/* SO-101 Arm Lab, a Lastlight Goods project.
   Palette: ink, dusk, paper, sand, sage, silver, one gold. */

:root {
  --ink: #1a191f;
  --dusk: #3d3b49;
  --paper: #fdfbf6;
  --sand: #f0e9dc;
  --sage: #6a7060;
  --silver: #aeb4bb;
  --gold: #b98526;

  /* dark theme (default) */
  --bg: var(--ink);
  --bg-2: #211f27;
  --panel: var(--dusk);
  --panel-2: #2a2831;
  --text: var(--sand);
  --heading: var(--paper);
  --muted: var(--silver);
  --label: #959b8a;          /* sage, lifted for contrast on ink */
  --rule: rgba(174, 180, 187, 0.28);
  --rule-strong: rgba(174, 180, 187, 0.55);
  --accent: var(--gold);
  --accent-ink: var(--ink);
  --code-bg: rgba(174, 180, 187, 0.10);
  --focus: var(--gold);
  --shadow: 0 1px 0 rgba(253, 251, 246, 0.04) inset;

  --serif: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;   /* headings: engineering mono (TC, REQ 018) */
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 72ch;
  --wide: 1120px;
  --gutter: 16px;
  --space: clamp(3rem, 8vw, 7rem);

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: var(--paper);
    --bg-2: #f7f3ea;
    --panel: var(--sand);
    --panel-2: #f7f3ea;
    --text: var(--ink);
    --heading: var(--ink);
    --muted: #5a5f66;
    --label: var(--sage);
    --rule: rgba(61, 59, 73, 0.22);
    --rule-strong: rgba(61, 59, 73, 0.45);
    --accent: #8a6118;        /* gold, deepened for contrast on paper */
    --accent-ink: var(--paper);
    --code-bg: rgba(61, 59, 73, 0.08);
    --focus: #8a6118;
    --shadow: none;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: var(--paper);
  --bg-2: #f7f3ea;
  --panel: var(--sand);
  --panel-2: #f7f3ea;
  --text: var(--ink);
  --heading: var(--ink);
  --muted: #5a5f66;
  --label: var(--sage);
  --rule: rgba(61, 59, 73, 0.22);
  --rule-strong: rgba(61, 59, 73, 0.45);
  --accent: #8a6118;
  --accent-ink: var(--paper);
  --code-bg: rgba(61, 59, 73, 0.08);
  --focus: #8a6118;
  --shadow: none;
  color-scheme: light;
}

/* ---------- base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

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

code, kbd {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.08em 0.35em;
  border-radius: 3px;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  color: var(--heading);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(2.75rem, 7vw, 5.25rem); }
h2 { font-size: clamp(2rem, 4vw, 3rem); }
h3 { font-size: clamp(1.5rem, 2.6vw, 2rem); font-variation-settings: "opsz" 72; }

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

.skip {
  position: absolute; left: var(--gutter); top: -4rem;
  padding: 0.5rem 0.9rem; background: var(--accent); color: var(--accent-ink);
  font-family: var(--mono); font-size: 0.8rem; text-decoration: none; z-index: 10;
  border-radius: 3px;
}
.skip:focus { top: 0.75rem; }

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

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--label);
  margin: 0 0 1rem;
}
.eyebrow .n { color: var(--muted); }

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }
.rule-motif {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--label); font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em;
}
.rule-motif::before, .rule-motif::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.rule-motif::after { flex: 6; }

/* ---------- header ---------- */

.site-head {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-head .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 3.25rem;
}
.brand {
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  text-decoration: none; color: var(--heading); display: inline-flex; align-items: center; gap: 0.6rem;
  white-space: nowrap;
}
.brand svg { width: 14px; height: 14px; }
.site-head nav { display: flex; gap: 1.25rem; font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.08em; }
.site-head nav a { text-decoration: none; color: var(--muted); }
.site-head nav a:hover { color: var(--accent); }
@media (max-width: 720px) { .site-head nav { display: none; } }

.theme-btn {
  appearance: none; background: transparent; color: var(--muted);
  border: 1px solid var(--rule); border-radius: 999px;
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem; cursor: pointer; line-height: 1;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- hero ---------- */

.hero { padding-block: clamp(3rem, 9vw, 7rem) clamp(2rem, 5vw, 4rem); }
.hero .lede {
  font-size: clamp(1.15rem, 2vw, 1.4rem); line-height: 1.5; color: var(--text);
  max-width: 44ch; margin-top: 1.5rem; text-wrap: pretty;
}
.hero-top { display: grid; gap: 2rem; align-items: end; grid-template-columns: 1fr; }
.status {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--rule); border-radius: 999px; padding: 0.4rem 0.85rem 0.4rem 0.7rem;
  margin-top: 2rem;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent); position: relative; flex: none;
}
.dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid var(--accent); opacity: 0;
  /* static: the chip is a dated snapshot, not live (TC, handoff doc 32) */
}
@keyframes ping {
  0% { transform: scale(0.5); opacity: 0.9; }
  70% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

.hero-figure { margin: clamp(2rem, 5vw, 3.5rem) 0 0; }
.frame {
  border: 1px solid var(--rule-strong);
  background: var(--panel-2);
  padding: 6px;
  border-radius: 2px;
  box-shadow: var(--shadow);
}
.frame img { width: 100%; border-radius: 1px; }
figcaption {
  font-family: var(--mono); font-size: 0.76rem; line-height: 1.5; color: var(--muted);
  margin-top: 0.7rem; text-wrap: pretty;
}
figcaption b { font-weight: 500; color: var(--text); }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--rule); border-block: 1px solid var(--rule);
  margin-top: clamp(2rem, 5vw, 3.5rem);
  list-style: none; padding: 0;
}
.stats li { background: var(--bg); padding: 1.5rem 1.25rem 1.4rem; }
.stats li:first-child { padding-left: 0; }
.stats .num {
  font-family: var(--mono); font-weight: 500; color: var(--accent);
  font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stats .num small { font-size: 0.45em; color: var(--muted); font-weight: 400; margin-left: 0.2em; letter-spacing: 0; }
.stats .what { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--label); margin-top: 0.7rem; }
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats li { padding: 1.25rem 1rem 1.1rem; }
  .stats li:nth-child(odd) { padding-left: 0; }
}

/* ---------- sections ---------- */

section { padding-block: var(--space); }
section + section { border-top: 1px solid var(--rule); }
.sec-head { margin-bottom: clamp(2rem, 4vw, 3.5rem); }
.sec-head p { color: var(--muted); max-width: var(--measure); margin-top: 1rem; }

/* diagram */
.diagram { margin: 0; }
.diagram svg { width: 100%; height: auto; }
.diagram .wide { display: block; }
.diagram .tall { display: none; }
@media (max-width: 720px) { .diagram .wide { display: none; } .diagram .tall { display: block; } }
.diagram text { font-family: var(--mono); fill: var(--text); }
.diagram .t-title { font-size: 15px; fill: var(--heading); letter-spacing: 0.04em; }
.diagram .t-sub { font-size: 11px; fill: var(--muted); }
.diagram .t-label { font-size: 10px; fill: var(--label); letter-spacing: 0.14em; }
.diagram .t-link { font-size: 10px; fill: var(--muted); letter-spacing: 0.06em; }
.diagram .box { fill: var(--panel-2); stroke: var(--rule-strong); stroke-width: 1; }
.diagram .hair { stroke: var(--silver); stroke-width: 0.75; fill: none; }
.diagram .hair-accent { stroke: var(--accent); stroke-width: 0.75; fill: none; }
.diagram .marker { fill: var(--heading); }
.diagram .mat { fill: none; stroke: var(--silver); stroke-width: 0.75; stroke-dasharray: 2 3; }
.diagram .arm { stroke: var(--heading); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.diagram .cam { fill: none; stroke: var(--accent); stroke-width: 0.75; }
.diagram .node { fill: var(--accent); }

.spec {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem;
  margin-top: clamp(2rem, 4vw, 3rem); padding-top: 2rem; border-top: 1px solid var(--rule);
}
.spec h3 { font-family: var(--mono); font-weight: 500; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--label); font-variation-settings: normal; }
.spec ul { list-style: none; padding: 0; margin: 0.9rem 0 0; font-size: 0.95rem; color: var(--text); }
.spec li { padding: 0.45rem 0; border-top: 1px solid var(--rule); }
.spec li:first-child { border-top: 0; }
.spec .k { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
@media (max-width: 720px) { .spec { grid-template-columns: 1fr; gap: 1.5rem; } }

/* field notes */
.notes { display: grid; gap: clamp(3rem, 7vw, 5.5rem); }
.note {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}
.note:nth-child(even) { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr); }
.note:nth-child(even) .note-body { order: 2; }
.note:nth-child(even) .note-fig { order: 1; }
.note-body { max-width: var(--measure); }
.note-body h3 { margin-bottom: 1.25rem; }
.note-body p { text-wrap: pretty; }
.note-fig { margin: 0; position: sticky; top: 4.5rem; }
.note-fig.pixel img { image-rendering: pixelated; }
.src { font-family: var(--mono); font-size: 0.72rem; color: var(--label); margin-top: 1.5rem; line-height: 1.6; }
.src::before { content: "sources "; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
@media (max-width: 860px) {
  .note, .note:nth-child(even) { grid-template-columns: 1fr; }
  .note:nth-child(even) .note-body { order: 1; }
  .note:nth-child(even) .note-fig { order: 2; }
  .note-fig { position: static; }
}

/* gallery */
.gallery {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem 1.25rem;
  list-style: none; padding: 0; margin: 0;
}
.gallery figure { margin: 0; }
.gallery a { display: block; text-decoration: none; color: inherit; }
.gallery a:hover .frame { border-color: var(--accent); }
.gallery .frame { aspect-ratio: 16 / 10; overflow: hidden; display: grid; place-items: center; }
.gallery .frame img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 860px) { .gallery { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .gallery { grid-template-columns: 1fr; } }

/* status */
.status-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.panel { background: var(--panel-2); border: 1px solid var(--rule); border-radius: 2px; padding: 1.5rem; }
.panel h3 { font-family: var(--mono); font-weight: 500; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--label); font-variation-settings: normal; margin-bottom: 1rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1.25rem; margin: 0; font-size: 0.95rem; }
.kv dt { font-family: var(--mono); color: var(--muted); font-size: 0.82rem; padding-top: 0.15rem; white-space: nowrap; }
.kv dd { margin: 0; }
.kv .num { font-family: var(--mono); color: var(--accent); font-weight: 500; }
.runs { font-family: var(--mono); font-size: 0.82rem; width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.runs th, .runs td { text-align: right; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--rule); font-weight: 400; font-variant-numeric: tabular-nums; }
.runs th { color: var(--label); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; }
.runs th:first-child, .runs td:first-child { text-align: left; padding-left: 0; }
.runs td.ok { color: var(--text); }
@media (max-width: 860px) { .status-grid { grid-template-columns: 1fr; } }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; max-width: var(--measure); }
.timeline li {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 1.25rem;
  padding: 1.1rem 0; border-top: 1px solid var(--rule);
  position: relative;
}
.timeline li:last-child { border-bottom: 1px solid var(--rule); }
.timeline time { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); padding-top: 0.2rem; white-space: nowrap; }
.timeline .ev { text-wrap: pretty; }
.timeline .ev b { font-weight: 500; color: var(--heading); }
@media (max-width: 520px) {
  .timeline li { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* footer */
.site-foot { border-top: 1px solid var(--rule); padding-block: 3rem 4rem; color: var(--muted); font-size: 0.92rem; }
.site-foot .wrap { display: grid; gap: 1.5rem; grid-template-columns: 1fr auto; align-items: start; }
.site-foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; font-family: var(--mono); font-size: 0.8rem; }
.site-foot .mark { font-family: var(--serif); font-weight: 300; font-size: 1.5rem; color: var(--heading); font-variation-settings: "opsz" 72; }
.site-foot .fine { font-family: var(--mono); font-size: 0.72rem; color: var(--label); margin-top: 1rem; }
@media (max-width: 600px) { .site-foot .wrap { grid-template-columns: 1fr; } }

/* ---------- article pages ---------- */

.article { padding-block: clamp(2.5rem, 7vw, 5rem) var(--space); }
.article header { margin-bottom: 2.5rem; }
.article h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); max-width: 24ch; }
.article .meta { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); margin-top: 1.25rem; }
.article h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 2.75rem 0 1rem; font-variation-settings: "opsz" 72; }
.article ol { padding-left: 1.25rem; }
.article ol li { margin-bottom: 1rem; padding-left: 0.4rem; text-wrap: pretty; }
.article ol li::marker { font-family: var(--mono); color: var(--accent); font-size: 0.9em; }
.article strong { font-weight: 500; color: var(--heading); }
.article pre {
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.55; background: var(--code-bg);
  border: 1px solid var(--rule); border-radius: 2px; padding: 0.9rem 1rem; overflow-x: auto; margin: 1.25rem 0;
}
.article pre code { background: none; padding: 0; font-size: inherit; }
.back { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.08em; text-decoration: none; color: var(--muted); display: inline-flex; gap: 0.5rem; align-items: center; }
.back:hover { color: var(--accent); }
.callout { border-left: 2px solid var(--accent); padding: 0.25rem 0 0.25rem 1.25rem; margin: 1.75rem 0; color: var(--text); }

/* 404 */
.lost { min-height: calc(100vh - 3.25rem); display: grid; place-items: center; text-align: center; padding-block: 4rem; }
.lost .code { font-family: var(--mono); font-size: clamp(4rem, 15vw, 8rem); color: var(--accent); line-height: 1; font-weight: 500; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dot::after { animation: none; opacity: 0.5; transform: scale(1.2); }
  *, *::before, *::after { transition: none !important; }
}
