/* Nanhe Group: motion.
   One orchestrated hero entrance, characters that feel alive, and motion that answers taps.
   Individual transform properties (translate / rotate / scale) are used on SVG groups so they
   add to, never replace, each group's transform attribute. Everything stops under reduced motion. */

/* ---------- page change: the candy curtain (transitions.js + transition-boot.js) ----------
   Leaving: the curtain grows as a circle from the tapped spot. Arriving: it lifts away with a
   rounded bottom edge. One look in every browser, so the native cross-page view transition is off. */
.page-curtain,
.is-arriving body::after {
  position: fixed; inset: 0; z-index: 1000;
  background:
    var(--kite-mark) center / clamp(90px, 14vmin, 140px) no-repeat,
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .07) 0 22px, transparent 22px 44px),
    linear-gradient(135deg, #FF7AB6 0%, #D41E68 38%, #FFB627 74%, #FFE066 100%);
}
.page-curtain { clip-path: circle(0 at var(--x) var(--y)); transition: clip-path .46s cubic-bezier(.7, 0, .3, 1); }
.page-curtain.is-on { clip-path: circle(150vmax at var(--x) var(--y)); }
.is-arriving body::after { content: ''; pointer-events: none; animation: curtain-lift .72s cubic-bezier(.7, 0, .3, 1) .06s both; }
@keyframes curtain-lift {
  from { clip-path: inset(0 0 0 0 round 0 0 0 0); }
  to { clip-path: inset(0 0 100% 0 round 0 0 50% 50%); }
}
:root {
  --kite-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 140'%3E%3Cpath d='M50 4 92 52 50 100 8 52Z' fill='%23FFFDF7'/%3E%3Cpath d='M50 52 92 52 50 100Z' fill='%23FFE9A8'/%3E%3Cpath d='M50 4V100M8 52Q50 34 92 52' stroke='%231E2350' stroke-width='3' fill='none'/%3E%3Cpath d='M50 100q-9 9 0 17t0 19' stroke='%23FFFDF7' stroke-width='4' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
}

/* the day/night switch still uses a same-page view transition */
::view-transition-old(root) { animation: vt-out .28s ease both; }
::view-transition-new(root) { animation: vt-in .38s var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-12px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(16px); } }

/* ---------- characters ---------- */

.blink { transform-box: fill-box; transform-origin: center; animation: blink 5.5s infinite; }
@keyframes blink { 0%, 94%, 100% { scale: 1 1; } 96% { scale: 1 .1; } }
.char--jugnu .blink { animation-delay: -1.3s; }
.char--tinku .blink { animation-delay: -2.4s; }
.char--pothi .blink { animation-delay: -3.1s; animation-duration: 7s; }
.char--gilli .blink { animation-delay: -.6s; }

.flutter { transform-box: fill-box; transform-origin: 50% 90%; animation: flutter .22s ease-in-out infinite alternate; }
@keyframes flutter { to { scale: 1 .86; } }

.glow-pulse { transform-box: fill-box; transform-origin: center; animation: glow 3s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .55; scale: .9; } }

.key-turn { transform-box: fill-box; transform-origin: center; animation: key 2.4s ease-in-out infinite; }
@keyframes key { 50% { scale: .25 1; } }

.tail-swish { transform-box: fill-box; transform-origin: 10% 95%; animation: swish 3.6s ease-in-out infinite; }
@keyframes swish { 50% { rotate: 5deg; } }

/* ---------- scene life ---------- */

.drift { animation: drift 16s ease-in-out infinite alternate; }
@keyframes drift { to { translate: 34px 0; } }
.bob { animation: bob 6s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -10px; } }
.hero-art .bob:nth-of-type(2n) { animation-delay: -2s; }
.sway { transform-box: fill-box; transform-origin: 50% 0; animation: sway 3.2s ease-in-out infinite; }
.sway.s1 { animation-delay: -1s; } .sway.s2 { animation-delay: -2.1s; animation-duration: 4s; }
@keyframes sway { 50% { rotate: 5deg; translate: 0 -6px; } }
.nod { transform-box: fill-box; transform-origin: 30% 80%; animation: nod 1.4s ease-in-out infinite; }
@keyframes nod { 50% { rotate: 14deg; } }
.spin { transform-box: fill-box; transform-origin: center; animation: spin 2.4s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.twinkle { animation: twinkle 2.6s ease-in-out infinite; }
.twinkle:nth-of-type(2n) { animation-delay: -1.2s; } .twinkle:nth-of-type(3n) { animation-delay: -.5s; }
@keyframes twinkle { 50% { opacity: .25; } }
.firefly { animation: firefly 5s ease-in-out infinite; }
.firefly.f1 { animation-delay: -1.2s; animation-duration: 6s; } .firefly.f2 { animation-delay: -2.5s; } .firefly.f3 { animation-delay: -3.6s; animation-duration: 7s; }
@keyframes firefly { 25% { translate: 10px -14px; opacity: .4; } 50% { translate: -6px -24px; } 75% { translate: -12px -8px; opacity: .6; } }
.leaf { animation: leaf 4.5s ease-in-out infinite; }
.leaf.l1 { animation-delay: -1.5s; } .leaf.l2 { animation-delay: -3s; }
@keyframes leaf { 50% { translate: 0 -5px; rotate: 3deg; } }
.ray { animation: ray 3s ease-in-out infinite; }
@keyframes ray { 50% { opacity: .25; } }

/* ---------- hero entrance: the one orchestrated moment ---------- */

.hero__hi { animation: hi-in 1s var(--ease-spring) .15s both; }
.hero__name { animation: rise .7s var(--ease-out) .55s both; }
.hero__lede { animation: rise .7s var(--ease-out) .7s both; }
.hero__actions { animation: rise .7s var(--ease-out) .85s both; }
.hero__hint:not([hidden]) { animation: rise .6s var(--ease-out) 1.6s both; transition: opacity .6s ease, translate .6s ease; }
.hero__hint.is-gone { opacity: 0; translate: 0 10px; pointer-events: none; }
@keyframes hi-in { from { opacity: 0; transform: rotate(-14deg) translateY(40px) scale(.7); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

/* ---------- answers to taps ---------- */

.tag__card { transition: transform .3s var(--ease-spring); }
.tag__card:hover { transform: rotate(-2.5deg); }
.tag__card.is-swinging { animation: swing 1.4s var(--ease-out); }
@keyframes swing {
  15% { transform: rotate(9deg); } 35% { transform: rotate(-7deg); } 55% { transform: rotate(4deg); }
  75% { transform: rotate(-2deg); } 100% { transform: rotate(0); }
}
.tag__card:hover .char, .tag__card.is-swinging .char { animation: hop .5s var(--ease-spring); }
@keyframes hop { 40% { transform: translateY(-10px) scale(1.04); } }

.jar.is-shaking svg { animation: shake .6s ease-in-out; }
@keyframes shake { 15%, 45%, 75% { transform: rotate(-9deg); } 30%, 60%, 90% { transform: rotate(9deg); } }
.slip.is-new { animation: slip-in .55s var(--ease-spring); }
@keyframes slip-in { from { opacity: 0; transform: rotate(-8deg) translateY(30px) scale(.85); } }

/* kite maker: fly away and come back */
.maker__sky.is-flying .maker__kite { animation: fly 2.6s var(--ease-out); }
@keyframes fly {
  0% { transform: none; }
  35% { transform: translate(40px, -160px) rotate(14deg) scale(.7); }
  60% { transform: translate(-60px, -220px) rotate(-12deg) scale(.5); }
  100% { transform: none; }
}

/* footer fireflies */
.ff { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #FFE08A; box-shadow: 0 0 12px 4px rgba(255, 200, 80, .5); animation: ff 7s ease-in-out infinite; }
.ff:nth-child(1) { left: 8%; top: 30%; } .ff:nth-child(2) { left: 22%; top: 70%; animation-delay: -1s; }
.ff:nth-child(3) { left: 41%; top: 22%; animation-delay: -2s; } .ff:nth-child(4) { left: 63%; top: 58%; animation-delay: -3s; }
.ff:nth-child(5) { left: 78%; top: 18%; animation-delay: -4s; } .ff:nth-child(6) { left: 92%; top: 64%; animation-delay: -5s; }
.ff:nth-child(7) { left: 52%; top: 84%; animation-delay: -2.5s; } .ff:nth-child(8) { left: 30%; top: 44%; animation-delay: -6s; }
@keyframes ff { 0%, 100% { opacity: .2; transform: translate(0, 0); } 30% { opacity: 1; transform: translate(18px, -14px); } 60% { opacity: .5; transform: translate(-10px, -30px); } }

/* "in view" reveal, used only for the story chapters (see animations.js) */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .7s ease, transform .8s var(--ease-out); transition-delay: calc(var(--i, 0) * 90ms); }
.reveal.is-in { opacity: 1; transform: none; }

/* paused when off-screen (animations.js toggles .is-offscreen on heavy scenes) */
.is-offscreen * { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .page-curtain, .is-arriving body::after { display: none; }
}
