/*
 * Design system core: layers, tokens, and the chrome and primitives every page shares.
 *
 * Direction: "technical editorial". Neutral paper and ink; one green accent; Inter for
 * reading and display, JetBrains Mono for metadata (dates, tags, status, section numbers).
 *
 * Cascade layers, lowest to highest priority. `scale` holds the shared token scale (see "Shared
 * scale" below), so a page can adjust it (the home page's phone scale) without out-shouting it.
 * The order is also declared inline in each page's <head>, which must come before any style.
 */
@layer scale, reset, tokens, base, components, sections, utilities;

/* ==========================================================================
   Fonts
   Inter (variable, 300-700) for text and display; JetBrains Mono 500 for metadata.
   ========================================================================== */
@layer base {
  @font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/inter-variable.woff2') format('woff2');
  }

  @font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    /* stylelint-disable-next-line declaration-property-value-disallowed-list -- an @font-face descriptor, not a text weight */
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-500.woff2') format('woff2');
  }

  /* Metric-matched stand-ins, so the text barely moves when a web font swaps in. The
     overrides make a local font occupy the same space as the real one (values from the
     fonts' own metrics), which is what keeps the layout shift at zero. */
  @font-face {
    font-family: 'Inter Fallback';
    src: local('Arial');
    size-adjust: 107.64%;
    ascent-override: 89.79%;
    descent-override: 22.36%;
    line-gap-override: 0%;
  }

  @font-face {
    font-family: 'JetBrains Mono Fallback';
    src: local('Courier New');
    size-adjust: 100%;
    ascent-override: 102%;
    descent-override: 30%;
    line-gap-override: 0%;
  }
}

/* ==========================================================================
   Tokens
   Colours are semantic and defined once with light-dark(); the theme is whatever
   color-scheme resolves to. <html data-theme="light|dark"> is the visitor's explicit choice
   (set before first paint by the script in <head>); with none, the OS preference applies.
   This is the only place colour literals may appear (see stylelint.config.mjs).
   ========================================================================== */
@layer tokens {
  :root {
    color-scheme: light dark;
  }

  :root[data-theme='light'] {
    color-scheme: light;
  }

  :root[data-theme='dark'] {
    color-scheme: dark;
  }

  /* stylelint-disable color-no-hex, function-disallowed-list -- the token block is where colours are defined */
  :root {
    /* Surfaces */
    --surface: light-dark(#fbfbf8, #0b0d0b);
    --surface-raised: light-dark(#ffffff, #131613);
    --surface-sunken: light-dark(#f2f3ee, #0f120f);

    /* Ink */
    --text: light-dark(#15181a, #eef1ee);
    --muted: light-dark(#4a524d, #a4aba6);

    /* Lines */
    --border: light-dark(#dcdfd7, #252a25);
    --border-strong: light-dark(#b9beb4, #3a403a);

    /* Accent: links, focus, live indicators, the primary action, the flow field */
    --accent: light-dark(#15803d, #4ade80);
    --accent-strong: light-dark(#166534, #86efac);
    --accent-contrast: light-dark(#ffffff, #052e16);
    --accent-wash: color-mix(in srgb, var(--accent) 10%, transparent);

    /* Errors. 6:1 or better on every surface, in both themes. */
    --danger: light-dark(#b91c1c, #f87171);

    --scrim: light-dark(rgb(15 20 17 / 0.45), rgb(0 0 0 / 0.65));
    --shadow-overlay:
      0 1.5rem 4rem light-dark(rgb(15 20 17 / 0.18), rgb(0 0 0 / 0.55)),
      0 0.25rem 1rem light-dark(rgb(15 20 17 / 0.08), rgb(0 0 0 / 0.4));
  }
  /* stylelint-enable color-no-hex, function-disallowed-list */

  :root {
    /* Type */
    --font-sans: Inter, 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: var(--font-sans);
    --font-mono:
      'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, 'SF Mono', Menlo, Consolas,
      monospace;
    --font-size-display: clamp(2.5rem, 1.2rem + 5.2vw, 5.25rem);
    --font-size-title: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
    --line-height-display: 1.04;
    --letter-spacing-display: -0.035em;

    /* Layout */
    --gutter: var(--space-4);
    --page-max: 75rem;
    --measure: 40rem;
    --nav-h: 4rem;

    /* Motion */
    --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
    --dur-fast: 150ms;
    --dur-base: 250ms;
  }

  @media (min-width: 48rem) {
    :root {
      --gutter: var(--space-8);
    }
  }
}

/* ==========================================================================
   Shared scale
   The type, spacing and radius scales. A layer of their own, below everything else, so a page
   can adjust a value for its own needs (home.css makes the scale a step tighter on phones)
   without a more specific rule.
   ========================================================================== */
@layer scale {
  :root {
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    --font-size-6xl: 3.75rem;
    --font-size-7xl: 4.5rem;

    --line-height-tight: 1.2;
    --line-height-snug: 1.375;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    --line-height-loose: 1.75;

    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --letter-spacing-tight: -0.02em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.06em;
    --letter-spacing-wider: 0.1em;

    --space-0: 0;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    --space-32: 8rem;

    --radius-sm: 0.25rem;
    --radius-base: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    --border-width: 1px;

    --z-fixed: 1030;
    --z-modal: 1050;
  }
}

/* ==========================================================================
   Base
   Only what the shared components need. A page sets its own element defaults (home.css does).
   ========================================================================== */
@layer reset {
  *,
  ::before,
  ::after {
    box-sizing: border-box;
  }

  body {
    margin: 0;
  }
}

@layer base {
  /* The pages use viewport-fit=cover, so on a notched phone held sideways the page would run under
     the cutout. Keep the content out of it; where there is no inset this is zero. */
  @supports (padding: max(0px)) {
    body {
      padding-left: max(0px, env(safe-area-inset-left));
      padding-right: max(0px, env(safe-area-inset-right));
    }
  }

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

/* ==========================================================================
   Components
   ========================================================================== */
@layer components {
  /* Page-width column with a responsive gutter */
  .wrap {
    width: min(100% - 2 * var(--gutter), var(--page-max));
    margin-inline: auto;
  }

  /* --- Mono eyebrow: "01 — Selected work", categories, dates ---------------- */
  .eyebrow {
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--letter-spacing-wide);
    line-height: var(--line-height-normal);
    text-transform: uppercase;
    color: var(--muted);
  }

  /* --- Buttons --------------------------------------------------------------- */
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 2.75rem;
    padding: var(--space-2) var(--space-5);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    text-decoration: none;
    cursor: pointer;
    transition:
      background-color var(--dur-fast) var(--ease-out),
      border-color var(--dur-fast) var(--ease-out),
      color var(--dur-fast) var(--ease-out);
  }

  .button:hover {
    border-color: var(--text);
  }

  .button--primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
  }

  .button--primary:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
  }

  .button .icon {
    transition: transform var(--dur-fast) var(--ease-out);
  }

  .button:hover .icon {
    transform: translateX(0.125rem);
  }

  /* --- Utilities the new pages need  ------------ */
  .icon {
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    fill: currentcolor;
    vertical-align: -0.125em;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    /* stylelint-disable-next-line declaration-property-value-disallowed-list -- optical nudge, not on the spacing scale */
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Shown on keyboard focus: the way past the navigation to the content */
  .skip-link {
    position: absolute;
    inset-block-start: -4rem;
    inset-inline-start: 0;
    z-index: var(--z-fixed);
    padding: var(--space-2) var(--space-4);
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
  }

  .skip-link:focus {
    inset-block-start: 0;
  }

  /* --- Footer ------------------------------------------------------------------------- */
  .site-footer {
    padding-block: var(--space-8);
    border-top: var(--border-width) solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
  }

  .site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4) var(--space-8);
  }

  .site-footer__note {
    margin: 0;
  }

  .site-footer__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-5);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .site-footer__views {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    font-variant-numeric: tabular-nums;
    font-weight: var(--font-weight-medium);
  }

  .site-footer__views[hidden] {
    display: none;
  }

  /* --- Key/value facts (About, project pages) -------------------------------------------- */
  .facts {
    margin: 0;
    border-top: var(--border-width) solid var(--border);
  }

  .facts__row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: var(--border-width) solid var(--border);
  }

  .facts dt {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--letter-spacing-wide);
    text-transform: uppercase;
  }

  .facts dd {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    text-align: right;
  }

  /* One screenshot per theme. The visitor's explicit choice (data-theme) wins; otherwise
     the OS preference decides, which also covers a page with no script. */
  .shot {
    display: block;
    width: 100%;
    height: 100%;
  }

  /* The <img> inside a <picture>. A bare <img class="shot"> must NOT get display from a rule
     like this one: it would out-rank .shot--dark below (more specific) and un-hide the other
     theme's image, which is then still downloaded. */
  .shot img {
    display: block;
  }

  /* Same specificity as .shot and later, so these win. Keep the two kept together. */
  .shot--dark {
    display: none;
  }

  :root[data-theme='dark'] .shot--light {
    display: none;
  }

  :root[data-theme='dark'] .shot--dark {
    display: block;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .shot--light {
      display: none;
    }

    :root:not([data-theme]) .shot--dark {
      display: block;
    }
  }

  /* --- Sections: a hairline above, generous air, and a heading that sits left ------- */
  .section {
    padding-block: var(--space-16);
    border-top: var(--border-width) solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-sans);
  }

  @media (min-width: 48rem) {
    .section {
      padding-block: var(--space-24);
    }
  }

  .section-heading {
    display: grid;
    gap: var(--space-3);
    max-width: var(--measure);
    margin-bottom: var(--space-10);
  }

  .section-heading__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--font-size-title);
    font-weight: var(--font-weight-bold);
    letter-spacing: var(--letter-spacing-tight);
    line-height: var(--line-height-tight);
    text-wrap: balance;
  }

  /* A link inside the lede is the same size as the words around it */
  .section-heading__lede .link {
    font-size: inherit;
  }

  .section-heading__lede {
    margin: 0;
    color: var(--muted);
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
    text-wrap: pretty;
  }

  /* --- Text link with an arrow ------------------------------------------------ */
  .link {
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--text);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.3em;
    transition:
      color var(--dur-fast) var(--ease-out),
      text-decoration-color var(--dur-fast) var(--ease-out);
  }

  .link:hover {
    color: var(--accent);
    text-decoration-color: currentcolor;
  }

  /* --- Tags: mono, neutral. Colour is reserved for what is live or actionable. -- */
  .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .tag {
    padding: var(--space-1) var(--space-2);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
  }

  /* --- Forms: fields, errors, status, and the busy state of a button ---------------- */
  .form {
    display: grid;
    gap: var(--space-5);
  }

  .form__row {
    display: grid;
    gap: var(--space-5);
  }

  @media (min-width: 40rem) {
    .form__row {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .form__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-5);
  }

  .field {
    display: grid;
    gap: var(--space-2);
  }

  .field__label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
  }

  /* 16px: iOS zooms into a smaller field on focus. The border is the field's edge, so it
     needs 3:1 against the surface (the token borders are for hairlines, not controls). */
  .input,
  .textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: var(--border-width) solid color-mix(in srgb, var(--text) 55%, var(--surface-raised));
    border-radius: var(--radius-base);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    transition: border-color var(--dur-fast) var(--ease-out);
  }

  .textarea {
    min-height: 8rem;
    resize: vertical;
  }

  .input:hover,
  .textarea:hover {
    border-color: var(--text);
  }

  .input[aria-invalid='true'],
  .textarea[aria-invalid='true'] {
    border-color: var(--danger);
  }

  .field__error {
    margin: 0;
    color: var(--danger);
    font-size: var(--font-size-sm);
  }

  .field__error[hidden] {
    display: none;
  }

  /* Where a form says what happened. An <output> with an explicit role="status" (a polite live
   region), so a change to its text is announced; the markup carries the role, not this rule. */
  .form-status {
    margin: 0;
    color: var(--muted);
    font-size: var(--font-size-sm);
  }

  .form-status[data-state='success'] {
    color: var(--accent);
  }

  .form-status[data-state='error'] {
    color: var(--danger);
  }

  .form-status a {
    color: inherit;
    text-underline-offset: 0.25em;
  }

  /* A honeypot: out of sight and out of the tab order, but present for bots to fill in */
  .trap {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .spinner {
    display: none;
    width: 1em;
    height: 1em;
    border: 2px solid currentcolor;
    border-inline-end-color: transparent;
    border-radius: var(--radius-full);
    animation: spinner-rotate 700ms linear infinite;
  }

  .button[aria-busy='true'] .spinner {
    display: inline-block;
  }

  /* Busy, not disabled: a disabled button drops keyboard focus. The script ignores the click. */
  .button[aria-disabled='true'] {
    cursor: progress;
    opacity: 0.75;
  }

  @keyframes spinner-rotate {
    to {
      transform: rotate(1turn);
    }
  }

  /* --- Icon-only button (theme, menu, search) --------------------------------- */
  .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text);
    font-size: var(--font-size-base);
    cursor: pointer;
    transition:
      background-color var(--dur-fast) var(--ease-out),
      border-color var(--dur-fast) var(--ease-out);
  }

  .icon-button:hover {
    border-color: var(--border-strong);
    background: var(--surface-sunken);
  }

  /* --- Site navigation --------------------------------------------------------
     A top bar on wide screens; on narrow ones the link list becomes a sheet that drops
     from the bar. main.js sets .active on the toggle and the list while the sheet is open, in a
     browser without popover. */
  .site-nav {
    font-family: var(--font-sans);
    position: fixed;
    inset: 0 0 auto;
    z-index: var(--z-fixed);
    height: var(--nav-h);
    border-bottom: var(--border-width) solid transparent;
  }

  /* The frosted background is a layer of its own: backdrop-filter on the bar itself would
     make the bar the containing block of the fixed sheet below, shrinking it to 4rem tall. */
  .site-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    -webkit-backdrop-filter: blur(0.75rem) saturate(1.4);
    backdrop-filter: blur(0.75rem) saturate(1.4);
  }

  /* The hairline under the bar fills in over the first few rem of scrolling: a scroll timeline, no
     script (it replaced a scroll listener). A browser without scroll timelines keeps the bar
     borderless, the frosted background still marks it, as with .reading-progress in article.css.
     A page that renders the bar already scrolled (the generated pages) has the class and the line. */
  .site-nav.scrolled {
    border-bottom-color: var(--border);
  }

  @supports (animation-timeline: scroll()) {
    .site-nav:not(.scrolled) {
      animation: nav-rule linear both;
      animation-timeline: scroll(root block);
      animation-range: 0 var(--space-12);
    }
  }

  @keyframes nav-rule {
    to {
      border-bottom-color: var(--border);
    }
  }

  .site-nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    height: 100%;
  }

  .site-nav__logo {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--letter-spacing-tight);
    text-decoration: none;
  }

  .site-nav__links {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin: 0;
    padding: var(--space-4) var(--gutter) var(--space-8);
    list-style: none;
    /* Narrow screens: a sheet under the bar. Closed, it is invisible and cannot be tapped. It is a
       popover (index.html), so the browser's own box for one is reset here: it would otherwise be
       sized to its content, centred, bordered and coloured as a pop-up. */
    position: fixed;
    inset: var(--nav-h) 0 0;
    width: auto;
    height: auto;
    margin: 0;
    border: 0;
    color: inherit;
    overflow-y: auto;
    background: var(--surface);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-0.5rem);
    transition:
      opacity var(--dur-base) var(--ease-out),
      transform var(--dur-base) var(--ease-out),
      visibility 0s linear var(--dur-base);
  }

  /* .active is for a browser without popover (modules/menu-fallback.js) */
  .site-nav__links.active,
  .site-nav__links:popover-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition-delay: 0s;
  }

  .site-nav__links a {
    display: block;
    padding: var(--space-3) 0;
    border-bottom: var(--border-width) solid var(--border);
    color: var(--text);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--letter-spacing-tight);
    text-decoration: none;
  }

  .site-nav__links a[aria-current='location'] {
    color: var(--accent);
  }

  /* Socials live in the sheet only; the bar has no room for them */
  .site-nav__socials {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    margin-top: var(--space-6);
  }

  .site-nav__socials a {
    padding: 0;
    border: 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--letter-spacing-normal);
  }

  .site-nav__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  /* The search button reads as a field on wide screens and as an icon on narrow ones */
  .site-nav__search {
    gap: var(--space-2);
    width: auto;
    padding-inline: var(--space-3);
    color: var(--muted);
    font-size: var(--font-size-sm);
  }

  .site-nav__search-label,
  .site-nav__search::after {
    display: none;
  }

  /* The shortcut hint is generated content from data-shortcut (set for the platform by
     command-palette.js), not text in the page: the button's visible text is just "Search",
     which its accessible name ("Search the site") contains. A hint written as text would be
     visible text the name does not include (WCAG 2.5.3, label in name). */
  .site-nav__search::after {
    content: attr(data-shortcut);
    padding: 0 var(--space-1);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
  }

  /* The menu button: three bars that become a cross */
  .site-nav__menu-bars {
    position: relative;
    display: block;
    width: 1.125rem;
    height: 0.125rem;
    background: currentcolor;
    transition: background-color var(--dur-fast) var(--ease-out);
  }

  .site-nav__menu-bars::before,
  .site-nav__menu-bars::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    height: 0.125rem;
    background: currentcolor;
    transition: transform var(--dur-base) var(--ease-out);
  }

  .site-nav__menu-bars::before {
    transform: translateY(-0.3125rem);
  }

  .site-nav__menu-bars::after {
    transform: translateY(0.3125rem);
  }

  .site-nav__menu.active .site-nav__menu-bars,
  .site-nav__inner:has(.site-nav__links:popover-open) .site-nav__menu-bars {
    background: transparent;
  }

  .site-nav__menu.active .site-nav__menu-bars::before,
  .site-nav__inner:has(.site-nav__links:popover-open) .site-nav__menu-bars::before {
    transform: rotate(45deg);
  }

  .site-nav__menu.active .site-nav__menu-bars::after,
  .site-nav__inner:has(.site-nav__links:popover-open) .site-nav__menu-bars::after {
    transform: rotate(-45deg);
  }

  @media (min-width: 48rem) {
    .site-nav__links {
      position: static;
      flex-direction: row;
      gap: var(--space-1);
      padding: 0;
      overflow: visible;
      background: transparent;
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: none;
      transition: none;
    }

    .site-nav__links a {
      padding: var(--space-2) var(--space-3);
      border: 0;
      border-radius: var(--radius-base);
      color: var(--muted);
      font-size: var(--font-size-sm);
      font-weight: var(--font-weight-medium);
      letter-spacing: var(--letter-spacing-normal);
      transition: color var(--dur-fast) var(--ease-out);
    }

    .site-nav__links a:hover {
      color: var(--text);
    }

    .site-nav__links a[aria-current='location'] {
      color: var(--text);
      text-decoration: underline;
      text-decoration-color: var(--accent);
      text-decoration-thickness: 2px;
      text-underline-offset: 0.6em;
    }

    .site-nav__socials,
    .site-nav__menu {
      display: none;
    }

    .site-nav__search-label,
    .site-nav__search::after {
      display: inline;
    }
  }
}

/* ==========================================================================
   Utilities
   ========================================================================== */
@layer utilities {
  @media (prefers-reduced-motion: reduce) {
    .site-nav__links,
    .site-nav__menu-bars,
    .site-nav__menu-bars::before,
    .site-nav__menu-bars::after,
    .button,
    .button .icon,
    .input,
    .textarea {
      transition: none;
    }

    .spinner {
      animation: none;
    }
  }
}

/* ==========================================================================
   Page transitions
   A navigation between two of our pages cross-fades, and a project's image and title morph
   between its card and its page. The elements are named by modules/page-transitions.js only
   while navigating, so a theme switch (a same-page transition) doesn't split them out.
   Browsers without support ignore all of this.
   ========================================================================== */
/* The opt-in (@view-transition) is inline in each page's <head>, not here: see VIEW_TRANSITION_CSS in
   scripts/templates/chrome.mjs for why. */

/* The theme switch: a circle that grows from the toggle (theme.js sets the origin and the
   attribute). Scoped to the switch so it never runs on a navigation. */
:root[data-switching-theme]::view-transition-old(root),
:root[data-switching-theme]::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

:root[data-switching-theme]::view-transition-new(root) {
  z-index: 2;
  animation: theme-reveal 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-switching-theme]::view-transition-old(root) {
  z-index: 1;
}

@keyframes theme-reveal {
  from {
    clip-path: circle(0% at var(--theme-x, 50%) var(--theme-y, 50%));
  }

  to {
    clip-path: circle(150% at var(--theme-x, 50%) var(--theme-y, 50%));
  }
}
