/* CCE 2026 site stylesheet. No frameworks, no web fonts, no JavaScript needed. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-soft: #f2f5f8;
  --surface: #ffffff;
  --text: #16202b;
  --muted: #4d5966;
  --link: #0b5fb0;
  --link-hover: #073f77;
  --border: #cbd3dc;
  --code-bg: #f2f5f8;
  --quote-bg: #eaf2fb;
  --quote-border: #0b5fb0;
  --button-bg: #0b5fb0;
  --button-bg-2: #6d3bd1;
  --button-text: #ffffff;
  --live-bg: #b3121a;
  --live-bg-2: #8f0d14;
  --live-text: #ffffff;
  --nav-bg: rgba(255, 255, 255, 0.82);
  --focus: #e0700a;
  --grad-a: #0b5fb0;
  --grad-b: #7a2fb8;
  --grad-c: #c2185b;
  --grad-d: #0a7d6c;
  --glow-a: rgba(11, 95, 176, 0.16);
  --glow-b: rgba(122, 47, 184, 0.14);
  --glow-c: rgba(10, 125, 108, 0.12);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 6px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 10px 28px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.08), 0 20px 48px rgba(16, 24, 40, 0.16);
  --measure: 46rem;
  --gutter: 16px;
  --nav-h: 3.5rem;
  --radius: 0.75rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1318;
    --bg-soft: #181e26;
    --surface: #151b23;
    --text: #e8edf2;
    --muted: #aab5c0;
    --link: #8cc0ff;
    --link-hover: #b9d8ff;
    --border: #2f3a46;
    --code-bg: #181e26;
    --quote-bg: #162233;
    --quote-border: #8cc0ff;
    --button-bg: #2d7fd6;
    --button-bg-2: #7c5ce6;
    --button-text: #ffffff;
    --live-bg: #d0202a;
    --live-bg-2: #a3141c;
    --live-text: #ffffff;
    --nav-bg: rgba(15, 19, 24, 0.78);
    --focus: #ffb35c;
    --grad-a: #8cc0ff;
    --grad-b: #d7a3ff;
    --grad-c: #ff8fb1;
    --grad-d: #6fe3c8;
    --glow-a: rgba(140, 192, 255, 0.12);
    --glow-b: rgba(215, 163, 255, 0.1);
    --glow-c: rgba(111, 227, 200, 0.08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.45), 0 20px 48px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1318;
  --bg-soft: #181e26;
  --surface: #151b23;
  --text: #e8edf2;
  --muted: #aab5c0;
  --link: #8cc0ff;
  --link-hover: #b9d8ff;
  --border: #2f3a46;
  --code-bg: #181e26;
  --quote-bg: #162233;
  --quote-border: #8cc0ff;
  --button-bg: #2d7fd6;
  --button-bg-2: #7c5ce6;
  --button-text: #ffffff;
  --live-bg: #d0202a;
  --live-bg-2: #a3141c;
  --live-text: #ffffff;
  --nav-bg: rgba(15, 19, 24, 0.78);
  --focus: #ffb35c;
  --grad-a: #8cc0ff;
  --grad-b: #d7a3ff;
  --grad-c: #ff8fb1;
  --grad-d: #6fe3c8;
  --glow-a: rgba(140, 192, 255, 0.12);
  --glow-b: rgba(215, 163, 255, 0.1);
  --glow-c: rgba(111, 227, 200, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.45), 0 20px 48px rgba(0, 0, 0, 0.55);
}

/* Keyframes ------------------------------------------------------------- */

@keyframes shimmer {
  to {
    background-position: 300% center;
  }
}

/* One full pass: pause, type, hold, erase. The tagline loops it forever. */
@keyframes typing {
  0%,
  6% {
    width: 0;
  }
  51% {
    width: 27ch;
  }
  78% {
    width: 27ch;
  }
  88%,
  100% {
    width: 0;
  }
}

@keyframes caret {
  0%,
  49% {
    border-color: var(--grad-b);
  }
  50%,
  100% {
    border-color: transparent;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes drift {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(2%, 3%, 0) scale(1.06);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes stripes {
  to {
    background-position: 56px 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 60, 70, 0.45), var(--shadow-lg);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(255, 60, 70, 0), var(--shadow-lg);
  }
}

/* Heartbeat: two quick thumps, then rest. */
@keyframes event-beat {
  0%,
  100% {
    scale: 1;
  }
  12% {
    scale: 1.05;
  }
  24% {
    scale: 1;
  }
  36% {
    scale: 1.05;
  }
  48% {
    scale: 1;
  }
}

/* Base ------------------------------------------------------------------ */

* {
  box-sizing: border-box;
}

html {
  font-size: 112.5%; /* 18px: readable on a phone and on a projector */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (min-width: 48em) {
  html {
    font-size: 125%; /* 20px */
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  min-width: 0;
}

/* Ambient glow behind the page. Decorative only. */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 15% 10%, var(--glow-a), transparent 70%),
    radial-gradient(35% 35% at 85% 20%, var(--glow-b), transparent 70%),
    radial-gradient(45% 40% at 50% 100%, var(--glow-c), transparent 70%);
  animation: drift 24s ease-in-out infinite;
}

::selection {
  background: var(--grad-b);
  color: #ffffff;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

a {
  color: var(--link);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.14em;
  overflow-wrap: anywhere;
  transition: color 0.15s, text-decoration-color 0.15s;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--grad-c);
}

p,
li,
td,
th,
summary {
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  margin: 2rem 0 0.6rem;
  overflow-wrap: break-word;
  letter-spacing: -0.01em;
}

/* The title: a slowly shifting gradient. */
h1 {
  font-size: 2.3rem;
  margin-top: 1rem;
  font-weight: 800;
  background: linear-gradient(
    90deg,
    var(--grad-a),
    var(--grad-b),
    var(--grad-c),
    var(--grad-d),
    var(--grad-a)
  );
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 18px var(--glow-b));
  animation: shimmer 9s linear infinite;
}

h2 {
  font-size: 1.7rem;
  margin-top: 3rem;
}

h2::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 0.32rem;
  margin-top: 0.45rem;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c));
  box-shadow: 0 2px 10px var(--glow-b);
}

h3 {
  font-size: 1.3rem;
}

h2,
h3,
h4 {
  scroll-margin-top: calc(var(--nav-h) + 1rem);
}

/* Room for the sticky section menu on pages that have one. */
:root:has(.section-menu) h2,
:root:has(.section-menu) h3,
:root:has(.section-menu) h4 {
  scroll-margin-top: calc(var(--nav-h) + 4rem);
}

hr {
  border: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 2.5rem 0;
}

strong {
  font-weight: 700;
}

ul,
ol {
  padding-left: 1.4em;
}

li + li {
  margin-top: 0.25em;
}

li::marker {
  color: var(--grad-b);
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  background: var(--button-bg);
  color: var(--button-text);
  padding: 0.5em 1em;
  border-radius: 0.4rem;
  z-index: 100;
}

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

/* Header and nav -------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* The nav wraps instead of scrolling. A scrolling nav also scrolls
   vertically (the current pill's shadow overflows), which looked doubled. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.3rem var(--gutter);
  min-height: var(--nav-h);
}

.site-nav a {
  flex: 0 0 auto;
  padding: 0.4em 0.8em;
  border-radius: 99px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.site-nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.site-nav a.current {
  background: linear-gradient(135deg, var(--button-bg), var(--button-bg-2));
  color: var(--button-text);
  box-shadow: 0 4px 14px var(--glow-b);
}

.theme-toggle {
  margin-left: auto;
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.35em 0.8em;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.site-nav a.nav-contact {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  margin-left: auto;
  color: var(--link);
}

.nav-contact + .theme-toggle {
  margin-left: 0.25rem;
}

/* Mid widths: the contact link shows only its icon, so the nav stays on one line. */
@media (max-width: 64em) {
  .site-nav a {
    padding: 0.4em 0.55em;
  }

  .nav-contact-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Narrow screens: the nav wraps onto a second line instead of shrinking
   the labels, and the contact link drops to its icon. */
@media (max-width: 48em) {
  .site-nav {
    flex-wrap: wrap;
    overflow-x: visible;
    row-gap: 0;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }
}

@media (max-width: 30em) {
  .site-nav {
    font-size: 0.9rem;
    gap: 0.1rem;
    padding-left: 8px;
    padding-right: 8px;
  }

  .site-nav a {
    padding: 0.5em 0.6em;
  }

  .nav-contact-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .site-nav a.nav-contact {
    font-size: 1.15rem;
    padding: 0.4em 0.6em;
  }

  .theme-toggle {
    font-size: 0.8rem;
    padding: 0.4em 0.6em;
  }
}

/* Page layout ----------------------------------------------------------- */

.page {
  padding: 0.5rem var(--gutter) 3rem;
}

.page > * {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.page > :nth-child(2) { animation-delay: 0.08s; }
.page > :nth-child(3) { animation-delay: 0.16s; }
.page > :nth-child(4) { animation-delay: 0.24s; }
.page > :nth-child(5) { animation-delay: 0.32s; }
.page > :nth-child(6) { animation-delay: 0.4s; }
.page > :nth-child(7) { animation-delay: 0.48s; }
.page > :nth-child(n + 8) { animation-delay: 0.56s; }

/* The tagline under the title types itself out, terminal style. */
.page > h1 + p {
  font-size: min(1.35rem, calc((100vw - 40px) / 16.5));
  color: var(--muted);
  margin-top: 0;
  min-height: 1.6em;
}

.page > h1 + p em {
  display: inline-block;
  box-sizing: content-box; /* the 27ch width is the text alone */
  max-width: calc(100% - 0.3em);
  vertical-align: bottom;
  font-family: var(--mono);
  font-style: normal;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  border-right: 0.14em solid var(--grad-b);
  padding-right: 0.12em;
  color: var(--text);
  animation:
    typing 8s steps(27, end) 0.8s infinite both,
    caret 0.75s step-end 0.8s infinite;
}

/* Live banner (Demo 0 edits this line) ---------------------------------- */

.page > .live-banner {
  max-width: none;
  margin: 2rem calc(-1 * var(--gutter));
  padding: 1.15rem var(--gutter);
  color: var(--live-text);
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  background-color: var(--live-bg);
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0 14px,
    rgba(0, 0, 0, 0.14) 14px 28px
  );
  background-size: 56px 56px;
  border-top: 4px dashed rgba(255, 255, 255, 0.75);
  border-bottom: 4px dashed rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow-lg);
  animation:
    rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both,
    stripes 1.6s linear infinite,
    pulse 2.4s ease-in-out infinite;
}

.live-banner em {
  font-weight: 400;
}

/* Event line (Intro): colour-shifting, gently beating. ------------------- */

.page > .event-line {
  font-weight: 800;
  text-align: center;
  background: linear-gradient(
    90deg,
    var(--grad-a),
    var(--grad-b),
    var(--grad-c),
    var(--grad-d),
    var(--grad-a)
  );
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 14px var(--glow-b));
  animation:
    rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both,
    shimmer 6s linear infinite,
    event-beat 2.8s ease-in-out infinite;
}

/* Marker highlight: a hand-swiped highlighter stripe. -------------------- */

.marker {
  padding: 0.14em 0.42em 0.2em;
  margin: 0 0.12em;
  border-radius: 0.5em 0.22em 0.45em 0.18em / 0.28em 0.5em 0.22em 0.45em;
  background-image:
    linear-gradient(
      86deg,
      rgba(255, 238, 95, 0.35) 2%,
      rgba(255, 238, 95, 0) 62%
    ),
    linear-gradient(
      97deg,
      rgba(255, 222, 60, 0.18) 0%,
      rgba(255, 218, 45, 0.95) 3%,
      rgba(255, 216, 40, 0.88) 50%,
      rgba(255, 212, 32, 0.92) 90%,
      rgba(255, 204, 15, 0.45) 98%,
      rgba(255, 204, 15, 0.1) 100%
    );
  background-size: 100% 80%;
  background-position: 0 60%;
  background-repeat: no-repeat;
  color: #33290a;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Quotes: key ideas and definitions ------------------------------------- */

blockquote {
  position: relative;
  margin: 1.75rem auto;
  padding: 1.1rem 1.35rem 1.1rem 1.6rem;
  background: var(--quote-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.15em;
  box-shadow: var(--shadow);
  overflow: hidden;
}

blockquote::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.55rem;
  background: linear-gradient(180deg, var(--grad-a), var(--grad-b), var(--grad-c));
}

blockquote > :first-child {
  margin-top: 0;
}

blockquote > :last-child {
  margin-bottom: 0;
}

/* Code ------------------------------------------------------------------ */

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.08em 0.4em;
  border-radius: 0.35rem;
}

pre {
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin: 1.5rem auto;
  line-height: 1.45;
  overflow-x: auto;
  max-width: 100%;
  box-shadow: var(--shadow);
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.85em;
  border-radius: 0;
}

/* Diagrams: fenced `text` blocks. The block is centered; the lines keep
   their alignment. Auto margins center only when the content fits, so a
   wide diagram scrolls inside its box instead of being clipped on the left. */
pre.diagram {
  display: flex;
  text-align: left;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--grad-a), var(--grad-b), var(--grad-d)) border-box;
  border: 2px solid transparent;
}

pre.diagram code {
  display: block;
  margin: 0 auto;
  white-space: pre;
}

/* Prompts: fenced `prompt` blocks, copyable ----------------------------- */

.prompt-box {
  margin: 1.5rem auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.prompt-box:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.prompt-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: linear-gradient(135deg, var(--button-bg), var(--button-bg-2));
  color: var(--button-text);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.prompt-label::before {
  content: "❯ ";
  opacity: 0.8;
}

.copy {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--button-bg);
  background: #ffffff;
  border: 0;
  border-radius: 99px;
  padding: 0.3em 0.9em;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s, box-shadow 0.15s;
}

.copy:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.copy:active {
  transform: translateY(0);
}

.prompt-box pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: visible;
}

.prompt-box pre code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Buttons: the three-link list on the Intro page ------------------------ */

ul.buttons {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem auto;
}

ul.buttons li {
  margin: 0;
}

ul.buttons a,
p.next a {
  display: inline-block;
  background: linear-gradient(135deg, var(--button-bg), var(--button-bg-2));
  color: var(--button-text);
  padding: 0.7em 1.3em;
  border-radius: 99px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px var(--glow-b), var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s, filter 0.18s;
}

ul.buttons a:hover,
p.next a:hover {
  color: var(--button-text);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 28px var(--glow-b), var(--shadow);
  filter: brightness(1.08);
}

ul.buttons a:active,
p.next a:active {
  transform: translateY(-1px);
}

/* Section menu: the dot-separated link line at the top of a long page --- */

.page > .section-menu {
  position: sticky;
  top: var(--nav-h);
  z-index: 10;
  margin: 1rem auto;
  padding: 0.55rem 0.6rem;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

.section-menu a {
  text-decoration: none;
  overflow-wrap: normal;
  padding: 0.2em 0.5em;
  border-radius: 99px;
  transition: background 0.15s;
}

.section-menu a:hover {
  background: var(--quote-bg);
  text-decoration: none;
}

/* Contact links: icon + label rows on the Intro and About pages --------- */

.contact-links ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.25rem auto;
}

.contact-links li {
  margin: 0;
}

.contact-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.5em 0.95em;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.contact-links a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.contact-links i {
  width: 1.2em;
  text-align: center;
}

/* Tables of contents on the Explanation page ---------------------------- */

nav.toc {
  margin: 1.5rem auto;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

nav.toc > p:first-child {
  margin-top: 0;
  font-weight: 700;
}

nav.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0.4rem 0 0;
}

nav.toc ul ul {
  padding-left: 1.25rem;
  margin: 0.2rem 0 0.6rem;
  font-size: 0.95em;
}

nav.toc li {
  margin: 0.2rem 0;
}

nav.toc a {
  text-decoration: none;
}

nav.toc a:hover {
  text-decoration: underline;
}

nav.toc-part ul {
  columns: 2 16rem;
  column-gap: 2rem;
}

nav.toc-part li {
  break-inside: avoid;
}

/* Details and summary --------------------------------------------------- */

details {
  margin: 1.5rem auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 1rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

details:hover {
  box-shadow: var(--shadow);
}

details[open] {
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}

summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--link);
  padding: 0.85rem 0;
  list-style: none;
}

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

summary::before {
  content: "▸";
  display: inline-block;
  width: 1.2em;
  transition: transform 0.2s;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details[open] summary {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

details[open] > :not(summary) {
  animation: rise 0.35s ease-out both;
}

details > :last-child {
  margin-bottom: 1rem;
}

/* Tables ---------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  margin: 1.5rem auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95em;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.8rem;
  text-align: left;
  vertical-align: top;
}

td + td,
th + th {
  border-left: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: 0;
}

th {
  background: linear-gradient(180deg, var(--bg-soft), var(--surface));
  font-weight: 700;
}

tbody tr:hover {
  background: var(--quote-bg);
}

/* Images ---------------------------------------------------------------- */

img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

img[src$="headshot-crop.jpg"] {
  width: 15rem;
  border-radius: 1.25rem;
  padding: 4px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b), var(--grad-c));
  box-shadow: var(--shadow-lg);
}

img[src$="qr-site.png"],
img[src$="qr-contact.png"] {
  width: min(100%, 17rem);
  padding: 0.75rem;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
}

/* About page: contact QR above the headshot on phones, left of it on wide screens */
.about-portrait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: 1.5rem auto;
}

.about-portrait p {
  margin: 0;
}

.about-portrait img {
  margin: 0 auto;
}

.about-qr {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.about-qr img {
  width: 15rem;
  margin-bottom: 0.5rem;
}

@media (min-width: 48em) {
  .about-portrait {
    flex-direction: row;
    justify-content: center;
    gap: 2.5rem;
    margin-bottom: 3rem;
  }

  /* Keep the caption out of the row's alignment so the QR and photo line up */
  .about-qr {
    position: relative;
  }

  .about-qr p:last-child {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
  }
}

/* Next link ------------------------------------------------------------- */

p.next {
  margin-top: 2rem;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: right;
}

p.next a {
  padding: 0.65em 1.3em;
}

/* Footer ---------------------------------------------------------------- */

.site-footer {
  position: relative;
  padding: 1.75rem var(--gutter) 2.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c), var(--grad-d));
}

.site-footer p {
  margin: 0.3rem 0;
}

/* Reduced motion: everything still looks finished, nothing moves. ------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.001s !important;
  }

  .page > h1 + p em {
    width: auto;
    border-right-color: transparent;
  }

  body::before {
    animation: none;
  }
}
