/* Mooring: an FM front panel, printed like its manual.
   Tokens are the app's (fm-tuner DESIGN.md § Colour tokens). Do not add colours. */

:root {
  color-scheme: light dark;
  --canvas: #E9E2D4;
  --surface: #F4EFE5;
  --bezel: #0F0C0B;
  --rule: #C7B9A5;
  --ink: #221C19;
  --ink-muted: #5B514A;
  --silk: #4A3F39;
  --burgundy: #6E1E30;
  --burgundy-lit: #B03E57;
  --on-burgundy: #F6EDDF;
  --teal: #2C7262;
  --teal-text: #24685A;
  --on-teal: #F6EDDF;
  --lcd: #B5CF6A;
  --lcd-ink: #1B240E;
  --led: #FF3B2E;
  --led-window: #170B09;
  --loop-lit: #2C7262;
  --caution: #7E5200;
  --lcd-glow: none;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 72rem;
  --gutter: max(1rem, env(safe-area-inset-left));
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #15110F;
    --surface: #221D1B;
    --rule: #3D342F;
    --ink: #F1E8D8;
    --ink-muted: #A99C8C;
    --silk: #D9CDBA;
    --burgundy: #7A2235;
    --teal: #3C8F7C;
    --teal-text: #72C7B1;
    --on-teal: #0C1C17;
    --loop-lit: #B5CF6A;
    --caution: #E8B04B;
    --lcd-glow: 0 0 2.5rem -.25rem color-mix(in srgb, var(--lcd) 45%, transparent);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 1.125rem/1.6 var(--sans);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--teal-text); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--teal-text); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.15; margin: 0; text-wrap: balance; }
p, ul, ol { margin: 0; }
p { text-wrap: pretty; }

.skip {
  position: absolute; left: var(--gutter); top: -4rem;
  background: var(--ink); color: var(--canvas);
  padding: .75rem 1rem; border-radius: 6px; z-index: 10;
}
.skip:focus { top: .75rem; }

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

/* Silkscreen label: condensed, uppercase, tracked. */
.silk {
  font-size: .75rem;
  font-weight: 600;
  font-stretch: condensed;
  letter-spacing: .14em;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--silk);
}
.silk--rule { display: flex; align-items: center; gap: .875rem; margin-bottom: 1.25rem; }
.silk--rule::after { content: ""; flex: 1; height: 1px; background: var(--rule); order: 1; }
.silk--rule > span:nth-child(2) { order: 2; }

/* ---------- header & footer ---------- */
header.site {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1rem var(--gutter) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: .6rem;
  min-height: 44px;
  padding: .5rem 0;
  color: var(--ink);
  text-decoration: none;
}
.wordmark-name {
  font-size: 1.25rem;
  font-weight: 900;
  font-stretch: expanded;
  letter-spacing: .3em;
  text-transform: uppercase;
  margin-right: -.3em;
}
.wordmark-for { font-size: .8125rem; font-weight: 600; color: var(--ink-muted); }
header.site nav { display: flex; gap: .25rem; }
header.site nav a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 .75rem;
  font-size: .8125rem; font-weight: 600;
  font-stretch: condensed; letter-spacing: .14em; text-transform: uppercase;
  color: var(--silk); text-decoration: none;
}
header.site nav a:hover { color: var(--ink); text-decoration: underline; }

footer.site {
  border-top: 1px solid var(--rule);
  padding: 2.5rem 0 3rem;
  color: var(--ink-muted);
  font-size: 1rem;
}
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; }
footer.site ul { list-style: none; padding: 0; display: flex; gap: 1.5rem; }
footer.site a { display: inline-flex; align-items: center; min-height: 44px; }
.disclaimer { margin-top: 1rem; font-size: .875rem; max-width: 60ch; }

/* ---------- membrane keys ---------- */
.keys { display: flex; flex-wrap: wrap; gap: .75rem; }
.key {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 48px;
  padding: 0 1.25rem;
  border: 1px solid var(--silk);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: .875rem;
  font-weight: 700;
  font-stretch: condensed;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
}
.key:hover { background: var(--surface); text-decoration: none; }
.key--flash { background: var(--burgundy); border-color: var(--burgundy); color: var(--on-burgundy); }
.key--flash:hover { background: var(--burgundy-lit); border-color: var(--burgundy-lit); }

/* ---------- LCD ---------- */
.lcd {
  --cell: color-mix(in srgb, var(--lcd-ink) 7%, transparent);
  display: inline-grid;
  max-width: 100%;
  padding: .55em .8em;
  background: var(--lcd);
  color: var(--lcd-ink);
  border: .45rem solid var(--bezel);
  border-radius: .75rem;
  box-shadow: var(--lcd-glow);
  font: 600 clamp(.8rem, 4.2vw, 1.375rem)/1.35 var(--mono);
  letter-spacing: .2ch;
  white-space: pre;
  text-transform: uppercase;
}
.lcd-line { background: repeating-linear-gradient(90deg, var(--cell) 0 1ch, transparent 1ch 1.2ch); }
.lcd-line + .lcd-line { margin-top: .2em; }

/* ---------- LED ---------- */
.led {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: end;
  gap: .4rem .6rem;
  margin-top: 2rem;
  padding: 1rem 1.25rem 1.1rem;
  background: var(--led-window);
  border: 1px solid var(--bezel);
  border-radius: 10px;
}
.led-digits { height: 3.5rem; width: auto; overflow: visible; }
.seg-on { fill: var(--led); filter: drop-shadow(0 0 4px color-mix(in srgb, var(--led) 70%, transparent)); }
.seg-off { fill: var(--led); opacity: .09; }
.led-unit { font: 700 1.25rem/1 var(--sans); color: #D9CDBA; padding-bottom: .2rem; }
.led-total {
  grid-column: 1 / -1;
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding-top: .6rem;
  border-top: 1px solid #3D342F;
}
.led-count { font: 700 1.125rem/1 var(--mono); color: var(--led); text-shadow: 0 0 6px color-mix(in srgb, var(--led) 60%, transparent); }
.led-total .silk { color: #D9CDBA; }

/* ---------- algorithm chart ---------- */
.algo { width: 100%; height: auto; overflow: visible; }
.algo-route path { stroke: var(--rule); stroke-width: 1.5; }
.algo .algo-broken { stroke-dasharray: 2 5; opacity: .7; }
.algo-loop { stroke: var(--loop-lit); stroke-width: 2; stroke-dasharray: 4 3; }
.op { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
.op rect { fill: currentColor; stroke-width: 1.5; }
.op text { stroke: none; }
.op-n { font: 700 15px var(--mono); }
.op-label { font: 600 10.5px var(--sans); font-stretch: condensed; letter-spacing: .14em; fill: var(--silk); }
.op-out { font-size: 9.5px; }

/* Static frame: writing. Steps 1-3 done, 4 lit, 5-6 idle. */
.algo--run :is(.op1, .op2, .op3) { color: var(--teal); stroke: var(--teal); fill: var(--on-teal); }
.algo--run .op4 { color: var(--lcd); stroke: var(--lcd); fill: var(--lcd-ink); }
@media (prefers-color-scheme: dark) {
  .algo--run .op4 { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--lcd) 60%, transparent)); }
  .algo-loop { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--lcd) 50%, transparent)); }
}

/* The sequence: 14 s, each step lit in turn, Write held longest. */
@media (prefers-reduced-motion: no-preference) {
  .algo--run .op { animation: 14s linear infinite both; }
  .algo--run .op1 { animation-name: op1; }
  .algo--run .op2 { animation-name: op2; }
  .algo--run .op3 { animation-name: op3; }
  .algo--run .op4 { animation-name: op4; }
  .algo--run .op5 { animation-name: op5; }
  .algo--run .op6 { animation-name: op6; }
  .algo--run .algo-loop { animation: loop-run .7s linear infinite, loop-on 14s linear infinite both; }
}
@keyframes loop-run { to { stroke-dashoffset: -14; } }
@keyframes loop-on {
  0%, 20.5% { stroke: var(--rule); opacity: .6; }
  21%, 63% { stroke: var(--loop-lit); opacity: 1; }
  63.5%, 100% { stroke: var(--rule); opacity: .6; }
}
@keyframes op1 {
  0%, 6.5% { color: var(--lcd); stroke: var(--lcd); fill: var(--lcd-ink); }
  7%, 91.5% { color: var(--teal); stroke: var(--teal); fill: var(--on-teal); }
  92%, 100% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
}
@keyframes op2 {
  0%, 6.5% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
  7%, 13.5% { color: var(--lcd); stroke: var(--lcd); fill: var(--lcd-ink); }
  14%, 91.5% { color: var(--teal); stroke: var(--teal); fill: var(--on-teal); }
  92%, 100% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
}
@keyframes op3 {
  0%, 13.5% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
  14%, 20.5% { color: var(--lcd); stroke: var(--lcd); fill: var(--lcd-ink); }
  21%, 91.5% { color: var(--teal); stroke: var(--teal); fill: var(--on-teal); }
  92%, 100% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
}
@keyframes op4 {
  0%, 20.5% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
  21%, 62.5% { color: var(--lcd); stroke: var(--lcd); fill: var(--lcd-ink); }
  63%, 91.5% { color: var(--teal); stroke: var(--teal); fill: var(--on-teal); }
  92%, 100% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
}
@keyframes op5 {
  0%, 62.5% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
  63%, 71.5% { color: var(--lcd); stroke: var(--lcd); fill: var(--lcd-ink); }
  72%, 91.5% { color: var(--teal); stroke: var(--teal); fill: var(--on-teal); }
  92%, 100% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
}
@keyframes op6 {
  0%, 71.5% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
  72%, 80.5% { color: var(--lcd); stroke: var(--lcd); fill: var(--lcd-ink); }
  81%, 91.5% { color: var(--teal); stroke: var(--teal); fill: var(--on-teal); }
  92%, 100% { color: transparent; stroke: var(--rule); fill: var(--ink-muted); }
}

/* ---------- screenshots ---------- */
.device {
  --pad: clamp(5px, 1.3vw, 9px);
  --radius: clamp(26px, 5.5vw, 46px);
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  padding: var(--pad);
  background: var(--bezel);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--rule), 0 1.5rem 3rem -1.5rem rgb(15 12 11 / .45);
}
.device img { width: 100%; height: auto; border-radius: calc(var(--radius) - var(--pad)); }

/* ---------- landing ---------- */
.landing h2 { font-size: clamp(1.75rem, 4.2vw, 2.75rem); font-weight: 800; letter-spacing: -.015em; margin-bottom: 1rem; }
.landing h3 { font-size: 1.125rem; font-weight: 700; }
.landing p + p { margin-top: 1rem; }

.hero {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) var(--gutter) clamp(3rem, 8vw, 6rem);
  display: grid;
  gap: clamp(2.5rem, 6vw, 4rem);
  align-items: center;
}
.hero-copy .lcd { margin-bottom: clamp(1.75rem, 4vw, 2.5rem); }
.hero h1 {
  font-size: clamp(2.25rem, 6.2vw, 4.25rem);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -.025em;
  max-width: 15ch;
}
.lede { margin: 1.5rem 0 2rem; font-size: clamp(1.125rem, 2vw, 1.25rem); color: var(--ink-muted); max-width: 50ch; }
.hero-shot .device { max-width: min(20rem, 78vw); }

.band { padding: clamp(3.5rem, 10vw, 7rem) 0; border-top: 1px solid var(--rule); }
.band--surface { background: var(--surface); }
.band p:not(.silk) { max-width: 60ch; }
.note { color: var(--ink-muted); font-size: 1rem; }

.algo-grid { display: grid; gap: 3rem; align-items: center; }
.algo-wrap {
  padding: clamp(1.25rem, 4vw, 2.25rem);
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
}
.algo-wrap .algo { max-width: 30rem; margin: 0 auto; }

.steps {
  list-style: none;
  padding: 0;
  margin-top: clamp(2.5rem, 6vw, 4rem);
  display: grid;
  gap: clamp(3rem, 7vw, 4rem) clamp(1.5rem, 4vw, 3rem);
}
/* Phones: screenshot beside its text, so six steps don't stack into a 10,000px page. */
.step { display: grid; grid-template-columns: minmax(7.5rem, 40%) 1fr; gap: 1.25rem; align-items: center; }
.step .device { --pad: 4px; --radius: 22px; max-width: none; margin: 0; }
.step-text { display: grid; gap: .5rem; align-content: center; }
.step-text p { color: var(--ink-muted); font-size: 1rem; }
.op-badge {
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: 4px;
  background: var(--teal); color: var(--on-teal);
  font: 700 1rem var(--mono);
}

.two-col { display: grid; gap: 3rem; align-items: start; }
.checklist { list-style: none; padding: 0; margin-top: 1.5rem; display: grid; gap: .875rem; }
.checklist li { position: relative; padding-left: 2rem; }
.checklist li::before {
  content: "";
  position: absolute; left: 0; top: .3em;
  width: 1.125rem; height: 1.125rem;
  border-radius: 3px;
  background: var(--teal);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M0 0h18v18H0z' fill='%23000'/%3E%3Cpath d='M4.5 9.2 7.6 12.3 13.5 6' fill='none' stroke='%23fff' stroke-width='2.2'/%3E%3C/svg%3E") center / contain luminance;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M0 0h18v18H0z' fill='%23fff'/%3E%3Cpath d='M4.5 9.2 7.6 12.3 13.5 6' fill='none' stroke='%23000' stroke-width='2.2'/%3E%3C/svg%3E") center / contain luminance;
}
.caution {
  padding: 1.5rem 1.5rem 1.6rem;
  border-left: 4px solid var(--caution);
  background: var(--canvas);
  border-radius: 0 8px 8px 0;
}
.caution .silk { color: var(--caution); margin-bottom: .5rem; }

.practice-lcd { display: flex; justify-content: center; }

.measure { max-width: 60ch; }
.banks { counter-reset: slot; display: grid; gap: 2rem; margin-top: 2.5rem; }
.bank .silk { margin-bottom: .875rem; }
.slots { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(9.5rem, 100%), 1fr)); gap: .5rem; }
.slots li {
  counter-increment: slot;
  display: flex; align-items: baseline; gap: .75rem;
  padding: .7rem .9rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--canvas);
  font: 600 .9375rem/1.3 var(--mono);
}
.slots li::before {
  content: counter(slot, decimal-leading-zero);
  font: 600 .75rem var(--sans); font-stretch: condensed; letter-spacing: .1em;
  color: var(--silk);
}

@media (max-width: 26rem) {
  .wordmark-name { font-size: 1.0625rem; letter-spacing: .22em; margin-right: -.22em; }
  .wordmark { gap: .45rem; }
  header.site nav a { padding: 0 .5rem; }
  header.site nav { margin-right: -.5rem; }
}
@media (min-width: 36rem) {
  .steps { grid-template-columns: repeat(2, 1fr); }
  .step { grid-template-columns: none; gap: 1.5rem; align-items: start; align-content: start; }
  .step .device { --pad: clamp(5px, 1.3vw, 9px); --radius: clamp(26px, 5.5vw, 46px); max-width: min(15rem, 72vw); }
  .step-text { grid-template-columns: auto 1fr; gap: .25rem .875rem; align-items: center; }
  .step-text p { grid-column: 2; }
}
@media (min-width: 60rem) {
  .hero { grid-template-columns: 1.25fr .75fr; }
  .algo-grid { grid-template-columns: 1fr 1.1fr; gap: 4rem; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1.2fr .8fr; gap: 4rem; }
  .banks { grid-template-columns: 1fr 3fr; }
}

/* ---------- reading pages (privacy, support, 404) ---------- */
.prose {
  max-width: calc(65ch + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(3rem, 8vw, 5rem);
}
.prose h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: 1.25rem; }
.prose h2 {
  font-size: 1.25rem; font-weight: 700;
  margin: 2.75rem 0 .75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
.prose p, .prose ul { margin: .875rem 0; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin: .5rem 0; padding-left: .25rem; }
.prose li::marker { color: var(--silk); }
.prose strong { font-weight: 700; }
.prose .key { margin-top: 1rem; }

/* Support: the failure section as a calm caution callout. */
.prose h2#if-an-update-fails {
  margin-bottom: 0;
  padding: 1.25rem 1.5rem .5rem;
  border-top: 0;
  border-left: 4px solid var(--caution);
  border-radius: 0 8px 0 0;
  background: var(--surface);
}
.prose h2#if-an-update-fails + p {
  margin-top: 0;
  padding: 0 1.5rem 1.4rem;
  border-left: 4px solid var(--caution);
  border-radius: 0 0 8px 0;
  background: var(--surface);
}

.algo-wrap--404 { margin: 2.5rem 0 1.5rem; }
.algo-wrap--404 .algo { max-width: 22rem; }
