/* Glade theme — light through leaves. */
:root {
    /* Type stacks */
    --font-display: 'Fondamento', 'Niconne', 'Apple Chancery', cursive;
    --font-body: 'Lora', Georgia, 'Iowan Old Style', serif;
    --font-mono: 'DM Mono', ui-monospace, 'JetBrains Mono', monospace;
    /* Backwards-compatible aliases (existing CSS expects these names). */
    --font-heading: var(--font-display);
    --font-code: var(--font-mono);

    /* Type scale (perfect-fourth-ish, roomier at the top) */
    --fs-display: 3rem;     /* h1 on wide screens */
    --fs-h2: 1.85rem;
    --fs-h3: 1.4rem;
    --fs-h4: 1.15rem;
    --fs-body: 1.0625rem;   /* 17px */
    --fs-small: 0.875rem;
    --fs-mono: 0.9375rem;

    --leading-body: 1.65;
    --leading-tight: 1.25;

    /* Mossy-garden palette — light: oat paper, deep plum text,
       sage primary accent, lavender highlight, petal as a
       tertiary warm pop. */

    /* Paper (cool-cream / oatmeal — sits well next to sage) */
    --paper-50:  #f6f4ec;   /* outermost background; soft oat */
    --paper-100: #efebde;   /* card / callout background */
    --paper-200: #e5dfcd;   /* surface / hr */
    --paper-300: #ccc4a8;   /* borders */
    --paper-400: #a89e80;   /* muted dividers */

    /* Ink (deep moss — body text in dark forest green
       instead of black, harmonises with sage primary accent
       while staying high-contrast on the oat paper) */
    --ink-900: #1a2a1c;     /* deepest text, h1 */
    --ink-700: #233a26;     /* body text */
    --ink-500: #3d5640;     /* secondary text */
    --ink-400: #5e7660;     /* muted */
    --ink-300: #7d9580;     /* very muted */

    /* Sage (primary accent — mossy green family) */
    --sage-800: #36462f;    /* link-visited / deep accent */
    --sage-700: #4a5d3f;    /* link */
    --sage-600: #5d7350;    /* link hover, primary accent */
    --sage-500: #768a68;    /* secondary sage */
    --sage-400: #93a684;    /* muted sage */
    --sage-300: #b8c6a9;    /* faint chrome */
    --sage-200: #d3dcc4;    /* highlight wash */
    --sage-100: #e6ecdc;    /* faint background */

    /* Lavender (secondary accent / highlight wash) */
    --lavender-700: #5a4880;   /* deep lavender */
    --lavender-600: #7565a0;   /* link-on-emphasis */
    --lavender-500: #8f7eb8;   /* status:budding */
    --lavender-400: #ad9fcc;   /* secondary lavender */
    --lavender-300: #c8bdd9;   /* highlight wash */
    --lavender-200: #ddd5e8;   /* faint background */
    --lavender-100: #ece6f3;   /* very faint */

    /* Plum (text overtones, epistemic accent) */
    --plum-700: #5e2e63;
    --plum-500: #7c4684;
    --plum-300: #b89bbc;

    /* Petal (tertiary warm pop — used sparingly: tag hover, alert) */
    --petal-700: #8a3c2c;
    --petal-600: #a64a3a;
    --petal-300: #e8b6a8;
    --petal-100: #f5e0d8;

    /* Semantic role tokens — what components actually reference. */
    --bg: var(--paper-50);
    --bg-elevated: var(--paper-100);
    --bg-deep: var(--paper-200);
    --fg: var(--ink-700);
    --fg-strong: var(--ink-900);
    --fg-muted: var(--ink-500);
    --fg-faint: var(--ink-400);
    --border: var(--paper-300);
    --border-soft: var(--paper-200);
    --rule: var(--paper-400);

    /* Two-register accent system:
       - sage  = structural / site identity (chrome, callouts,
                 wikilinks, structural rules)
       - lavender = interactive (external links, focus rings,
                    hover states, highlights, tag chrome) */
    --link: var(--lavender-600);            /* general/external links */
    --link-hover: var(--lavender-500);
    --link-visited: var(--lavender-700);
    --link-internal: var(--sage-700);       /* wikilinks: stay in the garden */
    --link-internal-hover: var(--sage-600);

    --accent: var(--sage-700);              /* structural site accent */
    --accent-soft: var(--sage-100);
    --accent-strong: var(--sage-800);
    --interact: var(--lavender-600);        /* interaction accent */
    --interact-soft: var(--lavender-100);
    --interact-strong: var(--lavender-700);
    --highlight: var(--lavender-200);
    --highlight-strong: var(--lavender-500);

    --code-bg: var(--paper-100);
    --code-fg: var(--ink-700);
    --callout-bg: var(--paper-100);
    --callout-border: var(--sage-600);
    --callout-rule: var(--paper-300);

    --dead-link: var(--ink-300);
    --tag-bg: var(--lavender-100);
    --tag-fg: var(--lavender-700);
    --tag-bg-hover: var(--lavender-300);

    /* Backwards-compatible aliases for older selectors. */
    --muted: var(--fg-muted);

    /* Botanical status gradient: cool-to-warm-to-deep ─────
       seedling → budding → growing → evergreen
       plum     → lavender → sage   → deep sage */
    --status-seedling: var(--plum-500);
    --status-budding: var(--lavender-500);
    --status-growing: var(--sage-600);
    --status-evergreen: var(--sage-800);

    /* Shadows tinted toward ink, not pure black */
    --shadow-sm: 0 1px 2px rgba(42, 26, 46, 0.06);
    --shadow-md: 0 4px 16px rgba(42, 26, 46, 0.10);
    --shadow-lg: 0 10px 30px rgba(42, 26, 46, 0.14);

    /* Motion */
    --t-fast: 120ms;
    --t-med: 220ms;
    --ease: cubic-bezier(0.4, 0.0, 0.2, 1);

    color-scheme: light;
}

/* Dark theme: deep aubergine + cream text */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --__dark: 1; }
}
:root[data-theme="dark"] { --__dark: 1; }

/* Dark theme — mossy garden at dusk. Defined once below as a token
   block and applied via two selector branches: a system-preference
   `@media (prefers-color-scheme: dark)` and a manual override
   `[data-theme="dark"]`. CSS forbids mixing media-queried and
   non-queried selector lists, so we duplicate rather than share. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Stone-and-moss ground */
        --paper-50:  #1c211a;     /* deepest forest stone */
        --paper-100: #232a20;     /* elevated surface */
        --paper-200: #2c3528;     /* deeper surface */
        --paper-300: #3f4a3a;     /* borders */
        --paper-400: #5a6855;     /* rules */

        /* Warm cream text — very slightly mossy to feel like
           it belongs to the same garden, not pasted on. */
        --ink-900: #f3ecdc;
        --ink-700: #e6dec9;
        --ink-500: #c5bda7;
        --ink-400: #a59c87;
        --ink-300: #80796a;

        /* Sage lifts brightly on dark — primary accent */
        --sage-800: #c8d8be;
        --sage-700: #aec4a3;
        --sage-600: #94ad88;
        --sage-500: #7d966f;
        --sage-400: #647c57;
        --sage-300: #4a6041;
        --sage-200: #38492f;
        --sage-100: #2a3823;

        /* Lavender on dark — cool highlight */
        --lavender-700: #d6c8ec;
        --lavender-600: #c0aee0;
        --lavender-500: #aa92d4;
        --lavender-400: #8d75bd;
        --lavender-300: #5a4a82;
        --lavender-200: #3d325a;
        --lavender-100: #2c2444;

        /* Plum on dark */
        --plum-700: #d4afd9;
        --plum-500: #b48bbb;
        --plum-300: #7a4f80;

        /* Petal on dark — tertiary warm pop */
        --petal-700: #f0a995;
        --petal-600: #e08a72;
        --petal-300: #6e3a30;
        --petal-100: #3a201d;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.55);

        color-scheme: dark;
    }
}

/* Manual override duplicate. */
:root[data-theme="dark"] {
    --paper-50:  #1c211a;
    --paper-100: #232a20;
    --paper-200: #2c3528;
    --paper-300: #3f4a3a;
    --paper-400: #5a6855;

    --ink-900: #f3ecdc;
    --ink-700: #e6dec9;
    --ink-500: #c5bda7;
    --ink-400: #a59c87;
    --ink-300: #80796a;

    --sage-800: #c8d8be;
    --sage-700: #aec4a3;
    --sage-600: #94ad88;
    --sage-500: #7d966f;
    --sage-400: #647c57;
    --sage-300: #4a6041;
    --sage-200: #38492f;
    --sage-100: #2a3823;

    --lavender-700: #d6c8ec;
    --lavender-600: #c0aee0;
    --lavender-500: #aa92d4;
    --lavender-400: #8d75bd;
    --lavender-300: #5a4a82;
    --lavender-200: #3d325a;
    --lavender-100: #2c2444;

    --plum-700: #d4afd9;
    --plum-500: #b48bbb;
    --plum-300: #7a4f80;

    --petal-700: #f0a995;
    --petal-600: #e08a72;
    --petal-300: #6e3a30;
    --petal-100: #3a201d;

    color-scheme: dark;
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

::selection {
    background: var(--accent-soft);
    color: var(--ink-900);
}

/* Body */
html {
    font-size: 17px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-body);
    background-color: var(--bg);
    color: var(--fg);
    line-height: var(--leading-body);
    padding: 1rem;
    max-width: 100%;
    overflow-x: hidden;
    font-feature-settings: "kern", "liga", "onum"; /* old-style figures */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

/* Paper texture
   A subtle fractal-noise grain layered over the background.
   Fixed so it stays consistent during scroll. Inline SVG data
   URI — no extra request. Tile small enough (~220px) that the
   noise reads as paper fibre rather than a stretched photo. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18  0 0 0 0 0.16  0 0 0 0 0.14  0 0 0 0.85 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
    background-size: 220px 220px;
    opacity: 0.06;
    mix-blend-mode: multiply;
}

/* In dark mode, switch to a lifting blend so the grain lightens
   rather than darkens the deep moss ground. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body::before {
        opacity: 0.08;
        mix-blend-mode: screen;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.95  0 0 0 0 0.92  0 0 0 0 0.84  0 0 0 0.85 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
    }
}
:root[data-theme="dark"] body::before {
    opacity: 0.08;
    mix-blend-mode: screen;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.95  0 0 0 0 0.92  0 0 0 0 0.84  0 0 0 0.85 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
}

/* Vignette */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background: radial-gradient(
        ellipse 100% 75% at 50% 50%,
        transparent 45%,
        color-mix(in srgb, var(--ink-900, #2a2530) 24%, transparent) 100%
    );
    mix-blend-mode: multiply;
}

:root[data-theme="dark"] body::after {
    background: radial-gradient(
        ellipse 110% 80% at 50% 50%,
        transparent 42%,
        color-mix(in srgb, #000 14%, transparent) 60%,
        color-mix(in srgb, #000 38%, transparent) 75%,
        color-mix(in srgb, #000 68%, transparent) 88%,
        color-mix(in srgb, #000 92%, transparent) 100%
    );
    mix-blend-mode: normal;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body::after {
        background: radial-gradient(
            ellipse 110% 80% at 50% 50%,
            transparent 42%,
            color-mix(in srgb, #000 14%, transparent) 60%,
            color-mix(in srgb, #000 38%, transparent) 75%,
            color-mix(in srgb, #000 68%, transparent) 88%,
            color-mix(in srgb, #000 92%, transparent) 100%
        );
        mix-blend-mode: normal;
    }
}

/* Honour the user's accessibility preference: people who ask
   for reduced transparency probably want a flat ground. */
@media (prefers-reduced-transparency: reduce) {
    body::after { display: none; }
}

/* Unpublished preview banner
   Sticky strip at the top of any page rendered only because
   `--drafts` was passed. Petal/warm warning colour, paper-
   coloured text. Stays visible while scrolling so the author
   doesn't forget they're looking at a draft. */
.preview-banner {
    position: sticky;
    top: 0;
    z-index: 200;
    margin: 0;
    padding: 0.55rem 1rem;
    background: var(--petal-600);
    color: var(--paper-50);
    font-family: var(--font-body);
    font-size: 0.92rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    line-height: 1.4;
}

.preview-banner-icon {
    font-size: 1.05em;
    line-height: 1;
}

.preview-banner code {
    background: rgba(255, 255, 255, 0.18);
    padding: 0.05em 0.35em;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

:root[data-theme="dark"] .preview-banner {
    background: var(--petal-700);
    color: var(--paper-100);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .preview-banner {
        background: var(--petal-700);
        color: var(--paper-100);
    }
}

/* Page grid
   Mobile-first single column. On wide screens (≥1280px) we
   switch to a CSS grid with a marginalia gutter. */
.page-wrapper {
    max-width: 44rem;
    margin: 0 auto;
    padding: 0 0.75rem;
    position: relative;
}

@media (min-width: 1280px) {
    body.has-marginalia .page-wrapper {
        max-width: 64rem;
        display: grid;
        grid-template-columns: minmax(0, 44rem) minmax(0, 18rem);
        column-gap: 2.5rem;
    }
    body.has-marginalia main { grid-column: 1; }
    body.has-marginalia .marginalia-rail { grid-column: 2; }
    body.has-marginalia header,
    body.has-marginalia footer { grid-column: 1 / -1; }
}

/* Marginalia rail
   Standard markdown footnotes (`[^1]` and `[^1]: text`) get
   promoted to margin notes by the MarginaliaExtract transform.

   Two layouts:
    • Wide (≥1280px): rail sits in the right gutter; each item
      is absolutely positioned by `marginalia.js` next to its
      reference. Looks like Maggie Appleton / Tufte sidenotes.
    • Narrow (<1280px): the grid collapses; the rail flows below
      `<main>` as a traditional numbered "Notes" section.

   Inline reference superscripts (`<sup class="marginalia-ref">`)
   are styled small and accent-coloured wherever they appear. */
.marginalia-rail {
    display: block;
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-soft);
}
.marginalia-rail::before {
    content: "Notes";
    display: block;
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    margin-bottom: 1rem;
}
.marginalia-item {
    display: grid;
    grid-template-columns: 1.8em 1fr auto;
    column-gap: 0.5rem;
    align-items: baseline;
    margin: 0 0 1rem 0;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--fg-muted);
    scroll-margin-top: 1rem;
    transition: background-color var(--t-fast) var(--ease);
}
.marginalia-item:target {
    background: var(--accent-soft);
}
.marginalia-num {
    grid-column: 1;
    font-family: var(--font-mono, monospace);
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.marginalia-body {
    grid-column: 2;
}
.marginalia-body > :first-child { margin-top: 0; }
.marginalia-body > :last-child { margin-bottom: 0; }
.marginalia-body p {
    margin: 0 0 0.5em 0;
    /* Smaller paragraph spacing in margin notes. */
}
.marginalia-backref {
    grid-column: 3;
    color: var(--fg-muted);
    text-decoration: none;
    font-size: 0.85em;
    opacity: 0.4;
    transition: opacity var(--t-fast) var(--ease);
}
.marginalia-backref:hover { opacity: 1; }

/* Inline reference superscript in body text. */
.marginalia-ref {
    font-size: 0.7em;
    vertical-align: super;
    line-height: 0;
}
.marginalia-ref a {
    color: var(--accent);
    text-decoration: none;
    padding: 0 0.15em;
    border-radius: 2px;
    transition: background-color var(--t-fast) var(--ease);
}
.marginalia-ref a:hover { background: var(--accent-soft); }
.marginalia-ref:target a { background: var(--accent-soft); }

@media (min-width: 1280px) {
    /* Wide screen: the rail sits in column 2 of the grid;
       drop the "Notes" header and let JS position each item
       absolutely next to its reference. */
    body.has-marginalia .marginalia-rail {
        position: relative;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }
    body.has-marginalia .marginalia-rail::before { display: none; }
    body.has-marginalia .marginalia-item {
        margin-bottom: 1rem;
        background: transparent;
        border-left: 2px solid var(--border-soft);
        padding-left: 0.75rem;
        font-style: italic;
    }
    body.has-marginalia .marginalia-item.is-positioned {
        position: absolute;
        left: 0;
        right: 0;
        margin-bottom: 0;
    }
}

/* Marginalia hover highlighting
   When the user hovers/focuses an inline `<sup>` reference
   or a rail item, marginalia.js toggles `is-active` on
   BOTH sides. We highlight visually so the eye can match
   them up without needing a drawn line between them. */

/* Inline ref when active: an expanding pulse ring around
   the number plus a sparkle burst. The `<a>` becomes
   position: relative so the ::before pulse-ring and ::after
   sparkle layer can stack over the number without
   disturbing surrounding text flow. */
a[data-marginalia-ref] {
    position: relative;
    display: inline-block;
    transition: color var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
}

a[data-marginalia-ref].is-active {
    color: var(--accent);
    font-weight: 700;
    transform: scale(1.2);
}

/* Pulse ring: a sage circle that fades out as it expands.
   Drawn via the `<a>`'s ::before pseudo-element, centred on
   the number. Locked to `aspect-ratio: 1` so it stays a
   true circle regardless of the `<a>`'s text width. */
a[data-marginalia-ref]::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.6em;
    aspect-ratio: 1;
    transform: translate(-50%, -50%) scale(0.6);
    transform-origin: center;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    opacity: 0;
    pointer-events: none;
}

a[data-marginalia-ref].is-active::before {
    animation: marginalia-pulse 1.8s ease-out infinite;
}

@keyframes marginalia-pulse {
    0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.9; }
    60%  { transform: translate(-50%, -50%) scale(1.8); opacity: 0.2; }
    85%  { transform: translate(-50%, -50%) scale(2.1); opacity: 0;   }
    100% { transform: translate(-50%, -50%) scale(2.1); opacity: 0;   }
}

/* Honour reduced-motion: keep the colour highlight, drop
   the looping animation. The pulse ring stays as a static
   halo at full size rather than looping. */
@media (prefers-reduced-motion: reduce) {
    a[data-marginalia-ref].is-active::before {
        animation: none;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.4);
    }
}

/* Rail item when active: accent-bordered card with a quick
   lift-in shimmer so it reads as the partner of the
   highlighted inline reference. */
.marginalia-item.is-active {
    border-left-color: var(--accent);
    border-left-width: 3px;
    background: var(--accent-soft);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    transform: translateX(-2px);
}

.marginalia-item.is-active .marginalia-num {
    color: var(--accent);
    font-weight: 700;
    transform: scale(1.1);
}

/* Smooth transitions for the rail-item side. */
.marginalia-item,
.marginalia-num {
    transition: background-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease),
                border-width var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease);
}

/* Make sure body content sits above other layered overlays
   so text remains crisply readable. */
.page-wrapper > main,
.page-wrapper > .marginalia-rail,
.page-wrapper > footer {
    position: relative;
    z-index: 1;
}

/* Header stacks above main so the absolutely-positioned
   search-results dropdown (anchored inside .search-container)
   can paint over article content and receive pointer events.
   Without this, header would also sit at z-index 1 and lose
   to main on source order. */
.page-wrapper > header {
    position: relative;
    z-index: 50;
}

/* Dialog blocks
   Fenced `dialog` code blocks render as an iMessage-style
   exchange between named characters. Each turn carries the
   character's accent colour (sage/plum/petal/gold/moss/…)
   and sits on the left or right per their `side` config.
   Consecutive turns from the same speaker collapse the
   avatar via `.is-continuation`. */
.dialog {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin: 1.75rem 0;
}
.dialog-turn {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    max-width: 100%;
    color: var(--fg);
}
.dialog-turn--left {
    align-self: flex-start;
    flex-direction: row;
    margin-right: 3rem;
}
.dialog-turn--right {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: 3rem;
    text-align: right;
}
.dialog-turn.is-continuation {
    margin-top: -0.35rem;
}
.dialog-avatar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    /* Stronger fill than the bubble so the character's hue
       anchors the eye to the avatar first. */
    background: var(--dialog-strong, var(--accent-soft));
    color: var(--dialog-accent, var(--accent));
    box-shadow: 0 0 0 1.5px var(--dialog-edge, transparent),
                inset 0 0 0 1px color-mix(in srgb, var(--dialog-accent) 18%, transparent);
}
.dialog-avatar svg {
    width: 1.25rem;
    height: 1.25rem;
}
.dialog-avatar--spacer {
    background: transparent;
    color: transparent;
}
.dialog-meta {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    min-width: 0;
    max-width: min(34rem, 80%);
}
.dialog-turn--right .dialog-meta { align-items: flex-end; }
.dialog-name {
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--dialog-accent, var(--accent));
    font-weight: 600;
    opacity: 0.85;
}
.dialog-bubble {
    background: var(--dialog-tint, var(--accent-soft));
    border: 1px solid var(--dialog-edge, transparent);
    padding: 0.55rem 0.95rem;
    border-radius: 18px;
    line-height: 1.5;
    text-align: left;
    /* Bubble corners adapt to which side they sit on so the
       sharper "tail" corner reads as attached to the
       speaker's name/avatar above. */
}
.dialog-turn--left .dialog-bubble {
    border-top-left-radius: 6px;
}
.dialog-turn--right .dialog-bubble {
    border-top-right-radius: 6px;
}
.dialog-bubble > :first-child { margin-top: 0; }
.dialog-bubble > :last-child { margin-bottom: 0; }
.dialog-bubble p { margin: 0 0 0.45em 0; }
.dialog-bubble p:last-child { margin-bottom: 0; }
.dialog-bubble code {
    font-size: 0.92em;
    background: color-mix(in srgb, currentColor 10%, transparent);
    padding: 0.05em 0.3em;
    border-radius: 3px;
}

/* Character colour mapping.
   Three layers per hue:
     --dialog-accent : full accent (text, avatar SVG, name label)
     --dialog-tint   : bubble background (~22% mix — soft, readable text on top)
     --dialog-strong : avatar background (~36% mix — saturated, eye-catching)
     --dialog-edge   : bubble border + avatar ring (~50% mix — defined outline)
   The 3-strength split keeps the bubble subtle (text reads
   cleanly) while the avatar carries a saturated hue cue, so
   4–6 characters stay visually distinct even when several
   share a side of the chat. */
.dialog-color--sage {
    --dialog-accent: var(--sage-500, #6f8a5a);
    --dialog-tint:   color-mix(in srgb, var(--sage-500, #6f8a5a) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--sage-500, #6f8a5a) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--sage-500, #6f8a5a) 52%, transparent);
}
.dialog-color--plum {
    --dialog-accent: var(--plum-500, #6b4a82);
    --dialog-tint:   color-mix(in srgb, var(--plum-500, #6b4a82) 20%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--plum-500, #6b4a82) 36%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--plum-500, #6b4a82) 50%, transparent);
}
.dialog-color--petal {
    --dialog-accent: var(--petal-600, #c97a8e);
    --dialog-tint:   color-mix(in srgb, var(--petal-600, #c97a8e) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--petal-600, #c97a8e) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--petal-600, #c97a8e) 52%, transparent);
}
.dialog-color--gold {
    --dialog-accent: var(--gold-500, #b48a3a);
    --dialog-tint:   color-mix(in srgb, var(--gold-300, #d9b86b) 30%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--gold-300, #d9b86b) 48%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--gold-500, #b48a3a) 48%, transparent);
}
.dialog-color--moss {
    --dialog-accent: var(--moss-500, #4a7c59);
    --dialog-tint:   color-mix(in srgb, var(--moss-500, #4a7c59) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--moss-500, #4a7c59) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--moss-500, #4a7c59) 52%, transparent);
}
.dialog-color--lavender {
    /* Nudged cooler/bluer so it sits clearly apart from plum
       (which is warmer, more red-violet). */
    --dialog-accent: var(--lavender-500, #7a8fce);
    --dialog-tint:   color-mix(in srgb, var(--lavender-500, #7a8fce) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--lavender-500, #7a8fce) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--lavender-500, #7a8fce) 52%, transparent);
}
.dialog-color--rose {
    --dialog-accent: var(--rose-500, #c25768);
    --dialog-tint:   color-mix(in srgb, var(--rose-500, #c25768) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--rose-500, #c25768) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--rose-500, #c25768) 52%, transparent);
}
.dialog-color--amber {
    --dialog-accent: var(--amber-500, #c97532);
    --dialog-tint:   color-mix(in srgb, var(--amber-500, #c97532) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--amber-500, #c97532) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--amber-500, #c97532) 52%, transparent);
}
.dialog-color--teal {
    --dialog-accent: var(--teal-500, #3f8a82);
    --dialog-tint:   color-mix(in srgb, var(--teal-500, #3f8a82) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--teal-500, #3f8a82) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--teal-500, #3f8a82) 52%, transparent);
}
.dialog-color--ocean {
    --dialog-accent: var(--ocean-500, #3a6ba8);
    --dialog-tint:   color-mix(in srgb, var(--ocean-500, #3a6ba8) 22%, var(--bg, #fafaf7));
    --dialog-strong: color-mix(in srgb, var(--ocean-500, #3a6ba8) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--ocean-500, #3a6ba8) 52%, transparent);
}
.dialog-color--default {
    --dialog-accent: var(--accent);
    --dialog-tint:   var(--accent-soft);
    --dialog-strong: color-mix(in srgb, var(--accent) 38%, var(--bg, #fafaf7));
    --dialog-edge:   color-mix(in srgb, var(--accent) 50%, transparent);
}

@media (max-width: 640px) {
    .dialog-turn--left { margin-right: 1.25rem; }
    .dialog-turn--right { margin-left: 1.25rem; }
    .dialog-meta { max-width: 100%; }
}

/* Header — compact single row: [explorer ☰][site-title]   [search][🌓 toggle] */
header {
    margin-bottom: 2rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: nowrap;
    row-gap: 0.5rem;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1 1 auto;
}

header .site-title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.75rem);
    font-weight: 400;
    text-decoration: none;
    color: var(--fg-strong);
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    transition: color var(--t-fast) var(--ease);
}

/* Florette glyph next to the title. Sage accent so it reads
   as a small botanical mark, slightly smaller than the title
   text, with a hair of space between the title's last letter
   and the glyph. */
.site-title-glyph {
    color: var(--accent);
    font-size: 0.85em;
    margin-left: 0.35em;
    vertical-align: 0.05em;
    display: inline-block;
    transition: transform var(--t-med) var(--ease);
}

/* Glyph is now a sibling of the link, so target via the
   adjacent-sibling selector to keep the hover rotation. */
header .site-title:hover + .site-title-glyph {
    transform: rotate(60deg);
}

/* ≤480px — fold header into two rows: title above, tools
   (hamburger / search / theme) below.

   The breakpoint sits above modern phone widths in portrait:
   iPhone SE is 375pt, iPhone 15 is 393pt, iPhone 15 Pro Max
   is 430pt, common Android phones are 360-412pt. A 480px
   cutoff catches all of them without intruding on the small-
   tablet / large-phone landscape band (≥600pt). */
@media (max-width: 480px) {
    header {
        flex-wrap: wrap;
        gap: 0.5rem;
        row-gap: 0.5rem;
        justify-content: center;
    }
    .header-tools {
        order: 1;
        flex: 1 1 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }
    /* `position: fixed` so `left: 50%` resolves against the
       viewport, not the narrow search-container box. */
    .search-container:focus-within .us-search-input {
        position: fixed;
        right: auto;
        left: 50%;
        top: 0.75rem;
        transform: translateX(-50%);
        width: min(88vw, 22rem);
    }
    .search-container:focus-within .us-search-results {
        position: fixed;
        left: 50%;
        right: auto;
        top: calc(0.75rem + 2.6rem);
        transform: translateX(-50%);
        width: min(88vw, 22rem);
        max-height: 60vh;
    }
    .site-brand {
        order: 2;
        flex: 1 1 100%;
        justify-content: center;
        gap: 0;
    }
    .site-brand .explorer-toggle {
        display: none;
    }
    .header-tools .explorer-toggle-mobile {
        display: inline-flex;
    }
}
@media (min-width: 481px) {
    .header-tools .explorer-toggle-mobile {
        display: none;
    }
}

@media (max-width: 640px) {
    .search-container {
        flex: 0 0 auto;
        min-width: 0;
        width: 2.4rem;
    }
    /* Magnifier glyph overlay; click-through so the input receives focus. */
    .search-container:not(:focus-within)::before {
        content: "";
        position: absolute;
        inset: 0;
        margin: auto;
        width: 1.1rem;
        height: 1.1rem;
        background-color: var(--fg-muted);
        -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
        mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='16' y1='16' x2='21' y2='21'/></svg>");
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;
        pointer-events: none;
        z-index: 1;
    }
    /* Fill the full container box so the tap target matches
       the visible glyph (otherwise the input is a line-height
       tall strip and the glyph extends above/below it). */
    .search-container:not(:focus-within) .us-search-input {
        width: 2.4rem;
        height: 2.4rem;
        padding: 0;
        cursor: pointer;
        color: transparent;
        background: transparent;
        border-color: transparent;
        box-shadow: none;
    }
    /* Hover/focus accent on the glyph, mirroring .icon-btn. */
    .search-container:hover:not(:focus-within)::before {
        background-color: var(--accent);
    }
    .search-container:not(:focus-within) .us-search-input::placeholder {
        color: transparent;
    }
    /* Expanded floating input. */
    .search-container:focus-within .us-search-input {
        width: min(80vw, 22rem);
        position: absolute;
        right: 0;
        top: 0;
        padding: 0.45rem 0.85rem;
        cursor: text;
        z-index: 30;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    }
}

header .site-title:hover { color: var(--accent); }

.header-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    transition: color var(--t-fast) var(--ease),
                background-color var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease);
}

.icon-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

/* Baseline keyboard focus ring. `:where` keeps specificity at zero so
   any component-specific focus style still wins. */
:where(a, button, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--interact);
    outline-offset: 2px;
    border-radius: 2px;
}

.icon-btn:focus-visible {
    outline: 2px solid var(--interact);
    outline-offset: 2px;
}

.icon-btn svg {
    display: block;
    width: 1.1em;
    height: 1.1em;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Wander: hidden until wander.js has the content index to pick from. */
.wander[hidden] { display: none; }

/* Theme toggle: shows sun on dark, moon on light */
.theme-toggle .theme-toggle-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-toggle-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .theme-toggle-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .theme-toggle-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .theme-toggle-moon { display: none; }
}

/* Search */
.search-container {
    flex: 0 1 clamp(7rem, 22vw, 14rem);
    min-width: 6rem;
    position: relative;
}

/* #search wrapper would collapse to content width — force fill. */
.search-container #search {
    display: block;
    width: 100%;
}

.us-search-input {
    width: 100%;
    padding: 0.45rem 0.85rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--fg);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 999px;
    outline: none;
    transition: border-color var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease),
                width var(--t-med) var(--ease);
}

.us-search-input::placeholder {
    color: var(--fg-faint);
    font-style: italic;
}

.us-search-input:focus {
    border-color: var(--interact);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--interact) 22%, transparent);
}

.us-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 70vh;
    overflow-y: auto;
    /* z-index above article content; opaque so prose doesn't bleed through. */
    background-color: #fbf9f1;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(35, 30, 24, 0.18),
                0 2px 6px rgba(35, 30, 24, 0.10);
    z-index: 50;
}

:root[data-theme="dark"] .us-search-results {
    background-color: #1e231b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55),
                0 2px 6px rgba(0, 0, 0, 0.35);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .us-search-results {
        background-color: #1e231b;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55),
                    0 2px 6px rgba(0, 0, 0, 0.35);
    }
}

.us-search-hit {
    display: block;
    padding: 0.7rem 0.95rem;
    border-bottom: 1px solid var(--border-soft);
    color: var(--fg);
    text-decoration: none;
    transition: background-color var(--t-fast) var(--ease);
}

.us-search-hit:last-child { border-bottom: none; }

.us-search-hit:hover,
.us-search-hit--active {
    background: color-mix(in srgb, var(--link) 10%, var(--bg));
}

.us-search-title {
    font-weight: 600;
    color: var(--link);
    margin-bottom: 0.15rem;
}

.us-search-hit:focus-visible {
    outline: 2px solid var(--interact);
    outline-offset: -2px;
}

/* Best-matching heading within the page (from Pagefind sub-results). */
.us-search-section {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.us-search-desc,
.us-search-excerpt {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.us-search-results mark {
    background: color-mix(in srgb, var(--highlight) 70%, transparent);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.us-search-pending {
    padding: 0.5rem 0.95rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted);
    border-top: 1px solid var(--border-soft);
}

.us-search-empty {
    padding: 0.85rem;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

/* Main */
main { margin-bottom: 2rem; }

/* Type voice — Fondamento display, Lora body, DM Mono chrome. */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-body);
    color: var(--fg-strong);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: var(--leading-tight);
    font-weight: 600;
    letter-spacing: 0;
    font-feature-settings: "kern", "liga", "dlig", "calt";
}

article > h1:first-child,
h1.page-title {
    /* Hero h1: Fondamento, big, italic by default (the face is
       already calligraphic — don't add font-style: italic on
       top of it, it's a no-op). Tight line-height with extra
       padding-top so multi-line titles read as a single unit. */
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 6vw + 0.5rem, 4.5rem);
    line-height: 1;
    padding-top: 1rem;
    font-weight: 400;            /* Fondamento only ships 400 */
    letter-spacing: 0;
    margin-top: 0.4em;
    margin-bottom: 0.65em;
    color: var(--fg-strong);
    text-wrap: balance;
    font-feature-settings: "kern", "liga", "dlig", "calt";
}

h2 {
    font-size: var(--fs-h2);
    font-style: italic;
    font-weight: 500;
    margin-top: 2.25em;
    font-family: var(--font-body);
}

h3 {
    font-size: var(--fs-h3);
    font-style: italic;
    font-weight: 500;
    font-family: var(--font-body);
}

h4 {
    font-size: var(--fs-h4);
    font-weight: 600;
    font-family: var(--font-body);
}

h5, h6 {
    font-size: 1rem;
    font-weight: 500;
    font-style: italic;
    font-family: var(--font-body);
}

p { margin-bottom: 1em; }
p + p { text-indent: 0; }

article p {
    hyphens: auto;
    -webkit-hyphens: auto;
}

strong { color: var(--fg-strong); font-weight: 600; }
em { font-style: italic; }

mark {
    background: color-mix(in srgb, var(--highlight) 80%, transparent);
    color: inherit;
    padding: 0 0.15em;
    border-radius: 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Links — default (lavender, interaction) vs wikilinks (sage,
   structural); external links pick up the default plus an ↗ glyph. */
a {
    color: var(--link);
    text-decoration: none;
    background-image: linear-gradient(var(--link), var(--link));
    background-position: 0 100%;
    background-repeat: no-repeat;
    background-size: 100% 1px;
    padding-bottom: 0.06em;
    transition: color var(--t-fast) var(--ease),
                background-size var(--t-fast) var(--ease);
}

a:hover {
    color: var(--link-hover);
    background-size: 100% 2px;
}

a:visited { color: var(--link-visited); }

/* Wikilink underline uses a CSS mask so the squiggle picks up currentColor. */
a[data-wikilink="true"] {
    background: none;
    position: relative;
    text-decoration: none;
    color: var(--link-internal);
    padding-bottom: 0.18em;
    transition: color var(--t-fast) var(--ease);
}

a[data-wikilink="true"]:hover {
    color: var(--link-internal-hover);
}

a[data-wikilink="true"]:visited {
    color: var(--link-internal);
}

a[data-wikilink="true"]::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.02em;
    height: 0.32em;
    background: currentColor;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 6' preserveAspectRatio='none'><path d='M0 3 Q 7.5 0 15 3 T 30 3 T 45 3 T 60 3' stroke='black' stroke-width='1.2' fill='none' stroke-linecap='round'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 6' preserveAspectRatio='none'><path d='M0 3 Q 7.5 0 15 3 T 30 3 T 45 3 T 60 3' stroke='black' stroke-width='1.2' fill='none' stroke-linecap='round'/></svg>");
    -webkit-mask-repeat: repeat-x;
    mask-repeat: repeat-x;
    -webkit-mask-size: 0.85em 0.32em;
    mask-size: 0.85em 0.32em;
    opacity: 0.7;
    transition: opacity var(--t-fast) var(--ease);
    pointer-events: none;
}

a[data-wikilink="true"]:hover::after { opacity: 1; }

/* External links — adds the ↗ glyph. */
a[rel~="external"]::after,
article a[href^="http://"]:not([data-wikilink])::after,
article a[href^="https://"]:not([data-wikilink])::after {
    content: " ↗";
    font-size: 0.85em;
    color: var(--fg-faint);
    margin-left: 0.05em;
    display: inline-block;
    transition: transform var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
}

article a[href^="http://"]:not([data-wikilink]):hover::after,
article a[href^="https://"]:not([data-wikilink]):hover::after {
    transform: translate(1px, -1px);
    color: var(--interact);
}

a.dead-link {
    color: var(--dead-link);
    background: none;
    text-decoration: line-through;
    text-decoration-thickness: 1px;
    text-decoration-color: color-mix(in srgb, var(--dead-link) 60%, transparent);
}
span.dead-link {
    color: var(--dead-link);
    cursor: not-allowed;
    background: none;
    text-decoration: underline dotted color-mix(in srgb, var(--dead-link) 60%, transparent);
}

/* Code
   Inline `code` chips use our paper token (soft, in-prose).
   Block `<pre>` code intentionally inherits its background +
   foreground from `/syntax.css` (Solarized) — the Solarized
   palette is part of the visual statement for fenced blocks. */
code {
    font-family: var(--font-code);
    background: var(--code-bg);
    padding: 0.15em 0.3em;
    border-radius: 3px;
    font-size: 0.875em;
}

pre {
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1em;
    margin-top: 1em;
    font-size: 0.85em;
    line-height: 1.5;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
}

pre code {
    background: none;
    padding: 0;
    font-size: 1em;
}

/* Blockquote / Callout */
blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1em;
    margin-bottom: 1em;
    color: var(--muted);
}

/* GFM alerts (`> [!NOTE]`, `> [!TIP]`, …) — comrak emits
   `<div class="markdown-alert markdown-alert-{kind}">` with a
   `<p class="markdown-alert-title">Kind</p>` as the first
   child. Per-kind variants below set `--alert-color` and a
   unicode glyph that the title's ::before picks up. */
.markdown-alert {
    border-left: 4px solid var(--alert-color, var(--callout-border));
    background: color-mix(in srgb, var(--alert-color, var(--callout-border)) 9%, var(--bg, #fafaf7));
    padding: 0.75em 1em;
    margin: 1em 0;
    border-radius: 0 6px 6px 0;
}
.markdown-alert > :first-child { margin-top: 0; }
.markdown-alert > :last-child { margin-bottom: 0; }
.markdown-alert-title {
    margin: 0 0 0.4em 0;
    color: var(--alert-color, var(--callout-border));
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 0.45em;
}
.markdown-alert-title::before {
    content: var(--alert-icon, "•");
    font-size: 1.1em;
    line-height: 1;
    font-family: system-ui, sans-serif;
}
.markdown-alert-note {
    --alert-color: var(--ocean-500, #3a6ba8);
    --alert-icon: "ⓘ";
}
.markdown-alert-tip {
    --alert-color: var(--sage-500, #6f8a5a);
    --alert-icon: "✦";
}
.markdown-alert-important {
    --alert-color: var(--plum-500, #6b4a82);
    --alert-icon: "★";
}
.markdown-alert-warning {
    --alert-color: var(--amber-500, #c97532);
    --alert-icon: "⚠";
}
.markdown-alert-caution {
    --alert-color: var(--rose-500, #c25768);
    --alert-icon: "⊘";
}

/* Backwards compat: the old `.alert` class used by an earlier
   render path; kept so anything authoring raw HTML still works. */
.alert {
    border-left: 3px solid var(--callout-border);
    background: var(--callout-bg);
    padding: 0.75em 1em;
    margin-bottom: 1em;
    border-radius: 0 6px 6px 0;
}

/* Table */
table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

th, td {
    border: 1px solid var(--border);
    padding: 0.5em 0.75em;
    text-align: left;
    white-space: nowrap;
}

th { font-weight: 600; }

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

/* Page meta */
.page-meta {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
    color: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-small);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em 1.5em;
    font-feature-settings: "tnum"; /* tabular figures for dates */
}

/* The byline variant sits between the h1 and the body. No
   rule on top, lighter rule on the bottom; reads as an
   editorial dateline, not a footer. Margin-bottom matches the
   gap above the strip (set by .page-dateline's margin-bottom)
   so the byline reads as a single block. */
.page-meta--top {
    margin-top: -0.5em;
    margin-bottom: 0.5rem;
    padding-top: 0;
    padding-bottom: 0.5rem;
    border-top: none;
    border-bottom: 1px dotted var(--border-soft);
    font-size: 0.82rem;
    opacity: 0.85;
}

/* Word-count + reading-time items in the meta strip. Mirrors
   .page-dateline-item: emoji glyph on the left, value to its
   right, gap between items via the parent's flex layout. */
.page-meta-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
}

.page-meta-emoji {
    font-size: 0.95rem;
    line-height: 1;
    text-transform: none;
    letter-spacing: 0;
    font-feature-settings: normal;
}

/* Page dateline — created / updated above the meta strip. */
.page-dateline {
    margin: -0.25rem 0 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.75rem;
    color: var(--fg-muted);
    font-feature-settings: "tnum";
}

/* Both label and date share the same font family (DM Mono)
   so the line reads as one tight editorial unit. The label
   is small-caps and faint; the date is tabular and slightly
   heavier so it reads as the value. */
.page-dateline-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Growth stage (`status:` frontmatter). The ring fills a quarter per
   stage, so maturity reads at a glance without the label. */
.growth-stage {
    --stage: var(--status-seedling);
    --fill: 25%;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.1rem 0.6rem 0.1rem 0.4rem;
    border: 1px solid color-mix(in srgb, var(--stage) 45%, transparent);
    border-radius: 999px;
    color: var(--stage);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    cursor: help;
}
.growth-stage--budding   { --stage: var(--status-budding);   --fill: 50%; }
.growth-stage--growing   { --stage: var(--status-growing);   --fill: 75%; }
.growth-stage--evergreen { --stage: var(--status-evergreen); --fill: 100%; }

.growth-stage-ring {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: conic-gradient(var(--stage) var(--fill), transparent 0);
    box-shadow: inset 0 0 0 1.5px var(--stage);
}

.page-dateline-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--fg-faint);
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
}

/* Emoji glyph next to the label. Sized slightly larger than
   the small-caps letters so the symbol reads without dominating;
   text-transform: none so the emoji's case-related layout
   rules don't apply. */
.page-dateline-emoji {
    font-size: 0.95rem;
    line-height: 1;
    text-transform: none;
    letter-spacing: 0;
    font-feature-settings: normal;
}

.page-dateline time {
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}

/* When `modified` is unavailable (serve mode), show a quiet
   placeholder instead of leaving the slot blank — signals
   that the real value will appear after `understory build`. */
.page-dateline-deferred {
    color: var(--fg-faint);
    opacity: 0.85;
}

/* Tags */
.tags {
    display: flex;
    gap: 0.4em;
    flex-wrap: wrap;
    margin-top: 1.25em;
}

/* Tags-as-byline variant: sits within the editorial byline
   cluster below the dates and word count. Top margin matches
   the gap between dates and word count for a uniform rhythm. */
.tags--top {
    margin: 0.5rem 0 1.25rem;
}

.tag {
    background: var(--tag-bg);
    padding: 0.2em 0.65em;
    border-radius: 999px;
    font-size: 0.78rem;
    text-decoration: none;
    color: var(--tag-fg);
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: background-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
}

.tag:visited { color: var(--tag-fg); }
.tag:hover {
    background: var(--interact);
    color: var(--paper-50);
}
.tag::before {
    content: "#";
    opacity: 0.55;
    margin-right: 0.05em;
}

/* Landing page
   Custom layout used only on the root index page (opted in
   via `layout: index` in the page's frontmatter). The intro
   uses the standard prose styling; below it sit two feeds:
   recent posts and a featured-tag cloud. */
.landing-intro {
    /* Inherits prose styles. Margin below to separate from
       the feeds grid. */
    margin-bottom: 2.5rem;
}

.landing-feeds {
    display: grid;
    gap: 2rem 2.5rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dotted var(--border-soft);
}

@media (min-width: 720px) {
    .landing-feeds {
        grid-template-columns: 1.4fr 1fr;
    }
}

.landing-recent h2,
.landing-tags h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 500;
    margin: 0 0 0.85rem;
    color: var(--fg-strong);
    font-style: italic;
}

/* Two-column grid: titles right-aligned in the left column,
   dates left-aligned in the right column. The grid shares
   column tracks across rows, so every date starts at the
   same x-coordinate regardless of title length. The title
   column auto-fits to the widest title; the date column
   hugs its content. */
.landing-recent-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: max-content max-content;
    column-gap: 0.85rem;
    row-gap: 0.15rem;
    justify-content: start;
}

.landing-recent-row {
    display: contents;
}

.landing-recent-link {
    grid-column: 1;
    justify-self: end;     /* size to content, align to right edge of column */
    color: var(--link-internal);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
    padding: 0.3rem 0;
}

.landing-recent-link:hover {
    color: var(--link-internal-hover);
    border-bottom-color: var(--link-internal-hover);
}

.landing-recent-date {
    grid-column: 2;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--fg-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    align-self: baseline;
    padding: 0.3rem 0;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.55rem;
    align-items: baseline;
    line-height: 1.7;
}

.tag-cloud-item {
    /* Inline `style="font-size: <rem>rem"` from the template
       provides the per-tag scale (0.8–1.4 rem); other tag
       styling inherits from .tag. */
    transition: transform var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
}

.tag-cloud-item:hover {
    transform: translateY(-1px);
}

/* Backlinks — editorial section title with flourish and denser list. */
.backlinks {
    margin-top: 3rem;
    padding-top: 0;
    border-top: none;
    position: relative;
}

.backlinks::before {
    content: "❀";
    display: block;
    text-align: center;
    color: var(--accent);
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    opacity: 0.7;
}

.backlinks h2 {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 500;
    font-size: 1.4rem;
    color: var(--fg-strong);
    margin: 0 0 1rem;
}

.backlinks h2::after {
    content: "";
    display: block;
    width: 2.5rem;
    height: 1px;
    background: var(--rule);
    margin-top: 0.5rem;
}

.backlinks ul { list-style: none; padding: 0; }
.backlinks li {
    margin-bottom: 0.45rem;
    padding-left: 1.1em;
    position: relative;
    font-size: 1rem;
    line-height: 1.4;
}
.backlinks li::before {
    content: "↩";
    position: absolute;
    left: 0;
    color: var(--fg-faint);
    font-size: 0.9em;
}
.backlinks li a {
    color: var(--fg);
    background-image: linear-gradient(var(--fg-faint), var(--fg-faint));
}
.backlinks li a:hover {
    color: var(--interact);
    background-image: linear-gradient(var(--interact), var(--interact));
}

/* The sentence the linking note uses, with the link itself marked. */
.backlinks li:has(.backlink-context) { margin-bottom: 0.9rem; }
.backlink-context {
    margin: 0.2rem 0 0;
    color: var(--fg-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}
.backlink-context mark {
    background: color-mix(in srgb, var(--highlight) 70%, transparent);
    color: var(--fg);
    padding: 0 1px;
    border-radius: 2px;
}

/* Graph panel */
.graph-panel {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.graph-panel summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    color: var(--muted);
    font-family: var(--font-heading);
}

.graph-panel summary::marker { color: var(--muted); }

#graph-container {
    width: 100%;
    height: 250px;
    margin-top: 0.75em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--code-bg);
    overflow: hidden;
}

/* Footer */
footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

/* Misc */
del { color: var(--muted); }

.task-list { list-style: none; padding-left: 0; }
.task-list li { display: flex; align-items: baseline; gap: 0.5em; }

sup { font-size: 0.75em; }
.footnotes { margin-top: 2rem; font-size: 0.9em; color: var(--muted); }
.footnotes hr { border: none; border-top: 1px solid var(--border); margin-bottom: 1em; }

/* Table of contents — inline editorial sidebar with sage rule. */
.toc {
    margin: 1.75em 0;
    padding: 0.4em 0 0.4em 1.1em;
    border-left: 2px solid var(--rule);
    font-size: 0.95em;
    font-family: var(--font-body);
}

.toc summary {
    cursor: pointer;
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 500;
    font-size: 1.05rem;
    color: var(--fg-strong);
    list-style: none;
    margin-bottom: 0.4em;
    user-select: none;
}

.toc summary::-webkit-details-marker { display: none; }
.toc summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 0.5em;
    font-size: 0.7em;
    color: var(--fg-faint);
    transition: transform var(--t-fast) var(--ease);
}
.toc details[open] summary::before { transform: rotate(90deg); }

.toc ul {
    list-style: none;
    padding-left: 0;
    margin-top: 0.6em;
}

.toc li {
    margin-bottom: 0.25em;
    line-height: 1.4;
}

.toc a {
    color: var(--fg-muted);
    background: none;
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}
.toc a:hover { color: var(--accent); }

/* Math (pre-render) */
[data-math-style] {
    font-family: var(--font-code);
    font-size: 0.9em;
    opacity: 0.6;
}

[data-math-style="display"] {
    display: block;
    text-align: center;
    margin: 1em 0;
}

/* Transclusion */
.transclusion {
    border-left: 3px solid var(--accent);
    padding: 0.5em 1em;
    margin: 0.5em 0;
    background: var(--code-bg);
    border-radius: 0 6px 6px 0;
}

/* PDF embed
   Renders an Obsidian `![[deck.pdf]]` transclusion as a
   browser-native PDF viewer. The iframe sits in an aspect-
   ratio box so it stays usable on phones (4:3 deck-shape
   default); the fallback download link only matters when
   the browser's CSP or sandbox blocks the embed entirely.

   `.iframe-pdf` is also matched so user-authored raw HTML
   (`<iframe class="iframe-pdf" src="...">`) — typically
   used when the PDF lives on an external CDN and the
   transclusion syntax doesn't apply — gets the same
   article-width rendering instead of the browser-default
   300×150 inline iframe. */
.pdf-embed {
    margin: 1.5em 0;
}
.pdf-embed iframe,
.iframe-pdf {
    display: block;
    margin: 1.5em 0;
    width: 100%;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--border, #ccc);
    border-radius: 6px;
    background: var(--code-bg, #f6f6f6);
}
.pdf-embed-fallback {
    margin: 0.5em 0 0;
    font-size: 0.9em;
    text-align: center;
}

/* Responsive breakpoints
   Type sizes scale via the `clamp()` on the hero h1; these
   rules just add padding / table behaviour. */
@media (min-width: 640px) {
    body { padding: 1.5rem; }
    .page-wrapper { padding: 0 1rem; }
    #graph-container { height: 280px; }
    th, td { white-space: normal; }
    table { display: table; }
}

@media (min-width: 1024px) {
    body { padding: 2rem 1.5rem; }
    .page-wrapper { max-width: 48rem; }
    #graph-container { height: 300px; }
}

@media (min-width: 1280px) {
    .page-wrapper { max-width: 50rem; }
}

/* Explorer sidebar */
.explorer-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 16rem;
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem;
    z-index: 300;
    transform: translateX(-100%);
    /* Closed panel is `inert` in the markup; `visibility` backs that up
       so its links never sit in the tab order off-screen. Visibility
       flips only after the slide-out finishes. */
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
}

.explorer-panel.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.2s ease, visibility 0s;
}

.explorer-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.explorer-panel-header h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.explorer-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1rem;
}

.explorer-close:hover { color: var(--fg); }

.explorer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 299;
    display: none;
}

.explorer-overlay.visible { display: block; }

.explorer-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.explorer-list .explorer-list {
    padding-left: 0.75em;
}

.explorer-folder {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0.1em 0;
}

.explorer-folder::marker { color: var(--muted); font-size: 0.7em; }

.explorer-page {
    font-size: 0.85rem;
    padding: 0.1em 0;
}

.explorer-page a {
    color: var(--fg);
    text-decoration: none;
}

.explorer-page a:hover { text-decoration: underline; }

.explorer-page a.explorer-current {
    color: var(--link);
    font-weight: 600;
}

@media (min-width: 1280px) {
    .explorer-panel {
        width: 18rem;
    }
}

/* Link popover */
.link-popover {
    position: absolute;
    z-index: 200;
    max-width: 20rem;
    padding: 0.6em 0.8em;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    font-size: 0.85rem;
    line-height: 1.5;
    pointer-events: auto;
}

@media (prefers-color-scheme: dark) {
    .link-popover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }
}

.popover-title {
    font-weight: 600;
    margin-bottom: 0.25em;
}

.popover-desc {
    color: var(--muted);
    margin-bottom: 0.35em;
}

.popover-tags {
    display: flex;
    gap: 0.3em;
    flex-wrap: wrap;
}

.popover-tag {
    font-size: 0.75rem;
    color: var(--tag-fg);
    background: var(--tag-bg);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

/* Mermaid diagrams */
.mermaid {
    text-align: center;
    margin: 1em 0;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}

/* Pre-render: hide mermaid code blocks until JS replaces them */
pre > code.language-mermaid {
    font-size: 0.8em;
    color: var(--muted);
}

/* Section flourish (optional, used after long pages) */
.section-flourish {
    display: block;
    text-align: center;
    color: var(--accent);
    font-size: 1.2rem;
    margin: 2.5rem 0;
    opacity: 0.55;
    letter-spacing: 0.4em;
}

/* Mossy corner accents
   Fixed to the viewport so they stay anchored as you scroll.
   Hidden below ~900px so they don't compete with the reading
   column. Sage-tinted via currentColor; the parent sets the
   color and an opacity ramp so they recede behind text but
   stay visible as a "this is a garden" cue. */
.moss-corner {
    position: fixed;
    bottom: -1.5rem;
    color: var(--sage-600);
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
    display: none;
    transition: opacity var(--t-med) var(--ease);
    filter: saturate(1.05);
}

/* The watercolor splashes hug each corner — small, slightly
   bleeding off-edge so they read as splotches at the margin
   rather than full background ornaments. */
.moss-corner-left {
    left: -1.5rem;
    width: 11rem;
    height: auto;
}

.moss-corner-right {
    right: -1.5rem;
    width: 9rem;
    height: auto;
}

/* Show only on screens roomy enough not to crowd the column. */
@media (min-width: 900px) {
    .moss-corner { display: block; }
}
@media (min-width: 1280px) {
    .moss-corner-left { width: 13rem; }
    .moss-corner-right { width: 11rem; }
}
@media (min-width: 1600px) {
    .moss-corner-left { width: 16rem; }
    .moss-corner-right { width: 13rem; }
}

/* On dark mode the splashes shift to a brighter sage so they
   remain visible against the deep-moss ground. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .moss-corner {
        color: var(--sage-500);
        opacity: 0.5;
    }
}
:root[data-theme="dark"] .moss-corner {
    color: var(--sage-500);
    opacity: 0.5;
}

/* Fade further when the reader scrolls so they don't compete
   with long-form prose. */
body.is-scrolled .moss-corner { opacity: 0.3; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body.is-scrolled .moss-corner {
        opacity: 0.28;
    }
}
:root[data-theme="dark"] body.is-scrolled .moss-corner { opacity: 0.28; }

@media (prefers-reduced-motion: reduce) {
    .moss-corner { transition: none; }
}

/* Floating pollen
   Soft particles that drift upward with a slow horizontal
   sway. Each <i.pollen> reads four inline custom properties
   --x, --size, --dur, --delay, --drift to vary individually.
   Disabled under reduced-motion. */
.pollen-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    display: none;
    /* Light-mode opacity multiplier on top of the keyframe's
       animated opacity. Dark mode overrides below to restore
       full visibility against the deep moss ground. */
    --pollen-opacity: 0.22;
    opacity: var(--pollen-opacity);
}

@media (prefers-reduced-motion: no-preference) {
    .pollen-field { display: block; }
}

/* Tablet: roughly half the particles. Hide every other one. */
@media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
    .pollen-field .pollen:nth-child(2n) { display: none; }
}

/* Phone: keep only ~3 of 12. Hide everything except every 4th. */
@media (max-width: 639px) and (prefers-reduced-motion: no-preference) {
    .pollen-field .pollen { display: none; }
    .pollen-field .pollen:nth-child(4n+1) { display: block; }
}

/* Dark mode: full opacity — the particles already use a
   palette tuned for the deep moss ground and benefit from
   reading at intended saturation. */
:root[data-theme="dark"] .pollen-field {
    --pollen-opacity: 1;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pollen-field {
        --pollen-opacity: 1;
    }
}

.pollen {
    position: absolute;
    left: var(--x);
    bottom: -2vh;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: radial-gradient(
        circle at 35% 35%,
        color-mix(in srgb, var(--sage-600) 90%, white 10%) 0%,
        color-mix(in srgb, var(--sage-700) 80%, transparent) 60%,
        transparent 100%
    );
    opacity: 0;
    filter: blur(0.5px);
    animation: pollen-drift var(--dur, 45s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
    will-change: transform, opacity;
}

.pollen--lavender {
    background: radial-gradient(
        circle at 35% 35%,
        color-mix(in srgb, var(--lavender-500) 90%, white 10%) 0%,
        color-mix(in srgb, var(--lavender-600) 80%, transparent) 60%,
        transparent 100%
    );
}

/* Pollen path is an S-curve: it leans toward `--drift1` at
   ~33% of travel, swings back through `--drift2` at ~66%,
   then settles near origin at the top. ease-in-out timing
   gives the sway a breathing quality rather than mechanical
   ticking. */
@keyframes pollen-drift {
    0% {
        transform: translate3d(0, 0, 0) scale(0.85);
        opacity: 0;
    }
    8% {
        opacity: 0.55;
    }
    33% {
        transform: translate3d(var(--drift1, 60px), -36vh, 0) scale(1);
        opacity: 0.7;
    }
    66% {
        transform: translate3d(var(--drift2, -60px), -72vh, 0) scale(1);
        opacity: 0.6;
    }
    92% {
        opacity: 0.4;
    }
    100% {
        transform: translate3d(0, -110vh, 0) scale(0.8);
        opacity: 0;
    }
}

/* In dark mode lift the pollen slightly so it's still visible
   against the deep moss ground without taking over. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pollen {
        background: radial-gradient(
            circle at 35% 35%,
            color-mix(in srgb, var(--sage-500) 95%, white 5%) 0%,
            color-mix(in srgb, var(--sage-600) 75%, transparent) 60%,
            transparent 100%
        );
        filter: blur(0.6px);
    }
    :root:not([data-theme="light"]) .pollen--lavender {
        background: radial-gradient(
            circle at 35% 35%,
            color-mix(in srgb, var(--lavender-600) 95%, white 5%) 0%,
            color-mix(in srgb, var(--lavender-500) 75%, transparent) 60%,
            transparent 100%
        );
    }
}
:root[data-theme="dark"] .pollen {
    background: radial-gradient(
        circle at 35% 35%,
        color-mix(in srgb, var(--sage-500) 95%, white 5%) 0%,
        color-mix(in srgb, var(--sage-600) 75%, transparent) 60%,
        transparent 100%
    );
    filter: blur(0.6px);
}
:root[data-theme="dark"] .pollen--lavender {
    background: radial-gradient(
        circle at 35% 35%,
        color-mix(in srgb, var(--lavender-600) 95%, white 5%) 0%,
        color-mix(in srgb, var(--lavender-500) 75%, transparent) 60%,
        transparent 100%
    );
}

/* When the reader scrolls into long-form territory, fade the
   pollen further so it doesn't compete with prose. */
.pollen-field { transition: opacity var(--t-med) var(--ease); }
body.is-scrolled .pollen-field { opacity: calc(var(--pollen-opacity) * 0.5); }

/* Entrance animation for hero h1 + first paragraph */
@keyframes us-fade-up {
    from {
        opacity: 0;
        transform: translateY(0.4rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

article > h1:first-child {
    animation: us-fade-up 380ms var(--ease) both;
}

article > h1:first-child + p {
    animation: us-fade-up 380ms var(--ease) 60ms both;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* View transitions: pages cross-fade on same-origin navigation.
   Browsers without support navigate as before. The header keeps its
   own layer so it holds still; the old pollen is dropped so drifting
   particles don't ghost through the fade. */
@view-transition { navigation: auto; }

.page-wrapper > header { view-transition-name: site-header; }
.pollen-field { view-transition-name: pollen; }

::view-transition-old(pollen) { display: none; }
::view-transition-new(pollen) { animation: none; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: var(--t-med); }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}

/* 404 page. */
.not-found {
    text-align: center;
    margin: 3rem auto 4rem;
    max-width: 36rem;
}

.not-found-code {
    font-family: var(--font-heading);
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 700;
    line-height: 1;
    color: var(--accent, var(--link));
    opacity: 0.85;
    margin-bottom: 0.5rem;
    letter-spacing: -0.04em;
}

.not-found h1 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1.6rem;
}

.not-found-lede {
    color: var(--muted);
    margin-bottom: 2.5rem;
}

.not-found-search {
    margin: 0 auto 2.5rem;
    max-width: 30rem;
    text-align: left;
}

.not-found-search > p {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.not-found-search [data-search-root] {
    /* Override the header's compact width so the inline search is roomier. */
    min-width: 0;
}

.not-found-search .us-search-results {
    /* Inline (not floating) results on the 404 page. */
    position: static;
    box-shadow: none;
    margin-top: 0.5rem;
}

.not-found-links {
    text-align: left;
    max-width: 30rem;
    margin: 0 auto;
}

.not-found-links > p {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.not-found-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.not-found-links li {
    padding: 0.4rem 0;
    border-top: 1px solid var(--border);
}

.not-found-links li:last-child {
    border-bottom: 1px solid var(--border);
}
