/* A field guide to Uni — tokens first; components use tokens only. */
:root {
  --blotter: #EEF1EA;   /* ground: lichen-grey blotting paper */
  --sheet: #F7F9F4;     /* label stock */
  --ink: #1C231E;       /* gall ink: text and hairlines */
  --ink-soft: #46524A;  /* secondary text, 7.6:1 on blotter */
  --type-red: #A4132F;  /* herbarium type-specimen red: the heart, Uni's signature */
  --verdigris: #2D6A5E; /* links, what grew at this magnification */
  --pollen: #E7BC1A;    /* highlighter behind rough notes; never text */
  --rule: #B9C3B8;
  --mark-bg: #F2D97A;   /* pollen, thinned for light ground */
  --mark-ink: #1C231E;
  --card-dark: #1C231E; /* the spore card is a physical object: half dark, half pale, in both themes */
  --card-light: #F7F9F4;

  --display: "IM Fell English", Georgia, "Times New Roman", serif;
  --body: "Literata", Georgia, "Times New Roman", serif;
  --label: "Courier Prime", "Courier New", ui-monospace, monospace;

  --step-0: clamp(1.06rem, 1rem + 0.3vw, 1.2rem);
  --step-1: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem);
  --step-2: clamp(1.75rem, 1.4rem + 1.4vw, 2.4rem);
  --step-3: clamp(2.6rem, 1.7rem + 4vw, 4.6rem);
  --label-size: 0.8125rem;
  --measure: 62ch;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --blotter: #141A16; --sheet: #1C241F; --ink: #E3E9E1; --ink-soft: #AEB9B0;
    --type-red: #F07A8E; --verdigris: #7CC3B2; --pollen: #E7BC1A; --rule: #3A463E; --mark-bg: #E7BC1A; --mark-ink: #1C231E;
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --blotter: #141A16; --sheet: #1C241F; --ink: #E3E9E1; --ink-soft: #AEB9B0;
  --type-red: #F07A8E; --verdigris: #7CC3B2; --pollen: #E7BC1A; --rule: #3A463E; --mark-bg: #E7BC1A; --mark-ink: #1C231E;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0; background: var(--blotter); color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--body); font-optical-sizing: auto;
  text-rendering: optimizeLegibility; caret-color: var(--type-red);
  scrollbar-color: var(--rule) var(--blotter);
}
::selection { background: var(--pollen); color: #1C231E; }
a { color: var(--verdigris); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--type-red); outline-offset: 3px; border-radius: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--blotter); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; top: 1rem; }
h1, h2, h3 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
code, pre { font-family: var(--label); font-size: 0.9em; }
:not(pre) > code { background: var(--sheet); border: 1px solid var(--rule); padding: 0 .3em; border-radius: 2px; overflow-wrap: anywhere; }
pre { background: var(--sheet); border: 1px solid var(--rule); padding: .9rem 1rem; overflow-x: auto; line-height: 1.5; border-radius: 2px; }
mark { background: var(--mark-bg); color: var(--mark-ink); padding: 0 .12em; border-radius: 1px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.mark { width: .8em; height: .8em; vertical-align: -0.05em; color: var(--ink); margin-right: .15em; }

/* ── The plate (masthead) ─────────────────────────────────────── */
.plate {
  max-width: 72rem; margin: var(--gutter) auto 0; padding: clamp(1rem, 3vw, 2rem) var(--gutter) clamp(1.5rem, 3vw, 2.5rem);
  border: 1px solid var(--ink); outline: 1px solid var(--ink); outline-offset: 4px;
  margin-inline: max(var(--gutter), calc((100% - 72rem) / 2));
}
.running-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font: 400 var(--label-size)/1.4 var(--label); letter-spacing: .02em; color: var(--ink-soft); border-bottom: 1px solid var(--rule); padding-bottom: .6rem; }
.wordmark { color: var(--ink); font-weight: 700; }
.wip { font-weight: 400; margin-left: .35em; padding: 0 .35em; white-space: nowrap; }
h1 { font: 400 var(--step-3)/1.02 var(--display); letter-spacing: -0.01em; margin: clamp(1.2rem, 3vw, 2rem) 0 .4rem; max-width: 16ch; }
h1 i { color: var(--type-red); }
.subtitle { font-style: italic; color: var(--ink-soft); margin: 0 0 1.5rem; max-width: 46ch; }

.fig { margin: 0; }
.plate { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); grid-template-areas: "head head" "print title" "print sub" "print cap"; grid-template-rows: auto auto auto 1fr; column-gap: clamp(1.5rem, 3.5vw, 3rem); }
.running-head { grid-area: head; }
.plate h1 { grid-area: title; }
.subtitle { grid-area: sub; }
.fig-spore { display: contents; }
.fig-spore .spore { grid-area: print; margin-top: 1.5rem; }
.fig-spore figcaption { grid-area: cap; align-self: end; }
.spore { width: 100%; height: auto; display: block; }
.spore .card-dark { fill: var(--card-dark); }
.spore .card-light { fill: var(--card-light); }
.spore line { stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; }
.spore .on-dark { color: #E9EEE6; }
.spore .on-light { color: #1C231E; }
.spore line.n { stroke-dasharray: 1 3.2; stroke-width: 1.3; opacity: .85; }
.spore .stipe { fill: none; stroke: #8A958C; stroke-width: 1; }
.spore .dev { r: 320px; }
@media (prefers-reduced-motion: no-preference) {
  .spore .dev { animation: develop 2.2s cubic-bezier(.16, 1, .3, 1) both; }
  @keyframes develop { from { r: 24px; } to { r: 320px; } }
}
figcaption { font-size: .92rem; line-height: 1.5; color: var(--ink-soft); }
.fig-no { font: 700 var(--label-size) var(--label); color: var(--ink); margin-right: .4em; }
.key-solid, .key-dotted { white-space: nowrap; border-bottom: 1.5px solid var(--ink); }
.key-dotted { border-bottom-style: dotted; border-bottom-width: 2px; }

/* ── The loupe ────────────────────────────────────────────────── */
.loupe { max-width: 72rem; margin: 1.25rem auto 0; padding-inline: var(--gutter); position: sticky; top: 0; z-index: 5; }
.loupe fieldset { border: 0; margin: 0; padding: .6rem 0; background: var(--blotter); display: flex; align-items: center; gap: .5rem 1.25rem; flex-wrap: wrap; border-bottom: 1px solid var(--rule); }
.loupe legend { float: left; font: 700 var(--label-size) var(--label); color: var(--type-red); padding: 0; margin: 0; }
.loupe-options { display: inline-flex; border: 1px solid var(--ink); border-radius: 999px; padding: 3px; gap: 2px; }
.loupe input { position: absolute; opacity: 0; pointer-events: none; }
.loupe label { cursor: pointer; border-radius: 999px; padding: .35rem .9rem; font: 400 .95rem/1.2 var(--body); display: inline-flex; gap: .35em; align-items: baseline; transition: background-color .16s ease-out, color .16s ease-out; }
.loupe label b { font: 700 .95rem var(--label); }
.loupe label span { color: var(--ink-soft); }
.loupe input:checked + label { background: var(--ink); color: var(--blotter); }
.loupe input:checked + label span { color: inherit; }
.loupe input:focus-visible + label { outline: 2px solid var(--type-red); outline-offset: 2px; }
.loupe label:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.loupe input:checked + label:hover { background: var(--ink); }
.loupe-note { margin: 0; font-size: .85rem; color: var(--ink-soft); flex: 1 1 18rem; }

/* What each magnification shows. Without :has() support, everything shows. */
[data-ring="10"], [data-ring="40"] { display: none; }
body:has(#look-10:checked) [data-ring="10"],
body:has(#look-40:checked) [data-ring="10"],
body:has(#look-40:checked) [data-ring="40"] { display: revert; }
@supports not selector(:has(*)) { [data-ring="10"], [data-ring="40"] { display: revert; } .loupe { display: none; } }
@media (prefers-reduced-motion: no-preference) {
  .ring.just-grew, .just-grew { animation: grow .16s ease-out both; }
  @keyframes grow { from { opacity: 0; } to { opacity: 1; } }
}

/* ── Reading column and rings ─────────────────────────────────── */
main { padding: 0 var(--gutter); }
.ring { max-width: calc(var(--measure) + 10rem); margin: 0 auto; padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(1rem, 3vw, 2rem) 10rem; position: relative; border-top: 1px solid var(--rule); }
#heart { border-top: 0; }
.ring > * { max-width: var(--measure); }
.grew { position: absolute; left: 0; top: clamp(2.7rem, 6vw, 4.7rem); font: 700 var(--label-size) var(--label); color: var(--verdigris); border-top: 1px solid var(--verdigris); padding-top: .3rem; width: 7rem; }
h2 { font: 400 var(--step-2)/1.1 var(--display); margin: 0 0 1rem; letter-spacing: -0.005em; }
h3 { font: 600 var(--step-1)/1.25 var(--body); margin: 2.4rem 0 .6rem; }
.lede { font-size: 1.12em; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.3rem; margin: 0 0 1.2rem; }
li { margin-bottom: .45rem; }

.parts { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.parts li { display: flex; justify-content: space-between; gap: .4rem 1.5rem; flex-wrap: wrap; padding: .7rem 0; margin: 0; border-bottom: 1px solid var(--rule); }
.parts .name { font: italic 400 1.15rem var(--display); color: var(--type-red); white-space: nowrap; }
.takeaways li::marker { font: 700 .9em var(--label); color: var(--type-red); }
.honest { margin-top: 1.5rem; }

/* Herbarium labels: typed, small, carry the truth about each section */
.label { font: 400 var(--label-size)/1.5 var(--label); background: var(--sheet); border: 1px solid var(--rule); padding: .75rem .9rem; margin: 1.5rem 0 .5rem; max-width: 40rem; box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 12%, transparent); }
.label p { margin: 0 0 .25rem; display: grid; grid-template-columns: 7.5rem 1fr; gap: .5rem; }
.label p:last-child { margin: 0; }
.label p > span:first-child { color: var(--ink-soft); }
.label .v { color: var(--ink); }
.label-type { border-top: 6px solid var(--type-red); }

/* 10×: the key to the plate */
.key { margin: 2rem 0; }
.key-item { padding: 1.1rem 0 .4rem; border-top: 1px solid var(--rule); }
.key dt { font: 400 var(--step-1)/1.2 var(--display); margin-bottom: .5rem; }
.fig-letter { font: 700 var(--label-size) var(--label); color: var(--type-red); margin-right: .4em; vertical-align: .2em; }
.role { font: italic 400 1rem var(--body); color: var(--ink-soft); margin-left: .3em; }
.key dd { margin: 0; }
.problem { font-style: italic; color: var(--ink-soft); }
.cond { font-size: .92rem; color: var(--ink-soft); }

/* Fig. 2: one request, ridden like a line on a transit diagram */
.fig-ride { margin: 2.5rem 0 1rem; }
.fig-ride figcaption { margin-bottom: 1rem; }
.line { list-style: none; padding: 0; margin: 0; counter-reset: stop; position: relative; }
.line li { counter-increment: stop; position: relative; padding: 0 0 1.1rem 2.6rem; margin: 0; }
.line li::before { content: ""; position: absolute; left: .62rem; top: .4rem; bottom: -.4rem; width: 3px; background: var(--verdigris); }
.line li:last-child::before { display: none; }
.line li::after { content: counter(stop); position: absolute; left: 0; top: .1rem; width: 1.55rem; height: 1.55rem; border-radius: 50%; background: var(--blotter); border: 3px solid var(--verdigris); font: 700 .72rem/1.05rem var(--label); text-align: center; color: var(--ink); box-sizing: border-box; padding-top: .12rem; }
.line li.branch::after { border-color: var(--type-red); border-radius: 3px; }
.line li[aria-current="step"]::after { background: var(--verdigris); color: var(--blotter); }
.line li[aria-current="step"] b { color: var(--verdigris); }
.ride-controls { display: flex; gap: .6rem; align-items: center; margin-top: .4rem; }
.ride-controls button { font: 700 .9rem var(--label); background: transparent; color: var(--ink); border: 1px solid var(--ink); border-radius: 999px; padding: .35rem 1rem; cursor: pointer; }
.ride-controls button:hover { background: var(--ink); color: var(--blotter); }
.ride-controls output { font: .85rem var(--label); color: var(--ink-soft); }

/* 40× */
.contents ol { columns: 2 14rem; font-size: .95rem; padding-left: 1.4rem; }
.contents li::marker { font: 700 .85em var(--label); color: var(--ink-soft); }
.sub { padding-top: .5rem; }
.steps li::marker { font: 700 .9em var(--label); color: var(--verdigris); }
.table-wrap { overflow-x: auto; margin: 1rem 0 1.5rem; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums; }
caption { text-align: left; font: 700 var(--label-size)/1.4 var(--label); padding-bottom: .5rem; }
th, td { text-align: left; padding: .5rem .6rem .5rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font: 700 var(--label-size) var(--label); color: var(--ink-soft); border-bottom-color: var(--ink); }
.num { text-align: right; white-space: nowrap; }
.rough-list li { margin-bottom: .6rem; }

/* Grow your own */
.grow { border-top: 1px solid var(--ink); }
.cuttings { list-style: none; padding: 0; counter-reset: cut; }
.cuttings > li { counter-increment: cut; position: relative; padding: 0 0 1rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.2rem; }
.cuttings h3 { margin-top: .6rem; }
.cuttings h3::before { content: "Step " counter(cut); display: block; font: 700 var(--label-size) var(--label); color: var(--verdigris); margin-bottom: .2rem; }
.see { font-size: .95rem; }
.see span { font: 700 var(--label-size) var(--label); color: var(--ink-soft); margin-right: .5em; }
.more { color: var(--ink-soft); font-size: .95rem; }
.tools { display: grid; grid-template-columns: 9rem 1fr; gap: .55rem 1rem; font-size: .95rem; }
.tools dt { font: 700 var(--label-size)/1.9 var(--label); }
.tools dd { margin: 0; }
.not-yet { margin-top: 1.5rem; font-style: italic; color: var(--ink-soft); }

.colophon { max-width: 72rem; margin: 3rem auto 2rem; padding: 1.2rem var(--gutter) 0; border-top: 1px solid var(--ink); font-size: .92rem; color: var(--ink-soft); margin-inline: max(var(--gutter), calc((100% - 72rem) / 2)); }
.colophon .sig b { color: var(--type-red); font-weight: 600; }
.status { font: 400 var(--label-size)/1.6 var(--label); }

/* ── Phone ────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .plate { grid-template-columns: 1fr; grid-template-areas: "head" "title" "sub" "print" "cap"; }
  .fig-spore figcaption { margin-top: 1rem; }
  .ring { padding-left: 0; }
  .grew { position: static; display: block; width: auto; margin-bottom: .6rem; }
  .loupe { position: fixed; top: auto; bottom: 0; left: 0; right: 0; margin: 0; padding: 0; }
  .loupe fieldset { justify-content: center; padding: .5rem .5rem calc(.5rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--ink); border-bottom: 0; box-shadow: 0 -4px 14px color-mix(in srgb, var(--ink) 10%, transparent); }
  .loupe legend, .loupe-note { display: none; }
  .loupe-options { width: 100%; justify-content: space-between; }
  .loupe label { flex: 1; justify-content: center; padding: .45rem .3rem; flex-direction: column; align-items: center; gap: 0; font-size: .8rem; }
  body { padding-bottom: 5rem; }
  .tools { grid-template-columns: 1fr; gap: .1rem; }
  .tools dd { margin-bottom: .6rem; }
  .label p { grid-template-columns: 6rem 1fr; }
}
@media print { .loupe { display: none; } [data-ring] { display: revert !important; } }
