/* Breathe with Ellie · a calm breathing game for ages 4 to 7. Same sea, same Ellie, same controls as Play with Ellie. */
@font-face {
  font-family: "Fredoka";
  src: url("/assets/fonts/fredoka-latin.woff2") format("woff2");
  font-weight: 300 700; font-display: swap;
}

:root {
  --navy: #2E3253;
  --sun: #FDF2C5;
  --coral: #F56F56;
  --lagoon: #0EC0DB;
  --deep: #0293C6;
  --kelp: #8A9A2A;
  --ellie: #D29E76;
  --spots: #716166;
  --blush: #FBB5A8;
}

html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  background: #3CC4E2;
}
body {
  position: fixed; inset: 0;
  font-family: "Fredoka", ui-rounded, system-ui, sans-serif;
  color: var(--navy);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sea {
  position: absolute; inset: 0; overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(253, 242, 197, 0.55), transparent 60%),
    linear-gradient(180deg, #A4E2F1 0%, #49C7E4 26%, #16B2DA 52%, #0BA0CE 76%, #2FB0D2 100%);
  cursor: pointer;
}

/* sun rays from the surface */
.sea__light { position: absolute; inset: 0; pointer-events: none; }
.sea__light i {
  position: absolute; top: -6%; left: 50%;
  width: 11vw; min-width: 60px; height: 115%;
  transform-origin: 50% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 72%);
  filter: blur(14px); opacity: 0.28;
  animation: ray 14s ease-in-out infinite alternate;
}
.sea__light i:nth-child(1) { transform: translateX(-50%) rotate(-34deg); animation-delay: -3s; }
.sea__light i:nth-child(2) { transform: translateX(-50%) rotate(-16deg); width: 7vw; animation-delay: -8s; }
.sea__light i:nth-child(3) { transform: translateX(-50%) rotate(2deg); width: 14vw; animation-delay: -1s; }
.sea__light i:nth-child(4) { transform: translateX(-50%) rotate(19deg); width: 8vw; animation-delay: -11s; }
.sea__light i:nth-child(5) { transform: translateX(-50%) rotate(35deg); animation-delay: -6s; }
@keyframes ray { from { opacity: 0.16; } to { opacity: 0.42; } }

/* kelp, swaying slowly */
.kelp { position: absolute; bottom: 8vh; height: 78vh; width: auto; pointer-events: none; }
.kelp--left { left: -2vw; }
.kelp--right { right: -2vw; }
.kelp__frond { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 9s ease-in-out infinite alternate; }
.kelp__frond--b { animation-duration: 11s; animation-delay: -4s; }
@keyframes sway { from { transform: rotate(-2.2deg); } to { transform: rotate(2.2deg); } }
.kelp__stem { fill: none; stroke: #7E8F24; stroke-width: 9; stroke-linecap: round; }
.kelp__stem--back { stroke: rgba(110, 126, 31, 0.55); stroke-width: 7; }
.kelp__leaf { fill: var(--kelp); }
.kelp__leaf--dark { fill: #6F7E1F; }
.kelp__leaf--back { fill: rgba(110, 126, 31, 0.5); }

/* sandy floor */
.sand {
  position: absolute; left: 0; right: 0; bottom: 0; height: 20vh;
  background:
    radial-gradient(40% 30% at 20% 40%, rgba(255, 255, 255, 0.35), transparent 70%),
    radial-gradient(30% 25% at 70% 60%, rgba(255, 255, 255, 0.3), transparent 70%),
    linear-gradient(180deg, #F3DDB3 0%, #ECCD98 100%);
}
.sand svg { position: absolute; left: 0; bottom: 100%; width: 100%; height: 40px; margin-bottom: -1px; }
.sand path { fill: #F3DDB3; }

.layer { position: absolute; inset: 0; pointer-events: none; }
.layer > * { pointer-events: auto; }
.layer--fx { z-index: 4; }
.layer--fx > * { pointer-events: none; }

/* the breath bubble: Ellie floats inside it. JS sets its size, place, scale and glow every frame. */
.breath {
  position: absolute; left: 0; top: 0;
  width: 300px; height: 300px;
  border-radius: 50%;
  outline: none;
  will-change: transform;
  z-index: 3;
}
.breath__ring {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 31% 25%, rgba(255, 255, 255, 0.6) 0 3.5%, rgba(255, 255, 255, 0) 11%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0) 56%, rgba(255, 255, 255, 0.12) 72%, rgba(255, 255, 255, 0.32) 100%);
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 34px rgba(253, 242, 197, 0.35), inset 0 0 30px rgba(255, 255, 255, 0.2);
  transform: scale(0.68); opacity: 0.72;
  will-change: transform, opacity;
}
.breath__glow {
  position: absolute; inset: 4%; border-radius: 50%;
  background: radial-gradient(circle, rgba(253, 242, 197, 0.75) 0%, rgba(253, 242, 197, 0.32) 42%, rgba(253, 242, 197, 0) 72%);
  opacity: 0.1;
  will-change: opacity;
}
.breath:focus-visible .breath__ring { outline: 3px solid #fff; outline-offset: 6px; }
.breath:focus-visible .ellie__svg { filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 6px #fff); }

/* "tap me": a soft ring that drifts out from the bubble while Ellie is resting */
.breath__hint {
  position: absolute; inset: 16%; border-radius: 50%;
  border: 4px solid rgba(253, 242, 197, 0.95);
  opacity: 0; pointer-events: none;
}
.breath.is-ready .breath__hint { animation: hint 3.4s ease-out infinite; }
@keyframes hint { 0% { transform: scale(0.95); opacity: 0; } 25% { opacity: 0.85; } 100% { transform: scale(1.35); opacity: 0; } }

/* Ellie (drawn exactly as in Play with Ellie) */
.ellie {
  position: absolute; left: 50%; top: 50%;
  width: 186px; aspect-ratio: 260 / 110;
  transform: translate(-50%, -50%);
  will-change: transform;
  z-index: 2;
}
.ellie__turn { width: 100%; height: 100%; transition: transform 1.1s ease-in-out; }
.ellie__turn.is-right { transform: scaleX(-1); }
/* Bible: Ellie's one heart is on her LEFT side. Facing right shows her right side, so the heart hides. */
.ellie__turn.is-right .e-spot { visibility: hidden; }
/* the new Ellie (play/ellie-art.js, copied in by tools/ellie-inline.cjs): her heart is on her left side, so it hides when she faces right */
.ellie__turn.is-right .ce-heart { visibility: hidden; }
.ellie__loop { width: 100%; height: 100%; transform-origin: 50% 120%; }
.ellie__svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 18px 14px rgba(2, 80, 120, 0.18)); }
.ellie__tail { transform-box: fill-box; transform-origin: 0% 50%; animation: wag 1.8s ease-in-out infinite alternate; }
@keyframes wag { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }
.e-body { fill: var(--ellie); }
.e-fin { fill: #C68F66; }
.e-belly { fill: #F6E6CF; }
.e-spots circle, .e-spot { fill: var(--spots); }
.e-gills { fill: none; stroke: #B48463; stroke-width: 2; stroke-linecap: round; }
.e-eye { fill: #3A2A24; }
.e-glint { fill: #fff; }
.e-cheek { fill: var(--blush); opacity: 0.75; }
.e-smile { fill: none; stroke: #5A3F37; stroke-width: 2.5; stroke-linecap: round; }

/* bubbles (tap, breath and ambient) */
.fxb {
  position: absolute; left: 0; top: 0; border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.95) 0 10%, rgba(255, 255, 255, 0.32) 14% 40%, rgba(255, 255, 255, 0.08) 65%, rgba(255, 255, 255, 0.04));
  border: 1.5px solid rgba(255, 255, 255, 0.8);
}

/* six breath dots, filling softly one per breath (same look as the bucket dots) */
.dots {
  position: absolute; right: max(16px, env(safe-area-inset-right)); top: max(27px, calc(env(safe-area-inset-top) + 15px));
  display: flex; gap: 8px;
  z-index: 6; pointer-events: none;
}
.dots i {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.25);
  transition: background-color 1.2s ease, transform 1.2s ease, box-shadow 1.2s ease;
}
.dots i.on { background: var(--sun); transform: scale(1.12); box-shadow: 0 0 10px rgba(253, 242, 197, 0.9); }

/* a small line for grown-ups on the sand (kids don't need it) */
.caption {
  position: absolute; left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  margin: 0; text-align: center;
  font: 500 clamp(0.82rem, 2.6vw, 1rem)/1.35 "Fredoka", system-ui, sans-serif;
  color: rgba(46, 50, 83, 0.8);
  z-index: 5; pointer-events: none;
}

/* grown-up controls (small, out of the way) */
.controls {
  position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top));
  display: flex; gap: 8px; z-index: 6;
}
.ctl {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 252, 240, 0.78);
  color: var(--navy); text-decoration: none;
  font: 500 0.92rem/1 "Fredoka", system-ui, sans-serif;
  cursor: pointer;
}
.ctl:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.ctl--round { width: 46px; height: 46px; padding: 0; justify-content: center; }
.ctl--round svg { width: 24px; height: 24px; fill: none; stroke: var(--navy); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ctl--pill { box-sizing: border-box; height: 46px; padding: 0 16px 0 11px; gap: 7px; font-size: 1rem; } /* "Games": the way to every game, labeled so grown-ups find it */
.ctl--pill svg { width: 22px; height: 22px; fill: none; stroke: var(--navy); stroke-width: 2.4; }
.ctl--round .spk { fill: var(--navy); }
.ctl--round .off { display: none; }
.ctl[aria-pressed="false"] .wave { display: none; }
.ctl[aria-pressed="false"] .off { display: inline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* reduced motion: nothing travels. The bubble shows the rhythm with a soft glow instead (see breathe.js). */
@media (prefers-reduced-motion: reduce) {
  .sea__light i, .kelp__frond { animation: none !important; }
  .ellie__turn { transition: none; }
  .breath.is-ready .breath__hint { animation: hintsoft 3.4s ease-in-out infinite alternate; }
}
@keyframes hintsoft { from { opacity: 0.12; } to { opacity: 0.7; } }

@media (min-width: 900px) {
  .dots { gap: 10px; }
  .dots i { width: 20px; height: 20px; }
}
