/* =========================================================
   Stator — mechanical / engineering schematic
   Dark + light themes via CSS variables.
   Single content measure throughout, page centered.
   ========================================================= */

/* ---- Theme tokens ----------------------------------------
   The page defaults to LIGHT. prefers-color-scheme: dark
   flips it to dark unless the user has forced light. The
   [data-theme] attribute always wins.
----------------------------------------------------------- */
:root {
  /* Theme-independent */
  --copper-light:      #a8501f;
  --copper-light-deep: #7e3a13;
  --copper-dark:       #e08a4c;
  --copper-dark-deep:  #b8623a;

  /* Type */
  --sans:  "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Measure (single column for the whole document) */
  --measure: 42rem;

  /* ---- Light theme defaults ---- */
  color-scheme: light;
  --canvas:        #ebe7d8;
  --canvas-deep:   #e1dcc8;
  --panel:         #e0dac6;
  --panel-deep:    #d4ccb3;
  --ink:           #1a1714;
  --ink-soft:      #5a5448;
  --ink-faint:     #8c8675;
  --line:          rgba(26, 23, 20, 0.10);
  --line-strong:   rgba(26, 23, 20, 0.22);
  --grid-line:     rgba(26, 23, 20, 0.05);
  --copper:        var(--copper-light);
  --copper-deep:   var(--copper-light-deep);
  --copper-glow:   rgba(168, 80, 31, 0.10);

  /* Code surface stays dark in both themes (deliberate) */
  --code-bg:       #0d1218;
  --code-fg:       #e8e2d5;
  --code-c:        #6b7480;
  --code-k:        #e08a4c;
  --code-f:        #d4b878;
  --code-s:        #98b87a;
  --code-n:        #e08a4c;
}

/* Dark theme when system prefers it AND user hasn't forced light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas:        #0d1218;
    --canvas-deep:   #080c10;
    --panel:         #131a22;
    --panel-deep:    #1a232d;
    --ink:           #e8e2d5;
    --ink-soft:      #95a0ad;
    --ink-faint:     #555f6a;
    --line:          rgba(232, 226, 213, 0.08);
    --line-strong:   rgba(232, 226, 213, 0.18);
    --grid-line:     rgba(232, 226, 213, 0.025);
    --copper:        var(--copper-dark);
    --copper-deep:   var(--copper-dark-deep);
    --copper-glow:   rgba(224, 138, 76, 0.16);
  }
}

/* Explicit dark override */
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas:        #0d1218;
  --canvas-deep:   #080c10;
  --panel:         #131a22;
  --panel-deep:    #1a232d;
  --ink:           #e8e2d5;
  --ink-soft:      #95a0ad;
  --ink-faint:     #555f6a;
  --line:          rgba(232, 226, 213, 0.08);
  --line-strong:   rgba(232, 226, 213, 0.18);
  --grid-line:     rgba(232, 226, 213, 0.025);
  --copper:        var(--copper-dark);
  --copper-deep:   var(--copper-dark-deep);
  --copper-glow:   rgba(224, 138, 76, 0.16);
}

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

body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  letter-spacing: -0.005em;
  font-variation-settings: "wdth" 100;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color 200ms ease, color 200ms ease;
}

a { color: inherit; }
img, svg { display: block; max-width: 100%; }

/* ---- Background grid (drafting paper / CAD canvas) ---- */
.grid-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: 0 0;
  transition: background-image 200ms ease;
}

/* ---- Layout ---- */
.header,
.main,
.footer {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  position: relative;
  z-index: 1;
}

/* ---- Header ---- */
.header {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
}

.header__mark {
  width: 22px;
  height: 22px;
  color: var(--copper);
}

.header__wordmark {
  font-family: var(--sans);
  font-weight: 700;
  font-variation-settings: "wdth" 90;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav__meta {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  padding: 0.18rem 0.45rem;
  border: 1px solid var(--line-strong);
}

@media (max-width: 540px) {
  .nav__meta { display: none; }
}

.nav__link {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-decoration: none;
  color: var(--ink-soft);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color 160ms ease, border-color 160ms ease;
}

.nav__link:hover {
  color: var(--copper);
  border-bottom-color: var(--copper);
}

/* ---- Theme toggle ---- */
.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  overflow: hidden;
  margin-left: 0.25rem;
}

.theme-toggle__btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.4rem 0.5rem;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 160ms ease, background 160ms ease;
  border-right: 1px solid var(--line-strong);
}

.theme-toggle__btn:last-child {
  border-right: 0;
}

.theme-toggle__btn:hover {
  color: var(--copper);
  background: var(--copper-glow);
}

.theme-toggle__btn[aria-pressed="true"] {
  color: var(--copper);
  background: var(--copper-glow);
}

/* ---- Main ---- */
.main {
  padding-top: 4rem;
  padding-bottom: 5rem;
}

/* ---- Hero ---- */
.hero {
  margin-bottom: 5rem;
}

.hero__spec {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--copper);
  margin: 0 0 2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.hero__spec::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1px;
  background: var(--copper);
}

.hero__title {
  font-family: var(--sans);
  font-weight: 600;
  font-variation-settings: "wdth" 90;
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
  margin: 0 0 1.5rem;
  color: var(--ink);
  text-transform: uppercase;
}

.hero__title-line {
  display: block;
}

.hero__title-accent {
  color: var(--copper);
  font-weight: 500;
  font-variation-settings: "wdth" 95;
}

.dimension {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--copper);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 2rem 0 2.25rem;
}

.dimension__bracket {
  font-family: var(--mono);
  color: var(--copper);
  font-size: 1.05rem;
  line-height: 1;
}

.dimension::after {
  content: "";
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(
    90deg,
    var(--copper-deep) 0,
    var(--copper-deep) 4px,
    transparent 4px,
    transparent 8px
  );
  margin-left: 0.4rem;
}

.hero__lede {
  font-size: 1.18rem;
  line-height: 1.55;
  margin: 0 0 2.5rem;
  color: var(--ink);
  font-weight: 400;
}

.poc {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--copper);
  padding: 1rem 1.25rem 1.1rem;
}

.poc__label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--copper);
  margin: 0 0 0.45rem;
}

.poc__text {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0;
}

/* ---- Section heads ---- */
.section-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.25rem;
}

.section-head__id {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--copper);
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--copper-deep);
  background: var(--copper-glow);
  flex-shrink: 0;
}

.section-head__divider {
  flex: 1;
  height: 1px;
  background: var(--line-strong);
  display: block;
}

.section-head__title {
  font-family: var(--sans);
  font-weight: 600;
  font-variation-settings: "wdth" 88;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  flex-shrink: 0;
}

@media (max-width: 540px) {
  .section-head__title { font-size: 0.78rem; }
}

/* ---- Decisions (single-column list) ---- */
.decisions {
  margin-bottom: 5rem;
}

.decisions__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line-strong);
}

.decision {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: 1rem;
  padding: 1.05rem 0.5rem;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
  transition: background 200ms ease;
}

.decision:hover {
  background: var(--panel);
}

.decision__num {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--copper);
  align-self: start;
  padding-top: 0.18rem;
}

.decision__claim {
  font-family: var(--sans);
  font-weight: 600;
  font-variation-settings: "wdth" 95;
  font-size: 1.02rem;
  line-height: 1.35;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 0 0 0.3rem;
}

.decision__detail {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}

/* ---- Section ---- */
.section {
  margin-bottom: 4.5rem;
}

/* ---- Prose ---- */
.prose p {
  margin: 0 0 1.2rem;
  font-size: 1.04rem;
  line-height: 1.65;
  color: var(--ink);
}

.prose em {
  font-style: normal;
  color: var(--copper);
  font-weight: 500;
}

.prose__sub {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--copper);
  margin: 2.25rem 0 1rem;
}

.inline {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--panel);
  color: var(--copper);
  padding: 0.12em 0.4em;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
}

/* ---- Code ---- */
.code {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.65;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 1.4rem 1.5rem;
  margin: 1.75rem 0 2rem;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--copper);
}

.code code { font-family: inherit; background: none; color: inherit; }

.c-c { color: var(--code-c); font-style: italic; }
.c-k { color: var(--code-k); }
.c-f { color: var(--code-f); }
.c-s { color: var(--code-s); }
.c-n { color: var(--code-n); }

/* ---- Links ---- */
.link {
  color: var(--copper);
  text-decoration: none;
  border-bottom: 1px solid var(--copper-deep);
  transition: border-color 160ms ease;
}

.link:hover { border-bottom-color: var(--copper); }

/* ---- Modes (vertical stack, each row has text + media) ---- */
.modes {
  margin: 2rem 0 0;
  border-top: 1px solid var(--line-strong);
}

.mode {
  display: grid;
  grid-template-columns: 1fr 13rem;
  gap: 1.5rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--line-strong);
  align-items: start;
}

@media (max-width: 620px) {
  .mode {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.mode__id {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--copper);
  margin: 0 0 0.4rem;
}

.mode__route {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.mode__name {
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
  font-variation-settings: "wdth" 90;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.85rem;
}

.mode__body {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0;
}

.mode__media {
  background: var(--canvas-deep);
  border: 1px solid var(--line-strong);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.mode__media::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0,
      transparent 18px,
      var(--line) 18px,
      var(--line) 19px
    );
  pointer-events: none;
}

.mode__media span {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 0.75rem;
}

/* ---- Compare (vertical stack) ---- */
.compare {
  margin: 1.5rem 0 0;
  border-top: 1px solid var(--line-strong);
}

.compare__row {
  padding: 1.5rem 0 1.75rem;
  border-bottom: 1px solid var(--line-strong);
}

.compare__name {
  font-family: var(--sans);
  font-weight: 700;
  font-variation-settings: "wdth" 88;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--copper);
  margin: 0 0 0.85rem;
}

.compare__diff {
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--ink);
  margin: 0 0 1rem;
}

.compare__when {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: var(--panel);
  border-left: 2px solid var(--copper-deep);
}

.compare__when-label {
  color: var(--copper);
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-right: 0.5rem;
}

/* ---- Status (two short columns) ---- */
.status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 0 0 2.25rem;
}

@media (max-width: 540px) {
  .status { grid-template-columns: 1fr; }
}

.status__col {
  padding: 1.25rem 1.25rem 1.4rem;
  border: 1px solid var(--line-strong);
}

@media (min-width: 541px) {
  .status__col + .status__col { border-left: none; }
}

@media (max-width: 540px) {
  .status__col + .status__col { border-top: none; }
}

.status__head {
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  margin: 0 0 0.85rem;
}

.status__head--ok  { color: var(--copper); }
.status__head--gap { color: var(--ink-soft); }

.status__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.status__list li {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink);
  padding: 0.5rem 0 0.5rem 1.4rem;
  position: relative;
  border-top: 1px dashed var(--line);
}

.status__list li:first-child { border-top: none; padding-top: 0; }

.status__list li::before {
  content: ">";
  position: absolute;
  left: 0;
  top: 0.5rem;
  color: var(--copper);
}

.status__list li:first-child::before { top: 0; }

/* ---- CTA ---- */
.cta {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
}

@media (min-width: 560px) {
  .cta { flex-direction: row; gap: 1rem; }
}

/* Mid-page CTA after the architectural decisions: extra top margin so it
   has its own breathing room separating it from the dense decisions list. */
.cta--mid {
  margin-top: 3rem;
}

.cta__link {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  padding: 0.8rem 1.15rem;
  border: 1px solid var(--copper-deep);
  background: var(--copper-glow);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.cta__link:hover {
  background: var(--copper);
  color: var(--canvas);
  border-color: var(--copper);
}

.cta__arrow {
  color: var(--copper);
  transition: color 160ms ease;
}

.cta__link:hover .cta__arrow { color: var(--canvas); }

/* ---- Footer ---- */
.footer {
  padding-top: 2.5rem;
  padding-bottom: 3.5rem;
  border-top: 1px solid var(--line-strong);
}

.footer__row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.footer__cell {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--copper);
}

.footer__note {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
  margin: 0;
}

/* ---- Selection ---- */
::selection {
  background: var(--copper);
  color: var(--canvas);
}

/* ============================================================
   Mobile (≤ 540px) refinements
   ============================================================ */

@media (max-width: 540px) {

  /* Tighter horizontal gutter so we don't lose so much usable width. */
  .header,
  .main,
  .footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Mobile header: brand and theme toggle only. The Demo / Source
     links are accessible via the prominent CTAs mid-page and at the
     bottom of the page. */
  .nav__link                  { display: none; }

  /* Hero dimension: hide the trailing dashed line (it's just a few
     dashes on a phone, and visually noisy) and center the brackets. */
  .dimension                  { justify-content: center; }
  .dimension::after           { display: none; }

  /* Section head: drop the divider line and let the title wrap onto
     its own row when it doesn't fit next to the chip. */
  .section-head               { flex-wrap: wrap; row-gap: 0.4rem; }
  .section-head__divider      { display: none; }
  .section-head__title        { flex-shrink: 1; min-width: 0; }

  /* Decisions: tighter number column and less row inset. */
  .decision {
    grid-template-columns: 1.75rem 1fr;
    gap: 0.6rem;
    padding: 1.05rem 0.25rem;
  }

  /* Less vertical air below the final CTA before the footer. */
  .main                       { padding-bottom: 2.5rem; }
  .section:last-child         { margin-bottom: 0; }
}
