:root {
  --bg: #f5efe0;
  --fg: #0a0a0a;
  --card: #faf6ec;
  --muted: #4a4a48;
  --red: #8b2e2e;
  --line: #0a0a0a;
  --mono: "Geist Mono", ui-monospace, monospace;
  --sans: "Geist", system-ui, sans-serif;
  --frame: 1440px;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
}

html.dark {
  --bg: #0a0a0a;
  --fg: #f5efe0;
  --card: #161616;
  --muted: #a8a8a0;
  --red: #c04545;
  --line: #f5efe0;
}

@media (prefers-color-scheme: dark) {
  html.system {
    --bg: #0a0a0a;
    --fg: #f5efe0;
    --card: #161616;
    --muted: #a8a8a0;
    --red: #c04545;
    --line: #f5efe0;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner,
footer {
  width: min(100% - 2rem, var(--frame));
  margin-inline: auto;
}
.topbar-inner {
  min-height: 4rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2rem;
}
.mark,
.topbar nav,
.theme,
footer {
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.mark,
.topbar nav a { text-decoration: none; }
.topbar nav { display: flex; justify-content: center; gap: 1.5rem; }
.topbar nav a:hover { color: var(--red); }
.theme { display: flex; border: 1px solid var(--line); }
button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  padding: .5rem .6rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .65rem;
  cursor: pointer;
}
button:last-child { border-right: 0; }
button.active { background: var(--red); color: #f5efe0; }

main {
  width: min(100% - 2rem, var(--frame));
  margin-inline: auto;
  border-inline: 1px solid var(--line);
}
.hero,
.editorial-section {
  border-bottom: 1px solid var(--line);
}
.hero {
  min-height: 46rem;
  display: grid;
  grid-template-columns: minmax(0, 10fr) minmax(0, 6fr);
}
.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(3rem, 7vw, 6rem) var(--gutter);
  border-right: 1px solid var(--line);
}
.eyebrow,
article > span,
figcaption {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
h1,
h2,
h3 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
}
h1 {
  margin-top: 1rem;
  font-size: clamp(3.4rem, 6.25vw, 5.8rem);
  line-height: .94;
  letter-spacing: -.055em;
}
h2 {
  margin-top: .9rem;
  max-width: 18ch;
  font-size: clamp(2.1rem, 3.5vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -.035em;
}
h3 {
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: -.015em;
}
em { color: var(--red); font-style: normal; }
.lede {
  max-width: 34rem;
  margin: 2rem 0 0;
  font-size: clamp(1.1rem, 1.7vw, 1.3rem);
  font-weight: 300;
  line-height: 1.55;
}
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2.25rem; }
.command-ref {
  margin-top: 1.75rem;
  padding: .9rem 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: .25rem;
  border-block: 1px solid var(--line);
}
.command-ref + .command-ref { margin-top: -1px; }
.command-ref > span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
}
.command-ref code {
  overflow-wrap: anywhere;
  color: var(--fg);
  font-family: var(--mono);
  font-size: .9rem;
  font-weight: 700;
}
.command-ref p {
  margin: .15rem 0 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}
.command-ref-compact { max-width: 34rem; }
.command-pair { display: grid; }
.command-pair .command-ref { margin-top: 0; }
.closing-commands { margin-top: 2rem; }
.button {
  padding: .8rem 1rem;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-decoration: none;
}
.button:hover { background: var(--fg); color: var(--bg); }
.button.primary { border-color: var(--red); background: var(--red); color: #f5efe0; }

.hero-plate {
  min-width: 0;
  margin: 0;
  padding: clamp(1.5rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--card);
}
.hero-plate img { display: block; width: 100%; height: auto; }
.hero-plate figcaption { margin-top: .9rem; font-style: italic; }

.editorial-section {
  padding: clamp(3.5rem, 7vw, 6rem) var(--gutter);
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: clamp(2rem, 4vw, 4rem);
  align-items: start;
}
.split-section > .section-copy,
.split-section > .section-stack { grid-column: span 7; }
.split-section > .media-frame,
.split-section > .mode-list,
.split-section > .rule-list { grid-column: span 9; }
.section-copy > p:not(.eyebrow),
.section-lede {
  max-width: 38rem;
  margin: 1.5rem 0 0;
  font-size: 1.125rem;
  line-height: 1.65;
}
.section-stack { display: grid; gap: 2.5rem; }

.media-frame {
  min-width: 0;
  margin: 0;
  padding: .75rem;
  border: 1px solid var(--line);
  background: var(--card);
}
.media-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
.media-frame figcaption {
  padding-top: .75rem;
  font-style: italic;
}

.calibration-section { background: var(--card); }
.calibration-section > .section-copy { grid-column: span 7; }
.section-intro { grid-column: span 9; align-self: end; margin-bottom: .35rem; font-size: clamp(1.2rem, 2vw, 1.55rem); }
.calibration-plate { grid-column: span 9; }
.axis-list { grid-column: span 7; border-top: 1px solid var(--line); }
.axis-list > .command-pair { margin-bottom: .5rem; }
.axis-list article,
.mode-list article {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--line);
}
.axis-list article:last-child,
.mode-list article:last-child { border-bottom: 0; }
.axis-list h3,
.mode-list h3 { margin-top: .55rem; }
.axis-list p,
.mode-list p { margin: .6rem 0 0; }

.mode-list,
.rule-list { margin: 0; border-top: 1px solid var(--line); }
.rules-section { background: var(--card); }
.rules-heading {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 9fr) minmax(0, 7fr);
  gap: clamp(2rem, 4vw, 4rem);
  align-items: end;
}
.rules-heading .section-copy { max-width: 38rem; }
.rules-heading .command-ref { margin: 0; }
.rules-section > .media-frame { grid-column: span 7; }
.rules-section > .rule-list { grid-column: span 9; }
.rule-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 2rem;
}
.rule-column {
  margin: 0;
  padding: 0;
  list-style: none;
}
.rule-column li {
  display: grid;
  border-bottom: 1px solid var(--line);
}
.rule-column details { min-width: 0; }
.rule-column summary {
  min-height: 3.65rem;
  padding: .9rem 2rem .9rem 0;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: .75rem;
  align-items: start;
  position: relative;
  cursor: pointer;
  list-style: none;
}
.rule-column summary::-webkit-details-marker { display: none; }
.rule-column summary::after {
  content: "+";
  position: absolute;
  top: .75rem;
  right: .1rem;
  color: var(--red);
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
}
.rule-column details[open] summary::after { content: "−"; }
.rule-column summary:hover span,
.rule-column summary:focus-visible span { color: var(--red); }
.rule-column summary:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.rule-column b {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}
.rule-column p {
  margin: -.15rem 2rem 1rem 3rem;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}
.rule-column code {
  color: var(--fg);
  font-family: var(--mono);
  font-size: .82em;
  font-weight: 700;
}
.closing-section { align-items: center; }

footer {
  min-height: 5rem;
  padding-block: 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: 1fr auto; padding-block: .8rem; }
  .topbar nav { order: 3; grid-column: 1 / -1; justify-content: flex-start; overflow-x: auto; padding-top: .8rem; border-top: 1px solid var(--line); }
  .hero { min-height: auto; grid-template-columns: minmax(0, 1fr); }
  .editorial-section { grid-template-columns: 1fr; }
  .hero-copy { min-height: 38rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .hero-plate { max-height: 42rem; align-items: center; }
  .hero-plate svg { max-width: 34rem; }
  .split-section > .section-copy,
  .split-section > .section-stack,
  .split-section > .media-frame,
  .split-section > .mode-list,
  .split-section > .rule-list,
  .calibration-section > .section-copy,
  .section-intro,
  .calibration-plate,
  .axis-list { grid-column: 1 / -1; }
  .rules-heading { grid-template-columns: 1fr; gap: 1.5rem; }
  .rule-list { grid-template-columns: 1fr; }
  .section-intro { margin-top: -1rem; }
  .media-frame { max-width: 42rem; }
}

@media (max-width: 560px) {
  .topbar-inner,
  main,
  footer { width: 100%; }
  main { border-inline: 0; }
  .topbar-inner { padding-inline: 1rem; }
  .theme button { padding-inline: .45rem; }
  .hero-copy { min-height: 34rem; padding: 3.5rem 1.25rem; }
  .hero-plate,
  .editorial-section { padding: 3rem 1.25rem; }
  h1 { font-size: clamp(2.3rem, 11vw, 3.25rem); }
  h2 { font-size: clamp(2rem, 10vw, 2.75rem); }
  .button { width: 100%; text-align: center; }
  footer { min-height: auto; padding: 1.5rem 1rem; flex-direction: column; }
}
