/*
  Direction
  - What: a personal page read top to bottom. One job: show the setup and the builds, then GitHub.
  - Look: a 90s Japanese car-catalogue spec sheet. Paper #EDECE8, ink #121212, one signal red
    #C8211A. Archivo (variable width: condensed for display, normal for text) + JetBrains Mono for
    specs. Square corners, hairline rules, no shadows.
  - Why: the root domain is a 180SX zine; this page presents its owner the way the brochure
    presents the car, with a technical cutaway of the setup as the centrepiece.
*/

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --paper: #edece8;
  --paper-2: #e2e1dc;
  --ink: #121212;
  --ink-2: #4b4a46;
  --hair: rgba(18, 18, 18, 0.2);
  --red: #c8211a;
  --on-red: #ffffff;

  --sans: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --wrap: 1200px;
  --gutter: 32px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141413;
    --paper-2: #1d1d1b;
    --ink: #e9e7e2;
    --ink-2: #a5a39d;
    --hair: rgba(233, 231, 226, 0.18);
    --red: #e5483d;
    --on-red: #141413;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
code { font-family: var(--mono); font-size: 0.875em; }
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
@media (max-width: 640px) { :root { --gutter: 16px; } }

.skip {
  position: absolute; left: var(--s4); top: -100px;
  background: var(--ink); color: var(--paper); padding: var(--s2) var(--s3);
  font-family: var(--mono); font-size: 14px; z-index: 10;
}
.skip:focus { top: var(--s2); }

/* ---- Top bar ---- */
.bar {
  position: sticky; top: 0; z-index: 5;
  background: var(--paper);
  border-bottom: 1px solid var(--hair);
}
.bar-inner {
  display: flex; align-items: center; gap: var(--s5);
  height: 48px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
}
.bar-name { font-weight: 700; text-decoration: none; font-size: 14px; letter-spacing: 0; }
.bar nav { display: flex; gap: var(--s5); margin-left: auto; }
.bar nav a { text-decoration: none; color: var(--ink-2); }
.bar nav a:hover { color: var(--red); }
.bar-print {
  font: inherit; color: var(--ink);
  background: transparent; border: 1px solid var(--ink);
  padding: 6px 10px; cursor: pointer;
  transition: background-color 150ms, color 150ms;
}
.bar-print:hover { background: var(--ink); color: var(--paper); }
.bar-print:active { background: var(--red); border-color: var(--red); color: var(--on-red); }
@media (max-width: 720px) {
  .bar-print { display: none; }
  .bar nav { gap: var(--s4); }
}

/* ---- Cover ---- */
.cover { padding-top: var(--s7); padding-bottom: var(--s8); }
.cover-edition {
  display: flex; justify-content: space-between;
  border-top: 2px solid var(--ink);
  padding-top: var(--s2);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
}
.cover-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--s7);
  align-items: end;
  margin-top: var(--s6);
}
.cover-name {
  font-size: clamp(140px, 38vw, 300px);
  line-height: 0.8;
  font-weight: 800;
  font-stretch: 62%;
  letter-spacing: -0.02em;
  margin-left: -0.04em;
}
.cover-stripe {
  height: 14px; margin-top: var(--s4);
  background: linear-gradient(var(--red), var(--red)) left / 100% 10px no-repeat,
              linear-gradient(var(--ink), var(--ink)) left bottom / 100% 2px no-repeat;
}
.cover-model {
  margin-top: var(--s4);
  font-size: 24px; line-height: 1.25;
  font-weight: 600; font-stretch: 85%;
}
.cover-intro {
  margin-top: var(--s4);
  max-width: 34em;
  font-size: 18px; color: var(--ink-2);
}

/* Spec table with dotted leaders */
.specs { font-family: var(--mono); font-size: 13px; line-height: 1.4; }
.specs > div {
  display: grid; grid-template-columns: 15ch minmax(0, 1fr);
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--hair);
}
.specs > div:first-child { border-top: 2px solid var(--ink); }
.specs dt {
  color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px;
  display: flex; gap: var(--s2);
}
.specs dt::after {
  content: ""; flex: 1;
  border-bottom: 1px dotted var(--ink-2);
  transform: translateY(-4px);
  margin-right: var(--s2);
}
.specs dd { font-weight: 500; }

@media (max-width: 900px) {
  .cover-grid { grid-template-columns: 1fr; gap: var(--s6); }
}

/* ---- Sections ---- */
.section { padding-top: var(--s8); padding-bottom: var(--s8); }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s5);
  border-top: 2px solid var(--ink);
  padding-top: var(--s3);
  margin-bottom: var(--s6);
}
.section-head h2 {
  font-size: 48px; line-height: 1;
  font-weight: 800; font-stretch: 62%;
  letter-spacing: -0.01em;
}
.section-ref {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  text-align: right; max-width: 44ch;
}
@media (max-width: 640px) {
  .section { padding-top: var(--s7); padding-bottom: var(--s7); }
  .section-head { flex-direction: column; gap: var(--s2); }
  .section-ref { text-align: left; }
  .section-head h2 { font-size: 40px; }
}

/* ---- Cutaway figure ---- */
.cutaway {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s5);
}
.figure-scroll { background: var(--paper-2); border: 1px solid var(--hair); }
.figure { display: block; width: 100%; height: auto; }
.figure-hint { display: none; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }

.figure .ln { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.figure .ln-thin { fill: none; stroke: var(--ink); stroke-width: 1; }
.figure .box { fill: var(--paper); }
.figure .ln.box, .figure .ln-thin.box { fill: var(--paper); }
.figure .hatch { fill: url(#hatch); }
.figure .hatch-line { stroke: var(--ink-2); stroke-width: 1; opacity: 0.45; }
.figure .faint { stroke: var(--ink-2); opacity: 0.6; }
.figure .dashed { stroke-dasharray: 5 5; stroke: var(--ink-2); }
.figure .x-mark { stroke: var(--red); stroke-width: 2.5; }
.figure .solid { fill: var(--ink); }
.figure .accent-fill { fill: var(--red); }
.figure .arrow-head { fill: var(--ink); }
.figure text { fill: var(--ink); font-family: var(--mono); }
.figure .lbl { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.figure .lbl-sm { font-size: 12px; }
.figure .lbl-xs { font-size: 10.5px; }

.figure .flow { stroke: var(--red); stroke-dasharray: 3 9; animation: flow 1.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -24; } }

.figure .callout circle { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; transition: fill 150ms, stroke 150ms; }
.figure .callout text {
  font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: central;
  transition: fill 150ms;
}
.figure .callout { cursor: pointer; }

.figure .part { transition: opacity 150ms; }
.figure.has-focus .part:not(.is-on) { opacity: 0.28; }
.figure .part.is-on .ln, .figure .part.is-on .ln-thin { stroke: var(--red); }
.figure .part.is-on .solid { fill: var(--red); }
.figure .part.is-on text { fill: var(--red); }
.figure .callout.is-on circle { fill: var(--red); stroke: var(--red); }
.figure .callout.is-on text { fill: var(--on-red); }

@media (prefers-reduced-motion: reduce) {
  .figure .flow { animation: none; }
  .figure .part, .figure .callout circle, .figure .callout text { transition: none; }
}

.legend { counter-reset: part; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: var(--s5); }
.legend li:nth-child(-n+4) { border-top: 2px solid var(--ink); }
.legend li {
  counter-increment: part;
  position: relative;
  padding: var(--s3) 0 var(--s3) 40px;
  border-bottom: 1px solid var(--hair);
  font-size: 15px; line-height: 1.5; color: var(--ink-2);
  cursor: default;
  transition: color 150ms;
}
.legend li::before {
  content: counter(part);
  position: absolute; left: 0; top: var(--s3);
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--ink);
  transition: background-color 150ms, color 150ms, border-color 150ms;
}
.legend li strong { color: var(--ink); font-weight: 700; }
.legend li.is-on { color: var(--ink); }
.legend li.is-on::before { background: var(--red); border-color: var(--red); color: var(--on-red); }
.legend li:focus-visible { outline-offset: 0; }

@media (max-width: 1000px) {
  .legend { grid-template-columns: 1fr 1fr; }
  .legend li:nth-child(-n+4) { border-top: 0; }
  .legend li:nth-child(-n+2) { border-top: 2px solid var(--ink); }
}
@media (max-width: 720px) {
  .figure-scroll { overflow-x: auto; margin-inline: calc(var(--gutter) * -1); border-inline: 0; }
  .figure { width: 760px; max-width: none; }
  .figure-hint { display: block; margin-top: calc(var(--s3) * -1); }
  .legend { grid-template-columns: 1fr; }
  .legend li:nth-child(2) { border-top: 0; }
}

/* ---- Builds ---- */
.builds-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 6fr) minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--s5);
  padding: var(--s5) 0;
  border-bottom: 1px solid var(--hair);
  align-items: baseline;
}
.builds-headrow {
  padding: 0 0 var(--s2);
  border-bottom: 2px solid var(--ink);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
.builds-row h3 {
  font-size: 32px; line-height: 1;
  font-weight: 750; font-stretch: 70%;
  letter-spacing: -0.005em;
}
.builds-row h3 a { text-decoration: none; background: linear-gradient(var(--red), var(--red)) left bottom / 100% 3px no-repeat; padding-bottom: 2px; }
.builds-row p { font-size: 16px; }
.builds-row .stack { font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.builds-row .state { font-family: var(--mono); font-size: 12px; display: flex; gap: var(--s2); align-items: baseline; }
.dot { flex: none; width: 8px; height: 8px; border: 1.5px solid var(--ink-2); display: inline-block; transform: translateY(-1px); }
.dot.is-live { background: var(--red); border-color: var(--red); }
.builds-row:not(.builds-headrow):hover h3 { color: var(--red); }
.builds-row h3 { transition: color 150ms; }

@media (max-width: 900px) {
  .builds-headrow { display: none; }
  .builds-list { border-top: 2px solid var(--ink); }
  .builds-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name state" "desc desc" "stack stack";
    gap: var(--s2) var(--s4);
  }
  .builds-row h3 { grid-area: name; font-size: 28px; }
  .builds-row p:nth-of-type(1) { grid-area: desc; margin-top: var(--s1); }
  .builds-row .stack { grid-area: stack; }
  .builds-row .state { grid-area: state; }
}

/* ---- Log ---- */
.log li {
  display: grid; grid-template-columns: 14ch minmax(0, 1fr);
  gap: var(--s5);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--hair);
  align-items: baseline;
}
.log li:first-child { border-top: 2px solid var(--ink); }
.log time { font-family: var(--mono); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.log p { font-size: 17px; max-width: 60ch; }
.log li:first-child time { color: var(--red); font-weight: 700; }
@media (max-width: 520px) {
  .log li { grid-template-columns: 1fr; gap: var(--s1); }
}

/* ---- Links ---- */
.links { border-top: 2px solid var(--ink); }
.links li { border-bottom: 1px solid var(--hair); }
.links a {
  display: flex; align-items: baseline; gap: var(--s5);
  padding: var(--s4) 0;
  text-decoration: none;
}
.links-host {
  width: 14ch; flex: none;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
.links-path {
  font-size: clamp(32px, 6vw, 64px); line-height: 1;
  font-weight: 800; font-stretch: 62%;
  overflow-wrap: anywhere;
}
.links a:hover .links-path { color: var(--red); }
.links a:hover .links-host { color: var(--red); }
@media (max-width: 520px) {
  .links a { flex-direction: column; gap: var(--s1); }
}

/* ---- Footer ---- */
.foot {
  display: flex; justify-content: space-between; gap: var(--s4);
  padding-top: var(--s5); padding-bottom: var(--s6);
  border-top: 1px solid var(--hair);
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}

/* ---- Print: the page becomes the spec sheet ---- */
@media print {
  :root {
    --paper: #fff; --paper-2: #fff; --ink: #000; --ink-2: #333; --hair: #bbb; --red: #c8211a; --on-red: #fff;
  }
  @page { margin: 14mm; }
  body { font-size: 10.5pt; }
  .bar, .skip, .foot, #log, .figure-hint, .section-ref { display: none; }
  .section-head { break-after: avoid; }
  #setup { break-before: page; }
  .wrap { max-width: none; padding-inline: 0; }
  .cover { padding-top: 0; padding-bottom: 24px; }
  .cover-name { font-size: 140px; }
  .section { padding-top: 18px; padding-bottom: 18px; }
  .section-head h2 { font-size: 30px; }
  .section-head { margin-bottom: 12px; }
  .figure-scroll { border: 1px solid #000; overflow: visible; margin: 0; }
  .figure { width: 100%; }
  .figure .flow { animation: none; }
  .cutaway { grid-template-columns: 1fr; gap: 12px; }
  .legend { grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .legend li { font-size: 9pt; padding-top: 6px; padding-bottom: 6px; }
  .legend li::before { top: 6px; }
  .builds-row, .log li, .legend li { break-inside: avoid; }
  .builds-row { padding: 7px 0; gap: 2px 16px; }
  .builds-row h3 { font-size: 20px; }
  .builds-row p { font-size: 9pt; line-height: 1.4; }
  .links a { padding: 6px 0; }
  .links-path { font-size: 18px; }
  #elsewhere { break-inside: avoid; }
  #builds { break-before: page; }
  a { text-decoration: none; }
}
