/* book/css/book.css — Moo's Harbour Walk (phone-first, sea palette) */
:root {
  --navy: #0b1f3a;
  --sea: #1d5c7a;
  --foam: #e8f4f6;
  --sand: #f6ecd6;
  --cream: #fffaf0;
  --ink: #14233a;
  --coral: #e8735a;
  --coral-deep: #b33f25; /* S3: white text on this is 5.75:1 */
  --ok: #2f8f5b;
  --tap: 44px;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--navy);
  color: var(--cream);
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.brand { font-weight: 800; letter-spacing: .02em; }

.skip { position: absolute; left: -999px; top: 0; min-height: var(--tap); display: inline-flex; align-items: center; background: var(--cream); color: var(--ink); padding: 10px 14px; z-index: 10; border-radius: 0 0 8px 0; }
.skip:focus { left: 0; }

.top {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--navy); border-bottom: 1px solid rgba(255,255,255,.12);
}
.top h1 { flex: 1; min-width: 0; margin: 0; font-size: .95rem; line-height: 1.2; text-align: center; text-wrap: balance; }
.back .back-long { display: inline; }
@media (max-width: 420px) { .back .back-long { display: none; } .top { gap: 4px; padding: 6px 8px; } .top h1 { font-size: .9rem; } }
.back { color: var(--foam); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; gap: .3em; padding: 0 6px; font-size: .9rem; white-space: nowrap; }
.back:hover { text-decoration: underline; }

.stage {
  flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px; padding: 12px;
  outline: none;
}

/* Art: Pixar-style environment backgrounds (book/assets/bg-<key>.webp, empty scenes)
   + the ORIGINAL Moo cut-out on ::after (never redrawn, flipped or recoloured).
   Layers: background = environment, ::before = optional prop (Pip), ::after = Moo. */
.art {
  --moo-x: 7%; --moo-w: 38%;
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius);
  overflow: hidden; background-color: #8fd0e8;
  background-image: linear-gradient(180deg, #8fd0e8 0 55%, #3a86a8 55% 70%, var(--sand) 70%);
  background-size: cover; background-position: center 62%; background-repeat: no-repeat;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.art[hidden] { display: none; }
.art::before { content: none; position: absolute; background: center / contain no-repeat; }
.art::after { /* Moo cut-out — 134x192 source, keep aspect */
  content: ""; position: absolute; left: var(--moo-x); bottom: 5%; width: var(--moo-w); aspect-ratio: 134 / 192;
  background: url("../../assets/moo-cutout-192.webp") center bottom / contain no-repeat;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.3));
}

/* open: sunny St Helier waterfront */
.art-open { background-image: url("../assets/bg-open.webp"); }
/* kerb: high kerb on the right, Moo on the pavement */
.art-kerb { background-image: url("../assets/bg-kerb.webp"); }
/* choice: fork — sea path vs dropped-kerb sign */
.art-choice { --moo-x: 35%; background-image: url("../assets/bg-choice.webp"); }
/* promenade: Havre des Pas sea wall and railings */
.art-promenade { --moo-x: 56%; background-image: url("../assets/bg-promenade.webp"); }
/* ramp: gentle slope — Moo on the pavement beside it */
.art-ramp { --moo-x: 3%; background-image: url("../assets/bg-ramp.webp"); }
/* hunt: Liberation Square */
.art-hunt { --moo-x: 6%; background-image: url("../assets/bg-hunt.webp"); }
/* pip: café terrace with Pip the puffin (café scene has no puffin, so keep the overlay) */
.art-pip { --moo-x: 4%; background-image: url("../assets/bg-pip.webp"); }
.art-pip::before { content: ""; left: 60%; bottom: 7%; width: 18%; aspect-ratio: 100 / 120; background-image: url("../assets/puffin.svg");
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.3)); }
/* icecream: Sunny Scoops kiosk — Moo to the right of the counter */
.art-icecream { --moo-x: 52%; background-image: url("../assets/bg-icecream.webp"); }
/* end: sunset over the harbour, Moo centred */
.art-end { --moo-x: 35%; background-image: url("../assets/bg-end.webp"); }

/* Captions always visible */
.caption {
  background: var(--cream); color: var(--ink); border-radius: var(--radius);
  padding: 14px 16px; font-size: 1.15rem; line-height: 1.45;
}
.caption h2 { margin: 0 0 6px; font-size: 1.3rem; }
.caption p { margin: 0; }

/* Buttons */
.btn, .game-opt {
  min-height: var(--tap); min-width: var(--tap);
  border: 2px solid var(--foam); background: transparent; color: var(--cream);
  border-radius: 999px; padding: 10px 18px; font: inherit; font-size: 1.05rem; font-weight: 600;
  cursor: pointer; touch-action: manipulation;
}
.btn.primary { background: var(--coral-deep); border-color: var(--coral-deep); color: #fff; }
.btn.small { font-size: .85rem; padding: 6px 12px; }
/* M1 + m11: two-tone ring (yellow next to the control, navy outside) shows on the navy page and the pale game cards alike */
.btn:focus-visible, .game-opt:focus-visible, .pin-stage:focus-visible, .back:focus-visible, .map-links a:focus-visible, .skip:focus-visible, .foot a:focus-visible {
  outline: 3px solid var(--navy); outline-offset: 3px; box-shadow: 0 0 0 3px #ffd166;
}
.top .back:focus-visible, .foot a:focus-visible { outline-color: #fff; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.game-opt[aria-disabled="true"] { cursor: default; }
.game-feedback { margin: 10px 0 0; font-weight: 700; min-height: 1.4em; }
.foot a { color: var(--foam); display: inline-block; padding: 12px 4px; }
.btn[hidden] { display: none; }

.choices { display: grid; gap: 10px; }
.choices[hidden], .game-mount[hidden], .map-links[hidden] { display: none; }
.choices .btn { width: 100%; text-align: left; padding: 14px 18px; background: var(--sea); border-color: var(--sea); }

.nav { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* Games */
.game { background: var(--foam); color: var(--ink); border-radius: var(--radius); padding: 14px; }
.game-prompt { margin: 0 0 10px; font-weight: 700; font-size: 1.1rem; }
.game-options { display: grid; gap: 10px; }
.game-opt { color: var(--ink); border-color: var(--sea); background: #fff; text-align: left; }
.game-opt.wrong { opacity: .5; text-decoration: line-through; border-color: #999; }
.game-opt.right { background: var(--ok); color: #fff; border-color: var(--ok); }
.pin-stage {
  position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; min-height: var(--tap);
  border: 2px solid var(--sea); border-radius: 12px; cursor: crosshair; padding: 0;
  background: linear-gradient(180deg, #cfe9f3 0 45%, #9aa3ad 45% 50%, #c9c2b4 50%);
}
.pin-stage::before { /* the ramp drawn exactly over the hit zone (games.js zone: x .55 y .45 w .25 h .25) */
  content: ""; position: absolute; left: 55%; top: 45%; width: 25%; height: 25%;
  background: url("../assets/ramp.svg") center / 100% 100% no-repeat;
}
.pin-stage::after { /* soft hint, same box */
  content: "ramp"; position: absolute; left: 55%; top: 70%; width: 25%;
  font-size: .75rem; color: var(--sea); opacity: .7; text-align: center;
}
.pin-stage.miss { animation: shake .3s; }
.pin-stage.hit { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(47,143,91,.35); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Map links */
.map-links { display: grid; gap: 8px; }
.map-links a {
  display: flex; align-items: center; min-height: var(--tap); padding: 10px 16px;
  background: var(--sea); color: #fff; border-radius: 12px; text-decoration: none; font-weight: 600;
}
.map-links a::before { content: "📍"; margin-right: 8px; }

.foot { text-align: center; font-size: .8rem; padding: 10px 12px 14px; color: var(--foam); opacity: .85; }

@media (min-width: 720px) {
  .stage { padding: 24px; }
  .top h1 { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
