/* Under This Log! — cozy DUSK garden aesthetic, touch-first, nothing fetched.
   Pattern copied from plants3d / lifecycle-3d style.css. The WebGL canvas has a
   transparent clear color, so the dusk SKY behind the garden corner IS this
   gradient (deep violet-blue up top, warm amber horizon — dusk makes the
   glow-worm's light read for free). */
* { 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(52, 44, 112) 0%, rgb(118, 82, 142) 46%, rgb(232, 148, 88) 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,244,224,.9); color: #6b4d8f; font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.pillBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.pillBtn.off { opacity: .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: #fff6e6; color: #4a3a6b;
  font-size: clamp(26px, 5vmin, 52px); font-weight: 900; text-align: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.2);
  z-index: 7; pointer-events: none; min-height: 1em;
}
/* per-spot label colors: burrow = bark/soil bugs, dusk = night light, glow = finale */
#wordLabel[data-link="burrow"] { background: #f1e0cd; color: #7a4a21; }
#wordLabel[data-link="dusk"]   { background: #e3dbff; color: #5a4a9e; }
#wordLabel[data-link="glow"]   { background: #d8f5cf; color: #2f7d32; }
#wordLabel[data-link="finale"] { background: #ffe3a3; color: #b0630a; }
/* Phone width: a wide word (LADYBUG!, GOODNIGHT!) would slide under the pill
   buttons and hide the read-again control — drop the label below the top bar. */
@media (max-width: 900px) { #wordLabel { top: calc(78px + env(safe-area-inset-top)); } }
#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,246,230,.92); color: #6b4d8f;
  font-size: clamp(18px, 3.4vmin, 30px); font-weight: 900;
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
  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; } }

/* 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 */

/* ---------- body view (js/body-view.js) ----------
   Only visible while <body class="body-open">. The normal #wordLabel/handHint
   step aside so the big part word owns the top of the screen; everything stays
   in the UPPER half so nothing fights the lesson bar at the bottom of phones. */
body.body-open #wordLabel, body.body-open #handHint { opacity: 0; }
#bodyView {
  position: fixed; top: calc(84px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 9;
  display: none; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
body.body-open #bodyView { display: flex; }
#bodyWord {
  padding: 14px 36px; border-radius: 30px; background: #fff6e6; color: #4a3a6b;
  font-size: clamp(24px, 4.6vmin, 46px); font-weight: 900; text-align: center;
  box-shadow: 0 5px 0 rgba(0,0,0,.2); max-width: calc(100vw - 32px);
}
#bodyWord.bpop { animation: bodyPop .5s ease-out; }
@keyframes bodyPop { 0% { transform: scale(.5); opacity: 0; }
                     60% { transform: scale(1.12); opacity: 1; }
                     100% { transform: scale(1); } }
#bodySub {
  padding: 8px 22px; border-radius: 20px; background: rgba(255,246,230,.92); color: #6b4d8f;
  font-size: clamp(15px, 2.6vmin, 22px); font-weight: 700; text-align: center;
  box-shadow: 0 3px 0 rgba(0,0,0,.18); max-width: calc(100vw - 32px);
}
#bodySub:empty { display: none; }
#legDots { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(8px, 1.6vmin, 14px);
  max-width: min(520px, calc(100vw - 40px)); }
#legDots:empty { display: none; }
#legDots i { width: clamp(16px, 3vmin, 26px); aspect-ratio: 1; border-radius: 50%;
  background: rgba(255,246,230,.22); box-shadow: inset 0 0 0 2px rgba(255,246,230,.5);
  transition: background .15s ease, transform .15s ease; }
#legDots i.on { background: #ffd43b; transform: scale(1.18); box-shadow: 0 0 12px rgba(255,212,59,.85); }
#bodyClose {
  display: none; position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 14px; z-index: 9;
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: rgba(255,244,224,.9); color: #6b4d8f; font-size: 24px; font-weight: 900;
  cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
body.body-open #bodyClose { display: block; }
#bodyClose:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
@media (max-width: 520px) {
  /* phone: below the pill buttons, above the low lesson bar; smaller type so a
     long word ("HEAD & CHEST") stays on one line and the dots fit in two rows. */
  #bodyView { top: calc(76px + env(safe-area-inset-top)); gap: 8px; }
  #bodyWord { font-size: clamp(22px, 5.4vmin, 32px); padding: 10px 24px; }
  #bodySub { font-size: clamp(14px, 3.2vmin, 18px); }
}
