:root {
  color-scheme: dark;
  --page: #181818;
  --paper: #181818;
  --ink: #e8e4dc;
  --muted: #aaaead;
  --line: #35393b;
  --accent: #ff0000;
  --accent-text: #ff5c5c;
  --accent-soft: color-mix(in srgb, var(--accent) 4%, var(--paper));
  --link: #77cbd2;
  --popover: rgba(30, 30, 30, .96);
  --popover-border: rgba(255, 255, 255, .14);
  --popover-divider: rgba(255, 255, 255, .12);
  --popover-hover: rgba(255, 255, 255, .06);
  --header-height: 5.25rem;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); scroll-behavior: smooth; }
body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Barlow", system-ui, sans-serif;
}
body::after {
  position: fixed;
  z-index: 30;
  inset: 0;
  background-image:
    repeating-linear-gradient(17deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(103deg, rgba(0, 0, 0, .025) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, .035), transparent 38%);
  mix-blend-mode: soft-light;
  opacity: .28;
  pointer-events: none;
  content: "";
}
a { color: var(--link); text-underline-offset: .22em; }
a:hover { text-decoration-thickness: .14em; }
.citation {
  margin-left: .12em;
  font-family: "Barlow", system-ui, sans-serif;
  font-size: .76em;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: .75rem;
  left: .75rem;
  padding: .7rem 1rem;
  color: var(--page);
  background: var(--ink);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.scene {
  position: absolute;
  z-index: 0;
  top: var(--header-height);
  right: 0;
  left: 0;
  height: var(--scene-height, 100vh);
  overflow: hidden;
  background: var(--page);
  pointer-events: none;
}
.scene.is-reset .tile { transition: none; }
.scene.is-reset::before { visibility: hidden; }
.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--scene-left), var(--scene-right);
  background-position: top left, top right;
  background-size: min(44vw, 768px) auto;
  background-repeat: repeat-y;
}
.tiles {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  left: 0;
  contain: strict;
}
.tile {
  position: absolute;
  background: var(--page);
  border: 0;
  outline: 1px solid var(--page);
  opacity: 1;
  contain: strict;
}
body.flip-enabled .tile {
  transition: opacity 520ms cubic-bezier(.45, 0, .55, 1) var(--flip-delay, 0ms);
}
body.flip-enabled .tile.is-recycling { transition: none; }
.tile.is-revealed { opacity: 0; }

.masthead {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: var(--header-height);
  padding: .8rem clamp(1rem, 4vw, 2.5rem);
  background: var(--paper);
  border-bottom: 4px solid var(--accent);
}
.header-actions { display: flex; align-items: center; gap: .85rem; }
.header-actions-left { justify-self: start; }
.header-actions-right { justify-self: end; }
.header-link {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  padding: .45rem 0;
  color: var(--ink);
  font-size: 1.11rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-decoration: none;
  opacity: .62;
}
.header-link:hover { opacity: .9; }
.header-social-link {
  display: inline-grid;
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 50%;
}
.header-social-link:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 20%, transparent); }
.header-social-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.header-social-link svg { display: block; width: 1.4rem; height: 1.4rem; fill: currentColor; }
.language-link img { display: block; width: 1.875rem; height: 1.125rem; }
.brand { display: grid; grid-column: 2; width: min(13rem, 44vw); min-height: 2.75rem; place-items: center; line-height: 0; }
.brand img { display: block; width: 100%; height: auto; filter: invert(1); }
.footer-wordmark { width: 5.4rem; height: auto; vertical-align: -.08em; filter: invert(1); }
.theme-toggle,
.copy-link,
.icon-control {
  display: inline-grid;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 0;
  min-height: 0;
  flex: 0 0 auto;
  padding: .5rem;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}
.theme-toggle:hover,
.copy-link:hover,
.icon-control:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 20%, transparent); }
.icon-control:disabled { opacity: .42; cursor: not-allowed; }
.icon-control[aria-expanded="true"] { color: var(--ink); border-color: var(--accent); }
.theme-toggle:focus-visible,
.copy-link:focus-visible,
.icon-control:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.theme-toggle svg,
.copy-link svg,
.icon-control svg {
  display: block;
  width: 1.4rem;
  height: 1.4rem;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
.background-toggle .background-off-icon { display: none; }
.background-toggle[aria-pressed="true"] {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent-text) 45%, transparent);
}
.background-toggle[aria-pressed="true"] .background-on-icon { display: none; }
.background-toggle[aria-pressed="true"] .background-off-icon {
  display: block;
  filter: drop-shadow(0 0 .24rem color-mix(in srgb, var(--accent-text) 65%, transparent));
}
.copy-link .copy-link-check { display: none; }
.copy-link[data-copied="true"] .copy-link-chain { display: none; }
.copy-link[data-copied="true"] .copy-link-check { display: block; }
.copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.site-tooltip {
  position: fixed;
  z-index: 40;
  max-width: calc(100vw - 1rem);
  padding: .35rem .65rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .7rem;
  font: 650 .75rem/1.2 "Barlow", sans-serif;
  text-align: center;
  overflow-wrap: anywhere;
  transition: opacity 120ms ease;
}
.site-tooltip[hidden] { display: none; }
.theme-toggle .bulb-rays { opacity: 0; transition: opacity 160ms ease; }
.theme-toggle .bulb-core { transition: fill 160ms ease, filter 160ms ease; }
.theme-toggle[data-theme-active="light"],
.theme-toggle[data-theme-active="dark"]:hover { color: #b77400; }
.theme-toggle[data-theme-active="light"] .bulb-rays,
.theme-toggle[data-theme-active="dark"]:hover .bulb-rays { opacity: 1; }
.theme-toggle[data-theme-active="light"] .bulb-core,
.theme-toggle[data-theme-active="dark"]:hover .bulb-core {
  fill: #ffd75a;
  filter: drop-shadow(0 0 .28rem rgba(255, 199, 55, .7));
}
.theme-toggle[data-theme-active="light"]:hover { color: var(--ink); }
.theme-toggle[data-theme-active="light"]:hover .bulb-rays { opacity: 0; }
.theme-toggle[data-theme-active="light"]:hover .bulb-core { fill: none; filter: none; }
.icon-control { font: 600 .74rem/1.15 "Barlow", sans-serif; }
.icon-control:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.control-menu { position: relative; }
.text-control span { font: 700 1rem/1 "Atkinson Hyperlegible Next", sans-serif; letter-spacing: -.08em; }
.control-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + .75rem);
  right: 0;
  width: min(15rem, calc(100vw - 2rem));
  margin: 0;
  padding: .65rem 1rem .85rem;
  color: var(--ink);
  background: var(--popover);
  border: 1px solid var(--popover-border);
  border-radius: .85rem;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, .55), 0 .2rem .7rem rgba(0, 0, 0, .35);
  backdrop-filter: blur(18px) saturate(1.15);
}
.control-popover[hidden] { display: none; }
.control-popover::before {
  position: absolute;
  top: -.38rem;
  right: .95rem;
  width: .7rem;
  height: .7rem;
  background: inherit;
  border-top: inherit;
  border-left: inherit;
  transform: rotate(45deg);
  content: "";
}
.control-popover > p {
  width: calc(100% + .5rem);
  margin: 0 -.25rem .45rem;
  padding: .15rem .25rem .65rem;
  border-bottom: 1px solid var(--popover-divider);
  font-size: .8rem;
  font-weight: 600;
}
.random-controls { width: min(25rem, calc(100vw - 2rem)); }
.random-controls label {
  display: grid;
  grid-template-columns: 1fr 3.5rem;
  align-items: center;
  gap: .3rem .65rem;
  padding: .55rem .1rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.random-controls label > span { grid-column: 1 / -1; }
.random-controls input { width: 100%; accent-color: var(--accent); cursor: pointer; }
.random-controls input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.random-controls output { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.text-controls { width: min(11rem, calc(100vw - 2rem)); }
.design-controls { width: min(14rem, calc(100vw - 2rem)); }
.menu-choice {
  display: block;
  width: 100%;
  min-height: 2.6rem;
  padding: .55rem .5rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: .35rem;
  font: 600 .9rem/1.2 "Barlow", sans-serif;
  text-align: left;
  cursor: pointer;
}
.menu-choice:hover { color: var(--ink); background: var(--popover-hover); }
.menu-choice[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.menu-choice:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.menu-action {
  margin-top: .45rem;
  padding-top: .75rem;
  border-top: 1px solid var(--popover-divider);
  border-radius: 0;
}
.copy-controls {
  width: min(19rem, calc(100vw - 2rem));
  padding: .8rem;
  border-top: 3px solid var(--accent);
}
.control-popover.copy-controls > p {
  width: auto;
  margin: 0 0 .7rem;
  padding: .15rem .2rem .65rem;
  font-size: .88rem;
}
.copy-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem;
  margin-bottom: .75rem;
}
.copy-options label {
  display: flex;
  min-height: 3rem;
  align-items: center;
  gap: .55rem;
  padding: .55rem .6rem;
  color: var(--muted);
  background: var(--popover-hover);
  border: 1px solid transparent;
  border-radius: .55rem;
  font-size: .82rem;
  font-weight: 650;
  cursor: pointer;
}
.copy-options label:hover {
  color: var(--ink);
  border-color: var(--popover-border);
}
.copy-options label:has(input:checked) {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent-text) 55%, transparent);
}
.copy-options input {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}
.copy-options input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.copy-option-label { line-height: 1.15; }
.copy-submit {
  width: 100%;
  min-height: 2.75rem;
  padding: .65rem 1rem;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: .55rem;
  font: 700 .9rem/1.2 "Barlow", sans-serif;
  cursor: pointer;
}
.copy-submit:hover { filter: brightness(.88); }
.copy-submit:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

main { position: relative; z-index: 1; scroll-margin-top: calc(var(--header-height) + 1rem); }
article {
  --article-paper-inset: clamp(0px, calc((100vw - 20rem) / 12), 3rem);
  width: min(calc(100% - clamp(2rem, 11vw, 11rem)), 52.5rem);
  margin: 0 auto;
  background: linear-gradient(to right, transparent 0 var(--article-paper-inset), var(--paper) var(--article-paper-inset) calc(100% - var(--article-paper-inset)), transparent calc(100% - var(--article-paper-inset)) 100%);
  border: 0;
  box-shadow: none;
}
.article-header, .article-body { padding-inline: clamp(1.5rem, 6vw, 4.75rem); }
.article-header { padding-top: clamp(2.5rem, 7vw, 5.5rem); padding-bottom: 2rem; }
.article-body { padding-top: 0; padding-bottom: clamp(4rem, 8vw, 7rem); }
.kicker { margin: 0 0 1.1rem; color: var(--accent-text); font-size: .74rem; font-weight: 650; letter-spacing: .17em; text-transform: uppercase; }
.home-content .entry-meta span:first-child { color: var(--accent-text); }
h1, h2, h3 { font-family: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", sans-serif; }
h1 { margin: 0 0 1.5rem; font-size: clamp(1.6rem, 4vw, 3.2rem); font-weight: 700; line-height: 1; }
.lead { margin: 0; color: var(--ink); }
.byline { margin: 1.4rem 0 0; color: var(--muted); font-size: .82rem; letter-spacing: .035em; }
p { margin: 0; }
h1, h2, h3, p, li, blockquote { overflow-wrap: anywhere; }
.lead, .article-body p, .article-body li {
  color: var(--ink);
  font-size: clamp(1.15em, 1.4vw, 1.25em);
  line-height: 1.55;
  letter-spacing: .018em;
}
.article-body p + p { margin-top: 1.2em; }
.article-body ul,
.article-body ol { margin: 1.2em 0; padding-left: 1.5em; }
.article-body li + li { margin-top: .65em; }
.article-body section { padding-top: 2rem; }
.article-body section:first-child { padding-top: .75rem; }
h2 { margin: 2.5rem 0 1.5rem; padding-bottom: .7rem; border-bottom: 4px solid var(--accent); font-size: clamp(1.65rem, 3.2vw, 2.35rem); line-height: 1.12; }
.article-body h3 { margin: 1.8rem 0 .75rem; font-size: 1.45rem; }
.article-body .term-heading {
  margin: 1.8rem 0 .75rem;
  padding: .7rem 1rem;
  background: var(--accent-soft);
  border-left: 5px solid var(--accent);
  font-size: 1.45rem;
}
.term-heading + p { margin-top: 0; padding-inline: 1rem; }

body > footer {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 9rem;
  padding: 2rem clamp(1rem, 5vw, 5rem);
  background: var(--page);
}
body > footer nav { display: flex; gap: .85rem; }
body > footer .footer-notice { color: var(--muted); font-size: 1rem; text-align: right; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --page: #f4f1eb;
    --paper: #f4f1eb;
    --ink: #1b1d1f;
    --accent-text: #a70000;
    --muted: #666b6f;
    --line: #d8d3ca;
    --link: #155f68;
    --popover: rgba(255, 254, 251, .97);
    --popover-border: rgba(27, 29, 31, .18);
    --popover-divider: rgba(27, 29, 31, .14);
    --popover-hover: rgba(27, 29, 31, .06);
  }
  :root:not([data-theme="dark"]) .brand img,
  :root:not([data-theme="dark"]) .footer-wordmark { filter: none; }
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f4f1eb;
  --paper: #f4f1eb;
  --ink: #1b1d1f;
  --accent-text: #a70000;
  --muted: #666b6f;
  --line: #d8d3ca;
  --link: #155f68;
  --popover: rgba(255, 254, 251, .97);
  --popover-border: rgba(27, 29, 31, .18);
  --popover-divider: rgba(27, 29, 31, .14);
  --popover-hover: rgba(27, 29, 31, .06);
}
:root[data-theme="light"] .brand img,
:root[data-theme="light"] .footer-wordmark { filter: none; }
:root[data-theme="dark"] .brand img,
:root[data-theme="dark"] .footer-wordmark { filter: invert(1); }

@media (max-width: 70rem) {
  .masthead { grid-template-columns: 1fr auto; row-gap: .45rem; }
  .brand { grid-column: 1 / -1; grid-row: 1; justify-self: center; width: min(11rem, 46vw); }
  .header-actions-left { grid-column: 1; grid-row: 2; }
  .header-actions-right { grid-column: 2; grid-row: 2; }
}

@media (max-width: 46rem) {
  .masthead { display: flex; flex-direction: column; gap: .55rem; padding-inline: .5rem; }
  .brand { order: 1; width: min(11rem, 55vw); }
  .header-actions-left { order: 2; }
  .header-actions-right {
    order: 3;
    display: grid;
    grid-template-columns: repeat(4, 2.75rem);
    justify-content: center;
    gap: .35rem;
    width: 100%;
  }
  .header-link { font-size: 1rem; }
  main { scroll-margin-top: 14.5rem; }
  article { width: calc(100% - 1.5rem); }
  .article-header, .article-body { padding-inline: clamp(1.25rem, 6vw, 2.5rem); }
  .control-popover { position: fixed; top: auto; right: .75rem; bottom: .75rem; left: .75rem; width: auto; }
  .control-popover::before { display: none; }
  body > footer { align-items: flex-start; flex-direction: column; }
  body > footer .footer-notice { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tile, .theme-toggle .bulb-rays, .theme-toggle .bulb-core, .site-tooltip { transition: none !important; }
}
