/* ─────────────────────────────────────────────────────────────────────────
   Paper night: unofficial same-evening worked solutions for NSC papers.
   Plan and runbook: docs/38-paper-night.md. Visual rules: ../DESIGN.md.

   Why a small sheet of its own and not ../styles.css: the homepage sheet is
   ~4,000 lines of film, lab and pricing, and these pages are read on a phone
   on mobile data at 19:00 the night of a paper. The learn/ pages set the
   same precedent (self-contained). The TOKENS below are copied from
   ../styles.css verbatim; if a token changes there, change it here.

   Gold contract, applied to this page: gold marks what has been OBSERVED.
   Here that is exactly one thing: a solution a person has checked (the
   "Checked" stamp, the hub's "Up, checked" status). A mark allocation is the
   memo's plan of marks, not evidence, so ticks and codes stay neutral. The
   "unofficial" notice is a boundary, not evidence, so it is not gold either.
   Cream acts; gold attests.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;
  --ink: #16191d;
  --raise: #1c2127;
  --raise-2: #232931;
  --line: rgba(250, 250, 251, 0.08);
  --line-2: rgba(250, 250, 251, 0.16);
  --fg: #fafafb;
  --fg-2: rgba(250, 250, 251, 0.72);
  --fg-3: rgba(250, 250, 251, 0.5);
  --gold: #c9a962;
  --gold-dim: rgba(201, 169, 98, 0.14);
  --cream: #faf7ef;

  --sans: "Geist", system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
  --serif: "EB Garamond", Georgia, serif;

  --container: 1300px;
  --read: 780px;
  --gutter: clamp(20px, 4vw, 48px);

  --track-sm: 0.01em;
  --track-md: -0.005em;
  --track-lg: -0.0125em;
  --track-xl: -0.02em;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #f9fafb;
  --raise: #ffffff;
  --raise-2: #f1f3f5;
  --line: rgba(22, 25, 29, 0.09);
  --line-2: rgba(22, 25, 29, 0.18);
  --fg: #16191d;
  --fg-2: rgba(22, 25, 29, 0.72);
  --fg-3: rgba(22, 25, 29, 0.64);
  --gold: #7d5f28;
  --gold-dim: rgba(138, 106, 47, 0.1);
  --btn-bg: #16191d;
  --btn-bg-hover: #23272c;
  --btn-fg: #fafafb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--ink);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: var(--track-sm);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:is(a, button, summary):focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 10px 16px; border-radius: 6px; font-size: 14px; text-decoration: none;
  background: var(--btn-bg, var(--cream)); color: var(--btn-fg, #16191d);
  transform: translateY(-64px); transition: transform 0.2s ease-out;
}
.skip-link:focus-visible { transform: translateY(0); }

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
.read { max-width: var(--read); }

/* ── Nav: fixed 52px ink bar, hairline under it ─────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 500; text-decoration: none; min-height: 40px; }
.brand svg { display: block; }
.nav-actions { display: flex; align-items: center; gap: 6px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 18px; border: 0; border-radius: 6px;
  font-family: var(--sans); font-size: 15px; font-weight: 500; letter-spacing: var(--track-sm);
  text-decoration: none; cursor: pointer; text-align: center;
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}
.btn-lg { min-height: 48px; padding: 0 26px; font-size: 16px; }
.btn-solid { background: var(--btn-bg, var(--cream)); color: var(--btn-fg, #16191d); }
.btn-solid:hover { background: var(--btn-bg-hover, #fff); }
.btn-line { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-line:hover { background: var(--raise); }
.btn-ghost { background: transparent; color: var(--fg-2); }
.btn-ghost:hover { color: var(--fg); }
.theme-toggle { width: 40px; padding: 0; }
.theme-toggle svg { display: block; }
/* The icon names the destination, not the state (sun shown in dark). */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn-lg { min-height: 48px; } .theme-toggle { width: 44px; } }

/* ── Type ───────────────────────────────────────────────────────────────── */
h1, h2, h3 { font-weight: 400; text-wrap: balance; }
h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.12; letter-spacing: var(--track-xl); }
h2 { font-size: clamp(23px, 2.6vw, 29px); line-height: 1.2; letter-spacing: var(--track-lg); }
h3 { font-size: 20px; line-height: 1.3; letter-spacing: var(--track-md); }
.accent { font-family: var(--serif); font-style: italic; font-size: 1.04em; color: var(--gold); }

.label {
  font-family: var(--mono); font-size: 12.5px; font-weight: 500;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--fg-3);
}
.meta { font-family: var(--mono); font-size: 12.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.lede { font-size: clamp(17px, 1.6vw, 19px); color: var(--fg-2); max-width: 58ch; }
p { max-width: 62ch; }
strong { font-weight: 500; color: var(--fg); }
.muted { color: var(--fg-2); }
.note { font-size: 13px; color: var(--fg-3); }

/* ── Page head ──────────────────────────────────────────────────────────── */
.page-head { padding-block: clamp(40px, 8vh, 80px) 28px; display: grid; gap: 14px; }
.crumb { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.06em; color: var(--fg-3); }
.crumb a { color: var(--fg-2); }

/* ── The notice: the page's boundary. Raise card, line-2 hairline, fg. ──── */
.notice {
  background: var(--raise);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 20px 22px;
  display: grid; gap: 8px;
}
.notice-title { font-size: 18px; line-height: 1.35; color: var(--fg); font-weight: 500; letter-spacing: var(--track-md); }
.notice p { font-size: 15px; color: var(--fg-2); }

/* ── Status line: when last checked ────────────────────────────────────── */
.status { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 16px; }
.stamp {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.09em;
  text-transform: uppercase; font-variant-numeric: tabular-nums;
  color: var(--gold); background: var(--gold-dim);
  border-radius: 999px; padding: 3px 9px;
}
/* An unchecked or upcoming state is not evidence, so it is not gold. */
.stamp.is-pending { color: var(--fg-2); background: var(--raise-2); }

/* ── Sections ───────────────────────────────────────────────────────────── */
.section { padding-block: clamp(40px, 7vh, 72px); border-top: 1px solid var(--line); }
.section > .read > * + * { margin-top: 14px; }
section[id], article[id] { scroll-margin-top: 68px; }

/* How to read the marks: a small key, mono codes */
.key { display: grid; gap: 10px; margin-top: 18px; }
.key-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.key-row dt { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--fg); font-variant-numeric: tabular-nums; }
.key-row dd { font-size: 15px; color: var(--fg-2); }

/* Contents */
.toc { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.toc a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 6px;
  font-family: var(--mono); font-size: 13px; color: var(--fg-2); text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.toc a:hover { background: var(--raise); color: var(--fg); }

/* ── CTA band ───────────────────────────────────────────────────────────── */
.cta-band {
  background: var(--raise); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px; display: grid; gap: 12px;
}
.cta-band h2 { font-size: 20px; letter-spacing: var(--track-md); line-height: 1.3; }
.cta-band p { font-size: 15.5px; color: var(--fg-2); }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

/* ── A question ─────────────────────────────────────────────────────────── */
.q-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.q-head .meta { white-space: nowrap; }
.q-topic { margin-top: 6px; font-size: 15px; color: var(--fg-2); }

.sub {
  background: var(--raise); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px; margin-top: 18px;
}
.sub-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sub-head h3 { font-variant-numeric: tabular-nums; }
.asked { margin-top: 14px; display: grid; gap: 4px; }
.asked p { font-size: 15.5px; color: var(--fg-2); }
.given {
  margin-top: 10px; background: var(--raise-2); border-radius: 8px; padding: 10px 14px;
  font-size: 16px; font-variant-numeric: tabular-nums; overflow-x: auto;
}

/* The working, memo-style: each line of working with the marks it earns. */
.working { list-style: none; margin-top: 16px; display: grid; gap: 0; }
.step {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px;
  padding-block: 10px; align-items: baseline;
}
.step + .step { border-top: 1px solid var(--line); }
.step-work { font-size: 16.5px; line-height: 1.55; font-variant-numeric: tabular-nums; min-width: 0; overflow-x: auto; }
.step-marks { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.mk {
  font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--fg); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 7px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.step-why { grid-column: 1 / -1; font-size: 13.5px; color: var(--fg-3); }
.sub-total { display: flex; justify-content: flex-end; margin-top: 6px; }
.sub-total .meta { color: var(--fg-2); }

/* "Looks like…": why a wrong answer looked right. */
.looks {
  margin-top: 14px; background: var(--raise-2); border-radius: 8px; padding: 12px 14px;
  display: grid; gap: 4px;
}
.looks p { font-size: 15px; color: var(--fg-2); }
.looks .label { font-size: 11.5px; }

.sub-foot { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.check-link { font-size: 14.5px; color: var(--fg); min-height: 40px; display: inline-flex; align-items: center; }
.alt { font-size: 13px; color: var(--fg-3); }

/* The human voice: who checked it. Serif italic, one line. */
.checked-by { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--fg-2); }

/* Placeholders the publisher must replace. Loud on purpose, so a leftover
   one is impossible to miss in review. tools/paper-night-check.py fails the
   build on any that remain. */
.ph {
  font-family: var(--mono); font-size: 0.86em; letter-spacing: 0.02em;
  color: var(--fg); border: 1px dashed var(--line-2); border-radius: 4px; padding: 0 5px;
}

/* ── Corrections log ────────────────────────────────────────────────────── */
.log { list-style: none; display: grid; gap: 10px; margin-top: 12px; }
.log li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; font-size: 15px; color: var(--fg-2); }
.log time { font-family: var(--mono); font-size: 12.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; padding-top: 2px; }

/* ── Hub: the papers ────────────────────────────────────────────────────── */
.papers { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 22px; max-width: 980px; }
.paper {
  background: var(--raise); border: 1px solid var(--line); border-radius: 12px; padding: 24px;
  display: grid; gap: 10px; align-content: start;
}
.paper h3 { font-size: 20px; }
.paper h3 a { text-decoration: none; }
.paper h3 a:hover { text-decoration: underline; }
.paper p { font-size: 15px; color: var(--fg-2); }
.paper .status { margin-top: 2px; }

.steps { list-style: none; display: grid; gap: 14px; margin-top: 16px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; font-size: 16px; color: var(--fg-2); counter-increment: s; }
.steps li::before { content: counter(s, decimal-leading-zero); font-family: var(--mono); font-size: 12.5px; color: var(--fg-3); padding-top: 3px; font-variant-numeric: tabular-nums; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); padding-block: 28px 48px; margin-top: clamp(40px, 7vh, 72px); }
.footer p { font-size: 13px; color: var(--fg-3); }
.footer p + p { margin-top: 8px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 14px; font-size: 13.5px; }
.footer nav a { color: var(--fg-2); min-height: 32px; display: inline-flex; align-items: center; }
/* The consent control (unhidden by /consent.js) reads as the fourth footer
   link, so it borrows that box rather than inventing a second idiom. */
/* Beats the `hidden` attribute's UA `display: none` otherwise — see styles.css. */
.footer nav button[hidden] { display: none; }
.footer nav button { font: inherit; color: var(--fg-2); min-height: 32px; display: inline-flex; align-items: center; border: 0; padding: 0; background: none; cursor: pointer; }

@media (max-width: 820px) {
  .papers { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .sub, .cta-band, .notice, .paper { padding: 18px 16px; }
  .step { grid-template-columns: minmax(0, 1fr); }
  .step-marks { justify-content: flex-start; }
  .log li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .nav .btn-solid { padding: 0 12px; }
}
