/* Spin the World — cozy night-sky aesthetic, touch-first, no fonts/images fetched.
   Visual language adapted from states-3d / drippy-3d style.css. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  /* sky gradient vars driven live from main.js (~6 Hz) from sun elevation + view;
     these defaults are the deep-space gradient so the page looks right pre-JS. */
  --sky-top: #050a24; --sky-mid: #101a44; --sky-bottom: #1c2a5e;
}
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: "Trebuchet MS", "Comic Sans MS", Verdana, sans-serif;
  /* deep-space gradient: the WebGL canvas has a transparent clear color,
     so space behind the planet IS this gradient (zero draw cost). */
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-bottom) 100%);
  touch-action: none; -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
#game3d { position: fixed; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- 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: #35406e; 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 word-label ---------- */
#stateLabel {
  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,.2);
  z-index: 7; pointer-events: none; min-height: 1em;
}
#stateLabel[data-state="day"]     { background: #ffe9a8; color: #9a6b00; }
#stateLabel[data-state="night"]   { background: #2b3a6e; color: #ffe9a8; }
#stateLabel[data-state="sunrise"] { background: #ffd3a3; color: #b04a12; }
#stateLabel[data-state="sunset"]  { background: #f3b8d9; color: #7c2d63; }
#stateLabel[data-state="stars"]   { background: #1e2a55; color: #bfe3ff; }
#stateLabel[data-state="hello"],
#stateLabel[data-state="ispuntheworld"] { background: #d6f5d0; color: #1f6b2d; }
#stateLabel.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); } }

/* ---------- peek-mode UP button ---------- */
#upBtn {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) scale(.6); z-index: 8;
  border: 0; border-radius: 34px; padding: 16px 34px; cursor: pointer;
  background: rgba(255,255,255,.92); color: #35406e;
  font-family: inherit; font-size: clamp(20px, 3.4vmin, 32px); font-weight: 900;
  box-shadow: 0 5px 0 rgba(0,0,0,.25);
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
#upBtn.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) scale(1); }
#upBtn:active { transform: translateX(-50%) scale(.95); }

/* ---------- onboarding hint ---------- */
#handHint {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 12px 22px; border-radius: 26px; z-index: 7;
  background: #fff; color: #35406e; font-weight: 900;
  font-size: clamp(18px, 3vmin, 30px);
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
  opacity: 0; pointer-events: none;
  transition: opacity .4s ease;
}
#handHint.show { opacity: 1; animation: hintNudge 1.6s ease-in-out infinite; }
#handHint.gone { opacity: 0; }
@keyframes hintNudge { 0%,100% { transform: translateX(-50%) translateY(0); }
                       50% { transform: translateX(-50%) translateY(-8px); } }

/* ---------- phone: keep the big word-label clear of the topbar pills when
   the app runs full-screen in portrait ---------- */
@media (max-width: 768px) {
  #stateLabel { top: calc(76px + env(safe-area-inset-top)); }
}

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

/* ---------- hands-only day clock (no digits, ever): dial top-right under the
   topbar pills; the hand shows where the Sun is around the local day
   (up = midday, right = evening), one lowercase word below names the phase. ---------- */
#dayClock {
  position: fixed; top: calc(84px + env(safe-area-inset-top)); right: 16px; z-index: 7;
  width: 72px; height: 72px; border-radius: 50%; pointer-events: none;
  background: rgba(9, 14, 36, .55); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}
#dayClock::before, #dayClock::after {   /* the four 12/3/6/9 tick marks */
  content: ""; position: absolute; border-radius: 2px; background: rgba(255,255,255,.75);
}
#dayClock::before { left: 34.5px; top: 3px; width: 3px; height: 7px;
  box-shadow: 0 59px 0 rgba(255,255,255,.75); }
#dayClock::after { left: 3px; top: 34.5px; width: 7px; height: 3px;
  box-shadow: 59px 0 0 rgba(255,255,255,.75); }
#dcHand {
  position: absolute; left: 34.5px; bottom: 36px; width: 3px; height: 26px;
  background: #ffe08a; border-radius: 2px; transform-origin: bottom center;
}
#dcWord {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 5px; padding: 3px 12px; border-radius: 14px; white-space: nowrap;
  background: rgba(9, 14, 36, .6); color: #ffe9a8; font-size: 12px; font-weight: 900;
  letter-spacing: .05em; text-transform: lowercase;
}

/* ---------- far-side greeting pills ("Good morning!" / "Good night!"):
   pinned over the marker and the friend house in space view, hidden otherwise ---------- */
.capPill {
  position: fixed; z-index: 7; display: none; pointer-events: none;
  padding: 7px 14px; border-radius: 16px; font-size: 14px; font-weight: 900;
  background: rgba(10, 16, 40, .78); color: #fff6df; white-space: nowrap;
  transform: translate(-50%, -100%);
}
