/* ============================================================================
   theme.css — the shared "TEST BENCH" component kit.
   ----------------------------------------------------------------------------
   Loaded after /tokens.css on every primary page. Owns the components that
   repeat across surfaces: nav, footer, cards + registration ticks, traces,
   chips, buttons, gauges, form fields, the telemetry ticker, and the motion
   layer (scroll reveals + micro-interactions). Page files keep only their
   page-specific layout.
   ========================================================================== */

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: rgb(var(--ink));
}
.prose { font-family: var(--font-ui); color: rgb(var(--ink-dim)); max-width: 56ch; }
a { color: inherit; text-decoration: none; }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

/* a consistent, visible focus ring across all interactive elements */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid rgb(var(--cyan));
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- top nav ---------------------------------------------------------------
   Bone glass over the bench; gains a shadow once you scroll (.scrolled is
   toggled by theme.js). The 2px orange rule under it is the scroll-progress
   meter (scaleX driven by theme.js via --progress). */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: rgb(var(--canvas) / 0.85);
  border-bottom: 1px solid rgb(var(--hairline));
  transition: box-shadow var(--dur-base) var(--ease);
}
.nav.scrolled { box-shadow: 0 4px 24px rgb(28 26 21 / 0.08); }
.nav::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: rgb(var(--amber));
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
  pointer-events: none;
}
.nav .wrap { display: flex; align-items: center; gap: var(--space-6); height: 60px; }
.brand { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; font-size: var(--fs-md); color: rgb(var(--ink)); }
.brand .dot { color: rgb(var(--amber)); }
.nav-links { display: flex; gap: var(--space-5); margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: rgb(var(--ink-dim)); }
.nav-links a { position: relative; padding: 4px 0; transition: color var(--dur-fast) var(--ease); }
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 1.5px; width: 100%;
  background: rgb(var(--amber));
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-base) var(--ease-out);
}
.nav-links a:hover, .nav-links a:focus-visible, .nav-links a[aria-current="page"] { color: rgb(var(--ink)); }
.nav-links a:hover::after, .nav-links a:focus-visible::after, .nav-links a[aria-current="page"]::after { transform: scaleX(1); }

.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; color: rgb(var(--green)); letter-spacing: 0.06em; }
.status .led { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--green)); box-shadow: 0 0 0 3px rgb(var(--green) / 0.18); animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* --- eyebrow with the leading index tick ---------------------------------- */
.eyebrow { display: inline-flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: rgb(var(--amber)); }

/* --- card + registration corner ticks (the drafting-mark motif) ----------- */
.card {
  position: relative;
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--hairline));
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card.ticks::before, .card.ticks::after,
.card.ticks > .tick-bl, .card.ticks > .tick-br {
  content: ""; position: absolute; width: 9px; height: 9px;
  border-color: rgb(var(--ink) / 0.30); pointer-events: none;
  transition: border-color var(--dur-base) var(--ease);
}
.card.ticks::before { top: 7px; left: 7px; border-top: 1.5px solid; border-left: 1.5px solid; }
.card.ticks::after  { top: 7px; right: 7px; border-top: 1.5px solid; border-right: 1.5px solid; }
.card.ticks > .tick-bl { bottom: 7px; left: 7px; border-bottom: 1.5px solid; border-left: 1.5px solid; }
.card.ticks > .tick-br { bottom: 7px; right: 7px; border-bottom: 1.5px solid; border-right: 1.5px solid; }
.card.ticks:hover::before, .card.ticks:hover::after,
.card.ticks:hover > .tick-bl, .card.ticks:hover > .tick-br { border-color: rgb(var(--amber) / 0.8); }

/* --- trace divider (PCB line + via dots) ----------------------------------- */
.trace { display: flex; align-items: center; gap: 0; margin: var(--space-10) 0; color: rgb(var(--ink) / 0.28); }
.trace .line { height: 1px; background: currentColor; flex: 1; }
.trace .via { width: 7px; height: 7px; border: 1.5px solid currentColor; border-radius: 50%; flex: none; }
.trace .seg { width: 14px; height: 14px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-7px); flex: none; }
.trace .label { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; color: rgb(var(--ink-mute)); padding: 0 var(--space-3); white-space: nowrap; letter-spacing: 0.08em; }

/* --- chips (status pills) --------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; padding: 5px 9px; border-radius: var(--radius-sm); border: 1px solid; }
.chip.ok   { color: rgb(var(--green)); border-color: rgb(var(--green) / 0.45); background: var(--green-soft); }
.chip.warn { color: rgb(var(--warn));  border-color: rgb(var(--warn) / 0.45);  background: var(--warn-soft); }
.chip.bad  { color: rgb(var(--red));   border-color: rgb(var(--red) / 0.45);   background: var(--red-soft); }
.chip.mute { color: rgb(var(--ink-mute)); border-color: rgb(var(--hairline)); background: rgb(var(--elevated)); }

/* --- buttons ----------------------------------------------------------------
   Primary = the orange tool. Ghost = inked outline. Data = cobalt. */
.btn {
  display: inline-flex; gap: 10px; align-items: center;
  font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-sm);
  color: rgb(var(--paper-hi)); background: rgb(var(--amber));
  padding: 12px 20px; border-radius: var(--radius); border: none; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgb(var(--amber) / 0.32); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn > span:last-child { transition: transform var(--dur-base) var(--ease-out); }
.btn:hover > span:last-child { transform: translateX(3px); }
.btn.ghost { background: transparent; color: rgb(var(--ink)); border: 1px solid rgb(var(--ink) / 0.35); }
.btn.ghost:hover { border-color: rgb(var(--ink)); box-shadow: none; background: rgb(var(--ink) / 0.04); }
.btn.cyan, .btn.data { background: rgb(var(--cyan)); }
.btn.cyan:hover, .btn.data:hover { box-shadow: 0 10px 28px rgb(var(--cyan) / 0.30); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* --- gauge / meter ----------------------------------------------------------- */
.gauge { padding: var(--space-4); }
.gauge .lab { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: rgb(var(--ink-mute)); }
.gauge .big { font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-lg); line-height: 1.1; margin-top: 4px; color: rgb(var(--ink)); }
.gauge .big .unit { font-size: var(--fs-sm); color: rgb(var(--ink-mute)); font-weight: 500; }
.bar { height: 5px; border-radius: 3px; background: rgb(var(--ink) / 0.12); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; transition: width var(--dur-slow) var(--ease), background var(--dur-base); }
/* meters: width animates in when revealed (target carried in --w) */
.bar > i.meter { width: 0; transition: width 900ms var(--ease) 150ms; }
.in .bar > i.meter, .bar > i.meter.in { width: var(--w, 0%); }

/* --- form fields ------------------------------------------------------------- */
.field label, .auth-form label { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: rgb(var(--ink-mute)); display: flex; flex-direction: column; gap: 6px; }
.field input, .auth-form input {
  font-family: var(--font-mono); font-size: var(--fs-sm); color: rgb(var(--ink));
  background: rgb(var(--paper-hi)); border: 1px solid rgb(var(--hairline)); border-radius: var(--radius-sm);
  padding: 11px 12px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field input:hover, .auth-form input:hover { border-color: rgb(var(--ink) / 0.35); }
.field input:focus, .auth-form input:focus { outline: none; border-color: rgb(var(--cyan)); box-shadow: var(--ring-data); }
.field label:focus-within, .auth-form label:focus-within { color: rgb(var(--cyan)); }
.form-err, .form-note { font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.5; border-radius: var(--radius-sm); padding: 8px 10px; margin: 0; }
.form-err  { color: rgb(var(--red));   background: var(--red-soft);   border: 1px solid rgb(var(--red) / 0.4); }
.form-note { color: rgb(var(--green)); background: var(--green-soft); border: 1px solid rgb(var(--green) / 0.4); }

/* --- telemetry ticker --------------------------------------------------------
   A graphite conveyor strip. Markup: .ticker > .ticker-belt > 2× .ticker-run
   (the duplicate run makes the loop seamless). Pauses on hover; static when
   the user prefers reduced motion. */
.ticker { overflow: hidden; background: rgb(var(--screen)); border-block: 1px solid rgb(var(--screen-edge)); }
.ticker-belt { display: flex; width: max-content; animation: belt 46s linear infinite; }
.ticker:hover .ticker-belt { animation-play-state: paused; }
.ticker-run { display: flex; align-items: center; gap: var(--space-6); padding: 10px var(--space-3) 10px var(--space-6); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.1em; color: rgb(var(--screen-dim)); white-space: nowrap; }
.ticker-run b { color: rgb(var(--screen-ink)); font-weight: 600; }
.ticker-run .tick-sep { color: rgb(255 138 76); }
@keyframes belt { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-belt { animation: none; } }

/* --- scroll reveals -----------------------------------------------------------
   theme.js flips .in when an element enters the viewport. Stagger with
   --d (e.g. style="--d:120ms"). Falls back to visible when scripting is off. */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity var(--dur-slow) var(--ease) var(--d, 0ms), transform var(--dur-slow) var(--ease) var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; }
@media (scripting: none) {
  .reveal { opacity: 1; transform: none; }
  .bar > i.meter { width: var(--w, 0%); }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  .bar > i.meter { width: var(--w, 0%); }
}

/* --- footer: the bench's anodized base plate ---------------------------------- */
footer.bench {
  margin-top: var(--space-10);
  background: rgb(var(--screen));
  border-top: 2px solid rgb(var(--amber));
  color: rgb(var(--screen-dim));
  font-family: var(--font-mono); font-size: var(--fs-xs);
  padding: var(--space-6) 0;
}
footer.bench .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); }
footer.bench .brandline { color: rgb(var(--screen-ink)); }
footer.bench .brandline .dot { color: rgb(255 138 76); }
footer.bench a { color: rgb(var(--screen-dim)); transition: color var(--dur-fast) var(--ease); }
footer.bench a:hover, footer.bench a:focus-visible { color: rgb(var(--screen-ink)); }
footer.bench .links a { margin-left: var(--space-4); }

/* --- live row (dashboard telemetry strip) -------------------------------------- */
.live-row { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; color: rgb(var(--ink-mute)); }
.live-row .clock { font-weight: 600; color: rgb(var(--ink)); font-variant-numeric: tabular-nums; }
.live-row .feed { color: rgb(var(--ink-dim)); transition: opacity var(--dur-base) var(--ease); }
.live-row .feed.swap { opacity: 0; }

@media (max-width: 880px) {
  .nav-links { display: none; }
}
