/* MetaFour Supply site layout. Builds on tokens.css and instrument.css; every colour comes from a token. */

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--space-5); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

img, svg { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { margin: 0; font-family: var(--font-sans); font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; }
h1 { font-size: clamp(34px, 5.6vw, 62px); letter-spacing: -0.04em; }
h2 { font-size: clamp(26px, 3.4vw, 38px); }
h3 { font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0; }
ul { margin: 0; padding: 0; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 4px; }

::selection { background: var(--signal); color: var(--on-signal); }

.vh {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Skip link: a key that drops in from the top edge */
.skip {
  position: absolute; left: var(--space-4); top: -80px; z-index: 100;
  background: var(--key); color: var(--ink); box-shadow: var(--shadow-key);
  border-radius: var(--radius-key); padding: 12px 16px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600; text-decoration: none;
  text-transform: uppercase; letter-spacing: .08em;
}
.skip:focus { top: var(--space-4); }

/* ---------- Bench: the page layout ---------- */
.bench {
  width: 100%;
  max-width: calc(1200px + 2 * var(--space-6));
  margin: 0 auto;
  padding: var(--space-4);
  display: grid;
  gap: var(--space-5);
}
main { display: grid; gap: var(--space-5); min-width: 0; }
main > * { min-width: 0; }

@media (min-width: 640px) {
  .lede { font-size: 18px; }
  .bench { padding: var(--space-5); gap: var(--space-6); }
  main { gap: var(--space-6); }
}
@media (min-width: 1024px) {
  .bench { padding: var(--space-6); }
}

/* Chassis tweaks: a module housing with a serial strip */
.iv-chassis { min-width: 0; }
.module { padding: var(--space-5); display: grid; gap: var(--space-5); }
@media (min-width: 900px) { .module { padding: var(--space-6); gap: var(--space-6); } }

.module-head { display: grid; gap: var(--space-3); max-width: 62ch; }
.module-head p { color: var(--ink-muted); }
.serial {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-4);
  padding-bottom: var(--space-3); border-bottom: 1px dashed var(--screw);
}
.serial .iv-label:last-child { text-align: right; }

.nowrap { white-space: nowrap; }
.lede { font-size: 17px; line-height: 1.6; max-width: 58ch; }
.muted { color: var(--ink-muted); }

/* Links styled as keys */
a.iv-key, .key-link {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  text-decoration: none; text-align: center; min-height: 44px;
}
a.iv-key:hover { color: var(--signal-text); }
a.iv-key[aria-current="page"] {
  transform: translateY(2px); box-shadow: var(--shadow-key-pressed); color: var(--signal-text);
}
.key-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.key-row .iv-key { padding: 12px 16px; font-size: 13px; letter-spacing: .04em; }

a.iv-action { text-decoration: none; }
a.iv-action:hover { text-decoration: none; }
.iv-action:disabled { opacity: .7; cursor: progress; }
.action-wrap { max-width: 420px; }

/* ---------- Header ---------- */
.masthead { padding: var(--space-4) var(--space-5); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.nameplate {
  display: inline-flex; align-items: baseline; gap: 2px;
  background: var(--plate); box-shadow: var(--shadow-recess);
  border-radius: var(--radius-key); padding: 6px 14px 8px;
  text-decoration: none; color: var(--ink); margin-right: auto;
}
.wordmark { font-family: var(--font-sans); font-weight: 800; font-size: 24px; letter-spacing: -0.04em; line-height: 1; }
.wordmark sup {
  font-family: var(--font-mono); font-weight: 600; font-size: 10.5px; letter-spacing: .06em;
  color: var(--signal-text); vertical-align: super; line-height: 0; margin-left: 2px;
}
.nameplate:hover { text-decoration: none; }

.site-nav ul { list-style: none; display: flex; gap: var(--space-2); }
.nav-key { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; padding: 12px 14px; }
.nav-key__n { font-size: 10px; color: var(--ink-muted); letter-spacing: .04em; font-weight: 400; }
.nav-key[aria-current="page"] .nav-key__n { color: inherit; }

.head-controls { display: flex; gap: var(--space-2); }
.ctl-key { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; padding: 12px 12px; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }
.ctl-key .led {
  width: 8px; height: 8px; border-radius: var(--radius-round); background: var(--screw); flex: none;
}
.ctl-key[data-mode="dark"] .led { background: var(--lcd-on); box-shadow: 0 0 6px var(--lcd-on); }
.menu-key { display: none; }

@media (max-width: 859px) {
  .js .menu-key { display: inline-flex; }
  .site-nav { order: 3; flex-basis: 100%; }
  .site-nav ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .site-nav .nav-key { width: 100%; justify-content: flex-start; }
  .js .site-nav { display: none; }
  .js .site-nav.is-open { display: block; padding-top: var(--space-2); }
}
@media (max-width: 400px) {
  .masthead { padding: var(--space-4); }
  .nameplate { padding: 6px 10px 8px; }
  .wordmark { font-size: 21px; }
  .ctl-key { padding: 12px 10px; letter-spacing: .06em; }
}

/* ---------- Readouts ---------- */
.iv-readout { min-width: 0; overflow-wrap: anywhere; }
.readout-code { font-size: clamp(40px, 11vw, 58px); line-height: 1; }
.readout-line-sm { font-size: 17px; line-height: 22px; }
@media (max-width: 480px) { .iv-readout .iv-readout__line { font-size: 17px; line-height: 22px; } }
.status-led {
  display: inline-block; width: 7px; height: 7px; border-radius: var(--radius-round);
  background: var(--lcd-on); box-shadow: 0 0 6px var(--lcd-on); margin-right: 6px; vertical-align: 1px;
}
.readout-mini { padding: var(--space-3) var(--space-4); }
.readout-mini .iv-readout__line { font-size: 15px; line-height: 20px; letter-spacing: .04em; }

/* ---------- Hero ---------- */
.hero { display: grid; gap: var(--space-6); align-items: center; }
.hero-copy { display: grid; gap: var(--space-4); align-content: start; }
.hero-copy h1 { max-width: 15ch; }
@media (min-width: 960px) {
  .hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); padding: var(--space-7) var(--space-7) var(--space-7) var(--space-7); }
}
.device {
  background-color: var(--plate);
  background-image:
    linear-gradient(var(--chassis) 1px, transparent 1px),
    linear-gradient(90deg, var(--chassis) 1px, transparent 1px);
  background-size: var(--space-6) var(--space-6);
  background-position: -1px -1px;
  box-shadow: var(--shadow-recess);
  border-radius: var(--radius-plate);
  padding: var(--space-4);
  display: grid; gap: var(--space-4);
  min-width: 0;
}
.device .iv-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.device .iv-keys .iv-key { font-size: 13px; padding: 14px 4px; }
.device-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.device-foot a { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--signal-text); }

/* ---------- Grids of plates ---------- */
.grid-3, .grid-2, .grid-4 { display: grid; gap: var(--space-4); }
@media (min-width: 720px) { .grid-2, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.iv-plate { min-width: 0; align-content: start; }
.plate-pad { padding: var(--space-5); gap: var(--space-4); }
.iv-plate p { color: var(--ink); }
.iv-plate .iv-label { color: var(--ink-muted); }

.brand-plate { grid-template-rows: auto auto auto 1fr auto; gap: var(--space-4); }
.brand-plate .tagline { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; color: var(--signal-text); }
.brand-plate .key-row { margin-top: var(--space-2); }

.ticks { list-style: none; display: grid; gap: 6px; }
.ticks li { position: relative; padding-left: 22px; }
.ticks li::before { content: "+"; position: absolute; left: 0; top: 0; font-family: var(--font-mono); font-weight: 600; color: var(--ink-muted); }
.ticks.cols { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); column-gap: var(--space-4); }

.cap-plate { gap: var(--space-3); }
.cap-plate .cap-foot { margin-top: auto; padding-top: var(--space-3); border-top: 1px dashed var(--screw); }

/* Spec tiles */
.spec-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.iv-spec { min-width: 0; box-shadow: var(--shadow-recess); }
.iv-spec .iv-label { margin-bottom: var(--space-1); }
.iv-spec__num { overflow-wrap: anywhere; }
.iv-spec p { font-size: 14px; line-height: 20px; color: var(--ink); }
@media (max-width: 420px) {
  .spec-grid { grid-template-columns: minmax(0, 1fr); }
}

.split { display: grid; gap: var(--space-6); }
@media (min-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .split--wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}
.stack { display: grid; gap: var(--space-4); align-content: start; }

/* CTA module */
.cta { display: grid; gap: var(--space-5); align-items: center; }
@media (min-width: 900px) { .cta { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.cta-side { display: grid; gap: var(--space-4); }

/* ---------- Brands page ---------- */
.brand-module { scroll-margin-top: var(--space-5); }
.brand-top { display: grid; gap: var(--space-5); }
@media (min-width: 960px) { .brand-top { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; } }
.brand-quote { font-family: var(--font-mono); font-size: 14px; line-height: 1.5; color: var(--ink-muted); }

.sw-list { list-style: none; display: grid; gap: var(--space-3); }
.sw-row {
  background: var(--key); border-radius: var(--radius-key); box-shadow: var(--shadow-key);
  padding: var(--space-3) var(--space-4); display: grid; gap: 4px;
}
.sw-row__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.sw-row__name { font-weight: 800; letter-spacing: -0.01em; font-size: 17px; }
.sw-row__status { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--signal-text); font-weight: 600; }
.sw-row p { font-size: 14.5px; line-height: 1.5; }
.sw-row a { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

.platforms { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-2); }
.platforms li {
  background: var(--key); box-shadow: var(--shadow-key); border-radius: var(--radius-key);
  padding: 10px 12px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.35; display: grid;
}
.platforms li span { color: var(--ink-muted); font-size: 11.5px; }
.platforms li.is-main { color: var(--signal-text); font-weight: 600; }

/* ---------- About wiring diagram ---------- */
.wiring { display: grid; gap: var(--space-5); justify-items: center; padding: var(--space-2) 0; }
.wiring__node {
  background: var(--key); box-shadow: var(--shadow-key); border-radius: var(--radius-key);
  padding: var(--space-3) var(--space-4); display: grid; gap: 2px; text-align: center; width: 100%; max-width: 320px;
}
a.wiring__node { text-decoration: none; color: var(--ink); }
a.wiring__node:hover strong { color: var(--signal-text); }
.wiring__node b { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; color: var(--signal-text); }
.wiring__node strong { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.wiring__node span { font-size: 14px; line-height: 1.45; color: var(--ink-muted); }
.wiring__root { position: relative; }
.wiring__root::after {
  content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: var(--space-5); margin-left: -1px; background: var(--ink-muted);
}
.wiring__row { list-style: none; display: grid; gap: var(--space-5); width: 100%; position: relative; justify-items: center; }
.wiring__row > li { position: relative; width: 100%; display: flex; justify-content: center; }
.wiring__row > li + li::before {
  content: ""; position: absolute; left: 50%; bottom: 100%; width: 2px; height: var(--space-5); margin-left: -1px; background: var(--ink-muted);
}
@media (min-width: 860px) {
  .wiring__row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); padding-top: var(--space-5); }
  .wiring__row::before {
    content: ""; position: absolute; top: 0; left: calc(100% / 6); right: calc(100% / 6); height: 2px; background: var(--ink-muted);
  }
  .wiring__row > li::before, .wiring__row > li + li::before {
    content: ""; position: absolute; left: 50%; bottom: 100%; top: auto; width: 2px; height: var(--space-5); margin-left: -1px; background: var(--ink-muted);
  }
  .wiring__row .wiring__node { max-width: none; height: 100%; }
}

/* ---------- Contact ---------- */
.contact-grid { display: grid; gap: var(--space-5); }
@media (min-width: 960px) { .contact-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; } }
.form { display: grid; gap: var(--space-4); }
.form-row { display: grid; gap: var(--space-4); }
@media (min-width: 640px) { .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field { margin: 0; border: 0; min-width: 0; gap: var(--space-2); }
fieldset.field { padding: var(--space-4); }
.field label, .field legend { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); font-weight: 600; }
.field legend { float: left; width: 100%; padding: 0; margin-bottom: var(--space-2); }
.field legend + * { clear: both; }
.req { color: var(--signal-text); margin-left: 2px; }
.opt { color: var(--ink-muted); font-weight: 400; letter-spacing: .08em; }
.hint { font-size: 13px; line-height: 1.4; color: var(--ink-muted); }
.field-foot { display: flex; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.counter { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.input {
  width: 100%; min-width: 0; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--key); border: 1px solid var(--ink-muted); border-radius: var(--radius-key);
  box-shadow: var(--shadow-recess); padding: 11px 12px; min-height: 46px;
}
.input:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
textarea.input { min-height: 180px; resize: vertical; line-height: 1.5; }
.input[aria-invalid="true"] { border-color: var(--signal-text); border-width: 2px; padding: 10px 11px; }
.err { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.4; color: var(--signal-text); font-weight: 600; }
.err:empty { display: none; }

.topic-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: var(--space-2); }
.topic-key { position: relative; display: block; }
.topic-key input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.topic-key span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 8px;
  background: var(--key); color: var(--ink); border-radius: var(--radius-key); box-shadow: var(--shadow-key);
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  transition: transform .06s, box-shadow .06s; pointer-events: none;
}
.topic-key input:checked + span { transform: translateY(2px); box-shadow: var(--shadow-key-pressed); color: var(--signal-text); }
.topic-key input:checked + span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--signal-text); margin-right: 8px; }
.topic-key input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 3px; }
.topic-key:hover span { color: var(--signal-text); }

.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.form-status .iv-readout__line { font-size: 18px; line-height: 24px; }
.form-status [data-status-msg] { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; color: var(--lcd-on); }
.form-status[data-state="error"] .status-led { background: var(--signal); box-shadow: 0 0 6px var(--signal); }

.email-link { font-family: var(--font-mono); font-weight: 600; font-size: 15px; overflow-wrap: anywhere; color: var(--signal-text); }

/* ---------- Legal prose ---------- */
.doc { display: grid; gap: var(--space-5); }
@media (min-width: 1000px) { .doc { grid-template-columns: 260px minmax(0, 1fr); align-items: start; } }
.toc { position: static; }
@media (min-width: 1000px) { .toc { position: sticky; top: var(--space-5); } }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: block; padding: 6px 0; font-family: var(--font-mono); font-size: 12.5px; text-decoration: none; color: var(--ink); }
.toc a::before { content: counter(toc, decimal-leading-zero) "  "; color: var(--ink-muted); white-space: pre; }
.toc a:hover { color: var(--signal-text); }
.prose { display: grid; gap: var(--space-4); max-width: 70ch; padding: var(--space-5); }
.prose h2 { font-size: 22px; letter-spacing: -0.02em; margin-top: var(--space-4); scroll-margin-top: var(--space-5); }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 1.2em; display: grid; gap: 6px; }
.prose li::marker { color: var(--ink-muted); }
.prose a { color: var(--signal-text); font-weight: 600; }

/* ---------- 404 ---------- */
.err-panel { display: grid; gap: var(--space-5); justify-items: start; }
.err-panel .iv-readout { width: 100%; }
.err-code { font-size: clamp(56px, 16vw, 120px); line-height: 1; }

/* ---------- Footer ---------- */
.foot { padding: var(--space-5); display: grid; gap: var(--space-5); }
@media (min-width: 900px) { .foot { padding: var(--space-6); } }
.foot-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.foot-brand { grid-column: 1 / -1; display: grid; gap: var(--space-3); justify-items: start; }
@media (min-width: 900px) {
  .foot-grid { grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); }
  .foot-brand { grid-column: auto; }
}
.foot-brand p { font-size: 14px; color: var(--ink-muted); max-width: 36ch; }
.foot-col { display: grid; gap: var(--space-2); align-content: start; }
.foot-col ul { list-style: none; display: grid; gap: 2px; }
.foot-col a { display: inline-block; padding: 6px 0; font-size: 14.5px; text-decoration: none; }
.foot-col a:hover { text-decoration: underline; }
.foot-base {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-4);
  padding-top: var(--space-4); border-top: 1px dashed var(--screw);
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted);
}
.foot-base a { color: var(--ink); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
