/* =============================================================
   PROJECT PAGE — SHARED ANIMATION LAYER
   Subtle, luxury-grade scroll & entrance animations.
   One-way reveals only — elements appear as you scroll to them.
   ============================================================= */

/* -----------------------------------------------------------
   LENIS SMOOTH SCROLL — compatibility rules
   Lenis requires scroll-behavior: auto to avoid conflicts.
   ----------------------------------------------------------- */
html.lenis,
html.lenis body {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

/* -----------------------------------------------------------
   0. SCROLL PROGRESS BAR
   ----------------------------------------------------------- */
.cs-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, var(--color-burgundy) 0%, var(--color-gold) 100%);
    z-index: 9999;
    transition: width 0.1s linear;
    pointer-events: none;
}


/* -----------------------------------------------------------
   1. PAGE ENTRANCE
   ----------------------------------------------------------- */
body {
    animation: cs-body-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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


/* -----------------------------------------------------------
   2. HERO ENTRANCE — staggered headline + desc + tags
   ----------------------------------------------------------- */
.cs-hero h1 {
    opacity: 0;
    transform: translateY(30px);
    animation: cs-slide-up 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

.cs-hero .cs-hero-desc {
    opacity: 0;
    transform: translateY(20px);
    animation: cs-slide-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}

.cs-hero .cs-roles {
    opacity: 0;
    transform: translateY(15px);
    animation: cs-slide-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.55s both;
}

@keyframes cs-slide-up {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* -----------------------------------------------------------
   3. SCROLL REVEALS — one-way, fire once
   ----------------------------------------------------------- */

/* Default */
[data-reveal] {
    opacity: 0;
    transform: translateY(30px);
    transition:
        opacity  0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal].is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Heading */
[data-reveal="heading"] {
    opacity: 0;
    transform: translateY(22px);
    transition:
        opacity  0.9s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal="heading"].is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Text */
[data-reveal="text"] {
    opacity: 0;
    transform: translateY(16px);
    transition:
        opacity  0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal="text"].is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Image Wipe Reveal */
[data-reveal="image"],
[data-reveal-group] .cs-img {
    opacity: 0;
    clip-path: inset(100% 0 0 0); /* Start hidden at bottom */
    transform: translateY(20px);
    transition:
        opacity 0.4s ease,
        transform 1.1s cubic-bezier(0.16, 1, 0.3, 1),
        clip-path 1.1s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: clip-path, transform, opacity;
}

.cs-parallax-wrap[data-reveal="image"].is-visible img {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    transform: translateY(0);
}

[data-reveal="image"].is-visible,
[data-reveal-group].is-visible .cs-img {
    opacity: 1;
    clip-path: inset(0 0 0 0); /* Wipe open to full height */
    transform: translateY(0);
}

/* Ensure stagger delays still apply to the wipe */
[data-reveal-group].is-visible > *:nth-child(1) .cs-img { transition-delay: 0.05s; }
[data-reveal-group].is-visible > *:nth-child(2) .cs-img { transition-delay: 0.15s; }
[data-reveal-group].is-visible > *:nth-child(3) .cs-img { transition-delay: 0.25s; }
[data-reveal-group].is-visible > *:nth-child(4) .cs-img { transition-delay: 0.35s; }
[data-reveal-group].is-visible > *:nth-child(5) .cs-img { transition-delay: 0.45s; }
[data-reveal-group].is-visible > *:nth-child(6) .cs-img { transition-delay: 0.55s; }


/* Stagger groups */
[data-reveal-group] > * {
    opacity: 0;
    transform: translateY(28px);
    transition:
        opacity  0.65s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-reveal-group].is-visible > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: translateY(0); }
[data-reveal-group].is-visible > *:nth-child(2) { transition-delay: 0.15s; opacity: 1; transform: translateY(0); }
[data-reveal-group].is-visible > *:nth-child(3) { transition-delay: 0.25s; opacity: 1; transform: translateY(0); }
[data-reveal-group].is-visible > *:nth-child(4) { transition-delay: 0.35s; opacity: 1; transform: translateY(0); }
[data-reveal-group].is-visible > *:nth-child(5) { transition-delay: 0.45s; opacity: 1; transform: translateY(0); }
[data-reveal-group].is-visible > *:nth-child(6) { transition-delay: 0.55s; opacity: 1; transform: translateY(0); }


/* -----------------------------------------------------------
   4. SECTION HEADING — gold underline draws in on scroll
   ----------------------------------------------------------- */
.cs-section h2 {
    position: relative;
    display: inline-block;
}

.cs-section h2::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    height: 1px;
    width: 0;
    background: var(--color-gold);
    transition: width 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.2s;
}

.cs-section.in-view h2::after {
    width: 100%;
}


/* -----------------------------------------------------------
   5. SECTION ORDINAL COUNTER
   ----------------------------------------------------------- */
main {
    counter-reset: cs-section-counter;
}

.cs-section:not(.cs-hero) {
    counter-increment: cs-section-counter;
    position: relative;
}

.cs-section:not(.cs-hero) .cs-container::before {
    content: counter(cs-section-counter, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 0;
    font-family: var(--font-body);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--color-gold);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.6s ease 0.4s, transform 0.6s ease 0.4s;
    pointer-events: none;
}

.cs-section.in-view .cs-container::before {
    opacity: 0.45;
    transform: translateY(0);
}


/* -----------------------------------------------------------
   6. CLOSING STATEMENT
   ----------------------------------------------------------- */
.cs-closing p {
    opacity: 0;
    transform: translateY(20px);
    transition:
        opacity  1.1s cubic-bezier(0.16, 1, 0.3, 1),
        transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
}

.cs-section.in-view .cs-closing p {
    opacity: 1;
    transform: translateY(0);
}


/* -----------------------------------------------------------
   7. IMAGE HOVER & PARALLAX
   ----------------------------------------------------------- */
.cs-parallax-wrap {
    will-change: transform;
    display: block;
    width: 100%;
}

.cs-img {
    will-change: transform, clip-path;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
    min-height: 200px; /* Layout stability: ensure images have area for the observer even before loading */
    background-color: rgba(0,0,0,0.02); /* Subtle placeholder */
}

.cs-img:hover,
.cs-section .cs-img:hover,
[data-reveal-group] .cs-img:hover,
[data-reveal] .cs-img:hover {
    transform: scale(1.03) translateY(-4px) !important;
}


/* -----------------------------------------------------------
   8. MERCH SECTION — equal-size containers
   ----------------------------------------------------------- */
.cs-merch-wrap {
    width: 100%;
    height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cs-merch-wrap .cs-img {
    width: 100%;
    height: 100%;
    aspect-ratio: unset;
    object-fit: contain;
}


/* -----------------------------------------------------------
   9. ROLE TAG STAGGER (hero)
   ----------------------------------------------------------- */
.cs-role-tag {
    opacity: 0;
    transform: translateY(10px);
    animation: cs-tag-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cs-role-tag:nth-child(1) { animation-delay: 0.65s; }
.cs-role-tag:nth-child(2) { animation-delay: 0.75s; }
.cs-role-tag:nth-child(3) { animation-delay: 0.85s; }
.cs-role-tag:nth-child(4) { animation-delay: 0.95s; }

@keyframes cs-tag-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* -----------------------------------------------------------
   10. REDUCE MOTION
   ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    [data-reveal],
    [data-reveal="image"],
    [data-reveal="heading"],
    [data-reveal="text"],
    [data-reveal-group] > * {
        opacity: 1 !important;
        transform: none !important;
    }
}
