@layer reset, base, layout, components, utilities;
@layer reset {
  html,
  body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: clip;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  figure {
    margin-inline: 0;
  }
}
/* registered, so it animates */
@property --i {
  syntax: "<integer>";
  inherits: true;
  initial-value: 0;
}

@layer base {
  :root {
    color-scheme: light dark;
    --paper: light-dark(oklch(97% 0 0), oklch(20.5% 0 0));
    --ink: light-dark(oklch(37.1% 0 0), oklch(92.2% 0 0));
    --accent: light-dark(oklch(0% 0 0), oklch(100% 0 0));
    --accent-wash: light-dark(
      oklch(from var(--paper) calc(l - 0.06) c h),
      oklch(from var(--paper) calc(l + 0.08) c h)
    );
    --muted: color-mix(in oklch, var(--ink) 78%, var(--paper));
    --rule: var(--ink);
    --tint: color-mix(in oklch, var(--ink) 7%, var(--paper));
    --highlight: color-mix(in oklch, var(--ink) 22%, var(--paper));
    --line: 1px solid var(--ink);
    /* white with a 1px ink border, like jamespants.com; dark mode uses the paper color */
    --button: light-dark(oklch(100% 0 0), oklch(20.5% 0 0));
    --button-hover: light-dark(oklch(94% 0 0), oklch(27% 0 0));
    --hard-shadow: none;
    --photo-filter: grayscale(100%) contrast(150%);
    --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
    --font-sans: var(--font-serif);
    --font-display: var(--font-serif);
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --nav-width: 140px;
    --measure: 40rem;
    --gutter: 2rem; /* space between main and rail */
    --hang: 0.65rem; /* gap between a hanging § or chapter number and its heading */
    --rail: 11rem;
    --wide-max: 1280px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

    /* TODO: remove; used by header and modal */
    --color-background: var(--paper);

    /* lets height animate to auto */
    interpolate-size: allow-keywords;
    line-height: 1.55;
    accent-color: var(--accent);
    scrollbar-color: var(--rule) transparent;
  }

  :root:has(select[name="theme"] option[value="light"]:checked) {
    color-scheme: light;
  }

  :root:has(select[name="theme"] option[value="dark"]:checked) {
    color-scheme: dark;
  }

  :root:has(select[name="theme"] option[value="sepia"]:checked) {
    color-scheme: light;
    --paper: oklch(92% 0.012 95);
    --ink: oklch(20% 0.01 80);
  }

  @media (width < 40rem) {
    :root {
      font-size: 106.25%;
    }
  }

  :root:has(select[name="size"] option[value="s"]:checked) {
    font-size: 87.5%;
  }

  :root:has(select[name="size"] option[value="l"]:checked) {
    font-size: 112.5%;
  }

  :root:has(select[name="size"] option[value="xl"]:checked) {
    font-size: 125%;
  }

  @media (prefers-contrast: more) {
    :root {
      --muted: var(--ink);
    }
  }

  body {
    font-family: var(--font-serif);
    font-optical-sizing: auto;
    font-size: clamp(1.0625rem, 0.9875rem + 0.3vi, 1.25rem);
    font-size: --fluid(1.0625, 1.25);
    color: var(--ink);
    background-color: var(--paper);
    -webkit-font-smoothing: antialiased;
  }

  a {
    color: inherit;
    text-decoration-line: underline;
  }

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

  ::selection {
    background: var(--highlight);
    color: var(--accent);
  }

  ::target-text {
    background: var(--highlight);
    color: var(--accent);
  }

  /* find in page: every match, then the one it's on (orange by default) */
  ::search-text {
    background: var(--highlight);
    color: var(--accent);
  }

  ::search-text:current {
    background: var(--ink);
    color: var(--paper);
  }

  .visually-hidden,
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  img {
    filter: var(--photo-filter);
  }

  .label {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-style: italic;
    font-weight: 400;
    color: var(--ink);
  }
}

/* --min at 400px to --max at 1400px; write a plain clamp() first */
@function --fluid(--min <number>, --max <number>) returns <length> {
  result: clamp(
    calc(var(--min) * 1rem),
    calc(
      (var(--min) - (var(--max) - var(--min)) * 0.4) * 1rem +
        (var(--max) - var(--min)) * 1.6vi
    ),
    calc(var(--max) * 1rem)
  );
}

@layer base {
  main p,
  main li {
    line-height: 1.6;
    text-wrap: pretty;
    hyphens: manual;
    hanging-punctuation: first allow-end last;
    font-variant-numeric: oldstyle-nums proportional-nums;
  }

  main p {
    margin-block: 0 0.85lh;
  }

  h1,
  h2,
  h3 {
    text-wrap: balance;
    text-box: trim-both cap alphabetic;
    font-variant-numeric: lining-nums;
  }

  .chapter__title {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 0.6em;
    margin-block: 3rlh 1.5rlh;
    padding-block-start: 1.5rem;
    border-block-start: 1px solid var(--ink);
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 1.3rem + 0.8vi, 2rem);
    font-size: --fluid(1.5, 2);
    font-weight: 400;
    line-height: 1.2;
  }

  .chapter:first-of-type .chapter__title {
    margin-block-start: 2rlh;
  }

  .chapter__num {
    font-style: italic;
    color: var(--muted);

    /* hangs in the margin so the title lines up with the text */
    @media (width >= 58.5rem) {
      flex: none;
      inline-size: 1.5em;
      margin-inline: calc(-1.5em - var(--hang)) calc(var(--hang) - 0.6em); /* 0.6em is the title gap */
      text-align: end;
    }
  }

  .section__title {
    position: relative;
    margin-block: 2rlh 0.75rlh;
    scroll-margin-block-start: 4rem; /* clear of the top bar */
    font-family: var(--font-display);
    font-size: 1.125em;
    font-style: italic;
    font-weight: 400;
    line-height: 1.3;
  }

  .section__anchor {
    margin-inline-start: 0.4em;
    font-style: normal;
    text-decoration: none;
    color: var(--muted);
    transition: color 0.3s ease;

    &:hover,
    :is(.section__title, .chapter__title):target &,
    .chapter:target > .chapter__title & {
      color: var(--accent);
    }

    .chapter__title & {
      margin: 0;
      font-size: 0.75em;
    }
  }

  #intro .lede::first-letter,
  p.drop__cap::first-letter {
    initial-letter: 3;
    margin-inline-end: 0.4em; /* em is the text size here */
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--accent);
  }

  @supports not (initial-letter: 3) {
    #intro .lede::first-letter,
    p.drop__cap::first-letter {
      float: left;
      font-size: 4.1em;
      line-height: 0.8;
      padding-block-start: 0.08em;
      margin-inline-end: 0.1em; /* the letter's own em */
    }
  }

  .ornament {
    width: 4rem;
    margin-block: 2.5rlh;
    border: 0;
    border-block-start: 1px solid var(--ink);
  }

  main ol:not([class]),
  main ul:not([class]) {
    padding-inline-start: 1.25em;
    margin-block: 0 1lh;
  }

  main :not(pre) > code {
    padding: 0.1em 0.3em;
    font-family: var(--font-mono);
    font-size: 0.85em;
    font-variant-ligatures: none;
    hyphens: none; /* a hyphen would read as part of the name */
    background: var(--tint);
    border-radius: 0;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
  }

  main a > code {
    text-decoration: inherit;
  }

  main ol:not([class]) ::marker {
    font-family: var(--font-sans);
    font-size: 0.875em;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
  }
}

@layer layout {
  /* Areas: full, nav, wide (main + rail + slack), main, rail. Main is centred. */
  .page {
    /* wide's slack: nothing until main is at full --measure, then up to --wide-max; the 1fr tracks take the rest.
       100% is the page width, since the value is used in grid-template-columns */
    --wide-slack: clamp(
      0px,
      (100% - 2 * var(--nav-width) - var(--measure) - 2 * (var(--gutter) + var(--rail))) / 2,
      (var(--wide-max) - var(--measure) - 2 * (var(--gutter) + var(--rail))) / 2
    );

    display: grid;
    grid-template-columns:
      [full-start nav-start] var(--nav-width)
      [nav-end] 1fr
      [wide-start] minmax(0, var(--wide-slack))
      calc(var(--gutter) + var(--rail))
      [main-start] minmax(0, var(--measure))
      [main-end] var(--gutter)
      [rail-start] var(--rail)
      [rail-end] minmax(0, var(--wide-slack))
      [wide-end] 1fr
      var(--nav-width)
      [full-end];

    /* lets the nav read chapter timelines. TODO: explain */
    timeline-scope:
      --ch-1, --ch-2, --ch-3, --ch-4, --ch-5, --ch-6, --ch-7, --ch-8, --ch-9;
  }

  header {
    grid-column: full;
    grid-row: 1;
  }

  nav {
    grid-column: nav;
    grid-row: 2;
    z-index: 3;
  }

  main,
  .chapter,
  .detour,
  .endmatter {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: full;
    align-content: start;
  }

  main {
    grid-row: 2;
  }

  :is(main, .chapter, .detour, .endmatter) > * {
    grid-column: main;
  }

  :is(main, .chapter, .detour, .endmatter) > :is(.chapter, .endmatter) {
    grid-column: full;
  }

  :is(main, .chapter, .detour, .endmatter) > .wide {
    grid-column: wide;
  }

  :is(main, .chapter, .detour, .endmatter) > .full {
    grid-column: full;
  }

  /* same row as the element before it */
  :is(main, .chapter, .detour, .endmatter) > .rail {
    grid-column: rail;
  }

  .chapter {
    scroll-margin-top: 2rem;
  }

  .chapter:nth-of-type(1) {
    view-timeline-name: --ch-1;
  }
  .chapter:nth-of-type(2) {
    view-timeline-name: --ch-2;
  }
  .chapter:nth-of-type(3) {
    view-timeline-name: --ch-3;
  }
  .chapter:nth-of-type(4) {
    view-timeline-name: --ch-4;
  }
  .chapter:nth-of-type(5) {
    view-timeline-name: --ch-5;
  }
  .chapter:nth-of-type(6) {
    view-timeline-name: --ch-6;
  }
  .chapter:nth-of-type(7) {
    view-timeline-name: --ch-7;
  }
  .chapter:nth-of-type(8) {
    view-timeline-name: --ch-8;
  }
  .chapter:nth-of-type(9) {
    view-timeline-name: --ch-9;
  }

  /* no room for a rail: it shares main's lines.
     84.5rem = both nav columns, gutters and rails, a full --measure, and 1rem for a scrollbar,
     so main never shrinks at the switch. minmax(0, 1fr), so wide content can't squeeze main */
  @media (width < 84.5rem) {
    .page {
      grid-template-columns:
        [full-start nav-start] var(--nav-width)
        [nav-end wide-start] minmax(0, 1fr)
        [main-start rail-start] minmax(0, var(--measure))
        [main-end rail-end] minmax(0, 1fr)
        [wide-end] var(--nav-width)
        [full-end];
    }
  }

  /* 58.5rem = both nav columns, a full --measure and a scrollbar. main still stops at --measure; wide goes edge to edge */
  @media (width < 58.5rem) {
    .page {
      --nav-width: 0px;
      grid-template-columns:
        [full-start nav-start nav-end] 1.25rem
        [wide-start] minmax(0, 1fr)
        [main-start rail-start] minmax(0, var(--measure))
        [main-end rail-end] minmax(0, 1fr)
        [wide-end] 1.25rem
        [full-end];
    }

    nav {
      display: none;
    }
  }
}

@layer components {
  @keyframes progress-grow {
    from {
      scale: 0 1;
    }
  }

  .progress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 10;
    height: 2px;
    background: var(--accent);
    transform-origin: left center;
    scale: 0 1; /* hidden without scroll timelines */
  }

  @supports (animation-timeline: scroll()) {
    .progress {
      scale: 1 1;
      animation: progress-grow linear both;
      animation-timeline: scroll(root);
    }
  }
}

@layer components {
  /* root is a scroll-state container (endmatter.css) */
  .topbar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 9; /* under the progress bar */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.9rem clamp(1.25rem, 4vw, 2.5rem);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 400;
    color: white;
    mix-blend-mode: difference;

    translate: 0 -100%;
    pointer-events: none;
    transition: translate 0.4s var(--ease);

    a {
      color: inherit;
      text-decoration: none;
    }

    a:hover {
      text-decoration: underline;
      text-underline-offset: 0.2em;
    }

    :focus-visible {
      outline-color: white;
    }
  }

  .topbar__crumbs {
    margin: 0;
    min-width: 0; /* lets the title truncate */
  }

  .topbar__chevron {
    display: none;
  }

  .topbar__links {
    display: flex;
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  @container scroll-state(scrolled: top) {
    .topbar {
      translate: 0 0;
      pointer-events: auto;
    }
  }

  /* can't tell scroll direction (Firefox): always show it on phones, where the sidebar is hidden */
  @supports not (container-type: scroll-state) {
    @media (width < 58.5rem) {
      /* always over text, so give it a solid bar instead of the blend */
      .topbar {
        translate: 0 0;
        pointer-events: auto;
        color: var(--ink);
        background: var(--paper);
        border-block-end: var(--line);
        mix-blend-mode: normal;

        :focus-visible {
          outline-color: var(--accent);
        }
      }
    }
  }

  /* keyboard users can always reach it */
  .topbar:focus-within {
    translate: 0 0;
    pointer-events: auto;
  }

  /* phones: ‹ Living C.L.E.A.N.E.R. instead of Blog / … */
  @media (width < 40rem) {
    .topbar__crumbs {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    .topbar__home {
      flex: none;
      display: grid;
      place-items: center;
      min-width: 1.5rem;
      margin-inline-start: -0.25rem;
    }

    .topbar__chevron {
      display: block;
      font-size: 1.5rem;
      line-height: 0.75;
    }

    /* still named for screen readers */
    .topbar__home-label {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    .topbar__slash {
      display: none;
    }

    .topbar__title {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }

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

  @media print {
    .topbar {
      display: none;
    }
  }
}

@layer components {
  .support {
    position: relative;
    display: inline-flex;
    gap: 2px;
    margin-inline: 0.3em 0.1em;
    /* all in em of the text around it, so the badge lines up with an inline code chip at any size */
    padding: 0.19em;
    vertical-align: 0.18em;
    font-family: var(--font-sans);
    font-size: 0.6em;
    font-style: normal;
    font-weight: 600;
    line-height: 1;
    text-indent: 0;
    white-space: nowrap;
    hyphens: none;
    border: var(--line);
    border-radius: 0;
    cursor: help;

    > span {
      display: grid;
      place-items: center;
      inline-size: 1.4em;
      block-size: 1.4em;
      border-radius: 0;
    }

    &::after {
      content: attr(data-tip);
      position: absolute;
      bottom: calc(100% + 6px);
      left: 50%;
      z-index: 6;
      padding: 0.5rem 0.7rem;
      font-size: 0.75rem;
      font-weight: 500;
      line-height: 1.5;
      white-space: pre;
      color: var(--paper);
      background: var(--ink);
      border-radius: 0;
      box-shadow: var(--hard-shadow);
      opacity: 0;
      translate: -50% 4px;
      pointer-events: none;
      transition:
        opacity 0.15s ease,
        translate 0.15s ease;
    }

    &:hover::after {
      opacity: 1;
      translate: -50% 0;
    }
  }

  .support-tail {
    white-space: nowrap;
  }

  .support--key {
    cursor: auto;

    &::after {
      content: none;
    }
  }

  [data-support="yes"] {
    color: var(--paper);
    background: var(--ink);
  }

  [data-support="partial"] {
    color: var(--ink);
    background: linear-gradient(135deg, var(--paper) 50%, var(--rule) 50%);
    outline: 1px solid var(--ink);
    outline-offset: -1px;
  }

  [data-support="no"] {
    color: color-mix(in oklch, var(--muted) 70%, var(--paper));
    text-decoration: line-through;
  }

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

  @media print {
    .support::after {
      display: none;
    }
  }
}

@property --read {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

@layer components {
  @keyframes read {
    to {
      --read: 100%;
    }
  }

  nav {
    width: 100%;
    height: 100svh;
    scroll-target-group: auto;
    position: sticky;
    container-type: scroll-state;
    top: 0;

    /* difference blend: dark on paper, light on photos */
    color: white;
    mix-blend-mode: difference;

    .nav__inner {
      width: 100%;
      height: 100%;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    ol {
      padding: 0;
      padding-inline: 1rem;
      list-style-type: none;
      opacity: 0;
      transition: opacity 0.6s ease;
    }

    ol li {
      position: relative;
      display: block;
      margin-block: 0.5rem;
      height: 1rem;
    }

    a {
      color: inherit;
      opacity: 0.55;
      /* centered to match the tooltip */
      display: flex;
      align-items: center;
      height: 100%;
      text-decoration: none;
      transition: opacity 0.3s ease;
      /* faster than the 0.5s default */
      interest-delay-start: 0.1s;
    }

    a:hover,
    a:target-current {
      opacity: 1;
    }

    a::before {
      content: "";
      display: block;
      height: 2px;
      border-radius: 0;
      width: calc(var(--nav-width) / 3);
      background: linear-gradient(
        to right,
        currentColor var(--read),
        color-mix(in srgb, currentColor 35%, transparent) 0
      );
      transform-origin: left center;
      scale: 0.6 1;
      transition: scale 0.3s var(--ease);

      animation: read linear both;
      animation-range: contain 0% contain 100%;
    }

    a:hover::before,
    a:target-current::before {
      scale: 1 1;
    }

    li:nth-child(1) a::before {
      animation-timeline: --ch-1;
    }
    li:nth-child(2) a::before {
      animation-timeline: --ch-2;
    }
    li:nth-child(3) a::before {
      animation-timeline: --ch-3;
    }
    li:nth-child(4) a::before {
      animation-timeline: --ch-4;
    }
    li:nth-child(5) a::before {
      animation-timeline: --ch-5;
    }
    li:nth-child(6) a::before {
      animation-timeline: --ch-6;
    }
    li:nth-child(7) a::before {
      animation-timeline: --ch-7;
    }
    li:nth-child(8) a::before {
      animation-timeline: --ch-8;
    }
    li:nth-child(9) a::before {
      animation-timeline: --ch-9;
    }
  }

  @container scroll-state(stuck: top) {
    nav ol {
      opacity: 1;
    }
  }

  @supports not (container-type: scroll-state) {
    nav ol {
      opacity: 1;
    }
  }
}

@layer components {
  /* interestfor anchors it to its trigger */
  .tip {
    inset: auto;
    margin: 0;
    border: none;
    padding: 0.4em 0.9em;
    border-radius: 0;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    line-height: 1.45;
    background: var(--ink);
    color: var(--paper);
    color: contrast-color(
      var(--ink)
    ); /* black or white, whichever reads better */
    box-shadow: var(--hard-shadow);

    /* closed; scales in from the trigger */
    opacity: 0;
    scale: 0.9;
    transition:
      opacity 0.15s ease,
      scale 0.15s ease,
      overlay 0.15s allow-discrete,
      display 0.15s allow-discrete;

    &:popover-open {
      opacity: 1;
      scale: 1;

      @starting-style {
        opacity: 0;
        scale: 0.9;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      scale: 1;
      transition: none;
    }
  }

  nav .nav__tip {
    position-area: right;
    position-try-fallbacks: flip-inline;
    margin-inline-start: 0.75rem;
    transform-origin: left center;
    white-space: nowrap;
  }

  /* no interestfor (Firefox): show the label on hover/focus with plain CSS */
  @supports not (interest-delay-start: 0s) {
    /* the tip sits inside the nav here, so drop the nav's blend */
    nav {
      color: var(--ink);
      mix-blend-mode: normal;
    }

    nav .nav__tip {
      display: block;
      position: absolute;
      top: 50%;
      left: 100%;
      translate: 0 -50%;
      pointer-events: none;
    }

    nav :is(a:hover, a:focus-visible) + .nav__tip {
      opacity: 1;
      scale: 1;
    }
  }

  .term__tip {
    position-area: block-start;
    position-try-fallbacks: flip-block;
    margin-block: 0.5rem;
    width: max-content;
    max-width: min(18rem, 90vw);
    transform-origin: bottom center;
    text-wrap: pretty;

    strong {
      display: block;
      font-weight: 600;
    }
  }

  .term {
    font: inherit;
    color: inherit;
    padding: 0;
    background: none;
    border: 0;
    cursor: help;
    text-decoration: underline dotted;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 0.22em;
    interest-delay-start: 0.2s;
  }
}

@layer components {
  @keyframes explode {
    to {
      transform: translate(var(--x), var(--y)) rotate(var(--spin));
      opacity: 0;
    }
  }

  header {
    height: 200svh;
    width: 100%;
    overflow-x: clip;
    background-color: var(--color-background);
    view-timeline-name: --header-scroll;
    view-timeline-axis: block;
    margin-block-end: 4rem;

    .header__inner {
      height: 100svh;
      width: 100%;
      position: sticky;
      top: 0;
      overflow: hidden;
    }

    /* the way back out, above the title */
    .header__crumbs {
      position: absolute;
      inset: 0.9rem auto auto clamp(1.25rem, 4vw, 2.5rem); /* lines up with the top bar */
      z-index: 1;
      margin: 0;
      font-family: var(--font-sans);
      font-size: 0.875rem;
      color: var(--muted);

      transition: opacity 0.4s var(--ease);

      a {
        color: var(--ink);
      }
    }

    /* small on purpose */
    .header__text {
      position: absolute;
      inset: 0 max(4%, 1.5rem);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 1rem;
      font-family: var(--font-serif);
      font-size: clamp(1.125rem, 1.025rem + 0.4vi, 1.375rem);
      font-size: --fluid(1.125, 1.375);
      line-height: 1.2;
      color: var(--accent);

      h1 {
        font-size: inherit; /* not the browser's 2em */
        margin: 0;
        font-weight: 400;
        line-height: inherit;
        text-box: none;
      }
    }

    .header__dek {
      margin: 0;
      max-width: 32rem;
      font-size: 1rem;
      font-style: italic;
      line-height: 1;
      text-align: center;
      text-wrap: balance;
      color: color-mix(in oklch, var(--ink) 85%, var(--paper));

      small {
        display: block;
        margin-block-end: 0.5rem;
        font-family: var(--font-sans);
        font-size: 0.875rem;
        letter-spacing: 0.01em;
        color: var(--muted);
        /* Safari hangs the bracket into the margin */
        hanging-punctuation: none;
      }
    }

    /* flex drops whitespace between letter spans */
    .header__letters {
      display: flex;

      > span {
        --i: calc(sibling-index() - 1);

        /* golden angle scatters neighbours */
        --angle: calc(var(--i) * 137.508deg);
        --reach: calc(30vmax + mod(var(--i) * 7, 5) * 10vmax);
        --x: calc(cos(var(--angle)) * var(--reach));
        --y: calc(sin(var(--angle)) * var(--reach));
        --spin: calc((mod(var(--i) * 53, 360) - 180) * 1deg);

        /* scrambled head start */
        --delay: calc(mod(var(--i) * 3, 7) * 3%);

        display: inline-block;
        white-space: pre;

        animation: explode ease-in both; /* loosens slowly, then flies */
        animation-timeline: --header-scroll;
        /* 15% dead zone: iOS Safari can read the top as a little past 0% once its toolbar has collapsed and come back */
        animation-range: contain calc(15% + var(--delay)) contain calc(75% + var(--delay)); /* the last are gone by 93% */
      }
    }
  }

  /* no scroll animations: a one-screen header */
  @supports not (animation-timeline: view()) {
    header {
      height: 100svh;
    }

    header .header__letters > span {
      animation: none;
    }
  }

  /* no sibling-index(): number by hand */
  @supports not (z-index: sibling-index()) {
    header .header__letters > span {
      &:nth-child(1) {
        --i: 0;
      }
      &:nth-child(2) {
        --i: 1;
      }
      &:nth-child(3) {
        --i: 2;
      }
      &:nth-child(4) {
        --i: 3;
      }
      &:nth-child(5) {
        --i: 4;
      }
      &:nth-child(6) {
        --i: 5;
      }
      &:nth-child(7) {
        --i: 6;
      }
      &:nth-child(8) {
        --i: 7;
      }
      &:nth-child(9) {
        --i: 8;
      }
      &:nth-child(10) {
        --i: 9;
      }
      &:nth-child(11) {
        --i: 10;
      }
      &:nth-child(12) {
        --i: 11;
      }
      &:nth-child(13) {
        --i: 12;
      }
      &:nth-child(14) {
        --i: 13;
      }
      &:nth-child(15) {
        --i: 14;
      }
      &:nth-child(16) {
        --i: 15;
      }
      &:nth-child(17) {
        --i: 16;
      }
      &:nth-child(18) {
        --i: 17;
      }
      &:nth-child(19) {
        --i: 18;
      }
      &:nth-child(20) {
        --i: 19;
      }
      &:nth-child(21) {
        --i: 20;
      }
      &:nth-child(22) {
        --i: 21;
      }
      &:nth-child(23) {
        --i: 22;
      }
      &:nth-child(24) {
        --i: 23;
      }
      &:nth-child(25) {
        --i: 24;
      }
      &:nth-child(26) {
        --i: 25;
      }
      &:nth-child(27) {
        --i: 26;
      }
      &:nth-child(28) {
        --i: 27;
      }
      &:nth-child(29) {
        --i: 28;
      }
      &:nth-child(30) {
        --i: 29;
      }
      &:nth-child(31) {
        --i: 30;
      }
      &:nth-child(32) {
        --i: 31;
      }
    }
  }

  /* the top bar sits in the same spot: step aside whenever it shows (same rules as topbar.css) */
  @container scroll-state(scrolled: top) {
    header .header__crumbs {
      opacity: 0;
      pointer-events: none;
    }
  }

  @supports not (container-type: scroll-state) {
    @media (width < 58.5rem) {
      header .header__crumbs {
        display: none;
      }
    }
  }

  :root:has(.topbar:focus-within) header .header__crumbs {
    opacity: 0;
    pointer-events: none;
  }

  /* avoids a screen of empty scrolling */
  @media (prefers-reduced-motion: reduce) {
    header {
      height: 100svh;
    }

    header .header__letters > span {
      animation: none;
    }
  }
}

@layer components {
  .opener {
    margin-block: 4rem 1rem;
  }

  .opener__kicker {
    margin: 0 0 0.5rem;
    color: var(--accent);
  }

  .byline {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* the next chapter's rule frames it */
  }

  .byline__text {
    margin: 0;
    flex: 1;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--muted);
    font-variant-numeric: lining-nums;

    a {
      color: var(--ink);
    }
  }
}

@layer components {
  .settings__toggle {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    font-family: var(--font-serif);
    font-size: 0.9375rem;
    color: var(--ink);
    background: var(--button);
    border: var(--line);
    border-radius: 0;
    cursor: pointer;

    &:hover {
      background: var(--button-hover);
    }
  }

  /* panel anchors to whichever button opened it */
  .settings__open {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.75em;
    margin-block: 0.5rlh 1rlh;
    padding: 0.9em 1.6em;
    font: inherit;
    font-size: 0.8em;
    color: var(--ink);
    background: var(--button);
    border: var(--line);
    border-radius: 0;
    cursor: pointer;

    &:hover {
      background: var(--button-hover);
    }

    span {
      font-family: var(--font-serif);
    }
  }

  .settings {
    inset: auto;
    margin: 0;
    margin-block-start: 0.5rem;
    position-area: block-end span-inline-start;
    position-try-fallbacks: flip-block;

    gap: 0.75rem;
    min-width: 15rem;
    padding: 1.25rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: var(--hard-shadow);

    opacity: 0;
    translate: 0 -0.5rem;
    transition:
      opacity 0.25s ease,
      translate 0.25s var(--ease),
      overlay 0.25s allow-discrete,
      display 0.25s allow-discrete;

    &:popover-open {
      display: grid; /* only when open, so it can still hide */
      opacity: 1;
      translate: 0 0;

      @starting-style {
        opacity: 0;
        translate: 0 -0.5rem;
      }
    }

    .label {
      margin: 0 0 0.25rem;
    }
  }

  .settings__field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
  }

  :is(.settings, .palette) select {
    font: inherit;
    color: inherit;
  }

  /* under 16px, iOS zooms in on focus */
  @media (pointer: coarse) {
    :is(.settings, .palette) select {
      font-size: max(16px, 1em);
    }
  }

  @supports (appearance: base-select) {
    :is(.settings, .palette) select,
    :is(.settings, .palette) ::picker(select) {
      appearance: base-select;
    }

    :is(.settings, .palette) select {
      min-width: 7.5rem;
      padding: 0.35em 0.75em;
      background: var(--tint);
      border: 1px solid var(--rule);
      border-radius: 0;
      cursor: pointer;

      &::picker-icon {
        color: var(--muted);
        transition: rotate 0.25s var(--ease);
      }

      &:open::picker-icon {
        rotate: 180deg;
      }
    }

    :is(.settings, .palette) ::picker(select) {
      padding: 0.25rem;
      margin-block: 0.25rem;
      color: var(--ink);
      background: var(--paper);
      border: 1px solid var(--rule);
      border-radius: 0;
      box-shadow: var(--hard-shadow);

      opacity: 0;
      transition:
        opacity 0.2s ease,
        overlay 0.2s allow-discrete,
        display 0.2s allow-discrete;
    }

    :is(.settings, .palette) select:open::picker(select) {
      opacity: 1;
    }

    @starting-style {
      :is(.settings, .palette) select:open::picker(select) {
        opacity: 0;
      }
    }

    :is(.settings, .palette) option {
      padding: 0.4em 0.75em;
      border-radius: 0;

      &:hover,
      &:focus-visible {
        background: var(--tint);
      }

      &:checked {
        font-weight: 600;
      }

      &::checkmark {
        color: var(--accent);
      }
    }
  }
}

@layer components {
  /* each note follows its paragraph inside .noted */
  main {
    counter-reset: note;
  }

  .note-ref {
    counter-increment: note;
    anchor-name: --note;
    padding: 0 0.1em;
    text-decoration: none;
    vertical-align: super;
    line-height: 0;

    &::after {
      content: counter(note);
      font-family: var(--font-sans);
      font-size: 0.7rem;
      font-weight: 600;
      color: var(--accent);
    }
  }

  .sidenote {
    position: relative;
    display: block;
    margin: -0.25lh 0 1.5rem;
    padding: 2rem 0.9rem 0.9rem;
    border: var(--line);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    line-height: 1.5;
    text-wrap: pretty;
    color: var(--muted);
    scroll-margin-block: 30vh; /* lands the note mid-screen */

    &::before {
      content: counter(note);
      position: absolute;
      inset: 0 0 auto auto;
      padding-inline: 0.5rem;
      border-block-end: var(--line);
      border-inline-start: var(--line);
      font-style: italic;
      color: var(--accent);
    }

    &:target {
      color: var(--ink);
      background: var(--tint);
    }
  }

  /* anchor-scope: each note finds its own marker */
  @media (width >= 84.5rem) {
    @supports (anchor-scope: --a) {
      .noted {
        anchor-scope: --note, --para;

        > p {
          anchor-name: --para;
        }
      }

      .sidenote {
        position: absolute;
        position-anchor: --note;
        top: anchor(--note top);
        /* one gutter past main-end is the rail */
        left: calc(anchor(--para right) + var(--gutter));
        width: var(--rail);
        box-sizing: border-box; /* keeps padding and border inside the rail */
        margin: 0;
      }

      .note-ref {
        pointer-events: none;
      }
    }
  }
}

@layer components {
  .callout {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-self: start;
    margin-block-end: 1.5rem;
    padding: 2.5rem 1rem 1rem;
    border: var(--line);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    line-height: 1.5;
    text-wrap: pretty;
    color: var(--muted);

    /* Narrow: end of section, not mid-paragraphs */
    order: 1;

    > * {
      margin: 0;
    }

    .support {
      margin-inline: 0;
    }

    > .label {
      position: absolute;
      inset: 0 0 auto auto;
      padding-inline: 0.5rem;
      border-block-end: var(--line);
      border-inline-start: var(--line);
    }

    /* two rows, so a tall callout doesn't stretch its own */
    @media (width >= 84.5rem) {
      order: 0;
      grid-row-end: span 2;
      font-size: 0.8125rem;
      /* hangs past the rows instead of pushing them apart */
      margin-block-end: -100vh;
    }
  }

  .callout__key {
    display: grid;
    gap: 0.35rem;
    padding: 0;
    list-style: none;

    > li {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    /* flex centres these, so they can be bigger than the inline badges in this small text */
    .support {
      margin: 0;
      font-size: 0.75rem;
      vertical-align: baseline;
    }
  }
}

@layer components {
  @scope (.pullquote) {
    :scope {
      container-type: inline-size;
      margin-block: 2.5rlh;
      padding-block: 2rem;
      border-block: 1px solid var(--rule);
      quotes: "“" "”";
    }

    blockquote {
      margin-inline: 2.5rem;
    }

    blockquote p {
      margin: 0;
      font-size: clamp(
        1.5rem,
        5.5cqi,
        2.25rem
      ); /* sized by the quote's width */
      font-style: italic;
      font-weight: 400;
      line-height: 1.25;
      text-wrap: balance;
      hyphens: manual;

      &::before {
        content: open-quote;
        margin-inline-start: -0.45em;
        color: var(--accent);
      }

      &::after {
        content: close-quote;
        color: var(--accent);
      }
    }
    .pullquote__by {
      display: flex;
      align-items: center;
      gap: 0.75em;
      margin: 1.25rem 0 0 2.5rem;
      font-family: var(--font-serif);
      font-size: 0.9375rem;
      font-variant-caps: all-small-caps;
      letter-spacing: 0.06em;
      color: var(--muted);

      &::before {
        content: "";
        inline-size: 2rem;
        border-block-start: 1px solid var(--accent);
      }
    }

    figcaption {
      margin-block-start: 1.5rem;
      font-family: var(--font-sans);
      font-size: 0.8125rem;
      color: var(--muted);
    }

    .pullquote__name {
      display: block;
      font-weight: 600;
      color: var(--ink);
    }
  }
}

@layer components {
  :root {
    /* on :root so the box can't override it */
    --page-paper: var(--paper);
    --page-ink: var(--ink);
  }

  .palette option[value="page"] {
    --paper: var(--page-paper);
    --ink: var(--page-ink);
  }

  .palette option[value="sepia"],
  .palette:has(option[value="sepia"]:checked) {
    --paper: oklch(92% 0.012 95);
    --ink: oklch(20% 0.01 80);
  }

  .palette option[value="slate"],
  .palette:has(option[value="slate"]:checked) {
    --paper: oklch(95% 0.015 250);
    --ink: oklch(30% 0.05 255);
  }

  .palette option[value="moss"],
  .palette:has(option[value="moss"]:checked) {
    --paper: oklch(94% 0.025 135);
    --ink: oklch(32% 0.05 150);
  }

  .palette option[value="ember"],
  .palette:has(option[value="ember"]:checked) {
    --paper: oklch(22% 0.03 40);
    --ink: oklch(90% 0.05 70);
  }

  .palette {
    /* re-mixed: :root used the root's colors */
    --muted: color-mix(in oklch, var(--ink) 78%, var(--paper));
    --rule: var(--ink);
    --tint: color-mix(in oklch, var(--ink) 7%, var(--paper));
    --accent: var(--ink);

    display: grid;
    gap: 1.25rem;
    margin-block: 2rlh;
    padding: 1.5rem;
    color: var(--ink);
    background: var(--paper);
    border: var(--line);
    transition:
      color 0.3s ease,
      background-color 0.3s ease;

    figcaption {
      font-family: var(--font-sans);
      font-size: 0.8125rem;
      color: var(--muted);
    }
  }

  .palette__field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
  }

  .palette select {
    min-width: 10rem;
  }

  .palette selectedcontent,
  .palette option {
    display: flex;
    align-items: center;
    gap: 0.6em;
  }

  .palette__chip {
    flex: none;
    inline-size: 1.1em;
    block-size: 1.1em;
    background: linear-gradient(90deg, var(--paper) 50%, var(--ink) 50%);
    border: 1px solid var(--ink);
  }

  .palette__swatches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;

    li {
      display: grid;
      gap: 0.4rem;
      font-size: 0.75rem;
    }

    li::before {
      content: "";
      block-size: 3rem;
      background: var(--swatch);
      border: 1px solid var(--rule);
      transition: background-color 0.3s ease;
    }
  }

  .palette__name {
    display: block;
    font-weight: 600;
    color: var(--ink);
  }

  @media (prefers-reduced-motion: reduce) {
    .palette,
    .palette__swatches li::before {
      transition: none;
    }
  }
}

/* IBM Plex Mono Light (OFL), digits only, ~2 KB */
@font-face {
  font-family: "Plex Mono Digits";
  src: url("data:font/woff2;base64,d09GMgABAAAAAAdYAA0AAAAAEFAAAAcJAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGx4ccgZgADwREAqWfJIGC0IAATYCJANCBCAFgxQHIBuxDCNSk3ogU0fqwp8//37+k1v5/jBr84EYd1GzE9eObYc28dbUkKZK0WaH9N6/ys8shEuR5L1eoKs8fYoTgImapAmEAOyyOSiv6gJuAKt8iq3E/7nfq+/+xmju4/94FGpVWS4isGmAm21URRFlPEAc4E7bRFx2FQPyb9YBBEBhnLcFbduxLwdJSDieTKbV37DnYQeMklM92NViMlsqe9qMILTYW9S0tbfCaett7YKNp7HqCQIO4msSIQlOP68ah4KAHK0ASFFA8xADhBYFqW1v/xgqw1xankwJlqmYMCAMF6gHMAfFmXdv2T+JXmESVkv6/w+QRCMqQCfP00KKJ5bKtBgLdaDxzI5nJZMkMQviGjmjk7D64ZlJWJQp7L8fofF3NpCEwlDEMhkM2VsntbCptBww3pt+eQ5olZZVcNB9gK6eLWN/Kkhp2rY5YRXL2RPs1ATbnmAHRB43hzA5GxkjJft1ODEkXmXFzEodUjpiL4Dr53kRUTpU2gfcoFhfCVhX2bt8hUtMHFM5G/JZMoaYlP/zt8qiPWff/kS2/PaLh3Ks+rAyb83Zl1+P4fulbz37NA3nPz+/Ddf/5SsdfnkxZuP1gIHXVGSRSfUsGApVlqGazYKsmzSHAm+r7z265Owotip1GMq/fhTt5W++709CmXjkOdtzswlFFhoqdfgnWZBPH56+7DYE5sTi1THdru/7u9TPKIqmZl8TSUvE8hd/cRDkwCbWvyy8Rd7AK9brfH0COQnH648Vs5EzJ//ZH1qcf/UuUfqG0s9GrTh59epD9n7DfbUqh6Hq9Y8xa08/Zu8pUVopGu7wROl5c65+Ze873GfTcP85XL9eUT7jHVVmklQOErw84YXSj5wV+QyVw2efkrb5QvZ6+3Imf/MnZZ04DkBrngHu82ZCWUaBykovV3oI2X/JtD7KDCwdsjCrngFg5llpJdh275nXsPGM8+F7rLxywaeQn42erxJRZFUU0yOhT64eeXtwQ4rvkTfuUq54U/y39GunroGMuEljT5w4MfbEpP5BEwtahYXTOqcKi1pbhUVTO6cJC1siLZJKpZIszr8GaC283xpx+bD+1pG2+dcLgfZW1e/POVW9Jdo6Mkg2BuvNcIc5QJlz84M2wkJm0YGJ/1/dXgDUC2iusSyhEtXWVFP5LfdOkkm16rRM2tjuqE3zNjWl3wp/N3nJtJQsJ31csBWmE6rOTX+u3ubyYbMShCoo0hwuBAtWdxfVfxf/DMsbtrr3WvqNMPBtXqXex+5t9JVmB22yHeUXOPjDgrMwDarQpj8PbqN8iESFVFG8hGwbwam7JabJw0BmXKnoK4O2zjIuczE5qgMnogOtDIEzB27nbpeKa3OC9vF2lFfg5DcLrnwky5SGkmXEyDKloWQZHLPNE1YW37hVZJoLMuLKsP26g8ygEIaJUSugVMOO6hwcHNXJ1kBpRRRMRJjKcJDXsX021xmoNdZ10DzfQdcZazsDbBfFwXJNOQ9Jkvd/CwdB0k0uczE1qh0nog1tDIGz+u/UCoQc3qagVPSVQlvn64uSodQepFgmxXxARj9RiSWxEhNEJRalSgx9mXRhQSGdmQhnjEzcEh0VvSXxLwcXVgyFDBY4x1R+6GKTZ/6BvXM6Ss4/0JFrfzQxETY3Jtpfm6rnMW5j8a4wL+a4+QfMy5zafmpfzTUxazSQeyVYWZhb2mnJtfQF9w0/FPU2rseshIqzEnWnqX2QO8k7ttouuev/1NXMNcK+5qhk/Ah2ZU5pL5RXcwSLTkOZUYqZrmhz+8SDFy3Wqoakl8MNnNc6uwb741jmHRTsZ64ZHH6pIehAdPz1oH2HjZ3WO7kG+42azDJWGc8yNpll/ATdsxdEWte/sxq1cMS2LCDI3cZ0nUL6Q0vf8oSX1wlLfa0fUsU6U5sgd/9T5n66Ch0/c2NzHYWun9kyy2V6Kv1llsZa9FV6y3hYw8LizXwDFppB4bcKpMvZzaWt7HMlmMljrTCZlHD5ZYqRiVopSTY7jxyjfnicmDP7T/W/Kpzi91Wpkrw4ytz1k/zrt7w/U//Af+W/VeIeaZppVeleWgydjtZHnPVf+V8p7tGwDMVrisRZCAQQSgzeWBJPNBEEEMsWNrODbazlAPs4yFZ3yL1OrmZB9AMbqrTPfrZO84soqRjdUpVPy+EKV4QF27hiJrOCK8GNuvHSe64MTTLCckx8nXnbybgBVbTRRhM+OOJIK6W0UE0TbTbJgdbb1uFAIy1U4kgiEcQRTQjxJFFHOV3eVo000Ig9cVTbGmrVDMppwdScNwu44IBra/fFdQrjsKlAisps204dxbRgGcBOwRcV6kNppInuR+h2Gu5tnXDGEwFfAzC3+GUHBIJtc13SD2xtXUXLaX1EfQfllOGgl6vD4v9SbP8g+hc=") format("woff2");
  font-weight: 300;
  font-display: swap;
  unicode-range: U+30-39;
}

@property --num {
  syntax: "<integer>";
  inherits: false;
  initial-value: 0;
}

@layer components {
  @keyframes count-up {
    from {
      --num: 0;
    }
    to {
      --num: var(--to);
    }
  }

  .stat {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: end;
    gap: 1rem 2.5rem;
    margin-block: 2rlh;
  }

  /* mono, so digits don't jiggle */
  .stat__value {
    margin: 0;
    /* at this size the font's side bearing shows; pull the first digit back to the text edge */
    margin-inline-start: -0.11em;
    font-family: "Plex Mono Digits", var(--font-mono);
    font-size: clamp(5rem, 3rem + 8vi, 10rem);
    font-size: --fluid(5, 10);
    font-weight: 300;
    line-height: 0.8;
    letter-spacing: -0.02em;
    font-variant-numeric: lining-nums tabular-nums;
    text-box: trim-both cap alphabetic;
  }

  .stat__unit {
    font-size: 0.5em;
    color: var(--accent);
    vertical-align: top;
  }

  .stat__caption {
    max-width: 24ch;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--muted);
    text-wrap: pretty;
  }

  /* needs typed attr() and scroll timelines */
  @supports (animation-timeline: view()) and (width: attr(x type(<length>))) {
    .stat__num {
      /* 1ch is one digit: room for three */
      display: inline-block;
      min-inline-size: 3ch;
      text-align: end;
      --to: attr(data-value type(<integer>), 0);
      counter-reset: n var(--num);
      animation: count-up cubic-bezier(0.1, 0.6, 0.2, 1) both;
      animation-timeline: view();
      animation-range: entry 40% cover 50%;

      &::after {
        /* empty alt: screen readers skip the ticking */
        content: counter(n) / "";
      }
    }

    .stat__static {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }
  }

  @media (width < 40rem) {
    .stat {
      grid-template-columns: 1fr;
    }
  }

  @keyframes bar-grow {
    from {
      scale: 0 1;
    }
  }

  .bars {
    margin-block: 2rlh;
  }

  .bars__caption {
    display: grid;
    gap: 0.4rem;
    margin-block-end: 1.25rem;
  }

  .bars__note {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--muted);
  }

  /* widest label sets the column for every row */
  .bars__list {
    display: grid;
    grid-template-columns: max-content 1fr max-content;
    gap: 0.45rem 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
  }

  .bars__list li {
    --value: attr(data-value type(<number>), 0);
    --i: sibling-index();

    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: center;
    line-height: 1;

    &::before {
      content: "";
      grid-column: 2;
      grid-row: 1;
      height: 1.25rem;
      width: calc(var(--value) * 1%);
      background: color-mix(in oklch, var(--ink) 18%, var(--paper));
      border-radius: 0;
      transform-origin: left center;
    }
  }

  /* no typed attr(): set widths by hand */
  @supports not (width: attr(x type(<length>))) {
    .bars__list li {
      &:nth-child(1) { --value: 20; }
      &:nth-child(2) { --value: 100; }
      &:nth-child(3) { --value: 78; }
      &:nth-child(4) { --value: 29; }
      &:nth-child(5) { --value: 10; }
      &:nth-child(6) { --value: 10; }
    }
  }

  .bars__label {
    grid-column: 1;
    grid-row: 1;
    color: var(--muted);
  }

  .bars__value {
    grid-column: 3;
    grid-row: 1;
    text-align: end;
    font-weight: 500;
  }

  @supports (animation-timeline: view()) {
    .bars__list li::before {
      animation: bar-grow var(--ease) both;
      animation-timeline: view();
      animation-range: entry calc(30% + var(--i) * 8%) cover
        calc(40% + var(--i) * 4%);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .bars__list li::before,
    .stat__num {
      animation: none;
    }

    .stat__num {
      counter-reset: n var(--to);
    }
  }
}

@layer components {
  /* both ends spelled out: inset() can't interpolate to none */
  @keyframes line-draw {
    from {
      clip-path: inset(0 100% 0 0);
    }
    to {
      clip-path: inset(0);
    }
  }

  @keyframes tag-in {
    from {
      opacity: 0;
    }
  }

  .linechart {
    margin-block: 2rlh;
    font-family: var(--font-sans);
  }

  .linechart__caption {
    display: grid;
    gap: 0.4rem;
    margin-block-end: 1rem;
  }

  .linechart__note {
    font-size: 0.75rem;
    color: var(--muted);
  }

  .linechart__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    margin: 0 0 1.25rem;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);

    li {
      display: flex;
      align-items: center;
      gap: 0.4rem;
    }

    svg {
      inline-size: 1.75rem;
      block-size: 0.25rem;
      overflow: visible;
      stroke: var(--ink);
      stroke-width: 2;
      stroke-linecap: round; /* matches the chart lines, so dots show */
    }
  }

  /* the drawing stretches to fill the box; text sits on top in HTML so it doesn't */
  .linechart__plot {
    position: relative;
    block-size: clamp(14rem, 40vi, 22rem);
    margin-block-end: 2rem; /* room for the month labels */
  }

  /* each span ends on its gridline, with the number sitting just above it */
  .linechart__grid span {
    position: absolute;
    inset-inline: 0;
    inset-block-start: var(--y);
    padding-block-end: 0.2rem;
    font-size: 0.6875rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    border-block-end: 1px solid var(--highlight);
    translate: 0 -100%;

    &:first-child {
      border-color: var(--ink); /* the baseline */
    }
  }

  .linechart__lines {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    overflow: visible;
    fill: none;
    stroke: var(--ink);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;

    path {
      vector-effect: non-scaling-stroke; /* keeps 2px lines and px dashes when stretched */
    }
  }

  .linechart__tag {
    position: absolute;
    inset-inline-start: var(--x);
    inset-block-start: var(--y);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    translate: 0.6rem -120%;

    &[data-side="start"] {
      translate: calc(-100% - 0.6rem) -120%;
    }
  }

  /* twelve columns, one per month, centered on the points */
  .linechart__months {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    margin: 0;
    padding: 0;
    list-style: none;

    li {
      position: relative;

      /* crosshair */
      &::before {
        content: "";
        position: absolute;
        inset-block: 0;
        inset-inline-start: 50%;
        border-inline-start: 1px solid var(--ink);
        opacity: 0;
      }

      &:hover::before {
        opacity: 0.4;
      }

      &:hover .linechart__tip {
        display: block;
      }

      /* the right half opens its tip to the left */
      &:nth-child(n + 7) .linechart__tip {
        inset-inline: auto 50%;
      }
    }
  }

  .linechart__month {
    position: absolute;
    inset-block-start: calc(100% + 0.5rem);
    inset-inline: 0;
    font-size: 0.6875rem;
    text-align: center;
    color: var(--muted);
  }

  .linechart__tip {
    display: none;
    position: absolute;
    z-index: 1;
    inset-block-start: 0;
    inset-inline-start: 50%;
    margin-inline: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: nowrap;
    background: var(--paper);
    border: var(--line);

    dl {
      display: grid;
      grid-template-columns: auto auto;
      gap: 0 1rem;
      margin: 0.25rem 0 0;
      font-variant-numeric: tabular-nums;
    }

    dt {
      color: var(--muted);
    }

    dd {
      margin: 0;
      text-align: end;
    }
  }

  @supports (animation-timeline: view()) {
    .linechart__lines {
      animation: line-draw linear both;
      animation-timeline: view();
      animation-range: entry 100% cover 60%;
    }

    .linechart__tag {
      animation: tag-in linear both;
      animation-timeline: view();
      animation-range: cover 58% cover 64%;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .linechart__lines,
    .linechart__tag {
      animation: none;
    }
  }
}

@layer components {
  /* data-span picks the column via attr() + if() */
  .figure {
    --span: attr(data-span type(<custom-ident>), main);
    grid-column: if(
      style(--span: full): full; style(--span: wide): wide; else: main
    );
    margin-block: 2rlh;
  }

  /* fallback without if() */
  @supports not (color: if(else: red)) {
    .figure[data-span="wide"] {
      grid-column: wide;
    }

    .figure[data-span="full"] {
      grid-column: full;
    }
  }

  .figure img {
    width: 100%;
    height: auto;
  }

  .figure__caption {
    margin-block-start: 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted);
    text-wrap: pretty;
  }

  .credit {
    display: block;
    margin-block-start: 0.25rem;
    font-size: 0.75rem;
    font-style: italic;
  }

  @media (width >= 84.5rem) {
    .figure[data-span="wide"] {
      display: grid;
      grid-template-columns: subgrid;
      align-items: end;

      :is(img, .ascii) {
        grid-column: wide-start / main-end;
        grid-row: 1;
      }

      .figure__caption {
        grid-column: rail;
        grid-row: 1;
        margin: 0;
        padding-block-start: 0.75rem;
        border-block-start: 1px solid var(--rule);
      }
    }
  }

  @keyframes drift {
    from {
      translate: 0 var(--drift);
    }
    to {
      translate: 0 0;
    }
  }

  .figure--parallax {
    /* a short window, so the drawing has plenty of room to move behind it */
    .figure__frame {
      height: min(60vh, 45vw);
      overflow: hidden;
      view-timeline: --frame;
    }

    /* room to drift */
    img {
      --drift: -16.5%;
      height: 120%;
      object-fit: cover;
      translate: 0 -8%;
    }

    /* the drawing is ~0.76× as tall as it is wide, so a 45vw window leaves 40% of it to travel */
    .ascii {
      --drift: -40%;
      translate: 0 -20%;
    }

    .figure__caption {
      max-width: var(--measure);
      margin-inline: auto;
      padding-inline: 1.25rem;
    }
  }

  @supports (animation-timeline: view()) {
    .figure--parallax :is(img, .ascii) {
      animation: drift linear both;
      animation-timeline: --frame;
    }
  }

  :root:has(select[name="theme"] option[value="dark"]:checked)
    main
    img:not(.lightbox *) {
    filter: var(--photo-filter) brightness(0.88);
  }

  @media (prefers-color-scheme: dark) {
    :root:has(select[name="theme"] option[value="system"]:checked)
      main
      img:not(.lightbox *) {
      filter: var(--photo-filter) brightness(0.88);
    }
  }

  /* never 3 columns, so 8 photos fill whole rows */
  .mosaic {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;

    @media (width >= 38rem) {
      grid-template-columns: repeat(3, 1fr);
    }
    margin-block: 2rlh;

    figure {
      margin: 0;
    }

    .mosaic__open img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      border-radius: 0;
    }
  }

  /* Firefox's older syntax */
  @supports (grid-template-rows: masonry) {
    .mosaic {
      grid-template-rows: masonry;

      .mosaic__open img {
        height: auto;
      }
    }
  }

  @supports (display: grid-lanes) {
    .mosaic {
      display: grid-lanes;

      .mosaic__open img {
        height: auto;
      }
    }
  }

  .mosaic__open {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    overflow: hidden;
    cursor: zoom-in;

    img {
      display: block;
      transition: scale 0.6s var(--ease);
    }

    &:hover img {
      scale: 1.03;
    }

    &:focus-visible {
      outline-offset: 3px;
    }
  }

  /* contained photo over a blurred cover copy */
  .lightbox {
    --duration: 0.45s;

    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    color: white;
    background: oklch(12% 0 0);

    /* closed, and where the exit ends */
    opacity: 0;
    scale: 1.03;
    transition:
      opacity var(--duration) var(--ease),
      scale var(--duration) var(--ease),
      overlay var(--duration) allow-discrete,
      display var(--duration) allow-discrete;

    &[open] {
      opacity: 1;
      scale: 1;

      @starting-style {
        opacity: 0;
        scale: 1.03;
      }
    }

    &::backdrop {
      background: oklch(12% 0 0);
    }
  }

  .lightbox__stage {
    position: absolute;
    inset: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-out;
  }

  .lightbox__fill,
  .lightbox__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .lightbox__fill {
    object-fit: cover;
    filter: var(--photo-filter) blur(40px) brightness(0.55);
    scale: 1.15; /* hides the blur's soft edges */
  }

  .lightbox__img {
    object-fit: contain;
  }

  .lightbox__caption {
    position: absolute;
    inset: auto 0 0;
    margin: 0;
    padding: 4rem clamp(1.25rem, 4vw, 3rem) 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.5;
    color: oklch(100% 0 0 / 0.8);
    background: linear-gradient(transparent, oklch(0% 0 0 / 0.65));
    pointer-events: none;

    strong {
      display: block;
      font-family: var(--font-serif);
      font-size: 1.375rem;
      font-weight: 400;
      color: white;
    }

    a {
      color: white;
      pointer-events: auto;
    }
  }

  .lightbox__close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
    color: white;
    background: oklch(0% 0 0 / 0.35);
    backdrop-filter: blur(8px);
    border: 1px solid oklch(100% 0 0 / 0.25);
    border-radius: 0;
    cursor: pointer;
    transition: rotate 0.4s var(--ease);

    &:hover {
      rotate: 90deg;
    }

    &:focus-visible {
      outline-color: white;
    }
  }

  html:has(.lightbox[open]) {
    overflow: hidden;
    scrollbar-gutter: stable;
  }

  @media (prefers-reduced-motion: reduce) {
    .figure--parallax :is(img, .ascii) {
      animation: none;
      translate: none;
    }

    .lightbox {
      scale: 1;
      transition-duration: 0.01s;
    }

    .mosaic__open img {
      transition: none;
    }
  }
}

@layer components {
  /* subgrid, so bars match the real columns */
  .grid-demo {
    display: grid;
    grid-template-columns: subgrid;
    row-gap: 0.5rem;
    margin: 2rlh 0;
  }

  .grid-demo__area {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    align-content: start;
    gap: 0.25rem 0.75rem;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    line-height: 1.2;
    border: var(--line);

    strong {
      font-family: var(--font-display);
      font-size: 1rem;
      font-weight: 700;
    }

    code {
      font-family: var(--font-mono);
      font-size: 0.75rem;
      color: var(--muted);
    }

    /* full-width line under the name and code */
    .grid-demo__desc {
      flex-basis: 100%;
      margin: 0;
      line-height: 1.35;
    }

    &[data-area="full"] {
      grid-column: full;
      border-inline: 0;
    }

    &[data-area="wide"] {
      grid-column: wide;
    }

    &[data-area="main"] {
      grid-column: main;
      background: var(--tint);
    }

    &[data-area="rail"] {
      grid-column: rail;
    }

    &[data-area="nav"] {
      grid-column: nav;
    }
  }

  .grid-demo__caption {
    grid-column: main;
  }

  @media (width < 58.5rem) {
    .grid-demo__area[data-area="nav"] {
      display: none;
    }
  }
}

@layer components {
  /* grid items can't float, so float inside the wrapper */
  .wrap {
    display: flow-root; /* contains the float */
    container-type: inline-size;
  }

  /* margin leaves room for shape-margin */
  .wrap__photo {
    float: left;
    float: inline-start;
    inline-size: 40%;
    aspect-ratio: 1;
    margin-block: 0.25lh 0.5lh;
    margin-inline-end: 1.25rem;
    object-fit: cover;
    clip-path: circle(50%);
    shape-outside: circle(50%) border-box;
    shape-margin: 1.25rem;
    filter: var(--photo-filter);
  }

  @container (width < 24rem) {
    .wrap__photo {
      float: none;
      display: block;
      inline-size: min(100%, 14rem);
      margin-inline: auto;
      margin-block-end: 1lh;
    }
  }
}

@layer components {
  /* All frames stacked; steps() flips through them */
  @keyframes ascii-reel {
    to {
      translate: 0 -100%;
    }
  }

  .ascii {
    container-type: inline-size;
    overflow: hidden;
    color: var(--ink);
    background: var(--tint);
    filter: none; /* keep the characters at full contrast */
  }

  .ascii__window {
    /* mono chars are ~0.6em wide */
    font-size: calc(100cqi / (var(--cols) * 0.61));
    block-size: calc(var(--rows) * 1em);
    overflow: hidden;
  }

  .ascii__reel {
    margin: 0;
    font-family: var(--font-mono);
    font-size: inherit;
    line-height: 1;
    white-space: pre;
    animation: ascii-reel calc(var(--frames) * 0.5s) steps(var(--frames)) infinite;
  }

  .ascii--fin {
    inline-size: min(100%, 36rem);
    margin-inline: auto;
    color: var(--muted);
    background: none;
  }

  @media (prefers-reduced-motion: reduce) {
    .ascii__reel {
      animation: none;
    }
  }
}

@layer components {
  .detour {
    margin-block: 2rlh;
    padding-block: 0.5rlh 2rlh;
    background: var(--tint);
    border-block: var(--line);

    > .detour__label {
      margin-block: 1.5rlh 0;
      color: var(--muted);
    }

    > .detour__label + .section__title {
      margin-block-start: 0.25rlh;
    }
  }
}

@layer components {
  grid-builder {
    display: grid;
    /* minmax(0, …) so wide content scrolls instead of stretching */
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    margin-block: 2rlh;
  }

  .grid-builder__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8rem;
    gap: 1rem;
    font-family: var(--font-sans);

    @media (width < 40rem) {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  .grid-builder__field {
    display: grid;
    gap: 0.4rem;
    min-inline-size: 0;

    > .label {
      font-family: var(--font-mono);
      font-weight: 500;
    }
  }

  .grid-builder__field input {
    box-sizing: border-box;
    inline-size: 100%;
    padding: 0.6rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ink);
    background: var(--paper);
    border: var(--line);
    border-radius: 0;

    &[aria-invalid] {
      border-style: dashed;
      text-decoration: wavy underline var(--muted);
    }

    /* under 16px, iOS zooms in on focus */
    @media (pointer: coarse) {
      font-size: max(16px, 0.8125rem);
    }
  }

  .grid-builder__presets {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    border: 0;

    > legend {
      float: left; /* legend joins the button row */
      margin-inline-end: 0.25rem;
    }
  }

  /* the radio is hidden; its label looks like a button */
  .grid-builder__presets input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  :is(.grid-builder__presets label, .grid-builder__copy) {
    padding: 0.35rem 0.7rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.3s ease;

    &:hover {
      background: var(--tint);
    }
  }

  .grid-builder__presets label {
    position: relative; /* holds the hidden radio */

    &:has(:checked) {
      background: var(--tint);
      border-color: var(--ink);
    }

    &:has(:focus-visible) {
      outline: 2px solid var(--ink);
      outline-offset: 2px;
    }
  }

  .grid-builder__status {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--muted);

    &:empty {
      display: none;
    }
  }

  /* Every preset has a preview pane and a code pane. The picked one's panes open to height: auto,
     the rest close to 0. The bordered boxes around them stay whole, so their borders never clip */
  .grid-builder__pane {
    block-size: 0;
    overflow: clip;
    opacity: 0;
    visibility: hidden; /* keeps closed panes out of tab order and screen readers */
    /* stacked panes: the box grows or shrinks by exactly the difference, so same-height code doesn't move */
    transition:
      block-size 0.5s var(--ease),
      opacity 0.2s,
      visibility 0.5s;

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

  /* previews are nearly always the same height, so they crossfade in place instead */
  .grid-builder__previews {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: clip;
    /* the cells draw the sides, so every line is a single 1px, like the code block */
    border-block: var(--line);

    > .grid-builder__pane {
      grid-area: 1 / 1;
      overflow: visible; /* the closing one fades out over the new one */
      transition:
        opacity 0.3s,
        visibility 0.3s;
    }
  }

  /* one line per preset in presets.js */
  grid-builder {
    &:has([value="0"]:checked) [data-preset="0"],
    &:has([value="1"]:checked) [data-preset="1"],
    &:has([value="2"]:checked) [data-preset="2"],
    &:has([value="3"]:checked) [data-preset="3"],
    &:has([value="4"]:checked) [data-preset="4"],
    &:has([value="5"]:checked) [data-preset="5"],
    &:has([value="6"]:checked) [data-preset="6"],
    &:has([value="7"]:checked) [data-preset="7"],
    &:has([value="custom"]:checked) [data-preset="custom"] {
      block-size: auto;
      opacity: 1;
      visibility: visible;
    }
  }

  .grid-builder__preview {
    display: grid;
    min-block-size: 7rem;
    overflow-x: auto;
    background: repeating-linear-gradient(-45deg, var(--rule) 0 1px, transparent 0 6px);
  }

  .grid-builder__cell {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-inline-size: 0;
    padding: 0.5rem;
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    line-height: 1.3;
    background: var(--paper);
    border-inline: var(--line);
    /* neighbours overlap by a pixel, so touching cells share one line */
    margin-inline-end: -1px;

    &:last-child {
      margin-inline-end: 0;
    }
  }

  .grid-builder__lines {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
    overflow-wrap: anywhere;
  }

  .grid-builder__size {
    padding: 0;
    font-size: 0.8125rem;
    background: none;
    color: var(--ink);
    overflow-wrap: anywhere;
  }

  .grid-builder__px {
    margin-block-start: auto;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
  }

  @container (width < 5rem) {
    :is(.grid-builder__lines, .grid-builder__size) {
      display: none;
    }
  }

  @container (width < 2.5rem) {
    .grid-builder__px {
      display: none;
    }
  }

  /* outweighs code.css, which loads later */
  grid-builder .grid-builder__output {
    margin: 0;
  }

  .grid-builder__copy {
    margin-inline-start: auto;
    border-color: var(--ink);

    &:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }
  }

  /* no script: the presets still switch, but there's no typing or copying */
  grid-builder:not(:defined) :is(.grid-builder__form, .grid-builder__copy, .grid-builder__mine) {
    display: none;
  }
}

@layer components {
  /* Frames overlap: a curtain wipe, or a cross-fade with scroll timelines */
  @keyframes frame-in {
    from {
      opacity: 0;
    }
  }

  .essay {
    --frame: 300svh; /* how long a photo pins (svh: dvh resizes the page as the iOS toolbar moves) */
    --overlap: 100svh; /* overlap with the previous frame */
    --card-at: 100svh; /* caption position in the frame */

    grid-column: full;
    margin-block: 3rlh;
    isolation: isolate;
    background: oklch(15% 0 0);
  }

  .essay__frame {
    position: relative;
    height: var(--frame);
    margin: 0;
    view-timeline-name: --frame;

    & + & {
      margin-block-start: calc(-1 * var(--overlap));
    }

    &:last-child {
      height: calc(var(--card-at) + 100lvh);
    }
  }

  .essay__pin {
    position: sticky;
    top: 0;
    z-index: 1;
    height: 100lvh; /* fills the screen with the toolbar shown or hidden */
    overflow: hidden;
  }

  .essay__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .essay__caption {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
  }

  .essay__card {
    position: absolute;
    top: var(--card-at);
    left: clamp(1.25rem, 8vw, 8rem);
    translate: 0 -50%;
    max-width: min(24rem, 100% - 2.5rem);
    padding: 1.5rem 1.75rem;
    color: var(--ink);
    /* mostly opaque so text reads over busy photos; the photo still hints through */
    background: color-mix(in oklch, var(--paper) 80%, transparent);
    backdrop-filter: blur(12px) saturate(1.3);
    border: 1px solid color-mix(in oklch, var(--paper) 80%, transparent);
    border-radius: 0;
    box-shadow: var(--hard-shadow);
    pointer-events: auto;

    p {
      margin: 0;
      font-family: var(--font-sans);
      font-size: 0.9375rem;
      line-height: 1.55;
    }

    .label {
      margin-block-end: 0.75rem;
      color: var(--accent);
    }
  }

  .essay__frame:nth-child(even) .essay__card {
    left: auto;
    right: clamp(1.25rem, 8vw, 8rem);
  }

  /* fades in over the first half of its pin */
  @supports (animation-timeline: view()) {
    .essay {
      --overlap: 200svh;
      --card-at: 125svh;
    }

    .essay__frame:not(:first-child) .essay__img {
      animation: frame-in linear both;
      animation-timeline: --frame;
      /* frame top hits screen top; photo pins */
      animation-range: cover 100svh cover 150svh;
    }
  }
}

@property --fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@layer components {
  .compare {
    --hover: color-mix(
      in oklch,
      var(--ink) 4%,
      var(--paper)
    ); /* opaque, for sticky headers */

    margin-block: 2rlh;
  }

  /* right edge fades while there's more to see */
  @keyframes edge-fade {
    0%,
    92% {
      --fade-end: 3rem;
    }
    100% {
      --fade-end: 0px;
    }
  }

  .compare__scroll {
    mask-image: linear-gradient(
      to right,
      black calc(100% - var(--fade-end)),
      transparent
    );

    &:focus-visible {
      outline-offset: 6px;
    }
  }

  @supports (animation-timeline: scroll()) {
    .compare__scroll {
      animation: edge-fade linear both;
      animation-timeline: scroll(
        self inline
      ); /* only when it overflows */
    }
  }

  .compare__table {
    width: 100%;
    min-width: 44rem;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums lining-nums;
    line-height: 1.3;
  }

  .compare__caption {
    padding-block-end: 1.5rem;
    font-family: var(--font-sans);
  }

  .compare__title {
    display: block;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink);
  }

  .compare__sub {
    display: block;
    margin-block-start: 0.35rem;
    font-size: 0.8125rem;
    color: var(--muted);
  }

  .compare__table :is(th, td) {
    padding: 0.85rem 1rem;
    text-align: end;
    vertical-align: top;
    border-block-end: 1px solid var(--rule);
    transition: background-color 0.2s ease;
  }

  .compare__table thead :is(th, td) {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--paper);
  }

  .compare__table thead th {
    font-weight: 600;
    color: var(--ink);
    vertical-align: bottom;
    border-block-end-color: var(--ink);

    span {
      display: block;
      margin-block-start: 0.2rem;
      font-size: 0.75rem;
      font-weight: 400;
      font-style: italic;
      color: var(--muted);
    }
  }

  .compare__table thead td {
    border-block-end-color: var(--ink);
  }

  .compare__table tbody th[scope="row"] {
    text-align: start;
    font-weight: 500;
    color: var(--ink);
    min-width: 13rem;

    span {
      display: block;
      margin-block-start: 0.15rem;
      font-size: 0.75rem;
      font-weight: 400;
      color: var(--muted);
    }

    sup {
      font-size: 0.65em;
      margin-inline-start: 0.15em;

      a {
        color: var(--accent);
        text-decoration: none;
      }
    }
  }

  .compare__group :is(th, td) {
    padding-block: 1.75rem 0.5rem;
    border-block-end: 0;
  }

  .compare__group th {
    text-align: start;
    font-size: 0.875rem;
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
  }

  tbody:first-of-type .compare__group :is(th, td) {
    padding-block-start: 1rem;
  }

  .compare__table td small {
    margin-inline-start: 0.3em;

    /* tight around the slash in Aug/Sep */
    &.compare__or {
      margin-inline: 0.1em;
    }
    font-size: 0.75em;
    color: var(--muted);
  }

  .compare__dot {
    display: inline-grid;
    place-items: center;
    inline-size: 2em;
    block-size: 2em;
    border: var(--line);
    border-radius: 50%;
    /* Times has lining figures, which center in circles */
    font-family: "Times New Roman", Times, serif;
    font-variant-numeric: lining-nums tabular-nums;
    line-height: 1;
    text-box: trim-both cap alphabetic;
  }

  /* :has() tracks the hovered column */
  .compare__table tbody tr:not(.compare__group):hover > * {
    background-color: var(--hover);
  }

  .compare__table:has(tbody td:nth-child(2):hover) :is(td, th):nth-child(2),
  .compare__table:has(tbody td:nth-child(3):hover) :is(td, th):nth-child(3),
  .compare__table:has(tbody td:nth-child(4):hover) :is(td, th):nth-child(4),
  .compare__table:has(tbody td:nth-child(5):hover) :is(td, th):nth-child(5),
  .compare__table:has(tbody td:nth-child(6):hover) :is(td, th):nth-child(6) {
    background-color: var(--hover);
  }

  .compare__table tfoot td {
    padding: 1rem 0 0;
    text-align: start;
    border: 0;
  }

  .compare__notes {
    margin: 0;
    padding: 0;
    list-style: lower-alpha inside;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);

    li {
      text-wrap: pretty;
    }

    li:target {
      color: var(--ink);
      background: var(--accent-wash);
    }

    ::marker {
      color: var(--accent);
      font-weight: 600;
    }
  }

  /* sideways only, so vertical swipes reach the page */
  @media (width < 64rem) {
    .compare__scroll {
      overflow-x: auto;
      overflow-y: hidden;
      overscroll-behavior-x: contain;
    }

    .compare__table thead td {
      left: 0;
      z-index: 3;
    }

    .compare__table tbody th[scope="row"],
    .compare__group th {
      position: sticky;
      left: 0;
      z-index: 1;
      background-color: var(--paper);
    }

    .compare__table tbody th[scope="row"] {
      min-width: 10rem;
    }

    .compare__notes {
      position: sticky;
      left: 0;
      max-width: calc(100vw - 2.5rem);
    }
  }

  @media (width < 40rem) {
    .compare__table {
      min-width: 0;
      font-size: 0.8125rem;
    }

    .compare__table :is(th, td) {
      padding: 0.65rem 0.5rem;
    }

    .compare__table :is(thead, tbody) :is(th, td):not(:first-child) {
      min-width: 5.5rem;
    }

    .compare__table tbody th[scope="row"],
    .compare__group th {
      width: 6.5rem;
      min-width: 6.5rem;
      padding-inline-start: 0;
      /* keeps scrolled cells from blending in */
      box-shadow: inset -1px 0 var(--rule);
    }

    .compare__table thead td {
      box-shadow: inset -1px 0 var(--rule);
    }

    .compare__table tbody th[scope="row"] span {
      font-size: 0.6875rem;
      line-height: 1.3;
    }

    .compare__group :is(th, td) {
      padding-block: 1.25rem 0.35rem;
    }

    .compare__dot {
      inline-size: 1.75em;
      block-size: 1.75em;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .compare__table :is(th, td) {
      transition: none;
    }
  }
}

@property --code-fade {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@layer components {
  .code {
    /* one lightness, so every hue weighs the same */
    --tok-at: light-dark(oklch(50% 0.17 350), oklch(78% 0.12 350));
    --tok-selector: light-dark(oklch(47% 0.13 255), oklch(79% 0.09 255));
    --tok-pseudo: light-dark(oklch(50% 0.1 200), oklch(80% 0.08 200));
    --tok-var: light-dark(oklch(48% 0.15 300), oklch(79% 0.1 300));
    --tok-fn: light-dark(oklch(52% 0.13 50), oklch(80% 0.1 60));
    --tok-num: light-dark(oklch(50% 0.12 150), oklch(80% 0.1 150));
    --tok-string: light-dark(oklch(52% 0.1 110), oklch(82% 0.09 110));

    --code-bg: color-mix(in oklch, var(--ink) 3.5%, var(--paper));
    --mark-bg: color-mix(in oklch, var(--ink) 8%, var(--code-bg));
    --gutter: 3.25rem;

    position: relative;
    margin-block: 2rlh;
    border: var(--line);
    border-radius: 0;
    background-color: var(--code-bg);
    overflow: clip;
  }

  .code__bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem 0.7rem 1.25rem;
    border-block-end: var(--line);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
  }

  .code__lang {
    position: absolute;
    inset-block-start: -1px;
    inset-inline-end: -1px;
    padding: 0.2rem 0.55rem;
    font-family: var(--font-serif);
    font-weight: 400;
    border: var(--line);
  }

  .code__file {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--ink);
  }

  .code__pre {
    margin: 0;
    padding-block: 1.1rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.75;

    @media (width < 40rem) {
      font-size: 0.75rem;
    }
    font-variant-ligatures: none;
    tab-size: 2;
    color: var(--ink);

    mask-image: linear-gradient(
      to right,
      black calc(100% - var(--code-fade)),
      transparent
    );

    &:focus-visible {
      outline-offset: -4px;
      border-radius: 0;
    }
  }

  @keyframes code-fade {
    0%,
    90% {
      --code-fade: 2.5rem;
    }
    100% {
      --code-fade: 0px;
    }
  }

  @supports (animation-timeline: scroll()) {
    .code__pre {
      animation: code-fade linear both;
      animation-timeline: scroll(self inline);
    }
  }

  .code__pre code {
    display: block;
    min-inline-size: max-content;
    font: inherit;
    counter-reset: line;
  }

  .code__pre code:not(.language-css) {
    padding-inline: 1.25rem;
  }

  .line {
    display: block;
    padding-inline: var(--gutter) 1.5rem;
    background-color: var(--code-bg);
    transition: opacity 0.3s ease;

    /* generated, so copying skips them */
    &::before {
      content: counter(line);
      counter-increment: line;
      position: sticky;
      left: 0;
      display: inline-block;
      box-sizing: border-box;
      inline-size: var(--gutter);
      margin-inline-start: calc(var(--gutter) * -1);
      padding-inline-end: 1.25rem;
      text-align: end;
      font-variant-numeric: tabular-nums;
      color: color-mix(in oklch, var(--muted) 65%, var(--code-bg));
      background-color: inherit;
      user-select: none;
    }
  }

  .line--mark {
    background-color: var(--mark-bg);

    &::before {
      color: var(--accent);
      box-shadow: inset 3px 0 var(--accent);
    }
  }

  .code__pre:has(.line--mark):not(:hover, :focus-visible)
    .line:not(.line--mark) {
    opacity: 0.5;
  }

  .tok-comment {
    font-family: var(--font-serif);
    font-size: 1.1em;
    font-style: italic;
    color: var(--muted);
  }

  .tok-at,
  .tok-important {
    color: var(--tok-at);
    font-weight: 500;
  }

  :is(.tok-tag, .tok-class) {
    color: var(--tok-selector);
  }

  :is(.tok-pseudo, .tok-attr) {
    color: var(--tok-pseudo);
  }

  .tok-nest {
    color: var(--tok-at);
    font-weight: 500;
  }

  .tok-prop {
    color: var(--ink);
  }

  .tok-var {
    color: var(--tok-var);
  }

  .tok-fn {
    color: var(--tok-fn);
  }

  .tok-num {
    color: var(--tok-num);
  }

  .tok-unit {
    color: color-mix(in oklch, var(--tok-num) 70%, var(--code-bg));
  }

  .tok-string {
    color: var(--tok-string);
  }

  .tok-keyword {
    color: color-mix(in oklch, var(--ink) 80%, var(--code-bg));
  }

  .tok-punct {
    color: var(--muted);
  }

  .tok-swatch {
    display: inline-block;
    inline-size: 0.8em;
    block-size: 0.8em;
    margin-inline-end: 0.35em;
    vertical-align: -0.08em;
    border-radius: 0;
    background: var(--swatch);
    box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--ink) 22%, transparent);
  }

  .code__caption {
    padding: 0.85rem 1.25rem 1rem;
    border-block-start: 1px solid var(--rule);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted);
    text-wrap: pretty;
  }

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

@layer components {
  .carousel {
    margin: 2rlh 0 0;
    padding: 0;
    list-style: none;
    anchor-name: --carousel;

    display: flex;

    overflow: auto hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 1rem;
    overscroll-behavior-x: contain;

    scrollbar-width: none;

    scroll-marker-group: after;
  }

  .carousel::-webkit-scrollbar {
    display: none;
  }

  .carousel img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: 0;
    pointer-events: none; /* stops image drag fighting scroll */
  }

  /* the next photo peeks in at the edge, so it's clear there's more */
  .carousel > li {
    flex: 0 0 88%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    container-type: scroll-state;
  }

  .carousel figure {
    margin: 0;
  }

  .carousel figcaption {
    margin-block-start: 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--muted);
    opacity: 0.35;
    translate: 0 0.25rem;
    transition:
      opacity 0.5s ease,
      translate 0.5s var(--ease);
  }

  @container scroll-state(snapped: x) {
    .carousel figcaption {
      opacity: 1;
      translate: 0 0;
    }
  }

  @supports not (container-type: scroll-state) {
    .carousel figcaption {
      opacity: 1;
      translate: 0 0;
    }
  }

  .carousel::scroll-button(*) {
    position: absolute;
    position-anchor: --carousel;
    top: calc(anchor(center) - 1.5rem);
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    font-family: var(--font-sans);
    font-size: 1.25rem;
    color: var(--paper);
    background: var(--ink);
    border: 0;
    box-shadow: 0 2px 12px color-mix(in oklch, black 25%, transparent);
    border-radius: 0;
    cursor: pointer;
    transition:
      opacity 0.3s ease,
      background-color 0.3s ease;
  }

  .carousel::scroll-button(*):hover {
    background: color-mix(in oklch, var(--ink) 85%, var(--paper));
  }

  .carousel::scroll-button(*):disabled {
    opacity: 0;
    cursor: default;
  }

  .carousel::scroll-button(left) {
    content: "←" / "Previous slide";
    left: calc(anchor(left) + 1rem);
  }

  .carousel::scroll-button(right) {
    content: "→" / "Next slide";
    right: calc(anchor(right) + 1rem);
  }

  .carousel::scroll-marker-group {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-block: 1rem 2rlh;
  }

  .carousel > li::scroll-marker {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 0;
    background: var(--rule);
    cursor: pointer;
    transition:
      background-color 0.3s ease,
      scale 0.3s ease;
  }

  .carousel > li::scroll-marker:target-current {
    background: var(--ink);
    scale: 1.25;
  }

  /* no dots (Safari, Firefox): the carousel keeps the space below itself */
  @supports not (scroll-marker-group: after) {
    .carousel {
      margin-block-end: 2rlh;

      @media (width < 40rem) {
        margin-block-end: 3rlh;
      }
    }
  }

  /* a little more air on phones */
  @media (width < 40rem) {
    .carousel > li {
      flex-basis: 85%;
    }

    .carousel::scroll-marker-group {
      margin-block-end: 3rlh;
    }
  }

  /* dots are a separate box; place them too */
  :is(main, .chapter) > .carousel::scroll-marker-group {
    grid-column: main;
  }
}

@layer components {
  .accordion {
    margin-block: 1.5rlh;
    border-block-start: 1px solid var(--rule);
  }

  .accordion details {
    border-block-end: 1px solid var(--rule);

    summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      padding-block: 1.1rem;
      font-family: var(--font-sans);
      font-size: 0.9375rem;
      font-weight: 500;
      cursor: pointer;
      list-style: none;

      &::-webkit-details-marker {
        display: none;
      }

      &::after {
        content: "+";
        font-size: 1.25rem;
        font-weight: 300;
        line-height: 1;
        color: var(--accent);
        transition: rotate 0.4s var(--ease);
      }
    }

    &::details-content {
      block-size: 0;
      overflow: clip;
      transition:
        block-size 0.5s var(--ease),
        content-visibility 0.5s allow-discrete;
    }

    /* [open] for browsers without :open */
    &:is(:open, [open])::details-content {
      block-size: auto;
    }

    &:is(:open, [open]) summary::after {
      rotate: 45deg;
    }
  }

  .accordion__body {
    padding-block-end: 1.25rem;

    p:last-child {
      margin-block-end: 0;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .accordion details::details-content {
      transition: none;
    }
  }
}

@layer base {
  :root {
    --color-foreground: var(--ink);
  }
}

@layer components {
  .modal-trigger {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.75em;
    margin-block: 1rem 3rem;
    padding: 0.9em 1.6em;
    font: inherit;
    font-size: 0.8em;
    color: var(--color-foreground);
    background: var(--button);
    border: var(--line);
    border-radius: 0;
    cursor: pointer;
  }

  .modal-trigger span {
    transition: translate 0.4s ease;
  }

  .modal-trigger:hover {
    background: var(--button-hover);
  }

  .modal-trigger:hover span {
    translate: 0.25em 0;
  }

  .modal-trigger:focus-visible,
  .modal__close:focus-visible {
    outline-offset: 4px;
  }

  .modal {
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --duration: 0.6s;

    width: 80vw;
    height: 80dvh;
    max-width: none;
    max-height: none;
    padding: 0;
    border: none;
    border-radius: 0;
    overflow: hidden;
    color: var(--color-foreground);
    background: var(--paper);
    box-shadow: var(--hard-shadow);

    /* closed, and where the exit ends */
    opacity: 0;
    translate: 0 2rem;
    scale: 0.98;
    transition:
      opacity var(--duration) var(--ease),
      translate var(--duration) var(--ease),
      scale var(--duration) var(--ease),
      overlay var(--duration) allow-discrete,
      display var(--duration) allow-discrete;
  }

  .modal[open] {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }

  /* where the entry starts */
  @starting-style {
    .modal[open] {
      opacity: 0;
      translate: 0 2rem;
      scale: 0.98;
    }
  }

  .modal::backdrop {
    background: rgb(20 20 20 / 0);
    backdrop-filter: blur(0);
    transition:
      background-color var(--duration) var(--ease),
      backdrop-filter var(--duration) var(--ease),
      overlay var(--duration) allow-discrete,
      display var(--duration) allow-discrete;
  }

  .modal[open]::backdrop {
    background: rgb(20 20 20 / 0.25);
    backdrop-filter: blur(16px) saturate(1.2);
  }

  @starting-style {
    .modal[open]::backdrop {
      background: rgb(20 20 20 / 0);
      backdrop-filter: blur(0);
    }
  }

  html:has(.modal[open]) {
    overflow: hidden;
    scrollbar-gutter: stable;
  }

  .modal__layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
  }

  .modal__media {
    margin: 0;
    overflow: hidden;
  }

  .modal__media .ascii {
    display: grid;
    align-content: center;
    height: 100%;
  }

  .modal__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .modal__body {
    overflow-y: auto;
    padding: clamp(2rem, 5vw, 5rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .modal__eyebrow {
    margin: 0 0 1.5rem;
    font-size: 0.75em;
    font-style: italic;
    color: var(--accent);
  }

  .modal__title {
    margin: 0 0 2rem;
    font-size: clamp(1.375rem, 2vw, 1.75rem);
    font-weight: 400;
    line-height: 1.2;
  }

  .modal__body p {
    margin: 0 0 1.2em;
    max-width: 34ch;
    line-height: 1.5;
    font-size: 0.85em;
  }

  .modal__close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--color-foreground);
    background: color-mix(in oklch, var(--paper) 80%, transparent);
    backdrop-filter: blur(8px);
    border: 1px solid var(--rule);
    border-radius: 0;
    cursor: pointer;
    transition:
      rotate 0.4s var(--ease),
      background-color 0.4s ease;
  }

  .modal__close:hover {
    rotate: 90deg;
    background: var(--paper);
  }

  @media (max-width: 800px) {
    .modal {
      width: 92vw;
      height: 88dvh;
    }

    .modal__layout {
      grid-template-columns: 1fr;
      grid-template-rows: 40% 1fr;
    }

    .modal__body {
      justify-content: start;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .modal,
    .modal::backdrop {
      translate: 0 0;
      scale: 1;
      transition-duration: 0.01s;
    }
  }
}

@layer components {
  .endmatter {
    margin-block: 4rlh 6rem;
  }

  .endmatter__links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-block-start: 2rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
  }

  .author {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.25rem;
    align-items: start;
    margin-block-end: 3rem;
    padding: 1.5rem;
    border: var(--line);

    p {
      margin: 0;
      font-size: 0.9375rem;
      line-height: 1.55;
      color: var(--muted);
    }

    strong {
      color: var(--ink);
      font-weight: 600;
    }
  }

  .author .author__initials {
    display: grid;
    place-items: center;
    width: 3.25rem;
    height: 3.25rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--accent);
    border: var(--line);
    border-radius: 0;
  }

  .newsletter {
    display: grid;
    gap: 1.25rem;
    margin-block-end: 4rem;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    background: var(--tint);
    border-radius: 0;
    font-family: var(--font-sans);
  }

  .newsletter__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.5rem;
  }

  .newsletter__text {
    margin: -0.5rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
  }

  .field {
    display: grid;
    gap: 0.4rem;
    justify-items: start;

    label {
      font-size: 0.8125rem;
      font-weight: 500;
    }

    :is(input, textarea) {
      box-sizing: border-box;
      field-sizing: content;
      min-inline-size: 18rem;
      max-inline-size: 100%;
      padding: 0.65em 0.85em;
      font: inherit;
      font-size: 0.9375rem;
      color: var(--ink);
      background: var(--paper);
      border: 1px solid var(--rule);
      border-radius: 0;
      transition: border-color 0.2s ease;

      &:focus-visible {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-wash);
      }

      &::placeholder {
        color: color-mix(in oklch, var(--muted) 70%, transparent);
      }
    }

    /* under 16px, iOS zooms in on focus */
    @media (pointer: coarse) {
      :is(input, textarea) {
        font-size: max(16px, 0.9375rem);
      }
    }

    textarea {
      min-block-size: 2lh;
      inline-size: 100%;
      resize: none;
    }

    input:user-invalid {
      border-color: var(--accent);
    }
  }

  .field__optional {
    font-weight: 400;
    color: var(--muted);
  }

  .field__hint {
    display: none;
    margin: 0;
    font-size: 0.75rem;
    color: var(--accent);
  }

  .field:has(:user-invalid) .field__hint {
    display: block;
  }

  .check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.875rem;

    input {
      width: 1.05rem;
      height: 1.05rem;
      margin: 0;
    }
  }

  .newsletter__submit {
    justify-self: start;
    padding: 0.75em 1.5em;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--paper);
    background: var(--ink);
    border: 0;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.3s ease;

    &:hover {
      background: var(--accent);
    }
  }

  .newsletter:has(:invalid) .newsletter__submit {
    opacity: 0.55;
  }

  /* root is a scroll-state container */
  :root {
    container-type: scroll-state;
  }
}

@layer utilities {
  @media print {
    @page {
      size: A4;
      margin: 2cm 2.2cm;

      @top-center {
        content: "Living C.L.E.A.N.E.R.";
        font:
          italic 9pt "Source Serif 4",
          Georgia,
          serif;
        color: #777;
      }

      @bottom-right {
        content: counter(page) " / " counter(pages);
        font:
          8pt "Inter",
          sans-serif;
        color: #777;
      }
    }

    @page :first {
      @top-center {
        content: none;
      }
    }

    :root {
      color-scheme: light;
      font-size: 10pt;
    }

    body {
      color: black;
      background: white;
    }

    nav,
    .progress,
    .settings__toggle,
    .settings__open,
    .modal-trigger,
    .newsletter,
    .header__bg,
    .header__wrap,
    .carousel::scroll-marker-group,
    .carousel::scroll-button(*) {
      display: none !important;
    }

    .page {
      display: block;
    }

    header,
    .header__inner {
      height: auto;
      position: static;
      overflow: visible;
      margin: 0;
    }

    .header__text {
      position: static;
      color: black;
      font-size: 32pt;
      animation: none;
      justify-content: start;
      text-align: start;
    }

    main,
    .chapter,
    .endmatter {
      display: block;
    }

    main a[href^="http"]::after {
      content: " (" attr(href) ")";
      font-size: 0.8em;
      color: #555;
    }

    .essay {
      background: none;
    }

    .essay__frame,
    .essay__frame:last-child {
      height: auto;
      margin: 0 0 1em;
    }

    .essay__pin,
    .essay__caption,
    .essay__card {
      position: static;
      height: auto;
      translate: none;
    }

    .essay__card {
      background: none;
      backdrop-filter: none;
      box-shadow: none;
      border: 0;
      padding: 0.5em 0;
      max-width: none;
    }

    .carousel {
      display: block;
      overflow: visible;
    }

    .figure--parallax img {
      translate: none;
      height: auto;
    }

    .figure--parallax .figure__frame {
      height: auto;
    }

    .compare__scroll {
      overflow: visible;
      mask-image: none;
    }

    .compare__table {
      min-width: 0;
    }

    .code__pre {
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      mask-image: none;
    }

    .code__pre code {
      min-inline-size: 0;
    }

    .code .line {
      opacity: 1 !important;
    }

    details::details-content {
      block-size: auto;
      content-visibility: visible;
    }

    figure,
    table,
    blockquote,
    .stat {
      break-inside: avoid;
    }

    h2 {
      break-after: avoid;
    }

    p {
      orphans: 3;
      widows: 3;
    }

    .stat__num {
      counter-reset: n var(--to);
    }

    * {
      animation: none !important;
      transition: none !important;
    }
  }
}
