/* The app's own stock: warm paper, dark ink, one oxblood accent, slate for glosses, set in Charter. */
:root {
  --paper: #fbf8f2;
  --paper-margin: #f4efe5;
  --ink: #2b2521;
  --ink-muted: #6b6158;
  --ink-faint: #a39990;
  --rule: #cfc6b8;
  --accent: #8b3a2f;
  --gloss: #4a5c6a;
  --serif: Charter, "Bitstream Charter", "Charis SIL", "Sitka Text", Cambria, Georgia, serif;
  --measure: 34rem;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1a18;
    --paper-margin: #24211e;
    --ink: #e8e2d6;
    --ink-muted: #9e968b;
    --ink-faint: #6b665e;
    --rule: #443f39;
    --accent: #cf6656;
    --gloss: #8fa3b3;
  }
}
:root[data-theme="dark"] {
  --paper: #1c1a18; --paper-margin: #24211e; --ink: #e8e2d6; --ink-muted: #9e968b;
  --ink-faint: #6b665e; --rule: #443f39; --accent: #cf6656; --gloss: #8fa3b3;
}
/* Asked for more contrast, the faint ink (the scroll cue, the colophon) comes up to at
   least 4.5:1 against the paper: 5.3:1 light, 5.6:1 dark, from 2.6:1 and 3.1:1. The muted ink and
   the accent already clear it, so they stay. */
@media (prefers-contrast: more) {
  :root { --ink-faint: #6f665d; }
  :root[data-theme="dark"] { --ink-faint: #9a9187; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ink-faint: #9a9187; }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Masthead */
.masthead {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(1rem + env(safe-area-inset-top)) clamp(1rem, 4vw, 3rem) 1rem;
  background: linear-gradient(var(--paper) 55%, transparent);
}
.wordmark { font-style: italic; font-size: 1.5rem; color: var(--ink); text-decoration: none; letter-spacing: .01em; }
.masthead-button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: .5rem 1.1rem; border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent); color: var(--paper);
  font-size: .875rem; line-height: 1.3; text-decoration: none;
}
.masthead-button:hover { background: var(--ink); border-color: var(--ink); }

/* The story: chapters on the left, the phone held on the right. */
.story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  padding: 0 clamp(1rem, 4vw, 3rem);
}
.chapters { grid-column: 1; grid-row: 1; }
.stage {
  grid-column: 2; grid-row: 1;
  position: sticky; top: 0; height: 100vh; height: 100svh;
  /* Run to the window's edge: the phone has more room than the column's padding would leave it. */
  margin-right: calc(-1 * clamp(1rem, 4vw, 3rem));
}
.stage iframe { width: 100%; height: 100%; border: 0; display: block; background: transparent; pointer-events: none; }
/* Over the phone: sideways drags turn it and taps fold it, while vertical swipes still scroll the page. */
.stage-touch { position: absolute; inset: 0; touch-action: pan-y; cursor: grab; }
.stage-touch.dragging { cursor: grabbing; }
.hero-wordmark { display: none; }

/* Out of sight and out of layout, but read by screen readers. */
.visually-hidden { position: absolute; }
.visually-hidden, .motion-toggle:not(:focus) {
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
/* The pause for the phone's screens appears only when the keyboard reaches it, set like the badge.
   Fixed even while hidden, so that focusing it never scrolls the page. */
.motion-toggle {
  position: fixed; z-index: 10;
  left: clamp(1rem, 4vw, 3rem); bottom: calc(1rem + env(safe-area-inset-bottom));
  padding: .7rem 1.2rem;
  border: 1px solid var(--ink); border-radius: 999px;
  background: var(--paper); color: var(--ink);
  font: .78rem/1.3 var(--serif); letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer;
}
.motion-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.motion-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.chapter {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  max-width: var(--measure);
  padding: 6rem 0;
}
.chapter + .chapter { border-top: 1px solid transparent; }

h1, h2 { font-weight: normal; font-style: italic; letter-spacing: -.01em; margin: 0 0 1.25rem; }
h1 { font-size: clamp(2.6rem, 5.4vw, 4.4rem); line-height: 1.05; }
h2 { font-size: clamp(1.9rem, 3.4vw, 2.8rem); line-height: 1.12; }
h2::after, h1::after {
  content: ""; display: block; width: 3.5rem; height: 2px; margin-top: 1.1rem; background: var(--accent);
}
p { margin: 0 0 1rem; }
.availability { color: var(--accent); font-size: 1.125rem; font-style: normal; margin-bottom: 1.25rem; }
.lede { font-size: 1.28rem; line-height: 1.55; color: var(--ink); }
cite { font-style: italic; }

.editions, .features { list-style: none; margin: .5rem 0 0; padding: 0; }
.editions li, .features li {
  position: relative;
  padding: .7rem 0 .7rem 1.1rem;
  border-top: 1px solid var(--rule);
  font-size: 1rem; line-height: 1.5; color: var(--ink-muted);
}
.editions li::before, .features li::before {
  content: ""; position: absolute; left: 0; top: .95rem; bottom: .95rem; width: 2px; background: var(--rule);
}
.editions li cite { color: var(--ink); }
.editions li:hover::before, .features li:hover::before { background: var(--accent); }

.cta { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; margin-top: 1.5rem; }
.app-store-badge {
  display: inline-flex; flex: none; padding: 12px; margin-inline-start: -12px;
  /* Apple's artwork needs clear space of one quarter its height on every side. */
}
.app-store-badge img { display: block; height: 48px; width: auto; }
.app-store-badge:focus-visible, .masthead-button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 4px;
}
.cta-note { font-size: .9rem; color: var(--ink-muted); font-style: italic; }
.scroll-cue {
  margin-top: 3rem; font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-faint);
}
.scroll-cue::after { content: " ↓"; content: " ↓" / ""; }

.finale { align-items: flex-start; }
.wordmark-large { font-style: italic; font-size: clamp(3.4rem, 8vw, 6rem); line-height: 1; margin: 0 0 1.5rem; }

.colophon {
  padding: 3rem clamp(1rem, 4vw, 3rem) calc(3rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  font-size: .8rem; color: var(--ink-faint);
}
.colophon a { color: inherit; text-underline-offset: .18em; }
.colophon .links a + a { margin-left: 1.2rem; }

/* Narrow screens: the phone holds the top of the screen and the chapters pass beneath it. */
@media (max-width: 820px) {
  body { font-size: 1.05rem; }
  /* No masthead on a phone: its fade would sit over the phone. The hero carries the name instead. */
  .masthead { display: none; }
  .hero-wordmark { display: block; font-style: italic; font-size: 1.5rem; margin: 0 0 1.25rem; }
  .story { display: block; padding: 0 16px; }
  .stage {
    position: sticky; top: 0; z-index: 2;
    height: 46svh; margin: 0 -16px;
    padding-top: env(safe-area-inset-top);
    background: linear-gradient(var(--paper) 82%, color-mix(in srgb, var(--paper) 0%, transparent));
  }
  .chapter { min-height: 78svh; padding: 2.5rem 0 4rem; justify-content: flex-start; max-width: none; }
  .hero { padding-top: 1rem; }
  h1 { font-size: 2.4rem; }
  h2 { font-size: 1.8rem; }
  .lede { font-size: 1.12rem; }
}
