/* How a read happens — page styles. Tokens come from assets/colors_and_type.css. */

html { font-optical-sizing: auto; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg-canvas); color: var(--fg-primary); }
*, *::before, *::after { box-sizing: border-box; }

:root {
  --rail-h: 52px;
  --wrap: 1120px;
  --field-blue: 106, 157, 198;   /* chart-blue, reader field */
  --field-cyan: 112, 191, 215;   /* chart-cyan, tag / coupled */
}

/* ── Sticky rail ─────────────────────────────────────────────── */
.rail {
  position: sticky; top: 0; z-index: 40; height: var(--rail-h);
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-6);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-hairline);
}
.rail.on-dark { background: rgba(29, 29, 27, 0.9); border-bottom-color: #3a3a38; }
.rail .wordmark { height: 13px; display: block; }
.rail .ctx { font-size: var(--text-sm); color: var(--fg-secondary); white-space: nowrap; }
.rail.on-dark .ctx { color: var(--color-gray-400); }
.rail .div { width: 1px; height: 18px; background: var(--border-hairline); flex: none; }
.rail.on-dark .div { background: #3a3a38; }
.rail .spacer { flex: 1; }
.rail .priv { font-size: var(--text-xs); color: var(--fg-tertiary); white-space: nowrap; }

.band-chip {
  display: flex; align-items: baseline; gap: 6px; white-space: nowrap;
  border: 1px solid var(--border-hairline); border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: var(--text-xs); color: var(--fg-secondary);
  font-feature-settings: "tnum" 1; transition: border-color 200ms;
}
.band-chip .v { font-weight: 700; color: var(--fg-primary); font-size: var(--text-sm); }
.band-chip.set { border-color: var(--color-gray-800); }
.rail.on-dark .band-chip { border-color: #3a3a38; color: var(--color-gray-400); }
.rail.on-dark .band-chip .v { color: #fff; }
.rail.on-dark .band-chip.set { border-color: var(--color-gray-400); }
@keyframes chip-pulse {
  0% { box-shadow: 0 0 0 0 rgba(231, 52, 70, 0.5); }
  100% { box-shadow: 0 0 0 9px rgba(231, 52, 70, 0); }
}
.band-chip.pulse { animation: chip-pulse 700ms ease-out 1; }

.progress { display: flex; align-items: center; gap: 5px; }
.progress .p-dot {
  width: 7px; height: 7px; border-radius: 0;
  background: var(--color-gray-200); transition: background 200ms;
}
.rail.on-dark .progress .p-dot { background: #414140; }
.progress .p-dot.done { background: var(--color-balluff-black); }
.rail.on-dark .progress .p-dot.done { background: #fff; }
.progress .p-count { font-size: var(--text-xs); color: var(--fg-tertiary); margin-left: 4px; font-feature-settings: "tnum" 1; }

/* ── Hero ────────────────────────────────────────────────────── */
.hero { background: var(--color-balluff-black); color: #fff; overflow: clip; }
.hero-inner {
  max-width: var(--wrap); margin: 0 auto;
  padding: var(--space-16) var(--space-6) var(--space-12);
  display: grid; grid-template-columns: 1.05fr 1fr; gap: var(--space-12);
  align-items: center;
}
.hero .eyebrow { color: var(--color-balluff-red); margin: 0 0 var(--space-4); }
.hero h1 {
  color: #fff; font-size: clamp(2.7rem, 6vw, 4.1rem); line-height: 1.02;
  letter-spacing: -0.025em; font-variation-settings: "wght" 780, "wdth" 88, "opsz" 60;
  margin: 0 0 var(--space-5); max-width: 14ch;
}
.hero .lede { color: var(--color-gray-300); font-size: var(--text-lg); line-height: 1.6; max-width: 54ch; margin: 0 0 var(--space-6); }
.hero .lede strong { color: #fff; font-weight: 600; }
.hero .follow { font-size: var(--text-sm); color: var(--color-gray-500); max-width: 46ch; }
.hero .follow a { color: var(--color-gray-300); text-decoration: underline; text-decoration-color: #555; text-underline-offset: 3px; }
.hero .follow a:hover { color: #fff; }

.hero-sim { position: relative; border: 1px solid #3a3a38; background: #232321; }
.hero-sim canvas { display: block; width: 100%; height: 430px; touch-action: none; cursor: grab; }
.hero-sim canvas.dragging { cursor: grabbing; }
.hero-readout {
  border-top: 1px solid #3a3a38; padding: var(--space-3) var(--space-4);
  min-height: 66px; display: flex; flex-direction: column; gap: 3px; justify-content: center;
}
.hero-readout .id {
  font-family: var(--font-mono); font-size: var(--text-sm); letter-spacing: 0.06em;
  color: rgb(var(--field-cyan)); min-height: 1.3em;
}
.hero-readout .fact { font-size: var(--text-xs); color: var(--color-gray-400); }
.hero-family { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--space-6) var(--space-10); }
.hero-family .frame { position: relative; border: 1px solid #3a3a38; overflow: hidden; }
.hero-family img, .hero-family video { width: 100%; height: 340px; object-fit: cover; object-position: center 48%; display: block; }
.hero-family .frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.5);
}
.hero-family figcaption { font-size: var(--text-xs); color: var(--color-gray-500); margin-top: var(--space-2); }
.hero-family #famHint { color: var(--color-gray-300); font-weight: 600; }

/* ── Entrance motion: variable-font settle + section reveals ──
   Gated on html.js so a script failure never hides content, and on
   prefers-reduced-motion so it all collapses to plain rendering. */
@media (prefers-reduced-motion: no-preference) {
  html.js .hero h1 { animation: h1-settle 1000ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  html.js .hero .lede { animation: fade-rise 800ms cubic-bezier(0.2, 0.7, 0.2, 1) 180ms both; }
  html.js .hero .follow { animation: fade-rise 800ms cubic-bezier(0.2, 0.7, 0.2, 1) 300ms both; }
  html.js .beat-inner > .eyebrow, html.js .beat-inner > h2, html.js .beat-inner > .beat-lede {
    opacity: 0; transform: translateY(14px);
    transition: opacity 600ms ease, transform 600ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  html.js .beat-inner > h2 { transition-delay: 70ms; }
  html.js .beat-inner > .beat-lede { transition-delay: 140ms; }
  html.js .beat-inner.in > .eyebrow, html.js .beat-inner.in > h2, html.js .beat-inner.in > .beat-lede {
    opacity: 1; transform: none;
  }
}
@keyframes h1-settle {
  from { font-variation-settings: "wght" 300, "wdth" 100, "opsz" 60; opacity: 0; letter-spacing: 0; }
  to { font-variation-settings: "wght" 780, "wdth" 88, "opsz" 60; opacity: 1; letter-spacing: -0.025em; }
}
@keyframes fade-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ── Beats ───────────────────────────────────────────────────── */
main { display: block; }
.beat { border-top: 1px solid var(--border-hairline); }
.beat-inner { max-width: var(--wrap); margin: 0 auto; padding: var(--space-20) var(--space-6); }
.beat .eyebrow { margin: 0 0 var(--space-3); }
.beat h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem); line-height: 1.08; letter-spacing: -0.02em;
  font-variation-settings: "wght" 780, "wdth" 90, "opsz" 40;
  max-width: 20ch; margin: 0 0 var(--space-4);
}
.beat-lede { font-size: var(--text-lg); line-height: 1.6; color: var(--color-gray-800); max-width: 62ch; margin: 0 0 var(--space-8); }
.beat-lede em { font-style: normal; font-weight: 650; color: var(--color-balluff-black); }

.sim {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--space-8);
  border: 1px solid var(--border-hairline); padding: var(--space-6); margin: 0;
  background: var(--bg-canvas);
}
.sim .stage { min-width: 0; }
.sim canvas { display: block; width: 100%; height: 400px; touch-action: none; }
.sim canvas.draggable { cursor: grab; }
.sim canvas.dragging { cursor: grabbing; }
.sim figcaption { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--fg-tertiary); line-height: 1.5; }

.panel { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.ctl-label { font-size: var(--text-sm); font-weight: 650; color: var(--fg-primary); margin-bottom: var(--space-2); }
.ctl-hint { font-size: var(--text-xs); color: var(--fg-tertiary); margin-top: var(--space-1); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; min-width: 84px; text-align: center; cursor: pointer; font: inherit;
  font-weight: 600; font-size: var(--text-sm); padding: var(--space-3) var(--space-2);
  border: 1px solid var(--border-hairline); background: var(--bg-canvas);
  border-radius: var(--radius-sm); transition: border-color 120ms, background 120ms;
  color: var(--fg-primary);
}
.seg button:hover { border-color: var(--color-gray-400); }
.seg button[aria-pressed="true"] { border-color: var(--color-balluff-black); background: var(--bg-subtle); }
.seg button:focus-visible, .commit:focus-visible, .stepper button:focus-visible, .ghost-btn:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--color-balluff-red); outline-offset: 2px;
}
.seg button .seg-sub { display: block; font-weight: 400; font-size: var(--text-xs); color: var(--fg-secondary); margin-top: 2px; }
#sysProtoSeg button { flex: 1 1 30%; min-width: 0; }

.slider-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.readout { font-variation-settings: "wght" 560; font-feature-settings: "tnum" 1; font-size: var(--text-lg); white-space: nowrap; }
.readout .u { font-size: var(--text-sm); color: var(--fg-secondary); }
input[type="range"] { width: 100%; accent-color: var(--color-balluff-black); margin: 0; }

.stepper { display: flex; align-items: center; gap: var(--space-2); }
.stepper button {
  width: 40px; height: 40px; font: inherit; font-size: var(--text-xl); font-weight: 600; line-height: 1;
  cursor: pointer; border: 1px solid var(--border-hairline); background: var(--bg-canvas);
  border-radius: var(--radius-sm); color: var(--fg-primary); transition: border-color 120ms;
}
.stepper button:hover:not(:disabled) { border-color: var(--color-gray-400); }
.stepper button:disabled { color: var(--color-gray-300); cursor: default; }
.stepper .stepper-v {
  min-width: 64px; text-align: center; font-size: var(--text-xl); font-weight: 650;
  font-feature-settings: "tnum" 1;
}

.verdict { display: flex; align-items: center; gap: var(--space-2); font-weight: 650; font-size: var(--text-sm); }
.verdict .dot { width: 10px; height: 10px; flex: none; background: var(--color-chart-cyan); }
.verdict.ok .dot { background: var(--color-chart-cyan); }
.verdict.warn .dot { background: var(--color-chart-blue); }
.verdict.far .dot { background: var(--color-chart-silver); }
.verdict.bad .dot { background: var(--color-gray-800); }
.consequence { font-size: var(--text-sm); line-height: 1.55; color: var(--fg-secondary); margin: 6px 0 0; }

.bigband { border: 1px solid var(--border-hairline); padding: var(--space-4); }
.bigband .k { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-secondary); }
.bigband .v { font-size: var(--text-2xl); font-weight: 750; letter-spacing: -0.01em; margin-top: 2px; font-variation-settings: "wght" 750, "wdth" 94; }
.bigband .n { font-size: var(--text-xs); color: var(--fg-secondary); margin-top: 4px; line-height: 1.5; }

.commit {
  align-self: flex-start; cursor: pointer; font: inherit; font-weight: 650; font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline); background: var(--bg-canvas); color: var(--fg-tertiary);
  transition: background 140ms, border-color 140ms, color 140ms;
}
.commit:disabled { cursor: default; }
.commit.armed { background: var(--color-balluff-red); border-color: var(--color-balluff-red); color: #fff; }
.commit.armed:hover { background: var(--color-balluff-red-hover); border-color: var(--color-balluff-red-hover); }
.commit.done { background: var(--bg-canvas); border-color: var(--color-balluff-black); color: var(--color-balluff-black); }

.ghost-btn {
  cursor: pointer; font: inherit; font-weight: 600; font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
  border: 1px solid var(--color-gray-800); background: var(--bg-canvas); color: var(--fg-primary);
  transition: background 120ms;
}
.ghost-btn:hover { background: var(--bg-subtle); }

.caveat { grid-column: 1 / -1; font-size: var(--text-xs); color: var(--fg-tertiary); border-top: 1px solid var(--border-hairline); padding-top: var(--space-4); margin: 0; line-height: 1.5; }

.uhf-notes { display: none; flex-wrap: wrap; gap: 6px; }
.uhf-notes.show { display: flex; }
.uhf-notes .chip {
  font-size: var(--text-xs); font-weight: 600; color: var(--color-gray-800);
  border: 1px solid var(--border-hairline); background: var(--bg-subtle);
  padding: 4px 9px; border-radius: var(--radius-sm);
}

/* Real-hardware strip */
.hw-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-4); margin-top: var(--space-8); }
.hw-strip figure { margin: 0; border: 1px solid var(--border-hairline); }
.hw-strip .imgbox { aspect-ratio: 4 / 3; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff; }
.hw-strip img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hw-strip figcaption { padding: var(--space-3) var(--space-4); font-size: var(--text-xs); color: var(--fg-secondary); border-top: 1px solid var(--border-hairline); line-height: 1.5; }
.hw-strip figcaption b { color: var(--fg-primary); font-weight: 650; }

/* ── Spec section ────────────────────────────────────────────── */
.spec-section { border-top: 1px solid var(--border-hairline); background: var(--bg-subtle); }
.spec-card { border: 1px solid var(--border-hairline); background: var(--bg-canvas); padding: var(--space-6); }
.spec-band { display: flex; align-items: baseline; gap: var(--space-4); flex-wrap: wrap; padding-bottom: var(--space-4); border-bottom: 1px solid var(--border-hairline); }
.spec-band .bv { font-size: var(--text-3xl); font-weight: 780; letter-spacing: -0.015em; font-variation-settings: "wght" 780, "wdth" 92; }
.spec-band .bv.unset { font-size: var(--text-xl); font-weight: 500; color: var(--fg-tertiary); font-variation-settings: "wght" 500, "wdth" 100; }
.spec-band .bn { font-size: var(--text-sm); color: var(--fg-secondary); max-width: 52ch; }
.spec-rows { margin-top: var(--space-2); }
.spec-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px dashed var(--border-hairline); }
.spec-row:last-child { border-bottom: 0; }
.spec-row .k { font-size: var(--text-sm); color: var(--fg-secondary); flex: none; }
.spec-row .v { font-size: var(--text-sm); font-weight: 650; text-align: right; }
.spec-row .v .sub { display: block; font-weight: 400; color: var(--fg-secondary); }
.spec-row .v a.edit { font-weight: 400; font-size: var(--text-xs); color: var(--fg-tertiary); margin-left: 6px; }
.spec-row .v a.edit:hover { color: var(--color-balluff-red); }
.spec-row.empty .v { color: var(--fg-tertiary); font-weight: 400; }
.spec-flags { margin: var(--space-4) 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.spec-flags li { font-size: var(--text-sm); color: var(--color-gray-800); padding-left: 18px; position: relative; line-height: 1.5; }
.spec-flags li::before { content: ""; position: absolute; left: 0; top: 7px; width: 8px; height: 8px; background: var(--color-chart-blue); }
.spec-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-6); align-items: center; }
.spec-actions .note { font-size: var(--text-xs); color: var(--fg-tertiary); }
.spec-cta {
  cursor: pointer; font: inherit; font-weight: 650; font-size: var(--text-sm); text-decoration: none;
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
  background: var(--color-balluff-red); border: 1px solid var(--color-balluff-red); color: #fff;
}
.spec-cta:hover { background: var(--color-balluff-red-hover); text-decoration: none; }

/* ── Footer ──────────────────────────────────────────────────── */
footer.site { border-top: 1px solid var(--border-hairline); }
footer.site .foot-inner { max-width: var(--wrap); margin: 0 auto; padding: var(--space-10) var(--space-6); display: flex; gap: var(--space-6); align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
footer.site p { font-size: var(--text-xs); color: var(--fg-tertiary); max-width: 70ch; }
footer.site .wordmark { height: 12px; opacity: 0.75; }

/* ── Print: the spec is the takeaway ─────────────────────────── */
@media print {
  .rail, .hero, main .beat:not(.spec-section), footer.site, .spec-actions { display: none; }
  .spec-section { border: 0; background: #fff; }
  .spec-card { border-color: #999; }
  body { background: #fff; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 880px) {
  .rail { padding: 0 var(--space-4); gap: var(--space-3); }
  .rail .priv, .rail .ctx { display: none; }
  .hero-inner { grid-template-columns: 1fr; padding: var(--space-10) var(--space-4) var(--space-8); gap: var(--space-8); }
  .hero-sim canvas { height: 360px; }
  .hero-family { padding: 0 var(--space-4) var(--space-8); }
  .beat-inner { padding: var(--space-12) var(--space-4); }
  .sim { grid-template-columns: 1fr; gap: var(--space-6); padding: var(--space-4); }
  .sim canvas { height: 330px; }
  .hw-strip { grid-template-columns: 1fr; }
  .spec-row .v { text-align: left; }
  .spec-row { flex-direction: column; gap: 2px; }
}
