/* ============================================================
   reading.css — shared stylesheet for article pages
   Used by case.html (case studies) and post.html (blog).
   Sizes/spacing updated to match Figma (35:248):
   760 column, title 24, lede 18, body 16, h2 18,
   article gap 40, head gap 28, prose gap 26.
   Header trimmed to a single "← Back" (no kicker/byline).
   ============================================================ */

:root{
  --bg:#0f0f0e;          /* warm near-black */
  --fg:#e8e8e6;          /* body text */
  --strong:#ffffff;
  --muted:#9a9a92;       /* lede / captions / secondary */
  --faint:#6a6a64;       /* meta, labels */
  --line:#242422;        /* hairlines */
  --line-2:#33332e;
  --underline:#43433c;
  --tint:#1a1a17;
  --tint-2:#201f1c;
  --accent:#cdbfa6;
  --available:#3fbf7f;
  --blue:#7aa2f7;        /* external-link accent */
  --blue-strong:#a9c4ff; /* hover */

  --sans:"Geist",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,system-ui,sans-serif;
  --mono:"Geist Mono","SF Mono",ui-monospace,SFMono-Regular,Menlo,monospace;

  --frame:1024px;        /* outer frame — matches home (1024 / 32 gutters → 960) */
  --col:760px;           /* reading text column (incl. 40px padding → 680 text) */
  --wide:880px;          /* breakout figures */
  --fig:960px;           /* case-study image container — aligns with back/lang chrome */
}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family:var(--sans);
  font-size:16px;
  line-height:1.8;
  letter-spacing:-0.003em;
  font-feature-settings:"ss01","cv01";
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
::selection{background:#e8e8e6;color:#0f0f0e}

a{color:inherit}
a:focus-visible{outline:2px solid var(--fg);outline-offset:3px;border-radius:3px}

/* ---------- reading-progress bar ---------- */
.progress{
  position:fixed;top:0;left:0;height:2px;width:0;
  background:var(--accent);z-index:50;
  transition:width .1s linear;
}

/* ---------- back link (top, no chrome) ---------- */
.topbar .inner,
.toparea{
  max-width:var(--frame);margin:0 auto;padding:44px 32px 0;
  display:flex;align-items:center;justify-content:space-between;gap:16px;
}

/* ---------- language toggle ---------- */
.lang{display:inline-flex;align-items:center;gap:12px;margin-left:auto}
.lang-btn{
  font-family:var(--sans);font-size:12px;font-weight:500;letter-spacing:0.02em;line-height:1;
  color:var(--muted);background:none;border:1px solid transparent;border-radius:32px;
  padding:5px 12px;cursor:pointer;transition:color .15s ease,border-color .15s ease;
}
.lang-btn:hover{color:var(--fg)}
.lang-btn.is-active{color:var(--strong);border-color:#8f8f88;font-weight:600}
.lang-btn:focus-visible{outline:2px solid var(--fg);outline-offset:2px}
/* fixed pill: stays on scroll; bg-coloured container keeps it legible over images.
   Hover reproduces the home case-item surface (tint + press-scale); the pill has a
   permanent bg, so it can't use a behind-it ::before panel like the other controls. */
.back{
  position:fixed;z-index:60;top:36px;
  left:max(16px, calc((100vw - var(--frame)) / 2 + 19px));
  display:inline-flex;align-items:center;gap:9px;
  font-size:15px;font-weight:500;color:var(--muted);
  text-decoration:none;letter-spacing:-0.005em;
  background:var(--bg);border:1px solid var(--line);border-radius:999px;
  padding:8px 15px 8px 13px;
  box-shadow:0 1px 2px rgba(0,0,0,.22),0 10px 26px rgba(0,0,0,.26);
  transition:color .15s ease,border-color .18s cubic-bezier(.2,0,0,1),
             background .18s cubic-bezier(.2,0,0,1),transform .18s cubic-bezier(.2,0,0,1);
}
.back .arr{display:inline-block;transition:transform .18s cubic-bezier(.2,0,0,1)}
.back:hover{color:var(--fg)}
.back:hover .arr{transform:translateX(-3px)}
@media (hover:hover){
  .back:hover{background:#171613;border-color:var(--line-2)}
  .back:active{transform:scale(.99);background:#1b1a16}
}

/* ---------- article shell ---------- */
/* Variant A (default): chrome at 960 frame, text centered in a 680 column */
.article{
  max-width:var(--col);margin:0 auto;
  padding:48px 40px 40px;
  display:flex;flex-direction:column;gap:40px;
}

/* Variant B: meta rail (narrow, sticky) + body column, inside the 960 frame */
.article.read-sidebar{
  max-width:var(--frame);
  display:grid;grid-template-columns:232px minmax(0,1fr);gap:56px;
  padding:48px 32px 40px;
}
.read-sidebar .rail{position:sticky;top:40px;align-self:start;display:flex;flex-direction:column;gap:28px}
.read-sidebar .rail .meta{display:flex;flex-direction:column;gap:22px;border:0;padding:0}
.read-sidebar .body{display:flex;flex-direction:column;gap:40px;min-width:0}
/* keep figures inside the body column (no viewport breakout in this layout) */
.read-sidebar figure.wide{width:auto;margin-left:0;transform:none}

/* header block: title + lede */
.head{display:flex;flex-direction:column;gap:28px}
.title{
  font-size:24px;line-height:1.08;letter-spacing:-0.02em;
  font-weight:600;color:var(--strong);margin:0;text-wrap:balance;
}
.lede{
  font-size:18px;line-height:1.8;
  color:var(--muted);margin:0;text-wrap:pretty;
}

/* case-study meta grid */
.meta{
  display:grid;grid-template-columns:repeat(4,1fr);gap:20px 28px;
  padding-top:28px;border-top:1px solid var(--line);
}
.meta .cell{display:flex;flex-direction:column;gap:5px;min-width:0}
.meta .k{font-family:var(--mono);font-size:11px;letter-spacing:0.04em;text-transform:uppercase;color:var(--faint)}
.meta .v{font-size:15px;color:var(--fg);letter-spacing:-0.01em}

/* ---------- prose ---------- */
.prose{display:flex;flex-direction:column;gap:26px}
.prose > *{margin:0}
.prose p{font-size:16px;line-height:1.8;letter-spacing:0.01em;color:var(--fg);text-wrap:pretty}

.prose h2{
  font-size:18px;line-height:1.2;letter-spacing:-0.01em;font-weight:600;
  color:var(--strong);margin-top:8px;text-wrap:balance;
}
.prose h3{
  font-size:16px;line-height:1.3;letter-spacing:-0.01em;font-weight:550;
  color:var(--fg);margin-top:6px;
}
.prose a{
  color:var(--fg);text-decoration:underline;text-decoration-color:var(--underline);
  text-underline-offset:3px;text-decoration-thickness:1px;
  transition:text-decoration-color .15s ease,color .15s ease;
}
.prose a:hover{color:var(--strong);text-decoration-color:var(--fg)}

/* inline external link (blue + Geist arrow) — overrides .prose a */
.exlink,.prose a.exlink{
  color:var(--blue);text-decoration:underline;
  text-decoration-color:color-mix(in srgb,var(--blue) 32%,transparent);
  text-underline-offset:3px;text-decoration-thickness:1px;
  transition:color .15s ease,text-decoration-color .15s ease;
}
.exlink:hover,.prose a.exlink:hover{color:var(--blue-strong);text-decoration-color:var(--blue-strong)}
.exlink-ico{
  width:.92em;height:.92em;vertical-align:-0.09em;margin-left:2px;
  transition:transform .18s cubic-bezier(.2,0,0,1);
}
.exlink:hover .exlink-ico{transform:translate(1.5px,-1.5px)}

.prose strong{color:var(--strong);font-weight:550}
.prose em{font-style:italic}

/* drop cap (opt-in: <p class="lead-cap">) */
.lead-cap::first-letter{
  float:left;font-weight:600;font-size:2.9em;line-height:.82;
  padding:5px 9px 0 0;color:var(--strong);
}

/* lists */
.prose ul,.prose ol{display:flex;flex-direction:column;gap:10px;margin:0;padding-left:1.2em}
.prose li{margin:0;padding-left:.3em;font-size:16px;line-height:1.8}
.prose li::marker{color:var(--faint)}
.prose ul li::marker{content:"–  "}

/* blockquote / pull quote */
.prose blockquote{
  margin:6px 0;padding:2px 0 2px 22px;border-left:2px solid var(--accent);
  display:flex;flex-direction:column;gap:10px;
}
.prose blockquote p{
  font-size:18px;line-height:1.5;letter-spacing:-0.01em;color:var(--fg);margin:0;text-wrap:pretty;
}
.prose blockquote cite{
  font-style:normal;font-family:var(--mono);font-size:12.5px;color:var(--faint);
}

/* inline + block code */
.prose code{
  font-family:var(--mono);font-size:.85em;color:var(--fg);
  background:var(--tint-2);border:1px solid var(--line-2);border-radius:5px;padding:1px 6px;
}
.prose pre{
  margin:6px 0;padding:20px 22px;overflow:auto;
  background:var(--tint);border:1px solid var(--line);border-radius:10px;
  font-family:var(--mono);font-size:13.5px;line-height:1.7;color:var(--fg);
  -webkit-text-size-adjust:100%;
}
.prose pre code{background:none;border:0;padding:0;font-size:inherit;color:inherit}

/* rule / dinkus */
.prose hr,.rule{border:0;height:1px;background:var(--line);margin:22px 0}
.dinkus{border:0;text-align:center;color:var(--faint);font-family:var(--mono);margin:22px 0;letter-spacing:.6em}
.dinkus::before{content:"· · ·"}

/* ---------- figures (with breakout) ---------- */
figure{margin:6px 0}
figure.wide{width:min(var(--wide),92vw);margin-left:50%;transform:translateX(-50%)}

/* ---------- wide image container (all Variant A pages) ----------
   Across every reading page (case studies + blog), the text stays in
   the reading column, but top-level figures break out to the --fig
   (960) container, aligned with the back/language chrome. Small .ref
   benchmark figures and figures nested in .pair/.compare grids are
   left alone. The Variant B (.read-sidebar) layout is excluded — its
   images live inside the body column beside the meta rail. */
.article:not(.read-sidebar) > figure:not(.ref),
.article:not(.read-sidebar) > .prose > figure:not(.ref){
  width:min(var(--fig),94vw);
  margin-left:50%;transform:translateX(-50%);
}
.article:not(.read-sidebar) figcaption{text-align:center}
figure .frame{
  background:var(--tint);border:1px solid var(--line);border-radius:12px;overflow:hidden;
  aspect-ratio:16/9;display:flex;align-items:center;justify-content:center;
  outline:1px solid rgba(255,255,255,.05);outline-offset:-1px;
}
figure.tall .frame{aspect-ratio:4/3}
figure img{width:100%;height:100%;object-fit:cover;display:block}
figure .ph{font-family:var(--mono);font-size:11px;color:#48483f;letter-spacing:0}
figcaption{margin-top:12px;font-size:13.5px;color:var(--muted);line-height:1.5;text-align:center;text-wrap:pretty}
figure:not(.wide) figcaption{text-align:left}

.pair{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.pair .frame{aspect-ratio:1/1}

/* ---------- real screenshots & references (migrated case studies) ----------
   .shot    → keep the capture's natural aspect (don't cover-crop tall pages)
   .ref     → small benchmark figure; never larger/glossier than the work it supports
   .compare → labelled before/after, side by side (stacks on mobile) */
figure.shot .frame,
figure.ref .frame{aspect-ratio:auto}
figure.shot .frame img,
figure.ref .frame img{height:auto;object-fit:contain}
figure.ref{max-width:360px}
figure.ref figcaption{font-style:italic}

/* ---------- light-paper illustration plates (e.g. BBC Maestro) ----------
   The frame matches the artwork's own off-white so the letterboxing is
   invisible; art is centered at its natural size and never upscaled, so
   low-resolution pieces stay clean instead of being blown up to fill. */
figure.illo .frame{
  background:#ededeb;aspect-ratio:4/3;padding:24px;
  border-color:rgba(0,0,0,.08);outline-color:rgba(0,0,0,.04);
}
figure.illo .frame img{
  width:auto;height:auto;max-width:100%;max-height:100%;object-fit:contain;cursor:zoom-in;
}
figure.illo.tall .frame{aspect-ratio:1/1}

/* ---------- video figures (prototype walkthroughs) ----------
   .video          → generic embedded video, fills the frame
   .video.phone    → portrait phone prototype, centered on a dark frame
                     with a device-style radius and a capped height */
figure video{display:block;width:100%;height:auto}
figure.video .frame{aspect-ratio:auto;background:#0c0c0b;padding:0}
figure.video.phone .frame{padding:24px;aspect-ratio:auto}
figure.video.phone video{
  width:auto;max-width:100%;max-height:80vh;margin:auto;
  border-radius:22px;box-shadow:0 10px 40px rgba(0,0,0,.45);
}
.compare{display:grid;grid-template-columns:1fr 1fr;gap:20px;align-items:center;margin:6px 0}
.compare figure{margin:0}
.compare .tag{display:block;font-family:var(--mono);font-size:11px;letter-spacing:.04em;
  text-transform:uppercase;color:var(--faint);margin-bottom:8px}

/* metrics row (case study) */
.metrics{
  display:grid;grid-template-columns:repeat(3,1fr);gap:24px;
  margin:6px 0;padding:28px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line);
}
.metrics .m{display:flex;flex-direction:column;gap:6px}
.metrics .num{font-size:28px;letter-spacing:-0.03em;color:var(--strong);font-variant-numeric:tabular-nums}
.metrics .cap{font-size:13.5px;color:var(--muted);line-height:1.45}

/* ---------- footnotes ---------- */
.fn-ref{font-family:var(--mono);font-size:.7em;vertical-align:super;line-height:0;color:var(--accent);text-decoration:none;padding:0 1px}
.footnotes{
  margin-top:8px;padding-top:24px;border-top:1px solid var(--line);
  font-size:14.5px;color:var(--muted);
}
.footnotes ol{margin:0;padding-left:1.4em}
.footnotes li{margin:0 0 12px;line-height:1.6}
.footnotes li::marker{color:var(--faint);font-family:var(--mono);font-size:12px}
.footnotes a{color:var(--fg)}

/* ---------- article footer ---------- */
.endmark{color:var(--faint);font-family:var(--mono);font-size:12px;letter-spacing:.3em}
.next{
  display:flex;justify-content:space-between;align-items:baseline;gap:16px;flex-wrap:wrap;
  margin-top:8px;padding-top:26px;border-top:1px solid var(--line);
}
.next a{text-decoration:none;color:var(--fg);font-weight:450;letter-spacing:-0.01em;transition:color .15s ease}
.next a:hover{color:var(--strong)}
.next .k{font-family:var(--mono);font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--faint);display:block;margin-bottom:6px}
.next .to-top{font-family:var(--mono);font-size:12.5px;color:var(--faint)}
.next .to-top:hover{color:var(--muted)}

.site-foot{
  max-width:var(--frame);margin:0 auto;
  padding:40px 32px 64px;
  font-family:var(--mono);font-size:11.5px;color:var(--faint);letter-spacing:0;
  display:flex;justify-content:space-between;gap:16px;flex-wrap:wrap;
}

/* ---------- responsive ---------- */
@media (max-width:720px){
  .topbar .inner,.toparea{padding:32px 22px 0}
  .back{top:20px;left:14px}
  .article{padding:36px 22px 32px}
  .article.read-sidebar{grid-template-columns:1fr;gap:32px;padding:36px 22px 32px}
  .read-sidebar .rail{position:static}
  .meta{grid-template-columns:1fr 1fr;gap:18px 24px}
  .metrics{grid-template-columns:1fr;gap:18px}
  .pair{grid-template-columns:1fr}
  .compare{grid-template-columns:1fr;gap:24px}
  figure.wide{width:100%;margin-left:0;transform:none}
  .article:not(.read-sidebar) > figure:not(.ref),
  .article:not(.read-sidebar) > .prose > figure:not(.ref){width:100%;margin-left:0;transform:none}
  .site-foot{padding:32px 22px 56px}
}
@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  *{transition:none!important}
  .progress{transition:none}
}

/* ---------- image lightbox (case-study figures) ----------
   Click a figure image to zoom it into a centered overlay; lightbox.js
   animates it from the thumbnail's exact position (FLIP). Reduced-motion
   users get an instant open via the global rule above. */
.article figure .frame img{cursor:zoom-in}
.lb-backdrop{
  position:fixed;inset:0;z-index:1000;border:0;
  background:rgba(8,8,7,.88);
  -webkit-backdrop-filter:blur(7px);backdrop-filter:blur(7px);
  opacity:0;transition:opacity .34s ease;cursor:zoom-out;
}
.lb-backdrop.is-open{opacity:1}
.lb-img{
  position:fixed;margin:0;display:block;object-fit:contain;
  border-radius:10px;cursor:zoom-out;background:var(--tint);
  box-shadow:0 24px 70px rgba(0,0,0,.55);will-change:left,top,width,height;
  transition:left .34s cubic-bezier(.2,0,0,1),top .34s cubic-bezier(.2,0,0,1),
             width .34s cubic-bezier(.2,0,0,1),height .34s cubic-bezier(.2,0,0,1);
}
.lb-hint{
  position:fixed;left:0;right:0;bottom:22px;text-align:center;pointer-events:none;
  font-family:var(--mono);font-size:11px;letter-spacing:.04em;color:var(--faint);
  opacity:0;transition:opacity .3s ease .08s;
}
.lb-backdrop.is-open .lb-hint{opacity:.85}

/* ---------- unified control hover (home case-item panel) ----------
   The same hover as the home selected-work items: a soft tinted panel fades +
   grows in behind the control (same #171613 surface, --line ring and easing),
   with a small press-scale. Applied to the language toggle and the footer
   next/top links; the .back pill reproduces the surface via its own background. */
.lang-btn,.next a{
  position:relative;isolation:isolate;
  transition:color .15s ease,border-color .15s ease,transform .18s cubic-bezier(.2,0,0,1);
}
.next a{display:inline-block}
.lang-btn::before,.next a::before{
  content:"";position:absolute;z-index:-1;pointer-events:none;
  background:#171613;box-shadow:inset 0 0 0 1px var(--line);
  opacity:0;transform:scale(.98);transform-origin:center;
  transition:opacity .18s cubic-bezier(.2,0,0,1),transform .18s cubic-bezier(.2,0,0,1);
}
.lang-btn::before{inset:0;border-radius:inherit}
.next a::before{inset:-6px -11px;border-radius:11px}
@media (hover:hover){
  .lang-btn:hover::before,.next a:hover::before{opacity:1;transform:scale(1)}
  .lang-btn:active,.next a:active{transform:scale(.99)}
  .lang-btn:active::before,.next a:active::before{background:#1b1a16}
}
