/* =====================================================================
   Tecniaero · Animaciones puntuales
   Solo dos momentos: la entrada del hero y el avance de las etapas del
   proceso. El resto de la página no se anima al bajar.
   Los estados ocultos solo existen bajo html.motion (lo pone <head> si el
   visitante no pidió reducir movimiento). Sin JS, todo se ve normal.
   ===================================================================== */

:root {
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ---------- Hero: las palabras del título suben desde una máscara ---------- */
.w {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    /* Margen para que no se corten acentos ni descendentes */
    padding: 0.08em 0 0.1em;
    margin: -0.08em 0 -0.1em;
}

.w > span {
    display: inline-block;
}

.motion .hero__title {
    animation: none;
}

.motion .hero__title .w > span {
    transform: translateY(110%);
    transition: transform 1100ms var(--ease-out);
    transition-delay: calc(250ms + var(--i, 0) * 70ms);
}

.motion .hero__title.is-in .w > span {
    transform: none;
}

/* Si el script no llegara a correr, el título aparece igual */
.motion .hero__title:not(.is-split) {
    animation: aparecer-tarde 0s 1.5s both;
    opacity: 0;
}

@keyframes aparecer-tarde {
    to { opacity: 1; }
}

/* ---------- Proceso: la línea avanza etapa por etapa ---------- */
.steps.has-progress .steps__fill {
    transition: none;
    background: var(--naranja);
}

.steps.has-progress .steps__line {
    background: rgba(22, 32, 42, 0.14);
}

/* Etapas pendientes: atenuadas */
.steps.has-progress .step .step__dot {
    background: var(--niebla);
    color: var(--gris);
    transition: background 450ms ease, color 450ms ease, border-color 450ms ease, box-shadow 450ms ease;
}

.steps.has-progress .step :is(.step__title, .step__text) {
    opacity: 0.35;
    transition: opacity 600ms ease;
}

/* Etapa alcanzada: se enciende */
.steps.has-progress .step.is-active .step__dot {
    background: var(--naranja);
    border-color: var(--naranja);
    color: var(--asfalto);
    box-shadow: 0 0 0 6px rgba(255, 90, 31, 0.18);
}

.steps.has-progress .step.is-active :is(.step__title, .step__text) {
    opacity: 1;
}

/* Indicador de porcentaje que viaja con la punta de la línea */
.steps__chip {
    position: absolute;
    z-index: 2;
    transform: translate(-50%, calc(-100% - 34px));
    padding: 4px 9px;
    background: var(--asfalto);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    border-radius: 2px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease;
}

.steps__chip::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--asfalto);
}

.steps.is-running .steps__chip {
    opacity: 1;
}

/* Al terminar, el indicador queda en 100% sobre la última etapa */
.steps.is-done .steps__chip {
    background: var(--naranja);
    color: var(--asfalto);
}

.steps.is-done .steps__chip::after {
    border-top-color: var(--naranja);
}

/* En móvil la línea es vertical y no hay lugar para el indicador flotante:
   el porcentaje aparece junto al número de cada etapa al encenderse */
@media (max-width: 880px) {
    .steps__chip {
        display: none;
    }

    .steps.has-progress .step__num::after {
        content: attr(data-pct);
        margin-left: 10px;
        padding: 2px 7px;
        background: var(--naranja);
        color: var(--asfalto);
        border-radius: 2px;
        letter-spacing: 0;
        opacity: 0;
        transition: opacity 400ms ease;
    }

    .steps.has-progress .step.is-active .step__num::after {
        opacity: 1;
    }
}

/* ---------- Botones: relleno que barre al pasar el mouse ---------- */
.btn--orange,
.btn--ghost {
    background-image: linear-gradient(#ffffff, #ffffff);
    background-repeat: no-repeat;
    background-position: left center;
    background-size: 0% 100%;
    transition: background-size 450ms var(--ease-io), color 300ms ease, border-color 300ms ease;
}

.btn--orange:hover,
.btn--ghost:hover,
.btn--orange:focus-visible,
.btn--ghost:focus-visible {
    background-size: 100% 100%;
    color: var(--asfalto);
}

.btn--ghost:hover {
    border-color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
    .btn--orange,
    .btn--ghost {
        transition: none;
    }
}

/* Al imprimir, todo visible */
@media print {
    .motion * {
        opacity: 1 !important;
        transform: none !important;
        clip-path: none !important;
    }
}

/* ---------- Manga de los títulos: se infla al aparecer y flamea con el viento ---------- */
.section__header {
    position: relative;
}

/* Mástil */
.section__header::after {
    content: "";
    position: absolute;
    left: 0;
    top: -5px;
    width: 4px;
    height: 52px;
    background: var(--asfalto);
}

.section__header::before {
    margin-left: 4px;
    margin-bottom: 14px;
    transform-origin: left center;
}

.motion .section__header::before {
    scale: 0 1;
}

.motion .section__header.is-in::before {
    animation:
        manga-inflar 900ms steps(5, jump-start) 150ms both,
        manga-flamear 2.8s ease-in-out 1050ms infinite;
}

@keyframes manga-inflar {
    from { scale: 0 1; }
    to { scale: 1 1; }
}

/* La punta sube y baja, el cuerpo ondula y la manga gira apenas sobre el mástil */
@keyframes manga-flamear {
    0%, 100% {
        clip-path: polygon(0 0, 50% 11%, 100% 22%, 100% 78%, 50% 89%, 0 100%);
        rotate: 0deg;
        scale: 1 1;
    }
    25% {
        clip-path: polygon(0 0, 50% 4%, 100% 8%, 100% 66%, 50% 84%, 0 100%);
        rotate: -3deg;
        scale: 0.96 1;
    }
    50% {
        clip-path: polygon(0 0, 50% 14%, 100% 26%, 100% 82%, 50% 92%, 0 100%);
        rotate: 1deg;
        scale: 1 1;
    }
    75% {
        clip-path: polygon(0 0, 50% 9%, 100% 30%, 100% 90%, 50% 95%, 0 100%);
        rotate: 3deg;
        scale: 0.93 1;
    }
}

/* Bandera: aparece al terminar el título, el sol gira y cada tanto le pasa un brillo */
.motion .hero__title .hero__flag {
    opacity: 0;
    transition: opacity 600ms ease 900ms;
}

.motion .hero__title.is-in .hero__flag {
    opacity: 1;
}

.motion .hero__sun {
    animation: sol-girar 6s linear infinite;
}

@keyframes sol-girar {
    to { rotate: 360deg; }
}

.motion .hero__flag::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%);
    transform: translateX(-120%);
    animation: bandera-brillo 4.5s ease-in-out 2s infinite;
    pointer-events: none;
}

@keyframes bandera-brillo {
    0% { transform: translateX(-120%); }
    30%, 100% { transform: translateX(120%); }
}
