@import url("./tokens.css");
@import url("./base.css");

/* ---------- Page scale ---------- */
:root { --display-weight: 680; }
html { scroll-padding-top: calc(var(--nav-h) + var(--space-lg)); }
body { font-size: var(--text-md); line-height: 1.6; }
.lead { color: var(--color-ink-2); }
code { font-family: var(--font-outlier); }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: var(--space-xs); top: calc(-1 * var(--space-3xl)); z-index: var(--z-toast);
  padding: var(--space-xs) var(--space-md); border-radius: 8px;
  background: var(--color-ink); color: var(--color-paper);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus-visible { top: var(--space-xs); outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* ---------- Controls, all states ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: 48px; padding: 0 var(--space-lg);
  border: 1px solid transparent; border-radius: 8px;
  font: 600 var(--text-md)/1 var(--font-body);
  white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-ink); }
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-ghost { background: transparent; border-color: var(--color-field-edge); color: var(--color-ink); }
.btn-ghost:hover { background: var(--color-paper-3); border-color: var(--color-ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }

a:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 2px; }
.src, .more { color: var(--color-accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; transition: color var(--dur-short) var(--ease-out); }
.src:hover, .more:hover { color: var(--color-ink); }
.more { font-weight: 600; }

/* ---------- Slab nav: the instrument surface, edge to edge ---------- */
.topbar-outer {
  position: sticky; top: 0; z-index: var(--z-sticky-nav);
  background: var(--inst-bg); color: var(--inst-ink);
  border-bottom: 1px solid var(--inst-rule);
}
.topbar-outer.is-scrolled { box-shadow: 0 1px 2px var(--inst-bg); }
.topbar { display: flex; align-items: center; gap: var(--space-xl); min-height: var(--nav-h); }
.wordmark {
  font-family: var(--font-outlier); font-weight: 600; font-size: var(--text-lg);
  letter-spacing: -0.02em; text-decoration: none; color: inherit; white-space: nowrap;
}
.wordmark .q { color: var(--inst-accent); }
.topbar .wordmark:focus-visible, .topnav a:focus-visible, .theme-toggle:focus-visible { outline: 2px solid var(--inst-accent); outline-offset: 3px; }
.topnav { display: flex; gap: var(--space-lg); margin-left: auto; }
.topnav a { color: var(--inst-ink); text-decoration: none; font-size: var(--text-sm); white-space: nowrap; transition: color var(--dur-short) var(--ease-out); }
.topnav a:hover { color: var(--inst-accent); }
.topnav a[href="#sec-beta"] { color: var(--inst-accent); font-weight: 600; }
.topnav a[href="#sec-beta"]:hover { color: var(--inst-ink); }
.theme-toggle {
  display: none; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; padding: 0;
  background: transparent; color: var(--inst-ink);
  border: 1px solid var(--inst-rule); border-radius: var(--radius-pill);
  cursor: pointer; transition: color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
}
.theme-toggle.ready { display: inline-flex; }
.theme-toggle:hover { color: var(--inst-accent); border-color: var(--inst-accent); }
.theme-toggle:active { transform: translateY(1px); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ---------- Hero: Stage, text on five columns, the readout on seven ---------- */
.hero { display: grid; align-items: center; min-height: calc(100svh - var(--nav-h)); padding-block: var(--space-2xl); }
.stage-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: var(--space-3xl); align-items: center; }
.hero h1 { font-size: clamp(2.5rem, 2.5vw + 1.5rem, 4.25rem); line-height: 1.04; letter-spacing: -0.03em; max-width: 14ch; }
.hero .lead { margin-top: var(--space-lg); max-width: 34ch; }
/* Category line above the headline: carries the search terms the ads use (OT, critical infrastructure). */
.hero .category { margin-bottom: var(--space-md); max-width: 40ch; font-size: var(--text-sm); font-weight: 600; color: var(--color-accent); }
.stage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-lg); margin-top: var(--space-xl); }
.stage-terms { font-size: var(--text-sm); line-height: 1.5; color: var(--color-muted); }

.readout { margin: 0; background: none; overflow: visible; }
.readout-body { background: var(--inst-bg); color: var(--inst-ink); border: 1px solid var(--inst-rule); border-radius: 12px; }
.readout .row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "proto tag" "link tag";
  align-items: center; column-gap: var(--space-lg); row-gap: var(--space-2xs);
  padding: var(--space-lg) var(--space-xl); border-bottom: 1px solid var(--inst-rule);
}
.readout .proto { grid-area: proto; display: flex; flex-wrap: wrap; gap: 0 var(--space-sm); font-family: var(--font-outlier); font-size: var(--text-lg); }
.p-name, .p-cipher { font: inherit; }
.p-name { color: var(--inst-ink); }
.p-cipher { color: var(--inst-muted); }
.readout .link { grid-area: link; font-size: var(--text-sm); color: var(--inst-muted); }
.tag { grid-area: tag; font-size: var(--text-sm); font-weight: 600; line-height: 1; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-pill); white-space: nowrap; }
.tag.red { color: var(--inst-red); background: color-mix(in srgb, var(--inst-red) 14%, var(--inst-bg)); }
.tag.amber { color: var(--inst-amber); background: color-mix(in srgb, var(--inst-amber) 14%, var(--inst-bg)); }
.tag.safe { color: var(--inst-safe); background: color-mix(in srgb, var(--inst-safe) 14%, var(--inst-bg)); }
.readout-foot { display: flex; justify-content: space-between; gap: var(--space-md); padding: var(--space-md) var(--space-xl); font-size: var(--text-sm); color: var(--inst-muted); }
.readout-head { display: flex; justify-content: space-between; gap: var(--space-md); padding: var(--space-sm) var(--space-xl); background: var(--inst-bg-2); border-bottom: 1px solid var(--inst-rule); border-radius: 12px 12px 0 0; font-size: var(--text-sm); color: var(--inst-muted); }
.readout-head span:first-child { color: var(--inst-ink); font-weight: 600; }
.readout-cols { display: flex; justify-content: space-between; padding: var(--space-sm) var(--space-xl) 0; font-size: var(--text-sm); color: var(--inst-muted); }

/* ---------- Shared head block: question on the left, answer on the right ---------- */
.head-split { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); row-gap: var(--space-md); align-items: end; margin-bottom: var(--space-2xl); }
.head-split h2 { grid-column: 1 / 7; }
.head-split .lead { grid-column: 8 / 13; }

/* ---------- The sample CBOM: a change of paper ---------- */
.sample { background: var(--color-paper-2); padding-block: var(--section-gap-s); }
.cbom-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); align-items: start; }
.code-card { grid-column: 1 / 8; margin: 0; background: var(--inst-bg); color: var(--inst-ink); border: 1px solid var(--inst-rule); border-radius: 12px; }
.code-card figcaption { padding: var(--space-sm) var(--space-lg); background: var(--inst-bg-2); border-bottom: 1px solid var(--inst-rule); font-family: var(--font-outlier); font-size: var(--text-sm); color: var(--inst-muted); }
.code-card pre { margin: 0; padding: var(--space-lg); overflow-x: auto; font-family: var(--font-outlier); font-size: var(--text-xs); color: var(--inst-ink); tab-size: 2; }
.code-card .k { color: var(--inst-key); }
.code-card .s { color: var(--inst-str); }
.code-card .n { color: var(--inst-num); }
/* Numbered notes, each matched by a .pin on a line of the excerpt. The markers render in ::after,
   so a copy of the JSON stays valid; one colour pair, because the code card is dark in both themes. */
.pin::after, .read-notes li::before {
  content: attr(data-n);
  display: inline-grid; place-items: center;
  width: 1.5em; height: 1.5em; border-radius: 50%;
  background: var(--inst-key); color: var(--inst-pin-ink);
  font-family: var(--font-outlier); font-size: var(--text-xs); font-weight: 700; line-height: 1;
}
.pin::after { margin-left: var(--space-sm); vertical-align: 1px; }
.code-card figcaption, .code-card pre { line-height: var(--code-lh-ratio); }
/* The notes read 1 to 4 in order beside the excerpt and stay in view while it scrolls (owner's
   call, 2026-11-07). Setting each note level with its pin put them in file order, 1, 3, 2, 4. */
.cbom-grid { --code-lh-ratio: 1.65; }
.cbom-notes { grid-column: 8 / 13; align-self: start; position: sticky; top: calc(var(--nav-h) + var(--space-2xl)); }
.read-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-xl); }
.read-notes li { position: relative; padding-left: var(--space-xl); }
.read-notes li::before { position: absolute; left: 0; top: var(--space-2xs); }
.read-notes h3 { font-size: var(--text-title); }
.read-notes p { margin-top: var(--space-xs); color: var(--color-ink-2); }
.read-notes code { font-size: 0.9em; color: var(--color-ink); }
.dl-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: var(--gap-columns); row-gap: var(--space-md); margin-top: var(--space-2xl); padding-top: var(--space-xl); border-top: 1px solid var(--color-rule-strong); }
.dl-note { font-size: var(--text-sm); color: var(--color-muted); max-width: 60ch; }

/* ---------- Why now: three dates set as figures ---------- */
.now { padding-block: var(--section-gap) 0; }
.timeline { margin: 0; }
.dates { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Centred as a set (owner's call, 2026-11-07): each date in its third, the caption under the middle. */
.dates li { padding-inline: var(--space-lg); border-left: 1px solid var(--color-rule-strong); text-align: center; }
.dates li:first-child { border-left: 0; }
.year { display: block; font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--text-display-s); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--color-ink); }
.what { display: block; margin-top: var(--space-sm); font-size: var(--text-lead); color: var(--color-ink-2); }
.timeline figcaption { margin: var(--space-lg) auto 0; color: var(--color-ink-2); max-width: 70ch; text-align: center; }
.now .head-split { align-items: start; }
.now-answer { grid-column: 8 / 13; }
.now-answer .also { margin-top: var(--space-md); font-size: var(--text-sm); color: var(--color-ink-2); }
.also .src { margin-right: var(--space-sm); }

/* ---------- How it works: the answer beside a spec list ---------- */
.how { padding-block: var(--section-gap-l) var(--section-gap-l); }
.how-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); align-items: start; }
.how-head { grid-column: 1 / 6; position: sticky; top: calc(var(--nav-h) + var(--space-2xl)); }
.how-head p { margin-top: var(--space-lg); color: var(--color-ink-2); max-width: 48ch; }
.spec { grid-column: 7 / 13; margin: 0; }
.spec > div { display: grid; grid-template-columns: minmax(0, 8rem) minmax(0, 1fr); column-gap: var(--gap-columns); padding-block: var(--space-xl); border-top: 1px solid var(--color-rule); }
.spec > div:last-child { border-bottom: 1px solid var(--color-rule); }
.spec dt { font-weight: 600; font-size: var(--text-lead); line-height: 1.3; color: var(--color-ink); }
.spec dd { margin: 0; color: var(--color-ink-2); }
.spec dd .more { display: inline-block; margin-top: var(--space-xs); }

/* ---------- Access: the form on a change of paper ---------- */
.access { background: var(--color-paper-2); padding-block: var(--section-gap-s); }
.access-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); row-gap: var(--space-xl); align-items: start; }
.access-head { grid-column: 1 / 6; }
.access-head p { margin-top: var(--space-lg); color: var(--color-ink-2); max-width: 48ch; }
.capture { grid-column: 7 / 13; }
.capture-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md) var(--space-lg); }
.field { display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field label { font-size: var(--text-sm); font-weight: 600; color: var(--color-ink-2); }
.capture input:not([type="checkbox"]), .capture select {
  width: 100%; min-height: 48px; padding: 0 var(--space-md);
  font-size: var(--text-md); color: var(--color-ink); background: var(--color-paper-3);
  border: 1px solid var(--color-field-edge); border-radius: 8px;
  outline: 2px solid transparent; outline-offset: 2px;
}
.capture input::placeholder { color: var(--color-muted); }
.capture input:focus-visible, .capture select:focus-visible { outline-color: var(--color-focus); }
.capture input:disabled, .capture select:disabled { opacity: 0.55; cursor: not-allowed; }
.consent-row { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: var(--space-sm); font-size: var(--text-sm); color: var(--color-ink-2); cursor: pointer; }
.consent-row input { flex: none; width: 18px; height: 18px; margin: var(--space-3xs) 0 0; accent-color: var(--color-accent); }
.consent-row input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.consent-row span { color: var(--color-muted); }
.capture-row .btn { grid-column: 1 / -1; justify-self: start; }
.capture-error { margin-top: var(--space-sm); font-size: var(--text-sm); color: var(--color-error); }
.capture-error:empty { display: none; }
.capture-legal { margin-top: var(--space-md); font-size: var(--text-sm); color: var(--color-muted); }
.capture-legal a { color: var(--color-accent); }
.capture-done { display: none; align-items: center; gap: var(--space-sm); font-size: var(--text-lead); font-weight: 600; color: var(--color-accent); }
.capture-done svg { width: 24px; height: 24px; flex: none; }
.capture.is-sent .capture-form { display: none; }
.capture.is-sent .capture-done { display: flex; }

/* ---------- Footer: a colophon under a rule ---------- */
.site-foot { border-top: 1px solid var(--color-rule); padding-block: var(--space-2xl) var(--space-3xl); }
.foot-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap-columns); row-gap: var(--space-xl); align-items: start; }
.foot-mast { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-lg); }
.site-foot .wordmark { font-size: var(--text-2xl); color: var(--color-ink); }
.site-foot .wordmark .q { color: var(--color-accent); }
.foot-topics { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); }
.foot-topics a, .foot-links a { color: var(--color-ink-2); text-decoration: none; white-space: nowrap; transition: color var(--dur-short) var(--ease-out); }
.foot-topics a:hover, .foot-links a:hover { color: var(--color-accent); }
.foot-colophon { grid-column: 1 / 9; }
.legal { color: var(--color-muted); max-width: 70ch; }
.legal .name { color: var(--color-ink-2); font-weight: 600; }
.foot-links { display: flex; flex-wrap: wrap; gap: var(--space-lg); margin-top: var(--space-md); }
.foot-links a { color: var(--color-accent); text-decoration: underline; text-underline-offset: 0.2em; }
.foot-badge { grid-column: 10 / 13; justify-self: end; line-height: 0; }
.foot-afc { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-md); padding-top: var(--space-lg); border-top: 1px solid var(--color-rule); }
.afc-panel { flex: none; background: var(--afc-panel); border-radius: 8px; padding: var(--space-xs) var(--space-sm); line-height: 0; }
.foot-afc p { font-size: var(--text-sm); color: var(--color-muted); max-width: 70ch; }

/* ---------- Cookie banner (consent.js), a slim bar along the foot ---------- */
.cc-banner {
  position: fixed; inset-inline: 0; bottom: 0; z-index: var(--z-toast);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-sm) var(--space-xl);
  padding: var(--space-sm) var(--gutter);
  background: var(--color-paper-3); color: var(--color-ink);
  border-top: 1px solid var(--color-rule-strong);
  font-size: var(--text-sm); line-height: 1.5;
}
.cc-banner[hidden] { display: none; }
.cc-banner p { margin: 0; flex: 0 1 60rem; color: var(--color-ink-2); }
.cc-banner a { color: var(--color-accent); }
.cc-actions { display: flex; gap: var(--space-sm); }
.cc-actions .btn { min-height: 44px; padding: 0 var(--space-md); font-size: var(--text-sm); }

/* ---------- Under 60rem every composition stacks in reading order ---------- */
@media (max-width: 60rem) {
  .topbar { gap: var(--space-md); }
  .topnav a:not([href="#sec-beta"]) { display: none; }
  .hero { min-height: 0; padding-block: var(--space-xl) var(--space-3xl); }
  .stage-grid { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-xl); }
  .head-split h2, .head-split .lead, .now-answer { grid-column: 1 / -1; }
  .code-card, .cbom-notes { grid-column: 1 / -1; }
  .cbom-notes { margin-top: var(--space-2xl); }
  .cbom-notes .read-notes { display: grid; gap: var(--space-xl); }
  .cbom-notes .read-notes li { position: relative; top: auto; }
  .dl-row { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .how-head { position: static; }
  .how-head, .spec, .access-head, .capture, .foot-colophon, .foot-badge { grid-column: 1 / -1; }
  .spec { margin-top: var(--space-2xl); }
  .foot-badge { justify-self: start; }
  .cc-banner { justify-content: flex-start; }
}
@media (max-width: 40rem) {
  .readout .row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "proto" "link" "tag"; padding: var(--space-md) var(--space-lg); }
  .tag { justify-self: start; margin-top: var(--space-xs); }
  .readout .proto { font-size: var(--text-md); }
  .readout-foot, .readout-head, .readout-cols { padding-inline: var(--space-lg); }
  .dates { grid-template-columns: minmax(0, 1fr); }
  .dates li { padding: var(--space-md) 0; border-left: 0; border-top: 1px solid var(--color-rule-strong); }
  .dates li:first-child { padding-top: 0; border-top: 0; }
  .capture-row { grid-template-columns: minmax(0, 1fr); }
  .spec > div { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-2xs); }
  .foot-afc { flex-wrap: wrap; }
}

@media (prefers-contrast: more) {
  :root { --hairline: var(--ink-muted); --ink-muted: var(--ink-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .src, .more, .topnav a, .theme-toggle, .foot-topics a, .foot-links a { transition: none; }
  .btn:active, .theme-toggle:active { transform: none; }
}
