/* Mood board tokens: ChatGPT black on warm paper, printed like a 1984 ad. */
:root {
  --paper: #F1EEE8;
  --stock: #E6E2DA;      /* uncoated interior */
  --linen: #D9D3C7;      /* cloth cover */
  --ink: #0D0D0D;
  --graphite: #2F2F2F;
  --mute: #6b675f;
  --rule: rgba(13,13,13,.18);
  --highlight: #F4EE2A;
  --signal: #F26A1B;
  --white: #FFFFFF;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --caps: Anton, Impact, "Arial Narrow", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ink); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------- Stage: the whole screen is the magazine ---------- */
.stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--ink); overflow: hidden; touch-action: none; }
#book-holder { position: relative; }
#book { touch-action: none; }
.stf__parent { margin: 0 auto; }
.stf__block { filter: drop-shadow(0 18px 40px rgba(0,0,0,.55)); }
.stage.portrait .stf__block { filter: none; }

/* ---------- Pages ---------- */
.page {
  position: relative;
  width: var(--pw); height: var(--ph);
  background: var(--stock);
  color: var(--ink);
  overflow: hidden;
  container-type: inline-size;
  --pad: clamp(20px, 7cqw, 44px);
  --body: clamp(14px, 4.15cqw, 17px);
  --small: clamp(10px, 3cqw, 12px);
}
/* toothy uncoated stock: the recycled-paper scan, warm, behind the content */
.page::before { content: ''; position: absolute; inset: 0; background: url('paper.jpg') center / cover; opacity: .55; pointer-events: none; z-index: 0; }
.page::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(rgba(0,0,0,.05) .6px, transparent .6px) 0 0 / 3px 3px; }
.page > * { position: relative; z-index: 2; }

/* running head + folio, sans, "official" */
.head { display: flex; justify-content: space-between; align-items: baseline; padding: calc(var(--pad) * .7) var(--pad) 0; font-size: var(--small); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--graphite); }
.folio { position: absolute; left: var(--pad); right: var(--pad); bottom: calc(var(--pad) * .6); display: flex; justify-content: space-between; font-size: var(--small); color: var(--graphite); letter-spacing: .04em; font-variant-numeric: tabular-nums; z-index: 2; border-top: 1px solid var(--rule); padding-top: 8px; }

/* ---------- Cover A: block caps on cloth ---------- */
.fill { height: 100%; width: 100%; display: flex; flex-direction: column; }
.page.cover { background: var(--linen); background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.06) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 1px, transparent 1px 3px); }
.page.cover .fill { align-items: center; justify-content: space-between; text-align: center; padding: 13% 9%; }
.page.cover::before { opacity: .35; }
.page.cover::after { display: none; }
.cover .caps-small { font-family: var(--caps); font-size: clamp(11px, 3.4cqw, 15px); letter-spacing: .14em; color: #1A1A1A; text-transform: uppercase; line-height: 1.5; max-width: 90%; }
.cover .caps-big { font-family: var(--caps); font-size: clamp(40px, 15.5cqw, 84px); line-height: .92; color: #1A1A1A; text-transform: uppercase; filter: blur(.2px); display: flex; flex-direction: column; align-items: center; }
.cover .caps-big span { white-space: nowrap; }
.cover .caps-big .accent { color: #10A37F; }
.cover .caps-mid { font-family: var(--caps); font-size: clamp(22px, 8.2cqw, 46px); line-height: 1; color: #1A1A1A; text-transform: uppercase; margin-top: 6%; letter-spacing: .02em; }
.cover .stack { display: flex; flex-direction: column; align-items: center; }
.page.cover.back .fill { justify-content: flex-end; }
.page.cover.back .caps-small { margin-bottom: 4%; }

/* ---------- Title page B: split sentence on flat signal ---------- */
.page.signal { background: var(--signal); }
.page.signal .fill { justify-content: space-between; align-items: center; text-align: center; padding: 10% 9%; }
.page.signal::before, .page.signal::after { display: none; }
.page.signal .line { font-family: var(--serif); font-size: clamp(34px, 12cqw, 64px); line-height: .95; letter-spacing: -.035em; color: var(--ink); text-wrap: balance; }
.page.signal .dot { width: 9%; aspect-ratio: 1; background: var(--ink); border-radius: 50%; }

/* ---------- Contents ---------- */
.contents .toc { padding: 0 var(--pad); display: flex; flex-direction: column; }
.toc-item { display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--rule); padding: clamp(6px, 1.8cqw, 10px) 0; font-family: var(--serif); font-size: clamp(16px, 5cqw, 21px); letter-spacing: -.02em; color: var(--ink); }
.toc-item .n { font-family: var(--sans); font-size: var(--small); font-weight: 600; min-width: 2.2em; color: var(--graphite); font-variant-numeric: tabular-nums; }
.toc-item .p { margin-left: auto; font-family: var(--sans); font-size: var(--small); color: var(--graphite); font-variant-numeric: tabular-nums; }
.toc-item.locked .t { color: transparent; text-shadow: 0 0 18px rgba(13,13,13,.5), 0 0 8px rgba(13,13,13,.3); }

/* ---------- Chapter pages: flush-left serif headline, sans body ---------- */
.chapter { padding: 0 var(--pad); display: flex; flex-direction: column; }
.chapter .num { font-family: var(--caps); font-size: clamp(22px, 7cqw, 34px); line-height: 1; color: var(--ink); margin: clamp(14px, 4cqw, 26px) 0 clamp(6px, 1.6cqw, 10px); }
.chapter h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(30px, 9.4cqw, 46px); line-height: .98; letter-spacing: -.035em; margin: 0 0 clamp(14px, 4cqw, 22px); text-wrap: balance; }
.chapter h2.plain { margin-top: clamp(14px, 4cqw, 26px); }
.body { font-size: var(--body); line-height: 1.55; color: var(--ink); }
.body p { margin: 0 0 .75em; }
.body strong { font-weight: 500; background: var(--highlight); padding: 0 .14em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.body em { color: var(--graphite); }
.body blockquote { margin: .2em 0 .9em; padding: .1em 0 .1em .9em; border-left: 2px solid var(--ink); font-family: var(--serif); font-size: 1.12em; line-height: 1.35; letter-spacing: -.01em; }
.body blockquote p { margin: 0; }
.body table { width: 100%; border-collapse: collapse; margin: .2em 0 .9em; font-size: .93em; line-height: 1.4; }
.body th { text-align: left; font-size: .75em; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--graphite); }
.body th, .body td { border-bottom: 1px solid var(--rule); padding: .35em .4em .35em 0; }
.body td:first-child { font-weight: 600; }
.body .note { color: var(--graphite); font-size: .8em; padding-top: .6em; }

.chapter .num.small { font-family: var(--sans); font-size: var(--small); font-weight: 600; letter-spacing: .12em; }
.body h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(20px, 6.2cqw, 28px); line-height: 1.05; letter-spacing: -.025em; margin: .9em 0 .35em; }
.body h3:first-child { margin-top: 0; }
.body .label { font-family: var(--sans); font-size: .8em; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--graphite); margin: .6em 0 .3em; }
.body .prompt { font-family: var(--serif); font-size: 1.1em; line-height: 1.35; letter-spacing: -.01em; padding-left: .9em; border-left: 2px solid var(--ink); margin-bottom: .9em; }
.body .step { margin-bottom: .35em; }
.body ol, .body ul { margin: 0 0 .75em; padding-left: 1.3em; }
.body li { margin-bottom: .25em; }
.body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: rgba(13,13,13,.06); padding: .05em .3em; }
.body blockquote.callout { border-left-color: transparent; background: var(--highlight); padding: .55em .8em; font-family: var(--sans); font-size: .95em; line-height: 1.45; }
.body blockquote.callout strong { background: none; padding: 0; font-weight: 600; }
.gated .body code, .gated .body .callout { background: rgba(13,13,13,.08); }

/* ---------- Screenshot pages: image low, caption on the baseline ---------- */
.shot { position: absolute; left: var(--pad); right: var(--pad); top: calc(var(--pad) * 2.3); bottom: calc(var(--pad) * 1.9); margin: 0; display: flex; flex-direction: column; }
.shot .frame { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.shot .frame img { width: 100%; max-height: 100%; object-fit: contain; object-position: center; display: block; border-radius: 8px; }
.shot .caption { font-size: var(--small); line-height: 1.5; color: var(--graphite); text-align: right; padding: clamp(10px, 3cqw, 16px) 0 0; flex: none; }

/* endpaper */
.page.endpaper .fill { align-items: center; justify-content: flex-end; padding: 12%; }
.page.endpaper span { font-family: var(--caps); font-size: clamp(12px, 3.6cqw, 16px); letter-spacing: .14em; text-transform: uppercase; color: var(--graphite); }

/* ---------- Locked pages: everything blurred, pages still turn ---------- */
.gated .num, .gated h2, .gated .body, .gated .body *, .gated .caption { color: transparent !important; text-shadow: 0 0 26px rgba(13,13,13,.5), 0 0 12px rgba(13,13,13,.35); user-select: none; }
.gated .body { opacity: .85; }
.gated .body strong { background: rgba(244,238,42,.65); }
.gated .body blockquote { border-left-color: rgba(13,13,13,.4); }

/* ---------- Chrome ---------- */
.stage.portrait .folio { display: none; }   /* on phones the controls float over the page foot */
.chrome { position: fixed; left: 0; right: 0; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; justify-content: center; align-items: center; gap: 10px; z-index: 30; pointer-events: none; }
.chrome > * { pointer-events: auto; }
.chrome-button { width: 40px; height: 40px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: rgba(13,13,13,.55); color: var(--paper); font-size: 16px; backdrop-filter: blur(6px); }
.chrome-button:hover { background: rgba(13,13,13,.85); }
.chrome-counter { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: rgba(13,13,13,.55); color: var(--paper); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; backdrop-filter: blur(6px); font-variant-numeric: tabular-nums; }

/* ---------- The one card over the book: one line, one field, one button ---------- */
.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 40; padding: 20px 16px 76px; }
.gate-card { pointer-events: auto; width: min(420px, 100%); background: var(--white); color: var(--ink); border-radius: 16px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.35); font-family: var(--sans); }
.gate-card h2 { font-family: var(--sans); font-weight: 600; font-size: 18px; line-height: 1.35; letter-spacing: -.01em; margin: 0 0 14px; text-wrap: balance; }
.gate-card h2 b { font-weight: 600; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 1.5px solid #cfcac1; border-radius: 10px; background: var(--white); color: var(--ink); font: inherit; font-size: 16px; }
.row input::placeholder { color: #9a958c; }
.row input:focus { outline: none; border-color: var(--ink); }
.code-input { letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.primary-button { height: 48px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--ink); color: var(--white); font-size: 15px; font-weight: 600; white-space: nowrap; }
.primary-button:hover { background: var(--graphite); }
.primary-button:disabled { background: #cfcac1; color: var(--white); }
.text-button { margin-top: 10px; padding: 0; height: auto; border: 0; background: none; font-size: 13px; color: var(--graphite); text-decoration: underline; text-underline-offset: 3px; }
.field-error { font-size: 13px; color: #b3261e; margin: 10px 0 0; }
.gate-note { font-size: 13px; line-height: 1.5; color: var(--ink); background: var(--highlight); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; }
.gate-note code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
#unlocked-step .primary-button { width: 100%; }
@media (max-width: 700px) { .gate { align-items: flex-end; padding: 12px 10px 74px; } .row { flex-direction: column; } .primary-button { width: 100%; } }

/* ---------- Contents dialog ---------- */
dialog { background: var(--paper); color: var(--ink); padding: 24px; border: 1.5px solid var(--ink); border-radius: 0; width: min(440px, calc(100% - 32px)); max-height: 85dvh; }
dialog::backdrop { background: rgba(13,13,13,.6); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; }
dialog .chrome-button { background: var(--ink); border-color: var(--ink); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--graphite); }
dialog h2 { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: .95; letter-spacing: -.035em; margin: 14px 0 18px; }
dialog .toc-item { font-size: 19px; padding: 10px 0; }
dialog .toc-item .n, dialog .toc-item .p { font-size: 11px; }
.error { position: fixed; inset: auto 0 40%; text-align: center; color: var(--paper); z-index: 50; }
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
