/* coldanvil.com — site styles. Layout + components over the DS tokens.
   All colour/type/spacing values come from the token files; the only
   token DEFINED here is the in-development status (the DS predates the
   Active / In Development / Concept taxonomy — upstream to the DS). */

:root, [data-theme="dark"] {
  --status-indev-fg: var(--blue-11);
  --status-indev-bg: var(--blue-a3);
  --status-indev-border: var(--blue-a7);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text-primary);
  font-family: var(--font-body); font-size: var(--text-md);
  line-height: var(--leading-normal);
  transition: background-color .16s linear, color .16s linear;
}
a { color: var(--text-link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--text-link-hover); }
::selection { background: var(--selection-bg); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
img { max-width: 100%; }
.shell { max-width: var(--container); margin: 0 auto; padding-left: var(--content-pad-x); padding-right: var(--content-pad-x); }
.overline {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--text-subtle);
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-ui); font-weight: var(--weight-medium);
  border-radius: var(--radius-2); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color .12s linear, border-color .12s linear;
}
.btn-primary { background: var(--brand-accent); color: var(--text-on-emphasis); }
.btn-primary:hover { background: var(--brand-accent-hover); color: var(--text-on-emphasis); }
.btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--border-default); }
.btn-secondary:hover { border-color: var(--border-strong); color: var(--text-primary); }
.btn-sm { font-size: var(--text-sm); padding: 6px 14px; }
.btn-lg { font-size: var(--text-md); padding: 11px 22px; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--border-subtle); background: var(--bg); }
.header-row { display: flex; align-items: center; gap: var(--space-7); height: 64px; }
.wordmark { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.wordmark-text { font-family: var(--font-display); font-weight: var(--weight-semibold); font-size: var(--text-lg); letter-spacing: var(--tracking-display); color: var(--text-primary); }
.site-nav { display: flex; gap: var(--space-5); flex: 1; }
.site-nav a { font-size: var(--text-sm); color: var(--text-secondary); text-decoration: none; }
.site-nav a:hover { color: var(--text-primary); }
.site-nav a[aria-current="page"] { color: var(--text-primary); box-shadow: 0 2px 0 var(--brand-accent); }
.header-actions { display: flex; align-items: center; gap: var(--space-4); }
.theme-toggle { background: none; border: 1px solid var(--border-default); border-radius: var(--radius-2); color: var(--text-secondary); width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text-primary); }
.js .theme-toggle[hidden] { display: inline-flex; }
.tt-moon { display: none; }
[data-theme="dark"] .tt-moon { display: block; }
[data-theme="dark"] .tt-sun { display: none; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border-subtle); margin-top: var(--section-y); background: var(--bg-subtle); }
.footer-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--space-8); padding-top: var(--space-9); padding-bottom: var(--space-9); }
.footer-col { display: flex; flex-direction: column; gap: var(--space-3); }
.footer-col a { font-size: var(--text-sm); color: var(--text-secondary); text-decoration: none; }
.footer-col a:hover { color: var(--text-primary); }
.footer-note { grid-column: 1 / -1; border-top: 1px solid var(--border-subtle); padding-top: var(--space-6); }
.footer-note p { font-size: var(--text-xs); color: var(--text-subtle); margin: 0; }

/* ---------- home ---------- */
.hero { background: var(--bg); color: var(--text-primary); }
.hero-grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(0,1fr); gap: var(--space-10); align-items: center; padding-top: var(--space-12); padding-bottom: var(--space-12); }
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-6); }
.hero h1 { font-family: var(--font-display); font-size: 52px; font-weight: var(--weight-semibold); letter-spacing: var(--tracking-display); line-height: var(--leading-tight); margin: 0; max-width: 18ch; text-wrap: pretty; }
.hero-sub { font-size: var(--text-lg); line-height: var(--leading-relaxed); color: var(--text-secondary); margin: 0; max-width: 56ch; text-wrap: pretty; }
.hero-cta { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.hero-tags { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.stat-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-4); background: var(--surface); padding: var(--space-7); display: flex; flex-direction: column; gap: var(--space-5); }
.stat-tick { width: 28px; height: 3px; border-radius: 2px; background: var(--brand-accent); }
.stat-big { font-family: var(--font-mono); font-size: 76px; font-weight: var(--weight-semibold); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--text-sm); color: var(--text-secondary); }
.stat-rows { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.stat-rows > div { display: flex; justify-content: space-between; gap: var(--space-4); padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.stat-rows span:first-child { color: var(--text-subtle); }
.home-section { border-bottom: 1px solid var(--border-subtle); }
.home-section .shell, .band .shell { padding-top: var(--section-y); padding-bottom: var(--section-y); display: flex; flex-direction: column; gap: var(--space-7); }
.section-head { display: flex; align-items: baseline; gap: var(--space-6); }
.section-head h2 { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-display); margin: 0; }
.section-head .spacer { flex: 1; }
.section-head a { font-size: var(--text-sm); }
.lede { font-size: var(--text-xl); line-height: 1.55; letter-spacing: var(--tracking-tight); margin: 0; max-width: var(--measure); text-wrap: pretty; }
.band { background: var(--bg); color: var(--text-primary); }

/* ---------- cards / project lists ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap-loose); }
.proj-card { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); padding: var(--space-6); border: 1px solid var(--border-subtle); border-radius: var(--radius-3); background: var(--surface); text-decoration: none; color: inherit; transition: border-color .12s linear; }
a.proj-card:hover { border-color: var(--border-strong); color: inherit; }
.proj-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-display); color: var(--text-primary); }
.proj-desc { font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--text-secondary); }
.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--text-2xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; border: 1px solid; border-radius: var(--radius-full); padding: 3px 10px; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active { color: var(--status-active-fg); background: var(--status-active-bg); border-color: var(--status-active-border); }
.status-indev { color: var(--status-indev-fg); background: var(--status-indev-bg); border-color: var(--status-indev-border); }
.status-concept { color: var(--status-concept-fg); background: var(--status-concept-bg); border-color: var(--status-concept-border); }
.status-indev, .status-active, .status-concept { text-transform: none; letter-spacing: 0; font-size: var(--text-xs); }

/* ---------- list pages (research / writing rows) ---------- */
.row-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.post-row a, .res-row a { display: grid; grid-template-columns: 110px minmax(0,1fr); gap: var(--space-6); align-items: baseline; padding: var(--space-5) 0; border-top: 1px solid var(--border-subtle); text-decoration: none; color: inherit; }
.row-list li:last-child a { border-bottom: 1px solid var(--border-subtle); }
.post-row a:hover, .res-row a:hover { background: var(--surface-hover); }
.post-main { display: flex; flex-direction: column; gap: 2px; }
.post-title { font-size: var(--text-md); font-weight: var(--weight-medium); color: var(--text-primary); display: inline-flex; align-items: center; gap: 6px; }
.post-title .ext { color: var(--text-subtle); flex: none; }
.post-desc { font-size: var(--text-sm); color: var(--text-secondary); }

/* ---------- simple article pages (about/studio/donate/project) ---------- */
.page { max-width: 50rem; margin: 0 auto; padding: var(--space-10) var(--content-pad-x) var(--section-y); display: flex; flex-direction: column; gap: var(--space-8); }
.page-header { display: flex; flex-direction: column; gap: var(--space-5); padding-bottom: var(--space-7); border-bottom: 1px solid var(--border-subtle); }
.page-header h1 { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-display); line-height: var(--leading-tight); margin: 0; }
.page-header .sub { font-size: var(--text-lg); line-height: var(--leading-relaxed); color: var(--text-secondary); margin: 0; max-width: var(--measure); text-wrap: pretty; }
.prose { font-size: 17px; line-height: var(--leading-relaxed); }
.prose p, .prose ul, .prose ol { max-width: var(--measure); }
.prose h2 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-display); margin: var(--space-8) 0 var(--space-4); }
.prose h2:first-child { margin-top: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-8) 0; }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-inset); border-radius: var(--radius-1); padding: 1px 5px; }

/* ---------- report reader ---------- */
.progress-bar { position: fixed; top: 0; left: 0; height: 2px; background: var(--brand-accent); z-index: 50; width: 0; }
.art-grid { display: grid; grid-template-columns: 250px minmax(0,1fr); gap: var(--space-10); align-items: start; padding-top: var(--space-9); padding-bottom: var(--section-y); }
.art-rail { position: sticky; top: var(--space-8); display: flex; flex-direction: column; gap: var(--space-5); }
.art-rail nav { display: flex; flex-direction: column; }
.rail-link { display: grid; grid-template-columns: 22px minmax(0,1fr); gap: var(--space-3); align-items: baseline; padding: 6px 10px; margin-left: -10px; border: 0; background: none; text-align: left; font-family: var(--font-ui); font-size: var(--text-sm); color: var(--text-secondary); text-decoration: none; cursor: pointer; border-radius: var(--radius-1); }
.rail-link:hover { color: var(--text-primary); }
.rail-link .n { font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-subtle); }
.rail-link[aria-current="true"] { color: var(--text-primary); box-shadow: inset 2px 0 var(--brand-accent); }
.rail-link[aria-current="true"] .n { color: var(--brand-accent-text); }
.rail-counter, .rail-hint { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.rail-hint { font-size: var(--text-2xs); line-height: 1.8; }
.art-drawer { display: none; border: 1px solid var(--border-subtle); border-radius: var(--radius-3); padding: var(--space-4) var(--space-5); }
.art-drawer summary { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); cursor: pointer; }
.article { display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; }
.art-header { display: flex; flex-direction: column; gap: var(--space-5); }
.art-header h1 { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-display); line-height: var(--leading-tight); margin: 0; max-width: 24ch; text-wrap: pretty; }
.byline { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; display: flex; gap: var(--space-6); flex-wrap: wrap; align-items: baseline; padding-bottom: var(--space-6); border-bottom: 1px solid var(--border-subtle); }
.byline .who { color: var(--text-secondary); }
.byline .updated { color: var(--state-warning-fg); }
.art-section { display: flex; flex-direction: column; gap: var(--space-6); scroll-margin-top: var(--space-8); }
.tldr { border-bottom: 1px solid var(--border-subtle); padding-bottom: var(--space-7); }
.tldr p { font-size: var(--text-md); line-height: var(--leading-relaxed); margin: 0; max-width: var(--measure); text-wrap: pretty; }
.aside-box { border: 1px solid var(--border-subtle); border-left: 2px solid var(--brand-accent); border-radius: var(--radius-2); background: var(--surface); padding: var(--space-5) var(--space-6); max-width: var(--measure-wide); }
.aside-box .overline { display: block; margin-bottom: var(--space-2); }
.aside-box p { margin: 0; font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--text-secondary); }

/* results tables */
.tbl-label { margin-bottom: var(--space-4); }
table.rtable { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.rtable caption { text-align: left; }
.rtable th { text-align: right; font-family: var(--font-mono); font-size: 11px; font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-subtle); padding: 0 12px 10px; border-bottom: 1px solid var(--border-default); }
.rtable th:first-child { text-align: left; padding-left: 0; }
.rtable th:last-child { padding-right: 0; }
.rtable td { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; padding: 11px 12px; border-bottom: 1px solid var(--border-subtle); }
.rtable td:first-child { text-align: left; font-family: var(--font-ui); font-weight: var(--weight-medium); padding-left: 0; }
.rtable td:last-child { padding-right: 0; }
.rtable .dim { color: var(--text-subtle); }
.rtable .desc-row td:first-child { color: var(--text-secondary); font-weight: var(--weight-regular); }
.tbl-foot { display: flex; justify-content: space-between; gap: var(--space-6); align-items: baseline; flex-wrap: wrap; margin-top: var(--space-4); }
.tbl-foot p { font-size: var(--text-xs); line-height: 1.6; color: var(--text-subtle); margin: 0; max-width: var(--measure); }
.tbl-foot a { font-family: var(--font-mono); font-size: var(--text-xs); white-space: nowrap; }

/* figures (CSS bars) */
figure.chart { margin: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-3); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
figure.chart figcaption { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); }
.bar-row { display: grid; grid-template-columns: 170px minmax(0,1fr) 64px; gap: var(--space-4); align-items: center; }
.bar-row .lbl { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.bar-track { height: 20px; background: var(--surface-inset); border-radius: var(--radius-1); overflow: hidden; }
.bar-fill { height: 100%; background: var(--neutral-9); }
.bar-fill.alt { background: var(--neutral-7); }
.bar-outline { height: 100%; border: 1px dashed var(--border-strong); border-radius: 2px; box-sizing: border-box; }
.bar-val { font-family: var(--font-mono); font-size: var(--text-xs); font-variant-numeric: tabular-nums; text-align: right; }
figure.chart details summary { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-subtle); cursor: pointer; }
figure.chart details table { border-collapse: collapse; font-size: var(--text-xs); margin-top: var(--space-3); }
figure.chart details td { padding: 4px 16px 4px 0; }
figure.chart details td:last-child { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; padding-right: 0; }

/* corrections, cite, footnotes */
.empty-box { border: 1px dashed var(--border-default); border-radius: var(--radius-3); padding: var(--space-6); max-width: var(--measure-wide); display: flex; flex-direction: column; gap: var(--space-2); }
.empty-box .k { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); }
.empty-box .v { font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--text-secondary); }
.cite-row { display: flex; align-items: baseline; gap: var(--space-5); flex-wrap: wrap; max-width: var(--measure-wide); }
.cite-row p { font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--text-secondary); margin: 0; flex: 1; min-width: 280px; }
.copy-btn { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); background: none; border: 1px solid var(--border-default); border-radius: var(--radius-2); padding: 5px 10px; cursor: pointer; white-space: nowrap; }
.copy-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
pre.code { background: var(--surface-inset); border: 1px solid var(--border-subtle); border-radius: var(--radius-3); padding: var(--space-5); overflow-x: auto; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.7; max-width: var(--measure-wide); }
.footnotes { font-size: var(--text-sm); color: var(--text-secondary); }
.footnotes ol { padding-left: 1.2em; max-width: var(--measure); }
.footnotes li { margin-bottom: var(--space-2); }

/* shortcuts overlay */
.kbd-overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 60; display: flex; align-items: center; justify-content: center; }
.kbd-panel { background: var(--surface); border: 1px solid var(--border-default); border-radius: var(--radius-4); box-shadow: var(--shadow-3); padding: var(--space-7); min-width: 320px; display: flex; flex-direction: column; gap: var(--space-5); }
.kbd-grid { display: grid; grid-template-columns: auto minmax(0,1fr); gap: var(--space-3) var(--space-6); align-items: center; font-size: var(--text-sm); }
.kbd-grid kbd { font-family: var(--font-mono); font-size: var(--text-xs); border: 1px solid var(--border-default); border-radius: var(--radius-1); padding: 2px 8px; text-align: center; }
.kbd-grid span { color: var(--text-secondary); }

/* lab page */
.lab-photos { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--gap-loose); }
.lab-photos figure { margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.photo-slot { height: 340px; border: 1px solid var(--border-subtle); border-radius: var(--radius-3); background: var(--surface-inset); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); overflow: hidden; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.lab-photos figcaption { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); }
.machine-list { display: flex; flex-direction: column; }
.machine { display: grid; grid-template-columns: 220px minmax(0,1.2fr) minmax(0,1fr); gap: var(--space-7); align-items: start; padding: var(--space-7) 0; border-top: 1px solid var(--border-subtle); }
.machine:last-of-type { border-bottom: 1px solid var(--border-subtle); }
.machine .name { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-display); }
.machine .role { font-size: var(--text-md); line-height: var(--leading-normal); color: var(--text-secondary); }
.machine .spec { font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.8; color: var(--text-subtle); font-variant-numeric: tabular-nums; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .art-grid { grid-template-columns: minmax(0,1fr); }
  .art-rail { display: none; }
  .js .art-drawer { display: block; }
  .art-drawer:not(.js .art-drawer) { display: block; }
}
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: minmax(0,1fr); gap: var(--space-8); padding-top: var(--space-9); padding-bottom: var(--space-9); }
  .hero h1 { font-size: var(--text-3xl); }
  .stat-big { font-size: 56px; }
  .card-grid { grid-template-columns: minmax(0,1fr); }
  .machine { grid-template-columns: minmax(0,1fr); gap: var(--space-3); }
  .lab-photos { grid-template-columns: minmax(0,1fr); }
  .footer-grid { grid-template-columns: minmax(0,1fr); gap: var(--space-6); }
  .site-nav { overflow-x: auto; }
}
@media (max-width: 640px) {
  .post-row a, .res-row a { grid-template-columns: minmax(0,1fr); gap: var(--space-2); }
  table.rtable thead { display: none; }
  table.rtable tr { display: block; border-bottom: 1px solid var(--border-default); padding: var(--space-3) 0; }
  table.rtable td { display: flex; justify-content: space-between; gap: var(--space-4); text-align: right; border: 0; padding: 4px 0; }
  table.rtable td::before { content: attr(data-label); font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-subtle); }
}

/* ---------- print: the article is a paper ---------- */
@media print {
  .site-header, .site-footer, .art-rail, .art-drawer, .progress-bar,
  .theme-toggle, .kbd-overlay { display: none !important; }
  .art-grid { display: block; }
  figure.chart, table.rtable, .aside-box { break-inside: avoid; }
  body { background: #fff; color: #000; }
}
