/* ============================================
   EL SANTO DISCO — animations.css
   Animaciones premium: typing, parallax,
   clip-path dividers, 3D tilt + gyro, split titles
   Mobile-first. Optimizado 99% mobile.
   ============================================ */


/* ============================================
   1. TYPING / REVEAL DE "UN VICIO"
   ============================================ */
.split-chars .sc {
    display: inline-block;
    opacity: 0;
    filter: blur(10px);
    transform: translateY(14px);
    transition:
        opacity .75s var(--ease),
        filter .75s var(--ease),
        transform .75s var(--ease);
    transition-delay: calc(var(--sc-i, 0) * 75ms + 500ms);
    will-change: opacity, filter, transform;
}

.split-chars.on .sc {
    opacity: 1;
    filter: blur(0);
    transform: none;
}

/* El reveal original del parent .hero-sub movía translateY del bloque entero.
   Lo anulamos cuando hacemos split para que sólo se animen los caracteres. */
.hero-sub.split-chars.reveal { transform: none; }


/* ============================================
   2. PARALLAX EN SCROLL
   ============================================ */
[data-parallax] {
    will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
    [data-parallax] {
        transform: none !important;
    }
}


/* ============================================
   3. DIVISORES ENTRE SECCIONES (CLIP-PATH)
   ============================================ */
.sec-divider {
    position: relative;
    height: 60px;
    overflow: hidden;
    pointer-events: none;
    background: transparent;
    margin: 0;
}

@media (max-width: 720px) {
    .sec-divider { height: 44px; }
}

.sec-divider-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(232, 0, 58, .45) 25%,
        rgba(201, 168, 76, .8) 50%,
        rgba(232, 0, 58, .45) 75%,
        transparent 100%
    );
    /* empieza cerrada desde el centro */
    clip-path: polygon(50% 0, 50% 0, 50% 100%, 50% 100%);
    transition: clip-path 1.1s cubic-bezier(.77, 0, .18, 1);
    box-shadow: 0 0 10px rgba(232, 0, 58, .35);
    transform: translateY(-.5px);
}

.sec-divider-gem {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, var(--red), var(--gold));
    transform: translate(-50%, -50%) rotate(45deg) scale(0);
    transition: transform .55s cubic-bezier(.34, 1.56, .64, 1) .55s;
    box-shadow: 0 0 14px rgba(232, 0, 58, .5);
    border-radius: 2px;
}

.sec-divider.in-view .sec-divider-line {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.sec-divider.in-view .sec-divider-gem {
    transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

/* Ajustes finos: reducir padding superior de secciones precedidas por divider */
.sec-divider + .section { padding-top: calc(var(--pad) - 1rem); }


/* ============================================
   4. HOVER 3D / TILT + GIROSCOPIO MOBILE
   ============================================ */
.tilt-3d {
    /* Combina tilt de mouse (desktop) + gyro (mobile) */
    transform:
        perspective(900px)
        rotateX(calc(var(--tilt-x, 0deg) + var(--gyro-x, 0deg)))
        rotateY(calc(var(--tilt-y, 0deg) + var(--gyro-y, 0deg)))
        translate3d(0, 0, 0);
    transition: transform .4s var(--ease);
    transform-style: preserve-3d;
    will-change: transform;
}

/* Desktop: responde rápido al mouse */
@media (hover: hover) and (pointer: fine) {
    .tilt-3d:hover {
        transition: transform .08s linear;
    }
}

/* Mobile: transición más suave para el gyro */
@media (hover: none) {
    .tilt-3d {
        transition: transform .6s cubic-bezier(.22, 1, .36, 1);
    }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .tilt-3d {
        transform: none !important;
    }
}

/* Banner para pedir permiso de giroscopio en iOS 13+ */
.gyro-banner {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%) translateY(40px);
    padding: .7rem .8rem .7rem 1.1rem;
    background: rgba(12, 12, 20, .92);
    border: 1px solid rgba(232, 0, 58, .45);
    border-radius: 999px;
    font-family: var(--font);
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
    z-index: 9998;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    pointer-events: none;
    transition:
        opacity .35s var(--ease),
        transform .4s var(--ease);
    display: flex;
    align-items: center;
    gap: .6rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 20px rgba(232, 0, 58, .15);
    max-width: calc(100vw - 2rem);
}

.gyro-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.gyro-banner-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--gold);
}

.gyro-banner-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gyro-banner button {
    background: linear-gradient(135deg, var(--red), #C9002E);
    color: #fff;
    border: none;
    padding: .38rem .9rem;
    border-radius: 999px;
    font-family: var(--font);
    font-weight: 800;
    font-size: .72rem;
    letter-spacing: .5px;
    text-transform: uppercase;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .2s var(--ease);
}

.gyro-banner button:active {
    transform: scale(.94);
}

.gyro-banner-close {
    background: transparent !important;
    color: var(--muted) !important;
    padding: .2rem .4rem !important;
    font-size: 1rem !important;
    line-height: 1 !important;
}


/* ============================================
   5. TÍTULOS QUE SE DIVIDEN EN SCROLL
   ============================================ */
.split-words {
    /* Evita que el reveal del parent aplique translateY al bloque entero */
    transform: none !important;
}

.split-words .sw {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    /* padding-bottom para que descendientes (g, p, etc) no queden recortados */
    padding-bottom: .08em;
    line-height: inherit;
}

.split-words .sw-i {
    display: inline-block;
    transform: translateY(110%) rotate(6deg);
    transition: transform .85s cubic-bezier(.22, 1, .36, 1);
    transition-delay: calc(var(--sw-i, 0) * 90ms + 150ms);
    will-change: transform;
    line-height: inherit;
}

/* Cuando entra al viewport (clase .on del reveal observer) anima */
.split-words.on .sw-i {
    transform: translateY(0) rotate(0deg);
}

/* Preserva el gradient de .grad dentro de los títulos */
.split-words .grad {
    display: inline-block;
}

/* En mobile, efecto más sutil para no marear */
@media (max-width: 720px) {
    .split-words .sw-i {
        transform: translateY(105%) rotate(3deg);
        transition-delay: calc(var(--sw-i, 0) * 65ms + 100ms);
    }
}

@media (prefers-reduced-motion: reduce) {
    .split-words .sw-i {
        transform: none !important;
        transition: none !important;
    }
    .split-chars .sc {
        opacity: 1 !important;
        filter: none !important;
        transform: none !important;
    }
    .sec-divider-line,
    .sec-divider-gem {
        transition: none !important;
    }
}
