/* ============================================================
   mv-motion.css — behaviour-level polish ONLY.

   Rules this sheet obeys:
   • Additive. No widths, heights, grid, flex, margin or padding are
     set here, so no layout can shift.
   • Only transform / opacity / filter animate (GPU, never layout).
   • Transitions (not keyframes) for anything interruptible.
   • Custom curves — the CSS built-ins are too weak to feel intentional.
   • Hover motion gated to real pointers so phones don't fake-hover.
   • Reduced-motion respected: keep colour/opacity, drop movement.
   ============================================================ */

:root {
  --mv-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --mv-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --mv-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ---- Press feedback ------------------------------------------------
   Any pressable surface confirms the tap instantly. 120ms is inside the
   100-160ms window where feedback reads as "the UI heard me" rather than
   as an animation. */
button,
.opt,
.list-item,
.tcard,
.option-card,
.tier,
[onclick],
a.btn,
.btn {
  transition: transform 120ms var(--mv-ease-out), opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

button:active,
.opt:active,
.list-item:active,
.tcard:active,
.option-card:active,
.btn:active {
  transform: scale(0.97);
}

/* Nothing appears from nothing: entry states start at 0.96, not 0. */
@keyframes mv-rise {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ---- Question cards -------------------------------------------------
   Each new question eases in. Short and subtle: this happens hundreds of
   times per session, so it must read as continuity, not choreography. */
#qText,
#qOptions,
.qimgbox img {
  animation: mv-rise 200ms var(--mv-ease-out) both;
}

/* ---- Loading bar polish ---------------------------------------------
   The fill already animates width from mv-loadbar.js (transform-free but
   cheap: one node). Keep the pulse gentle and the exit clean. */
#mvLoadBar .fill { will-change: width; }
#mvLoadBar { backdrop-filter: saturate(140%); }

/* ---- Lists: stagger the first few rows so a screen doesn't "pop" -----
   Capped at 8 rows via nth-child; beyond that the delays would make the
   page feel slow. Stagger is decorative and never blocks input. */
.list-item,
.tcard,
.option-card,
#qOptions > .opt {
  animation: mv-rise 240ms var(--mv-ease-out) both;
}
.list-item:nth-child(1), .tcard:nth-child(1) { animation-delay: 0ms; }
.list-item:nth-child(2), .tcard:nth-child(2) { animation-delay: 40ms; }
.list-item:nth-child(3), .tcard:nth-child(3) { animation-delay: 80ms; }
.list-item:nth-child(4), .tcard:nth-child(4) { animation-delay: 120ms; }
.list-item:nth-child(5), .tcard:nth-child(5) { animation-delay: 160ms; }
.list-item:nth-child(6), .tcard:nth-child(6) { animation-delay: 200ms; }
.list-item:nth-child(n+7) { animation-delay: 220ms; }

/* ---- Correct / incorrect reveal ------------------------------------
   Feedback lands with a tiny pop so the result registers even if the
   student is looking at the option they clicked, not the explanation. */
#qOptions > .opt.is-correct,
#qOptions > .opt.correct,
#qOptions > .opt.is-wrong,
#qOptions > .opt.wrong,
.option-card.is-correct,
#qOptions > .opt.is-incorrect,
#qOptions > .opt.incorrect,
.option-card.is-incorrect {
  animation: mv-pop 220ms var(--mv-ease-out) both;
}
@keyframes mv-pop {
  from { transform: scale(0.975); }
  to   { transform: scale(1); }
}

/* Explanation panel fades up rather than appearing mid-layout. */
#expl, #expBox, #zvNoKey, .expl-box {
  animation: mv-rise 220ms var(--mv-ease-out) both;
}

/* ---- Modals / sheets ------------------------------------------------
   Centred origin is correct for modals (they are not anchored to a
   trigger). Sheets rise from their own edge using translateY in %. */
[role="dialog"],
.modal,
.sheet {
  animation: mv-modal-in 220ms var(--mv-ease-out) both;
  transform-origin: center;
}
@keyframes mv-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* ---- Hover: real pointers only -------------------------------------
   Touch devices fire :hover on tap, which makes taps look like bugs. */
@media (hover: hover) and (pointer: fine) {
  .list-item:hover,
  .tcard:hover,
  .option-card:hover {
    transform: translateY(-1px);
    transition: transform 160ms var(--mv-ease-out);
  }
  .opt:hover:not([disabled]) {
    transform: translateX(2px);
  }
  button:hover:not([disabled]):not(.opt) {
    filter: brightness(1.04);
    transition: transform 120ms var(--mv-ease-out), filter 160ms ease;
  }
}

/* ---- Scrollbar: quieter, but only where it is visible --------------- */
@supports selector(::-webkit-scrollbar) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb {
    background: rgba(45, 112, 182, 0.28);
    border-radius: 999px;
    transition: background 160ms ease;
  }
  ::-webkit-scrollbar-thumb:hover { background: rgba(45, 112, 182, 0.45); }
  ::-webkit-scrollbar-track { background: transparent; }
}

/* ---- Focus: visible for keyboards, quiet for mice ------------------- */
:focus-visible {
  outline: 2px solid #62c8df;
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- Dark mode: keep the same motion, nothing colour-specific ------- */
[data-mvtheme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(98, 200, 223, 0.28);
}
[data-mvtheme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(98, 200, 223, 0.45);
}

/* ---- Reduced motion: drop movement, keep comprehension cues --------
   Opacity and colour stay (they aid understanding); translation and
   scale go. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  #qText, #qOptions, .qimgbox img,
  .list-item, .tcard, .option-card,
  .opt.is-correct, .opt.is-incorrect,
  #expl, #expBox, #zvNoKey, .expl-box,
  [role="dialog"], .modal, .sheet {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  button:active, .opt:active, .list-item:active,
  .tcard:active, .option-card:active, .btn:active {
    transform: none;
  }
}
