:root {
  --sun: #F6B93B;
  --sky: #1C2470;
  --ink: #15133B;
  --paper: #FFFDF8;
  --muted: #5F5D80;
  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: var(--serif); color: var(--ink); background: var(--paper); font-size: 1.25rem; line-height: 1.65; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--sun); }
.progress { position: fixed; inset: 0 0 auto 0; height: 4px; background: var(--sun); transform-origin: left; transform: scaleX(0); z-index: 20; }

.top { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px clamp(16px, 4vw, 40px); background: rgba(255, 253, 248, .9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-family: var(--sans); font-size: 1rem; }
.back { font-weight: 600; text-underline-offset: 4px; }

.button { display: inline-flex; align-items: center; justify-content: center; font: 700 1.05rem var(--sans); padding: 15px 26px; border-radius: 999px; border: 2px solid var(--sky); background: var(--sky); color: var(--paper); text-decoration: none; transition: background .2s, color .2s, border-color .2s; }
.button:hover { background: var(--sun); border-color: var(--sun); color: var(--ink); }
.button.small { padding: 9px 18px; font-size: .98rem; }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.button.ghost:hover { background: var(--ink); color: var(--paper); }

main { max-width: 42rem; margin: 0 auto; padding: clamp(32px, 6vw, 72px) clamp(20px, 5vw, 32px) 96px; }
.intro { display: grid; grid-template-columns: 150px 1fr; gap: clamp(20px, 4vw, 36px); align-items: center; padding-bottom: clamp(32px, 5vw, 56px); border-bottom: 2px solid var(--ink); }
.intro img { width: 100%; height: auto; border-radius: 4px; box-shadow: 0 14px 34px rgba(21, 19, 59, .28); }
.kicker { font-family: var(--sans); font-weight: 600; font-size: 1rem; color: var(--muted); }
h1 { font-family: var(--sans); font-weight: 800; font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1; letter-spacing: -.04em; margin: 6px 0 14px; }
.note { font-family: var(--sans); font-size: 1rem; line-height: 1.45; color: var(--muted); }

.chapter h2 { font-family: var(--sans); font-weight: 800; font-size: 1.6rem; letter-spacing: -.02em; text-align: center; margin: clamp(40px, 7vw, 72px) 0 clamp(28px, 4vw, 44px); }
.chapter p { text-indent: 1.6em; }
.chapter p.first { text-indent: 0; }
.chapter p.break { text-indent: 0; text-align: center; letter-spacing: .5em; margin: 1.4em 0; }
.chapter > p.first:first-of-type::first-letter { font-family: var(--sans); font-weight: 800; font-size: 3.4em; float: left; line-height: .82; padding: .06em .1em 0 0; color: var(--sky); }

.end { margin-top: clamp(56px, 9vw, 96px); padding: clamp(28px, 6vw, 56px); background: var(--sky); color: var(--paper); border-radius: 24px; font-family: var(--sans); }
.end-line { font-size: 1rem; font-weight: 600; color: var(--sun); margin-bottom: 8px; }
.end h2 { font-weight: 800; font-size: clamp(1.7rem, 5vw, 2.5rem); line-height: 1.05; letter-spacing: -.035em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.end .button { background: var(--sun); border-color: var(--sun); color: var(--ink); }
.end .button:hover { background: var(--paper); border-color: var(--paper); }
.end .button.ghost { background: transparent; border-color: var(--paper); color: var(--paper); }
.end .button.ghost:hover { background: var(--paper); color: var(--ink); }
.buy-note { margin-top: 16px; font-size: 1rem; color: var(--sun); }

@media (max-width: 520px) {
  body { font-size: 1.15rem; }
  .intro { grid-template-columns: 96px 1fr; }
  .end .button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Paged reader (added by reader.js; without it the chapter scrolls as above) */
.pager[hidden] { display: none; }
html.reader, html.reader body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.reader body { display: flex; flex-direction: column; background: #EFEADF; font-size: 1.14rem; line-height: 1.6; }
html.reader .top { position: static; flex: none; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
html.reader main { flex: 1; min-height: 0; max-width: none; width: 100%; margin: 0; padding: 0 clamp(10px, 3vw, 40px); display: flex; justify-content: center; }
html.reader .stage { position: relative; width: min(1120px, 100%); height: 100%; background: var(--paper); border-radius: 10px; box-shadow: 0 1px 2px rgba(21, 19, 59, .1), 0 18px 50px rgba(21, 19, 59, .16); padding: clamp(22px, 4.5vh, 52px) clamp(22px, 4.5vw, 60px); }
html.reader .stage.spread::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 70px; translate: -50% 0; background: linear-gradient(90deg, transparent, rgba(21, 19, 59, .07) 48%, rgba(21, 19, 59, .12) 50%, rgba(21, 19, 59, .07) 52%, transparent); pointer-events: none; }
html.reader .window { height: 100%; overflow: hidden; }
html.reader .pages { height: 100%; column-fill: auto; }
html.reader .intro { break-after: column; grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 28px; border-bottom: 0; padding: 4vh 0 0; }
html.reader .intro img { width: auto; max-width: 60%; height: min(42vh, 360px); }
html.reader .chapter h2 { margin: 0 0 1.4em; }
html.reader .chapter p { orphans: 2; widows: 2; }
html.reader .end { break-before: column; break-inside: avoid; margin-top: 0; }

.pager { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 16px 12px; font-family: var(--sans); font-size: .95rem; }
.hint { flex: 1; text-align: center; color: var(--muted); white-space: nowrap; }
.turn { font: 600 .95rem var(--sans); color: var(--ink); background: none; border: 0; padding: 8px 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.turn:disabled { visibility: hidden; }
.turn .long { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html.reader .stage { touch-action: pan-y pinch-zoom; }
@media (max-width: 640px) { html.reader body { font-size: 1.06rem; } }

/* Wide screens: the hints stand in the margins either side of the book, reading along its edges */
@media (min-width: 900px) {
  html.reader main { padding: 0 56px; }
  .pager { padding: 0; height: 22px; }
  .hint, .turn .short { display: none; }
  .turn .long { display: inline; }
  .turn { position: fixed; top: 50%; translate: 0 -50%; writing-mode: vertical-rl; padding: 16px 6px; color: var(--muted); font-weight: 500; letter-spacing: .03em; text-decoration: none; white-space: nowrap; transition: color .2s; }
  .turn:hover { color: var(--ink); text-decoration: underline; }
  #previous { left: max(14px, calc(50vw - 606px)); rotate: 180deg; }
  #next { right: max(14px, calc(50vw - 606px)); }
}

/* Page turn: the sheet rolls over along a moving fold (see reader.js). Nothing here rotates or scales text. */
.flip { position: absolute; inset: 0; z-index: 5; overflow: hidden; border-radius: inherit; pointer-events: none; --curl: 0; }
.flip .reveal { position: absolute; inset: 0; }
html.reader .flip .snapshot { position: absolute; top: 0; left: 0; height: 100%; max-width: none; box-shadow: none; border-radius: 0; }
.flip .flap { position: absolute; top: 0; bottom: 0; overflow: hidden; background: #F5F0E4; box-shadow: -18px 0 34px rgb(21 19 59 / calc(var(--curl) * .3)); }
.flip .flap.reversed { box-shadow: 18px 0 34px rgb(21 19 59 / calc(var(--curl) * .3)); }
/* The curve of the paper: light across the middle of the roll, dark where it turns under at the fold */
.flip .flap::after { content: ""; position: absolute; inset: 0; opacity: var(--curl); background: linear-gradient(90deg, rgba(21, 19, 59, .16) 0%, rgba(21, 19, 59, .02) 14%, rgba(255, 255, 255, .5) 46%, rgba(21, 19, 59, .05) 72%, rgba(21, 19, 59, .22) 90%, rgba(21, 19, 59, .42) 100%); }
.flip .flap.reversed::after { background: linear-gradient(270deg, rgba(21, 19, 59, .16) 0%, rgba(21, 19, 59, .02) 14%, rgba(255, 255, 255, .5) 46%, rgba(21, 19, 59, .05) 72%, rgba(21, 19, 59, .22) 90%, rgba(21, 19, 59, .42) 100%); }
.flip .flap.blank::after { opacity: calc(.4 + var(--curl) * .6); }
/* Shadow the roll casts on the page it is leaving */
.flip .cast { position: absolute; top: 0; bottom: 0; width: 90px; opacity: var(--curl); background: linear-gradient(90deg, rgba(21, 19, 59, .26), rgba(21, 19, 59, .06) 45%, transparent); }
.flip .cast.reversed { translate: -100% 0; background: linear-gradient(270deg, rgba(21, 19, 59, .26), rgba(21, 19, 59, .06) 45%, transparent); }
