/* ============================================================
   CELEBRATIONS
   Three tiers: micro (a block), lesson, unit. Premium and short —
   the learner can always continue immediately.
   ============================================================ */

/* ---- Level 1: the correct answer itself -------------------------------
   A spring on the card, a soft success glow around it, and a handful of
   particles. The whole thing is under a second and never blocks anything. */
@keyframes micro-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.022); }
  62%  { transform: scale(0.997); }
  100% { transform: scale(1); }
}
@keyframes micro-pop-streak {
  0%   { transform: scale(1) rotate(0deg); }
  26%  { transform: scale(1.035) rotate(-.35deg); }
  58%  { transform: scale(0.995) rotate(.25deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes success-glow {
  0%   { box-shadow: var(--sh-2), 0 0 0 0 color-mix(in srgb, var(--ok) 46%, transparent); }
  40%  { box-shadow: var(--sh-2), 0 0 0 7px color-mix(in srgb, var(--ok) 20%, transparent); }
  100% { box-shadow: var(--sh-2), 0 0 0 12px transparent; }
}

/* The glow rides on the card's own box-shadow rather than a pseudo-element:
   .act clips its overflow, which would crop a ring drawn inside it. */
.act.did-celebrate-single {
  animation: micro-pop 480ms var(--e-spring), success-glow 760ms var(--e-out);
}
.act.did-celebrate-streak {
  animation: micro-pop-streak 720ms var(--e-spring), success-glow 940ms var(--e-out);
}

/* Light burst behind a completed block */
.burst {
  position: absolute; inset: -8px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(60% 60% at 50% 50%, var(--accent-wash) 0%, transparent 70%);
  opacity: 0; animation: burst 700ms var(--e-out) forwards;
}
@keyframes burst { 20% { opacity: 1; } 100% { opacity: 0; transform: scale(1.06); } }

/* ---- The floating reaction ------------------------------------------
   Real uploaded artwork on a small glass tile, anchored to the top-right of
   the activity. It is attached to the segment wrapper, not the card, because
   .act clips its own overflow. It is decorative and short-lived, so it is
   aria-hidden and never sits over the answer, the explanation or Continue. */
.cel-react {
  --react-size: 124px;
  position: absolute;
  z-index: 5;
  width: var(--react-size);
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 8px 6px;
  border-radius: 22px;
  background: rgba(255,255,255,.62);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 18px 40px rgba(35,29,83,.16), inset 0 1px 0 rgba(255,255,255,.9);
  pointer-events: none;
  transform-origin: 70% 30%;
  animation: react-in 460ms var(--e-spring) both;
}
@keyframes react-in {
  0%   { opacity: 0; transform: scale(.8); }
  62%  { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}
.cel-react.is-leaving { animation: react-out 600ms var(--e-out) forwards; }
@keyframes react-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(.94) translateY(-8px); }
}
.cel-react-img {
  display: block; width: 100%; height: auto; border-radius: 16px;
}
.cel-react-cap {
  font-family: var(--font-display); font-weight: 800;
  font-size: var(--t-xs); color: var(--accent-ink);
  text-align: center; line-height: 1.2;
}

@media (max-width: 720px) {
  .cel-react { --react-size: 92px; border-radius: 18px; padding: 6px 6px 5px; }
  .cel-react-img { border-radius: 13px; }
}
@media (max-width: 420px) {
  .cel-react { --react-size: 76px; }
}

/* The completion panel's own reaction art sits in the flow, not floating. */
.cel-art {
  width: min(190px, 46vw); height: auto; display: block;
  border-radius: var(--r-lg);
  filter: drop-shadow(0 16px 28px rgba(35,29,83,.16));
  animation: cel-art-in 620ms var(--e-spring) both;
}
@keyframes cel-art-in { from { opacity: 0; transform: scale(.86) translateY(10px); } }

/* ---- Particle field (canvas-free, transform-only) ---- */
.confetti-host {
  position: fixed; inset: 0; z-index: 300; pointer-events: none; overflow: hidden;
}
.confetti-host i {
  position: absolute; display: block;
  width: var(--cw, 9px); height: var(--ch, 14px);
  background: var(--cc, var(--accent));
  border-radius: var(--cr, 2px);
  opacity: .95;
  will-change: transform, opacity;
  animation: fall var(--cd, 2200ms) var(--e-out) forwards;
  animation-delay: var(--cdelay, 0ms);
}
@keyframes fall {
  0%   { transform: translate3d(0,0,0) rotate(0deg) scale(1); opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translate3d(var(--cx, 0), var(--cy, 90vh), 0) rotate(var(--crot, 540deg)) scale(.7); opacity: 0; }
}

/* Glass shards — a lighter, more "premium" variant for micro moments */
.confetti-host i.shard {
  background: linear-gradient(135deg, rgba(255,255,255,.95), var(--cc, var(--accent)));
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(28,23,71,.14);
}

/* ---- Tier 2/3: full celebration panel ---- */
.celebrate {
  position: relative;
  display: grid; gap: var(--s4); justify-items: center; text-align: center;
  padding: clamp(var(--s5), 5vw, var(--s8)) clamp(var(--s4), 4vw, var(--s6));
  border-radius: var(--r-xl);
  background: linear-gradient(150deg,
      rgba(255,255,255,.92) 0%,
      color-mix(in srgb, var(--accent) 16%, white) 55%,
      color-mix(in srgb, var(--accent-2) 22%, white) 100%);
  border: 1px solid var(--glass-line);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
.celebrate::after {
  content: ""; position: absolute; inset: -40% -10% auto -10%; height: 70%;
  background: radial-gradient(50% 60% at 50% 100%, rgba(255,255,255,.85), transparent 70%);
  pointer-events: none;
}
.celebrate .cel-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: var(--t-2xl); color: var(--ink-900); letter-spacing: -.02em;
  animation: cel-title 620ms var(--e-spring) both;
}
@keyframes cel-title {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
}
.celebrate .cel-sub { color: var(--ink-700); max-width: 46ch; }

/* A perfect run should look visibly different, not just say so. */
.celebrate.is-perfect {
  background: linear-gradient(150deg,
      rgba(255,255,255,.94) 0%,
      color-mix(in srgb, var(--c-sun) 22%, white) 42%,
      color-mix(in srgb, var(--accent) 24%, white) 100%);
  border-color: color-mix(in srgb, var(--c-sun) 46%, transparent);
  box-shadow: var(--sh-3), 0 0 0 1px color-mix(in srgb, var(--c-sun) 30%, transparent);
}
.celebrate.is-perfect .cel-art { width: min(220px, 52vw); }
.celebrate .cel-ring { animation: cel-ring 700ms var(--e-spring) both; }
@keyframes cel-ring { from { opacity: 0; transform: scale(.7) rotate(-24deg); } }

/* "You can now…" skill list — skills, not percentages */
.cando { display: grid; gap: var(--s2); text-align: left; width: min(100%, 34rem); }
.cando li {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4);
  background: rgba(255,255,255,.78); border: 1px solid var(--glass-line);
  border-radius: var(--r-md); font-weight: 700; color: var(--ink-800);
  animation: cando-in 520ms var(--e-out) both;
}
.cando li:nth-child(1) { animation-delay: 120ms; }
.cando li:nth-child(2) { animation-delay: 200ms; }
.cando li:nth-child(3) { animation-delay: 280ms; }
.cando li:nth-child(4) { animation-delay: 360ms; }
.cando li:nth-child(5) { animation-delay: 440ms; }
.cando li:nth-child(6) { animation-delay: 520ms; }
.cando li:nth-child(7) { animation-delay: 600ms; }
.cando li:nth-child(8) { animation-delay: 680ms; }
@keyframes cando-in { from { opacity: 0; transform: translateX(-10px); } }
.cando .ck {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ok); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
}

/* Reward strip */
.rewards { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: center; }
.reward {
  display: grid; gap: 2px; justify-items: center;
  padding: var(--s3) var(--s4); min-width: 96px;
  background: rgba(255,255,255,.8); border: 1px solid var(--glass-line);
  border-radius: var(--r-md); box-shadow: var(--sh-1);
}
.reward .r-num { font-family: var(--font-display); font-weight: 800; font-size: var(--t-xl); color: var(--accent-ink); }
.reward .r-lab { font-size: var(--t-xs); color: var(--ink-600); font-weight: 700; }

/* Surprise moment (bonus, cultural fact, hidden scene) */
.surprise {
  position: relative; overflow: hidden;
  padding: var(--s4) var(--s5); border-radius: var(--r-lg);
  background: linear-gradient(120deg,
    color-mix(in srgb, var(--c-violet) 14%, white),
    color-mix(in srgb, var(--c-sun) 16%, white));
  border: 1px solid color-mix(in srgb, var(--c-violet) 24%, transparent);
  box-shadow: var(--sh-2);
  animation: surprise-in 520ms var(--e-spring) both;
}
@keyframes surprise-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.surprise .sp-tag {
  font-family: var(--font-display); font-weight: 800; font-size: var(--t-xs);
  letter-spacing: .11em; text-transform: uppercase; color: var(--c-violet-d);
  display: flex; gap: 6px; align-items: center; margin-bottom: 4px;
}

/* Daily Flame — never shames a missed day */
.flame {
  display: inline-flex; align-items: center; gap: var(--s2);
  white-space: nowrap; flex: none;
  padding: 6px 14px 6px 8px; border-radius: var(--r-pill);
  background: linear-gradient(120deg, color-mix(in srgb, var(--c-tangerine) 20%, white), color-mix(in srgb, var(--c-sun) 24%, white));
  border: 1px solid color-mix(in srgb, var(--c-tangerine) 30%, transparent);
  font-family: var(--font-display); font-weight: 800; font-size: var(--t-sm);
  color: #7a3600;
}
.flame .fl-glyph {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, #fff 0%, var(--c-sun) 34%, var(--c-tangerine) 76%);
  box-shadow: 0 0 12px rgba(255,138,61,.55);
  animation: flame-breathe 2.6s var(--e-out) infinite alternate;
}
@keyframes flame-breathe { to { transform: scale(1.09); box-shadow: 0 0 18px rgba(255,138,61,.75); } }
/* Unlit, but still clearly a flame waiting to be lit — not an empty hole. */
.flame.is-cold .fl-glyph {
  background: radial-gradient(circle at 50% 62%, #fff 0%, var(--ink-100) 40%, var(--ink-300) 100%);
  box-shadow: inset 0 0 0 1px var(--ink-200);
  animation: none;
}
.flame.is-cold { background: rgba(255,255,255,.7); color: var(--ink-600); border-color: var(--glass-edge); }

/* ---- Reduced motion --------------------------------------------------
   No particles and no spring. The learner still gets an unmistakable
   success state: a steady success ring on the card, and the reaction
   artwork fading in and out. */
@media (prefers-reduced-motion: reduce) {
  .confetti-host { display: none !important; }
  .celebrate .cel-title, .celebrate .cel-ring, .cando li, .surprise,
  .cel-art { animation: none !important; }

  /* A steady success ring instead of a spring — still unmistakable. */
  .act.did-celebrate,
  .act.did-celebrate-single,
  .act.did-celebrate-streak {
    animation: none !important;
    box-shadow: var(--sh-2), 0 0 0 3px color-mix(in srgb, var(--ok) 42%, transparent);
  }
  .burst { display: none !important; }

  .cel-react { animation: react-fade-in 240ms linear both; }
  @keyframes react-fade-in { from { opacity: 0; } to { opacity: 1; } }
  .cel-react.is-leaving { animation: react-fade-out 320ms linear forwards; }
  @keyframes react-fade-out { from { opacity: 1; } to { opacity: 0; } }
}
