/* bmeisl.com — design tokens + typography foundations (DESIGN.md P0 + P6).
   anti-slop-allow: warm-editorial is anchored to existing brand — resume accent
   #1F4C7A and the BBB hairline house style; the serif is a text face (Source
   Serif 4), and there is no green anywhere in the palette. On the tell's 2026
   rusty-orange drift: the copper here predates the trend (BBB house hairlines),
   and it is confined to document furniture — rules, numerals, ticks, selection —
   never a brand fill, hero wash, or display-italic pairing. */

/* ---------------- fonts ---------------- */

@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/SourceSerif4VF.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

/* Georgia, metric-matched to Source Serif 4 (overrides computed from the two
   fonts' tables) so the swap causes zero layout shift. */
@font-face {
  font-family: "SS4 Fallback";
  src: local("Georgia");
  size-adjust: 101.605%;
  ascent-override: 101.963%;
  descent-override: 32.971%;
  line-gap-override: 0%;
}

/* ---------------- tokens ---------------- */

:root {
  color-scheme: light dark;

  /* color — light "paper" / dark "slate"; WCAG + APCA measured, design/contrast.md */
  --paper: oklch(0.965 0.009 85);
  --paper: light-dark(oklch(0.965 0.009 85), oklch(0.185 0.008 260));
  --ink: oklch(0.24 0.01 85);
  --ink: light-dark(oklch(0.24 0.01 85), oklch(0.9 0.008 85));
  --ink-muted: oklch(0.45 0.012 85);
  --ink-muted: light-dark(oklch(0.45 0.012 85), oklch(0.765 0.01 85));
  --rule: oklch(0.87 0.012 85);
  --rule: light-dark(oklch(0.87 0.012 85), oklch(0.32 0.01 260));
  --accent: oklch(0.42 0.075 255);
  --accent: light-dark(oklch(0.42 0.075 255), oklch(0.82 0.07 250));
  --accent-warm: oklch(0.55 0.11 55);
  --accent-warm: light-dark(oklch(0.55 0.11 55), oklch(0.77 0.1 60));

  /* type */
  --serif: "Source Serif 4", "SS4 Fallback", Charter, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --t-display: clamp(2.75rem, 9.5vw, 6.75rem);
  --t-entry: clamp(1.12rem, 0.3vw + 1.06rem, 1.22rem);
  --t-body: clamp(1.02rem, 0.4vw + 0.95rem, 1.09rem);
  --t-caption: 0.82rem;
  --t-label: 0.78rem;

  /* space — modular scale, no magic numbers */
  --s-4: 0.25rem;
  --s-8: 0.5rem;
  --s-12: 0.75rem;
  --s-16: 1rem;
  --s-24: 1.5rem;
  --s-32: 2rem;
  --s-48: 3rem;
  --s-72: 4.5rem;
  --s-96: 6rem;
}

/* count-up plumbing (top-level by spec; harmless where unsupported) */
@property --n { syntax: "<integer>"; inherits: false; initial-value: 0; }
@property --na { syntax: "<integer>"; inherits: false; initial-value: 0; }
@property --nb { syntax: "<integer>"; inherits: false; initial-value: 0; }

@counter-style pad3 {
  system: extends decimal;
  pad: 3 "0";
}

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

* { box-sizing: border-box; }

.skip {
  position: absolute;
  inset-inline-start: -9999px;
}

.skip:focus {
  inset-inline-start: 1.25rem;
  top: 0.75rem;
  background: var(--paper);
  padding: var(--s-8) var(--s-12);
}

html {
  -webkit-text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  margin: 0 auto;
  padding: var(--s-48) 1.25rem var(--s-48);
  max-width: 44rem;
  font-family: var(--serif);
  font-size: var(--t-body);
  font-optical-sizing: auto;
  font-variant-numeric: oldstyle-nums proportional-nums;
  line-height: 1.65;
  hyphens: none;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: color-mix(in oklab, var(--accent-warm) 25%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- masthead (nameplate) ---------------- */

header { margin-bottom: var(--s-48); }

header h1 {
  font-size: var(--t-display);
  font-weight: 560;
  letter-spacing: -0.012em;
  line-height: 1.05;
  text-wrap: balance;
  margin: 0 0 var(--s-12);
}

.role {
  margin: 0 0 var(--s-8);
  font-size: var(--t-entry);
}

.contact {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--t-caption);
  color: var(--ink-muted);
}

/* thick-thin copper Oxford rule — the nameplate's one loud moment */
header::after {
  content: "";
  display: block;
  height: 7px;
  margin-top: var(--s-24);
  border-top: 3px solid var(--accent-warm);
  border-bottom: 1px solid var(--accent-warm);
}

@media (min-width: 768px) {
  body { padding-top: var(--s-96); }
}

/* ---------------- stats band ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: var(--s-24) var(--s-32);
  padding: var(--s-8) 0 var(--s-24);
  margin-bottom: var(--s-48);
  border-bottom: 1px solid var(--rule);
}

.num {
  display: block;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 560;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: lining-nums tabular-nums;
}

.stat-l {
  display: block;
  margin-top: var(--s-4);
  font-family: var(--sans);
  font-size: var(--t-caption);
  color: var(--ink-muted);
}

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

section { margin-bottom: var(--s-48); }

h2 {
  position: relative;
  font-family: var(--sans);
  font-size: var(--t-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
  margin: 0 0 1.1rem;
}

/* copper chapter numerals — display-serif, loud */
.secno {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 560;
  color: var(--accent-warm);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0;
  margin-inline-end: 0.4em;
  vertical-align: -0.08em;
}

.nobr { white-space: nowrap; }

.lede { font-size: var(--t-entry); }

p {
  margin: 0 0 var(--s-16);
  text-wrap: pretty;
}

/* ---------------- entries ---------------- */

.entry { margin: 0 0 var(--s-24); }

.entry h3 {
  position: relative;
  font-size: var(--t-entry);
  font-weight: 600;
  margin: 0;
}

.entry p { margin: 0.15rem 0 0; }

/* products carry the receipts — one type step up, tech line, real plate */
.featured .entry h3 { font-size: clamp(1.28rem, 0.5vw + 1.2rem, 1.42rem); }

.tech {
  font-family: var(--sans);
  font-size: var(--t-caption);
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}


/* repo index — hanging-indent catalog rows; the mono/serif contrast is the
   separator */
.repo-index {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
}

.repo-index li {
  margin: 0 0 0.45rem;
  padding-inline-start: 1.1rem;
  text-indent: -1.1rem;
}

.repo-index code { font-size: 0.85em; }

.repo-index a { margin-inline-end: 0.15em; }

.entry-no {
  font-family: var(--sans);
  font-size: var(--t-caption);
  font-weight: 400;
  color: var(--ink-muted);
  font-variant-numeric: lining-nums tabular-nums;
  margin-inline-end: 0.5em;
}

.status {
  font-family: var(--sans);
  font-size: var(--t-caption);
  font-weight: 400;
  color: var(--ink-muted);
  margin-inline-start: 0.4em;
  white-space: nowrap;
}

/* ---------------- marginalia ---------------- */

/* Inline caption line by default; floats into the rail at >=1080px. */
.note {
  font-family: var(--sans);
  font-size: var(--t-caption);
  color: var(--ink-muted);
  font-variant-numeric: lining-nums tabular-nums;
  margin: 0.2rem 0 0.4rem;
}

/* 67.5em, not 1080px: the layout inside is rem-sized, so the gate must track
   the user's root font size or the hangs clip at large text settings */
@media (min-width: 67.5em) {
  body { max-width: 58rem; }

  /* reserve the rail; prose measure stays 44rem. The masthead and stats band
     deliberately span the full measure — nameplate over document. */
  main > section:not(.stats),
  footer { padding-inline-end: 14rem; }

  .repo-index {
    columns: 2;
    column-gap: 2.5rem;
  }

  .repo-index li { break-inside: avoid; }

  /* wide screens breathe */
  section { margin-bottom: var(--s-72); }

  .note {
    float: inline-end;
    clear: inline-end;
    width: 13rem;
    margin-block: 0.25em 0.75rem;
    margin-inline: 0 -14rem;
  }

  /* copper tick ties each note into the mark system */
  .note::before {
    content: "";
    display: block;
    width: 1.25rem;
    border-top: 1px solid var(--accent-warm);
    padding-bottom: 0.35rem;
  }

  /* entry numbers hang into the start-side gutter */
  .entry-no {
    position: absolute;
    inset-inline-end: 100%;
    margin-inline-end: 0.75rem;
    top: 0.28em;
  }

  /* chapter numerals join them, at display size */
  .secno {
    position: absolute;
    inset-inline-end: 100%;
    margin-inline-end: 0.75rem;
    bottom: 0.2rem;
    font-size: 2rem;
  }
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in oklab, currentColor 40%, transparent);
}

a:hover {
  text-decoration-thickness: 2px;
  text-decoration-color: currentColor;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
}

/* ---------------- figure ---------------- */

figure { margin: var(--s-32) 0 0; }

/* wide-figure contract: scrolls inside itself below ~560px, never the page */
.fig-scroll { overflow-x: auto; }

.fig-scroll svg {
  display: block;
  width: 100%;
  min-width: 33rem;
  max-width: 40rem;
  height: auto;
  color: var(--ink);
}

.fig-label text {
  font-family: var(--sans);
  font-size: 13px;
  fill: currentColor;
}

.fig-edge text {
  font-family: var(--sans);
  font-size: 11px;
  fill: var(--ink-muted);
}

.fig-ghost { opacity: 0.45; }

figcaption {
  margin-top: var(--s-8);
  font-family: var(--sans);
  font-size: var(--t-caption);
  color: var(--ink-muted);
}

.figno { color: var(--accent-warm); }

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

.crumb {
  margin: 0 0 var(--s-24);
  font-family: var(--sans);
  font-size: var(--t-caption);
  color: var(--ink-muted);
}

.article-head h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.9rem);
  font-weight: 560;
  letter-spacing: -0.01em;
  line-height: 1.12;
  text-wrap: balance;
  margin: 0 0 var(--s-8);
}

.art-meta {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--t-caption);
  color: var(--ink-muted);
}

/* thin Oxford — the child-page variant of the masthead rule */
.article-head::after {
  content: "";
  display: block;
  height: 4px;
  margin-top: var(--s-16);
  border-top: 2px solid var(--accent-warm);
  border-bottom: 1px solid var(--accent-warm);
}

pre {
  margin: var(--s-16) 0;
  padding: var(--s-12) var(--s-16);
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
  border-inline-start: 2px solid var(--rule);
  background: color-mix(in oklab, var(--ink) 4%, transparent);
}

pre code { font-size: 1em; }

/* ---------------- colophon ---------------- */

footer {
  margin-top: var(--s-72);
  padding-top: var(--s-16);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: var(--t-caption);
  line-height: 1.55;
}

footer p { margin: 0 0 var(--s-8); }
footer p:last-child { margin: 0; }

/* ---------------- motion (DESIGN.md §6 — decorative, fully gated) ---------------- */

@media (prefers-reduced-motion: no-preference) {
  /* load choreography — once, ≤600ms total (§9b amends §6's load budget):
     the name rises and settles into weight, role/contact follow, rule draws */
  @keyframes name-settle {
    from { opacity: 0; transform: translateY(8px); font-variation-settings: "wght" 380; }
    to   { opacity: 1; transform: none; font-variation-settings: "wght" 560; }
  }

  @keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
  }

  header h1 { animation: name-settle 500ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .role     { animation: fade-up 300ms ease-out 140ms both; }
  .contact  { animation: fade-up 300ms ease-out 220ms both; }

  /* stats land: numerals count up once, zero JS. Text fallback stays for
     reduced-motion and engines without the modern animation stack. */
  @supports (animation-timeline: view()) {
    .num .txt { display: none; }

    .num {
      counter-reset: n var(--n) na var(--na) nb var(--nb);
      animation-duration: 1000ms;
      animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
      animation-fill-mode: both;
    }

    .n1 { animation-name: fade-up, count-1; }
    .n2 { animation-name: fade-up, count-2; }
    .n1::before { content: counter(n); }
    .n2::before { content: counter(na) "," counter(nb, pad3); }
    .plus::after { content: "+"; }

    .stat:nth-child(1) .num { animation-delay: 260ms; }
    .stat:nth-child(2) .num { animation-delay: 340ms; }
    .stat:nth-child(3) .num { animation-delay: 420ms; }
    .stat:nth-child(4) .num { animation-delay: 500ms; }
    .stat:nth-child(5) .num { animation-delay: 580ms; }

    @keyframes count-1 {
      from { --n: 0; }
      to   { --n: var(--t); }
    }

    @keyframes count-2 {
      from { --na: 0; --nb: 0; }
      to   { --na: var(--a); --nb: var(--b); }
    }
  }

  header::after {
    transform-origin: 0 50%;
    animation: rule-draw 420ms cubic-bezier(0.2, 0.7, 0.2, 1) 180ms both;
  }

  /* Fig. 1 strokes draw in on viewport entry — same gate: no scroll
     timelines, no dashing, fully drawn diagram */
  @keyframes fig-draw {
    from { stroke-dashoffset: 1; }
    to   { stroke-dashoffset: 0; }
  }

  @supports (animation-timeline: view()) {
    .fig-strokes > * {
      stroke-dasharray: 1;
      animation: fig-draw 900ms ease-in-out both;
      animation-timeline: view();
      animation-range: entry 5% entry 60%;
    }
  }

  /* section rules draw in on first reveal — only where scroll timelines
     exist; everywhere else the static border stays and nothing animates */
  @keyframes rule-draw {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
  }

  @supports (animation-timeline: view()) {
    h2 { border-bottom-color: transparent; }

    h2::after {
      content: "";
      position: absolute;
      inset-inline: 0;
      bottom: -1px;
      height: 1px;
      background: var(--rule);
      transform-origin: 0 50%;
      animation: rule-draw 600ms ease-out both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }

  /* link micro-state */
  a { transition: text-decoration-thickness 120ms ease, color 120ms ease; }
}

a:hover { color: color-mix(in oklab, var(--accent) 82%, var(--ink)); }

/* forced-colors: the animated hairline and its transparent base border must
   both resolve to the system palette */
@media (forced-colors: active) {
  h2 { border-bottom-color: CanvasText; }
  h2::after { background: CanvasText; }
}
