/* Self-hosted variable fonts (Fontsource files), registered under the exact
   family names global.css uses. Latin + Latin Extended only (ƒ is U+0192).
   Fraunces ships with all axes so global.css can pin SOFT/WONK to 0. */

/* Fraunces: opsz, wght, SOFT, WONK */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/_astro/fraunces-latin-full-normal.CFFu7zhK.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/_astro/fraunces-latin-ext-full-normal.YHFkNujK.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-display: swap;
  font-weight: 100 900;
  src: url("/_astro/fraunces-latin-full-italic.D2JnYqd-.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-display: swap;
  font-weight: 100 900;
  src: url("/_astro/fraunces-latin-ext-full-italic.B8-t4Nou.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Inter: opsz, wght */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/_astro/inter-latin-opsz-normal.BwkfbSeq.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/_astro/inter-latin-ext-opsz-normal.DpK-iCPk.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* JetBrains Mono: wght */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("/_astro/jetbrains-mono-latin-wght-normal.B9CIFXIH.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("/_astro/jetbrains-mono-latin-ext-wght-normal.DBQx-q_a.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* ==========================================================================
   Rich Hole — design system
   Vanilla CSS, cascade layers, native nesting, logical properties.
   Ports 1:1 to an Astro global stylesheet (src/styles/global.css).
   Textures are served from public/textures/.
   ========================================================================== */

@layer reset, tokens, base, layout, components, utilities;

/* --------------------------------------------------------------------------
   RESET
   -------------------------------------------------------------------------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: none; text-size-adjust: none; }
  body { min-block-size: 100svh; }
  img, picture, svg, video { display: block; max-inline-size: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  p, h1, h2, h3, h4, li, figcaption { overflow-wrap: break-word; }
  h1, h2, h3, h4 { text-wrap: balance; }
  p { text-wrap: pretty; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  [hidden] { display: none !important; }
}

/* --------------------------------------------------------------------------
   TOKENS
   -------------------------------------------------------------------------- */
@layer tokens {
  :root {
    /* Palette — oklch, all values clamped inside sRGB.
       Slate ink (h 211, anchored on 800 = oklch(38.2% 0.02 211)) · terracotta (h 38) · cool paper-grey neutral (h 211, near-zero chroma). */
    --slate-50:  oklch(97.5% 0.004 211);
    --slate-100: oklch(94%   0.007 211);
    --slate-200: oklch(88.5% 0.010 211);
    --slate-300: oklch(80%   0.013 211);
    --slate-400: oklch(70%   0.016 211);
    --slate-500: oklch(60%   0.019 211);
    --slate-600: oklch(52%   0.020 211);
    --slate-700: oklch(45%   0.020 211);
    --slate-800: oklch(38.2% 0.020 211);
    --slate-900: oklch(30%   0.018 211);
    --slate-950: oklch(22%   0.014 211);

    --terra-50:  oklch(97.5% 0.012 38);
    --terra-100: oklch(94%   0.028 38);
    --terra-200: oklch(88.5% 0.055 38);
    --terra-300: oklch(80%   0.090 38);
    --terra-400: oklch(70%   0.130 38);
    --terra-500: oklch(60%   0.155 38);
    --terra-600: oklch(51%   0.150 38);
    --terra-700: oklch(43%   0.130 38);
    --terra-800: oklch(36%   0.105 38);
    --terra-900: oklch(29%   0.080 38);
    --terra-950: oklch(22%   0.055 38);

    --stone-50:  oklch(97.5% 0.003 211);
    --stone-100: oklch(94%   0.004 211);
    --stone-200: oklch(89%   0.005 211);
    --stone-300: oklch(81%   0.006 211);
    --stone-400: oklch(71%   0.006 211);
    --stone-500: oklch(60%   0.006 211);
    --stone-600: oklch(47%   0.006 211);
    --stone-700: oklch(41%   0.006 211);
    --stone-800: oklch(35%   0.006 211);
    --stone-900: oklch(28%   0.005 211);
    --stone-950: oklch(21%   0.004 211);

    /* Semantic roles (contrast ratios measured, WCAG 2.x) */
    --color-canvas:        var(--stone-50);
    --color-surface:       var(--stone-100);
    --color-text:          var(--slate-900);   /* 12.6:1 on canvas · 9.7:1 on darkest paper fleck */
    --color-text-muted:    var(--stone-600);   /*  6.4:1 on canvas · 4.9:1 on darkest fleck */
    --color-heading:       var(--slate-800);   /*  9.2:1 — the brand ink */
    --color-accent:        var(--terra-700);   /*  8.0:1 on canvas · 6.2:1 worst — used for small text */
    --color-accent-mark:   var(--terra-600);   /* non-text marks: list markers, focus, progress (≥3:1) */
    --color-accent-strong: var(--terra-800);
    --color-link:          var(--slate-800);   /*  9.2:1 on canvas */
    --color-border:        var(--stone-300);
    --color-border-strong: var(--stone-500);
    --color-focus:         var(--color-accent-mark);

    --color-code-bg:       var(--slate-950);
    --color-code-text:     var(--stone-100);
    --color-code-comment:  var(--stone-400);   /*  6.44:1 on code-bg */
    --color-code-keyword:  var(--terra-300);   /*  8.94:1 */
    --color-code-string:   var(--slate-300);   /*  9.28:1 */
    --color-code-var:      var(--terra-200);   /* 11.98:1 */

    /* Spacing — strict 8pt grid */
    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2rem;
    --space-6: 3rem;
    --space-8: 4rem;
    --space-12: 6rem;

    /* Type — Perfect Fourth (1.333) from 16px */
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Fraunces", "Roslindale", ui-serif, Georgia, serif;
    --font-display-axes: "SOFT" 50, "WONK" 0;   /* upright, no wonky alternates */
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

    --step--1: 0.75rem;     /* 12px  */
    --step-0:  1rem;        /* 16px  */
    --step-1:  1.333rem;    /* 21.3px */
    --step-2:  1.777rem;    /* 28.4px */
    --step-3:  2.369rem;    /* 37.9px */
    --step-4:  3.157rem;    /* 50.5px */
    --step-5:  4.209rem;    /* 67.3px */

    /* Fluid heading sizes: each interpolates between two scale steps */
    --size-display: clamp(var(--step-3), 1.6rem + 3.4vw, var(--step-5));
    --size-h1:      clamp(var(--step-3), 1.9rem + 1.8vw, var(--step-4));
    --size-h2:      clamp(var(--step-2), 1.5rem + 0.9vw, var(--step-3));
    --size-h3:      clamp(var(--step-1), 1.2rem + 0.5vw, var(--step-2));
    --size-body:    clamp(var(--step-0), 0.96rem + 0.2vw, 1.0625rem);

    --leading-body: 1.6;
    --leading-heading: 1.2;
    --measure: 65ch;

    /* Shape & motion */
    --radius-0: 0;
    --radius-1: 2px;
    --radius-2: 4px;
    --radius-image: 0.5rem;   /* 8px — photographs only */
    --border-hairline: 1px solid var(--color-border);
    --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
    --duration-fast: 120ms;
    --duration-base: 220ms;

    /* Texture */
    --grain-url: url("/textures/noise.svg");
    --paper-url: url("/textures/paper.png");   /* 512px seamless cold-press tile, multiplied over --color-canvas */

    color-scheme: light;
  }
}

/* --------------------------------------------------------------------------
   BASE
   -------------------------------------------------------------------------- */
@layer base {
  html { scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    font-family: var(--font-sans);
    font-size: var(--size-body);
    line-height: var(--leading-body);
    color: var(--color-text);
    background-color: var(--color-canvas);
    background-image: var(--paper-url);       /* rough paper over the whole page */
    background-size: 512px 512px;
    background-blend-mode: multiply;
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    font-optical-sizing: auto;
    font-variation-settings: var(--font-display-axes);
    line-height: var(--leading-heading);
    letter-spacing: -0.01em;
    color: var(--color-heading);
  }
  h1 { font-size: var(--size-h1); letter-spacing: -0.015em; }
  h2 { font-size: var(--size-h2); }
  h3 { font-size: var(--size-h3); }
  h4 { font-size: var(--step-1); }

  a {
    color: var(--color-link);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: color var(--duration-fast) var(--ease-out);
    &:hover { color: var(--color-accent-strong); }
  }

  :focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 3px;
    border-radius: var(--radius-1);
  }

  code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.875em; }
  :not(pre) > code {
    padding-inline: 0.3em;
    padding-block: 0.1em;
    background: var(--slate-100);
    color: var(--slate-800);
    border: var(--border-hairline);
    border-color: var(--slate-200);
    border-radius: var(--radius-1);
    font-size: 0.85em;
  }

  ::selection { background: var(--terra-200); color: var(--slate-950); }

  body { overflow-x: clip; }
}

/* --------------------------------------------------------------------------
   LAYOUT — Every Layout primitives + full-bleed content grid
   -------------------------------------------------------------------------- */
@layer layout {
  /* Stack: vertical flow with one consistent gap */
  .stack {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: var(--stack-space, var(--space-3));
  }

  /* Cluster: wrapping inline group */
  .cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: var(--cluster-align, center);
    justify-content: var(--cluster-justify, flex-start);
    gap: var(--cluster-space, var(--space-2));
  }

  /* Sidebar: sidebar holds its width, content takes the rest, wraps when narrow */
  .with-sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sidebar-gap, var(--space-6));
    align-items: var(--sidebar-align, flex-start);
    & > .sidebar { flex-basis: var(--sidebar-width, 18rem); flex-grow: 1; }
    & > .not-sidebar { flex-basis: 0; flex-grow: 999; min-inline-size: var(--sidebar-threshold, 55%); }
  }

  /* Switcher: row → column below a threshold, no media query */
  .switcher {
    display: flex;
    flex-wrap: wrap;
    gap: var(--switcher-gap, var(--space-4));
    & > * {
      flex-grow: 1;
      flex-basis: calc((var(--switcher-threshold, 40rem) - 100%) * 999);
    }
  }

  /* Grid: auto-fitting columns with a minimum cell */
  .grid {
    display: grid;
    gap: var(--grid-gap, var(--space-4));
    grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min, 18rem), 100%), 1fr));
  }

  /* Center: horizontally centred wrapper with gutters */
  .center {
    box-sizing: content-box;
    max-inline-size: var(--center-max, 76rem);
    margin-inline: auto;
    padding-inline: var(--gutter, clamp(var(--space-2), 4vw, var(--space-6)));
  }

  /* Full-bleed content grid (Kevin Powell pattern) */
  .content-grid {
    --padding-inline: clamp(var(--space-2), 4vw, var(--space-6));
    --content-max-width: var(--measure);
    --breakout-max-width: 86ch;
    --breakout-size: calc((var(--breakout-max-width) - var(--content-max-width)) / 2);

    display: grid;
    grid-template-columns:
      [full-start] minmax(var(--padding-inline), 1fr)
      [breakout-start] minmax(0, var(--breakout-size))
      [content-start] min(100% - (var(--padding-inline) * 2), var(--content-max-width))
      [content-end] minmax(0, var(--breakout-size))
      [breakout-end] minmax(var(--padding-inline), 1fr)
      [full-end];

    & > * { grid-column: content; }
    & > .breakout { grid-column: breakout; }
    & > .full-bleed { grid-column: full; }
  }
}

/* --------------------------------------------------------------------------
   COMPONENTS
   -------------------------------------------------------------------------- */
@layer components {


  /* Composition modifiers (set primitive custom properties by class) */
  .site-header__inner { --cluster-justify: space-between; }
  .intro__grid { --sidebar-width: 18rem; --sidebar-gap: clamp(var(--space-4), 5vw, var(--space-8)); --sidebar-align: flex-start; --sidebar-threshold: 45%; }
  .feature__grid { --sidebar-width: 24rem; --sidebar-gap: var(--space-6); --sidebar-align: center; --sidebar-threshold: 50%; }
  .photo-grid {
    --grid-gap: var(--space-4) var(--space-3);
    @media (min-width: 40rem) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  .stack-tight { --stack-space: var(--space-1); }
  .stack-loose { --stack-space: var(--space-4); }
  .cluster-tight { --cluster-space: var(--space-1); }
  .page-head { padding-block: clamp(var(--space-4), 6vw, var(--space-8)) var(--space-4); }
  .page-head h1 { font-size: var(--size-display); letter-spacing: -0.02em; }
  .page-head p:not(.eyebrow) { max-inline-size: 52ch; font-size: var(--step-1); line-height: 1.5; color: var(--slate-800); }
  .ratio-portrait { --ratio: 4 / 5; }
  .ratio-square { --ratio: 1 / 1; }
  .ratio-wide { --ratio: 16 / 9; }
  .ratio-pano { --ratio: 21 / 9; }
  .photo-link {
    display: block;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius-image);
    &:hover { color: inherit; }
    &:hover img { scale: 1.02; }
  }

  /* Skip link */
  .skip-link {
    position: absolute;
    inset-inline-start: var(--space-2);
    inset-block-start: var(--space-2);
    z-index: 200;
    padding-block: var(--space-1);
    padding-inline: var(--space-2);
    background: var(--slate-950);
    color: var(--stone-50);
    border-radius: var(--radius-1);
    translate: 0 -200%;
    &:focus-visible { translate: 0 0; color: var(--stone-50); }
  }

  /* Icon (Lucide, inline SVG) */
  .icon {
    inline-size: 1.125em;
    block-size: 1.125em;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 1.75;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Site header */
  .site-header {
    border-block-end: var(--border-hairline);
    & .center { padding-block: var(--space-3); }
  }
  .wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-1);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--step-2);
    font-variation-settings: var(--font-display-axes);
    letter-spacing: -0.02em;
    color: var(--color-heading);
    text-decoration: none;
    & span {
      font-family: var(--font-mono);
      font-size: var(--step--1);
      font-weight: 400;
      letter-spacing: 0;
      color: var(--color-text-muted);
    }
  }
  .site-nav {
    --cluster-space: var(--space-1);
    & a {
      position: relative;
      display: inline-flex;
      align-items: center;
      min-block-size: 2.75rem;          /* 44px target */
      padding-inline: var(--space-1);
      font-size: 0.9375rem;
      font-weight: 500;
      color: var(--color-text);
      text-decoration: none;
      /* the line: draws in from the left, leaves to the right */
      &::after {
        content: "";
        position: absolute;
        inset-inline: var(--space-1);
        inset-block-end: 0.625rem;
        block-size: 1px;
        background: currentColor;
        scale: 0 1;
        transform-origin: right center;
        transition: scale var(--duration-base) var(--ease-out);
      }
      &:hover { color: var(--color-heading); }
      &:hover::after,
      &:focus-visible::after {
        scale: 1 1;
        transform-origin: left center;
      }
      &[aria-current="page"] {
        color: var(--color-heading);
        &::after {
          scale: 1 1;
          block-size: 2px;
          background: var(--color-accent-mark);
        }
      }
    }
  }

  /* Eyebrow / meta line */
  .eyebrow {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-accent);
  }
  .meta {
    --cluster-space: var(--space-1) var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--color-text-muted);
    & > * { display: inline-flex; align-items: center; gap: 0.375rem; }
  }

  /* Intro / bio */
  .intro {
    padding-block: clamp(var(--space-6), 8vw, var(--space-12)) clamp(var(--space-4), 5vw, var(--space-8));
    & h1 {
      font-size: var(--size-display);
      letter-spacing: -0.02em;
      max-inline-size: 18ch;
    }
    & .lede {
      font-size: var(--step-1);
      line-height: 1.5;
      color: var(--slate-800);
      max-inline-size: 40ch;
    }
  }

  /* Section heading row */
  .section-head {
    --cluster-justify: space-between;
    --cluster-align: baseline;
    padding-block-end: var(--space-2);
    border-block-end: var(--border-hairline);
    & h2 { font-size: var(--step-2); }
  }

  /* Text link with arrow */
  .arrow-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-block-size: 2.75rem;
    font-weight: 500;
    font-size: 0.9375rem;
    text-decoration: none;
    color: var(--color-link);
    & .icon { transition: translate var(--duration-base) var(--ease-out); }
    &:hover .icon { translate: 0.25rem 0; }
  }

  /* Post list (editorial index) */
  .post-list { padding: 0; list-style: none; }
  .post-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
    padding-block: var(--space-4);
    border-block-end: var(--border-hairline);
    @media (min-width: 48rem) {
      grid-template-columns: 9rem minmax(0, 1fr) auto;
      gap: var(--space-4);
      align-items: baseline;
    }
    & h3 { font-size: var(--size-h3); }
    & h3 a {
      color: var(--color-heading);
      text-decoration: none;
      &:hover { text-decoration: underline; text-decoration-color: var(--color-accent); }
    }
    & p { color: var(--color-text-muted); max-inline-size: 60ch; }
    & .tag { align-self: flex-start; }   /* the tag sits in a flex .stack, not the grid */
  }

  .tag {
    display: inline-flex;
    align-items: center;
    padding-inline: var(--space-1);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    line-height: 1.6;
    color: var(--slate-700);
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-1);
    white-space: nowrap;
  }
  /* Dev-only marker on draft posts (lib/posts.ts); never in a production build */
  .tag--draft {
    color: var(--color-accent);
    background: transparent;
    border-color: currentColor;
    border-style: dashed;
  }

  /* Featured essay */
  .feature {
    padding-block: var(--space-6);
    border-block-end: var(--border-hairline);
    & h3 { font-size: var(--size-h2); letter-spacing: -0.015em; }
    & h3 a { color: var(--color-heading); text-decoration: none; &:hover { color: var(--color-accent-strong); } }
    & p { color: var(--slate-800); font-size: var(--step-1); line-height: 1.5; max-inline-size: 42ch; }
  }

  /* Photo frame — the shared figure for photography */
  .photo-frame__media {
    position: relative;
    overflow: hidden;
    background-color: var(--stone-200);   /* tonal fallback while loading */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-image);
    aspect-ratio: var(--ratio, 3 / 2);
    &::after {                             /* grain on the print */
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      background-image: var(--grain-url);
      background-size: 200px;
      opacity: 0.06;
      mix-blend-mode: overlay;
    }
    & img {
      inline-size: 100%;
      block-size: 100%;
      object-fit: cover;
      transition: scale 600ms var(--ease-out), filter 600ms var(--ease-out);
    }
  }

  .photo-frame {
    display: grid;
    gap: var(--space-1);
    & figcaption {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: var(--space-1) var(--space-2);
      align-items: baseline;
    }
    & .photo-frame__title { font-size: 0.9375rem; font-weight: 500; color: var(--color-heading); }
  }

  .exif {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-2);
    padding: 0;
    list-style: none;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    & li { display: inline-flex; align-items: center; gap: 0.375rem; }
    & li[hidden] { display: none; }   /* lightbox hides blank settings (film scans) */
  }

  /* Clickable photo card (gallery) */
  .photo-card {
    display: block;
    inline-size: 100%;
    text-align: start;
    border-radius: var(--radius-image);
    &:hover img { scale: 1.02; }
    &:focus-visible { outline-offset: 4px; }
  }

  /* Gallery grid — square-ish cells, a few spanning */
  /* Gallery — justified rows. Each item sets its own flex-grow / flex-basis from its crop
     ratio (inline style from data), so every photo in a row shares one height.
     Featured items take a full row at 21:9. */
  .gallery {
    --row-height: 15rem;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4) var(--space-3);
    padding: 0;
    list-style: none;
    & > li { min-inline-size: 0; }
    & > li.is-featured { flex-basis: 100%; }
  }

  .filters {
    --cluster-space: var(--space-1);
    & button {
      min-block-size: 2.75rem;
      padding-inline: var(--space-2);
      font-size: 0.875rem;
      font-weight: 500;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-2);
      background: var(--color-canvas);
      color: var(--color-text);
      transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
      &:hover { border-color: var(--color-border-strong); }
      &[aria-pressed="true"] {
        background: var(--slate-900);
        border-color: var(--slate-900);
        color: var(--stone-50);
      }
    }
  }

  /* Article */
  .article-header {
    padding-block: clamp(var(--space-4), 6vw, var(--space-8)) clamp(var(--space-4), 4vw, var(--space-6));
    & h1 { font-size: var(--size-display); letter-spacing: -0.02em; }
    & .standfirst { font-size: var(--step-1); line-height: 1.5; color: var(--slate-800); }
  }

  .prose {
    & h2 { --flow-space: var(--space-6); }
    & h3 { --flow-space: var(--space-4); }
    & h2 + *, & h3 + * { --flow-space: var(--space-2); }
    /* Prose lists only: classed lists such as .exif keep their own layout
       (these rules indented figure EXIF and dropped every item after the first). */
    & :is(ul, ol):not([class]) { padding-inline-start: 1.25em; }
    & :is(ul, ol):not([class]) > li + li { margin-block-start: var(--space-1); }
    & :is(ul, ol):not([class]) > li::marker { color: var(--color-accent-mark); }
    & figure, & .callout, & .code-block { --flow-space: var(--space-4); }
    & figure + *, & .callout + *, & .code-block + * { --flow-space: var(--space-4); }
    & blockquote {
      font-family: var(--font-display);
      font-style: italic;
      font-variation-settings: var(--font-display-axes);
      padding-block: var(--space-3);
      border-block: var(--border-hairline);
      font-size: var(--step-1);
      line-height: 1.45;
      color: var(--slate-800);
      & p::before { content: "\201C"; }
      & p::after  { content: "\201D"; }
    }
  }

  .figure {
    display: grid;
    gap: var(--space-1);
    & figcaption {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: var(--space-1) var(--space-2);
      font-size: 0.875rem;
      color: var(--color-text-muted);
    }
  }
  .full-bleed.figure figcaption { padding-inline: clamp(var(--space-2), 4vw, var(--space-6)); }
  .full-bleed .photo-frame__media { border-inline: 0; border-radius: 0; }

  /* Code block */
  .code-block {
    /* Shiki's css-variables theme → code palette roles (HANDOFF §4, Code blocks) */
    --astro-code-foreground:              var(--color-code-text);
    --astro-code-background:              var(--color-code-bg);
    --astro-code-token-comment:           var(--color-code-comment);
    --astro-code-token-keyword:           var(--color-code-keyword);
    --astro-code-token-string:            var(--color-code-string);
    --astro-code-token-string-expression: var(--color-code-string);
    --astro-code-token-constant:          var(--color-code-var);
    --astro-code-token-parameter:         var(--color-code-var);
    --astro-code-token-function:          var(--color-code-text);
    --astro-code-token-punctuation:       var(--color-code-text);
    --astro-code-token-link:              var(--color-code-string);
    border: 1px solid var(--slate-800);
    border-radius: var(--radius-2);
    background: var(--color-code-bg);
    overflow: hidden;
    & .code-block__bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: var(--space-2);
      padding-block: var(--space-1);
      padding-inline: var(--space-2);
      border-block-end: 1px solid var(--slate-800);
      font-family: var(--font-mono);
      font-size: var(--step--1);
      color: var(--slate-300);
    }
    & pre {
      margin: 0;
      padding-block: var(--space-2);
      padding-inline: var(--space-2);
      overflow-x: auto;
      font-size: 0.8125rem;
      line-height: 1.7;
      color: var(--color-code-text);
      tab-size: 4;
    }
    & code { display: block; min-inline-size: max-content; }
    & .line { display: block; white-space: pre; }
    & .c { color: var(--color-code-comment); font-style: italic; }
    & .k { color: var(--color-code-keyword); }
    & .s { color: var(--color-code-string); }
    & .v { color: var(--color-code-var); }
  }

  /* Callout — tinted ground, crisp 1px full border, Lucide icon */
  .callout {
    --callout-bg: var(--slate-50);
    --callout-border: var(--slate-200);
    --callout-ink: var(--slate-700);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-2);
    padding: var(--space-3);
    background: color-mix(in oklch, var(--callout-bg) 72%, transparent);   /* paper shows through */
    border: 1px solid var(--callout-border);
    border-radius: var(--radius-2);
    & .icon { inline-size: 1.25rem; block-size: 1.25rem; color: var(--callout-ink); margin-block-start: 0.15em; }
    & .callout__title {
      font-size: 0.875rem;
      font-weight: 600;
      letter-spacing: 0.01em;
      color: var(--callout-ink);
    }
    & .callout__body { --flow-space: var(--space-1); color: var(--color-text); font-size: 0.9375rem; }

    &.callout--tip     { --callout-bg: var(--stone-100); --callout-border: var(--stone-300); --callout-ink: var(--stone-800); }
    &.callout--warning { --callout-bg: var(--terra-50);  --callout-border: var(--terra-200); --callout-ink: var(--terra-700); }
  }

  /* Author card / article footer */
  .author-card {
    --sidebar-width: 4rem;
    --sidebar-gap: var(--space-3);
    --sidebar-align: center;
    padding-block: var(--space-4);
    border-block: var(--border-hairline);
    & .sidebar { flex-grow: 0; }
    & img { inline-size: 4rem; block-size: 4rem; object-fit: cover; border-radius: var(--radius-image); border: var(--border-hairline); }
  }

  .post-nav {
    --switcher-threshold: 36rem;
    --switcher-gap: var(--space-2);
    & a {
      display: grid;
      gap: var(--space-1);
      padding: var(--space-3);
      border: var(--border-hairline);
      border-radius: var(--radius-2);
      text-decoration: none;
      color: var(--color-heading);
      font-weight: 500;
      &:hover { border-color: var(--color-border-strong); background: var(--color-surface); color: var(--color-heading); }
      & small { font-family: var(--font-mono); font-size: var(--step--1); color: var(--color-text-muted); font-weight: 400; }
    }
  }

  /* Reading progress (scroll-driven, see utilities) */
  .progress {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    block-size: 2px;
    z-index: 150;
    background: var(--color-accent-mark);
    transform-origin: 0 50%;
    scale: 0 1;
    display: none;
  }

  /* Footer */
  .site-footer {
    margin-block-start: var(--space-12);
    padding-block: var(--space-6);
    border-block-start: var(--border-hairline);
    font-size: 0.875rem;
    color: var(--color-text-muted);
    & .cluster { --cluster-justify: space-between; }
    & a { color: var(--color-text-muted); &:hover { color: var(--color-accent-strong); } }
    & .socials { --cluster-space: var(--space-1); }
    & .socials a {
      display: inline-grid;
      place-items: center;
      inline-size: 2.75rem;
      block-size: 2.75rem;
      border: var(--border-hairline);
      border-radius: var(--radius-2);
      &:hover { border-color: var(--color-border-strong); }
    }
  }

  /* ---- Personal layer: Now line + margin notes ---- */
  .now-line {
    border-block-end: var(--border-hairline);
    & .center {
      padding-block: var(--space-1);
      --cluster-space: var(--space-1) var(--space-3);
      font-family: var(--font-mono);
      font-size: var(--step--1);
      color: var(--color-text-muted);
    }
    & .now-line__label {
      display: inline-flex;
      align-items: center;
      gap: var(--space-1);
      color: var(--color-accent);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      font-weight: 500;
      &::before {                      /* a small terracotta mark, like a map pin */
        content: "";
        inline-size: 0.375rem;
        block-size: 0.375rem;
        border-radius: 50%;
        background: var(--color-accent-mark);
      }
    }
    & time { color: var(--color-text); }
    /* Optional icon per item (now.json `icon`). Inline, not flex, so the spaces
       around labels and italics survive. */
    & .now-line__item--icon .icon {
      display: inline-block;           /* the reset makes svg block-level */
      vertical-align: -0.2em;
      margin-inline-end: 0.4em;
    }
    /* Static list (no JS / reduced motion): the wrapper is transparent to the cluster. */
    & .now-line__items { display: contents; }

    /* Rotating (NowLine script adds .is-rotating): items stack in one cell and crossfade.
       The cell is as tall as the tallest item, so nothing below jumps. */
    &.is-rotating {
      & .center { flex-wrap: nowrap; }
      & .now-line__items {
        display: grid;
        flex: 1;
        min-inline-size: 0;
      }
      & .now-line__item {
        grid-area: 1 / 1;
        white-space: normal;
        opacity: 0;
        pointer-events: none;            /* hidden items can't catch clicks; still read by screen readers */
        transition: opacity 400ms ease;
      }
      & .now-line__item.is-current {
        opacity: 1;
        pointer-events: auto;
        transition: opacity 400ms ease 150ms;
      }
      /* Tap-paused on touch screens: the label's dot goes hollow as a cue. */
      &.is-paused .now-line__label::before {
        background: transparent;
        box-shadow: inset 0 0 0 1.5px var(--color-accent-mark);
      }
    }
  }

  .note {
    font-family: var(--font-display);
    font-variation-settings: var(--font-display-axes);
    font-optical-sizing: auto;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--slate-700);           /* 6.8:1 on canvas · 5.2:1 darkest fleck */
    max-inline-size: 34ch;
    text-wrap: pretty;
    & .note__mark {
      font-family: var(--font-mono);
      font-size: var(--step--1);
      color: var(--color-accent);
      margin-inline-end: 0.375rem;
    }
  }

  .post-row--noted {
    /* tablet: date | content, note tucked under the content */
    @media (min-width: 48rem) {
      grid-template-columns: 9rem minmax(0, 1fr);
      gap: var(--space-2) var(--space-4);
      & .note { grid-column: 2; }
    }
    /* desktop: the note moves out into its own margin column */
    @media (min-width: 64rem) {
      grid-template-columns: 9rem minmax(0, 1fr) 17rem;
      gap: var(--space-4);
      & .note { grid-column: 3; grid-row: 1; }
    }
    & .tag { justify-self: start; }
  }

  .feature__aside { display: grid; gap: var(--space-2); }
  .footer-voice { font-family: var(--font-display); font-variation-settings: var(--font-display-axes); font-size: 1rem; color: var(--slate-700); }
  /* ((aside)) in JSON copy (lib/inline-md.ts): a quieter phrase inside the sentence */
  .aside-inline {
    font-size: 0.85em;
    color: var(--color-text-muted);
  }
  /* Shown in place of a post list when there are no published posts (site.json writing.empty) */
  .empty-note {
    padding-block: var(--space-4);
    font-family: var(--font-display);
    font-variation-settings: var(--font-display-axes);
    font-size: var(--step-1);
    color: var(--slate-700);
  }

  /* Notes inside existing components (placed late so they win the cascade) */
  .photo-frame figcaption .note { flex-basis: 100%; max-inline-size: none; }
  .feature .note,
  .post-row .note {
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--slate-700);
    max-inline-size: 34ch;
  }


  /* Numbered sections — the one big terracotta moment */
  .numbered { counter-reset: section; }
  .numbered .section-title::before,
  .prose > h2::before {
    counter-increment: section;
    content: counter(section, decimal-leading-zero);
    margin-inline-end: 0.45em;
    color: var(--color-accent);
    font-weight: 400;
    font-variant-numeric: lining-nums tabular-nums;
  }
  .prose { counter-reset: section; }

  /* Sidenotes: on narrow screens a ruled block where the <Aside> sits in the text;
     with room, floated into the right margin (the Tufte CSS technique). The float
     lines each note up with the line it follows, and clear: right stacks several
     notes in one paragraph instead of piling them on one spot. */
  .has-note { position: relative; }
  .note-ref {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    line-height: 0;
    vertical-align: super;
    color: var(--color-accent);
    margin-inline-start: 0.1em;
  }
  .sidenote {
    display: block;
    margin-block: var(--space-2) var(--space-1);   /* end margin: room for text that carries on after a mid-paragraph note */
    padding-block-start: var(--space-1);
    border-block-start: var(--border-hairline);
    /* Into the margin from 77rem, the narrowest width where it still gets ~12rem.
       Width is whatever the margin offers, capped at 15rem: (100vw - 100%) / 2 is the
       space beside the text column (100% = the paragraph); minus the gap and a
       --space-2 edge gutter, which also absorbs a classic scrollbar. A fixed 15rem
       overflowed the viewport below 85rem. */
    @media (min-width: 77rem) {
      --note-size: min(15rem, (100vw - 100%) / 2 - var(--space-6) - var(--space-2));
      float: inline-end;
      clear: inline-end;
      inline-size: var(--note-size);
      /* Negative end margin pulls the note out of the text column into the margin
         without narrowing any lines of text. */
      /* The paragraph (a grid item, so its own formatting context) grows to hold a note
         taller than its text; keep the end margin small so that costs little. */
      margin-block: 0.35em var(--space-1);
      margin-inline: 0 calc(-1 * var(--note-size) - var(--space-6));
      padding: 0;
      border: 0;
    }
  }


  /* ---- Small screens: adapt, don't just stack ---------------------------------- */
  /* Horizontal swipe rows share one pattern */
  .swipe-row {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scroll-padding-inline: var(--gutter, var(--space-2));
    scrollbar-width: none;
    &::-webkit-scrollbar { display: none; }
    & > * { scroll-snap-align: start; flex-shrink: 0; }
  }

  @media (max-width: 40rem) {
    /* Header: wordmark and nav on one tidy block, nav targets stay 44px */
    .site-header .center { padding-block: var(--space-2); row-gap: 0; }
    .site-nav { margin-inline-start: calc(var(--space-1) * -1); }

    /* Now line: one swipeable line instead of four wrapped rows */
    .now-line .center {
      flex-wrap: nowrap;
      overflow-x: auto;
      scrollbar-width: none;
      white-space: nowrap;
      padding-inline-end: var(--space-2);
      &::-webkit-scrollbar { display: none; }
    }

    /* Home photo trio: swipe row with a peek of the next photo */
    .photo-grid {
      display: flex;
      grid-template-columns: none;
      gap: var(--space-2);
      overflow-x: auto;
      scroll-snap-type: inline mandatory;
      scrollbar-width: none;
      margin-inline: calc(var(--space-2) * -1);
      padding-inline: var(--space-2);
      scroll-padding-inline: var(--space-2);
      &::-webkit-scrollbar { display: none; }
      & > li { flex: 0 0 78%; scroll-snap-align: start; }
    }

    /* Gallery filters: one swipeable row */
    .filters {
      flex-wrap: nowrap;
      overflow-x: auto;
      scrollbar-width: none;
      margin-inline: calc(var(--space-2) * -1);
      padding-inline: var(--space-2);
      &::-webkit-scrollbar { display: none; }
      & button { flex-shrink: 0; }
    }

    /* Gallery: two-column contact sheet; featured photos span both columns.
       Notes move to the lightbox, titles stay, EXIF trims to one line. */
    .gallery {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-3) var(--space-2);
      & > li { max-inline-size: none !important; }
      & > li.is-featured { grid-column: 1 / -1; }
      & > li:not(.is-featured) .photo-frame__media { aspect-ratio: 4 / 5 !important; }
      & .note { display: none; }
      & figcaption { display: grid; gap: 0.125rem; }
      & .photo-frame__title { font-size: 0.875rem; }
      & .exif li:nth-child(n + 3) { display: none; }
    }
  }

  /* Lightbox */
  .lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--slate-950);
    color: var(--stone-50);
    & .lightbox__scrim { position: absolute; inset: 0; cursor: zoom-out; }
    & .lightbox__bar {
      position: relative;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: var(--space-2);
      padding-block: var(--space-2);
      padding-inline: var(--space-3);
      font-family: var(--font-mono);
      font-size: var(--step--1);
      color: var(--slate-300);
    }
    & .lightbox__stage {
      position: relative;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: stretch;               /* gives the figure a definite height … */
      gap: var(--space-2);
      padding-inline: var(--space-3);
      padding-block: var(--space-1);
      min-block-size: 0;
      & > .lightbox__btn { align-self: center; }
      pointer-events: none;
      & > * { pointer-events: auto; }
    }
    & .lightbox__figure {
      display: grid;
      place-items: center;
      min-block-size: 0;
      overflow: hidden;
      pointer-events: none;
    }
    & .lightbox__img {                      /* … so the photo can fit inside it */
      max-inline-size: 100%;
      max-block-size: 100%;
      min-block-size: 0;
      object-fit: contain;
      border: 1px solid var(--slate-800);
      border-radius: var(--radius-image);
      pointer-events: auto;
    }
    & .lightbox__caption {
      position: relative;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: baseline;
      gap: var(--space-1) var(--space-3);
      padding-block: var(--space-3);
      padding-inline: var(--space-3);
      border-block-start: 1px solid var(--slate-800);
      & h2 { font-size: var(--step-2); color: var(--stone-50); }
      & p { color: var(--slate-200); font-size: 0.875rem; }
      & .exif { color: var(--slate-300); }
    }
    & .lightbox__btn {
      display: inline-grid;
      place-items: center;
      inline-size: 2.75rem;
      block-size: 2.75rem;
      color: var(--stone-50);
      border: 1px solid var(--slate-700);
      border-radius: var(--radius-2);
      background: var(--slate-950);
      transition: border-color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
      & .icon { inline-size: 1.25rem; block-size: 1.25rem; }
      &:hover { border-color: var(--slate-400); background: var(--slate-900); }
      &:focus-visible { outline-color: var(--terra-300); }
    }
    @media (max-width: 40rem) {
      & .lightbox__stage { grid-template-columns: minmax(0, 1fr); padding-inline: var(--space-1); }
      & .lightbox__stage .lightbox__btn { position: absolute; inset-block-end: var(--space-2); }
      & .lightbox__stage .lightbox__btn--prev { inset-inline-start: var(--space-2); }
      & .lightbox__stage .lightbox__btn--next { inset-inline-end: var(--space-2); }
    }
  }
}

/* --------------------------------------------------------------------------
   UTILITIES
   -------------------------------------------------------------------------- */
@layer utilities {
  /* Vertical rhythm — the lobotomised owl */
  .flow > * + * { margin-block-start: var(--flow-space, 1em); }

  .visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    block-size: 1px;
    inline-size: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
  }

  .text-muted { color: var(--color-text-muted); }
  .mono { font-family: var(--font-mono); }

  .section { padding-block: clamp(var(--space-6), 6vw, var(--space-8)); }

  /* Scroll-driven reveals — progressive enhancement only */
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
      .reveal {
        animation: reveal linear both;
        animation-timeline: view();
        animation-range: entry 0% entry 100%;   /* was entry 60%: too quick on phones (18/11/2026) */
      }
      .progress {
        display: block;
        animation: progress linear both;
        animation-timeline: scroll(root block);
      }
    }
  }

  @keyframes reveal {
    from { opacity: 0; translate: 0 var(--space-3); }
    to   { opacity: 1; translate: 0 0; }
  }
  @keyframes progress { to { scale: 1 1; } }

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

/* --------------------------------------------------------------------------
   VIEW TRANSITIONS (native, cross-document: no JS, no router)
   Browsers without support just navigate normally. Off for reduced motion.
   - Default: a short crossfade between pages.
   - The header is named so it stays put instead of fading.
   - A post's title carries view-transition-name: post-<id> on the lists and
     on the article (inline style in PostRow, FeaturedPost, Post layout), so
     it slides from list to heading and back. Names must be unique per page.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
::view-transition-group(*) { animation-duration: 280ms; animation-timing-function: cubic-bezier(0.2, 0, 0, 1); }
.site-header { view-transition-name: site-header; }
/* Shrink-wrap titles so the morph scales the text, not an empty full-width box. */
.post-title { inline-size: fit-content; view-transition-class: post-title; }
/* A one-line list title and a three-line heading look messy crossfaded, so hand
   over instead: old out quickly, new in just after. (Browsers without
   view-transition-class keep the default crossfade.) */
::view-transition-old(*.post-title) { animation: 90ms ease-out both vt-fade-out; }
::view-transition-new(*.post-title) { animation: 180ms ease-in 80ms both vt-fade-in; }
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
