/* Copyright 2026 Leo Cheng
 * SPDX-License-Identifier: Apache-2.0
 *
 * Two designs, not one inverted.
 *
 * Daylight is a print on warm paper: ink that is brown rather than black, brass
 * rules, a vignette where the light fell off, and a little grain so the paper is
 * paper. The darkroom is the same room after the lamp goes off: a safelight in
 * the top corner, surfaces that catch a hairline of it along their top edge,
 * shadows that stop working as shadows and become edges, and a display face set
 * a weight lighter because light on dark reads heavier than dark on light.
 *
 * Code is the one thing that carries across: by day it is a darkroom in the
 * middle of the page, and at night it is the sheet on the enlarger — lighter than
 * what surrounds it, lit from above.
 */

:root {
  color-scheme: light dark;

  /* Daylight first, the darkroom second, in the same pair. */
  --paper: light-dark(#f4edde, #131110);
  --paper-deep: light-dark(#eae0cc, #0b0a09);
  --card: light-dark(#fbf7ee, #1c1815);
  --ink: light-dark(#241c15, #f2e8d6);
  --ink-soft: light-dark(#4c4034, #c9baa4);
  --ink-faint: light-dark(#75644f, #9b8b74);
  --rule: light-dark(#cfc0a7, #362c23);
  --rule-soft: light-dark(#ddd1bb, #241e18);
  --brass: light-dark(#8a6023, #e0a95e);
  --brass-bright: light-dark(#c9a15e, #f3c98d);
  --oxblood: light-dark(#7a3a2c, #d98d75);
  --sage: light-dark(#4f6a54, #a7c3ab);
  --code: light-dark(#1b1714, #241d18);
  --code-ink: light-dark(#ece0cd, #f5ecdc);
  --code-dim: light-dark(#9c8d78, #ab9a83);
  --code-rule: light-dark(#352d26, #3c3029);
  --shadow-ink: light-dark(rgb(36 28 21 / 7%), rgb(0 0 0 / 55%));
  --glow: light-dark(transparent, rgb(255 214 160 / 6%));

  --grain: 0.045;
  --photo-filter: none;
  --display-weight: 600;

  --serif: "EB Garamond", Georgia, "Times New Roman", serif;
  --display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --rail: 1180px;
  --pad: clamp(18px, 4vw, 40px);
}

/* The darkroom's own decisions, which are not colours and so cannot live in the
 * pairs above: the weight of the display face, the treatment of photographs, the
 * texture of paper that at night is not paper at all. */
:root[data-theme="dark"] {
  --grain: 0;
  --photo-filter: brightness(0.88) saturate(0.94);
  --display-weight: 500;
}

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

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

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  font-variant-ligatures: no-contextual;
  /* Room for the bar is always kept, so hiding it at the top of the page does
   * not move the text sideways by eleven pixels. */
  scrollbar-gutter: stable;
}

/* The bar shows while the page moves or under the pointer and hides a moment
 * after: the thumb goes, its place stays. */
@supports selector(::-webkit-scrollbar) {
  :root:not(.scrolling)::-webkit-scrollbar-thumb { background: transparent; border-color: transparent; box-shadow: none; }
}

@supports not selector(::-webkit-scrollbar) {
  :root:not(.scrolling) { scrollbar-color: transparent transparent; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.62 var(--serif);
  text-rendering: optimizeLegibility;
}

/* Where the light falls: a vignette by day, the safelight and the shadow of the
 * room at night. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 55%, rgb(36 28 21 / 5%) 100%),
    radial-gradient(90% 70% at 50% 100%, transparent 60%, rgb(36 28 21 / 4%) 100%);
}

:root[data-theme="dark"] body::before {
  background:
    radial-gradient(78% 55% at 88% -6%, rgb(198 96 44 / 13%), transparent 68%),
    radial-gradient(120% 70% at 50% 104%, rgb(0 0 0 / 55%), transparent 62%);
}

/* Grain: a photograph of paper, not paper. Daylight only — at night the stock is
 * gone and there is nothing to be grainy. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

::selection {
  background: color-mix(in srgb, var(--brass) 26%, transparent);
}

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Scrollbars: the standard properties and the WebKit ones fight, so the
 * standard pair is only declared where WebKit's pseudo-elements do not exist. */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--brass) 45%, var(--rule)) transparent;
  }
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--brass) 38%, var(--rule));
  border: 3px solid var(--paper);
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brass);
}

/* Text that is furniture rather than reading matter: a selection box dragged
 * across the navigation or a plate caption looks like a mistake. Prose, tables
 * of numbers and code stay selectable, because those are what a reader takes
 * away. */
.top,
.brand,
.aperture-toggle,
.icon-link,
.button,
.eyebrow,
.frame figcaption,
.stage .readout,
.panel h3,
table.formats thead th,
.figure,
.kind,
article.step .num,
.api nav,
.guide aside {
  user-select: none;
  -webkit-user-select: none;
}

.frame img,
.stage canvas {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

/* ------------------------------------------------------------------ type */

h1,
h2,
h3,
h4 {
  font-family: var(--display);
  font-weight: var(--display-weight);
  letter-spacing: 0.01em;
  line-height: 1.12;
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.4rem, 4.2vw, 3.5rem);
  max-width: 21ch;
}

h2 {
  font-size: clamp(1.75rem, 3.2vw, 2.35rem);
}

h3 {
  font-size: 1.3rem;
  letter-spacing: 0.015em;
}

p {
  margin: 0 0 1.05em;
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--brass) 55%, transparent);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--brass);
}

code,
kbd,
pre,
samp {
  font-family: var(--mono);
  font-variant-ligatures: none;
  font-size: 0.92em;
}

:not(pre) > code {
  background: color-mix(in srgb, var(--brass) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brass) 22%, transparent);
  border-radius: 4px;
  padding: 0.05em 0.32em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

/* ------------------------------------------------------------------ shell */

.wrap {
  width: 100%;
  max-width: var(--rail);
  margin-inline: auto;
  padding-inline: var(--pad);
  position: relative;
  z-index: 1;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px) saturate(1.1);
  border-bottom: 1px solid var(--rule);
}

.top nav {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 62px;
  max-width: var(--rail);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-right: auto;
  text-decoration: none;
  font-family: var(--display);
  font-size: 1.32rem;
  letter-spacing: 0.06em;
}

.brand b {
  font-weight: var(--display-weight);
}

.brand span {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.top a.link {
  text-decoration: none;
  color: var(--ink-soft);
  padding: 7px 11px;
  border-radius: 3px;
  font-size: 0.98rem;
}

.top a.link:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--brass) 12%, transparent);
}

.top a.link[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--brass);
  border-radius: 3px 3px 0 0;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--ink-soft);
  text-decoration: none;
}

.icon-link:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--brass) 14%, transparent);
}

.icon-link svg {
  width: 19px;
  height: 19px;
  display: block;
}

/* The switch: an aperture, wide open by day and stopped down at night. Both
 * states are drawn, and the blades cross-fade so it reads as the ring turning. */
.aperture-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease;
}

.aperture-toggle:hover {
  color: var(--brass);
  background: color-mix(in srgb, var(--brass) 12%, transparent);
}

.aperture-toggle svg {
  width: 21px;
  height: 21px;
  display: block;
  overflow: visible;
}

.aperture-toggle .ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  opacity: 0.45;
}

.aperture-toggle .iris {
  fill: currentColor;
  opacity: 0.85;
}

.aperture-toggle g {
  transform-origin: 12px 12px;
  transition: opacity 500ms ease, transform 500ms cubic-bezier(0.34, 0.9, 0.3, 1);
}

.aperture-toggle .closed {
  opacity: 0;
  transform: rotate(-20deg);
}

:root[data-theme="dark"] .aperture-toggle .open {
  opacity: 0;
  transform: rotate(20deg);
}

:root[data-theme="dark"] .aperture-toggle .closed {
  opacity: 1;
  transform: none;
}

:root[data-theme="dark"] .top {
  box-shadow: 0 1px 0 var(--glow);
}

/* --------------------------------------------------------------- masthead */

.hero {
  padding-block: clamp(44px, 7vw, 86px) clamp(30px, 4vw, 54px);
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  gap: clamp(28px, 4.5vw, 64px);
  align-items: center;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 14px;
}

.lede {
  margin-top: 20px;
  font-size: 1.14rem;
  color: var(--ink-soft);
  max-width: 33em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 30px 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 3px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-size: 1rem;
  letter-spacing: 0.02em;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button:hover {
  background: var(--oxblood);
  border-color: var(--oxblood);
  color: var(--paper);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: color-mix(in srgb, var(--ink) 35%, transparent);
}

.button.ghost:hover {
  background: color-mix(in srgb, var(--brass) 14%, transparent);
  border-color: var(--brass);
  color: var(--ink);
}

:root[data-theme="dark"] .button {
  background: var(--brass);
  border-color: var(--brass);
  color: #16120e;
}

:root[data-theme="dark"] .button:hover {
  background: var(--brass-bright);
  border-color: var(--brass-bright);
  color: #16120e;
}

:root[data-theme="dark"] .button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: color-mix(in srgb, var(--brass) 45%, transparent);
}

:root[data-theme="dark"] .button.ghost:hover {
  background: color-mix(in srgb, var(--brass) 14%, transparent);
  color: var(--brass-bright);
}

/* The plate hangs in a frame with brass corners, like a print on a wall. */
.frame {
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  padding: 12px;
  box-shadow: 0 1px 0 var(--shadow-ink), 0 14px 32px -22px var(--shadow-ink);
}

:root[data-theme="dark"] .frame {
  border-color: color-mix(in srgb, var(--brass) 22%, var(--rule));
  box-shadow: inset 0 1px 0 var(--glow), 0 26px 60px -40px rgb(0 0 0 / 90%);
}

.frame::before,
.frame::after,
.frame .corner::before,
.frame .corner::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid var(--brass);
}

.frame::before {
  top: 6px;
  left: 6px;
  border-right: 0;
  border-bottom: 0;
}

.frame::after {
  top: 6px;
  right: 6px;
  border-left: 0;
  border-bottom: 0;
}

.frame .corner::before {
  bottom: 6px;
  left: 6px;
  border-right: 0;
  border-top: 0;
}

.frame .corner::after {
  bottom: 6px;
  right: 6px;
  border-left: 0;
  border-top: 0;
}

.frame img {
  display: block;
  width: 100%;
  height: auto;
  filter: var(--photo-filter);
}

.frame figcaption {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 10px 2px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* ------------------------------------------------------------------ bands */

.band {
  padding-block: clamp(34px, 5vw, 62px);
  border-top: 1px solid var(--rule);
}

.band-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.band-head h2 {
  margin-right: auto;
}

.band-head h2::before {
  content: "";
  display: inline-block;
  width: 26px;
  height: 1px;
  margin-right: 14px;
  vertical-align: 0.32em;
  background: var(--brass);
  opacity: 0.7;
}

.band-head p {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.98rem;
}

/* ------------------------------------------------------------------- demo */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 34px);
  align-items: start;
}

.stage {
  position: relative;
  background: var(--code);
  border: 1px solid var(--rule);
  padding: 14px;
  box-shadow: 0 1px 0 var(--shadow-ink), 0 14px 32px -24px var(--shadow-ink);
}

:root[data-theme="dark"] .stage {
  box-shadow: inset 0 1px 0 var(--glow), 0 30px 60px -44px rgb(0 0 0 / 90%);
}

.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
  background: #0c0a08;
  filter: var(--photo-filter);
}

.stage .readout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding-top: 11px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--code-dim);
}

.stage .readout b {
  color: var(--code-ink);
  font-weight: 400;
}

.stage[data-drop="over"] {
  outline: 2px dashed var(--brass);
  outline-offset: -6px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  padding: 18px;
}

:root[data-theme="dark"] .panel {
  box-shadow: inset 0 1px 0 var(--glow);
}

.panel h3 {
  font-size: 1.05rem;
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 400;
  margin-bottom: 12px;
}

table.formats {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.8rem;
}

table.formats caption {
  caption-side: top;
  text-align: left;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink-soft);
  padding-bottom: 8px;
}

table.formats th,
table.formats td {
  text-align: right;
  padding: 7px 6px;
  border-bottom: 1px solid var(--rule-soft);
  white-space: nowrap;
}

table.formats th:first-child,
table.formats td:first-child {
  text-align: left;
}

table.formats thead th {
  font-weight: 400;
  color: var(--ink-faint);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule);
}

table.formats tbody tr:last-child td {
  border-bottom: 0;
}

table.formats td.exact {
  color: var(--sage);
}

table.formats td.lossy {
  color: var(--oxblood);
}

table.formats tbody tr.source td {
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule);
}

table.formats tbody tr:not(.source):hover {
  background: color-mix(in srgb, var(--brass) 10%, transparent);
  cursor: pointer;
}

table.formats tbody tr[aria-current="true"] td {
  background: color-mix(in srgb, var(--brass) 16%, transparent);
}

.note {
  font-size: 0.92rem;
  color: var(--ink-faint);
  margin: 12px 0 0;
}

.drop {
  border-left: 3px solid var(--brass);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--brass) 8%, transparent);
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-top: 16px;
}

/* ------------------------------------------------------------------ cards */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.card {
  background: var(--card);
  padding: 22px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

:root[data-theme="dark"] .card {
  box-shadow: inset 0 1px 0 var(--glow);
}

.card svg {
  width: 30px;
  height: 30px;
  color: var(--brass);
  margin-bottom: 2px;
}

.card h3 {
  font-size: 1.18rem;
}

.card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.99rem;
}

.card code {
  font-size: 0.86em;
}

/* ----------------------------------------------------------------- figures */

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 1px;
  background: var(--rule);
  border-block: 1px solid var(--rule);
}

.figure {
  background: var(--paper);
  padding: 20px 18px;
}

.figure b {
  display: block;
  font-family: var(--display);
  font-size: 2.15rem;
  font-weight: var(--display-weight);
  line-height: 1;
}

.figure span {
  display: block;
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--ink-faint);
}

/* -------------------------------------------------------------------- code */

pre {
  margin: 0 0 1.1rem;
  background: var(--code);
  color: var(--code-ink);
  border: 1px solid var(--code-rule);
  border-radius: 4px;
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.62;
  font-size: 0.84rem;
  tab-size: 2;
}

:root[data-theme="dark"] pre {
  box-shadow: inset 0 1px 0 var(--glow), 0 24px 50px -40px rgb(0 0 0 / 90%);
}

pre::-webkit-scrollbar {
  height: 9px;
}

pre::-webkit-scrollbar-thumb {
  border: 2px solid var(--code);
  background: var(--code-rule);
}

pre code {
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}

pre.output {
  background: transparent;
  color: var(--ink-soft);
  border: 1px dashed var(--rule);
  border-left: 3px solid var(--rule);
  border-radius: 0 4px 4px 0;
  font-size: 0.8rem;
  box-shadow: none;
}

pre.output::before {
  content: "output";
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.tok-kw {
  color: light-dark(#a1691f, #e9b978);
}

.tok-fn {
  color: light-dark(#4b5b74, #a9c2e6);
}

.tok-str {
  color: light-dark(#587a4e, #a8c79b);
}

.tok-num {
  color: light-dark(#8d4b48, #e0a09a);
}

.tok-com {
  color: var(--code-dim);
  font-style: italic;
}

/* ------------------------------------------------------------------- guide */

.guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
  padding-block: 42px 60px;
}

.guide aside {
  position: sticky;
  top: 84px;
  font-size: 0.92rem;
}

.guide aside .eyebrow {
  margin-bottom: 10px;
}

.guide aside a {
  display: block;
  padding: 5px 10px;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
}

.guide aside a:hover {
  color: var(--ink);
  border-left-color: var(--brass);
  background: color-mix(in srgb, var(--brass) 7%, transparent);
}

.guide aside a.sub {
  padding-left: 22px;
  font-size: 0.86rem;
  color: var(--ink-faint);
}

article.step {
  margin-bottom: 46px;
  scroll-margin-top: 84px;
}

article.step > h2 {
  font-size: 1.85rem;
  margin-bottom: 4px;
}

article.step .num {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--brass);
  text-transform: uppercase;
}

article.step p {
  margin-top: 12px;
}

article.step h3 {
  margin-top: 26px;
}

/* --------------------------------------------------------------------- api */

.api {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 44px);
  padding-block: 40px 70px;
  align-items: start;
}

.api nav {
  position: sticky;
  top: 84px;
  font-size: 0.92rem;
}

.api nav a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
}

.api nav a span {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.api nav a:hover {
  color: var(--ink);
  border-left-color: var(--brass);
  background: color-mix(in srgb, var(--brass) 7%, transparent);
}

.pkg {
  scroll-margin-top: 84px;
  margin-bottom: 54px;
}

.pkg > h2 {
  font-size: 1.9rem;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.pkg > h2 span {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink-faint);
}

.pkg > p {
  color: var(--ink-soft);
  margin-top: 8px;
  max-width: 68ch;
}

.entry {
  border-top: 1px solid var(--rule-soft);
  padding: 14px 0 4px;
}

.kind {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 1px 6px;
  margin-bottom: 7px;
}

code.sig {
  display: block;
  font-size: 0.84rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--brass) 6%, transparent);
  border: 0;
  border-radius: 3px;
  padding: 7px 9px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

code.sig .kw {
  color: var(--brass);
}

.doc {
  margin-top: 8px;
  max-width: 68ch;
  font-size: 0.96rem;
  color: var(--ink-soft);
}

.doc p {
  margin: 0 0 0.6em;
}

.doc p:last-child {
  margin-bottom: 0;
}

ul.fields,
ul.variants {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 0.9rem;
}

ul.fields li,
ul.variants li {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 12px;
  padding: 4px 0;
  border-top: 1px dotted var(--rule-soft);
}

ul.fields li b {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

ul.fields li span {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
  overflow-wrap: anywhere;
}

ul.variants li {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
}

ul.variants li em,
ul.fields li em {
  font-family: var(--serif);
  font-size: 0.92rem;
  color: var(--ink-soft);
}

ul.fields li em {
  grid-column: 2;
  font-size: 0.88rem;
}

.entry.method {
  border-top: 1px dotted var(--rule-soft);
  margin-left: 18px;
  padding-top: 10px;
}

.group {
  margin: 26px 0 2px;
}

/* ------------------------------------------------------------------ footer */

footer {
  border-top: 1px solid var(--rule);
  padding-block: 34px 46px;
  color: var(--ink-faint);
  font-size: 0.92rem;
}

footer .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  align-items: center;
}

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

footer .mark {
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: var(--ink);
  margin-right: auto;
}

/* ------------------------------------------------------------- narrow view */

@media (width <= 1080px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (width <= 980px) {
  .hero,
  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .guide,
  .api {
    grid-template-columns: minmax(0, 1fr);
  }

  .guide aside,
  .api nav {
    position: static;
    order: -1;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 6px;
  }

  .guide aside a,
  .api nav a {
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 4px 8px;
  }

  .guide aside a:hover,
  .api nav a:hover {
    border-left: 0;
    border-bottom-color: var(--brass);
  }

  .guide aside .eyebrow {
    width: 100%;
  }
}

@media (width <= 700px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (width <= 640px) {
  body {
    font-size: 1.02rem;
  }

  .top nav {
    height: 56px;
    gap: 2px;
  }

  .brand span {
    display: none;
  }

  .top a.link {
    padding: 6px 8px;
    font-size: 0.92rem;
  }

  .icon-link,
  .aperture-toggle {
    width: 30px;
    height: 30px;
  }

  ul.fields li {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  ul.fields li em {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .aperture-toggle,
  .aperture-toggle g,
  .button {
    transition: none;
  }
}

/* Long identifiers in running text break rather than widen the page. */
:where(p, li, td, dd, h1, h2, h3, h4) code { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Grid items give way to their scrolling code and tables instead of widening the page. */
.guide > *, .workbench > * { min-width: 0; }
.panel:has(> table.formats) { overflow-x: auto; }
