/* ══ PAGE TRANSITIONS ══ */
.page { display: none; flex: 1; }
.page.active {
  display: flex;
  flex-direction: column;
  animation: pageIn .22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.page.active.page-exit {
  animation: pageOut .13s ease forwards;
  pointer-events: none;
}
@keyframes pageIn  { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pageOut { from { opacity: 1; transform: translateY(0);  } to { opacity: 0; transform: translateY(-5px); } }

/* ══ SKELETON LOADING ══ */
.skeleton {
  background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes skeletonShimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.skel-title   { height: 22px; border-radius: 3px; margin-bottom: 8px; }
.skel-sub     { height: 12px; border-radius: 3px; width: 60%; }
.skel-value   { height: 40px; width: 70%; border-radius: 3px; margin: 4px 0 6px; }
.skel-row     { height: 11px; border-radius: 3px; margin-bottom: 6px; }
.skel-row.w80 { width: 80%; }
.skel-row.w60 { width: 60%; }
.skel-row.w40 { width: 40%; }

/* ══ TOAST NOTIFICATIONS ══ */
#toastContainer { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-radius: 8px; font-size: 12px; font-family: 'Barlow', sans-serif;
  min-width: 240px; max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5); border: 1px solid; pointer-events: all;
  animation: toastIn .28s cubic-bezier(.34,1.56,.64,1);
}
.toast.out { animation: toastOut .2s ease forwards; }
.toast-success { background: rgba(17,28,22,.97);  border-color: rgba(40,194,101,.3);  color: var(--green); }
.toast-error   { background: rgba(28,14,14,.97);   border-color: rgba(238,60,60,.3);   color: var(--red); }
.toast-info    { background: rgba(14,18,28,.97);   border-color: rgba(77,140,245,.3);  color: var(--blue); }
.toast-warn    { background: rgba(28,24,14,.97);   border-color: rgba(240,160,32,.3);  color: var(--gold); }
.toast-icon  { font-size: 15px; flex-shrink: 0; }
.toast-msg   { flex: 1; line-height: 1.45; }
.toast-close { background: none; border: none; color: inherit; opacity: .5; cursor: pointer; font-size: 16px; padding: 0; line-height: 1; flex-shrink: 0; }
.toast-close:hover { opacity: 1; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(16px) scale(.95); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(10px) scale(.97); } }

/* ══ BUTTON SPINNER ══ */
.btn-spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.3); border-top-color: rgba(255,255,255,.85); border-radius: 50%; animation: spin .6s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.run-btn.busy, .gen-btn.busy { display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ══ MICRO-ANIMATIONS ══ */

/* Primary buttons — tap feedback */
.run-btn:active, .gen-btn:active, .auth-submit:active, .start-btn:active, .chat-send:active, .log-btn:active {
  transform: scale(0.97) !important;
  transition: transform .08s ease !important;
}

/* Session complete — success pulse ring */
@keyframes successPulse {
  0%   { box-shadow: 0 0 0 0 rgba(40,194,101,.5); }
  60%  { box-shadow: 0 0 0 8px rgba(40,194,101,0); }
  100% { box-shadow: 0 0 0 0 rgba(40,194,101,0); }
}
.sess-complete-btn.done.pulse { animation: successPulse .55s ease; }

/* Stat count-up glow — applied in JS */
@keyframes statReveal {
  from { opacity: 0; transform: translateY(6px) scale(.95); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}
.stat-animating { animation: statReveal .35s cubic-bezier(0.16, 1, 0.3, 1) both; }

/* Nav hover slide */
.stab { transition: all .15s cubic-bezier(.34,1.56,.64,1); }
.stab:hover:not(.active) { transform: translateX(3px); }

/* Dash card spring hover */
.dash-card {
  transition: border-color .2s, transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.dash-card:hover { transform: translateY(-2px) !important; }

/* Quick action button spring */
.qa-btn { transition: all .25s cubic-bezier(.34,1.56,.64,1) !important; }
.qa-btn:hover { transform: translateY(-3px) scale(1.01) !important; }

/* Input focus — grow ring smoothly */
.f input, .f select,
.pc-f input, .pc-f select,
.auth-field input {
  transition: border-color .15s, box-shadow .2s cubic-bezier(.34,1.56,.64,1) !important;
}

/* Progress ring SVG stroke animation */
.wk-ring-fill {
  transition: stroke-dashoffset .55s cubic-bezier(.4,0,.2,1), stroke .3s ease;
}

/* Race hero time glow */
.hero-time-wrap .ht { font-family: 'Barlow Condensed', sans-serif; font-size: 52px; font-weight: 900; line-height: 1; letter-spacing: -.02em; text-shadow: 0 0 30px rgba(255,106,48,.25); }

/* Chat typing */
@keyframes typing { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* ══ ANIMATED STATION / PLAN BARS — stagger on first render ══ */
@keyframes barGrow { from { width: 0 !important; } }
.sc-bf.animate, .spbar.animate, .bal-seg.animate, .mod-bar-fill.animate {
  animation: barGrow .7s cubic-bezier(.4,0,.2,1) both;
}

/* ══ CONFETTI CANVAS (auto-positioned by library) ══ */
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 9998; }
