/* ═══════════════════════════════════════════════════════════════
   module-page.css: shared motion and section index for the module
   pages (fieldreporting, siteanalysis, firemonitoring, speciesintel,
   forestmonitoring, aviation, raptors). Paired with js/module-page.js.

   - Hero: plays once on load, pure CSS (no JS needed to see it).
   - Stats, cards and statement-stack sections: play once, the first
     time each section scrolls into view. module-page.js adds .mp-js to
     <html> (so a page without JS shows everything at rest) and .mp-in
     to a section when it enters. Until then each animation sits
     paused on its first frame.
   - Every entrance uses fill-mode "backwards" only, so once it ends the
     element falls back to its own styles (no clip-path or transform
     left behind to fight hover or layout rules).
   - tac-flicker is defined inline by each module page (same keyframes
     as public/css/animations.css).
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* house ease, same curve as --ease in variables.css */
    --mp-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --mp-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

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

@keyframes mp-fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Title rises out of its own baseline. */
@keyframes mp-rise {
    from { opacity: 0; transform: translateY(0.3em); clip-path: inset(100% -5% -20% -5%); }
    to   { opacity: 1; transform: translateY(0);     clip-path: inset(-20% -5% -20% -5%); }
}

/* Hero photo opens top to bottom like a shutter. */
@keyframes mp-shutter {
    from { clip-path: inset(0 0 100% 0); }
    to   { clip-path: inset(0 0 0 0); }
}

@keyframes mp-pop {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Hero (on load) ─────────────────────────────────────────── */
.s-hero .hero-upper          { animation: mp-shutter 1.1s var(--mp-ease-in-out) backwards; }
.s-hero .hero-upper::after   { animation: mp-fade 1.2s var(--mp-ease-out) 0.6s backwards; }
.s-hero .hero-eyebrow        { animation: tac-flicker 0.6s var(--mp-ease-out) 0.25s backwards; }
.s-hero .hero-title          { animation: mp-rise 0.9s var(--mp-ease-out) 0.35s backwards; }
.s-hero .hero-dot            { animation: mp-pop 0.5s var(--mp-ease-out) 0.7s backwards; }
.s-hero .hero-desc           { animation: mp-fade-up 0.8s var(--mp-ease-out) 0.75s backwards; }
.s-hero .hero-footer         { animation: mp-fade 0.6s var(--mp-ease-out) 1s backwards; }

/* ── Sections (on first view) ───────────────────────────────── */
/* Stats */
.mp-js .s-stats .stats-topnav        { animation: mp-fade 0.5s var(--mp-ease-out) backwards; }
.mp-js .s-stats .stats-intro-label   { animation: tac-flicker 0.6s var(--mp-ease-out) 0.1s backwards; }
.mp-js .s-stats .stat-num            { animation: tac-flicker 0.6s var(--mp-ease-out) backwards; }
.mp-js .s-stats .stat-lbl            { animation: mp-fade-up 0.6s var(--mp-ease-out) backwards; }
.mp-js .s-stats .stats-col           { animation: mp-fade-up 0.7s var(--mp-ease-out) backwards; }
.mp-js .s-stats .stats-footnote      { animation: mp-fade 0.6s var(--mp-ease-out) 0.9s backwards; }

.mp-js .s-stats .stat-row:nth-child(1) .stat-num { animation-delay: 0.2s; }
.mp-js .s-stats .stat-row:nth-child(2) .stat-num { animation-delay: 0.32s; }
.mp-js .s-stats .stat-row:nth-child(3) .stat-num { animation-delay: 0.44s; }
.mp-js .s-stats .stat-row:nth-child(4) .stat-num { animation-delay: 0.56s; }
.mp-js .s-stats .stat-row:nth-child(1) .stat-lbl { animation-delay: 0.3s; }
.mp-js .s-stats .stat-row:nth-child(2) .stat-lbl { animation-delay: 0.42s; }
.mp-js .s-stats .stat-row:nth-child(3) .stat-lbl { animation-delay: 0.54s; }
.mp-js .s-stats .stat-row:nth-child(4) .stat-lbl { animation-delay: 0.66s; }
.mp-js .s-stats .stats-col:nth-child(1)          { animation-delay: 0.5s; }
.mp-js .s-stats .stats-col:nth-child(2)          { animation-delay: 0.6s; }

/* Cards */
.mp-js .s-cards .cards-tag      { animation: tac-flicker 0.6s var(--mp-ease-out) backwards; }
.mp-js .s-cards .cards-heading  { animation: mp-rise 0.8s var(--mp-ease-out) 0.1s backwards; }
.mp-js .s-cards .cards-arrows   { animation: mp-fade 0.6s var(--mp-ease-out) 0.4s backwards; }
.mp-js .s-cards .card           { animation: mp-fade-up 0.7s var(--mp-ease-out) backwards; }
.mp-js .s-cards .card:nth-child(1) { animation-delay: 0.2s; }
.mp-js .s-cards .card:nth-child(2) { animation-delay: 0.27s; }
.mp-js .s-cards .card:nth-child(3) { animation-delay: 0.34s; }
.mp-js .s-cards .card:nth-child(4) { animation-delay: 0.41s; }
.mp-js .s-cards .card:nth-child(5) { animation-delay: 0.48s; }

/* Statement stacks */
.mp-js .s-stack .ss-eyebrow     { animation: tac-flicker 0.6s var(--mp-ease-out) backwards; }
.mp-js .s-stack .ss-head h2     { animation: mp-rise 0.8s var(--mp-ease-out) 0.1s backwards; }
.mp-js .s-stack .ss-count       { animation: mp-fade 0.6s var(--mp-ease-out) 0.35s backwards; }
.mp-js .s-stack .ss-row         { animation: mp-fade-up 0.6s var(--mp-ease-out) backwards; }
.mp-js .s-stack .ss-row:nth-child(1) { animation-delay: 0.25s; }
.mp-js .s-stack .ss-row:nth-child(2) { animation-delay: 0.31s; }
.mp-js .s-stack .ss-row:nth-child(3) { animation-delay: 0.37s; }
.mp-js .s-stack .ss-row:nth-child(4) { animation-delay: 0.43s; }
.mp-js .s-stack .ss-row:nth-child(5) { animation-delay: 0.49s; }

/* Hold every section animation on its first frame until the section
   enters (module-page.js adds .mp-in). */
.mp-js :is(.s-stats, .s-cards, .s-stack):not(.mp-in) :is(
    .stats-topnav, .stats-intro-label, .stat-num, .stat-lbl, .stats-col, .stats-footnote,
    .cards-tag, .cards-heading, .cards-arrows, .card,
    .ss-eyebrow, .ss-head h2, .ss-count, .ss-row) {
    animation-play-state: paused;
}

/* ── Section index (stats top bar) ──────────────────────────── */
/* Real links to each section. Hidden on phones by each page's own
   mobile rules; scrolls sideways instead of wrapping if labels run long. */
.stats-topnav {
    overflow-x: auto;
    scrollbar-width: none;
}

.stats-topnav::-webkit-scrollbar {
    display: none;
}

/* Same padding on every link (the page gives only the active one a
   bottom pad for its underline, which lifted it above the rest). */
.stats-topnav a,
.stats-topnav a.t-active-bar {
    padding: 4px 0;
}

.stats-topnav a {
    color: #767676;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.stats-topnav a.t-active {
    color: #111;
}

.stats-topnav a:focus-visible {
    outline: 2px solid #111;
    outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
    .stats-topnav a:hover {
        color: #111;
    }
}

/* ── Reduced motion: opacity only, short ────────────────────── */
/* Each page's footer sets every animation to 0.01ms !important; these
   selectors are more specific, so a gentle fade survives in its place. */
@media (prefers-reduced-motion: reduce) {
    @keyframes mp-fade-up  { from { opacity: 0; } to { opacity: 1; } }
    @keyframes mp-rise     { from { opacity: 0; } to { opacity: 1; } }
    @keyframes mp-pop      { from { opacity: 0; } to { opacity: 1; } }
    @keyframes mp-shutter  { from { opacity: 0; } to { opacity: 1; } }

    .s-hero :is(.hero-upper, .hero-eyebrow, .hero-title, .hero-dot, .hero-desc, .hero-footer),
    .mp-js :is(.s-stats, .s-cards, .s-stack) :is(
        .stats-topnav, .stats-intro-label, .stat-num, .stat-lbl, .stats-col, .stats-footnote,
        .cards-tag, .cards-heading, .cards-arrows, .card,
        .ss-eyebrow, .ss-head h2, .ss-count, .ss-row) {
        animation-name: mp-fade !important;
        animation-duration: 240ms !important;
        animation-delay: 0s !important;
    }
}
