/*
 * dash-animations.css
 * DASH Animation System — standalone stylesheet
 * Covers: A) Path Pulse, B) Summit Flash, C) Toast Overlay, D) Cinematic Overlay
 *
 * Usage overview:
 *   A) Path Pulse  — add .anim-path-pulse to a .node element to trigger the full sequence
 *   B) Summit Flash — add .summit-fire to a .journey-card element
 *   C) Toast        — use #dashToast with classes .toast--in / .toast--out
 *   D) Cinematic    — use .dash-cinematic with classes .cinematic--open / .cinematic--closing
 *
 * All timing is CSS-only; orchestration lives in dash-animations.js.
 */

/* ─────────────────────────────────────────────────────────────────────────────
   A. PATH PULSE
   Represents a small task completion travelling along a connector line.

   HTML structure expected:
     <div class="connector-wrap">
       <div class="connector-fill"></div>   ← the line that grows
       <div class="connector-dot"></div>    ← the dot that rides along it
     </div>
     <div class="node">                     ← destination node
       <svg class="node__check">…</svg>
       <div class="node__ripple node__ripple--1"></div>
       <div class="node__ripple node__ripple--2"></div>
       <div class="node__pct">72%</div>
     </div>

   Trigger: add .anim-path-pulse to the .node element.
   JS in dash-animations.js handles sequencing and removal.
───────────────────────────────────────────────────────────────────────────── */

/* Connector line grows left→right */
@keyframes connectorTravel {
  0%   { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

/* Dot rides from left end to right end of the connector */
@keyframes dotRide {
  0%   { right: 100%; opacity: 1; }
  90%  { right: -5px;  opacity: 1; }
  100% { right: -5px;  opacity: 0; }
}

/* Destination node pops on arrival */
@keyframes nodePop {
  0%   { transform: scale(1);    }
  40%  { transform: scale(1.28); }
  65%  { transform: scale(0.92); }
  100% { transform: scale(1);    }
}

/* Check icon snaps in */
@keyframes checkIn {
  0%   { opacity: 0; transform: scale(0.3)  rotate(-20deg); }
  60%  { opacity: 1; transform: scale(1.15) rotate(4deg);   }
  100% { opacity: 1; transform: scale(1)    rotate(0deg);   }
}

/* Ripple radiates outward from the node */
@keyframes rippleOut {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(2.4); opacity: 0;   }
}

/* Percentage counter bumps on update */
@keyframes pctBump {
  0%   { transform: scale(1);    }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1);    }
}

/* ── Connector elements ── */
.connector-wrap {
  position: relative;
  flex: 1;
  height: 2px;
  background: rgba(16, 120, 190, 0.10);
  border-radius: 1px;
  overflow: visible;
}

.connector-fill {
  position: absolute;
  inset: 0;
  border-radius: 1px;
  background: linear-gradient(90deg, #27b577, #5cc3dd);
  transform: scaleX(0);
  transform-origin: left center;
}

/* Triggered state — fill travels across */
.node.anim-path-pulse ~ .connector-wrap .connector-fill,
.anim-path-pulse-fill {
  animation: connectorTravel 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.connector-dot {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #27b577;
  transform: translateY(-50%);
  opacity: 0;
}

/* Triggered state — dot rides */
.anim-path-pulse-dot {
  animation: dotRide 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Node elements ── */
.node {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.node__check {
  opacity: 0;
}

.node__ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(39, 181, 119, 0.5);
  pointer-events: none;
}

.node__pct {
  font-family: 'Lato', sans-serif;
  font-size: 11px;
  font-weight: 700;
}

/* Triggered: node pops */
.anim-path-pulse .node,
.node.anim-node-pop {
  animation: nodePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Triggered: check snaps in */
.node.anim-path-pulse .node__check,
.anim-check-in {
  animation: checkIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s forwards;
}

/* Triggered: ripples radiate */
.anim-ripple-1 {
  animation: rippleOut 0.6s ease-out 0.0s forwards;
}
.anim-ripple-2 {
  animation: rippleOut 0.6s ease-out 0.15s forwards;
}

/* Triggered: percentage counter bumps */
.anim-pct-bump {
  animation: pctBump 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}


/* ─────────────────────────────────────────────────────────────────────────────
   B. SUMMIT FLASH
   Plays on stage (journey-card) completion. Add .summit-fire to the card.
   The card gains a temporary animated glow + sky-warm overlay.
   Child pseudo-elements and injected SVG elements drive the individual beats.

   HTML structure expected:
     <div class="journey-card">…card content…</div>

   Trigger: add .summit-fire class via JS (see DashAnim.summitFlash).
   Remove after ~2.5 s.
───────────────────────────────────────────────────────────────────────────── */

/* Rays fan out from behind the card centre-top */
@keyframes raysFan {
  0%   { opacity: 0; transform: scaleY(0) rotate(0deg);   }
  30%  { opacity: 1; transform: scaleY(1) rotate(0deg);   }
  80%  { opacity: 0.6; transform: scaleY(1.2) rotate(2deg); }
  100% { opacity: 0; transform: scaleY(0.8) rotate(-1deg); }
}

/* Subtle glow pulse on the card border */
@keyframes glowPulse {
  0%   { box-shadow: 0 0 0   0px rgba(39, 181, 119, 0);    }
  40%  { box-shadow: 0 0 32px 8px rgba(39, 181, 119, 0.35); }
  100% { box-shadow: 0 0 0   0px rgba(39, 181, 119, 0);    }
}

/* Flag plants down from above */
@keyframes flagPlant {
  0%   { opacity: 0; transform: translateY(-20px) scale(0.7); }
  60%  { opacity: 1; transform: translateY(4px)   scale(1.1); }
  80%  { transform: translateY(-2px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0)     scale(1);   }
}

/* Hills rise up from below */
@keyframes hillsRise {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0);    }
}

/* Badge scales in from centre */
@keyframes badgeIn {
  0%   { opacity: 0; transform: scale(0.5) rotate(-8deg); }
  65%  { opacity: 1; transform: scale(1.12) rotate(2deg); }
  100% { opacity: 1; transform: scale(1)    rotate(0deg); }
}

/* Sky warms from cool to golden */
@keyframes skyWarm {
  0%   { background: rgba(92, 195, 221, 0); }
  30%  { background: rgba(255, 210, 80, 0.18); }
  70%  { background: rgba(255, 175, 50, 0.12); }
  100% { background: rgba(39, 181, 119, 0); }
}

/* ── Summit fire card state ── */
.journey-card.summit-fire {
  animation: glowPulse 2s ease-out forwards;
}

/* Sky-warm overlay (injected pseudo-element via JS) */
.summit-fire__sky {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  animation: skyWarm 2s ease forwards;
}

/* Rays element */
.summit-fire__rays {
  position: absolute;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 140%;
  height: 60%;
  pointer-events: none;
  z-index: 1;
  transform-origin: top center;
  animation: raysFan 1.6s ease forwards;
}

/* Flag element */
.summit-fire__flag {
  position: absolute;
  top: 12px;
  right: 18px;
  z-index: 2;
  pointer-events: none;
  animation: flagPlant 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

/* Badge element */
.summit-fire__badge {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
  animation: badgeIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
  white-space: nowrap;
  background: linear-gradient(90deg, #27b577, #5cc3dd);
  color: #fff;
  font-family: 'Lato', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(39, 181, 119, 0.35);
}


/* ─────────────────────────────────────────────────────────────────────────────
   C. TOAST OVERLAY
   A pill-shaped notification anchored to the bottom centre of the viewport.

   HTML: <div class="dash-toast" id="dashToast">
           <span class="dash-toast__icon">…svg…</span>
           <span class="dash-toast__label">Upload received</span>
           <span class="dash-toast__sub">filename.csv</span>
           <span class="dash-toast__tag">+1 upload</span>
         </div>

   JS (DashAnim.showToast) adds .toast--in to show, then swaps to .toast--out.
   The toast is created automatically by showToast if #dashToast is absent.
───────────────────────────────────────────────────────────────────────────── */

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.94); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1);    }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1);    }
  to   { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.96); }
}

/* Journey milestone toast (#dashToast) — JS-driven; Blazor uses .dash-scope .dash-toast in dash-components.css */
#dashToast.dash-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 9000;
  pointer-events: none;
  opacity: 0;

  display: flex;
  align-items: center;
  gap: 12px;

  background: var(--color-card-bg);
  border: 0.5px solid rgba(39, 181, 119, 0.30);
  border-radius: 40px;
  padding: 12px 22px 12px 16px;
  box-shadow:
    0 8px 32px rgba(39, 181, 119, 0.18),
    0 2px 8px  rgba(0, 0, 0, 0.06);

  font-family: 'Lato', sans-serif;
  white-space: nowrap;
}

/* Dark mode support */
[data-theme="dark"] #dashToast.dash-toast {
  background: #0f2a3f;
  border-color: rgba(39, 181, 119, 0.25);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px  rgba(0, 0, 0, 0.3);
}

#dashToast .dash-toast__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(39, 181, 119, 0.12);
  color: #1d9466;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#dashToast .dash-toast__label {
  font-size: 13px;
  font-weight: 700;
  color: #0d2d45;
}
[data-theme="dark"] #dashToast .dash-toast__label { color: #e4f0f8; }

#dashToast .dash-toast__sub {
  font-size: 12px;
  color: #4a7a95;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] #dashToast .dash-toast__sub { color: #7ab0cc; }

#dashToast .dash-toast__tag {
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(39, 181, 119, 0.12);
  color: #1d9466;
  padding: 2px 9px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* State classes — applied by JS */
#dashToast.dash-toast.toast--in {
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: all;
}

#dashToast.dash-toast.toast--out {
  animation: toastOut 0.35s ease-in forwards;
  pointer-events: none;
}


/* ─────────────────────────────────────────────────────────────────────────────
   D. CINEMATIC OVERLAY
   Full-viewport overlay for stage-completion moments (cinematic pause).

   Production host: DashCinematicOverlay.razor (+ scoped CSS).
   Open/close: .cinematic--open / .cinematic--closing (z-index 10100).
   Trigger: DashCinematicOverlayService.Show(...) from Blazor; particles via
   DashAnim.spawnCinematicParticles. Gallery demo still uses #cinematicOverlay.
───────────────────────────────────────────────────────────────────────────── */

.dash-cinematic {
  position: fixed;
  inset: 0;
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.dash-cinematic.cinematic--open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.dash-cinematic.cinematic--closing {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Decorative layers must stay out of the flex flow or the card drifts off-centre. */
.dash-cinematic__backdrop,
.dash-cinematic__canvas,
.dash-cinematic__landscape,
.dash-cinematic__sun,
.dash-cinematic__flag {
  position: absolute;
  pointer-events: none;
}

.dash-cinematic__backdrop {
  inset: 0;
  background: rgba(5, 18, 40, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: all;
}

.dash-cinematic__canvas {
  inset: 0;
  width: 100%;
  height: 100%;
}

.dash-cinematic__landscape {
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 260px;
}

.dash-cinematic__sun {
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 200, 66, 0.55) 0%, rgba(245, 180, 40, 0.20) 35%, rgba(245, 180, 40, 0) 70%);
}

.dash-cinematic__flag {
  bottom: 178px;
  left: 50%;
  transform: translateX(-50%);
}

/* White readable card — centred as the only flex item in the overlay. */
.dash-cinematic__content {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: min(520px, calc(100vw - 2.5rem));
  margin: 0;
  padding: 44px 48px 40px;
  text-align: center;
  background: #fff;
  border: none;
  border-radius: 24px;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(39, 181, 119, 0.30);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: all;
}

.dash-cinematic__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, #27b577, #5cc3dd);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 8px rgba(39, 181, 119, 0.12), 0 0 0 16px rgba(39, 181, 119, 0.06);
}

.dash-cinematic__eyebrow {
  font-family: 'Montserrat', 'Lato', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #1a8a55;
  margin-bottom: 8px;
}

.dash-cinematic__heading {
  font-family: 'Montserrat', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: #0d2d45;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.dash-cinematic__sub {
  font-family: 'Lato', sans-serif;
  font-size: 15px;
  color: #3d5f73;
  line-height: 1.65;
  max-width: 380px;
  margin: 0 auto 24px;
}

.dash-cinematic__pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.dash-cinematic__pill-sep {
  color: #8aacbf;
  font-size: 12px;
}

.dash-cinematic__pill {
  padding: 5px 14px;
  border-radius: 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.dash-cinematic__pill--done {
  background: rgba(39, 181, 119, 0.12);
  border: 1px solid rgba(39, 181, 119, 0.28);
  color: #1a8a55;
}

.dash-cinematic__pill--active {
  background: rgba(16, 120, 190, 0.10);
  border: 1px solid rgba(16, 120, 190, 0.22);
  color: #1078be;
}

.dash-cinematic__pill--todo {
  background: rgba(16, 120, 190, 0.04);
  border: 1px solid rgba(16, 120, 190, 0.10);
  font-weight: 400;
  color: #8aacbf;
}

/* Step dots (gallery / legacy markup) */
.dash-cinematic__stages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.dash-cinematic__stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(16, 120, 190, 0.22);
  transition: background 0.3s;
}

.dash-cinematic__stage-dot--done {
  background: #27b577;
}

.dash-cinematic__stage-dot--active {
  background: #1078be;
  width: 24px;
  border-radius: 4px;
}

.dash-cinematic__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 32px;
  border-radius: 22px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #1078be, #27b577);
  color: #fff;
  font-family: 'Montserrat', 'Lato', sans-serif;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(16, 120, 190, 0.25);
  transition: opacity 0.15s, transform 0.15s;
}

.dash-cinematic__cta:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.dash-cinematic__cta:focus-visible {
  outline: 2px solid #1078be;
  outline-offset: 3px;
}

@keyframes cinematicCardIn {
  0%   { opacity: 0; transform: translateY(24px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.dash-cinematic.cinematic--open .dash-cinematic__content {
  animation: cinematicCardIn 0.5s cubic-bezier(0.34, 1.2, 0.64, 1) 0.1s both;
}

@media (prefers-reduced-motion: reduce) {
  .dash-cinematic,
  .dash-cinematic.cinematic--open .dash-cinematic__content {
    transition: none !important;
    animation: none !important;
  }
}
