/* Dapaba — one stylesheet for the whole site. Every colour and size is a token below. */

:root {
  --ground: #f2f2ef;
  --ground-2: #e4e3de;
  --ink: #121211;
  --ink-2: #55544f;
  --accent: #d9261c;
  --on-accent: #ffffff;
  --field: #141413;
  --field-ink: #eeede8;
  --field-2: #232321;
  --board: #191917;
  --board-part: #2d2d2a;
  --board-ink: #e9e7e1;
  --board-trace: #77756e;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --t-display: clamp(2.35rem, 6.2vw, 6rem);
  --t-h2: clamp(1.85rem, 3.4vw, 3.1rem);
  --t-lead: clamp(1.2rem, 1.6vw, 1.45rem);
  --t-body: 1.125rem;
  --t-small: 0.95rem;

  --gutter: clamp(16px, 3vw, 32px);
  --max: 1320px;
  --gap: clamp(88px, 12vw, 176px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f0f0e; --ground-2: #1c1c1a; --ink: #edebe5; --ink-2: #a9a79f;
    --accent: #ff5435; --on-accent: #0f0f0e; --field: #1c1c1a; --field-ink: #edebe5; --field-2: #2a2a27;
    --board: #222220; --board-part: #353531; --board-trace: #8b8981;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0f0f0e; --ground-2: #1c1c1a; --ink: #edebe5; --ink-2: #a9a79f;
  --accent: #ff5435; --on-accent: #0f0f0e; --field: #1c1c1a; --field-ink: #edebe5; --field-2: #2a2a27;
  --board: #222220; --board-part: #353531; --board-trace: #8b8981;
  color-scheme: dark;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--serif); font-size: var(--t-body); line-height: 1.55;
  font-optical-sizing: auto; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, p, ul, ol, figure, dl, dd { margin: 0; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 8px; background: var(--ink); color: var(--ground); padding: 10px 14px; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

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

/* Type */
.display, h1 {
  font-family: var(--serif); font-weight: 500; font-size: var(--t-display);
  line-height: 0.98; letter-spacing: -0.035em; text-wrap: balance;
}
h2 { font-family: var(--serif); font-weight: 500; font-size: var(--t-h2); line-height: 1.04; letter-spacing: -0.025em; text-wrap: balance; }
h3 { font-family: var(--sans); font-weight: 600; font-size: var(--t-body); line-height: 1.3; letter-spacing: -0.005em; }
.lead { font-size: var(--t-lead); line-height: 1.42; max-width: 36ch; }
.small, small { font-family: var(--sans); font-size: var(--t-small); line-height: 1.5; }
.muted { color: var(--ink-2); }
.sans { font-family: var(--sans); }

/* Header */
.site-head { background: var(--ground); }
.site-head .wrap { display: flex; align-items: center; gap: 24px; min-height: 76px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; text-decoration: none; margin-right: auto; color: var(--ink); }
.brand svg { height: 30px; width: auto; }
.nav { display: flex; gap: clamp(14px, 2vw, 30px); font-family: var(--sans); font-size: 1rem; font-weight: 500; }
.nav a { text-decoration: none; padding: 6px 0; text-underline-offset: 6px; }
.nav a:hover, .nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--accent); }
.theme-btn {
  font: 500 0.95rem var(--sans); color: var(--ink); background: var(--ground-2);
  border: 0; border-radius: 3px; padding: 8px 12px; cursor: pointer;
}
@media (max-width: 720px) {
  .site-head .wrap { gap: 6px 16px; padding-block: 12px; }
  .nav { order: 3; width: 100%; justify-content: space-between; gap: 8px; font-size: 0.98rem; }
  .brand svg { height: 26px; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font: 600 1.02rem var(--sans); background: var(--accent); color: var(--on-accent);
  padding: 15px 24px; border-radius: 3px; transition: transform .2s ease, background-color .2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn.quiet { background: var(--ground-2); color: var(--ink); }
.field .btn.quiet { background: var(--field-2); color: var(--field-ink); }
.btn .arrow { transition: transform .2s ease; }
.btn:hover .arrow { transform: translateX(4px); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* Sections */
.section { padding-block: calc(var(--gap) / 2); }
.section + .section { margin-top: calc(var(--gap) / 2); }
.field { background: var(--field); color: var(--field-ink); padding-block: clamp(72px, 9vw, 136px); }
.field .muted { color: color-mix(in srgb, var(--field-ink) 72%, transparent); }
.band { background: var(--ground-2); padding-block: clamp(64px, 8vw, 120px); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(20px, 3vw, 48px); }
.span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; }
.span-4 { grid-column: span 4; } .span-8 { grid-column: span 8; } .span-12 { grid-column: 1 / -1; }
@media (max-width: 900px) { .grid > * { grid-column: 1 / -1; } }
.stack > * + * { margin-top: 24px; }
.stack-lg > * + * { margin-top: 40px; }

/* Hero (home) */
.hero { padding-top: clamp(32px, 6vw, 88px); padding-bottom: clamp(64px, 8vw, 120px); }
.hero .grid { align-items: center; }
.hero h1 { max-width: 11ch; }
.hero .lead { margin-top: 40px; }
.hero .actions { margin-top: 40px; }
.hero figure figcaption { margin-top: 14px; }

/* Board drawing */
.board-fig svg { width: 100%; height: auto; }
.board-fig text { font-family: var(--sans); fill: var(--board-ink); }
.board .pcb { fill: var(--board); }
.board .part { fill: var(--board-part); }
.board .trace { stroke: var(--board-trace); stroke-width: 2; fill: none; }
.board .sig { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-dasharray: 6 10; animation: flow 1.6s linear infinite; }
.board .barrier { fill: var(--accent); }
.board .keep { fill: none; stroke: var(--board-trace); stroke-dasharray: 3 5; }
.board .side { font-weight: 600; font-size: 15px; }
.board .lbl { font-size: 12.5px; font-weight: 500; }
.board .lbl-s { font-size: 11px; fill: var(--board-trace); }
@keyframes flow { to { stroke-dashoffset: -32; } }

/* Feature rows (home) */
.feature { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: clamp(20px, 3vw, 48px); align-items: start; }
.feature .text { grid-column: 1 / span 5; }
.feature .media { grid-column: 7 / -1; }
.feature.flip .text { grid-column: 8 / -1; grid-row: 1; }
.feature.flip .media { grid-column: 1 / span 6; grid-row: 1; }
@media (max-width: 900px) { .feature .text, .feature .media, .feature.flip .text, .feature.flip .media { grid-column: 1 / -1; grid-row: auto; } }

/* Fact list: label/value pairs separated by tone, not rules */
.facts { display: grid; gap: 4px; font-family: var(--sans); }
.facts div { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 16px; padding: 14px 16px; background: var(--ground-2); }
.field .facts div { background: var(--field-2); }
.facts dt { color: var(--ink-2); font-size: var(--t-small); }
.field .facts dt { color: color-mix(in srgb, var(--field-ink) 70%, transparent); }
.facts dd { font-size: 1.02rem; font-weight: 500; }

/* Rows list (reviews, guides) */
.rows { display: grid; gap: 6px; list-style: none; padding: 0; }
.rows a { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; gap: 24px; align-items: baseline;
  padding: 26px clamp(16px, 2vw, 28px); background: var(--ground-2); text-decoration: none; transition: background-color .2s ease; }
.rows a:hover { background: color-mix(in srgb, var(--ground-2) 70%, var(--accent) 30%); }
.rows .t { font-size: clamp(1.4rem, 2.2vw, 2rem); line-height: 1.1; letter-spacing: -0.02em; font-weight: 500; }
.rows .d { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-2); }
.rows .s { font-family: var(--sans); font-size: var(--t-small); font-weight: 600; white-space: nowrap; }
@media (max-width: 720px) { .rows a { grid-template-columns: 1fr; gap: 8px; } .rows .s { white-space: normal; } }

/* Live tool: format calculator & switcher */
.tool fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.tool legend { font: 600 1rem var(--sans); margin-bottom: 12px; padding: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; font: 500 1rem var(--sans); padding: 12px 16px; min-width: 64px; text-align: center;
  background: var(--field-2); color: var(--field-ink); border-radius: 3px; transition: background-color .15s ease, color .15s ease; }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 3px solid var(--field-ink); outline-offset: 2px; }
.readout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 36px; }
.readout div { background: var(--field-2); padding: 20px; }
.readout b { display: block; font-family: var(--serif); font-weight: 500; font-size: clamp(2rem, 3.6vw, 3.2rem); line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.readout span { display: block; font: 400 var(--t-small)/1.4 var(--sans); margin-top: 10px; }
@media (max-width: 720px) { .readout { grid-template-columns: 1fr; } }
.spectrum { margin-top: 28px; max-width: 760px; }
.spectrum .bar { height: 14px; margin: 6px 0 14px; }
.spectrum .hear { background: color-mix(in srgb, var(--field-ink) 30%, transparent); }
.spectrum .fmt { background: var(--accent); transition: width .35s ease; }
.spectrum .axis { display: flex; justify-content: space-between; opacity: .75; }
.verdict { margin-top: 24px; font-size: var(--t-lead); line-height: 1.4; max-width: 46ch; }

.switch-out { background: var(--field-2); padding: clamp(24px, 3vw, 40px); }
.switch-out b { display: block; font-family: var(--serif); font-weight: 500; font-size: clamp(2.2rem, 4.4vw, 3.8rem); line-height: 1; letter-spacing: -0.03em; transition: color .2s ease; }
.switch-out b.on { color: var(--accent); }
.switch-out p { margin-top: 16px; font-family: var(--sans); font-size: 1rem; }
.feature .media .tool .grid > * { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }

/* Article pages */
.page-head { padding-top: clamp(36px, 6vw, 96px); padding-bottom: clamp(40px, 6vw, 80px); }
.page-head .lead { margin-top: 32px; max-width: 44ch; }
.page-head .meta { margin-top: 28px; }
.status { display: inline-block; font: 600 1rem var(--sans); background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 3px; }
.prose { max-width: 68ch; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { margin-top: 2.2em; font-size: clamp(1.7rem, 2.8vw, 2.4rem); }
.prose h3 { margin-top: 1.8em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: 0.4em; }
.prose a { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.prose code, .prose kbd { font-family: var(--mono); font-size: 0.86em; background: var(--ground-2); padding: 0.1em 0.35em; border-radius: 3px; }
pre { font-family: var(--mono); font-size: 0.86rem; line-height: 1.6; background: var(--ground-2); padding: 20px; overflow-x: auto; border-radius: 3px; max-width: 100%; }
pre code { background: none; padding: 0; }
.article { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px); gap: clamp(32px, 6vw, 96px); align-items: start; }
.article aside { position: sticky; top: 24px; }
@media (max-width: 960px) { .article { grid-template-columns: minmax(0, 1fr); } .article aside { position: static; } }
.disclose { font-family: var(--sans); font-size: var(--t-small); color: var(--ink-2); background: var(--ground-2); padding: 14px 16px; }
.disclose a { color: var(--ink); }

/* Tables: tone steps, no rules */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.98rem; }
th, td { text-align: left; padding: 12px 14px; vertical-align: top; }
thead th { font-weight: 600; background: var(--ink); color: var(--ground); }
tbody tr:nth-child(odd) td { background: var(--ground-2); }

/* Signal chain */
.chain { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--sans); }
.chain li { background: var(--field-2); color: var(--field-ink); padding: 14px 16px; flex: 1 1 140px; }
.chain li b { display: block; font-weight: 600; }
.chain li span { display: block; font-size: var(--t-small); opacity: .78; margin-top: 4px; }
.chain li.cross { background: var(--accent); color: var(--on-accent); }
.chain li.cross span { opacity: 1; }

/* Rack */
.rack { display: grid; gap: 6px; }
.rack section { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(20px, 3vw, 48px); padding: clamp(24px, 3vw, 40px); background: var(--ground-2); }
.rack h2 { font-size: clamp(1.7rem, 2.8vw, 2.5rem); }
.rack ul { list-style: none; padding: 0; display: grid; gap: 18px; }
.rack li b { display: block; font-family: var(--sans); font-weight: 600; font-size: 1.1rem; }
@media (max-width: 720px) { .rack section { grid-template-columns: 1fr; } }

/* Footer */
.site-foot { background: var(--field); color: var(--field-ink); margin-top: calc(var(--gap) / 2); padding-top: clamp(56px, 7vw, 104px); padding-bottom: 32px; }
.site-foot .mark { color: var(--field-ink); width: 100%; height: auto; }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; margin-top: clamp(40px, 5vw, 72px); font-family: var(--sans); font-size: 1rem; }
.foot-grid ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.foot-grid a { text-decoration: none; }
.foot-grid a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.foot-grid h2 { font: 600 1rem var(--sans); letter-spacing: 0; margin-bottom: 12px; }
.foot-grid p { max-width: 42ch; }
.foot-base { margin-top: 48px; font-family: var(--sans); font-size: var(--t-small); opacity: .75; }
@media (max-width: 720px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-grid > :first-child { grid-column: 1 / -1; } }

/* Motion: reveal on scroll (only when JS is on and motion is allowed) */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.js .reveal.in { opacity: 1; transform: none; }
.mark-draw path, .mark-draw circle { stroke-dasharray: 260; stroke-dashoffset: 260; animation: draw 1.4s cubic-bezier(.6,.1,.2,1) forwards; }
.mark-draw :nth-child(2) { animation-delay: .08s; } .mark-draw :nth-child(3) { animation-delay: .16s; }
.mark-draw :nth-child(4) { animation-delay: .24s; } .mark-draw :nth-child(5) { animation-delay: .32s; }
.mark-draw :nth-child(6) { animation-delay: .4s; } .mark-draw :nth-child(7) { animation-delay: .48s; }
.mark-draw :nth-child(8) { animation-delay: .56s; } .mark-draw :nth-child(9) { animation-delay: .64s; }
.mark-draw :nth-child(10) { animation-delay: .72s; } .mark-draw :nth-child(11) { animation-delay: .8s; }
.mark-draw :nth-child(12) { animation-delay: .88s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .mark-draw path, .mark-draw circle { stroke-dashoffset: 0; }
}

main > .band:last-child, main > .field:last-child { margin-bottom: calc(var(--gap) / -2); }
.hero h1.hero-title { max-width: none; font-size: clamp(2rem, 5.1vw, 5.4rem); }
.hero-title span { display: block; white-space: nowrap; }
.prose > :first-child { margin-top: 0; }
.prose .chain { padding-left: 0; }
.prose .chain li + li { margin-top: 0; }
