/**
 * ============================================================================
 * RELATANDO.COM - MODULE PREMIUM UX
 * ----------------------------------------------------------------------------
 * 1. Fuego Fatuo Cursor & Estela Espectral (Ghosting / Trail 1.0s - 1.2s)
 * 2. Text Reveal (Cinematic typography reveal synced with Intro Overlay)
 * ============================================================================
 */

/* ============================================================================
   1. FUEGO FATUO & SPECTRAL TRAIL CURSOR (AWWWARDS NOIR EDITION)
   ============================================================================ */

/* Ocultar puntero nativo solo en dispositivos con ratón de precisión */
@media (pointer: fine) and (hover: hover) {
    body {
        cursor: none;
    }
    a, button, input, textarea, select, .story-card, .noir-card, .vip-card, .coleccion-card, [role="button"], .carousel-nav-btn {
        cursor: none !important;
    }
}

/* Lienzo de la Estela Espectral (Ghosting / Trail con persistencia de 1.0 a 1.2s) */
.spectral-cursor-canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    pointer-events: none !important;
    z-index: 9999997 !important;
    opacity: 0;
    transition: opacity 0.35s ease;
    user-select: none !important;
    will-change: transform;
}

/* Elementos del Puntero Principal (Fuego Fatuo) */
.fuego-fatuo-core,
.fuego-fatuo-halo,
.magnetic-cursor-dot,
.magnetic-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none !important;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    will-change: transform, width, height, box-shadow;
    opacity: 0;
    transition: opacity 0.35s ease;
    user-select: none !important;
}

/* Puntero Principal: Núcleo verde luminoso (Fuego Fatuo de alta visibilidad) */
.fuego-fatuo-core,
.magnetic-cursor-dot {
    width: 9px;
    height: 9px;
    background: radial-gradient(circle, #f0fff6 0%, #00ff88 60%, #059669 100%);
    box-shadow: 
        0 0 8px #00ff88,
        0 0 16px rgba(0, 255, 136, 0.9),
        0 0 30px rgba(0, 255, 136, 0.5),
        0 0 45px rgba(0, 255, 136, 0.25);
    z-index: 9999999 !important;
    transition: width 0.24s cubic-bezier(0.16, 1, 0.3, 1), 
                height 0.24s cubic-bezier(0.16, 1, 0.3, 1), 
                box-shadow 0.24s ease,
                background 0.24s ease;
}

/* Puntero Principal: Halo o resplandor suave flotante */
.fuego-fatuo-halo,
.magnetic-cursor-ring {
    width: 34px;
    height: 34px;
    border: 1.5px solid rgba(0, 255, 136, 0.45);
    background: radial-gradient(circle, rgba(0, 255, 136, 0.12) 0%, rgba(0, 255, 136, 0) 70%);
    box-shadow: 
        0 0 18px rgba(0, 255, 136, 0.22),
        inset 0 0 12px rgba(0, 255, 136, 0.12);
    z-index: 9999998 !important;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                height 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
                border-color 0.25s ease, 
                background-color 0.25s ease, 
                box-shadow 0.25s ease;
}

/* Reacción interactiva fluida al posarse sobre enlaces o triggers (Hover) */
.fuego-fatuo-halo.is-hovering,
.magnetic-cursor-ring.is-hovering {
    width: 58px;
    height: 58px;
    border-color: rgba(0, 255, 136, 0.85);
    background: radial-gradient(circle, rgba(0, 255, 136, 0.2) 0%, rgba(0, 255, 136, 0.04) 65%, transparent 100%);
    box-shadow: 
        0 0 32px rgba(0, 255, 136, 0.5),
        inset 0 0 20px rgba(0, 255, 136, 0.3);
}

.fuego-fatuo-core.is-hovering,
.magnetic-cursor-dot.is-hovering {
    width: 14px;
    height: 14px;
    background: radial-gradient(circle, #ffffff 0%, #00ff88 55%, #047857 100%);
    box-shadow: 
        0 0 12px #00ff88,
        0 0 24px rgba(0, 255, 136, 1),
        0 0 40px rgba(0, 255, 136, 0.65);
}

/* Pulsación táctil (Click activo) */
.fuego-fatuo-halo.is-active,
.magnetic-cursor-ring.is-active {
    width: 26px;
    height: 26px;
    border-color: #00ff88;
    box-shadow: 0 0 24px rgba(0, 255, 136, 0.85);
}

.fuego-fatuo-core.is-active,
.magnetic-cursor-dot.is-active {
    transform: translate(-50%, -50%) scale(0.7);
}

/* Desactivación automática en dispositivos táctiles / móviles */
@media (hover: none), (pointer: coarse), (max-width: 900px) {
    .spectral-cursor-canvas,
    .fuego-fatuo-core,
    .fuego-fatuo-halo,
    .magnetic-cursor-dot,
    .magnetic-cursor-ring {
        display: none !important;
        visibility: hidden !important;
    }
    body, a, button, input, textarea, select, .story-card, .noir-card, .vip-card, .coleccion-card {
        cursor: auto !important;
    }
}

/* Respeto estricto a preferencias de accesibilidad de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .spectral-cursor-canvas,
    .fuego-fatuo-core,
    .fuego-fatuo-halo,
    .magnetic-cursor-dot,
    .magnetic-cursor-ring {
        display: none !important;
        visibility: hidden !important;
    }
    body, a, button, input, textarea, select, .story-card, .noir-card, .vip-card, .coleccion-card {
        cursor: auto !important;
    }
}

/* Exclusión total de cursor y estela en modos de impresión o PDF */
@media print {
    .spectral-cursor-canvas,
    .fuego-fatuo-core,
    .fuego-fatuo-halo,
    .magnetic-cursor-dot,
    .magnetic-cursor-ring {
        display: none !important;
    }
}

/* ============================================================================
   2. TEXT REVEAL (Cinematic Typography)
   ============================================================================ */
.text-reveal-target {
    opacity: 1 !important;
}

.text-reveal-word {
    display: inline-block;
    overflow: hidden;
    vertical-align: bottom;
    padding-bottom: 2px;
}

.text-reveal-char {
    display: inline-block;
    transform: translateY(110%);
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.text-reveal-target.is-revealed .text-reveal-char {
    transform: translateY(0);
    opacity: 1;
}

/* ARCANE AUTO-LINKS (Internal Linking) */
.arcane-auto-link {
    color: var(--fatuo-green);
    text-decoration: none;
    border-bottom: 1px dashed rgba(0, 255, 136, 0.4);
    transition: all 0.3s ease;
    position: relative;
}
.arcane-auto-link:hover {
    color: #ffffff;
    border-bottom-color: var(--fatuo-green);
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

/* ==========================================================================
   TOC DINÁMICO (TABLE OF CONTENTS - GRIMORIO)
   ========================================================================== */
.relatando-toc-box {
    background: linear-gradient(135deg, rgba(6, 18, 12, 0.95) 0%, rgba(3, 8, 5, 0.98) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    margin: 35px 0;
    padding: 0;
    width: 100%;
    clear: both;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Smart Sticky Mode (triggered by JS observer) */
.relatando-toc-box.is-stuck {
    position: sticky;
    top: 15px;
    z-index: 999;
    margin-top: 0;
    margin-bottom: 25px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.7);
}

.relatando-toc-box .toc-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: rgba(212, 175, 55, 0.05);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    cursor: pointer;
}

.relatando-toc-box .toc-icon {
    font-size: 1.2rem;
    margin-right: 12px;
}

.relatando-toc-box .toc-title {
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 700;
    color: #d4af37;
    font-size: 1.15rem;
    letter-spacing: 1px;
    flex-grow: 1;
}

.relatando-toc-box .toc-toggle {
    background: transparent;
    border: none;
    color: #d4af37;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    transition: transform 0.3s ease;
}

.relatando-toc-box.is-collapsed .toc-toggle {
    transform: rotate(-90deg);
}

.relatando-toc-box .toc-list {
    list-style: none;
    padding: 20px;
    margin: 0;
    max-height: 2000px;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.4s ease;
    opacity: 1;
    counter-reset: toc-counter;
}

.relatando-toc-box.is-collapsed .toc-list {
    max-height: 0;
    padding: 0 20px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.relatando-toc-box li {
    margin-bottom: 10px;
    line-height: 1.5;
}

.relatando-toc-box li.toc-item-h2 {
    counter-increment: toc-counter;
}

.relatando-toc-box li:last-child {
    margin-bottom: 0;
}

.relatando-toc-box li a {
    color: #a3b8ad;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: inline-block;
}

.relatando-toc-box li.toc-item-h2 > a::before {
    content: counter(toc-counter, upper-roman) ". ";
    color: #d4af37;
    font-weight: 600;
    font-family: 'Cinzel', serif;
}

.relatando-toc-box li a:hover {
    color: #00ff88;
    transform: translateX(4px);
}

.relatando-toc-box .toc-item-h3 {
    padding-left: 20px;
    font-size: 0.88rem;
    position: relative;
}

.relatando-toc-box .toc-item-h3::before {
    content: '└';
    position: absolute;
    left: 4px;
    color: rgba(212, 175, 55, 0.4);
    top: -2px;
}
