/* ── Motion library ──────────────────────────────────────────────────────
   Shared entrance animations for the whole app. Loaded globally via
   index.html, so any component's stylesheet can reference these keyframes
   and utility classes regardless of Angular view encapsulation. See
   CLAUDE.md → "Component entrance animation" for the convention. */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(1.75rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(-0.35rem);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* For edge-anchored drawers/flyout panels (e.g. a collapsible sidebar) — a horizontal
   slide, distinct from scale-in's "grow from anchor" motion used by dropdowns/popovers. */
@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Page transition ──────────────────────────────────────────────────────
   Wraps every routed page component (see app.html's <div class="page-wrap">)
   so the whole screen fades in on navigation. Opacity only, on purpose: a routed host
   element is `display: inline` unless its component says otherwise, and transforms are
   ignored on inline boxes — so the "rise" only ever appeared on some pages, and stacked
   on top of each page's own staggered rise on the rest. Pages own the rise (fade-in-up /
   stagger-fade); this layer just softens the route swap. `backwards` fill leaves no
   lingering stacking context behind once it ends. Safe on phones (no transform, so no
   containing-block change for fixed drawers). */

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(1.75rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-wrap {
  display: contents;
  padding-bottom: 5rem;
}

.page-wrap > *:not(router-outlet) {
  animation: fade-in 0.35s ease backwards;
}

/* ── Component entrance utility ─────────────────────────────────────────
   Apply `fade-in-up` to any element that should animate in on mount. Apply
   `stagger-fade` to a container whose direct children (cards, sections,
   panels — any sibling "components" on the page) should cascade in one
   after another instead of popping in all at once. Works with any element,
   any Angular component, any encapsulation mode — this is a global
   stylesheet, so the keyframe/class names are never rewritten. */

.fade-in-up {
  animation: fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stagger-fade > * {
  animation: fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stagger-fade > *:nth-child(2) { animation-delay: 0.07s; }
.stagger-fade > *:nth-child(3) { animation-delay: 0.14s; }
.stagger-fade > *:nth-child(4) { animation-delay: 0.21s; }
.stagger-fade > *:nth-child(5) { animation-delay: 0.28s; }
.stagger-fade > *:nth-child(6) { animation-delay: 0.35s; }
.stagger-fade > *:nth-child(7) { animation-delay: 0.42s; }
.stagger-fade > *:nth-child(n+8) { animation-delay: 0.49s; }

/* Set by ShareDocument while it snapshots a print page into a PDF: the snapshot copies each
   element's styles, and a copied entrance animation would replay from opacity 0 (blank PDF). */
.share-capture,
.share-capture * {
  animation: none !important;
  transition: none !important;
}
