/* Metamorphosis Pond — flat bright kid aesthetic, touch-first, no fonts/images
   fetched. Pattern adapted from foodchain-3d / senses-3d style.css. The WebGL
   canvas has a transparent clear color, so the sunny SKY behind the pond IS
   this gradient. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: "Trebuchet MS", "Comic Sans MS", Verdana, sans-serif;
  background: linear-gradient(180deg, rgb(146, 214, 255) 0%, rgb(198, 236, 255) 48%, rgb(214, 244, 196) 100%);
  touch-action: none; -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
#game3d { position: fixed; inset: 0; display: block; touch-action: none; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 14px; z-index: 8;
  display: flex; gap: 10px;
}
.pillBtn {
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.85); color: #2f6b8f; font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.pillBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.pillBtn.off { opacity: .45; }
#playBtn.on { box-shadow: 0 0 12px rgba(255,215,102,.8), 0 4px 0 rgba(0,0,0,.15); }
#agesBtn.on { box-shadow: 0 0 12px rgba(255,183,3,.9), 0 4px 0 rgba(0,0,0,.15); }

/* ---------- story mode progress ribbon (dots only — no digits, ever) ----- */
/* sits under the word pill (label bottom ~88px at 1280x800); on phones the
   label moves below the ribbon instead (see @media). z-index 6: above the
   canvas, below #wordLabel (7) and #topbar (8). */
#storyRibbon {
  position: fixed; top: 96px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 18px; background: rgba(43,58,85,.28);
  z-index: 6; opacity: 0; pointer-events: none; transition: opacity .5s ease;
}
body.story-on #storyRibbon { opacity: 1; }
#storyRibbon s { width: 10px; display: inline-block; }
#storyRibbon i {
  width: 13px; height: 13px; border-radius: 50%; display: inline-block;
  background: #3a4250; opacity: .55; transition: all .3s;
}
#storyRibbon i.lit[data-line="frog"], #storyRibbon i.now[data-line="frog"] { background: #38d9a9; opacity: 1; }
#storyRibbon i.lit[data-line="bug"],  #storyRibbon i.now[data-line="bug"]  { background: #ffa94d; opacity: 1; }
#storyRibbon i.lit[data-line="hen"],  #storyRibbon i.now[data-line="hen"]  { background: #ff8787; opacity: 1; }
#storyRibbon i.now { animation: ribbonPulse .9s ease-in-out infinite; }
@keyframes ribbonPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.45); } }

/* ---------- big one-word label ---------- */
#wordLabel {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  max-width: 66vw; padding: 14px 36px; border-radius: 30px;
  background: #ffffff; color: #2b3a55;
  font-size: clamp(26px, 5vmin, 52px); font-weight: 900; text-align: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.15);
  z-index: 7; pointer-events: none; min-height: 1em;
}
/* per-line label colors: green = frog line, orange = bug line, gold = finale */
#wordLabel[data-link="frog"]       { background: #d3f9d8; color: #2b8a3e; }
#wordLabel[data-link="bug"]        { background: #ffe8cc; color: #d9480f; }
#wordLabel[data-link="metamorphosis"] { background: #ffd8a8; color: #c2410c; }
#wordLabel.pop { animation: labelPop .5s ease-out; }
@keyframes labelPop { 0% { transform: translateX(-50%) scale(.5); opacity: 0; }
                      60% { transform: translateX(-50%) scale(1.12); opacity: 1; }
                      100% { transform: translateX(-50%) scale(1); } }

/* ---------- first-time hint ---------- */
#handHint {
  position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  padding: 12px 26px; border-radius: 26px; z-index: 7; pointer-events: none;
  background: rgba(255,255,255,.88); color: #35617f;
  font-size: clamp(18px, 3.4vmin, 30px); font-weight: 900;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  animation: hintBob 1.6s ease-in-out infinite;
  transition: opacity .6s ease, transform .6s ease;
}
#handHint.gone { opacity: 0; transform: translateX(-50%) translateY(30px); }
@keyframes hintBob { 0%,100% { margin-bottom: 0; } 50% { margin-bottom: 10px; } }

@media (max-width: 520px) {
  /* phone: hang the word pill below the round buttons so long finale words never hide under them */
  #wordLabel { top: calc(78px + env(safe-area-inset-top)); }
  /* six pills at 56px (play, ages, read, facts, lessons, mute) need a tighter
     gap to stay on one row and on-screen at 390px wide */
  #topbar { gap: 6px; }
}

/* 2026-11-05 phone layout fixes (Claude Code, Ryan: "fix and finish all 18 learning apps").
   left:50% + translateX(-50%) with no width made these shrink-to-fit inside HALF the screen: on a phone the hint
   wrapped to 5-6 lines in a 192px bubble and two-word titles broke onto two lines. max-content + a screen-wide cap fixes it. */
#handHint { width: max-content; max-width: calc(100vw - 32px); text-align: center; }
#wordLabel { width: max-content; }
#wordLabel:empty { display: none; }   /* an empty white pill showed before the first word */
@media (max-width: 900px) { #wordLabel { top: calc(78px + env(safe-area-inset-top)); } }   /* below the buttons, not under them */
@media (max-width: 900px) {
  /* phone: ribbon tucks under the pill row (pills end at ~66px); the word
     label drops below the ribbon (ribbon bottom ~101px) so nothing overlaps. */
  #storyRibbon { top: 76px; }
  body.story-on #wordLabel { top: calc(110px + env(safe-area-inset-top)); }
}
