/**
 * Animations.css
 * Todas as animações e transições do site
 * Respeita preferência de movimento reduzido (prefers-reduced-motion)
 */

/* === ANIMAÇÕES GERAIS === */

@media (prefers-reduced-motion: no-preference) {
    /* Scroll suave */
    html {
        scroll-behavior: smooth;
    }

    /* Animação de entrada do título do hero */
    .hero h1 span {
        animation: title-in .6s ease-out both;
    }

    .hero h1 span:nth-child(2) {
        animation-delay: .09s;
    }

    .hero h1 span:nth-child(3) {
        animation-delay: .18s;
    }

    @keyframes title-in {
        from {
            opacity: 0;
            transform: translateY(.28em);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Animação de entrada dos cards do Salom Finance */
    .sf-mini.sf-in-view > :not(.sf-confetti) {
        animation: sf-card-in .43s ease-out both;
    }

    @keyframes sf-card-in {
        from {
            opacity: .58;
            transform: translateY(.4rem);
        }
    }
}

/* === SCROLL-BASED ANIMATIONS (Desktop) === */

@media (min-width: 53rem) and (min-height: 38rem) and (prefers-reduced-motion: no-preference) {
    /* Layout de scroll para projetos */
    .scroll-ready .story {
        display: grid;
        grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
        gap: clamp(2rem, 5vw, 5rem);
    }

    .scroll-ready .steps {
        gap: 0;
    }

    .scroll-ready .step {
        display: grid;
        align-content: center;
        min-height: clamp(17rem, 43svh, 26rem);
    }

    .scroll-ready .step:first-child {
        min-height: clamp(7rem, 15svh, 10rem);
    }

    /* Destaque do step atual */
    .scroll-ready .step[aria-current="step"] {
        border-top-color: var(--accent);
    }

    .scroll-ready .step[aria-current="step"] h3 {
        color: var(--accent);
    }

    /* Esconde mini stages em desktop */
    .scroll-ready .step-stage {
        display: none;
    }

    /* Stage fixo durante o scroll */
    .scroll-ready .sticky-stage {
        display: block;
        grid-column: 2;
        grid-row: 1;
        position: sticky;
        top: max(calc(var(--header-height, calc(var(--header) + var(--safe-top))) + 1rem), calc(50svh - 8rem));
        align-self: start;
        margin: 0;
    }

    .sticky-stage svg {
        max-height: calc(50svh + 3rem);
    }
}

/* Transições de links */

a,
nav a {
    transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}

/* Hero rain */

.hero-backdrop {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.hero-backdrop > .hero {
    position: relative;
    z-index: 2;
}

.hero-rain {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0%, #000 55%, transparent 100%);
}

@media (prefers-color-scheme: dark) {
    .hero-backdrop::before,
    .hero-backdrop::after {
        position: absolute;
        inset: 0;
        pointer-events: none;
        content: "";
    }

    .hero-backdrop::before {
        background:
            radial-gradient(ellipse at 0% 25%, color-mix(in srgb, var(--mint) 2.5%, transparent), transparent 62%),
            radial-gradient(ellipse at 100% 16%, color-mix(in srgb, var(--mint) 2.5%, transparent), transparent 52%),
            radial-gradient(ellipse at 30% 47%, color-mix(in srgb, var(--mint) 2%, transparent), transparent 53%);
    }

    .hero-backdrop::after {
        opacity: .03;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='144' height='144'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    }
}
