/* Motion: press feedback, the habit check-off, celebrations, the flame.
   Only transform and opacity are animated. Everything here is switched off
   (or reduced to a fade) under prefers-reduced-motion. */

@keyframes pop { 0% { transform: scale(0.6); } 55% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes grow-up { from { transform: scaleY(0); } }
@keyframes float-y { 50% { transform: translateY(-6px) rotate(-3deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ---------- press feedback on everything tappable ---------- */
.btn:active:not(:disabled), .chip.tap:active, .react:active, .round-btn:active, .template:active, .pick:active, .choice:active, .swatch:active { transform: scale(0.95); filter: brightness(0.96); }
a.card:active, button.card:active, .habit:has(.habit-main:active), .anchor:not(.future):active, button.day:active, .wday:active { transform: scale(0.975); filter: brightness(0.96); }
.icon-btn:active:not(:disabled) { transform: scale(0.88); background: var(--sunken); }
.check:active::before { transform: scale(0.86); }
.tab:active .tab-icon { transform: scale(0.9); }
.tab-icon { transition: transform 0.15s, background 0.18s; }
.tab.on .tab-icon svg { animation: pop 0.35s cubic-bezier(.3, 1.8, .5, 1); }

/* ---------- page content eases in ---------- */
#main > * { animation: rise 0.32s ease backwards; }
#main > *:nth-child(2) { animation-delay: 0.03s; }
#main > *:nth-child(3) { animation-delay: 0.06s; }
#main > *:nth-child(4) { animation-delay: 0.09s; }
#main > *:nth-child(n+5) { animation-delay: 0.12s; }
/* A redraw after a tap must not replay the entrance. */
#main.settled > * { animation: none; }

/* ---------- empty states: a little idle life ---------- */
.empty-emoji { animation: float-y 3.2s ease-in-out infinite; display: inline-block; }

/* ---------- checking off a habit ---------- */
.habit.just-done { animation: habit-done 0.5s cubic-bezier(.3, 1.4, .5, 1); }
.habit.just-done .check::before { animation: pop 0.5s cubic-bezier(.3, 1.8, .5, 1); }
.habit.just-done .check svg { animation: pop 0.55s cubic-bezier(.3, 2, .5, 1) 0.05s backwards; }
.habit.just-done .habit-emoji { animation: wiggle 0.6s ease; }
@keyframes habit-done { 0% { transform: scale(1); } 40% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes wiggle { 25% { transform: rotate(-12deg) scale(1.15); } 60% { transform: rotate(9deg) scale(1.1); } }
.ring.filling .ring-center { animation: pop 0.6s cubic-bezier(.3, 1.6, .5, 1); }
.anim-num { display: inline-block; font-variant-numeric: tabular-nums; }
.anim-num.bump { animation: pop 0.4s cubic-bezier(.3, 1.8, .5, 1); }

.float-xp { position: fixed; z-index: 125; pointer-events: none; margin: -14px 0 0 -30px; width: 60px; text-align: center; font-weight: 800; font-size: 0.95rem; color: var(--ember-strong);
  text-shadow: 0 1px 0 var(--paper), 0 0 8px var(--paper); animation: float-xp 1s cubic-bezier(.2, .8, .3, 1) forwards; white-space: nowrap; }
@keyframes float-xp { 0% { opacity: 0; transform: translateY(0) scale(0.6); } 20% { opacity: 1; transform: translateY(-18px) scale(1.15); } 100% { opacity: 0; transform: translateY(-64px) scale(1); } }

/* ---------- the all-done hero ---------- */
.hero.all-done::before { content: ""; position: absolute; inset: -40%; background: conic-gradient(from 0deg, transparent 0 70%, color-mix(in srgb, #EEB333 26%, transparent) 80%, transparent 90%); animation: spin 9s linear infinite; pointer-events: none; }
.hero.all-done > * { position: relative; }
.hero.all-done .hero-sun { position: absolute; animation: float-y 3s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- the streak flame ---------- */
.flame { display: inline-flex; transform-origin: 50% 90%; }
.flame.lit { animation: flicker 2.4s ease-in-out infinite; }
.flame.lit svg { fill: color-mix(in srgb, currentColor 25%, transparent); }
.flame.t2 svg, .flame.t3 svg { fill: color-mix(in srgb, currentColor 55%, transparent); }
.flame.t4 svg, .flame.t5 svg { fill: currentColor; }
.flame.t2 { transform: scale(1.1); } .flame.t3 { transform: scale(1.2); } .flame.t4 { transform: scale(1.3); } .flame.t5 { transform: scale(1.4); }
.flame.t3, .flame.t4, .flame.t5 { filter: drop-shadow(0 0 4px color-mix(in srgb, #EEB333 80%, transparent)); }
.flame.t5 { color: #EEB333; }
.streak-chip.t3, .streak-chip.t4, .streak-chip.t5 { background: linear-gradient(90deg, var(--ember-soft), color-mix(in srgb, #EEB333 35%, var(--ember-soft))); }
.streak-chip.t4, .streak-chip.t5 { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ember) 55%, transparent); }
@keyframes flicker { 0%, 100% { rotate: 0deg; scale: 1; } 30% { rotate: -5deg; scale: 1.06 0.97; } 60% { rotate: 4deg; scale: 0.97 1.07; } 80% { rotate: -2deg; scale: 1.03 1; } }

/* ---------- small reward: a bouncy toast at the top ---------- */
#celebration { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 110; display: flex; flex-direction: column; align-items: center; padding: 0 14px; pointer-events: none; }
.celebrate { pointer-events: auto; display: flex; align-items: center; gap: 12px; width: 100%; max-width: 420px; background: var(--raised); border: 1.5px solid color-mix(in srgb, var(--ember) 45%, transparent); border-radius: 20px; padding: 12px 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18); opacity: 0; transform: translateY(-120%) scale(0.9); transition: transform 0.5s cubic-bezier(.3, 1.5, .45, 1), opacity 0.2s; }
.celebrate.in { opacity: 1; transform: none; }
.celebrate-emoji { font-size: 30px; line-height: 1; }
.celebrate.in .celebrate-emoji { animation: pop 0.6s cubic-bezier(.3, 1.8, .5, 1) 0.15s backwards; }
.celebrate-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.celebrate-text span { font-size: 0.86rem; color: var(--text-2); }

/* ---------- big moment: full screen ---------- */
.big-moment { position: fixed; inset: 0; z-index: 115; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, #0B1410 78%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.24s ease; cursor: pointer; }
.big-moment.in { opacity: 1; }
.big-card { width: 100%; max-width: 340px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: #FBF9F0; transform: scale(0.8) translateY(20px); transition: transform 0.55s cubic-bezier(.3, 1.5, .45, 1); }
.big-moment.in .big-card { transform: none; }
.big-badge { position: relative; width: 148px; height: 148px; display: grid; place-items: center; margin-bottom: 10px; }
.big-badge::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #F6CF63, #EEB333 45%, #ED8552); box-shadow: 0 0 0 6px rgba(238, 179, 51, 0.25), 0 0 60px rgba(238, 179, 51, 0.55); }
.big-moment.level .big-badge::before { background: radial-gradient(circle at 35% 30%, #74C7A4, #1F5C47 60%, #174536); box-shadow: 0 0 0 6px rgba(116, 199, 164, 0.25), 0 0 60px rgba(116, 199, 164, 0.5); }
.big-rays { position: absolute; inset: -34px; border-radius: 50%; background: repeating-conic-gradient(rgba(238, 179, 51, 0.22) 0 9deg, transparent 9deg 22deg); -webkit-mask: radial-gradient(circle, transparent 38%, #000 40%, transparent 70%); mask: radial-gradient(circle, transparent 38%, #000 40%, transparent 70%); animation: spin 14s linear infinite; }
.big-emoji { position: relative; font-size: 68px; line-height: 1; }
.big-moment.in .big-emoji { animation: pop 0.7s cubic-bezier(.3, 1.9, .5, 1) 0.12s backwards; }
.sparkle { position: absolute; color: #F6CF63; font-size: 18px; opacity: 0; animation: twinkle 1.8s ease-in-out infinite; }
.sparkle.s0 { top: 0; left: 18%; } .sparkle.s1 { top: 12%; right: 2%; animation-delay: 0.3s; font-size: 24px; } .sparkle.s2 { bottom: 6%; left: 0; animation-delay: 0.6s; }
.sparkle.s3 { bottom: 0; right: 16%; animation-delay: 0.9s; font-size: 14px; } .sparkle.s4 { top: 42%; left: -8%; animation-delay: 1.2s; font-size: 12px; color: #ED8552; } .sparkle.s5 { top: -6%; right: 30%; animation-delay: 1.5s; color: #74C7A4; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); } 50% { opacity: 1; transform: scale(1.1) rotate(40deg); } }
.big-kicker { font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em; color: #F6CF63; }
.big-title { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; color: #FBF9F0; }
.big-detail { color: rgba(251, 249, 240, 0.82); font-size: 1.02rem; max-width: 280px; }
.big-xp { margin-top: 6px; font-size: 1.5rem; font-weight: 800; color: #1c1206; background: linear-gradient(90deg, #F6CF63, #ED8552); padding: 6px 18px; border-radius: 999px; font-variant-numeric: tabular-nums; min-width: 130px; }
.btn.big-ok, .btn.big-ok:hover { margin-top: 14px; min-width: 180px; background: #FBF9F0; color: #1F5C47; }
.big-hint { font-size: 0.78rem; color: rgba(251, 249, 240, 0.55); }

/* ---------- boards: podium and rows arrive in turn ---------- */
.rank-row.enter { animation: rise 0.4s cubic-bezier(.3, 1.2, .5, 1) backwards; animation-delay: calc(var(--i, 0) * 55ms + 120ms); }
.podium.enter .podium-step { animation: grow-up 0.55s cubic-bezier(.3, 1.4, .5, 1) backwards; }
.podium.enter .p2 .podium-step { animation-delay: 0.08s; } .podium.enter .p1 .podium-step { animation-delay: 0.2s; } .podium.enter .p3 .podium-step { animation-delay: 0s; }
.podium.enter .avatar, .podium.enter .podium-crown { animation: pop 0.5s cubic-bezier(.3, 1.8, .5, 1) 0.45s backwards; }
.podium-crown { animation: float-y 3s ease-in-out infinite; }

/* ---------- reduced motion: fades only, no movement, no particles ---------- */
@media (prefers-reduced-motion: reduce) {
  .empty-emoji, .flame.lit, .big-rays, .sparkle, .hero.all-done::before, .hero.all-done .hero-sun, .podium-crown, .boot-pulse, .skeleton { animation: none !important; }
  .sparkle { opacity: 0.8; }
  .float-xp { animation: none !important; opacity: 1; transform: translateY(-24px); transition: opacity 0.6s 0.3s; }
  .big-card, .celebrate, .sheet { transform: none !important; }
  .btn:active, a.card:active, .habit:has(.habit-main:active) { transform: none !important; }
}
