/* ═══════════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   Cinematic slide + fade between pages.
   The .container > .card (the whole card) is the transition target.
   ═══════════════════════════════════════════════════════════════ */


/* ─── Progress bar ────────────────────────────────────────────── */

.la-transit-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  z-index: 9999;
  background: linear-gradient(
    90deg,
    var(--la-accent-teal) 0%,
    #7dd4f0 40%,
    var(--la-accent-teal) 100%
  );
  background-size: 200% 100%;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px rgba(46, 160, 200, 0.5),
              0 0 4px rgba(46, 160, 200, 0.3);
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
  pointer-events: none;
  transition: none;
}

.la-transit-progress.is-loading {
  opacity: 1;
  animation: la-progress-fill 1.8s cubic-bezier(0.22, 0.68, 0, 1) forwards,
             la-progress-shimmer 1.2s linear infinite;
}

.la-transit-progress.is-done {
  transform: scaleX(1) !important;
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.35s 0.15s ease;
}

@keyframes la-progress-fill {
  0%   { transform: scaleX(0); }
  100% { transform: scaleX(0.85); }
}

@keyframes la-progress-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ─── Hide content before JS enter-animation kicks in ─────────── */
/* The blocking <script> in <head> adds this class to <html> when
   a transition is in progress, preventing a flash of the final state
   before the enter animation starts.                                */

.la-transit-incoming .wrap > .container > .card,
.la-transit-incoming .wrap > .jumbotron .container {
  opacity: 0;
  /* Fallback: if JS fails to remove la-transit-incoming, reveal after 1.5 s */
  animation: la-transit-fallback-reveal 0.01s 1.5s ease forwards;
}

@keyframes la-transit-fallback-reveal {
  to { opacity: 1; }
}


/* ─── Content wrapper — always present for transition ─────────── */

.la-transit-content {
  will-change: transform, opacity;
}


/* ─── Leave (old content sliding out) ─────────────────────────── */

.la-transit-leave-active {
  animation: la-slide-out 0.32s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes la-slide-out {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-60px) scale(0.98);
    filter: blur(2px);
  }
}


/* ─── Enter (new content sliding in) ──────────────────────────── */

.la-transit-enter-active {
  animation: la-slide-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes la-slide-in {
  0% {
    opacity: 0;
    transform: translateX(50px) scale(0.98);
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
}


/* ─── Back navigation — reverse direction ─────────────────────── */

.la-transit-back .la-transit-leave-active {
  animation-name: la-slide-out-right;
}

.la-transit-back .la-transit-enter-active {
  animation-name: la-slide-in-left;
}

@keyframes la-slide-out-right {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: translateX(60px) scale(0.98);
    filter: blur(2px);
  }
}

@keyframes la-slide-in-left {
  0% {
    opacity: 0;
    transform: translateX(-50px) scale(0.98);
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
}


/* ─── Jumbotron header crossfade ──────────────────────────────── */

.jumbotron .la-transit-leave-active {
  animation: la-fade-out 0.25s ease forwards;
}

.jumbotron .la-transit-enter-active {
  animation: la-fade-in 0.3s 0.08s ease both;
}

@keyframes la-fade-out {
  to { opacity: 0; transform: translateY(-6px); }
}

@keyframes la-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ─── Dashboard staggered entrance ────────────────────────────── */
/* When the dashboard (.la-quicknav is present) is the transition
   target, skip the whole-card slide and instead stagger each child
   element individually.                                            */

/* Hide dashboard items before stagger plays — both on transition
   and on cold page load (the view adds .la-stagger-init)          */

.la-transit-incoming .la-intro,
.la-transit-incoming .la-quicknav__card,
.la-stagger-init .la-intro,
.la-stagger-init .la-quicknav__card {
  opacity: 0;
}

.la-transit-stagger .la-intro {
  animation: la-stagger-intro 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.la-transit-stagger .la-quicknav__card {
  animation: la-stagger-card 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.la-transit-stagger .la-quicknav__card:nth-child(1) { animation-delay: 0.08s; }
.la-transit-stagger .la-quicknav__card:nth-child(2) { animation-delay: 0.16s; }
.la-transit-stagger .la-quicknav__card:nth-child(3) { animation-delay: 0.24s; }
.la-transit-stagger .la-quicknav__card:nth-child(4) { animation-delay: 0.32s; }
.la-transit-stagger .la-quicknav__card:nth-child(5) { animation-delay: 0.40s; }
.la-transit-stagger .la-quicknav__card:nth-child(6) { animation-delay: 0.48s; }

@keyframes la-stagger-intro {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes la-stagger-card {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ─── Reduce motion for accessibility ─────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .la-transit-leave-active,
  .la-transit-enter-active,
  .jumbotron .la-transit-leave-active,
  .jumbotron .la-transit-enter-active {
    animation-duration: 0.01ms !important;
  }

  .la-transit-progress.is-loading {
    animation-duration: 0.01ms !important;
  }
}
