/* Question Reef — visual design. Claude (Fable) owns this file.
   One tall vertical world: space → sky → land → dinosaur cove → venom garden → ocean.
   iPad Safari portrait first (768×1024). No child-facing text chrome. */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", system-ui, sans-serif;
  background: #061626;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- The world ---------- */

#world { position: relative; width: 100%; }

.zone { position: relative; width: 100%; overflow: hidden; }

.zone-space {
  height: 85vh;
  background: linear-gradient(#0b0b2e 0%, #1a1354 55%, #2c2270 100%);
}
.zone-sky {
  height: 55vh;
  background: linear-gradient(#2c2270 0%, #4a5fb0 18%, #6ea8dd 55%, #8ecaef 100%);
}
.zone-land {
  height: 105vh;
  background: linear-gradient(#8ecaef 0%, #a5d8f2 30%, #cfe9c9 55%, #a9d68a 78%, #93c977 100%);
}
.zone-dino {
  height: 65vh;
  background: linear-gradient(#93c977 0%, #7fbc72 40%, #6aab68 100%);
}
.zone-venom {
  height: 60vh;
  background: linear-gradient(#6aab68 0%, #5a9a70 35%, #3f7f74 100%);
}
.zone-ocean {
  height: 130vh;
  background: linear-gradient(#3f7f74 0%, #2fb3c4 6%, #1a97b8 25%, #0e6f9b 55%, #084a74 80%, #062f52 100%);
}

/* soft scalloped water line at the top of the ocean */
.zone-ocean::before {
  content: "";
  position: absolute; top: -2px; left: 0; right: 0; height: 26px;
  background: radial-gradient(circle at 12px -6px, transparent 16px, #2fb3c4 17px);
  background-size: 34px 26px;
  opacity: .9;
}

/* seafloor */
.zone-ocean::after {
  content: "";
  position: absolute; bottom: 0; left: 0; right: 0; height: 90px;
  background:
    radial-gradient(60px 34px at 15% 100%, #d9b877 98%, transparent),
    radial-gradient(90px 44px at 45% 100%, #cfae6e 98%, transparent),
    radial-gradient(70px 36px at 78% 100%, #d9b877 98%, transparent),
    linear-gradient(transparent 40%, #c4a463 95%);
}

/* ---------- Ambient decorations (JS-spawned) ---------- */

.star { position: absolute; border-radius: 50%; background: #fff;
  animation: twinkle var(--tw, 3s) ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .25; transform: scale(.8); } to { opacity: 1; transform: scale(1.15); } }

.drift-cloud { position: absolute; width: 140px; height: 46px; border-radius: 30px;
  background: rgba(255,255,255,.85);
  box-shadow: 28px -16px 0 6px rgba(255,255,255,.85), 62px -6px 0 2px rgba(255,255,255,.8);
  animation: clouddrift var(--cd, 70s) linear infinite; opacity: .9; }
@keyframes clouddrift { from { transform: translateX(-220px); } to { transform: translateX(110vw); } }

.hill { position: absolute; bottom: 0; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }

.bubble { position: absolute; border: 2.5px solid rgba(255,255,255,.55); border-radius: 50%;
  background: rgba(255,255,255,.12);
  animation: bubblerise var(--br, 9s) linear infinite; }
@keyframes bubblerise {
  from { transform: translateY(0) translateX(0); opacity: 0; }
  12% { opacity: .9; }
  to { transform: translateY(-56vh) translateX(24px); opacity: 0; }
}

.seagrass { position: absolute; bottom: 34px; border-radius: 40% 40% 0 0;
  transform-origin: bottom center; animation: sway var(--sw, 5s) ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }

.fern { position: absolute; bottom: 0; transform-origin: bottom center;
  animation: sway var(--sw, 6s) ease-in-out infinite alternate; }

/* tap feedback effects */
.tapfx { position: absolute; pointer-events: none; z-index: 40;
  animation: tappop .9s ease-out forwards; }
@keyframes tappop {
  from { transform: translateY(0) scale(.4); opacity: 1; }
  to { transform: translateY(-70px) scale(1.25); opacity: 0; }
}

/* ---------- Wonder badges ---------- */

.wonder {
  position: absolute;
  width: calc(var(--size, 1) * 108px);
  height: calc(var(--size, 1) * 108px);
  border-radius: 50%;
  border: 5px solid rgba(255,255,255,.95);
  background: radial-gradient(circle at 38% 32%, var(--bg, #cfe9f7), color-mix(in srgb, var(--bg, #cfe9f7) 62%, #24506b));
  box-shadow: 0 10px 26px rgba(4, 24, 44, .35), inset 0 -6px 14px rgba(0,0,0,.12);
  cursor: pointer;
  padding: 0;
  animation: bob var(--bob, 5s) ease-in-out infinite alternate;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1);
  z-index: 5;
}
.wonder svg { width: 88%; height: 88%; display: block; margin: 6% auto; pointer-events: none; }
.wonder img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; pointer-events: none; }
.wonder:active { transform: scale(1.12); }
.wonder:focus-visible { outline: 4px solid #ffd94d; outline-offset: 3px; }

@keyframes bob {
  from { transform: translateY(-7px) rotate(-2deg); }
  to { transform: translateY(7px) rotate(2deg); }
}

.wonder.wiggling { animation: wiggle .7s ease-in-out 2; }
@keyframes wiggle {
  0%,100% { transform: rotate(0); } 25% { transform: rotate(-7deg) scale(1.06); }
  75% { transform: rotate(7deg) scale(1.06); }
}

/* recent questions get a gentle sparkle */
.wonder.is-new::after {
  content: ""; position: absolute; top: -12px; right: -6px; width: 30px; height: 30px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><path d="M15 2 l3.2 8.3 8.8 1.2-6.4 6.1 1.6 8.8-7.2-4.4-7.2 4.4 1.6-8.8-6.4-6.1 8.8-1.2z" fill="%23ffd94d" stroke="%23d9a92f" stroke-width="1.6" stroke-linejoin="round"/></svg>') no-repeat center/contain;
  animation: newpulse 1.8s ease-in-out infinite alternate;
}
@keyframes newpulse { from { transform: scale(.85) rotate(-8deg); } to { transform: scale(1.12) rotate(10deg); } }

/* ---------- Encounter overlay ---------- */

#encounter {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--zonetint, #0e6f9b) 78%, #04121f);
  padding: 4vh 5vw;
}
#encounter.open { display: flex; animation: encounterin .35s cubic-bezier(.34,1.4,.64,1); }
@keyframes encounterin { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

.enc-card {
  width: min(640px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 34px;
  background: linear-gradient(rgba(255,255,255,.97), rgba(240,250,255,.97));
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
  padding: 26px 26px 20px;
  position: relative;
  text-align: center;
}

.enc-art {
  width: 250px; height: 250px; border-radius: 50%;
  border: 7px solid #fff;
  background: radial-gradient(circle at 38% 32%, var(--bg, #cfe9f7), color-mix(in srgb, var(--bg, #cfe9f7) 62%, #24506b));
  box-shadow: 0 14px 32px rgba(10, 40, 70, .3);
  margin: 6px auto 12px;
  animation: encfloat 4s ease-in-out infinite alternate;
}
.enc-art svg { width: 88%; height: 88%; margin: 6%; }
.enc-art img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
@keyframes encfloat { from { transform: translateY(-4px) rotate(-1.5deg); } to { transform: translateY(5px) rotate(1.5deg); } }

.enc-asked {
  display: inline-block; font-size: 15px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: #fff; background: #f2913d;
  padding: 5px 16px; border-radius: 999px; margin-bottom: 10px;
  box-shadow: 0 3px 0 #c96f22;
}
.enc-question {
  font-size: clamp(22px, 4.2vw, 28px); font-weight: 800; color: #6a8299;
  line-height: 1.22; margin: 2px 6px 16px; cursor: pointer; text-wrap: balance;
}

/* picture-book reading lines: few words, huge, centered */
.enc-answer { display: flex; flex-direction: column; gap: 12px; margin: 0 4px; }
.enc-line {
  font-size: clamp(27px, 5.4vw, 36px); font-weight: 800; color: #8fa9bc;
  border-radius: 20px; padding: 10px 14px; line-height: 1.3; text-align: center;
  text-wrap: balance; letter-spacing: .01em;
  transition: all .4s ease; cursor: pointer;
}
.enc-line.said { color: #17384f; }
.enc-line.saying { color: #17384f; background: #fff3cf; box-shadow: 0 0 0 3px #ffd94d inset; }

.enc-fun {
  margin-top: 12px; border-radius: 20px; background: #fff6d8; padding: 14px 16px;
  font-size: clamp(24px, 4.6vw, 30px); font-weight: 800; color: #8a6410;
  border: 3px solid #ffd94d; display: none; text-align: center; cursor: pointer;
  line-height: 1.3; text-wrap: balance;
}
.enc-fun.shown { display: block; animation: funpop .45s cubic-bezier(.34,1.56,.64,1); }
@keyframes funpop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.enc-buttons { display: flex; justify-content: center; gap: 18px; margin-top: 16px; }
.bigbtn {
  width: 84px; height: 84px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 10px 20px rgba(0,0,0,.18);
}
.bigbtn:active { transform: scale(1.12) translateY(2px); }
.bigbtn svg { width: 46px; height: 46px; }
.btn-replay { background: linear-gradient(#6db5e8, #3d8ecb); }
.btn-fun { background: linear-gradient(#ffd94d, #f2b93d); }
.btn-fun.used { filter: saturate(.55) brightness(.96); }

.enc-close {
  position: absolute; top: 14px; right: 14px; width: 58px; height: 58px;
  border-radius: 50%; border: none; background: #f0575c; cursor: pointer;
  box-shadow: 0 4px 0 #b02d36; display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
  z-index: 5;
}
.enc-close:active { transform: scale(1.1); }
.enc-close svg { width: 26px; height: 26px; }

/* ---------- The tomorrow pearl ---------- */

#pearl {
  position: absolute; left: 55%; bottom: 26px; z-index: 6;
  width: 92px; height: 92px; border: none; background: none; cursor: pointer;
  filter: drop-shadow(0 0 14px rgba(255, 220, 240, .75));
  animation: pearlglow 3.2s ease-in-out infinite alternate;
}
#pearl svg { width: 100%; height: 100%; }
#pearl:active { transform: scale(1.12); }
#pearl:focus-visible { outline: 4px solid #ffd94d; outline-offset: 3px; border-radius: 50%; }
@keyframes pearlglow {
  from { filter: drop-shadow(0 0 8px rgba(255, 220, 240, .45)); transform: translateY(0); }
  to { filter: drop-shadow(0 0 22px rgba(255, 230, 245, .95)); transform: translateY(-5px); }
}
body.reduced-motion #pearl { animation: none; }
@media (prefers-reduced-motion: reduce) { #pearl { animation: none; } }

/* ---------- Fixed chrome (guide, nav, parent) ---------- */

#guide {
  position: fixed; right: 14px; bottom: 16px; z-index: 60;
  width: 96px; height: 96px; border-radius: 50%; border: 5px solid #fff;
  background: #9fd8e8; padding: 0; cursor: pointer; overflow: hidden;
  box-shadow: 0 10px 26px rgba(4,24,44,.4);
  animation: bob 4.5s ease-in-out infinite alternate;
}
#guide img { width: 100%; height: 100%; object-fit: cover; }

#zonenav {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: 10px;
}
.zdot {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,.9);
  background: rgba(8, 40, 66, .45); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); transition: transform .2s, background .2s;
}
.zdot svg { width: 24px; height: 24px; }
.zdot.active { background: #ffd94d; transform: scale(1.18); border-color: #fff; }

#parentshell {
  position: fixed; left: 12px; bottom: 18px; z-index: 60;
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.32); cursor: pointer; opacity: .65;
  display: flex; align-items: center; justify-content: center;
}
#parentshell svg { width: 26px; height: 26px; }

#parentpanel {
  position: fixed; inset: 0; z-index: 120; display: none;
  align-items: center; justify-content: center; background: rgba(6, 22, 38, .82);
}
#parentpanel.open { display: flex; }
.pp-card {
  width: min(430px, 90vw); border-radius: 24px; background: #fff; padding: 26px;
  color: #2a4356; position: relative;
}
.pp-card h2 { font-size: 20px; margin-bottom: 10px; }
.pp-card p { font-size: 14.5px; line-height: 1.5; margin-bottom: 10px; color: #4a6478; }
.pp-card label { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; padding: 8px 0; }
.pp-card input[type="checkbox"] { width: 22px; height: 22px; }

/* ---------- Parallax layers ---------- */

.plx { position: absolute; inset: 0; pointer-events: none; will-change: transform; }

/* ---------- Wonder Hunt riddles ---------- */

body.riddle-on .wonder:not(.riddling) { filter: saturate(.55) brightness(.82); }
.wonder.riddling {
  animation: riddleglow 1.4s ease-in-out infinite alternate, bob var(--bob, 5s) ease-in-out infinite alternate;
  z-index: 8;
}
@keyframes riddleglow {
  from { box-shadow: 0 10px 26px rgba(4,24,44,.35), 0 0 0 6px rgba(255,217,77,.55), 0 0 26px 8px rgba(255,217,77,.5); }
  to { box-shadow: 0 10px 26px rgba(4,24,44,.35), 0 0 0 9px rgba(255,217,77,.9), 0 0 40px 14px rgba(255,217,77,.75); }
}

.confetti {
  position: absolute; border-radius: 3px; pointer-events: none; z-index: 50;
  animation: confettifly 1.25s cubic-bezier(.2,.7,.4,1) forwards;
}
@keyframes confettifly {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  to { transform: translate(var(--dx, 60px), var(--dy, -160px)) rotate(var(--rot, 360deg)); opacity: 0; }
}

/* ---------- Ambient travelers ---------- */

.traveler {
  position: absolute; left: 0; z-index: 4; border: none; background: none;
  padding: 8px; cursor: pointer;
  animation: travelacross var(--tdur, 18s) linear forwards;
}
@keyframes travelacross {
  from { transform: translateX(-140px); }
  to { transform: translateX(105vw); }
}
.traveler.zoom { animation-duration: 1.4s; animation-timing-function: ease-in; }
.tr-shooter { animation-name: shootacross; }
@keyframes shootacross {
  from { transform: translate(-140px, 0); opacity: 0; }
  8% { opacity: 1; }
  to { transform: translate(108vw, 26vh); opacity: .9; }
}
.tr-butterfly .wing { transform-origin: 22px 18px; animation: flap .34s ease-in-out infinite alternate; }
.tr-butterfly .wl { animation-name: flapL; }
.tr-butterfly .wr { animation-name: flapR; }
@keyframes flapL { from { transform: rotateY(0) rotate(0); } to { transform: rotate(24deg); } }
@keyframes flapR { from { transform: rotate(0); } to { transform: rotate(-24deg); } }
.tr-butterfly, .tr-submarine { animation-timing-function: linear; }
.tr-orcapass svg, .tr-submarine svg { filter: drop-shadow(0 4px 8px rgba(0,20,40,.3)); }

/* ---------- The fish (flocking canvas) ---------- */

#fishcanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

/* ---------- The wish conch ---------- */

#conch {
  position: absolute; left: 22%; bottom: 30px; z-index: 6;
  width: 84px; height: 84px; border: none; background: none; cursor: pointer;
  filter: drop-shadow(0 6px 12px rgba(4, 24, 44, .4));
  animation: bob 6s ease-in-out infinite alternate;
}
#conch svg { width: 100%; height: 100%; }
#conch:active { transform: scale(1.12); }
#conch:focus-visible { outline: 4px solid #ffd94d; outline-offset: 3px; border-radius: 50%; }
.conch-ring {
  position: absolute; inset: -8px; border-radius: 50%; pointer-events: none;
  border: 4px solid rgba(255, 130, 160, 0);
}
#conch.listening { animation: none; }
#conch.listening .conch-ring {
  border-color: rgba(255, 130, 160, .9);
  animation: listenpulse 1.1s ease-in-out infinite;
}
@keyframes listenpulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.18); opacity: .4; }
}

.wish { display: flex; align-items: center; gap: 10px; font-size: 13.5px; padding: 6px 0; border-top: 1px solid #e4ecf2; }
.wish span { flex: 1; color: #4a6478; }
.wish button, .wish a {
  border: none; background: #eaf3fa; color: #2a5670; font-weight: 700; font-size: 12.5px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer; text-decoration: none;
}
.wish .wdel { background: #fdecec; color: #a33; }
#pp-wishes h3 { font-size: 15px; margin: 14px 0 6px; color: #2a4356; }
.wish-empty { font-size: 13px; color: #7a92a4; }

/* ---------- Constellations (night only) ---------- */

.constellation {
  position: absolute; border: none; background: none; padding: 6px; cursor: pointer;
  display: none; z-index: 3; opacity: 0; transition: opacity 2s ease;
}
body.night .constellation { display: block; opacity: .95; }
.constellation svg { width: 100%; height: auto; overflow: visible; }
.constellation .cstar { filter: drop-shadow(0 0 4px rgba(255, 224, 138, .9)); }
.constellation .clines line {
  stroke: rgba(255, 230, 160, .85); stroke-width: .9; stroke-linecap: round;
  stroke-dasharray: 60; stroke-dashoffset: 60; transition: stroke-dashoffset 1.6s ease;
}
.constellation.lit .clines line { stroke-dashoffset: 0; }
.constellation:focus-visible { outline: 3px solid #ffd94d; outline-offset: 2px; border-radius: 12px; }

/* ---------- Wonder of the day ---------- */

.wonder.wonder-of-day { border-color: #ffe08a; }
.wonder.wonder-of-day::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 0deg, rgba(255,217,77,0), rgba(255,217,77,.85), rgba(255,140,180,.7), rgba(120,220,255,.7), rgba(255,217,77,0));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  animation: crownspin 5s linear infinite;
}
@keyframes crownspin { to { transform: rotate(360deg); } }

/* ---------- Night mode ---------- */

#nightveil {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  background: linear-gradient(rgba(9, 8, 52, .38), rgba(4, 18, 44, .5));
  mix-blend-mode: multiply;
  opacity: 0; transition: opacity 2.5s ease;
}
body.night #nightveil { opacity: 1; }
body.night .star { box-shadow: 0 0 7px 1px rgba(255,255,255,.9); }
body.night .wonder { box-shadow: 0 10px 26px rgba(2, 10, 22, .55), 0 0 18px rgba(160, 200, 255, .12), inset 0 -6px 14px rgba(0,0,0,.12); }

.firefly, .plankton {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  pointer-events: none; z-index: 6;
  animation: fireflyfloat var(--fd, 5s) ease-in-out infinite alternate;
}
.firefly { background: #ffe66b; box-shadow: 0 0 10px 3px rgba(255, 230, 107, .8); }
.plankton { background: #7df2e0; box-shadow: 0 0 9px 3px rgba(125, 242, 224, .7); width: 5px; height: 5px; }
@keyframes fireflyfloat {
  from { transform: translate(0, 0); opacity: .25; }
  50% { opacity: 1; }
  to { transform: translate(26px, -34px); opacity: .35; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .wonder, .enc-art, #guide, .star, .drift-cloud, .bubble, .seagrass, .fern,
  .wonder.is-new::after, .traveler, .tr-butterfly .wing, .firefly, .plankton { animation: none !important; }
  .traveler { display: none; }
  .wonder.riddling { animation: none !important; box-shadow: 0 10px 26px rgba(4,24,44,.35), 0 0 0 8px rgba(255,217,77,.85), 0 0 32px 10px rgba(255,217,77,.6); }
  #fishcanvas { display: none !important; }
  #conch, #conch.listening .conch-ring, .wonder.wonder-of-day::before { animation: none !important; }
  .constellation .clines line { transition: none; }
}
body.reduced-motion .wonder, body.reduced-motion .enc-art, body.reduced-motion #guide,
body.reduced-motion .star, body.reduced-motion .drift-cloud, body.reduced-motion .bubble,
body.reduced-motion .seagrass, body.reduced-motion .fern,
body.reduced-motion .traveler, body.reduced-motion .tr-butterfly .wing,
body.reduced-motion .firefly, body.reduced-motion .plankton,
body.reduced-motion .wonder.is-new::after { animation: none !important; }
body.reduced-motion .traveler { display: none; }
body.reduced-motion .wonder.riddling { animation: none !important; box-shadow: 0 10px 26px rgba(4,24,44,.35), 0 0 0 8px rgba(255,217,77,.85), 0 0 32px 10px rgba(255,217,77,.6); }
body.reduced-motion #fishcanvas { display: none !important; }
body.reduced-motion #conch, body.reduced-motion #conch.listening .conch-ring,
body.reduced-motion .wonder.wonder-of-day::before { animation: none !important; }
body.reduced-motion .constellation .clines line { transition: none; }
body.reduced-motion html { scroll-behavior: auto; }

/* small phones: shrink chrome a bit */
@media (max-width: 430px) {
  .wonder { width: calc(var(--size, 1) * 88px); height: calc(var(--size, 1) * 88px); }
  #guide { width: 78px; height: 78px; }
  .enc-art { width: 150px; height: 150px; }
  .zdot { width: 38px; height: 38px; }
}
