/* ============================================================
   MGMI — DESIGN.md system. "Field Manual, Journal-Grade."
   Archivo (condensed display/nav/placards) · Source Serif 4 (body)
   · IBM Plex Mono (data/citations). 5 tokens. One light mode.
   ============================================================ */

:root {
  --ink:   #111A24;   /* text, headers, placards */
  --paper: #F7F6F2;   /* page ground */
  --steel: #5C6B7A;   /* secondary text, hairlines, metadata */
  --star:  #2853C4;   /* sole accent — links, active, verified check, range band */
  --draft: #B3541E;   /* draft/unverified banners ONLY */

  /* WBGT flag semantics — heat UI only, never brand */
  --flag-green: #2e7d32; --flag-yellow: #b8a200; --flag-red: #c62828; --flag-black: #1a1a1a;

  /* type scale, 1.25 from 17px */
  --f-2: 10.9px; --f-1: 13.6px; --f0: 17px; --f1: 21.25px;
  --f2: 26.6px; --f3: 33.2px; --f4: 41.5px; --f5: 51.9px;

  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --display: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --measure: 68ch;
  --rail-w: 250px;
  --gap: 52px;
  --hair: 1px solid var(--steel);
  --hair-soft: 1px solid color-mix(in srgb, var(--steel) 35%, transparent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--f0);
  line-height: 1.65;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- type roles ---------- */
h1, h2, h3, h4, .display, nav, .placard, .eyebrow, th, .mono, .data {
  font-family: var(--display);
}
h1, h2, h3, h4 { line-height: 1.1; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .4em; }
h1 { font-size: var(--f4); }
h2 { font-size: var(--f2); }
h3 { font-size: var(--f1); }
p, li { max-width: var(--measure); }
a { color: var(--star); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
strong, b { font-weight: 600; }

.mono, .data, code, time, .doi { font-family: var(--mono); font-size: var(--f-1); }

/* ---------- placards (wayfinding chips) ---------- */
.placard, .eyebrow {
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 78%;
  font-size: var(--f-1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
}
.placard {
  background: var(--ink); color: var(--paper);
  padding: 5px 9px 4px; border-radius: 3px;
}
.placard--ghost { background: transparent; color: var(--ink); border: var(--hair); }
.placard--star { background: var(--star); color: #fff; }
.eyebrow { color: var(--steel); }
a.placard:hover { text-decoration: none; opacity: .88; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 28px; }

/* content + citation rail */
.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 28px; }
.layout { display: block; }
@media (min-width: 1100px) {
  .layout { display: grid; grid-template-columns: minmax(0, var(--measure)) var(--rail-w); gap: var(--gap); align-items: start; }
}
.content { min-width: 0; }
.content > * { max-width: var(--measure); }

/* ---------- header / nav ---------- */
.site-header { border-bottom: var(--hair); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: baseline; gap: 28px; height: 60px; }
.brand {
  font-family: var(--display); font-weight: 800; font-stretch: 82%;
  font-size: var(--f1); letter-spacing: 0.02em; color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand .brand-sub { color: var(--steel); font-weight: 600; font-size: var(--f-1); letter-spacing: .1em; text-transform: uppercase; margin-left: 8px; }
nav.mainnav { margin-left: auto; display: flex; gap: 22px; }
nav.mainnav a {
  font-family: var(--display); font-weight: 600; font-size: var(--f-1);
  letter-spacing: .06em; text-transform: uppercase; color: var(--steel);
}
nav.mainnav a:hover, nav.mainnav a[aria-current="page"] { color: var(--ink); text-decoration: none; }
nav.mainnav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--star); }

/* ---------- footer ---------- */
.site-footer { border-top: var(--hair); margin-top: 72px; padding: 26px 0 40px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-footer, .site-footer .mono { color: var(--steel); font-size: var(--f-1); }

/* ---------- hero (home thesis) ---------- */
.thesis { padding: 64px 0 12px; }
.thesis .lede { font-family: var(--serif); font-size: var(--f3); line-height: 1.28; font-weight: 400; max-width: 20ch; margin: 14px 0 22px; }
.thesis .lede em { font-style: italic; }
.stat-line { font-family: var(--mono); font-size: var(--f-1); color: var(--steel); display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 8px; }
.stat-line b { color: var(--ink); font-weight: 500; }

/* ---------- section rhythm ---------- */
section.band { padding: 34px 0; }
section.band + section.band { border-top: var(--hair-soft); }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.section-head .placard { transform: translateY(-1px); }

/* ---------- library index: journal-style ruled rows (NOT cards) ---------- */
.entry-list { border-top: var(--hair); }
.entry-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; padding: 16px 0; border-bottom: var(--hair-soft); }
.entry-row .title { font-family: var(--display); font-weight: 700; font-size: var(--f1); line-height: 1.18; letter-spacing: -0.01em; }
.entry-row .title a { color: var(--ink); }
.entry-row .title a:hover { color: var(--star); text-decoration: none; }
.entry-row .cite { font-family: var(--mono); font-size: var(--f-1); color: var(--steel); grid-column: 1 / 2; }
.entry-row .flags { grid-column: 2; grid-row: 1 / 3; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.entry-row .kind { font-family: var(--display); font-weight: 600; font-stretch: 80%; font-size: var(--f-2); letter-spacing: .12em; text-transform: uppercase; color: var(--steel); }

/* verified / unverified marks */
.vmark { font-family: var(--mono); font-size: var(--f-1); display: inline-flex; align-items: center; gap: 4px; }
.vmark--ok { color: var(--star); }
.vmark--no { color: var(--draft); }

/* ---------- filters (placard chips) ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0 6px; }
.filter-chip {
  font-family: var(--display); font-weight: 600; font-stretch: 82%; font-size: var(--f-2);
  letter-spacing: .1em; text-transform: uppercase; color: var(--steel);
  border: var(--hair-soft); background: transparent; border-radius: 3px; padding: 5px 9px 4px; cursor: pointer;
}
.filter-chip:hover { color: var(--ink); border-color: var(--steel); }
.filter-chip[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.searchbar { margin: 20px 0 4px; }
.searchbar input {
  width: 100%; max-width: var(--measure); font-family: var(--serif); font-size: var(--f1);
  padding: 10px 2px; border: none; border-bottom: var(--hair); background: transparent; color: var(--ink);
}
.searchbar input::placeholder { color: var(--steel); }
.searchbar input:focus { outline: none; border-bottom-color: var(--star); }

/* ---------- article / entry detail ---------- */
article.entry .detail-kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
article.entry h1 { font-size: var(--f3); max-width: 22ch; }
.byline { font-family: var(--mono); font-size: var(--f-1); color: var(--steel); margin: 0 0 6px; }
.block { margin: 26px 0; }
.block > h2 { font-size: var(--f-1); letter-spacing: .12em; text-transform: uppercase; color: var(--steel); font-stretch: 80%; margin-bottom: 8px; }
.sowhat { border-left: 3px solid var(--star); padding: 4px 0 4px 18px; font-size: var(--f1); }
.sup { font-family: var(--mono); font-size: .7em; vertical-align: super; color: var(--star); text-decoration: none; padding: 0 1px; }

/* ---------- Citation Rail ---------- */
.rail { font-size: var(--f-1); }
.rail .rail-head { font-family: var(--display); font-weight: 700; font-stretch: 80%; font-size: var(--f-2); letter-spacing: .14em; text-transform: uppercase; color: var(--steel); padding-bottom: 8px; border-bottom: var(--hair); margin-bottom: 4px; }
.cite-item { padding: 12px 0; border-bottom: var(--hair-soft); }
.cite-item .cite-label { font-family: var(--serif); font-size: var(--f-1); line-height: 1.4; display: block; margin-bottom: 3px; }
.cite-item .doi { display: block; word-break: break-all; color: var(--steel); }
.cite-item a.doi:hover { color: var(--star); }
.cite-item .cite-verified { color: var(--star); font-family: var(--mono); font-size: var(--f-2); letter-spacing: .04em; display: inline-flex; gap: 4px; align-items: center; margin-top: 3px; }
.cite-item .cite-unverified { color: var(--draft); font-family: var(--mono); font-size: var(--f-2); letter-spacing: .04em; margin-top: 3px; display: inline-block; }

@media (min-width: 1100px) {
  .rail { position: sticky; top: 84px; }
  .rail-inline-head { display: none; }
}
@media (max-width: 1099px) {
  /* rail collapses under content as a sources block */
  .rail { margin-top: 30px; border-top: var(--hair); padding-top: 6px; max-width: var(--measure); }
}

/* ---------- draft banner ---------- */
.draft-strip {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--draft); border-left-width: 4px; border-radius: 3px;
  background: color-mix(in srgb, var(--draft) 8%, var(--paper));
  color: var(--draft); padding: 10px 14px; margin: 18px 0; max-width: var(--measure);
}
.draft-strip .draft-tag { font-family: var(--mono); font-weight: 500; font-size: var(--f-1); letter-spacing: .06em; }
.draft-strip .draft-note { font-family: var(--serif); font-size: var(--f-1); color: var(--ink); }

/* ---------- calculator ---------- */
.calc-form { margin: 20px 0; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px 24px; max-width: none; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-family: var(--display); font-weight: 600; font-stretch: 84%; font-size: var(--f-1); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }
.field .hint { font-family: var(--serif); font-size: var(--f-2); color: var(--steel); }
.field input, .field select {
  font-family: var(--serif); font-size: var(--f0); color: var(--ink);
  padding: 8px 10px; background: #fff; border: var(--hair-soft); border-radius: 3px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--star); outline-offset: 0; border-color: var(--star); }
.consent { font-family: var(--serif); font-size: var(--f-1); color: var(--steel); margin: 20px 0; max-width: var(--measure); border-top: var(--hair-soft); padding-top: 14px; }
button.run, .btn {
  font-family: var(--display); font-weight: 700; font-stretch: 84%; font-size: var(--f-1);
  letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--star);
  border: none; border-radius: 3px; padding: 12px 22px; cursor: pointer;
}
button.run:hover, .btn:hover { background: color-mix(in srgb, var(--star) 88%, #000); }
button.run:focus-visible, .btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn--ghost { background: transparent; color: var(--star); border: var(--hair-soft); }
.btn--ghost:hover { background: transparent; border-color: var(--star); }

/* results table */
.results table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; }
.results th, .results td { text-align: left; padding: 12px 10px; border-bottom: var(--hair-soft); }
.results th { font-family: var(--display); font-weight: 700; font-stretch: 82%; font-size: var(--f-2); letter-spacing: .1em; text-transform: uppercase; color: var(--steel); border-bottom: var(--hair); }
.results td.num, .results th.num { text-align: right; font-family: var(--mono); font-size: var(--f-1); }
.results .model-name { font-family: var(--display); font-weight: 600; font-stretch: 88%; }
.results .model-draft td { color: var(--steel); }
.results .model-draft .model-name::after { content: " DRAFT"; font-family: var(--mono); font-size: var(--f-2); color: var(--draft); letter-spacing: .06em; }

/* planning-range band */
.range-band { margin: 26px 0; max-width: var(--measure); }
.range-band .rb-label { font-family: var(--display); font-weight: 700; font-stretch: 80%; font-size: var(--f-2); letter-spacing: .12em; text-transform: uppercase; color: var(--steel); margin-bottom: 8px; }
.rb-track { position: relative; height: 42px; border-bottom: var(--hair); }
.rb-fill { position: absolute; bottom: 0; height: 10px; background: var(--star); border-radius: 2px; }
.rb-tick { position: absolute; bottom: 0; height: 22px; width: 2px; background: var(--ink); }
.rb-num { position: absolute; bottom: 26px; font-family: var(--mono); font-size: var(--f-1); color: var(--ink); transform: translateX(-50%); white-space: nowrap; }

/* ---------- empty / notice states ---------- */
.notice { border: var(--hair-soft); border-radius: 3px; padding: 22px; color: var(--steel); font-family: var(--serif); max-width: var(--measure); }
.notice .next { color: var(--star); }

/* ---------- focus + a11y ---------- */
:focus-visible { outline: 2px solid var(--star); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 10px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 3px; z-index: 40; font-family: var(--display); }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .rise { opacity: 0; transform: translateY(8px); animation: rise .25s ease forwards; }
  .rail.rise { animation-delay: .08s; }
  @keyframes rise { to { opacity: 1; transform: none; } }
  .rb-fill { transition: width .4s ease; }
}
@media (prefers-reduced-motion: reduce) {
  .rise { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  :root { --f3: 27px; --f4: 32px; }
  .wrap, .page { padding: 0 18px; }
  nav.mainnav { gap: 14px; }
  .brand .brand-sub { display: none; }
}

/* ---------- print: entries, cases, calc one-pager (ink on white, rail -> footnotes) ---------- */
@media print {
  :root { --paper: #fff; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-header, nav.mainnav, .filters, .searchbar, .run, .btn, .consent, .no-print { display: none !important; }
  .layout { display: block; }
  .rail { position: static; margin-top: 18pt; border-top: 1px solid #000; }
  .rail .rail-head::before { content: "Sources — "; }
  a { color: #000; text-decoration: none; }
  .rb-fill { background: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .draft-strip { border-color: #000; color: #000; }
  .rise { opacity: 1 !important; transform: none !important; }
}
