/* ============================================================
   RIV//LUX — document pages (Journal)
   Inherits the palette and type scale from main.css.
   ============================================================ */

body.doc {
  background:
    radial-gradient(120vh 80vh at 78% -10%, rgba(169,138,255,.10), transparent 60%),
    radial-gradient(100vh 70vh at 5% 8%, rgba(255,83,55,.08), transparent 62%),
    var(--ink);
  min-height:100vh;
  display:flex; flex-direction:column;
  overflow-x:hidden;
}
body.doc .nav { position:sticky; }

.doc-main {
  flex:1; width:100%; max-width:760px;
  margin:0 auto; padding:16vh clamp(1.2rem,5vw,2rem) 8rem;
}

.crumbs {
  font-family:var(--mono); font-size:.66rem; letter-spacing:.2em; text-transform:uppercase;
  color:var(--muted); margin-bottom:2rem;
}
.crumbs a { color:var(--muted); text-decoration:none; }
.crumbs a:hover { color:var(--gold); }
.crumbs span { margin:0 .5rem; opacity:.5; }

.post-title {
  font-weight:900; font-size:clamp(2.1rem,5.6vw,3.9rem); line-height:1.02;
  letter-spacing:-.03em; text-transform:uppercase; margin:1.2rem 0 1rem;
  overflow-wrap:break-word;
}
.post-meta {
  font-family:var(--mono); font-size:.68rem; letter-spacing:.16em; text-transform:uppercase;
  color:var(--muted); padding-bottom:2.2rem; border-bottom:1px solid var(--line);
}
.doc-sub { color:var(--muted); font-size:1.02rem; line-height:1.7; max-width:56ch; }
.doc-head { margin-bottom:4rem; }

/* ---------- prose ---------- */
.prose { padding-top:2.6rem; font-size:1.06rem; line-height:1.78; color:#ddd9d0; }
.prose > * + * { margin-top:1.35em; }
.prose h2 {
  font-weight:900; font-size:clamp(1.4rem,3vw,1.95rem); line-height:1.15; letter-spacing:-.02em;
  color:var(--paper); margin-top:2.6em; text-transform:uppercase;
}
.prose h3 {
  font-weight:700; font-size:clamp(1.1rem,2.2vw,1.35rem); color:var(--paper);
  margin-top:2em; letter-spacing:-.01em;
}
.prose a { color:var(--gold); text-decoration:none; border-bottom:1px solid rgba(243,172,63,.35); }
.prose a:hover { border-bottom-color:var(--gold); }
.prose strong { color:var(--white); font-weight:600; }
.prose img { max-width:100%; height:auto; border-radius:12px; border:1px solid var(--line); display:block; }
.prose hr { border:none; border-top:1px solid var(--line); margin:3em 0; }
.prose ul, .prose ol { padding-left:1.3em; }
.prose li + li { margin-top:.5em; }
.prose li::marker { color:var(--gold); }
.prose blockquote {
  border-left:2px solid var(--gold); padding:.2em 0 .2em 1.3em;
  color:var(--paper); font-style:italic;
}
.prose code {
  font-family:var(--mono); font-size:.86em; background:rgba(245,241,232,.08);
  padding:.15em .45em; border-radius:5px; color:var(--aqua);
}
.md-pre {
  background:rgba(2,2,3,.7); border:1px solid var(--line); border-radius:12px;
  padding:1.15rem 1.3rem; overflow-x:auto; font-size:.84rem; line-height:1.6;
}
.md-pre code { background:none; padding:0; color:var(--paper); font-size:inherit; }

.tags { display:flex; flex-wrap:wrap; gap:.5rem; list-style:none; padding:0; margin:3rem 0 0; }
.tags li {
  font-family:var(--mono); font-size:.6rem; letter-spacing:.2em; text-transform:uppercase;
  color:var(--muted); border:1px solid var(--line); border-radius:99px; padding:.45rem .85rem;
}

/* ---------- post CTA ---------- */
.post-cta {
  margin-top:4.5rem; padding:2.2rem clamp(1.3rem,4vw,2.2rem);
  border:1px solid var(--line); border-radius:16px; background:var(--panel);
}
.post-cta h2 {
  font-weight:900; font-size:clamp(1.3rem,3vw,1.7rem); text-transform:uppercase;
  letter-spacing:-.02em; margin-bottom:.7rem;
}
.post-cta p { color:var(--muted); line-height:1.65; margin-bottom:1.5rem; max-width:48ch; }

/* ---------- index list ---------- */
.post-list { list-style:none; padding:0; display:flex; flex-direction:column; gap:1rem; }
.post-card {
  display:flex; flex-direction:column; gap:.5rem;
  padding:1.8rem clamp(1.2rem,3vw,1.8rem); border-radius:14px;
  border:1px solid var(--line); background:var(--panel);
  text-decoration:none; color:var(--paper); transition:border-color .35s, transform .35s var(--ease);
}
.post-card:hover { border-color:var(--line-hot); transform:translateY(-3px); }
.post-card-meta {
  font-family:var(--mono); font-size:.62rem; letter-spacing:.2em;
  text-transform:uppercase; color:var(--gold);
}
.post-card-title { font-weight:900; font-size:clamp(1.3rem,3vw,1.8rem); letter-spacing:-.02em; line-height:1.15; }
.post-card-desc { color:var(--muted); line-height:1.6; font-size:.95rem; }
.post-card-go {
  margin-top:.5rem; font-size:.7rem; font-weight:600; letter-spacing:.22em;
  text-transform:uppercase; opacity:.75;
}
.post-card:hover .post-card-go { opacity:1; }
.post-card-go i { font-style:normal; display:inline-block; transition:transform .3s var(--ease); }
.post-card:hover .post-card-go i { transform:translateX(4px); }

/* ---------- footer ---------- */
.doc-foot {
  border-top:1px solid var(--line); padding:2rem clamp(1.2rem,5vw,3rem);
  display:flex; gap:1.4rem; flex-wrap:wrap; align-items:center;
  font-size:.72rem; letter-spacing:.1em; color:var(--muted);
}
.doc-foot a { color:var(--paper); text-decoration:none; }
.doc-foot a:hover { color:var(--gold); }

@media (max-width:560px) {
  .doc-main { padding-top:12vh; }
  .prose { font-size:1rem; }
}

/* ---------- tables ---------- */
/* Wide tables scroll inside their own box so the page body never does. */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; border:1px solid var(--line); border-radius:12px; }
.prose table { width:100%; border-collapse:collapse; font-size:.94rem; min-width:34rem; }
.prose thead th {
  font-family:var(--mono); font-size:.62rem; letter-spacing:.18em; text-transform:uppercase;
  color:var(--muted); text-align:left; font-weight:400;
  padding:.9rem 1rem; border-bottom:1px solid var(--line); white-space:nowrap;
}
.prose tbody td { padding:.85rem 1rem; border-bottom:1px solid rgba(255,255,255,.05); vertical-align:top; }
.prose tbody tr:last-child td { border-bottom:none; }
.prose tbody td:first-child { color:var(--paper); }

/* ---------- landing/service page bits ---------- */
.page-stamp {
  margin-top:3rem; padding-top:1.4rem; border-top:1px solid var(--line);
  font-size:.64rem; letter-spacing:.18em; text-transform:uppercase; color:var(--muted);
}

/* ---------- read-aloud player ---------- */
/* Server-rendered hidden; js/readaloud.js reveals it only where
   SpeechSynthesis actually exists, so no browser gets a dead button. */
.listen {
  margin-top:2.2rem; padding:1rem 1.1rem .9rem;
  border:1px solid var(--line); border-radius:14px;
  background:var(--panel); backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
}
.listen[hidden] { display:none; }
.listen.is-active { border-color:rgba(243,172,63,.42); }
.listen-row { display:flex; align-items:center; gap:.75rem; flex-wrap:wrap; }

.listen-btn {
  display:inline-flex; align-items:center; gap:.6rem;
  padding:.62rem 1rem; border-radius:999px; cursor:pointer;
  background:transparent; border:1px solid var(--line-hot); color:var(--paper);
  font-family:var(--mono); font-size:.68rem; letter-spacing:.16em; text-transform:uppercase;
  transition:border-color .25s, background .25s, color .25s;
}
.listen-btn:hover { border-color:var(--gold); color:var(--gold); }
.listen-btn:focus-visible { outline:2px solid var(--gold); outline-offset:3px; }

/* Triangle → two bars, driven by the button's own pressed state. */
.listen-ico {
  width:0; height:0; flex:none;
  border-left:9px solid currentColor; border-top:6px solid transparent; border-bottom:6px solid transparent;
  transition:border-color .2s;
}
.listen-btn[aria-pressed="true"] .listen-ico {
  width:9px; height:12px; border:none;
  background:linear-gradient(to right, currentColor 0 3px, transparent 3px 6px, currentColor 6px 9px);
}
.listen-btn[aria-pressed="true"] { border-color:var(--gold); color:var(--gold); }

.listen-panel { display:flex; align-items:center; gap:.4rem; flex-wrap:wrap; }
.listen-panel[hidden] { display:none; }
.listen-panel button {
  min-width:2.1rem; height:2.1rem; padding:0 .5rem; border-radius:8px; cursor:pointer;
  background:transparent; border:1px solid var(--line); color:var(--muted);
  font-family:var(--mono); font-size:.66rem; line-height:1;
  transition:border-color .2s, color .2s;
}
.listen-panel button:hover { border-color:var(--line-hot); color:var(--paper); }
.listen-panel button:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }
.listen-panel select {
  max-width:13rem; height:2.1rem; padding:0 .5rem; border-radius:8px; cursor:pointer;
  background:rgba(0,0,0,.35); border:1px solid var(--line); color:var(--muted);
  font-family:var(--mono); font-size:.64rem;
}
.listen-panel select:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }

.listen-bar { display:block; margin-top:.85rem; height:2px; background:rgba(245,241,232,.1); border-radius:2px; overflow:hidden; }
.listen-bar i { display:block; height:100%; background:var(--grad); transform:scaleX(0); transform-origin:left; transition:transform .35s linear; }
.listen-status {
  margin-top:.55rem; min-height:1em;
  font-family:var(--mono); font-size:.6rem; letter-spacing:.18em; text-transform:uppercase; color:var(--muted);
}

/* Follow-along. Kept to a rail and a lift in text colour — a filled
   highlight behind body copy fights the page for 7 minutes straight. */
.prose .is-reading, .post-title.is-reading {
  position:relative; color:var(--paper);
}
.prose .is-reading::before {
  content:''; position:absolute; left:-1.1rem; top:.15em; bottom:.15em; width:2px;
  background:var(--gold); border-radius:2px;
  pointer-events:none;   /* decorative: never let it hit-test over the prose links */
}
.prose li.is-reading::before { left:-1.9rem; }
@media (prefers-reduced-motion: reduce) {
  .listen-bar i { transition:none; }
}
@media (max-width:560px) {
  .listen-panel select { max-width:100%; flex:1 1 100%; order:9; }
}
/* Finger-sized controls. Two arms on purpose: the width query is what a
   phone actually hits, and the pointer query catches touch tablets and
   touchscreen laptops that are wider than the breakpoint. 34px clears
   WCAG's 24px minimum but is a fiddly target for a thumb; 44px is the
   size both Apple and Android ask for. */
@media (max-width:560px), (pointer: coarse) {
  .listen-btn { padding:.8rem 1.1rem; }
  .listen-panel button { min-width:2.75rem; height:2.75rem; }
  .listen-panel select { height:2.75rem; }
}
