/* ==========================================================================
   Modrats field notes: shared stylesheet for every post in site/notes/.
   Light mode only. Pastels are surfaces; the deeper chart steps carry
   text and data marks (validated for contrast and colour blindness).
   Components and usage are documented in .claude/skills/field-note/SKILL.md.
   ========================================================================== */

:root {
  /* house pastels: surfaces and fills only, never text or thin marks */
  --pink:#FDCAF7; --lilac:#D9C6FE; --sky:#CCEDFB; --mint:#BFFAF5; --cream:#FFEBC4; --mist:#E8E6FE; --violet:#C4A7FE; --grape:#C19EFB;
  --ground:var(--mist); --card:#fff; --accent:var(--grape);
  /* text */
  --ink:#22183a; --muted:#5f5880; --link:#6f42d8; --rule:#d9d4f5;
  /* chart steps, in this order: purple, blue (good), pink (bad), amber */
  --s-1:#8a5cf0; --s-good:#1c68a8; --s-bad:#dc66c4; --s-4:#c47c0e; --s-neutral:#b9a6e8; --grid:#efedfb;
  /* section divider: house pastels only, grape → pink → sky */
  --divider:linear-gradient(90deg, var(--grape), var(--pink) 50%, var(--sky));
  --on-good:#fff; --on-bad:#22183a;
  --display:Anton,Impact,sans-serif;
  --text:Archivo,system-ui,sans-serif;
  color-scheme:light;
}
* { box-sizing:border-box; margin:0; }
body { background:var(--ground); color:var(--ink); font-family:var(--text); -webkit-font-smoothing:antialiased; overflow-x:hidden; }
a { color:inherit; }
:focus-visible { outline:3px solid var(--ink); outline-offset:3px; }
/* read by screen readers, not shown */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
/* skip link: hidden until a keyboard user tabs to it */
.skip { position:absolute; left:16px; top:-60px; z-index:30; background:var(--ink); color:#fff; font-weight:700; padding:10px 16px; border-radius:999px; text-decoration:none; }
.skip:focus { top:12px; }

/* ---------- site bar (same as the home page) ---------- */
.bar { position:relative; z-index:2; display:flex; align-items:center; gap:30px; padding:20px 28px; font-size:16px; font-weight:500; }
.bar .mark { font-family:var(--display); font-size:22px; letter-spacing:.01em; text-decoration:none; margin-right:auto; font-weight:400; }
.bar a { text-decoration:none; }
.bar a:hover { text-decoration:underline; text-underline-offset:5px; }
.bar .cv { display:inline-flex; align-items:center; gap:6px; }
.bar .cv svg { width:20px; height:20px; }
.bar .cta { background:var(--accent); font-weight:700; padding:10px 20px; border-radius:999px; }
.bar .cta:hover { text-decoration:none; }

/* ---------- banner: the post's illustration, drifting a little on scroll ---------- */
/* full-bleed banner. Set --r on .banner to the picture's width ÷ height (e.g. style="--r:2.357" for 1584×672).
   The box takes that shape, capped at 72vh on short screens and 16:9 on phones. object-fit:cover crops
   (never stretches) whatever the cap trims, and the extra 8% height is the room the drift uses. */
.banner { --r:1.3333; position:relative; width:100%; aspect-ratio:calc(var(--r) * 1.0417); max-height:72vh; overflow:hidden; background:var(--lilac); }
.banner img { position:absolute; left:0; top:-4%; width:100%; height:108%; object-fit:cover; object-position:50% 40%; will-change:transform; }

/* ---------- article frame ---------- */
/* the post is a grid: contents list in the left margin, title and body on the right.
   The list starts beside the title and sticks as the reader scrolls (.toc, built by notes.js). */
/* One reading column, --col wide, holds the title, text, headings, dividers and charts, so what you see is
   what gets centred. It is centred on the PAGE: <main> is a size container, so cqw is the page width without
   the scrollbar. The contents list takes the room left of that centred column (200–340px) and sits in the
   left margin (--pad). Only where even a 200px list doesn't fit (~1400px and narrower) does --shift
   bottom out at 0, leaving the column slightly right of centre. */
main { container-type:inline-size; }
article.post { --col:38rem; --pad:clamp(64px, 7cqw, 128px); --gap:clamp(32px, 3cqw, 72px);
  --room:calc(50cqw - var(--col) / 2 - var(--pad) - var(--gap));
  --toc:clamp(200px, var(--room), 340px);
  --shift:max(0px, calc(var(--room) - var(--toc)));
  padding:56px 44px 120px var(--pad); display:grid; grid-template-columns:var(--toc) minmax(0, 1fr); grid-template-areas:"toc head" "toc body"; column-gap:var(--gap); }
.post-head, .post > .prose { justify-self:start; width:min(var(--col), 100% - var(--shift)); margin-left:var(--shift); }
.post-head { grid-area:head; }
.post h1 { scroll-margin-top:24px; }
.post > .prose { grid-area:body; }

/* contents list */
/* it starts up on the banner (pulled up by --lift), then sticks in the margin as the reader scrolls.
   A frosted mist panel keeps it readable over the illustration. */
.toc { --lift:180px; grid-area:toc; position:sticky; top:24px; align-self:start; z-index:2; margin-top:calc(-1 * var(--lift) - 56px); max-height:calc(100vh - 48px); overflow:auto;
  background:rgba(232,230,254,.82); -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px); border-radius:22px; padding:16px clamp(8px, calc(var(--toc, 340px) * .045), 16px); box-shadow:0 14px 36px -22px rgba(34,24,58,.5); }
.toc:not(.ready) { display:none; }
.toc h2 { font:700 15px/1.3 var(--text); margin:0 0 14px 2px; }
.toc ol { list-style:none; padding:0; display:flex; flex-direction:column; gap:12px; counter-reset:toc; }
.toc li { counter-increment:toc; }
.toc a { display:grid; grid-template-columns:1.2em 1fr; gap:6px; padding:clamp(12px, calc(var(--toc, 340px) * .058), 20px) clamp(12px, calc(var(--toc, 340px) * .065), 22px); background:var(--card); border-radius:16px; font-size:15px; line-height:1.4; text-decoration:none; box-shadow:0 6px 18px -12px rgba(34,24,58,.35); transition:background .25s, transform .25s cubic-bezier(.2,.8,.2,1); }
.toc a::before { content:counter(toc); font-weight:700; color:var(--s-1); }
.toc a:hover { transform:translateX(3px); }
.toc a[aria-current="true"] { background:var(--lilac); font-weight:700; }
.toc a[aria-current="true"]::before { color:var(--ink); }
.prose h2 { scroll-margin-top:24px; }
@media (prefers-reduced-motion:no-preference) { html { scroll-behavior:smooth; } }
.back { display:inline-block; font-weight:700; font-size:15px; text-decoration:none; margin-bottom:28px; }
.back:hover { text-decoration:underline; text-underline-offset:4px; }
h1 { font-family:var(--display); font-weight:400; text-transform:uppercase; font-size:clamp(48px,7vw,96px); line-height:.92; text-wrap:balance; }
.dek { font-size:clamp(20px,2vw,24px); line-height:1.45; margin-top:22px; }
.meta { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-top:18px; font-size:14px; font-weight:500; color:var(--muted); font-variant-numeric:tabular-nums; }
.meta span[aria-hidden] { color:var(--s-1); }

/* ---------- prose ---------- */
.prose { margin-top:48px; font-size:20px; line-height:1.6; display:flex; flex-direction:column; gap:1.2em; }
.prose b, .prose strong { font-weight:700; }
/* measure: the 38rem column keeps running text near 65–70 characters a line (45–75 is the readable range;
   WCAG AAA caps at 80). text-wrap:pretty avoids one-word last lines. */
.prose > p, .prose > ul, .prose > ol, .dek { text-wrap:pretty; }
.prose h2 { font-family:var(--display); font-weight:400; text-transform:uppercase; font-size:clamp(32px,4.2vw,46px); line-height:.98; margin-top:1.6em; text-wrap:balance; }
/* gradient divider above every section heading, so each section reads as its own block */
.prose h2::before { content:""; display:block; height:5px; border-radius:5px; background:var(--divider); margin-bottom:1.1em; }
.prose a { color:var(--link); text-underline-offset:3px; }
.prose ul { padding-left:1.25rem; display:flex; flex-direction:column; gap:.6rem; }
.prose li::marker { color:var(--s-1); }
.prose li b { font-weight:700; }
.def { background:var(--card); border-radius:22px; padding:22px 26px; }
.def b { font-weight:700; }

/* pull quote: one per post, the line a reader should remember */
.pull { font-size:clamp(24px,2.6vw,30px); font-weight:700; line-height:1.28; letter-spacing:-.01em; background:var(--card); border-radius:22px; padding:26px 28px 26px 30px; border-left:8px solid var(--accent); margin-block:.4em; }
.pull mark { background:linear-gradient(transparent 58%, var(--pink) 58%); color:inherit; padding:0 .1em; }

/* numbered plan: only for a real sequence of steps */
.steps { list-style:none; padding:0; counter-reset:st; display:flex; flex-direction:column; gap:12px; }
.steps li { counter-increment:st; position:relative; padding:18px 22px 18px 64px; background:var(--card); border-radius:20px; transition:transform .25s cubic-bezier(.2,.8,.2,1); }
.steps li:hover { transform:translateY(-3px); }
.steps li::before { content:counter(st); position:absolute; left:18px; top:16px; width:32px; height:32px; border-radius:50%; display:grid; place-items:center; font-weight:700; font-size:15px; background:linear-gradient(135deg, var(--pink), var(--lilac)); }

/* ---------- figures ---------- */
figure { display:flex; flex-direction:column; gap:10px; margin-block:.6em; }
figcaption { font-size:13px; line-height:1.5; color:var(--muted); }
figcaption a { color:var(--link); }
.chart { background:var(--card); border-radius:24px; padding:22px 24px 24px; display:flex; flex-direction:column; gap:16px; }
.chart h3 { font-size:21px; line-height:1.2; font-weight:700; }
.chart .sub { font-size:15px; color:var(--muted); margin-top:-8px; }
.scroll { overflow-x:auto; }

/* filter chips */
.seg { display:flex; flex-wrap:wrap; gap:8px; }
.seg button { font:500 14px var(--text); color:var(--ink); background:transparent; border:1.5px solid var(--rule); border-radius:999px; padding:7px 14px; cursor:pointer; transition:background .25s, border-color .25s, transform .15s; }
.seg button:hover { border-color:var(--s-1); }
.seg button:active { transform:scale(.97); }
.seg button[aria-pressed="true"] { background:var(--accent); border-color:var(--s-1); font-weight:700; } /* the --s-1 edge gives the pressed state 3:1+ against white */

/* legend */
.legend { display:flex; flex-wrap:wrap; gap:6px 18px; font-size:14px; color:var(--muted); }
.legend span { display:inline-flex; align-items:center; gap:7px; }
.sw { width:13px; height:13px; border-radius:4px; display:inline-block; }
.hatch { background:repeating-linear-gradient(135deg, var(--s-neutral) 0 3px, transparent 3px 6px); box-shadow:inset 0 0 0 1px var(--s-neutral); }

/* horizontal bars: name | bar | value */
.bars { position:relative; display:flex; flex-direction:column; gap:8px; padding-top:18px; }
.b { display:grid; grid-template-columns:8.5rem 1fr 3.8rem; gap:10px; align-items:center; cursor:default; border-radius:8px; }
.b .nm { font-size:15px; font-weight:700; }
.b .nm small { font-size:12px; font-weight:500; color:var(--muted); margin-left:4px; }
.b .track { position:relative; height:20px; }
.b .fill { position:absolute; left:0; top:0; bottom:0; background:linear-gradient(90deg, var(--s-1), var(--s-bad)); border-radius:0 7px 7px 0; transition:width 1s cubic-bezier(.2,.7,.2,1) calc(var(--i,0) * 70ms); }
.b:hover .fill, .b:focus-visible .fill { filter:brightness(1.1); }
.b .v { font-size:14px; font-weight:500; font-variant-numeric:tabular-nums; text-align:right; }
.b.hide { display:none; }
.axis { display:grid; grid-template-columns:8.5rem 1fr 3.8rem; gap:10px; }
.axis .ticks { position:relative; height:16px; font-size:12px; color:var(--muted); }
.axis .ticks span { position:absolute; transform:translateX(-50%); }
.gridlines { position:absolute; inset:18px 4.4rem 0 9.1rem; pointer-events:none; }
.gridlines i { position:absolute; top:0; bottom:0; width:1px; background:var(--grid); }
.gridlines i.avg { background:none; border-left:1.5px dashed var(--muted); }
.gridlines em { position:absolute; top:-18px; font-size:12px; font-style:normal; color:var(--muted); white-space:nowrap; transform:translateX(-50%); }

/* 100% stacked rows: name over a stack of segments */
.rows { display:flex; flex-direction:column; gap:14px; }
.row { display:grid; grid-template-columns:10rem 1fr; gap:12px; align-items:center; }
.row .nm { font-size:15px; font-weight:700; line-height:1.2; }
.row .nm small { display:block; font-size:12px; font-weight:500; color:var(--muted); }
.stack { display:flex; gap:2px; height:34px; }
.stack .s { height:100%; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; min-width:0; overflow:hidden; cursor:default; transition:flex-basis .9s cubic-bezier(.2,.7,.2,1) calc(var(--i,0) * 90ms); }
.stack .s:first-child { border-radius:8px 0 0 8px; } .stack .s:last-child { border-radius:0 8px 8px 0; }
.stack .s.good { background:var(--s-good); color:var(--on-good); }
.stack .s.bad { background:var(--s-bad); color:var(--on-bad); }
.stack .s.neutral { background:repeating-linear-gradient(135deg, var(--s-neutral) 0 3px, transparent 3px 6px); box-shadow:inset 0 0 0 1px var(--s-neutral); color:var(--ink); }
.stack .s:hover { filter:brightness(1.1); }
.stack .s:focus-visible { outline:3px solid var(--ink); outline-offset:-3px; }

/* 2x2 concept grid: only when the two axes are the point */
.matrix { display:grid; grid-template-columns:auto 1fr 1fr; grid-template-rows:auto 1fr 1fr; gap:10px; background:var(--card); border-radius:24px; padding:18px; }
.ax { font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); display:flex; align-items:center; justify-content:center; text-align:center; }
.ax.y { writing-mode:vertical-rl; transform:rotate(180deg); }
.q { border-radius:16px; padding:16px 18px; display:flex; flex-direction:column; gap:5px; min-width:0; background:var(--mist); transition:transform .25s cubic-bezier(.2,.8,.2,1); }
.q:hover { transform:translateY(-3px); }
.q h3 { font-size:17px; font-weight:700; }
.q p { font-size:14px; line-height:1.45; color:var(--muted); }
.q .tag { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; }
.q.good { background:var(--sky); } .q.good .tag { color:var(--s-good); }
.q.bad { background:var(--pink); } .q.bad .tag { color:#922a7e; }
.q.bad p, .q.good p { color:var(--ink); }

/* scroll-triggered "film" for one headline number */
.film-top { display:flex; justify-content:space-between; align-items:center; gap:16px; }
.replay { font:700 13px var(--text); color:var(--ink); background:var(--mist); border:0; border-radius:999px; padding:7px 14px; cursor:pointer; }
.replay:hover { background:var(--lilac); }
.film-body { display:grid; grid-template-columns:auto 1fr; gap:24px; align-items:center; }
.big { font-family:var(--display); font-size:84px; line-height:.9; font-variant-numeric:tabular-nums; }
.big small { display:block; font-family:var(--text); font-size:14px; line-height:1.4; color:var(--muted); max-width:11rem; margin-top:8px; }
.waffle { display:grid; grid-template-columns:repeat(20, 1fr); gap:4px; }
.waffle i { aspect-ratio:1; border-radius:3px; background:var(--s-bad); transition:background .5s, box-shadow .5s, transform .45s cubic-bezier(.3,1.6,.5,1), opacity .4s; }
.waffle i.ok { background:transparent; box-shadow:inset 0 0 0 2px var(--s-good); }
.waffle i.ok.glow { box-shadow:inset 0 0 0 2px var(--s-good), 0 0 0 3px var(--sky); }
.waffle i.blank { background:transparent; box-shadow:inset 0 0 0 1.5px var(--s-neutral); }
.waffle i.hidden { opacity:0; transform:scale(.3); }
.scene { font-size:16px; font-weight:500; line-height:1.45; min-height:2.9em; transition:opacity .4s; }
.scene.fade { opacity:0; }
.timeline { height:5px; border-radius:5px; background:var(--mist); overflow:hidden; }
.timeline span { display:block; height:100%; width:100%; border-radius:5px; background:linear-gradient(90deg, var(--s-1), var(--s-bad)); }

/* data table behind every chart */
details { font-size:14px; color:var(--muted); }
details summary { cursor:pointer; font-weight:700; }
details table { border-collapse:collapse; width:100%; margin-top:8px; font-size:14px; color:var(--ink); }
details th, details td { text-align:left; padding:7px 10px; border-bottom:1px solid var(--grid); font-variant-numeric:tabular-nums; }
details th { font-size:12px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); }

/* tooltip (created by notes.js) */
#tip { position:fixed; z-index:20; pointer-events:auto; background:var(--ink); color:#fff; font-size:14px; line-height:1.4; padding:8px 12px; border-radius:10px; max-width:17rem; box-shadow:0 8px 24px -10px rgba(34,24,58,.5); }
#tip b { display:block; }

/* scroll choreography (classes added by notes.js only to things below the fold) */
.rv { transition:opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.pre { opacity:0; transform:translateY(28px); }
.armed .fill { width:0 !important; }
.armed .stack .s { flex-basis:0 !important; }

@media (max-width:900px) {
  .bar { padding:16px; gap:18px; } .bar a:not(.mark):not(.cta) { display:none; }
  /* phones: a very wide picture would be a thin strip, so cap the box at 16:9 and crop the sides evenly (never stretch) */
  .banner { aspect-ratio:min(calc(var(--r) * 1.0417), 1.7778); }
  /* one column: title, then the contents list (not sticky), then the body */
  article.post { display:block; padding:36px 16px 80px; }
  .post-head, .post > .prose { width:min(var(--col), 100%); margin-inline:auto; }
  .toc { position:static; max-height:none; overflow:visible; margin:32px 0 0; background:none; -webkit-backdrop-filter:none; backdrop-filter:none; box-shadow:none; padding:0; }
  .prose { font-size:18px; }
}
@media (max-width:560px) {
  .row { grid-template-columns:1fr; gap:6px; }
  .b, .axis { grid-template-columns:6.5rem 1fr 3.3rem; }
  .gridlines { inset:18px 3.9rem 0 7.1rem; }
  .film-body { grid-template-columns:1fr; }
  .matrix { grid-template-columns:1fr; } .matrix .ax, .matrix .corner { display:none; }
  .chart { padding:18px; }
}
@media (prefers-reduced-motion:reduce) {
  .rv, .pre { transition:none; opacity:1; transform:none; }
  .fill, .stack .s, .waffle i, .steps li, .q { transition:none; }
}
