/* =========================================================
   Ionik+ — Motion library.
   Single source of truth for any non-trivial animation in the app.
   If you're writing a transition longer than 240ms, use a keyframe
   from this file instead — the springs + cascade tokens are tuned
   to feel "bubbly / fluid" rather than the flat smooth-ease defaults.
   ========================================================= */

:root {
  /* --- Spring easings (overshoot bezier curves) ----------------- */
  --spring-soft:   cubic-bezier(0.34, 1.26, 0.64, 1);   /* gentle overshoot */
  --spring-snappy: cubic-bezier(0.22, 1.50, 0.36, 1);   /* quick pop */
  --spring-bouncy: cubic-bezier(0.34, 1.56, 0.64, 1);   /* big bounce */
  --spring-back:   cubic-bezier(0.68, -0.55, 0.32, 1.55); /* anticipation + overshoot */

  /* --- Sharp easings (for press / drag-out) --------------------- */
  --ease-sharp: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-decel: cubic-bezier(0.05, 0.7, 0.1, 1);

  /* --- Durations ------------------------------------------------ */
  --m-quick:   220ms;
  --m-base:    360ms;
  --m-slow:    480ms;
  --m-xslow:   900ms;
  --m-bubble:  720ms;   /* enough for scale 0 → 1.12 → 1 to read */

  /* --- Stagger step --------------------------------------------- */
  /* Trimmed from 80ms: a content-heavy page (Portal, Syllabus Journey) with
     10+ staggered panels was taking over a second to finish settling —
     "watching the page assemble" reads as templated, not premium. Page-load
     cascades below also cap at 8 items' worth of delay (see fx-* rules) so a
     long page's last element doesn't wait indefinitely; it just joins the
     last visible wave instead. */
  --m-stagger: 40ms;
}

/* =========================================================
   KEYFRAMES — copy-paste these, don't invent new ones.
   ========================================================= */

/* Bubble in — scale from 0 with overshoot. Optional --fr-y for vertical offset. */
@keyframes ionik-bubble-in {
  0%   { transform: translate(0, 0) scale(0);        opacity: 0; filter: blur(4px); }
  55%  {                                               opacity: 1; filter: blur(0); }
  78%  { transform: translate(0, var(--fr-y, 0)) scale(1.12); }
  100% { transform: translate(0, var(--fr-y, 0)) scale(1);    opacity: 1; filter: blur(0); }
}

/* Bubble out — fast retract, no overshoot. */
@keyframes ionik-bubble-out {
  0%   { transform: translate(0, var(--fr-y, 0)) scale(1); opacity: 1; }
  100% { transform: translate(0, 0) scale(0);              opacity: 0; }
}

/* Spring in — for cards, modals, sections that should "punch" into view */
@keyframes ionik-spring-in {
  0%   { transform: translateY(14px) scale(0.92); opacity: 0; filter: blur(6px); }
  60%  { transform: translateY(-2px) scale(1.02); opacity: 1; filter: blur(0); }
  100% { transform: translateY(0)    scale(1);    opacity: 1; filter: blur(0); }
}

/* Fade rise — gentlest reveal. Use for text/long lists where bubble is too much. */
@keyframes ionik-fade-rise {
  0%   { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0);    opacity: 1; }
}

/* Magnetic slide — translate-only with overshoot, no scale (good for nudge effects) */
@keyframes ionik-magnetic-in {
  0%   { transform: translateY(-18px); opacity: 0; }
  70%  { transform: translateY(3px);   opacity: 1; }
  100% { transform: translateY(0);     opacity: 1; }
}

/* Pulse glow — subtle attention pull. Loop with infinite. */
@keyframes ionik-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
  50%      { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* Shimmer — for skeleton loaders */
@keyframes ionik-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.fx-spring-in {
  animation: ionik-spring-in var(--m-slow) var(--spring-soft) calc(min(var(--i, 0), 8) * var(--m-stagger)) both;
}
.fx-rise {
  animation: ionik-fade-rise var(--m-base) var(--ease-decel) calc(min(var(--i, 0), 8) * 30ms) both;
}
.fx-magnetic-in {
  animation: ionik-magnetic-in var(--m-base) var(--spring-snappy) calc(min(var(--i, 0), 8) * 30ms) both;
}

/* Stagger helper — sets --i on each child so children share one animation rule.
   Supports up to 24 siblings; extend if you have more. */
.fx-stagger-children > *:nth-child(1)  { --i: 0; }
.fx-stagger-children > *:nth-child(2)  { --i: 1; }
.fx-stagger-children > *:nth-child(3)  { --i: 2; }
.fx-stagger-children > *:nth-child(4)  { --i: 3; }
.fx-stagger-children > *:nth-child(5)  { --i: 4; }
.fx-stagger-children > *:nth-child(6)  { --i: 5; }
.fx-stagger-children > *:nth-child(7)  { --i: 6; }
.fx-stagger-children > *:nth-child(8)  { --i: 7; }
.fx-stagger-children > *:nth-child(9)  { --i: 8; }
.fx-stagger-children > *:nth-child(10) { --i: 9; }
.fx-stagger-children > *:nth-child(11) { --i: 10; }
.fx-stagger-children > *:nth-child(12) { --i: 11; }
.fx-stagger-children > *:nth-child(13) { --i: 12; }
.fx-stagger-children > *:nth-child(14) { --i: 13; }
.fx-stagger-children > *:nth-child(15) { --i: 14; }
.fx-stagger-children > *:nth-child(16) { --i: 15; }
.fx-stagger-children > *:nth-child(17) { --i: 16; }
.fx-stagger-children > *:nth-child(18) { --i: 17; }
.fx-stagger-children > *:nth-child(19) { --i: 18; }
.fx-stagger-children > *:nth-child(20) { --i: 19; }

.fx-glow {
  transition: box-shadow var(--m-base) var(--spring-soft);
}
.fx-glow:hover { box-shadow: 0 10px 28px -12px rgba(42,36,28,0.30); }

/* =========================================================
   GLOBAL SPRING INTERACTIONS
   These override the flat bezier transitions in ionik-cream.css.
   Load this file AFTER cream.css. No markup changes needed.
   ========================================================= */

/* --- Buttons: spring lift on hover, firm press on active --- */
.btn {
  transition:
    background 180ms var(--ease-sharp),
    color 180ms var(--ease-sharp),
    border-color 180ms var(--ease-sharp),
    transform 260ms var(--spring-snappy),
    box-shadow 320ms var(--spring-soft) !important;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px -10px rgba(42,36,28,0.28) !important;
}
.btn:active {
  transform: translateY(1px) scale(0.97) !important;
  box-shadow: none !important;
  transition-duration: 100ms !important;
}
.btn.primary:hover { box-shadow: 0 10px 26px -10px rgba(42,36,28,0.42) !important; }
.btn.danger:hover  { box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--r-red) 28%, transparent) !important; }

/* --- Bell & avatar: spring scale on hover --- */
.bell, .avatar {
  transition:
    background 180ms var(--ease-sharp),
    transform 280ms var(--spring-bouncy),
    box-shadow 300ms var(--spring-soft) !important;
}
.bell:hover, .avatar:hover {
  transform: scale(1.1) !important;
  box-shadow: 0 6px 18px -8px rgba(42,36,28,0.28) !important;
}
.bell:active, .avatar:active { transform: scale(0.92) !important; transition-duration: 100ms !important; }

/* --- Multi-part navigator circles (A·b·c·d): spring scale on hover, firm press --- */
.qpart-dot {
  transition:
    background 180ms var(--ease-sharp),
    border-color 180ms var(--ease-sharp),
    color 180ms var(--ease-sharp),
    transform 300ms var(--spring-bouncy),
    box-shadow 320ms var(--spring-soft) !important;
}
.qpart-dot:hover    { transform: scale(1.12) !important; }
.qpart-dot.on:hover { transform: scale(1.18) !important; }
.qpart-dot:active   { transform: scale(0.94) !important; transition-duration: 100ms !important; }

/* --- Dropdowns: spring-in on open, spring-out on close --- */
.notif-panel,
.menu {
  transition:
    opacity 260ms var(--ease-sharp),
    transform 480ms var(--spring-bouncy) !important;
}
.notif-panel.open,
.menu.open {
  transform: translateY(0) scale(1) !important;
}
/* Starting state (closed): scale down + shift up + invisible */
.notif-panel     { transform: translateY(-8px) scale(0.94) !important; }
.menu            { transform: translateY(-8px) scale(0.94) !important; }

/* Dropdown items: stagger-fade-in when panel opens */
.notif-panel.open .ni,
.menu.open .mi {
  animation: ionik-fade-rise 340ms var(--spring-soft) calc(var(--i, 0) * 45ms) both;
}
.notif-panel.open .ni:nth-child(1)  { --i: 0; }
.notif-panel.open .ni:nth-child(2)  { --i: 1; }
.notif-panel.open .ni:nth-child(3)  { --i: 2; }
.notif-panel.open .ni:nth-child(4)  { --i: 3; }
.menu.open .mi:nth-child(1) { --i: 0; }
.menu.open .mi:nth-child(2) { --i: 1; }
.menu.open .mi:nth-child(3) { --i: 2; }
.menu.open .mi:nth-child(4) { --i: 3; }

/* Dropdown items: hover lift */
.notif-panel .ni,
.menu .mi {
  transition: background 160ms var(--ease-sharp), transform 260ms var(--spring-snappy) !important;
  border-radius: var(--r-sm);
}
.notif-panel .ni:hover  { transform: translateX(3px) !important; }
.menu .mi:hover         { transform: translateX(3px) !important; }

/* --- Panel / card hover lift --- */
.panel {
  transition: background 220ms var(--ease-sharp), box-shadow 360ms var(--spring-soft) !important;
}
.panel.lift:hover { box-shadow: 0 12px 30px -16px rgba(42,36,28,0.28) !important; }

/* --- Tags / chips spring pop on hover --- */
.tag, .chip {
  transition: transform 260ms var(--spring-bouncy), background 160ms var(--ease-sharp) !important;
}
.tag:hover, .chip:hover { transform: scale(1.06) !important; }

/* =========================================================
   Sign-in "dive" — Auth card turns black, shows the loader, then
   zooms past the camera; the next page fades up out of the black.
   Opacity + transform only (compositor-friendly for old laptops / iPads).
   ========================================================= */
:root { --dive-black: #0b0907; }

/* Multi-step panels: next slides in from the right, Back from the left. */
@keyframes ionik-step-in {
  0%   { transform: translateX(var(--step-dir, 16px)); opacity: 0; }
  100% { transform: translateX(0);                     opacity: 1; }
}
.fx-step-in { animation: ionik-step-in var(--m-base) var(--ease-decel) both; }

@keyframes ionik-dive-zoom {
  0%   { transform: scale(1); }
  100% { transform: scale(var(--dive-scale, 10)); }
}
@keyframes ionik-arrive {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.dive-layer {
  position: absolute; inset: 0; z-index: 5;
  border-radius: inherit;
  background: var(--dive-black);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--m-base) var(--ease-sharp);
}
.dive-veil {
  position: fixed; inset: 0; z-index: 50;
  background: var(--dive-black);
  opacity: 0; pointer-events: none;
  transition: opacity var(--m-xslow) var(--ease-sharp);
}
.fx-dive-dim { will-change: transform; }
.fx-dive-dim .dive-layer { opacity: 1; pointer-events: auto; }
.fx-dive-zoom { position: relative; z-index: 60; animation: ionik-dive-zoom 820ms cubic-bezier(0.7, 0, 0.84, 0) forwards; }
.fx-dive-veil .dive-veil { opacity: 1; }

/* Sign-out: the app page fades to black (ionikSignOut adds a veil), then the
   Auth card starts full-screen black and shrinks back to a panel. */
@keyframes ionik-dive-out {
  0%   { transform: scale(var(--dive-scale, 10)); }
  100% { transform: scale(1); }
}
.fx-dive-unzoom { position: relative; z-index: 60; animation: ionik-dive-out 880ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.dive-veil.is-exit { z-index: 10000; transition-duration: var(--m-slow); }

/* Arrival: theme.js adds .ionik-arrive on the first page after sign-in. */
html.ionik-arrive { background: var(--dive-black); }
html.ionik-arrive body { min-height: 100vh; animation: ionik-arrive 1100ms var(--ease-sharp) 60ms both; }

/* =========================================================
   Ionik loader — THE loading indicator for the whole app.
   Blue square + red circle squeezing round each other (same mark as
   the sign-in loader in ionik-loader.js). Never use a grey ring spinner.
     <span class="ik-loader sm" aria-hidden="true"></span>
   Sizes: xs 12 · sm 16 · (default) 20 · md 24 · lg 40 · xl 56.
   The squeeze is in % so it keeps its shape at every size.
   ========================================================= */
@keyframes ik-loader-squeeze {
  0%    { inset: 0 44% 44% 0; }
  12.5% { inset: 0 44% 0 0; }
  25%   { inset: 44% 44% 0 0; }
  37.5% { inset: 44% 0 0 0; }
  50%   { inset: 44% 0 0 44%; }
  62.5% { inset: 0 0 0 44%; }
  75%   { inset: 0 0 44% 44%; }
  87.5% { inset: 0 0 44% 0; }
  100%  { inset: 0 44% 44% 0; }
}
@keyframes ik-loader-spin { to { transform: rotate(-360deg); } }
.ik-loader {
  --s: 20px; --ik-squeeze: 2.4s; --ik-spin: 8s;
  position: relative; display: inline-block; flex: none; vertical-align: middle;
  width: var(--s); height: var(--s);
  contain: layout;
  animation: ik-loader-spin var(--ik-spin) linear infinite;
}
.ik-loader::before, .ik-loader::after {
  content: ''; position: absolute; inset: 0 44% 44% 0;
  animation: ik-loader-squeeze var(--ik-squeeze) infinite;
}
.ik-loader::before { background: var(--brand-blue, #5B6FE8); }
.ik-loader::after  { background: var(--brand-red, #FF5C5C); border-radius: 999px; animation-delay: calc(var(--ik-squeeze) * -0.4167); }
.ik-loader.xs { --s: 12px; }
.ik-loader.sm { --s: 16px; }
.ik-loader.md { --s: 24px; }
.ik-loader.lg { --s: 40px; --ik-squeeze: 3s; --ik-spin: 10s; }
.ik-loader.xl { --s: 56px; --ik-squeeze: 3s; --ik-spin: 10s; }

/* =========================================================
   Reduced motion — ALWAYS respect
   ========================================================= */
/* Keyboard focus stays visible even on controls that reset their own outline. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent, #8a6d2f) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #8a6d2f) 18%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .fx-spring-in,
  .fx-rise,
  .fx-magnetic-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  .fx-glow { transition: none !important; }
  .fx-step-in, .fx-dive-zoom, .fx-dive-unzoom { animation: none !important; }
  /* A loader is essential feedback: keep the squeeze, drop the spin, slow it down. */
  .ik-loader { animation: none; --ik-squeeze: 4s; }
  html.ionik-arrive body { animation-duration: 300ms !important; }

  .btn, .bell, .avatar,
  .notif-panel, .menu,
  .notif-panel .ni, .menu .mi, .panel, .tag, .chip {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
  /* Part navigator: stop hover/press motion but keep the selected dot's static
     scale + colour as a no-animation state cue. */
  .qpart-dot, .qpart-line { transition: none !important; animation: none !important; }
  .qpart-dot:hover, .qpart-dot:active { transform: none !important; }
}
