/* Floodcaster demo — fixed design tokens.
   Color appears only as a governance state or the single accent. Radius <= 2px. */

@font-face { font-family: 'Source Serif 4'; src: url(fonts/SourceSerif4-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Source Serif 4'; src: url(fonts/SourceSerif4-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url(fonts/Inter-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url(fonts/Inter-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(fonts/IBMPlexMono-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(fonts/IBMPlexMono-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --paper: #FAF9F6;
  --ink: #0C0F13;
  --rule: #D9D5CD;
  --body: #1B1E23;
  --muted: #6E6A63;
  --accent: #14304F;
  --admitted: #1F5F3F;
  --limited: #8A6100;
  --suppressed: #8B2231;

  /* logo-derived brand blues (see docs/PALETTE.md) */
  --fc-deep: #0E2B47;
  --fc-navy: #14304F;
  --fc-ocean: #1580BE;
  --fc-cyan: #16A6E0;
  /* the ONE attention color — reserved for the primary conversion CTA */
  --signal: #E3A008;
  --signal-ink: #0C0F13;

  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;

  --surface: var(--paper);
  --text: var(--body);
  --head: var(--ink);
  --line: var(--rule);
  --dim: var(--muted);
}

[data-mode="ink"] {
  --surface: var(--ink);
  --text: #C9C5BD;
  --head: #FAF9F6;
  --line: #2A2E35;
  --dim: #7A766F;
  /* re-apply: descendants inherit body's computed color, not the re-scoped var */
  color: var(--text);
  background: var(--surface);
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--surface);
  color: var(--text);
  font: 400 16px/26px var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1248px; margin: 0 auto; padding: 0 96px; }
@media (max-width: 720px) { .wrap { padding: 0 20px; } }

/* ---- type scale (brief §2) ---- */
.display { font: 600 56px/60px var(--serif); color: var(--head); letter-spacing: -0.01em; }
h1, .h1 { font: 600 40px/46px var(--serif); color: var(--head); }
h2, .h2 { font: 600 28px/34px var(--serif); color: var(--head); }
h3, .h3 { font: 500 20px/26px var(--sans); color: var(--head); }
.body-l { font: 400 18px/28px var(--sans); }
.small { font: 400 14px/22px var(--sans); }
.mono   { font: 400 13px/20px var(--mono); }
.mono-s { font: 400 12px/18px var(--mono); }
@media (max-width: 720px) {
  .display { font-size: 38px; line-height: 42px; }
  h1, .h1 { font-size: 30px; line-height: 36px; }
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
[data-mode="ink"] a { color: #9DB6D1; }

/* ---- section rule: hairline + micro label (the exhibit motif) ---- */
.rule {
  border: 0; border-top: 1px solid var(--line);
  margin: 96px 0 0; position: relative;
}
.rule + section, .rule + div { padding-top: 48px; }
.micro {
  font: 500 12px/18px var(--mono); color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.14em;
}
.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 32px; }

/* ---- buttons ---- */
.btn {
  display: inline-block; border: 1px solid var(--accent); border-radius: 2px;
  background: var(--accent); color: var(--paper);
  font: 500 15px/1 var(--sans); padding: 14px 24px; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #1B3E64; border-color: #1B3E64; }
/* signal: the single primary conversion CTA — see docs/PALETTE.md (one per screen) */
.btn.signal { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.signal:hover { background: #F2AE1A; border-color: #F2AE1A; }
.btn.ghost { background: transparent; color: var(--accent); }
[data-mode="ink"] .btn.ghost { color: #9DB6D1; border-color: #3A4E63; }
.btn.ghost:hover { background: rgba(20,48,79,0.06); }
[data-mode="ink"] .btn.ghost:hover { background: rgba(157,182,209,0.08); }

/* ---- state badges: the ONLY color in the system ---- */
.badge {
  display: inline-block; border-radius: 2px; padding: 3px 8px;
  font: 500 12px/18px var(--mono); letter-spacing: 0.06em; color: var(--paper);
}
.badge.admitted { background: var(--admitted); }
.badge.limited { background: var(--limited); }
.badge.suppressed { background: var(--suppressed); }

/* ---- evidence rows ---- */
.evidence { border-top: 1px solid var(--line); }
.ev-row {
  display: grid; grid-template-columns: 200px 1fr auto; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line); align-items: baseline;
  position: relative;
}
.ev-row.changed::before {
  content: ""; position: absolute; left: -16px; top: 12px; bottom: 12px;
  border-left: 2px solid var(--limited);
}
.ev-label { font: 500 12px/18px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; }
.ev-value { font: 500 13px/20px var(--mono); color: var(--head); }
.chip {
  font: 400 12px/18px var(--mono); color: var(--dim);
  border: 1px solid var(--line); border-radius: 2px; padding: 1px 7px; white-space: nowrap;
}
@media (max-width: 720px) { .ev-row { grid-template-columns: 1fr; gap: 4px; } }

/* ---- source health strip: coverage bar + health dot, SEPARATE ---- */
.src-row {
  display: grid; grid-template-columns: 200px 1fr 120px 20px; gap: 16px;
  align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.cov { height: 6px; background: var(--line); border-radius: 2px; position: relative; }
.cov > i { position: absolute; inset: 0 auto 0 0; background: var(--dim); border-radius: 2px; }
.cov > i.sig { background: var(--accent); }
[data-mode="ink"] .cov > i.sig { background: #4E7BA8; }
.cov > i.warn { background: var(--limited); }
.cov > i.down { background: var(--suppressed); }
.src-row.sig-row .ev-label { color: var(--head); }
.src-row .tag {
  font: 500 10px/16px var(--mono); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 2px; padding: 0 5px; margin-left: 8px;
}
[data-mode="ink"] .src-row .tag { color: #7FA6CC; border-color: #3A4E63; }
.dot { width: 8px; height: 8px; border-radius: 50%; justify-self: center; }
.dot.ok { background: var(--admitted); }
.dot.warn { background: var(--limited); }
.dot.down { background: var(--suppressed); }
@media (max-width: 720px) { .src-row { grid-template-columns: 1fr 1fr 60px 20px; } }

/* ---- diff rows ---- */
.diff-head, .diff-row {
  display: grid; grid-template-columns: 160px 1fr 1fr 1fr; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline;
}
.diff-head { font: 500 12px/18px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; }
.diff-row .then { color: var(--dim); text-decoration: line-through; text-decoration-color: var(--suppressed); text-decoration-thickness: 1px; }
@media (max-width: 720px) { .diff-head, .diff-row { grid-template-columns: 90px 1fr 1fr; } .diff-head .cause, .diff-row .cause { display: none; } }

/* ---- certificate sheet: ALWAYS paper, even on ink ----
   re-scope tokens so evidence rows/chips/footer never inherit ink-mode values */
.cert {
  --line: var(--rule); --dim: var(--muted); --text: var(--body); --head: var(--ink);
  background: var(--paper); color: var(--body);
  border: 1px solid #C7C2B8; border-radius: 2px;
  padding: 48px; max-width: 640px;
  box-shadow: 0 1px 0 rgba(12,15,19,0.25);
}
@media (max-width: 480px) { .cert { padding: 24px; } }
[data-mode="ink"] .cert { box-shadow: 0 0 0 1px rgba(250,249,246,0.06), 0 24px 48px rgba(0,0,0,0.5); }
.cert .ev-label { color: var(--muted); }
.cert .ev-value { color: var(--ink); }
.cert-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 8px; }
.cert-head h3 { font: 600 20px/26px var(--serif); color: var(--ink); }
.cert-brand { display: flex; align-items: center; gap: 14px; }
.cert-brand img { display: block; }
.cert-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---- anatomy of the record: exhibit grid, stacks on phones ---- */
.anatomy-grid { display: grid; grid-template-columns: minmax(0,640px) 1fr; gap: 64px; align-items: start; }
@media (max-width: 720px) { .anatomy-grid { grid-template-columns: 1fr; gap: 32px; } }

/* ---- attachment diagram ---- */
.attach { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 0; margin-top: 48px; }
.band { border: 1px solid var(--line); border-radius: 2px; padding: 24px 20px; text-align: center; }
.band.mid { border-color: var(--accent); }
.band .mono-s { display: block; margin-top: 8px; }
.attach-arrow { display: flex; align-items: center; padding: 0 12px; color: var(--dim); font: 400 13px/1 var(--mono); }
@media (max-width: 720px) {
  .attach { grid-template-columns: 1fr; }
  .attach-arrow { justify-content: center; padding: 8px 0; transform: rotate(90deg); }
}

/* ---- forms ---- */
.field { display: block; margin-bottom: 24px; }
.field span { display: block; font: 500 12px/18px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 2px; background: transparent;
  color: var(--head); font: 400 15px/22px var(--sans); padding: 10px 12px;
}
.field input:focus, .field select:focus { outline: 1px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
/* dropdown list must stay legible across mobile browsers (theme text on transparent = white-on-white risk) */
.field select option { background: var(--paper); color: var(--body); }

/* ---- specimen banner ---- */
.specimen {
  font: 500 12px/18px var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dim); border: 1px solid var(--line); border-radius: 2px;
  padding: 4px 10px; display: inline-block;
}

/* ---- replay instrument ---- */
.stage { min-height: 100vh; display: flex; flex-direction: column; }
.stage-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px 16px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
@media (min-width: 720px) { .stage-head { padding: 20px 32px; } }
.presets { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; }
.preset {
  border: 1px solid var(--line); border-radius: 2px; background: transparent;
  color: var(--text); font: 500 13px/18px var(--mono); padding: 6px 14px; cursor: pointer;
}
.preset[aria-pressed="true"] { border-color: var(--head); color: var(--head); }
.stage-main { flex: 1; padding: 24px 20px 48px; max-width: 860px; width: 100%; margin: 0 auto; }
@media (min-width: 720px) { .stage-main { padding: 40px 32px 64px; } }

/* mobile-first frame progress: dots, tap to jump, hover names on desktop */
.progress { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 28px; }
.pdot {
  width: 9px; height: 9px; border-radius: 50%; border: 0;
  padding: 0; background: var(--line); cursor: pointer; flex: none;
  /* keep a 9px dot but a ~28px hit area for touch */
  outline: 10px solid transparent; outline-offset: 0; margin: 6px;
}
.pdot.done { background: var(--dim); }
.pdot.now { background: var(--head); transform: scale(1.3); }
.plabel { color: var(--head); margin-left: 4px; white-space: nowrap; }

.ev-row.focus { background: rgba(20, 48, 79, 0.05); }
[data-mode="ink"] .ev-row.focus { background: rgba(250, 249, 246, 0.05); }
.ev-row.focus .ev-label { color: var(--head); }

.frame-title { margin-bottom: 8px; }
.frame-note { color: var(--dim); max-width: 56ch; margin-bottom: 32px; }

.scenario {
  display: flex; gap: 8px 24px; align-items: baseline; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 2px;
  padding: 12px 18px; margin-bottom: 40px;
}
.scenario .q { font: 400 15px/22px var(--sans); color: var(--head); }

.recon-banner {
  font: 500 13px/20px var(--mono); color: var(--paper); background: var(--accent);
  border-radius: 2px; padding: 8px 14px; margin-bottom: 24px; display: none;
}
.recon-banner.on { display: inline-block; }

.limitation {
  border: 1px solid var(--limited); border-radius: 2px; padding: 16px 20px; margin-top: 24px;
}
.limitation p { margin-top: 8px; }

/* timeline scrubber */
.timeline { border-top: 1px solid var(--line); padding: 24px 32px 32px; }
.tl-track { position: relative; height: 56px; }
.tl-line { position: absolute; left: 0; right: 0; top: 27px; border-top: 1px solid var(--line); }
.tl-tick { position: absolute; top: 20px; width: 1px; height: 15px; background: var(--dim); }
.tl-tick span {
  position: absolute; top: 18px; left: 0; transform: translateX(-50%);
  font: 400 11px/16px var(--mono); color: var(--dim); white-space: nowrap;
}
.tl-tick i { position: absolute; top: -16px; left: 0; transform: translateX(-50%); font: 400 11px/16px var(--mono); color: var(--dim); font-style: normal; white-space: nowrap; }
#scrub { position: absolute; inset: 6px 0 auto; width: 100%; height: 44px; -webkit-appearance: none; appearance: none; background: transparent; cursor: ew-resize; }
#scrub::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 44px;
  background: var(--head); border-radius: 2px; border: 0;
}
#scrub::-moz-range-thumb { width: 16px; height: 44px; background: var(--head); border-radius: 2px; border: 0; }
#scrub:disabled { cursor: default; opacity: 0.35; }

/* phones: thin the timeline to endpoints so labels stop colliding */
@media (max-width: 560px) {
  .tl-tick span, .tl-tick i { font-size: 10px; }
  .tl-tick:not(:first-child):not(:last-child) span,
  .tl-tick:not(:first-child):not(:last-child) i { display: none; }
}

.advance { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 40px; }

/* json payload */
.payload {
  font: 400 12px/18px var(--mono); color: var(--text);
  border: 1px solid var(--line); border-radius: 2px; padding: 24px;
  overflow-x: auto; white-space: pre; max-width: 720px;
}

/* close frame */
.close-line { font: 600 28px/34px var(--serif); color: var(--head); max-width: 30ch; }

/* reveal */
.frame { animation: rise 0.45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .frame { animation: none; } }

@media print {
  /* collapse everything but the certificate so hidden wrappers don't emit blank pages */
  body { margin: 0; background: #fff; }
  .stage-head, .timeline, .progress, .scenario, .advance, .frame-note,
  .frame-title, .micro, .recon-banner, footer, header { display: none !important; }
  .cert { box-shadow: none; border: 1px solid #C7C2B8; max-width: none; }
}
