/* ==========================================================================
   DMV Roleplay — Server Guidelines
   Every colour is a token below. Change --accent to rebrand the whole site.
   ========================================================================== */

/* ---------- Tokens ---------- */
/* Neutral greys only: the logo is the one thing on the page with colour. */
:root {
  --accent: #e5e5e5; /* silver, like the logo's chrome */

  --font-display: "Archivo", "Arial Black", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  --header-h: 4rem;
  --maxw: 68.75rem;
  --radius: 1.125rem;
  --radius-sm: 0.75rem;

  /* Motion curves */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-sweep: cubic-bezier(0.45, 0, 0.55, 1); /* even pace for the glints */

  /* Dark theme (default): obsidian grey */
  color-scheme: dark;
  --bg: #171717;
  --surface: #1f1f1f;
  --surface-2: #262626;
  --border: #2e2e2e;
  --border-strong: #3d3d3d;
  --text: #f5f5f5;
  --text-body: #d4d4d4;
  --text-muted: #a3a3a3;
  --text-faint: #5c5c5c;
  --accent-text: #bdbdbd; /* rule numbers, labels, links */
  --accent-ink: #171717; /* text and icons on top of --accent */
  --accent-wash: rgb(255 255 255 / 0.05);
  --glow: rgb(255 255 255 / 0.06); /* soft light at the top of the page */
  --badge-glow: rgb(255 255 255 / 0.16); /* behind the logo */
  --rays: rgb(255 255 255 / 0.09); /* light rays behind the logo */
  --spot: rgb(255 255 255 / 0.045); /* light that follows the cursor on cards */
  --header-bg: rgb(23 23 23 / 0.8);
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 1.5rem 3rem -2rem rgb(0 0 0 / 0.9);
  /* Polished-chrome fill for the page title, like the logo's lettering */
  --chrome: linear-gradient(180deg, #ffffff 8%, #e8e8e8 44%, #8c8c8c 52%, #d0d0d0 74%, #f7f7f7 100%);

  /* Punishment classes, mildest (A) to most severe (D): darker grey up to bright silver */
  --sev-a: color-mix(in srgb, var(--accent) 30%, var(--surface-2));
  --sev-b: color-mix(in srgb, var(--accent) 55%, var(--surface-2));
  --sev-c: color-mix(in srgb, var(--accent) 80%, var(--surface-2));
  --sev-d: var(--accent);
  --sev-a-ink: #fff;
  --sev-b-ink: #171717;
  --sev-c-ink: #171717;
  --sev-d-ink: #171717;
}

:root[data-theme="light"] {
  color-scheme: light;
  --accent: #262626; /* charcoal on the light theme */
  --bg: #f0f0f0;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --border: #e2e2e2;
  --border-strong: #d0d0d0;
  --text: #0a0a0a;
  --text-body: #262626;
  --text-muted: #525252;
  --text-faint: #a3a3a3;
  --accent-text: #404040;
  --accent-ink: #fafafa;
  --accent-wash: rgb(0 0 0 / 0.04);
  --glow: rgb(255 255 255 / 0.85);
  --badge-glow: rgb(0 0 0 / 0.1);
  --rays: rgb(0 0 0 / 0.045);
  --spot: rgb(0 0 0 / 0.03);
  --header-bg: rgb(240 240 240 / 0.82);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 1rem 2rem -1.5rem rgb(0 0 0 / 0.25);
  /* Graphite instead of chrome so the title stays readable on a light page */
  --chrome: linear-gradient(180deg, #4d4d4d 0%, #0f0f0f 48%, #2b2b2b 62%, #5c5c5c 100%);

  --sev-a-ink: #0a0a0a;
  --sev-b-ink: #0a0a0a;
  --sev-c-ink: #fafafa;
  --sev-d-ink: #fafafa;
}

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

[hidden] {
  display: none !important;
}

/* Auto scale: up to 1440px wide the page uses the visitor's normal text size. On wider screens
   everything grows with the window (sizes in this file are in rem), so a big monitor shows the
   same layout, just larger, up to twice the size. 1.111vw is 16px at 1440px wide; to start
   growing at a wider screen, lower it (1vw starts at 1600px). */
html {
  font-size: clamp(100%, 1.111vw, 200%);
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.25rem);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text-body);
  font: 400 1rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Soft accent glow behind the top of the page */
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 47.5rem;
  background: radial-gradient(55% 65% at 75% 0%, var(--glow), transparent 70%);
  pointer-events: none;
}

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

strong,
b {
  font-weight: 650;
  color: var(--text);
}

code {
  padding: 0.12em 0.4em;
  font: 600 0.875em/1 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0.375rem;
}

abbr[title] {
  text-decoration: none;
  cursor: help;
}

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

::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -3.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.625rem 0.875rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 0.625rem;
  text-decoration: none;
  transition: top 0.15s;
}

.skip-link:focus {
  top: 0.75rem;
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(160%) blur(0.875rem);
  backdrop-filter: saturate(160%) blur(0.875rem);
  transition: background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* See-through at the very top of the page, solid once you scroll */
html.js .topbar:not(.is-scrolled) {
  background-color: transparent;
  border-bottom-color: transparent;
}

.topbar.is-scrolled {
  box-shadow: 0 0.875rem 2rem -1.625rem rgb(0 0 0 / 0.8);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: var(--maxw);
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-right: auto;
  color: var(--text);
  text-decoration: none;
}

.brand-badge {
  position: relative;
  isolation: isolate;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  transition: transform 0.6s var(--ease-spring);
}

.brand-badge img {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0.25rem 0.625rem rgb(0 0 0 / 0.35));
}

.brand:hover .brand-badge {
  transform: rotate(-10deg) scale(1.08);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-name span {
  font-weight: 600;
  color: var(--text-muted);
}

.search {
  position: relative;
  flex: 0 1 20rem;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  width: 1rem;
  height: 1rem;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem 0 2.375rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.1875rem var(--accent-wash);
}

.search kbd {
  position: absolute;
  top: 50%;
  right: 0.625rem;
  display: grid;
  place-items: center;
  min-width: 1.375rem;
  height: 1.375rem;
  padding: 0 0.375rem;
  font: 600 0.75rem/1 var(--font-body);
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 0.375rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.search input:focus ~ kbd,
.search input:not(:placeholder-shown) ~ kbd {
  display: none;
}

.icon-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, scale 0.2s var(--ease-out);
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--text-faint);
}

.icon-btn:active {
  scale: 0.92;
}

.icon-btn svg {
  width: 1.125rem;
  height: 1.125rem;
}

.menu-btn,
.icon-moon {
  display: none;
}

:root[data-theme="light"] .icon-sun {
  display: none;
}

:root[data-theme="light"] .icon-moon {
  display: block;
}

/* ---------- Layout ---------- */
/* Trims the logo's glow and light rays at the screen edges so the page never scrolls sideways.
   "clip" (unlike "hidden") keeps the sticky header and sidebar working. */
.page {
  overflow-x: clip;
}

.layout {
  display: grid;
  grid-template-columns: 15.625rem minmax(0, 1fr);
  gap: 3rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  min-width: 0;
  padding: 3rem 0 6rem;
  outline: none;
}

.scrim {
  display: none;
}

/* ---------- Contents sidebar ---------- */
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 2rem);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 3rem);
  margin-top: 3rem;
  padding: 2px 0.375rem 1.5rem 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.toc-title {
  margin: 0 0 0.75rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.toc-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 0.625rem;
  transition: color 0.2s, opacity 0.2s, translate 0.35s var(--ease-out);
}

.toc-list a:hover {
  color: var(--text);
}

.toc-list a.is-active {
  font-weight: 600;
  color: var(--text);
}

.toc-list a.is-dim {
  opacity: 0.35;
}

.toc-num {
  flex: none;
  width: 1.5rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent-text);
}

.toc-num svg {
  width: 0.875rem;
  height: 0.875rem;
  vertical-align: -0.1875rem;
}

/* ---------- Hero ---------- */
.hero {
  padding: 0.5rem 0 2.25rem;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.125rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.eyebrow .stars {
  flex: none;
  width: 2.75rem;
  height: auto;
  fill: currentColor;
}

.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.hero-title {
  flex: 1 1 0;
  min-width: 0;
  container-type: inline-size;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 12cqi, 4.25rem); /* "GUIDELINES" is ~8em wide, so 12% of the column always fits */
  font-weight: 900;
  font-stretch: 125%;
  line-height: 0.95;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  color: var(--text);
  /* Two layers: a reflection that sweeps across (see Motion) over the chrome band, repeated per line.
     The reflection is a white core with darker edges, so it shows even on near-white chrome. */
  background-image:
    linear-gradient(
      105deg,
      transparent 35%,
      rgb(48 48 48 / 0.6) 44%,
      #fff 50%,
      rgb(48 48 48 / 0.6) 56%,
      transparent 65%
    ),
    var(--chrome);
  background-size: 250% 100%, 100% 0.95em;
  background-position: 110% 0, 0 0;
  background-repeat: no-repeat, repeat;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero h1::selection {
  -webkit-text-fill-color: var(--text);
}

.hero-badge {
  position: relative;
  isolation: isolate;
  flex: none;
  width: clamp(9.375rem, 19vw, 14.375rem);
  perspective: 56.25rem;
}

.badge {
  position: relative;
  will-change: transform;
}

.hero-badge::before {
  content: "";
  position: absolute;
  inset: -14%;
  z-index: -1;
  background: radial-gradient(closest-side, var(--badge-glow), transparent);
}

.hero-badge img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 1.125rem 1.75rem rgb(0 0 0 / 0.45));
}

/* Light effects on the logo, cut to the logo's own shape */
.shine,
.glare {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask: url("logo.webp") center / contain no-repeat;
  mask: url("logo.webp") center / contain no-repeat;
}

.shine {
  mix-blend-mode: screen;
}

/* The glint that sweeps across: a bright streak with a thinner one trailing it */
.shine::before {
  content: "";
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: 0;
  width: 55%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgb(255 255 255 / 0.08) 18%,
    rgb(255 255 255 / 0.8) 36%,
    rgb(255 255 255 / 0.08) 50%,
    transparent 57%,
    rgb(255 255 255 / 0.5) 67%,
    transparent 76%
  );
  transform: translateX(-155%) skewX(-20deg);
}

/* Highlight that follows the cursor (desktop) */
.glare {
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 30%), rgb(255 255 255 / 0.42), transparent 46%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
}

.hero-badge.is-tilting .glare {
  opacity: 1;
}

.hero p {
  max-width: 62ch;
  margin: 0 0 0.875rem;
}

.hero .lead {
  font-size: 1.1875rem;
  line-height: 1.55;
  color: var(--text);
}

.hero .hero-meta {
  margin-top: 1.625rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ---------- Search status ---------- */
.search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  padding: 0.625rem 0.625rem 0.625rem 1.125rem;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.text-btn {
  flex: none;
  padding: 0.375rem 0.625rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-text);
  background: none;
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
}

.text-btn:hover {
  background: var(--accent-wash);
}

.empty {
  margin-top: 1rem;
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty strong {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 1.0625rem;
}

body.is-searching .hero {
  display: none;
}

::highlight(search-hit) {
  background-color: #facc15;
  color: #09090b;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  isolation: isolate;
  margin-top: 1rem;
  padding: clamp(1.375rem, 1rem + 1.6vw, 2.125rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

/* Soft light under the cursor (position set by script.js), drawn behind the card's content */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(32.5rem circle at var(--mx, 50%) var(--my, -18.75rem), var(--spot), transparent 65%);
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}

.card:target {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
  box-shadow: 0 0 0 0.25rem var(--accent-wash), var(--shadow);
}

.card h2 {
  margin: 0;
  padding-right: 2.75rem;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1rem + 1vw, 1.625rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 1.12;
  text-transform: uppercase;
  color: var(--text);
}

.card h2 .num {
  display: block;
  margin-bottom: 0.625rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  font-stretch: 100%;
  letter-spacing: 0.16em;
  color: var(--accent-text);
}

.card p {
  margin: 0.875rem 0 0;
}

.card .lead-in {
  margin-top: 1.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.copy-link {
  position: absolute;
  top: 1.125rem;
  right: 1.125rem;
  display: grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.625rem;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s, scale 0.2s var(--ease-out);
}

.card:hover .copy-link {
  color: var(--text-muted);
  border-color: var(--border);
}

.copy-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.copy-link:active {
  scale: 0.88;
}

.copy-link svg {
  width: 1rem;
  height: 1rem;
}

/* After copying, the link icon turns into a check mark for a moment */
.copy-link .icon-check {
  display: none;
}

.copy-link.is-copied,
.card:hover .copy-link.is-copied {
  color: var(--accent-text);
}

.copy-link.is-copied .icon-link {
  display: none;
}

.copy-link.is-copied .icon-check {
  display: block;
  animation: pop 0.45s var(--ease-spring);
}

/* Punishment line + A–D meter */
.penalty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.625rem;
  width: fit-content;
  max-width: 100%;
  padding: 0.3125rem 0.875rem 0.3125rem 0.3125rem;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.penalty b {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meter {
  display: inline-flex;
  gap: 0.1875rem;
}

.meter i {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-style: normal;
  font-weight: 800;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 0.4375rem;
}

.meter i.on {
  border-color: transparent;
}

.meter i.on[data-c="A"] { color: var(--sev-a-ink); background: var(--sev-a); }
.meter i.on[data-c="B"] { color: var(--sev-b-ink); background: var(--sev-b); }
.meter i.on[data-c="C"] { color: var(--sev-c-ink); background: var(--sev-c); }
.meter i.on[data-c="D"] { color: var(--sev-d-ink); background: var(--sev-d); }

/* Rule lists */
.items {
  display: grid;
  gap: 0.5rem;
  margin: 0.625rem 0 0;
  padding: 0;
  list-style: none;
}

.items.cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.items li {
  position: relative;
  padding: 0.625rem 0.875rem 0.625rem 2rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.3s ease;
}

.items li::before {
  content: "";
  position: absolute;
  top: calc(0.625rem + 0.75em - 0.1875rem);
  left: 0.875rem;
  width: 0.375rem;
  height: 0.375rem;
  background: var(--accent);
  border-radius: 1.5px;
  transform: rotate(45deg);
  transition: transform 0.5s var(--ease-spring);
}

/* Takeaway line */
.card .note {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  background: var(--accent-wash);
  border-left: 0.1875rem solid var(--accent);
  border-radius: 0.25rem var(--radius-sm) var(--radius-sm) 0.25rem;
}

/* RDM / VDM definitions */
.defs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.625rem;
  margin: 1.125rem 0 0;
}

.defs div {
  padding: 1rem 1.125rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.defs dt {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 900;
  font-stretch: 125%;
  line-height: 1;
  color: var(--accent-text);
}

.defs dd {
  margin: 0.625rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Punishment classes */
.class-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.625rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.class-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem 0.75rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
}

.class-letter {
  display: grid;
  flex: none;
  place-items: center;
  width: 3rem;
  height: 3rem;
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 900;
  font-stretch: 125%;
  border-radius: 0.6875rem;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), inset 0 -1px 0 rgb(0 0 0 / 0.2);
}

.class-item[data-class="A"] .class-letter { color: var(--sev-a-ink); background: var(--sev-a); }
.class-item[data-class="B"] .class-letter { color: var(--sev-b-ink); background: var(--sev-b); }
.class-item[data-class="C"] .class-letter { color: var(--sev-c-ink); background: var(--sev-c); }
.class-item[data-class="D"] .class-letter { color: var(--sev-d-ink); background: var(--sev-d); }

.class-item p {
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.class-item strong {
  display: block;
  margin-bottom: 0.1875rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Final reminders */
.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.checks li {
  position: relative;
  padding: 0.6875rem 0 0.6875rem 2.125rem;
  line-height: 1.45;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.checks li::before {
  content: "";
  position: absolute;
  top: 0.75rem;
  left: 0;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--accent);
  border-radius: 0.375rem;
}

/* The tick, cut out of a solid fill so its colour follows the theme */
.checks li::after {
  content: "";
  position: absolute;
  top: 0.75rem;
  left: 0;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--accent-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 0.75rem no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 0.75rem no-repeat;
}

.card .statement {
  margin-top: 1.5rem;
  padding: 1.125rem 1.25rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 2.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer p {
  margin: 0;
}

.footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}

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

.footer svg {
  width: 1rem;
  height: 1rem;
  transition: translate 0.35s var(--ease-spring);
}

.footer a:hover svg {
  translate: 0 -0.1875rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 60;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: 0 0.75rem 2rem -0.75rem rgb(0 0 0 / 0.5);
  opacity: 0;
  transform: translate(-50%, 1rem) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.5s var(--ease-spring);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================================================
   Motion
   Runs only when <html> has the "motion" class. The page adds it unless the
   visitor's device is set to reduce motion, so those visitors get a still page.
   ========================================================================== */
@keyframes rise {
  from { opacity: 0; transform: translateY(1.125rem); }
}

@keyframes fade {
  from { opacity: 0; }
}

@keyframes drop {
  from { opacity: 0; transform: translateY(-100%); }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-1.125rem); }
}

@keyframes title-in {
  from { opacity: 0; transform: translateY(1.75rem); filter: blur(0.75rem); }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(2.25rem) scale(0.98); }
}

@keyframes item-in {
  from { opacity: 0; transform: translateY(0.875rem); }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.3); }
}

@keyframes icon-in {
  from { opacity: 0; transform: rotate(-120deg) scale(0.4); }
}

@keyframes badge-in {
  from { opacity: 0; scale: 0.6; rotate: y -90deg; }
}

@keyframes badge-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -0.625rem; }
}

@keyframes glow-breathe {
  0%, 100% { opacity: 1; scale: 1; }
  50% { opacity: 0.6; scale: 0.9; }
}

@keyframes spin {
  to { rotate: 1turn; }
}

/* The glints start just off one edge and end just off the other, so the whole sweep is visible */
@keyframes shine-sweep {
  0% { transform: translateX(-155%) skewX(-20deg); }
  25%, 100% { transform: translateX(240%) skewX(-20deg); }
}

@keyframes shine-once {
  from { transform: translateX(-155%) skewX(-20deg); }
  to { transform: translateX(240%) skewX(-20deg); }
}

@keyframes title-shine {
  0% { background-position: 110% 0, 0 0; }
  25%, 100% { background-position: -10% 0, 0 0; }
}

@keyframes reveal-fallback {
  to { opacity: 1; }
}

/* Page load: header, contents, then the hero one line after another */
.motion .topbar {
  animation: drop 0.8s var(--ease-out) backwards;
}

.motion .toc {
  animation: slide-in 0.9s var(--ease-out) 0.35s backwards;
}

.motion .eyebrow {
  animation: rise 0.8s var(--ease-out) 0.1s backwards;
}

.motion .hero h1 {
  animation:
    title-in 1.1s var(--ease-out) 0.2s backwards,
    title-shine 8s var(--ease-sweep) 1.2s infinite;
}

.motion .hero > p {
  animation: rise 0.9s var(--ease-out) backwards;
}

.motion .hero > p:nth-of-type(1) { animation-delay: 0.42s; }
.motion .hero > p:nth-of-type(2) { animation-delay: 0.5s; }
.motion .hero > p:nth-of-type(3) { animation-delay: 0.58s; }
.motion .hero > p:nth-of-type(4) { animation-delay: 0.66s; }

/* Logo: flips in like a coin, floats with a breathing glow and slow light rays,
   and a chrome glint crosses it every 8 seconds, just after the one on the title */
.motion .badge {
  animation:
    badge-in 1.5s var(--ease-spring) 0.15s backwards,
    badge-float 6s ease-in-out 1.65s infinite;
}

.motion .hero-badge::before {
  animation:
    fade 1.2s ease 0.3s backwards,
    glow-breathe 6s ease-in-out 1.65s infinite;
}

.motion .hero-badge::after {
  content: "";
  position: absolute;
  inset: -26%;
  z-index: -1;
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 14deg,
    var(--rays) 22.5deg,
    transparent 31deg 45deg
  );
  -webkit-mask: radial-gradient(closest-side, #000 35%, transparent 100%);
  mask: radial-gradient(closest-side, #000 35%, transparent 100%);
  animation:
    fade 2s ease 0.8s backwards,
    spin 60s linear infinite;
}

.motion .hero-badge .shine::before {
  animation: shine-sweep 8s var(--ease-sweep) 1.9s infinite;
}

/* Scrolled past the top: freeze the looping effects (they pick up where they left off) */
.hero.is-offscreen *,
.hero.is-offscreen *::before,
.hero.is-offscreen *::after {
  animation-play-state: paused !important; /* beats the more specific animation rules above */
}

/* Scroll reveal: cards rise in as they come into view (script.js adds .is-visible) */
.motion .card:not(.is-visible) {
  opacity: 0;
}

/* Safety net: if script.js never runs, show the cards anyway */
.motion:not(.motion-ready) .card:not(.is-visible) {
  animation: reveal-fallback 0.6s ease 2.5s forwards;
}

.motion .card.is-visible {
  animation: card-in 0.9s var(--ease-out) backwards;
}

.motion .card.is-visible :is(.items li, .class-item, .checks li, .defs > div) {
  animation: item-in 0.65s var(--ease-out) backwards;
  animation-delay: calc(0.15s + min(var(--i, 0), 14) * 0.045s);
}

.motion .card.is-visible .meter i.on {
  animation: pop 0.55s var(--ease-spring) backwards;
  animation-delay: calc(0.3s + var(--i, 0) * 0.08s);
}

/* Search results bar and "no results" message */
.motion .search-bar,
.motion .empty {
  animation: rise 0.45s var(--ease-out);
}

/* The theme button's icon spins in when it changes */
.motion #theme-toggle svg {
  animation: icon-in 0.6s var(--ease-spring);
}

/* Mobile menu entries slide in one after another */
@media (max-width: 900px) {
  .motion body.nav-open .toc-list li {
    animation: slide-in 0.5s var(--ease-out) backwards;
    animation-delay: calc(0.08s + min(var(--i, 0), 16) * 0.025s);
  }
}

/* Theme switch: the new theme grows out of the button in a circle (script.js) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* Hover details */
.class-item,
.defs div {
  transition: border-color 0.3s ease;
}

.class-letter {
  transition: scale 0.5s var(--ease-spring), rotate 0.5s var(--ease-spring);
}

@media (hover: hover) {
  .toc-list a:hover {
    translate: 0.25rem 0;
  }

  .items li:hover,
  .class-item:hover,
  .defs div:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  }

  .items li:hover::before {
    transform: rotate(225deg) scale(1.35);
  }

  .class-item:hover .class-letter {
    scale: 1.08;
    rotate: -6deg;
  }

  .motion .brand:hover .shine::before {
    animation: shine-once 0.9s var(--ease-sweep);
  }
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  }

  .motion .card:hover::after {
    opacity: 1;
  }
}

/* ---------- Without JavaScript ---------- */
html:not(.js) .sidebar,
html:not(.js) .search,
html:not(.js) #theme-toggle {
  display: none;
}

html:not(.js) .layout {
  display: block;
  max-width: 50rem;
}

/* ---------- Tablet: contents become a slide-in drawer ---------- */
@media (max-width: 900px) {
  .menu-btn {
    display: inline-grid;
  }

  .layout {
    display: block;
    max-width: 47.5rem;
    padding: 0 1.25rem;
  }

  main {
    padding-top: 2rem;
  }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    z-index: 45;
    align-self: auto; /* fill the space under the header instead of sizing to the list */
    width: min(20rem, 86vw);
    max-height: none;
    margin: 0;
    padding: 1.25rem 0.875rem 2rem;
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: 1.5rem 0 3rem -1.5rem rgb(0 0 0 / 0.5);
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }

  body.nav-open .sidebar {
    visibility: visible;
    transform: none;
    transition: transform 0.25s ease;
  }

  .scrim {
    position: fixed;
    inset: var(--header-h) 0 0;
    z-index: 44;
    display: block;
    background: rgb(0 0 0 / 0.5);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.25s, visibility 0s linear 0.25s;
  }

  body.nav-open .scrim {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.25s;
  }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  :root {
    --header-h: 7rem;
  }

  .topbar-inner {
    flex-wrap: wrap;
    align-content: center;
    row-gap: 0.625rem;
    padding: 0 1rem;
  }

  .search {
    flex: 1 0 100%;
    order: 3;
  }

  .hero-head {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 1rem;
  }

  .hero-title {
    flex: none;
  }

  .hero-badge {
    width: 8.25rem;
  }

  .search kbd {
    display: none;
  }

  .layout {
    padding: 0 1rem;
  }

  main {
    padding: 1.5rem 0 4rem;
  }

  .card {
    border-radius: 1rem;
  }

  .items.cols,
  .class-grid,
  .defs,
  .checks {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (hover: none) {
  .search kbd {
    display: none;
  }

  .copy-link {
    color: var(--text-muted);
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/* ---------- Print ---------- */
@media print {
  :root,
  :root[data-theme="light"] {
    --bg: #fff;
    --surface: #fff;
    --surface-2: #fff;
    --text: #000;
    --text-body: #111;
    --text-muted: #444;
    --border: #ccc;
    --border-strong: #bbb;
    --shadow: none;
    /* Dark ink on paper whichever theme is on screen */
    --accent: #262626;
    --accent-text: #404040;
    --accent-ink: #fafafa;
    --accent-wash: rgb(0 0 0 / 0.04);
    --text-faint: #a3a3a3;
    --sev-a-ink: #0a0a0a;
    --sev-b-ink: #0a0a0a;
    --sev-c-ink: #fafafa;
    --sev-d-ink: #fafafa;
  }

  /* Browsers leave out background colours when printing; these need theirs to stay readable */
  .meter,
  .class-letter,
  .checks,
  .items {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .topbar,
  .sidebar,
  .scrim,
  .copy-link,
  .skip-link,
  .search-bar,
  .footer a,
  .toast {
    display: none !important;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .card {
    opacity: 1 !important; /* cards not scrolled to yet are still hidden on screen */
  }

  body::before,
  .hero-badge::before,
  .hero-badge::after,
  .card::after,
  .shine,
  .glare {
    display: none !important;
  }

  .hero h1 {
    background: none;
    -webkit-text-fill-color: currentColor;
  }

  .layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  main {
    padding: 0;
  }

  .card {
    break-inside: avoid;
  }
}
