@font-face { font-family: "Instrument Serif"; src: url(fonts/instrument-serif-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Instrument Serif"; font-style: italic; src: url(fonts/instrument-serif-latin-400-italic.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(fonts/instrument-sans-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Instrument Sans"; font-weight: 600; src: url(fonts/instrument-sans-latin-600-normal.woff2) format("woff2"); font-display: swap; }

:root {
  --bg: #f6f1ea;
  --card: #fbf8f3;
  --soft: #efe3d4;
  --ink: #2b2622;
  --muted: #675d53;
  --line: #e0d5c7;
  --accent: #c9471f;
  --accent-ink: #a33915;
  --fold: #8f3214;
  --bubble: #efe3d4;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --measure: 44rem;
  --breath: 8s;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1714;
    --card: #231f1b;
    --soft: #2c2520;
    --ink: #f1eae1;
    --muted: #b4a99c;
    --line: #3a332c;
    --accent: #ef8259;
    --accent-ink: #f39a78;
    --fold: #c25a35;
    --bubble: #3a312a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: .2em; }
a, button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
p { margin: 0 0 1rem; text-wrap: pretty; }
h1, h2, h3 { font-weight: 400; margin: 0; text-wrap: balance; }

.skip { position: absolute; left: 1rem; top: -3rem; background: var(--ink); color: var(--bg); padding: .5rem .9rem; border-radius: 6px; z-index: 2; }
.skip:focus { top: 1rem; }

.intro, main, .foot { max-width: var(--measure); margin-inline: auto; padding-inline: 1.25rem; }

.intro { text-align: center; padding-block: clamp(4rem, 13vh, 8rem) 3rem; }
.glyph { width: 3.5rem; margin: 0 auto 2rem; display: block; }
.glyph .face { fill: var(--accent); }
.glyph .fold { fill: var(--fold); }
.kicker { font-size: .8rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 1rem; }
h1 { font: 400 clamp(2.9rem, 10vw, 5.2rem)/.98 var(--serif); letter-spacing: -.01em; margin-bottom: 2rem; }
h1 em { display: block; color: var(--accent); }
.lede { color: var(--muted); max-width: 33rem; margin-inline: auto; }
.pull { font: italic 400 clamp(1.45rem, 3.5vw, 1.8rem)/1.3 var(--serif); max-width: 30rem; margin: 1.6rem auto; }
.aside { font-size: .95rem; color: var(--muted); text-align: left; border-left: 2px solid var(--line); padding: .15rem 0 .15rem 1.1rem; max-width: 28rem; margin: 0 auto; }
.stages-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: .45rem; margin-top: 2.5rem; }
.stages-nav a {
  font-size: .85rem; text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: .4rem .85rem;
  transition: background-color .2s ease, border-color .2s ease;
}
.stages-nav a:hover { background: var(--soft); border-color: transparent; }

.stage { display: grid; gap: .25rem 2rem; padding-block: clamp(2.75rem, 7vw, 3.75rem); border-top: 1px solid var(--line); scroll-margin-top: 1.5rem; }
@media (min-width: 44rem) { .stage { grid-template-columns: 6rem 1fr; } }
.num { font: italic 400 clamp(3.5rem, 9vw, 4.75rem)/.9 var(--serif); color: var(--accent); margin: 0; }
@media (min-width: 64rem) {
  .num { font-size: 8rem; line-height: .8; margin-left: -3rem; }
}
.stage h2 { font: 400 2.25rem/1.1 var(--serif); margin-bottom: 1.25rem; }
.said { font: italic 400 1.6rem/1.3 var(--serif); padding-left: 1rem; border-left: 2px solid var(--accent); margin-bottom: 1.25rem; }
.caps { font-style: normal; letter-spacing: .04em; }
.why { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.why li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.why li:last-child { border-bottom: 0; }

.breathe {
  display: flex; align-items: center; gap: 1rem; width: 100%; text-align: left; cursor: pointer;
  font: inherit; color: inherit; background: var(--soft); border: 0; border-radius: 14px; padding: 1rem 1.25rem; margin-top: 1.5rem;
}
.breathe { transition: background-color .2s ease; }
.breathe:hover { background: color-mix(in srgb, var(--soft) 80%, var(--accent)); }
.breathe[aria-pressed="true"] .orb { opacity: .85; }
.orb { width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); flex: none; opacity: .4; transform: scale(.45); animation: breathe var(--breath) ease-in-out infinite paused; }
.cue { position: relative; font-size: .95rem; color: var(--muted); min-width: 7rem; height: 1.6em; }
.cue span { position: absolute; inset: 0; animation: cue-in var(--breath) step-end infinite paused; }
.breathe:hover .orb, .breathe:hover .cue span, .breathe.is-running .orb, .breathe.is-running .cue span { animation-play-state: running; }
.cue .out { animation-name: cue-out; }
@keyframes breathe { 0%, 100% { transform: scale(.45); opacity: .4; } 50% { transform: scale(1); opacity: .85; } }
@keyframes cue-in { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes cue-out { 0% { opacity: 0; } 50% { opacity: 1; } }

.talk { padding-block: 1rem clamp(2.75rem, 7vw, 3.75rem); }
.talk-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: clamp(1.25rem, 4vw, 2rem); }
.talk-card .kicker { color: var(--accent-ink); }
.talk-form { display: grid; gap: .75rem; }
textarea {
  width: 100%; resize: vertical; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem;
}
textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.talk-form button {
  justify-self: start; font: 600 .95rem/1 var(--sans); color: var(--bg); background: var(--ink);
  border: 0; border-radius: 999px; padding: .8rem 1.4rem; cursor: pointer; transition: transform .15s ease, background-color .15s ease;
}
.talk-form button:hover { background: color-mix(in srgb, var(--ink) 82%, var(--accent)); }
.talk-form button:active { transform: translateY(1px); }
.chat { display: grid; gap: .6rem; margin-bottom: 1rem; }
.bubble { margin: 0; max-width: 85%; padding: .75rem 1.05rem; border-radius: 18px 18px 18px 4px; background: var(--bubble); }
.sent { justify-self: end; border-radius: 18px 18px 4px 18px; background: var(--ink); color: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; }
.typing { display: flex; gap: .3rem; width: max-content; margin: 0; padding: .9rem 1.05rem; border-radius: 18px 18px 18px 4px; background: var(--bubble); }
.typing i { width: .45rem; height: .45rem; border-radius: 50%; background: var(--muted); animation: dot 1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes glow { 50% { opacity: .9; } }
@keyframes dot { 50% { transform: translateY(-3px); opacity: .4; } }
.reply { display: grid; gap: .2rem; }
.reply .bubble { justify-self: start; width: fit-content; }
.reply .bubble:first-child { border-bottom-left-radius: 6px; }
.reply .bubble:last-child { border-top-left-radius: 6px; }
.reply:focus, .chat:focus { outline: none; }
.reply-big { font: italic 400 clamp(1.5rem, 4vw, 1.9rem)/1.2 var(--serif); text-wrap: balance; }

.foot { text-align: center; background: linear-gradient(var(--line), var(--line)) top center / calc(100% - 2.5rem) 1px no-repeat; padding-block: 3rem 4rem; color: var(--muted); font-size: .92rem; }
.foot h2 { font: 400 1.5rem/1.2 var(--serif); color: var(--ink); margin-bottom: .75rem; }
.foot ul { list-style: none; margin: 0 0 2rem; padding: 0; }
.foot .last { font: italic 400 1.6rem/1.4 var(--serif); color: var(--ink); margin-top: .3rem; }
.signpost { font-size: .85rem; margin: 0; }

@media (max-width: 40rem) {
  .intro { text-align: left; }
  .glyph { margin-inline: 0; }
  .lede, .pull, .aside { margin-inline: 0; }
  .stages-nav { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .orb, .cue span, .typing i { animation: none; }
  .orb { transform: none; opacity: .6; }
  .breathe.is-running .orb { animation: glow var(--breath) ease-in-out infinite; }
  .cue { height: auto; }
  .cue span { position: static; opacity: 1; }
  .cue .in::after { content: ". "; }
}

/* Roughly one load in seven, roulette.js swaps the page for a stock-looking error report. */
.mage-down { color-scheme: light; }
.mage-down body { background: #fff; color: #333; }
.mage-down body > :not(.mage-error) { display: none !important; }
.mage-error { max-width: 46rem; margin: 0 auto; padding: 3rem 1.25rem; font: 14px/1.5 Arial, Helvetica, sans-serif; color: #333; }
.mage-error h1 { font: 700 20px/1.3 Arial, Helvetica, sans-serif; color: #333; margin: 0 0 .9rem; letter-spacing: 0; }
.mage-error p { margin: 0 0 .5rem; }
.mage-record { color: #666; }
.mage-details { margin: 1.5rem 0; border: 1px solid #ccc; background: #f8f8f8; }
.mage-details summary { cursor: pointer; padding: .5rem .75rem; font-weight: 700; }
.mage-details pre { margin: 0; padding: .75rem; border-top: 1px solid #ccc; font: 12px/1.5 Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: #a00; }
.mage-retry { color: #1979c3; }
.mage-retry:focus-visible { outline: 2px solid #1979c3; }
