/* =========================================================================
   Zine reader — style.css
   Palette: spruce desk #16241B · cream paper #F4EDE1 · cranberry #9B2335
   ========================================================================= */

:root {
  --spruce: #16241b;
  --spruce-deep: #0e1812;
  --pine: #2c4a37;
  --cream: #f4ede1;
  --cream-dim: rgba(244, 237, 225, 0.62);
  --cranberry: #9b2335;

  --mono: ui-monospace, "SFMono-Regular", "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Page geometry. --ratio (width / height) is replaced at runtime with the
     natural ratio of pages/page-1.jpg. 0.6471 = 5.5 × 8.5in digest zine. */
  --ratio: 0.6471;
  --gap: 4px;                 /* thin gap at the spine between the two pages */
  --top: 76px;                /* space reserved for the masthead */
  --bottom: 112px;            /* space reserved for the control dock */
  --zoom: 1;

  --page-w: min(
    calc((94vw - var(--gap)) / 2),
    calc((100vh - var(--top) - var(--bottom)) * var(--ratio))
  );
  --page-w: min(
    calc((94vw - var(--gap)) / 2),
    calc((100dvh - var(--top) - var(--bottom)) * var(--ratio))
  );
  --pw: calc(var(--page-w) * var(--zoom));
  --ph: calc(var(--pw) / var(--ratio));

  --flip-ms: 900ms;           /* overwritten from script.js */
  --ease-flip: cubic-bezier(0.645, 0.045, 0.355, 1);
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--cream);
  font-family: var(--mono);
  background-color: var(--spruce);
  /* Candle-lit desk: warm pool of light behind the zine, darker edges. */
  background-image:
    radial-gradient(ellipse 60% 55% at 50% 46%, rgba(244, 222, 180, 0.075), transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 110%, rgba(5, 10, 7, 0.55), transparent 60%),
    radial-gradient(ellipse 140% 100% at 50% -20%, rgba(5, 10, 7, 0.35), transparent 55%);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Fine paper-grain on the desk surface (fixed, non-interactive). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.95 0 0 0 0 0.92 0 0 0 0 0.86 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 0.9rem;
  color: var(--spruce);
  background: var(--cream);
  border-radius: 6px;
  font-size: 0.8rem;
}
.skip-link:focus { top: 1rem; }

/* ---------------------------------------------------------------- Masthead */

.masthead {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--top);
  padding: 0 clamp(1rem, 3vw, 2.25rem);
  pointer-events: none;
}

.masthead__title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.masthead h1 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.masthead h1 span {
  margin-left: 0.6em;
  font-weight: 400;
  color: var(--cream-dim);
  letter-spacing: 0.14em;
  text-transform: lowercase;
  font-style: italic;
}

.starburst {
  width: 18px;
  height: 18px;
  fill: var(--cranberry);
  flex: none;
  animation: spin 24s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.masthead__hint {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--cream-dim);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.masthead__hint.is-hidden {
  opacity: 0;
  transform: translateY(-6px);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.35em;
  font-family: var(--mono);
  font-size: 0.95em;
  text-align: center;
  color: var(--cream);
  border: 1px solid rgba(244, 237, 225, 0.28);
  border-bottom-width: 2px;
  border-radius: 4px;
}

.hint--touch { display: none; }
@media (hover: none) {
  .hint--pointer { display: none; }
  .hint--touch { display: inline; }
}

/* ---------------------------------------------------------------- Viewport */

.viewport {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
}

.stage {
  display: flex;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: var(--top) 3vw var(--bottom);
}

/* margin:auto = "safe" centering, so a zoomed spread can be scrolled
   to every edge instead of overflowing off-screen to the left. */
.book-wrap {
  margin: auto;
}

/* ---------------------------------------------------------------- The book */

.book {
  position: relative;
  width: calc(var(--pw) * 2 + var(--gap));
  height: var(--ph);
  perspective: 1800px;
  perspective-origin: 50% 50%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* Horizontal shift so a closed cover sits centred, an open spread too. */
  transform: translateX(0);
  transition: transform var(--flip-ms) var(--ease-flip);
  opacity: 0;
  animation: arrive 1.1s 0.15s var(--ease-flip) forwards;
}

@keyframes arrive {
  from { opacity: 0; translate: 0 18px; }
  to   { opacity: 1; translate: 0 0; }
}

.book.is-closed-front { transform: translateX(calc((var(--pw) + var(--gap)) / -2)); }
.book.is-closed-back  { transform: translateX(calc((var(--pw) + var(--gap)) / 2)); }

/* Resting paper under each side: casts the soft, low desk shadow. */
.base {
  position: absolute;
  top: 0;
  width: var(--pw);
  height: 100%;
  background: var(--cream);
  border-radius: 1px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.35),
    0 2px 5px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.3s ease calc(var(--flip-ms) * 0.45);
}

.base--left  { right: calc(50% + var(--gap) / 2); }
.base--right { left: calc(50% + var(--gap) / 2); }

.book.has-left  .base--left,
.book.has-right .base--right { opacity: 1; }

/* Stacked fore-edges: thickness follows how many sheets lie on each side. */
.base::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: -1px;
  width: calc(var(--edge, 0) * 0.32px);
  background: repeating-linear-gradient(90deg, #e6dccb 0 1px, #cfc3ae 1px 2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}
.base--left::after  { right: 100%; border-radius: 2px 0 0 2px; }
.base--right::after { left: 100%;  border-radius: 0 2px 2px 0; }

/* ---------------------------------------------------------------- Sheets */

.sheet {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--pw);
  height: 100%;
  transform-origin: left center;       /* hinge on the centre spine */
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform var(--flip-ms) var(--ease-flip);
  transition-delay: var(--delay, 0ms);
}

.sheet.is-flipped { transform: rotateY(-180deg); }

/* A tiny lift of the top page on hover hints that it can be turned. */
@media (hover: hover) and (pointer: fine) {
  body:not(.is-zoomed) .sheet.is-top-right:not(.is-flipping):hover { transform: rotateY(-5deg); }
  body:not(.is-zoomed) .sheet.is-top-left:not(.is-flipping):hover  { transform: rotateY(-175deg); }
}

.face {
  position: absolute;
  top: 0;
  left: calc(var(--gap) / 2);
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--cream);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 1px;
}

.face--front { transform: translateZ(0.5px); }
/* The two sides sit a hair apart so the visible one always receives clicks. */
.face--back { transform: rotateY(180deg) translateZ(0.5px); }

/* Page number "ghost" while a JPEG is still on its way. */
.face::before {
  content: attr(data-page);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 500 0.8rem/1 var(--mono);
  letter-spacing: 0.3em;
  color: rgba(44, 74, 55, 0.35);
  background:
    linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%) 0 0 / 250% 100%,
    var(--cream);
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer { to { background-position: -250% 0, 0 0; } }

.face img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;                 /* never crop, never stretch */
  opacity: 0;
  transition: opacity 0.35s ease;
  -webkit-user-drag: none;
  user-select: none;
}

.face img.is-loaded { opacity: 1; }

/* Inner-spine crease shading so flat JPEGs read as folded paper. */
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.face--front::after {
  background: linear-gradient(to right,
    rgba(20, 16, 10, 0.30) 0%,
    rgba(20, 16, 10, 0.12) 2.5%,
    rgba(255, 250, 240, 0.08) 5%,
    rgba(20, 16, 10, 0.05) 9%,
    transparent 16%);
}

.face--back::after {
  background: linear-gradient(to left,
    rgba(20, 16, 10, 0.30) 0%,
    rgba(20, 16, 10, 0.12) 2.5%,
    rgba(255, 250, 240, 0.08) 5%,
    rgba(20, 16, 10, 0.05) 9%,
    transparent 16%);
}

/* Covers fold over card stock: a lighter hinge, with a faint score line. */
.face--cover.face--front::after {
  background: linear-gradient(to right,
    rgba(20, 16, 10, 0.18) 0%, rgba(255, 250, 240, 0.12) 1.2%, rgba(20, 16, 10, 0.06) 2.4%, transparent 6%);
}
.face--cover.face--back::after {
  background: linear-gradient(to left,
    rgba(20, 16, 10, 0.18) 0%, rgba(255, 250, 240, 0.12) 1.2%, rgba(20, 16, 10, 0.06) 2.4%, transparent 6%);
}

/* Light falloff that sweeps across a page while it turns. */
.face__shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to right, rgba(10, 16, 12, 0.55), rgba(10, 16, 12, 0.12) 60%, rgba(255, 248, 235, 0.05));
}
.face--back .face__shade {
  background: linear-gradient(to left, rgba(10, 16, 12, 0.55), rgba(10, 16, 12, 0.12) 60%, rgba(255, 248, 235, 0.05));
}

.sheet.is-flipping .face__shade {
  animation: turn-shade var(--flip-ms) var(--ease-flip) var(--delay, 0ms) both;
}

@keyframes turn-shade {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------------------------------------------------------------- Quiz
   Clickable "Me? Or Ben?" bubbles laid exactly over the printed circles. */

.quiz {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.quiz__bubble {
  position: absolute;
  /* generous hit area, centred on the printed circle */
  width: 6.2%;
  aspect-ratio: 1;
  padding: 0;
  margin: 0;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.quiz__bubble svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 72%;
  height: 72%;
  overflow: visible;
  opacity: 0;
  transform: scale(0.5) rotate(-12deg);
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quiz__bubble svg path { fill: #1e3326; }

.quiz__bubble svg .quiz__scribble {
  fill: none;
  stroke: rgba(244, 237, 225, 0.16);
  stroke-width: 0.9;
  stroke-linecap: round;
}

/* A faint pencil preview on hover */
@media (hover: hover) {
  .quiz__bubble:hover svg {
    opacity: 0.18;
    transform: scale(0.85) rotate(-6deg);
  }
}

.quiz__bubble[aria-pressed="true"] svg {
  opacity: 0.94;
  transform: scale(1) rotate(0deg);
}

.quiz__bubble.is-inked svg { animation: ink 0.42s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes ink {
  0%   { transform: scale(0.3) rotate(-25deg); opacity: 0.4; }
  60%  { transform: scale(1.12) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 0.94; }
}

.quiz__bubble:focus-visible {
  outline: 2px solid var(--cranberry);
  outline-offset: -2px;
}

/* "click me!" nudge — a cream speech bubble pointing at quote 1's bubbles */
.quiz-hint {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.38em 0.7em 0.38em 0.5em;
  font: 600 max(6px, calc(var(--pw) * 0.026))/1 var(--mono);
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: #1e3326;
  background: var(--cream);
  border: 1px solid rgba(30, 51, 38, 0.28);
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(30, 51, 38, 0.22), 0 1px 2px rgba(30, 51, 38, 0.18);
  pointer-events: none;
  translate: 0 -50%;
  animation: hint-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s both,
             hint-nudge 1.6s ease-in-out 1s infinite;
  transition: opacity 0.35s ease, scale 0.35s ease;
}

/* tail pointing down-right, at the BEN bubble */
.quiz-hint::before,
.quiz-hint::after {
  content: "";
  position: absolute;
  border-style: solid;
  border-color: transparent;
}
.quiz-hint::before {
  right: 0.45em;
  bottom: -0.55em;
  border-width: 0.55em 0 0 0.6em;
  border-top-color: rgba(30, 51, 38, 0.32);
}
.quiz-hint::after {
  right: 0.52em;
  bottom: -0.44em;
  border-width: 0.46em 0 0 0.5em;
  border-top-color: var(--cream);
}

.quiz-hint__star {
  width: 1.2em;
  height: 1.2em;
  flex: none;
  fill: var(--cranberry);
  animation: spin 6s linear infinite;
}

.quiz-hint.is-gone {
  opacity: 0;
  scale: 0.6;
  animation: none;
}

@keyframes hint-in {
  from { opacity: 0; scale: 0.4; }
  to   { opacity: 1; scale: 1; }
}

@keyframes hint-nudge {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translate(0.12em, 0.22em); }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-hint,
  .quiz-hint__star { animation: none; }
}

/* ---------------------------------------------------------------- Links
   Hotspots over books and products; invisible until hovered. */

.links {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.zine-link {
  position: absolute;
  display: block;
  border-radius: 4px;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(155, 35, 53, 0.15);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.zine-link.is-hot,
.zine-link:focus-visible {
  background-color: rgba(155, 35, 53, 0.07);
  box-shadow: 0 0 0 1.5px rgba(155, 35, 53, 0.45), 0 4px 14px rgba(155, 35, 53, 0.12);
  outline: none;
}

.zine-link__icon {
  position: absolute;
  top: 0;
  right: 0;
  width: max(10px, calc(var(--pw) * 0.028));
  height: max(10px, calc(var(--pw) * 0.028));
  padding: 2px;
  translate: 40% -40%;
  fill: none;
  stroke: var(--cream);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  background: var(--cranberry);
  border-radius: 50%;
  opacity: 0;
  scale: 0.6;
  transition: opacity 0.2s ease, scale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zine-link:hover .zine-link__icon,
.zine-link:focus-visible .zine-link__icon {
  opacity: 1;
  scale: 1;
}

/* ---------------------------------------------------------------- Slot numbers */

.slots {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.slots.is-done { opacity: 0; }

.slot-cover,
.slot-reel {
  position: absolute;
}

.slot-reel {
  overflow: hidden;
  /* soft top and bottom edges, like a reel window */
  -webkit-mask-image: linear-gradient(transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(transparent, #000 7%, #000 93%, transparent);
}

.slot-strip {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.slot-cell {
  display: block;
  width: 100%;
  flex: none;
  background-repeat: no-repeat;
  background-size: 1000% 100%;
}

/* ---------------------------------------------------------------- Curl
   Stand-in for a sheet while it turns: nested strips that bend. */

.sheet.is-curling {
  visibility: hidden;
  transition: none !important;
}

.curl {
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
}

.curl__seg {
  position: absolute;
  top: 0;
  left: 100%;
  width: calc(var(--pw) / 14);
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
}

.curl > .curl__seg { left: calc(var(--gap) / 2); }

.curl__face {
  position: absolute;
  top: 0;
  left: 0;
  /* a hair of overlap hides seams between strips */
  width: calc(100% + 0.7px);
  height: 100%;
  overflow: hidden;
  background-color: var(--cream);
  background-repeat: no-repeat;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.curl__face--back { transform: rotateY(180deg); }

.curl__shade {
  position: absolute;
  inset: 0;
  background: rgb(10, 16, 12);
  opacity: 0;
}

/* the spine crease travels with the turning page */
.curl > .curl__seg > .curl__face::after {
  content: "";
  position: absolute;
  inset: 0;
}
.curl > .curl__seg > .curl__face--front::after {
  background: linear-gradient(to right, rgba(20, 16, 10, 0.3), rgba(20, 16, 10, 0.08) 45%, transparent);
}
.curl > .curl__seg > .curl__face--back::after {
  background: linear-gradient(to left, rgba(20, 16, 10, 0.3), rgba(20, 16, 10, 0.08) 45%, transparent);
}

/* ---------------------------------------------------------------- Stars */

.ground {
  position: fixed;
  inset: 0;
  z-index: 25;
  overflow: hidden;
  pointer-events: none;
}

.fallen-star {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
  transition: opacity 0.8s ease;
  will-change: transform;
}

.fallen-star.is-resting {
  pointer-events: auto;
  cursor: pointer;
}

.fallen-star.is-gone { opacity: 0; }

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.twinkle {
  position: absolute;
  border-radius: 50%;
  background: var(--tw-color, var(--cream));
  box-shadow: 0 0 6px var(--tw-color, rgba(244, 237, 225, 0.7));
  opacity: 0.1;
  animation: twinkle var(--tw-dur, 4s) ease-in-out var(--tw-delay, 0s) infinite;
}

.twinkle--sparkle {
  border-radius: 0;
  box-shadow: none;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.08; transform: scale(0.7) rotate(0deg); }
  50%      { opacity: var(--tw-max, 0.5); transform: scale(1) rotate(45deg); }
}

.shooting-star {
  position: absolute;
  width: 140px;
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(to right, transparent, rgba(244, 237, 225, 0.85));
  transform: rotate(var(--angle, 25deg));
  transform-origin: right center;
  opacity: 0;
  animation: shoot 1.3s ease-out forwards;
}
.shooting-star::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: #fff8ec;
  box-shadow: 0 0 8px 2px rgba(233, 199, 123, 0.7);
}

@keyframes shoot {
  0%   { opacity: 0; translate: 0 0; }
  15%  { opacity: 1; }
  100% { opacity: 0; translate: 260px 130px; }
}

/* ---------------------------------------------------------------- Staples */

.staples {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  width: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.book.is-center .staples {
  opacity: 1;
  transition: opacity 0.5s ease calc(var(--flip-ms) * 0.8);
}

.staple {
  position: absolute;
  left: 50%;
  width: max(3px, calc(var(--pw) * 0.009));
  height: calc(var(--ph) * 0.075);
  transform: translateX(-50%);
  border-radius: 2px;
  background: linear-gradient(90deg, #6f7276 0%, #e4e6e8 38%, #9da1a6 62%, #55585c 100%);
  box-shadow:
    0 1px 1.5px rgba(0, 0, 0, 0.45),
    0 0 0 0.5px rgba(0, 0, 0, 0.25);
}
.staple::before,
.staple::after {
  /* the legs, pressing into the paper */
  content: "";
  position: absolute;
  left: 50%;
  width: 140%;
  height: 2px;
  transform: translateX(-50%);
  background: rgba(30, 24, 16, 0.35);
  border-radius: 2px;
  filter: blur(0.4px);
}
.staple::before { top: -1px; }
.staple::after  { bottom: -1px; }

.staple:nth-child(1) { top: 24%; }
.staple:nth-child(2) { bottom: 24%; }

/* ---------------------------------------------------------------- Dock */

.dock {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem;
  transform: translateX(-50%);
  background: rgba(14, 24, 18, 0.72);
  border: 1px solid rgba(244, 237, 225, 0.12);
  border-radius: 999px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(244, 237, 225, 0.06);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

.dock__progress {
  position: absolute;
  left: 1.6rem;
  right: 1.6rem;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(244, 237, 225, 0.08);
}

.dock__progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--cranberry);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform var(--flip-ms) var(--ease-flip);
}

.dock__btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--cream);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.dock__btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock__btn:hover:not(:disabled) { background: rgba(244, 237, 225, 0.1); }
.dock__btn:active:not(:disabled) { transform: scale(0.92); }
.dock__btn:disabled { opacity: 0.28; cursor: default; }

.dock__btn:focus-visible,
.skip-link:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

.dock__btn--zoom { margin-left: 0.35rem; position: relative; }
.dock__btn--zoom::before {
  content: "";
  position: absolute;
  left: -0.3rem;
  top: 25%;
  bottom: 25%;
  width: 1px;
  background: rgba(244, 237, 225, 0.14);
}
.dock__btn--zoom[aria-pressed="true"] {
  color: var(--spruce);
  background: var(--cream);
}
.dock__btn--zoom[aria-pressed="true"]:hover { background: #fff8ec; }
.icon-zoom-out { display: none; }
.dock__btn--zoom[aria-pressed="true"] .icon-zoom-in { display: none; }
.dock__btn--zoom[aria-pressed="true"] .icon-zoom-out { display: block; }

.dock__counter {
  min-width: 8.5em;
  margin: 0;
  padding: 0 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dock__counter .of { color: var(--cream-dim); }

/* ---------------------------------------------------------------- Zoom */

body.is-zoomed .viewport {
  overflow: auto;
  touch-action: pan-x pan-y pinch-zoom;
  cursor: grab;
}
body.is-zoomed .viewport.is-panning { cursor: grabbing; }
body.is-zoomed .book { cursor: inherit; }
body.is-zoomed .masthead__hint { opacity: 0; }

/* Transitions are briefly switched off while the zoom level changes so
   the spread doesn't slide around while we re-centre it. */
.no-anim .book,
.no-anim .sheet,
.no-anim .base { transition: none !important; }

/* ---------------------------------------------------------------- Misc */

.noscript {
  position: fixed;
  inset: auto 1rem 50% 1rem;
  z-index: 50;
  max-width: 32rem;
  margin: 0 auto;
  font-size: 0.85rem;
  line-height: 1.6;
  text-align: center;
}
.noscript a { color: var(--cranberry); }

@media (max-width: 640px) {
  :root {
    --top: 58px;
    --bottom: 100px;
    --gap: 2px;
  }
  .masthead h1 { font-size: 0.72rem; }
  .masthead h1 span { display: none; }
  .masthead__hint { font-size: 0.66rem; }
  .dock { gap: 0; padding: 0.3rem; }
  .dock__counter { min-width: 7.2em; font-size: 0.72rem; letter-spacing: 0.08em; }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root { --top: 44px; --bottom: 76px; }
  .dock { bottom: 0.6rem; }
  .masthead__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .starburst,
  .twinkle,
  .face::before { animation: none; }
  .book { animation-duration: 0.01ms; }
}
