/* saga.ad: an old storybook on a desk. Parchment by day, a candlelit study by night; the book's
   pages stay cream with dark ink in both. */

@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-regular-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-italic-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-variable-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Saga Initials";
  src: url("fonts/saga-initials-fraktur.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3e9d2;
  --ink: #2b1d12;
  --ink-soft: #594331;
  --accent: #9e2b25;
  --gold: #b8892b;
  --btn-bg: #9e2b25;
  --btn-ink: #fbf3e2;
  --btn-line: rgba(240, 205, 120, 0.55);
  --focus: #9e2b25;
  --rule: #b8892b;
  --desk-glow: rgba(255, 252, 240, 0.7);
  --book-shadow: 58, 30, 10;
  --flame: 0;

  --paper: #f6ecd4;
  --paper-ink: #2b1d12;
  --paper-soft: #5a4431;
  --paper-red: #9e2b25;
  --leather: #5d2a1a;

  --serif: "Instrument Serif", "Iowan Old Style", "Palatino", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --initials: "Saga Initials", "Instrument Serif", serif;

  --rim: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17110c;
    --ink: #f2e6cf;
    --ink-soft: #d4c2a2;
    --accent: #e0a24a;
    --btn-bg: #e0a24a;
    --btn-ink: #1d130b;
    --btn-line: rgba(255, 236, 190, 0.55);
    --focus: #e0a24a;
    --rule: #a27a2e;
    --desk-glow: rgba(255, 170, 80, 0.13);
    --book-shadow: 0, 0, 0;
    --flame: 1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17110c;
  --ink: #f2e6cf;
  --ink-soft: #d4c2a2;
  --accent: #e0a24a;
  --btn-bg: #e0a24a;
  --btn-ink: #1d130b;
  --btn-line: rgba(255, 236, 190, 0.55);
  --focus: #e0a24a;
  --rule: #a27a2e;
  --desk-glow: rgba(255, 170, 80, 0.13);
  --book-shadow: 0, 0, 0;
  --flame: 1;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 80% 60% at 70% 30%, var(--desk-glow), transparent 70%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.wrap {
  width: 100%;
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: 16px;
}

a {
  color: inherit;
}

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

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 14px 6px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
  text-decoration: none;
  letter-spacing: 0.005em;
}
.wordmark-mark {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 1px rgba(40, 15, 5, 0.3));
}

/* ---------- theme switch: three red wax seals ---------- */

.theme {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
}
.seal {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seal svg {
  width: 26px;
  height: 26px;
  overflow: visible;
  transform: scale(0.88);
  opacity: 0.55;
  filter: saturate(0.45) brightness(1.2);
  transition: transform 220ms cubic-bezier(0.3, 1.5, 0.5, 1), opacity 200ms, filter 200ms;
}
.seal:hover svg {
  opacity: 0.8;
}
.seal[aria-pressed="true"] svg {
  transform: translateY(-1px) scale(1);
  opacity: 1;
  filter: drop-shadow(0 1.6px 1.2px rgba(45, 10, 5, 0.55)) drop-shadow(0 0 0.5px rgba(45, 10, 5, 0.4));
}
.seal-icon {
  stroke-width: 1.15;
}
.seal-lift {
  stroke: #ffb3a0;
  stroke-opacity: 0.45;
  transform: translateY(0.6px);
}
.seal-press {
  stroke: #4d0c08;
  stroke-opacity: 0.85;
}
.seal:focus-visible {
  outline-offset: 1px;
  border-radius: 50%;
}

/* ---------- hero ---------- */

.hero {
  display: grid;
  gap: 18px;
  padding-top: 18px;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(42px, 11.6vw, 52px);
  line-height: 1;
  letter-spacing: -0.01em;
}
.h1-line {
  display: block;
}
.accent {
  color: var(--accent);
  font-style: italic;
}
.lede {
  margin: 12px 0 0;
  max-width: 36em;
  color: var(--ink-soft);
  font-size: 16.5px;
  line-height: 1.5;
}

.play {
  display: grid;
}
.play-title {
  margin: 4px 0 12px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 27px;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 12px;
}
.play-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--rule), transparent);
  opacity: 0.7;
}

/* ---------- the desk and the candle ---------- */

.desk {
  position: relative;
}

.candle {
  display: none;
}

/* ---------- the book ---------- */

.book {
  position: relative;
  padding: var(--rim);
  touch-action: pan-y;
  border-radius: 8px;
  box-shadow:
    0 1px 0 rgba(255, 230, 190, 0.08) inset,
    0 2px 0 #2b0f07,
    0 4px 0 #1e0904,
    0 34px 46px -22px rgba(var(--book-shadow), 0.6),
    0 16px 24px -10px rgba(var(--book-shadow), 0.4),
    0 60px 90px -40px rgba(var(--book-shadow), 0.45);
}
.cover {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-color: var(--leather);
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.35), transparent 3%, transparent 47%, rgba(0, 0, 0, 0.5) 50%, transparent 53%, transparent 97%, rgba(0, 0, 0, 0.35)),
    radial-gradient(ellipse 70% 60% at 30% 20%, rgba(255, 190, 140, 0.18), transparent 70%),
    url("img/leather.svg");
  box-shadow: inset 0 0 0 1px rgba(20, 5, 0, 0.6), inset 0 0 12px rgba(20, 5, 0, 0.55);
}
.cover::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(219, 175, 85, 0.85);
  border-radius: 5px;
  box-shadow: 0 0 1px rgba(255, 220, 140, 0.4);
}
.cover::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px dotted rgba(219, 175, 85, 0.6);
  border-radius: 4px;
  display: none;
}
.edges {
  position: absolute;
  top: calc(var(--rim) - 1px);
  bottom: calc(var(--rim) - 5px);
  left: calc(var(--rim) - 3px);
  right: calc(var(--rim) - 4px);
  border-radius: 2px;
  background:
    repeating-linear-gradient(0deg, #f1e5c8 0 1px, #d3c09a 1px 2px),
    #e6d7b4;
  box-shadow: 0 1px 2px rgba(30, 10, 0, 0.5);
}

.block {
  position: relative;
  display: grid;
  perspective: 2600px;
}
.spread {
  grid-area: 1 / 1;
  visibility: hidden;
  position: relative;
}
.spread.is-current,
.spread.is-under {
  visibility: visible;
}
.spread.is-under {
  z-index: 0;
}
.spread.is-current {
  z-index: 1;
}
.spread.hide-l .page--l,
.spread.hide-r .page--r {
  visibility: hidden;
}

/* Paper: cream laid paper, faint texture, deckled edges. On a phone the spread is one sheet. */
.spread,
.page {
  color: var(--paper-ink);
}
.paper,
.spread {
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(70, 40, 10, 0.22), rgba(70, 40, 10, 0.06) 4%, transparent 11%),
    repeating-linear-gradient(0deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 34px),
    url("img/paper.svg");
  -webkit-mask: url("img/deckle-r.svg") 0 0 / 100% 100% no-repeat;
  mask: url("img/deckle-r.svg") 0 0 / 100% 100% no-repeat;
}

.page {
  position: relative;
  padding: 18px 40px 20px 24px;
}
.page--r {
  padding-top: 4px;
}

.rh {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper-soft);
  text-align: center;
}
.page--r .rh {
  display: none;
}

.orn {
  display: block;
  color: var(--paper-red);
}
.orn--head {
  width: 128px;
  height: 13px;
  margin: 0 auto 14px;
  opacity: 0.8;
}
.orn--tail {
  width: 20px;
  height: 20px;
  margin: 14px auto 0;
  opacity: 0.85;
}
.page--l .orn--tail {
  display: none;
}

.ch-label {
  margin: 0 0 4px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--paper-red);
}
.ch-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 25px;
  line-height: 1.15;
  color: var(--paper-ink);
}
.story {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.45;
  hyphens: manual;
}
.story::after {
  content: "";
  display: block;
  clear: both;
}
.initial {
  float: left;
  width: 76px;
  height: 76px;
  margin: 4px 10px 0 -2px;
}
.initial svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 1px 1px rgba(60, 20, 5, 0.3));
}
.initial-letter {
  font-family: var(--initials);
  font-size: 66px;
  fill: url(#g-gold);
  stroke: #5e3d0b;
  stroke-width: 1.1;
  paint-order: stroke fill;
  stroke-dasharray: 900;
  stroke-dashoffset: 0;
}
.story-text {
  display: block;
}
/* The first letter is drawn by the illuminated initial; the text keeps the whole word for screen
   readers and search. */
.story-text::first-letter {
  font-size: 0;
}
/* "A trail": the initial is the whole first word, so the space after it must not indent the line.
   em would resolve against the zero font size, hence rem. */
.story-text.is-lone::first-letter {
  margin-right: -0.29rem;
}

.vignette {
  display: block;
  width: min(220px, 70%);
  height: auto;
  aspect-ratio: 240 / 140;
  margin: 18px auto 6px;
}
.changed {
  margin: 10px 0 6px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--paper-red);
}
.changes {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
}
.changes li {
  position: relative;
  padding-left: 20px;
  margin-top: 6px;
}
.changes li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.52em;
  width: 7px;
  height: 7px;
  background: var(--paper-red);
  transform: rotate(45deg);
  border-radius: 1px;
}

/* The ribbon bookmark */
.ribbon {
  position: absolute;
  z-index: 4;
  top: calc(var(--rim) - 6px);
  right: calc(var(--rim) + 7px);
  width: 14px;
  height: calc(100% - var(--rim) + 46px);
  background: linear-gradient(90deg, #6e1712, #b3352b 38%, #c9473b 50%, #9b2a22 70%, #761b15);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 11px), 0 100%);
  filter: drop-shadow(1px 2px 1.5px rgba(30, 8, 2, 0.35));
  transform-origin: 50% 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}
.ribbon::before {
  content: "";
  position: absolute;
  inset: 0 0 0 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 3px);
}
.ribbon-num {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 15px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
  color: #f4d78a;
  text-shadow: 0 1px 0 rgba(60, 10, 5, 0.6);
  display: none;
}
.ribbon-num.is-current {
  display: block;
}
.ribbon.is-lifted {
  opacity: 0;
}
.motion .ribbon.is-settling {
  animation: ribbon-sway 900ms cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes ribbon-sway {
  0% { transform: translateY(-14px) rotate(1.5deg); opacity: 0; }
  40% { opacity: 1; }
  65% { transform: translateY(0) rotate(-1deg); }
  100% { transform: none; }
}

/* Candlelight over the book: a soft glow from one side */
.light {
  position: absolute;
  inset: 0;
  z-index: 8;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg, rgba(255, 252, 238, 0.14), transparent 38%, rgba(70, 35, 8, 0.06));
}

/* The leaf that turns: built by app.js from copies of the pages, decorative only */
.leaf {
  position: absolute;
  z-index: 6;
  top: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}
.strip {
  position: absolute;
  top: 0;
  height: 100%;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}
.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face--back {
  transform: rotateY(180deg);
}
.face > .copy {
  position: absolute;
  top: 0;
  z-index: auto;
  visibility: visible;
}
.leaf .initial-letter {
  animation: none !important;
}
.shade {
  position: absolute;
  inset: 0;
  background: #2a1606;
  opacity: 0;
}
.blank {
  position: absolute;
  inset: 0;
}
.cast {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  width: 80px;
  pointer-events: none;
  opacity: 0;
}
.cast--r {
  background: linear-gradient(to right, rgba(40, 20, 4, 0.34), rgba(40, 20, 4, 0.1) 40%, transparent);
}
.cast--l {
  background: linear-gradient(to left, rgba(40, 20, 4, 0.34), rgba(40, 20, 4, 0.1) 40%, transparent);
}

/* The initial draws itself in gold as the page settles */
.motion .spread.is-drawing .initial-letter {
  animation: draw-letter 1500ms ease-out both;
}
.motion .spread.is-drawing .initial svg {
  animation: initial-glint 1500ms ease-out both;
}
@keyframes draw-letter {
  0% { stroke-dashoffset: 900; fill-opacity: 0; stroke: #d8ab42; }
  55% { fill-opacity: 0; }
  100% { stroke-dashoffset: 0; fill-opacity: 1; stroke: #5e3d0b; }
}
@keyframes initial-glint {
  0% { opacity: 0.4; transform: scale(0.96); }
  40% { opacity: 1; }
  100% { transform: none; }
}

/* ---------- play controls ---------- */

.play-ctl {
  display: grid;
  justify-items: start;
  gap: 12px;
  margin-top: 54px;
}
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 22px 11px 18px;
  border: 0;
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  box-shadow: inset 0 0 0 1px var(--btn-line), inset 0 0 0 3px var(--btn-bg), inset 0 0 0 4px var(--btn-line), 0 6px 14px -6px rgba(var(--book-shadow), 0.55);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, filter 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  filter: brightness(1.07);
}
.btn:active {
  transform: translateY(1px);
}
.btn-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.play-note {
  margin: 0;
  max-width: 34em;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* ---------- three steps ---------- */

.steps {
  padding-top: 64px;
  padding-bottom: 24px;
}
.orn--wide {
  width: 200px;
  height: 20px;
  margin: 0 auto 30px;
  color: var(--rule);
}
.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 34px;
}
.step {
  text-align: center;
}
.numeral {
  display: block;
  width: 120px;
  height: 65px;
  margin: 0 auto 2px;
  overflow: visible;
}
.numeral text {
  font-family: var(--serif);
  font-size: 66px;
  fill: url(#g-gold);
  stroke: #8a6417;
  stroke-width: 0.9;
  paint-order: stroke fill;
  stroke-dasharray: 420;
  stroke-dashoffset: 0;
}
.motion .step .numeral text {
  stroke-dashoffset: 420;
  fill-opacity: 0;
}
.motion .step.is-drawn .numeral text {
  animation: draw-numeral 1700ms ease-out forwards;
}
@keyframes draw-numeral {
  0% { stroke-dashoffset: 420; fill-opacity: 0; stroke: #d8ab42; }
  60% { fill-opacity: 0; }
  100% { stroke-dashoffset: 0; fill-opacity: 1; stroke: #8a6417; }
}
.step h3 {
  margin: 0 0 4px;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.step p {
  margin: 0 auto;
  max-width: 22em;
  color: var(--ink-soft);
  font-size: 16.5px;
}

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

.foot {
  padding-top: 40px;
  padding-bottom: 36px;
  text-align: center;
}
.orn--foot {
  width: 20px;
  height: 20px;
  margin: 0 auto 10px;
  color: var(--accent);
}
.foot-line {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-soft);
}
.foot-line a {
  color: var(--accent);
  text-underline-offset: 3px;
}

/* ---------- two-page spread from 760 px ---------- */

@media (min-width: 760px) {
  :root {
    --rim: 16px;
  }
  .wrap {
    padding-inline: 40px;
  }
  .bar {
    padding-block: 22px 8px;
  }
  .wordmark {
    font-size: 27px;
  }
  .hero {
    gap: 28px;
    padding-top: 26px;
  }
  h1 {
    font-size: 68px;
  }
  .lede {
    font-size: 19px;
  }
  .cover::after {
    display: block;
  }
  .spread {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 500px;
    background: none;
    -webkit-mask: none;
    mask: none;
  }
  .page {
    padding: 22px 34px 26px 38px;
    background-color: var(--paper);
    background-image:
      linear-gradient(to left, rgba(70, 40, 10, 0.28), rgba(70, 40, 10, 0.09) 5%, transparent 13%),
      linear-gradient(to right, rgba(255, 255, 255, 0.18), transparent 30%),
      repeating-linear-gradient(0deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 5px),
      repeating-linear-gradient(90deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 34px),
      url("img/paper.svg");
    -webkit-mask: url("img/deckle-l.svg") 0 0 / 100% 100% no-repeat;
    mask: url("img/deckle-l.svg") 0 0 / 100% 100% no-repeat;
  }
  .page--r {
    padding: 22px 38px 26px 34px;
    background-image:
      linear-gradient(to right, rgba(70, 40, 10, 0.28), rgba(70, 40, 10, 0.09) 5%, transparent 13%),
      linear-gradient(to left, rgba(255, 255, 255, 0.12), transparent 30%),
      repeating-linear-gradient(0deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 5px),
      repeating-linear-gradient(90deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 34px),
      url("img/paper.svg");
    -webkit-mask: url("img/deckle-r.svg") 0 0 / 100% 100% no-repeat;
    mask: url("img/deckle-r.svg") 0 0 / 100% 100% no-repeat;
    display: flex;
    flex-direction: column;
  }
  .page--l {
    display: flex;
    flex-direction: column;
  }
  .page--r .rh {
    display: block;
  }
  .page--l .orn--tail {
    display: block;
  }
  .orn--tail {
    margin-top: auto;
  }
  .orn--head {
    margin-bottom: 34px;
  }
  .ch-label {
    font-size: 13.5px;
  }
  .ch-title {
    font-size: 30px;
    margin-bottom: 18px;
  }
  .story {
    font-size: 21.5px;
    line-height: 1.5;
  }
  .initial {
    width: 92px;
    height: 92px;
    margin: 5px 14px 2px -2px;
  }
  .vignette {
    width: min(290px, 90%);
    margin: 22px auto 22px;
  }
  .changed {
    font-size: 13.5px;
    margin-top: 6px;
  }
  .changes {
    font-size: 17px;
  }
  .ribbon {
    right: auto;
    left: calc(50% - 9px);
    width: 18px;
  }
  .ribbon-num {
    font-size: 15px;
    bottom: 17px;
  }
  .ch-label {
    margin-top: auto;
  }
  .page--l .orn--tail {
    margin-top: auto;
  }
  .vignette {
    margin-top: auto;
  }
  .play-title {
    font-size: 30px;
    margin-bottom: 16px;
  }
  .play-ctl {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 24px;
  }
  .step-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
  }
  .steps {
    padding-top: 90px;
  }
}

/* ---------- wide: words on the left, the book and its candle on the right ---------- */

@media (min-width: 1100px) {
  .wrap {
    padding-inline: 56px;
  }
  .hero {
    grid-template-columns: minmax(330px, 400px) minmax(0, 1fr);
    column-gap: 56px;
    align-items: center;
    padding-top: 6px;
  }
  .hero-copy {
    padding-bottom: 70px;
  }
  h1 {
    font-size: clamp(66px, 5.6vw, 82px);
    line-height: 0.98;
  }
  .lede {
    margin-top: 22px;
    font-size: 20px;
  }
  .desk {
    padding-right: 84px;
  }
  .candle {
    display: block;
    position: absolute;
    right: 0;
    bottom: -4px;
    width: 64px;
    height: 250px;
    z-index: 2;
  }
  .play-ctl {
    margin-top: 50px;
  }
  .spread {
    min-height: 520px;
  }
}

/* The candle: brass dish, cream wax, a flame lit only at night */
.candle-dish {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 30%, #e9c77a, #a37a2c 55%, #5a3f12);
  box-shadow: 0 8px 14px -4px rgba(var(--book-shadow), 0.55);
}
.candle-wax {
  position: absolute;
  left: 21px;
  width: 22px;
  bottom: 9px;
  height: 128px;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(90deg, #cdbb94, #f7ecd2 35%, #fff8e6 48%, #e6d6b2 72%, #b9a47a);
}
.candle-wax::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -3px;
  width: 9px;
  height: 22px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, #f3e6c8, #fff8e6);
}
.candle-wick {
  position: absolute;
  left: 31px;
  bottom: 136px;
  width: 2px;
  height: 9px;
  border-radius: 1px;
  background: #2a1a0e;
}
.candle-flame {
  position: absolute;
  left: 24px;
  bottom: 140px;
  width: 16px;
  height: 38px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse 50% 60% at 50% 72%, #fffbe8 0 22%, #ffd77a 42%, #ff9f2e 70%, rgba(255, 120, 20, 0) 100%);
  box-shadow: 0 0 18px 6px rgba(255, 170, 60, 0.45);
  transform-origin: 50% 90%;
  opacity: var(--flame);
}
.candle-glow {
  position: absolute;
  left: 32px;
  bottom: 160px;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  transform: translate(-50%, 50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 176, 80, 0.22), rgba(255, 150, 60, 0.07) 45%, transparent 70%);
  opacity: var(--flame);
  pointer-events: none;
}

/* Night: the book lit from one side by a slow candle flicker */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .light {
    background: linear-gradient(to left, rgba(255, 196, 120, 0.13), transparent 42%, rgba(10, 4, 0, 0.26));
  }
  :root:not([data-theme="light"]) .book {
    box-shadow: 0 2px 0 #1a0803, 0 4px 0 #120502, 0 40px 60px -20px rgba(0, 0, 0, 0.85), 0 0 80px -10px rgba(255, 160, 60, 0.12);
  }
  .motion:not([data-theme="light"]) .light {
    animation: flicker 6.5s ease-in-out infinite;
  }
  .motion:not([data-theme="light"]) .candle-flame {
    animation: flame 2.3s ease-in-out infinite;
  }
  .motion:not([data-theme="light"]) .candle-glow {
    animation: flicker 6.5s ease-in-out infinite;
  }
}
:root[data-theme="dark"] .light {
  background: linear-gradient(to left, rgba(255, 196, 120, 0.13), transparent 42%, rgba(10, 4, 0, 0.26));
}
:root[data-theme="dark"] .book {
  box-shadow: 0 2px 0 #1a0803, 0 4px 0 #120502, 0 40px 60px -20px rgba(0, 0, 0, 0.85), 0 0 80px -10px rgba(255, 160, 60, 0.12);
}
.motion[data-theme="dark"] .light,
.motion[data-theme="dark"] .candle-glow {
  animation: flicker 6.5s ease-in-out infinite;
}
.motion[data-theme="dark"] .candle-flame {
  animation: flame 2.3s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  18% { opacity: 0.86; }
  31% { opacity: 0.97; }
  47% { opacity: 0.8; }
  62% { opacity: 0.95; }
  78% { opacity: 0.87; }
}
@keyframes flame {
  0%, 100% { transform: scale(1, 1) rotate(0deg); }
  25% { transform: scale(0.94, 1.05) rotate(-2deg); }
  50% { transform: scale(1.03, 0.95) rotate(1.5deg); }
  75% { transform: scale(0.97, 1.03) rotate(-1deg); }
}

/* ---------- 404: a torn-out page ---------- */

.nf-body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}
.nf {
  flex: 1;
  display: grid;
  place-items: center;
  padding-top: 30px;
  padding-bottom: 20px;
}
.torn {
  position: relative;
  width: min(100%, 460px);
  padding: 34px 30px 34px 40px;
  transform: rotate(-1.6deg);
  color: var(--paper-ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(70, 40, 10, 0.12), transparent 12%),
    repeating-linear-gradient(0deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(110, 78, 36, 0.05) 0 1px, transparent 1px 34px),
    url("img/paper.svg");
  -webkit-mask: url("img/torn.svg") 0 0 / 100% 100% no-repeat;
  mask: url("img/torn.svg") 0 0 / 100% 100% no-repeat;
}
.torn-wrap {
  filter: drop-shadow(0 18px 18px rgba(var(--book-shadow), 0.35)) drop-shadow(0 3px 4px rgba(var(--book-shadow), 0.3));
  width: min(100%, 460px);
}
.nf-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.2;
  margin: 0 0 26px;
  color: var(--paper-ink);
}
.nf-title .initial {
  width: 84px;
  height: 84px;
}
.nf-title .story-text::first-letter {
  font-size: 0;
}
.blank-lines {
  display: grid;
  gap: 22px;
  margin: 0 0 30px;
}
.blank-lines span {
  height: 1px;
  background: rgba(90, 60, 30, 0.25);
}
.blank-lines span:nth-child(2) {
  width: 86%;
}
.blank-lines span:nth-child(3) {
  width: 64%;
}
.torn .btn {
  background: #9e2b25;
  color: #fbf3e2;
  --btn-line: rgba(240, 205, 120, 0.55);
  box-shadow: inset 0 0 0 1px var(--btn-line), inset 0 0 0 3px #9e2b25, inset 0 0 0 4px var(--btn-line);
}
@media (min-width: 760px) {
  .nf {
    padding-top: 60px;
  }
  .torn {
    padding: 48px 44px 44px 58px;
  }
  .nf-title {
    font-size: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
