/* Round-end celebration, Stream checkpoint, and Level Up screen styling.
   Split from index.html — see palabra-file-split-plan.md. */

  /* Generic full-viewport layer for the canvas-particle effects below
     (confetti shower, streak embers, achievement sparkle burst) — replaces
     the old DOM-divs confetti-container now that all of these are drawn on
     canvas instead. Fixed + pointer-events:none so it never blocks taps on
     whatever screen is underneath it. */
  .fx-canvas-layer {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 999;
  }

  /* --- Round-end celebration screen (Perfect / Finished) --- */
  .celebrate-screen { justify-content: center; cursor: pointer; }
  .celebrate-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    position: relative;
    z-index: 3;
  }
  .celebrate-badge-ring {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 26px;
  }
  .celebrate-badge-ring::before {
    content: '';
    position: absolute;
    inset: -22px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--cream-dim) 0%, transparent 70%);
    opacity: 0.4;
    filter: blur(2px);
    animation: badgeGlowPulse 1.8s ease-in-out infinite;
  }
  .celebrate-badge-ring.perfect::before { background: radial-gradient(circle, var(--ochre) 0%, transparent 70%); }
  .celebrate-badge-ring.neutral::before { background: radial-gradient(circle, rgba(220,210,250,0.35) 0%, rgba(220,210,250,0.1) 45%, transparent 72%); }
  .celebrate-badge-ring.fire::before { background: radial-gradient(circle, rgba(255,138,61,0.45) 0%, rgba(255,138,61,0.14) 45%, transparent 72%); }

  /* Rotating conic-gradient swirl layers behind the badge disc — two
     counter-rotating layers per variant (warm/perfect, neutral/round-
     complete, fire/streak) blurred and blended with `screen` so they read
     as soft drifting colour rather than a hard-edged spinning shape. Sit
     behind celebrate-badge-disc in paint order since neither has an
     explicit stacking z-index of its own until the disc's z-index:1. */
  .celebrate-badge-swirl {
    position: absolute;
    border-radius: 50%;
    filter: blur(15px);
    mix-blend-mode: screen;
    pointer-events: none;
  }
  .swirl-perfect-a {
    inset: -38px;
    background: conic-gradient(from 0deg,
      transparent 0deg, rgba(245, 183, 61, 0.55) 70deg, transparent 150deg,
      rgba(232, 96, 80, 0.4) 230deg, transparent 300deg, transparent 360deg);
    animation: swirlSpinCW 7s linear infinite;
  }
  .swirl-perfect-b {
    inset: -50px;
    opacity: 0.65;
    background: conic-gradient(from 0deg,
      transparent 0deg, rgba(165, 140, 224, 0.5) 100deg, transparent 200deg,
      rgba(43, 191, 160, 0.35) 260deg, transparent 360deg);
    animation: swirlSpinCCW 11s linear infinite;
  }
  .swirl-neutral-a {
    inset: -38px;
    background: conic-gradient(from 0deg,
      transparent 0deg, rgba(182, 162, 246, 0.5) 80deg, transparent 170deg,
      rgba(235, 228, 252, 0.32) 250deg, transparent 340deg, transparent 360deg);
    animation: swirlSpinCW 9s linear infinite;
  }
  .swirl-neutral-b {
    inset: -50px;
    opacity: 0.6;
    background: conic-gradient(from 0deg,
      transparent 0deg, rgba(108, 60, 233, 0.42) 120deg, transparent 220deg,
      rgba(220, 210, 250, 0.28) 300deg, transparent 360deg);
    animation: swirlSpinCCW 13s linear infinite;
  }
  .swirl-fire-a {
    inset: -38px;
    background: conic-gradient(from 0deg,
      transparent 0deg, rgba(255, 138, 61, 0.6) 70deg, transparent 150deg,
      rgba(232, 70, 50, 0.5) 230deg, transparent 320deg, transparent 360deg);
    animation: swirlSpinCW 4.5s linear infinite;
  }
  .swirl-fire-b {
    inset: -50px;
    opacity: 0.65;
    background: conic-gradient(from 0deg,
      transparent 0deg, rgba(255, 196, 61, 0.55) 100deg, transparent 210deg,
      rgba(214, 50, 30, 0.4) 290deg, transparent 360deg);
    animation: swirlSpinCCW 6.5s linear infinite;
  }
  @keyframes swirlSpinCW  { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
  @keyframes swirlSpinCCW { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }

  /* Radiating "impact" ticks that flick outward around the Round Complete
     badge on entry, like the clap actually landing. Perfect/Streak don't
     use these — only rendered inside the neutral (Round Complete) badge. */
  .impact-ticks { position: absolute; inset: -46px; pointer-events: none; }
  .impact-ticks .tick { opacity: 0; transform-origin: center; }
  .impact-ticks .tick:nth-child(1) { animation-delay: 0.02s; }
  .impact-ticks .tick:nth-child(2) { animation-delay: 0.06s; }
  .impact-ticks .tick:nth-child(3) { animation-delay: 0.1s; }
  .impact-ticks .tick:nth-child(4) { animation-delay: 0.06s; }
  .impact-ticks .tick:nth-child(5) { animation-delay: 0.02s; }
  .celebrate-badge-ring .impact-ticks .tick {
    animation-name: tickFlash;
    animation-duration: 0.5s;
    animation-timing-function: ease-out;
    animation-fill-mode: forwards;
  }
  @keyframes tickFlash {
    0%   { opacity: 0; transform: scale(0.5); }
    40%  { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0; transform: scale(1.35); }
  }

  .celebrate-badge-disc {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bg-card-alt);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1.5px solid var(--outline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 62px;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 0 6px rgba(255,255,255,0.04), 0 12px 40px rgba(0,0,0,0.35);
    animation: badgePopIn 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  }
  @keyframes badgePopIn {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
  }
  @keyframes badgeGlowPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.96); }
    50%      { opacity: 0.7; transform: scale(1.08); }
  }
  .celebrate-headline {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 34px;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
    padding: 0 12px;
    text-align: center;
    text-wrap: balance;
    opacity: 0;
    animation: celebrateTextIn 0.5s ease-out 0.15s forwards;
  }
  .celebrate-headline.perfect { color: var(--ochre); }
  .celebrate-headline.finished { color: var(--cream); }
  .celebrate-subline {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: var(--cream-dim);
    margin: 0;
    padding: 0 12px;
    text-align: center;
    opacity: 0;
    animation: celebrateTextIn 0.5s ease-out 0.26s forwards;
  }
  /* Small Spanish-language flourish line, sits above the existing English
     subline (kept, not replaced) on the Stream checkpoint screen. Reuses
     celebrate-subline's fade-in but smaller/dimmer so the English subline
     underneath it still reads as the primary line. */
  .celebrate-flourish {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--cream-dim);
    opacity: 0;
    margin: 0 0 2px;
    padding: 0 12px;
    text-align: center;
    animation: celebrateTextIn 0.5s ease-out 0.2s forwards;
  }
  .celebrate-flourish + .celebrate-subline {
    animation-delay: 0.32s;
  }
  @keyframes celebrateTextIn {
    0%   { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
  }
  .celebrate-screen .tap-hint {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: var(--cream-dim);
    opacity: 0;
    animation: hintFadeIn 0.6s ease-out 0.9s forwards, hintPulse 2s ease-in-out 1.5s infinite;
    z-index: 3;
  }
  @keyframes hintFadeIn { to { opacity: 0.55; } }
  @keyframes hintPulse {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 0.7; }
  }

  /* Stream checkpoint — reuses the celebrate badge/headline/subline visuals
     above (fire variant), but isn't a whole-screen tap-to-skip like
     Celebrate is, since it needs two distinct choices (keep going / stop)
     rather than one. */
  .stream-checkpoint-screen { justify-content: center; }
  .checkpoint-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 260px;
    margin-top: -14px;
    opacity: 0;
    animation: celebrateTextIn 0.5s ease-out 0.36s forwards;
  }

  /* --- Level Up screen: self-contained, deliberately not reusing the
     celebrate-badge-* classes above even though the composition is
     similar, since the badge content here is a self-drawing SVG ring
     rather than an emoji disc. Kept as its own dedicated block to avoid
     any specificity bleed between the two. --- */
  .levelup-screen { justify-content: center; cursor: pointer; }
  .levelup-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; width: 100%; position: relative; z-index: 3; }
  .levelup-ring-outer {
    width: 148px; height: 148px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: relative; margin-bottom: 26px;
  }
  .levelup-ring-outer::before {
    content: ''; position: absolute; inset: -22px; border-radius: 50%;
    background: radial-gradient(circle, var(--ochre) 0%, transparent 70%);
    opacity: 0.4; filter: blur(2px);
    animation: badgeGlowPulse 1.8s ease-in-out infinite;
  }
  /* The ring itself: drawn via stroke-dasharray/-dashoffset, animated by
     JS in animateLevelRing() (render-quiz.js) rather than a CSS
     @keyframes, since it needs to start from a JS-known offset and land
     exactly when the number flips. rotate(-90deg) so the draw starts at
     12 o'clock instead of 3 o'clock. */
  .levelup-ring-svg {
    position: absolute;
    inset: 0;
    width: 148px;
    height: 148px;
    transform: rotate(-90deg);
    z-index: 1;
  }
  .levelup-ring-fill {
    fill: none;
    stroke: var(--ochre-light, var(--ochre));
    stroke-width: 13;
    stroke-linecap: round;
    stroke-dasharray: 376.99;
    stroke-dashoffset: 376.99;
  }
  .levelup-disc-inner {
    position: absolute;
    inset: 19px;
    border-radius: 50%;
    background: #1B1030;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 6px rgba(255,255,255,0.04), 0 12px 40px rgba(0,0,0,0.35);
  }
  .levelup-num { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 46px; color: var(--cream); line-height: 1; font-variant-numeric: tabular-nums; }
  .levelup-num.flip { animation: levelupNumberPop 0.4s cubic-bezier(.34,1.56,.64,1); }
  @keyframes levelupNumberPop {
    0%   { transform: scale(0.7); }
    60%  { transform: scale(1.25); }
    100% { transform: scale(1); }
  }
  .levelup-headline {
    font-family: 'Sora', sans-serif; font-weight: 800; font-size: 34px; letter-spacing: -0.01em;
    margin: 0 0 8px; padding: 0 12px; text-align: center; text-wrap: balance; color: var(--ochre);
    opacity: 0; animation: celebrateTextIn 0.5s ease-out 0.55s forwards;
  }
  .levelup-subline {
    font-family: 'Inter', sans-serif; font-size: 15px; color: var(--cream-dim); margin: 0;
    padding: 0 12px; text-align: center;
    opacity: 0; animation: celebrateTextIn 0.5s ease-out 0.7s forwards;
  }
  /* Small Spanish-language flourish line, sits above the existing English
     subline (kept, not replaced). Mirrors celebrate-flourish's treatment,
     kept as its own class per this file's existing "no specificity bleed
     with celebrate-*" convention (see block comment above). */
  .levelup-flourish {
    font-family: 'Inter', sans-serif; font-size: 13px; color: var(--cream-dim);
    margin: 0 0 2px; padding: 0 12px; text-align: center;
    opacity: 0; animation: celebrateTextIn 0.5s ease-out 0.62s forwards;
  }
  .levelup-screen .tap-hint {
    position: absolute; bottom: 40px; left: 0; right: 0; text-align: center;
    font-size: 11.5px; letter-spacing: 0.04em; color: var(--cream-dim);
    opacity: 0; animation: hintFadeIn 0.6s ease-out 0.9s forwards, hintPulse 2s ease-in-out 1.5s infinite;
    z-index: 3;
  }

  @media (prefers-reduced-motion: reduce) {
    .levelup-ring-outer::before,
    .levelup-headline,
    .levelup-flourish,
    .levelup-subline,
    .levelup-screen .tap-hint {
      animation: none !important;
      opacity: 1 !important;
    }
    .levelup-num.flip { animation: none !important; }
    .levelup-ring-fill { transition: none !important; }
  }

  @media (prefers-reduced-motion: reduce) {
    .celebrate-badge-ring::before,
    .celebrate-badge-swirl,
    .celebrate-badge-disc,
    .celebrate-headline,
    .celebrate-flourish,
    .celebrate-subline,
    .celebrate-screen .tap-hint,
    .impact-ticks .tick {
      animation: none !important;
      opacity: 1 !important;
      transform: none !important;
    }
  }
