/* DesignSDK — The Signal
   Flat, dark, high-contrast. Solid colours only, no blends, no glows. */

:root {
  --bg: #0A0A0B;
  --surface: #131416;
  --line: #26282C;
  --text: #ECEAE4;
  --muted: #9A9DA3;
  --signal: #FFB547;
  --ink-on-signal: #0A0A0B;

  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --wrap: 1120px;
  --gutter: clamp(20px, 5vw, 56px);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(17px, 1.05rem + 0.2vw, 20px);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; }

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

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  padding: 8px 14px;
  background: var(--signal);
  color: var(--ink-on-signal);
  font-family: var(--mono);
  font-size: 14px;
  text-decoration: none;
  z-index: 10;
}
.skip:focus { top: 12px; }

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

.muted { color: var(--muted); }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--signal);
}

/* ---------- Hero ---------- */

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 96px 0 72px;
}

.hero-inner { display: grid; gap: 40px; }

.kicker,
.chapter-label,
.decoder-title,
.decoder-status,
figcaption,
.scroll-cue,
.site-footer {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kicker {
  margin: 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--signal);
  display: inline-block;
  animation: blink 2.4s steps(1, end) infinite;
}

@keyframes blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0; }
}

.hero-title {
  margin: 0;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(40px, 7vw, 96px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  max-width: 15ch;
}

.hero-title em {
  font-style: normal;
  color: var(--signal);
}

.hero-lede {
  margin: 0;
  max-width: 34em;
  color: var(--muted);
  font-size: clamp(18px, 1.1rem + 0.4vw, 22px);
}

/* hello in binary */
.hello { margin: 8px 0 0; }

.hello-grid {
  display: inline-grid;
  gap: 6px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.byte {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1;
}

.byte-bits { color: var(--muted); letter-spacing: 0.12em; }

.byte-cells { display: grid; grid-template-columns: repeat(8, 12px); gap: 3px; }

.byte-cells i { display: block; width: 12px; height: 12px; }
.byte-cells .on { background: var(--text); }
.byte-cells .off { background: var(--line); }

.byte-char { color: var(--signal); width: 1ch; }

.hello figcaption { margin-top: 12px; color: var(--muted); }

.scroll-cue {
  justify-self: start;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.scroll-cue:hover { border-color: var(--signal); color: var(--signal); }

/* ---------- Chapters ---------- */

.chapter {
  padding: clamp(80px, 12vw, 160px) 0;
  border-bottom: 1px solid var(--line);
}

.chapter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.chapter-no {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
  color: var(--line);
  letter-spacing: 0.04em;
}

.chapter-body { max-width: 40em; }

.chapter-label { margin: 0 0 18px; color: var(--signal); }

.chapter h2,
.coda h2 {
  margin: 0 0 28px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(28px, 3.6vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.chapter-body p { margin: 0 0 1.1em; }
.chapter-body p:last-child { margin-bottom: 0; }

strong { color: var(--text); font-weight: 700; }

.pull {
  margin: 48px 0 0;
  padding: 4px 0 4px 24px;
  border-left: 4px solid var(--signal);
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--muted);
}
.pull span { display: block; color: var(--text); }

@media (min-width: 900px) {
  .chapter-grid {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 48px;
  }
  .chapter-no { position: sticky; top: 48px; align-self: start; }
}

/* ---------- Decoder ---------- */

.chapter--decoder .decoder { margin-top: clamp(48px, 7vw, 80px); }

@media (min-width: 900px) {
  .chapter--decoder .decoder { margin-left: 268px; }
}

.decoder {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: clamp(18px, 3vw, 32px);
  max-width: 760px;
}

.decoder-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.decoder-title { margin: 0; color: var(--text); text-transform: none; letter-spacing: 0.02em; }

.decoder-controls { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); }

.decoder-controls button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 14px;
  cursor: pointer;
}
.decoder-controls button:last-child { border-right: 0; }
.decoder-controls button:hover { color: var(--text); }
.decoder-controls button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.signal-field {
  --cols: 23;
  font-family: var(--mono);
  min-height: 200px;
}

/* stream mode: raw text */
.signal-field[data-mode="stream"] {
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0.08em;
  word-break: break-all;
  color: var(--line);
}
.signal-field[data-mode="stream"] .b { display: inline; }
.signal-field[data-mode="stream"] .b1 { color: var(--muted); }

/* grid modes */
.signal-field[data-mode="wrong"],
.signal-field[data-mode="right"] {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 2px;
  max-width: 460px;
  margin: 0 auto;
  font-size: 0;
  line-height: 0;
}
.signal-field[data-mode="wrong"] .b,
.signal-field[data-mode="right"] .b {
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  transition: background-color 0.35s steps(3, end);
}
.signal-field[data-mode="wrong"] .b1 { background: var(--muted); }
.signal-field[data-mode="right"] .b1 { background: var(--signal); }

.decoder-status { margin: 24px 0 0; color: var(--signal); min-height: 1.4em; }

.noscript { margin: 0; color: var(--muted); }

/* ---------- Kit ---------- */

.kit {
  list-style: none;
  margin: clamp(48px, 7vw, 80px) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.kit li { background: var(--bg); padding: 32px 28px 36px; }

.kit-no {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-on-signal);
  background: var(--signal);
  padding: 3px 8px;
  margin-bottom: 28px;
}

.kit h3 {
  margin: 0 0 12px;
  font-family: var(--sans);
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.kit p { margin: 0; color: var(--muted); font-size: 0.95em; }

/* ---------- Coda ---------- */

.coda { padding: clamp(96px, 14vw, 180px) 0; }

.coda-inner { max-width: 820px; text-align: left; }

.coda h2 { font-size: clamp(32px, 5vw, 64px); max-width: 16ch; }

.coda-text { margin: 0 0 40px; color: var(--muted); max-width: 34em; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 18px 28px;
  background: var(--signal);
  color: var(--ink-on-signal);
  border: 2px solid var(--signal);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--bg); color: var(--signal); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 0;
  color: var(--muted);
}
.site-footer p { margin: 0; }

/* ---------- Motion ---------- */

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