/* ==========================================================================
   The Agency Standard — hosted edition.

   Theme lifted from revenue.inc: gold #B79455 as the one accent, deep slate
   #0F172A as ink, warm off-white #FDFCF8 as paper, and the terminal green
   #00FF41 kept for live/state signals only. Type is Satoshi, with Instrument
   Serif for editorial display and Fira Code for typed specimens, which is the
   pairing revenue.inc already runs.
   ========================================================================== */

/* Satoshi, Indian Type Foundry, via Fontshare. Self-hosted so the site keeps
   working offline and does not depend on a CDN staying up. Two variable files
   cover 300 to 900 in both styles: 86 KB for the whole family. */
@font-face {
  font-family: 'Satoshi';
  src: url('fonts/Satoshi-Variable.woff2') format('woff2-variations'),
       url('fonts/Satoshi-Variable.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Satoshi';
  src: url('fonts/Satoshi-VariableItalic.woff2') format('woff2-variations'),
       url('fonts/Satoshi-VariableItalic.woff2') format('woff2');
  font-weight: 300 900;
  font-style: italic;
  font-display: swap;
}

/* -------------------------------- tokens -------------------------------- */
:root {
  /* revenue.inc palette */
  --gold: #b79455;
  --gold-lo: #9d7d45;
  --gold-hi: #d4b478;
  --slate-950: #0a0f1a;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --paper-warm: #fdfcf8;
  --green: #00ff41;

  /* semantic, light */
  --bg: var(--paper-warm);
  --bg-2: #ffffff;
  --bg-3: var(--slate-50);
  --ink: var(--slate-900);
  --ink-2: var(--slate-600);
  --ink-3: var(--slate-500);
  --line: var(--slate-200);
  --line-2: var(--slate-100);
  --accent: var(--gold);
  --accent-ink: #6b5326;
  --on-accent: #ffffff;
  --glow: rgba(183, 148, 85, 0.16);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 8px -4px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.04), 0 12px 32px -12px rgba(15, 23, 42, 0.16);
  --shadow-lg: 0 4px 8px rgba(15, 23, 42, 0.05), 0 32px 64px -24px rgba(15, 23, 42, 0.24);

  /* type */
  --sans: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --serif: 'Instrument Serif', Charter, Georgia, 'Times New Roman', serif;
  --mono: 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;

  /* geometry, matching revenue.inc's generous radii */
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 22px;
  --r-xl: 32px;
  --measure: 36rem;
  --wide: 78rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* dark: explicit choice */
:root[data-theme='dark'] {
  --bg: var(--slate-950);
  --bg-2: #121a29;
  --bg-3: #16202f;
  --ink: #eef2f7;
  --ink-2: #a3b0c2;
  --ink-3: #74839a;
  --line: #22304a;
  --line-2: #1a2436;
  --accent: var(--gold-hi);
  --accent-ink: var(--gold-hi);
  --on-accent: var(--slate-950);
  --glow: rgba(212, 180, 120, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4), 0 32px 64px -24px rgba(0, 0, 0, 0.7);
}

/* dark: system default, unless the reader chose light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: var(--slate-950);
    --bg-2: #121a29;
    --bg-3: #16202f;
    --ink: #eef2f7;
    --ink-2: #a3b0c2;
    --ink-3: #74839a;
    --line: #22304a;
    --line-2: #1a2436;
    --accent: var(--gold-hi);
    --accent-ink: var(--gold-hi);
    --on-accent: var(--slate-950);
    --glow: rgba(212, 180, 120, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4), 0 32px 64px -24px rgba(0, 0, 0, 0.7);
  }
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-width: none;             /* no visible scrollbar anywhere */
  -ms-overflow-style: none;
}
html::-webkit-scrollbar, *::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.68;
  font-weight: 400;
  font-feature-settings: 'ss01', 'cv01';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; text-decoration: none; }
img, video, iframe { max-width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* -------------------------------- primitives -------------------------------- */
.eyebrow {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 clamp(1.25rem, 4vw, 2.5rem); }

/* reveal on scroll */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
[data-reveal].in { opacity: 1; transform: none; }

/* progress line */
#progress {
  position: fixed; inset: 0 auto auto 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--gold-lo), var(--gold), var(--gold-hi));
  z-index: 90; transition: width 0.12s linear;
}

/* -------------------------------- topbar -------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 0.85rem;
  height: 4rem; padding: 0 clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.topbar.stuck { border-bottom-color: var(--line); }

.wordmark {
  display: flex; align-items: center; gap: 0.55rem;
  font-weight: 700; font-size: 0.9375rem; letter-spacing: -0.015em;
  white-space: nowrap;
}
.wordmark .dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
  flex: none;
  transition: transform 0.3s var(--ease);
}
.wordmark:hover .dot { transform: scale(1.35); }
.wordmark .sub { color: var(--ink-3); font-weight: 500; }

.crumb {
  flex: 1; min-width: 0;
  font-size: 0.8125rem; font-weight: 500; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 2.25rem; padding: 0 0.85rem;
  font-family: inherit; font-size: 0.8125rem; font-weight: 600;
  color: var(--ink-2); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: all 0.22s var(--ease);
}
.btn:hover { color: var(--ink); border-color: var(--ink-3); background: var(--bg-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.solid { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.solid:hover { background: var(--gold-lo); border-color: var(--gold-lo); color: #fff; box-shadow: 0 6px 20px -6px var(--accent); }
.btn.icon { width: 2.25rem; padding: 0; justify-content: center; }
.btn svg { width: 1rem; height: 1rem; flex: none; }

/* theme toggle: a real switch, sun to moon */
#themeBtn .sun, #themeBtn .moon { transition: opacity 0.3s var(--ease), transform 0.4s var(--ease); }
#themeBtn .moon { display: none; }
:root[data-theme='dark'] #themeBtn .sun { display: none; }
:root[data-theme='dark'] #themeBtn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) #themeBtn .sun { display: none; }
  :root:not([data-theme='light']) #themeBtn .moon { display: block; }
}
#themeBtn:hover svg { transform: rotate(35deg); }

/* ================================== INDEX ================================== */
.hero { position: relative; padding: clamp(4rem, 11vw, 9rem) 0 clamp(2.5rem, 5vw, 4rem); overflow: hidden; }
.hero::before {
  content: ''; position: absolute; z-index: -1;
  top: -30%; left: 50%; transform: translateX(-50%);
  width: min(70rem, 130%); aspect-ratio: 2 / 1;
  background: radial-gradient(ellipse at center, var(--glow) 0%, transparent 62%);
  pointer-events: none;
}
.hero .kicker {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-ink);
  padding: 0.4rem 0.85rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-2);
}
.hero .kicker .live {
  width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(0, 255, 65, 0.6);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 255, 65, 0.55); }
  70% { box-shadow: 0 0 0 0.5rem rgba(0, 255, 65, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 255, 65, 0); }
}

.hero h1 {
  font-size: clamp(2.75rem, 9vw, 6.5rem);
  font-weight: 900; line-height: 0.94; letter-spacing: -0.035em;
  margin: 1.5rem 0 1.5rem;
}
.hero h1 em {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  letter-spacing: -0.01em; color: var(--accent-ink);
}
.hero .lede { font-size: clamp(1.0625rem, 2.1vw, 1.375rem); color: var(--ink-2); max-width: 40rem; line-height: 1.55; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 2rem; }
.hero .actions .btn { height: 2.75rem; padding: 0 1.35rem; font-size: 0.875rem; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1px; margin-top: clamp(2.5rem, 6vw, 4rem);
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.stats div { background: var(--bg); padding: 1.35rem 1.5rem; transition: background 0.25s var(--ease); }
.stats div:hover { background: var(--bg-2); }
.stats .n { display: block; font-size: 2.125rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stats .l { display: block; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-top: 0.5rem; }

/* toolbar */
.toolbar {
  position: sticky; top: 4rem; z-index: 40;
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 1rem 0; margin-top: 3rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.searchbox { position: relative; flex: 1; min-width: 13rem; }
.searchbox svg { position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: var(--ink-3); pointer-events: none; }
.searchbox input {
  width: 100%; height: 2.75rem; padding: 0 2.75rem 0 2.5rem;
  font-family: inherit; font-size: 0.9375rem; font-weight: 500;
  color: var(--ink); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 999px; outline: none;
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease);
}
.searchbox input::placeholder { color: var(--ink-3); font-weight: 400; }
.searchbox input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.searchbox kbd {
  position: absolute; right: 0.85rem; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-3);
  padding: 0.15rem 0.35rem; border: 1px solid var(--line); border-radius: 5px;
}
.searchbox input:focus ~ kbd { opacity: 0; }
.filters { display: flex; gap: 0.35rem; }
.filters .btn[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* cards */
.group { margin-top: 2.5rem; }
.grouphead { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.grouphead h2 { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.grouphead .n {
  font-size: 0.6875rem; font-weight: 700; color: var(--ink-3);
  padding: 0.1rem 0.45rem; border: 1px solid var(--line); border-radius: 999px;
}
.grouphead .hint { margin-left: auto; font-size: 0.8125rem; color: var(--ink-3); }
.grouphead::after { content: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: 1rem; }
.card {
  position: relative; display: flex; flex-direction: column;
  padding: 1.5rem 1.5rem 1.35rem;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; isolation: isolate;
  transition: transform 0.32s var(--ease), box-shadow 0.32s var(--ease), border-color 0.32s var(--ease);
}
.card::before {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: 0;
  background: radial-gradient(40rem 18rem at var(--mx, 50%) var(--my, 0%), var(--glow), transparent 65%);
  transition: opacity 0.32s var(--ease);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card:hover::before { opacity: 1; }
.card .no { font-family: var(--mono); font-size: 0.6875rem; font-weight: 500; color: var(--accent-ink); letter-spacing: 0.04em; }
.card h3 { font-size: 1.25rem; font-weight: 700; line-height: 1.22; letter-spacing: -0.02em; margin: 0.6rem 0 0.55rem; }
.card .epi { font-family: var(--serif); font-style: italic; font-size: 1.0625rem; line-height: 1.45; color: var(--ink-2); }
.card .meta { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; margin-top: auto; padding-top: 1.15rem; font-size: 0.75rem; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.card .meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line); }
.card .meta .has { color: var(--accent-ink); font-weight: 600; }
.card .go { position: absolute; top: 1.5rem; right: 1.5rem; width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); color: var(--ink-3); opacity: 0; transform: translateX(-4px); transition: all 0.32s var(--ease); }
.card:hover .go { opacity: 1; transform: none; color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.card .go svg { width: 0.8rem; height: 0.8rem; }

.tag {
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.2rem 0.45rem; border-radius: 5px; line-height: 1.4;
}
.tag.ext { color: var(--accent-ink); background: var(--glow); }
.tag.int { color: var(--ink-3); background: var(--bg-3); }

.noresults { padding: 5rem 0; text-align: center; color: var(--ink-3); }
.noresults strong { display: block; font-size: 1.125rem; color: var(--ink); margin-bottom: 0.4rem; }

/* ================================= PLAYBOOK ================================= */
.doc { display: grid; grid-template-columns: minmax(0, 1fr) 16rem; gap: clamp(2rem, 5vw, 4rem); max-width: var(--wide); margin: 0 auto; padding: 0 clamp(1.25rem, 4vw, 2.5rem) 7rem; }
@media (max-width: 64rem) { .doc { grid-template-columns: minmax(0, 1fr); } .doc aside.toc { display: none; } }

article { min-width: 0; max-width: var(--measure); }
@media (max-width: 64rem) { article { max-width: none; } }

/* masthead */
.masthead { padding: clamp(3rem, 7vw, 5rem) 0 2rem; }
.masthead .label {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-ink); padding: 0.4rem 0.8rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2);
}
.masthead h1 { font-size: clamp(2.125rem, 6vw, 3.75rem); font-weight: 900; line-height: 1.02; letter-spacing: -0.035em; margin: 1.25rem 0 1.25rem; }
.masthead .epigraph {
  font-family: var(--serif); font-style: italic; font-size: clamp(1.25rem, 2.6vw, 1.625rem);
  line-height: 1.35; color: var(--ink-2); padding-left: 1.15rem;
  border-left: 2px solid var(--accent);
}
.masthead .docmeta {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-top: 2rem; padding-top: 1.15rem; border-top: 1px solid var(--line);
  font-size: 0.75rem; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.masthead .docmeta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line); }

/* prose */
article p { margin: 0 0 1.1em; }
article > p:first-of-type { font-size: 1.1875rem; color: var(--ink-2); }
article ul, article ol { margin: 0 0 1.25em; padding-left: 1.3em; }
article li { margin-bottom: 0.45em; }
article li::marker { color: var(--accent); }
article hr { border: 0; height: 1px; background: var(--line); margin: 2.5rem 0; }
article strong { font-weight: 700; }
article a:not(.anchor) { color: var(--accent-ink); font-weight: 500; border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); transition: border-color 0.2s var(--ease); }
article a:not(.anchor):hover { border-bottom-color: var(--accent); }

/* part divider */
.part {
  position: relative; margin: 4.5rem 0 3rem; padding: 2rem 0 1.75rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  text-align: center;
}
.part-lbl { font-family: var(--mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase; color: var(--accent-ink); }
.part-ttl { font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 0.65rem; }

/* sections */
h3.sec { display: flex; align-items: baseline; gap: 0.7rem; margin: 3rem 0 1rem; scroll-margin-top: 5.5rem; }
h3.sec .sec-no { font-family: var(--mono); font-size: 0.875rem; font-weight: 500; color: var(--accent);
  white-space: nowrap; padding-top: 0.28rem; font-variant-numeric: tabular-nums;
  /* Standing alone without the numero sign, it needs a little help reading
     as a label rather than as the first word of the heading. */
  letter-spacing: 0.02em; }
h3.sec .sec-ttl { font-size: 1.4375rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
h3.sec .anchor { margin-left: auto; color: var(--line); font-family: var(--mono); opacity: 0; transition: opacity 0.2s var(--ease), color 0.2s var(--ease); }
h3.sec:hover .anchor { opacity: 1; }
h3.sec .anchor:hover { color: var(--accent); }
h4.sub, h3.sub { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; margin: 2rem 0 0.6rem; }

/* callout */
.callout {
  position: relative; margin: 2rem 0; padding: 1.5rem 1.6rem;
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--r);
}
.co-lbl { display: block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 0.65rem; }
.co-bd { font-family: var(--serif); font-style: italic; font-size: 1.1875rem; line-height: 1.45; }
.co-bd p { margin-bottom: 0.5em; }
.co-bd p:last-child { margin-bottom: 0; }

/* the last word */
.lastword {
  position: relative; margin: 3rem 0 0; padding: 2.5rem 2rem;
  background: var(--slate-900); color: var(--slate-100);
  border-radius: var(--r-lg); overflow: hidden; scroll-margin-top: 5.5rem;
}
.lastword::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(30rem 14rem at 80% -10%, rgba(183, 148, 85, 0.22), transparent 70%);
  pointer-events: none;
}
.lw-lbl { display: block; font-size: 0.625rem; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-hi); margin-bottom: 1rem; }
.lastword p { font-family: var(--serif); font-size: 1.25rem; line-height: 1.5; }
.lastword p:last-child { margin-bottom: 0; }

/* specimen */
.specimen { margin: 2rem 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.specimen figcaption { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1rem; background: var(--bg-3); border-bottom: 1px solid var(--line); }
.sp-lbl { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.sp-copy {
  margin-left: auto; display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: inherit; font-size: 0.6875rem; font-weight: 600; color: var(--ink-3);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.22rem 0.6rem; cursor: pointer; transition: all 0.2s var(--ease);
}
.sp-copy:hover { color: var(--accent-ink); border-color: var(--accent); background: var(--glow); }
.sp-copy.done { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.specimen pre { margin: 0; padding: 1.1rem 1.15rem; overflow-x: auto; }
.specimen code { font-family: var(--mono); font-size: 0.8125rem; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
article :not(pre) > code { font-family: var(--mono); font-size: 0.85em; background: var(--bg-3); padding: 0.12em 0.35em; border-radius: 5px; }

/* tables */
.tablewrap { margin: 2rem 0; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { padding: 0.75rem 0.95rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-2); }
thead th { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); background: var(--bg-3); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.18s var(--ease); }
tbody tr:hover { background: var(--bg-3); }

blockquote { margin: 1.75rem 0; padding-left: 1.15rem; border-left: 2px solid var(--line); font-family: var(--serif); font-style: italic; font-size: 1.125rem; color: var(--ink-2); }

/* figures */
figure.fig { margin: 2.5rem 0; }
figure.fig img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease); }
figure.fig a { display: block; }
figure.fig a:hover img { transform: scale(1.012); box-shadow: var(--shadow-md); }
figure figcaption { margin-top: 0.7rem; font-size: 0.8125rem; color: var(--ink-3); line-height: 1.5; }

/* video */
figure.video { margin: 2.75rem 0; }
.video-frame {
  position: relative; aspect-ratio: 16 / 9; background: var(--slate-950);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow-md);
}
.video-frame iframe, .video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
figure.video figcaption { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; margin-top: 0.85rem; }
.vlbl {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-ink); padding: 0.2rem 0.5rem; border-radius: 999px; background: var(--glow);
}
figure.video .vttl { font-weight: 600; color: var(--ink); }
figure.video .cap { color: var(--ink-3); font-size: 0.875rem; }
.video-fallback { margin-left: auto; font-size: 0.75rem; font-weight: 600; color: var(--ink-3); }
.video-fallback:hover { color: var(--accent-ink); }

/* unfilled slots */
.slot {
  margin: 2.25rem 0; padding: 1.35rem 1.5rem;
  border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: var(--r); background: color-mix(in srgb, var(--glow) 40%, transparent);
}
.slot-lbl { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink); }
.slot-ttl { font-size: 1rem; font-weight: 700; letter-spacing: -0.015em; margin: 0.4rem 0 0.35rem; }
.slot-bd { font-size: 0.9375rem; color: var(--ink-2); line-height: 1.55; }

/* designer notes */
.notes { margin-top: 4rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.notes summary { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); cursor: pointer; list-style: none; }
.notes summary::-webkit-details-marker { display: none; }
.notes summary::before { content: '+ '; color: var(--accent); }
.notes[open] summary::before { content: '– '; }
.notes[open] summary { color: var(--ink); margin-bottom: 1.25rem; }
.notes .inner { font-size: 0.9375rem; color: var(--ink-2); }

/* -------------------------------- TOC rail -------------------------------- */
aside.toc { position: sticky; top: 5.5rem; align-self: start; max-height: calc(100vh - 8rem); overflow-y: auto; padding: clamp(3rem, 7vw, 5rem) 0 3rem; }
aside.toc .tochead { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.85rem; }
aside.toc .track { position: relative; padding-left: 0.85rem; }
aside.toc .track::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--line); border-radius: 2px; }
aside.toc .thumb { position: absolute; left: 0; width: 2px; background: var(--accent); border-radius: 2px; transition: top 0.28s var(--ease), height 0.28s var(--ease); }
aside.toc a { display: block; padding: 0.34rem 0; font-size: 0.8125rem; line-height: 1.4; color: var(--ink-3); transition: color 0.2s var(--ease), transform 0.2s var(--ease); }
aside.toc a:hover { color: var(--ink); transform: translateX(2px); }
aside.toc a.part { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); margin-top: 0.85rem; }
aside.toc a.active { color: var(--accent-ink); font-weight: 600; }
aside.toc .no { font-family: var(--mono); font-size: 0.6875rem; color: var(--accent); margin-right: 0.35rem; }

/* -------------------------------- brand block -------------------------------- */
.brandblock { max-width: var(--wide); margin: 0 auto; padding: clamp(3rem, 6vw, 5rem) clamp(1.25rem, 4vw, 2.5rem) 4rem; }
.brandblock .inner { padding: clamp(2rem, 4vw, 3rem); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-xl); }
.brandblock .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 2rem; }
.brandblock h4 { display: flex; align-items: center; gap: 0.45rem; font-size: 1rem; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 0.5rem; }
.brandblock h4 .dot { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--accent); }
.brandblock p { font-size: 0.9375rem; color: var(--ink-2); line-height: 1.6; }
.brandblock .cta { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.85rem; font-size: 0.8125rem; font-weight: 600; color: var(--accent-ink); }
.brandblock .cta::after { content: '→'; transition: transform 0.25s var(--ease); }
.brandblock .cta:hover::after { transform: translateX(3px); }
.brandblock .foot { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 2.5rem; padding-top: 1.35rem; border-top: 1px solid var(--line); font-size: 0.75rem; color: var(--ink-3); }
.brandblock .foot .right { margin-left: auto; }

/* pager */
.pager { max-width: var(--wide); margin: 0 auto; padding: 0 clamp(1.25rem, 4vw, 2.5rem); display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 40rem) { .pager { grid-template-columns: 1fr; } }
.pager a { padding: 1.25rem 1.35rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); transition: all 0.28s var(--ease); }
.pager a:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pager .dir { display: block; font-size: 0.625rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.35rem; }
.pager .ttl { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.pager a.next { text-align: right; }
.pager span:empty { display: none; }

/* toast */
#toast {
  position: fixed; bottom: 1.75rem; left: 50%; transform: translate(-50%, 4rem);
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--slate-900); color: var(--slate-100);
  padding: 0.7rem 1.15rem; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; z-index: 95;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* back to top */
#toTop {
  position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 55;
  width: 2.75rem; height: 2.75rem; display: grid; place-items: center;
  background: var(--bg-2); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 50%; cursor: pointer;
  box-shadow: var(--shadow-sm); opacity: 0; transform: translateY(0.75rem);
  pointer-events: none; transition: all 0.3s var(--ease);
}
#toTop.show { opacity: 1; transform: none; pointer-events: auto; }
#toTop:hover { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
#toTop svg { width: 1rem; height: 1rem; }

/* ================================== PRINT ==================================
   ⌘P on any playbook gives a clean paginated PDF. This is the browser route,
   alongside the branded Typst build in pdfs/.
   ========================================================================== */
@media print {
  @page { size: A4; margin: 18mm 16mm 20mm; }

  :root {
    --bg: #fff; --bg-2: #fff; --bg-3: #f6f6f4;
    --ink: #000; --ink-2: #222; --ink-3: #555;
    --line: #bbb; --line-2: #ddd;
    --accent: #8a6f34; --accent-ink: #6b5326; --glow: transparent;
    --shadow-sm: none; --shadow-md: none; --shadow-lg: none;
  }

  html { scroll-behavior: auto; }
  body { background: #fff; font-size: 10.5pt; line-height: 1.5; }

  .topbar, aside.toc, #progress, .pager, .sp-copy, .video-fallback,
  .toolbar, #toast, #toTop, .notes, details, .card .go, .noprint { display: none !important; }

  [data-reveal] { opacity: 1 !important; transform: none !important; }

  .doc { display: block; max-width: none; padding: 0; }
  article { max-width: none; }
  .masthead { padding: 0 0 12pt; }
  .masthead h1 { font-size: 30pt; }
  .masthead .label { border: 0; padding: 0; background: none; }

  a { color: #000; border: 0 !important; }
  article a[href^='http']::after { content: ' (' attr(href) ')'; font-size: 8pt; color: #555; word-break: break-all; }

  h3.sec, .part, figure, .callout, .lastword, .specimen, table, .slot { break-inside: avoid; }
  .part { break-before: page; }
  .part:first-of-type { break-before: auto; }
  h3.sec { break-after: avoid; }
  p { orphans: 3; widows: 3; }

  .lastword { background: #000 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lastword::before { display: none; }
  .lw-lbl { color: #c9a868 !important; }

  /* An embedded player is a blank rectangle on paper. Print the link. */
  .video-frame { display: none; }
  figure.video figcaption { border: 1px solid #bbb; border-radius: 4px; padding: 8pt 10pt; }
  figure.video figcaption::after { content: 'Video. Watch it on the hosted page.'; display: block; width: 100%; font-size: 8pt; color: #555; }

  .brandblock { break-before: page; padding: 0; }
  .brandblock .inner { border: 0; padding: 0; }
}
