/* ==========================================================================
   REPRODUCTOR DE VELADORAS - DÍA DE MUERTOS
   Diseño de Vanguardia: Obsidian, Cempasúchil & Golden Ember Glassmorphism
   ========================================================================== */

:root {
    --bg-dark: #09060f;
    --bg-surface: rgba(22, 13, 31, 0.72);
    --bg-surface-elevated: rgba(35, 20, 50, 0.85);
    
    /* Paleta Tradicional Día de Muertos / Mexicana */
    --cempasuchil: #ff7700;
    --amber-flame: #ffaa00;
    --flame-gold: #ffbe3b;
    --rosa-mexicano: #ff007f;
    --morado-altar: #9c27b0;
    --turquesa: #00bcd4;
    --crimson-glow: #e63946;
    --candle-wax: #fff4db;

    /* Acentos y Gradientes Mexicanos */
    --gradient-flame: linear-gradient(135deg, #ff007f 0%, #ff6f00 50%, #ffb700 100%);
    --gradient-gold: linear-gradient(135deg, #ffe066 0%, #ff9e00 100%);
    --gradient-surface: linear-gradient(180deg, rgba(32, 16, 46, 0.88) 0%, rgba(14, 7, 22, 0.96) 100%);
    --gradient-wave: linear-gradient(90deg, #ff007f, #ff7900, #ffb700);

    /* Textos */
    --text-primary: #fcf9f2;
    --text-secondary: #c9b9a6;
    --text-muted: #8c7b8f;
    --text-gold: #ffd166;

    /* Bordes y Sombras */
    --border-glow: 1px solid rgba(255, 170, 0, 0.22);
    --border-subtle: 1px solid rgba(255, 255, 255, 0.08);
    --shadow-candle: 0 12px 40px -10px rgba(255, 90, 0, 0.35);
    --shadow-card: 0 24px 60px -12px rgba(0, 0, 0, 0.85), 0 0 45px -8px rgba(255, 110, 0, 0.18);
    
    --radius-xl: 32px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-full: 9999px;
}

/* Reset y base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body.veladora-theme {
    min-height: 100vh;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    padding: 1.5rem 1rem;
}

/* Fuentes personalizadas */
.font-cinzel {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.04em;
}

.font-mono {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Lienzo interactivo de partículas flotantes (brasas / chispas de veladora) */
.ambient-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    opacity: 0.85;
}

/* Resplandor ambiental de fondo */
.ambient-light {
    position: fixed;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 120vw;
    height: 80vh;
    background: radial-gradient(circle, rgba(255, 120, 0, 0.16) 0%, rgba(180, 40, 0, 0.08) 40%, rgba(9, 6, 15, 0) 70%);
    pointer-events: none;
    z-index: 0;
    filter: blur(50px);
}

/* Envoltorio principal */
.player-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 460px;
    margin: 2.2rem auto 1.5rem auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Banderines de Fiesta Colgantes (3 Tiras Curvas en Media U - Compacto y Fino) */
.feston-header-banner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 780px;
    max-height: 75px;
    z-index: 12;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
    pointer-events: none;
    overflow: hidden;
    padding: 0 0.5rem;
}

.feston-header-img {
    width: 100%;
    max-height: 75px;
    height: auto;
    display: block;
    object-fit: contain;
    animation: swayFestons 8s ease-in-out infinite alternate;
}

@keyframes swayFestons {
    0% { transform: translateY(0) rotate(-0.3deg); }
    100% { transform: translateY(2px) rotate(0.3deg); }
}

/* Tarjeta Principal Glassmorphic */
.candle-card {
    width: 100%;
    background: var(--gradient-surface);
    border: var(--border-glow);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 1.75rem 1.5rem 1.5rem 1.5rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Brillo superior decorativo de la tarjeta */
.candle-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--amber-flame), var(--flame-gold), var(--rosa-mexicano), transparent);
    opacity: 0.8;
}

/* CONTENEDOR DE LA PORTADA / MINIATURA */
.cover-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1;
    margin: 0 auto 1.5rem auto;
    border-radius: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

/* Anillo de resplandor cuando la canción está sonando */
.cover-glow-ring {
    position: absolute;
    inset: -6px;
    border-radius: 28px;
    background: conic-gradient(from 0deg, #ff007f, #ff7900, #ffd000, #00d4e0, #ff007f);
    opacity: 0.35;
    filter: blur(14px);
    transition: opacity 0.6s ease, filter 0.6s ease;
    z-index: 1;
}

body.is-playing .cover-glow-ring {
    opacity: 0.85;
    filter: blur(18px);
    animation: rotateGlow 8s linear infinite;
}

@keyframes rotateGlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 22px;
    border: 2px solid rgba(255, 195, 77, 0.4);
    background: #12091c;
    position: relative;
    z-index: 2;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    transition: transform 0.5s ease;
}

body.is-playing .cover-image {
    transform: scale(1.015);
}

.cover-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    pointer-events: none;
}

.mourning-ribbon-badge {
    width: 42px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.75));
    transition: transform 0.3s ease;
}

.mourning-ribbon-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

body.is-playing .mourning-ribbon-badge {
    animation: ribbonBreathe 3s ease-in-out infinite alternate;
}

@keyframes ribbonBreathe {
    0% { transform: scale(1); filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.75)); }
    100% { transform: scale(1.06); filter: drop-shadow(0 6px 14px rgba(255, 190, 50, 0.3)); }
}

/* METADATOS: ENFOQUE SOBRIO EN 'EN MEMORIA DE' */
.track-meta {
    width: 100%;
    text-align: center;
    margin-bottom: 1.5rem;
}

.memorial-title {
    font-size: 1.65rem;
    font-weight: 700;
    color: #fffaf0;
    line-height: 1.3;
    text-shadow: 0 2px 14px rgba(255, 120, 0, 0.5);
    word-break: break-word;
    letter-spacing: 0.03em;
    background: linear-gradient(180deg, #ffffff 20%, #ffd000 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.memorial-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fffaf0;
    line-height: 1.3;
    text-shadow: 0 2px 14px rgba(255, 120, 0, 0.5);
    word-break: break-word;
    letter-spacing: 0.03em;
    background: linear-gradient(180deg, #ffffff 15%, #ffd000 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* SECCIÓN FORMA DE ONDA (WAVESURFER) */
.waveform-section {
    width: 100%;
    background: rgba(16, 9, 25, 0.65);
    border: var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1rem 1rem 0.85rem 1rem;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.waveform-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.waveform-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

/* Barras animadas de ecualizador */
.equalizer-icon {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
}

.equalizer-icon span {
    width: 3px;
    height: 4px;
    background-color: var(--flame-gold);
    border-radius: 2px;
    transition: height 0.2s ease;
}

body.is-playing .equalizer-icon span:nth-child(1) { animation: eqBar 0.8s ease infinite alternate; }
body.is-playing .equalizer-icon span:nth-child(2) { animation: eqBar 0.5s ease infinite alternate 0.2s; }
body.is-playing .equalizer-icon span:nth-child(3) { animation: eqBar 0.7s ease infinite alternate 0.4s; }
body.is-playing .equalizer-icon span:nth-child(4) { animation: eqBar 0.6s ease infinite alternate 0.1s; }

@keyframes eqBar {
    from { height: 3px; }
    to { height: 14px; background-color: var(--cempasuchil); }
}

.time-readout {
    font-size: 0.82rem;
    color: var(--text-gold);
    letter-spacing: 0.05em;
    font-weight: 600;
}

.time-sep {
    opacity: 0.4;
    margin: 0 2px;
}

.waveform-container {
    position: relative;
    width: 100%;
    min-height: 72px;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}

.wavesurfer-canvas {
    width: 100%;
    min-height: 72px;
}

.waveform-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: var(--text-gold);
    background: rgba(14, 8, 22, 0.85);
    z-index: 5;
    transition: opacity 0.4s ease;
}

.waveform-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 170, 0, 0.3);
    border-top-color: var(--amber-flame);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* SECCIÓN DE CONTROLES CLARAMENTE VISIBLES */
.controls-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.primary-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
}

.btn-ctrl {
    border: none;
    outline: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.btn-ctrl:active {
    transform: scale(0.92);
}

/* BOTÓN DE PLAY / PAUSE PRINCIPAL GIGANTE */
.btn-play-main {
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: var(--gradient-flame);
    color: #ffffff;
    box-shadow: 0 8px 30px rgba(255, 84, 0, 0.55), 0 0 0 3px rgba(255, 200, 80, 0.3);
}

.btn-play-main:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 38px rgba(255, 84, 0, 0.7), 0 0 0 5px rgba(255, 200, 80, 0.45);
}

.btn-play-main svg {
    width: 34px;
    height: 34px;
    position: relative;
    z-index: 2;
    transition: transform 0.2s ease;
}

.btn-play-main svg.icon-play {
    transform: translateX(2px);
}

.play-pulse-halo {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 170, 0, 0.4) 0%, rgba(255, 84, 0, 0) 70%);
    animation: flamePulse 2.4s infinite ease-in-out;
    pointer-events: none;
    z-index: 1;
}

/* Botones secundarios (Rewind / Forward 10s) */
.btn-secondary {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(36, 21, 52, 0.85);
    border: var(--border-glow);
    color: var(--text-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.btn-secondary:hover {
    background: rgba(52, 30, 75, 0.95);
    color: var(--text-gold);
    border-color: rgba(255, 170, 0, 0.45);
    transform: translateY(-2px);
}

.btn-secondary svg {
    width: 22px;
    height: 22px;
}

.ctrl-subtext {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-gold);
    margin-top: -2px;
}

/* BOTÓN DE DESCARGA DE MP3 */
.download-section {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

.btn-download-audio {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 1.4rem;
    background: rgba(30, 16, 44, 0.75);
    border: var(--border-glow);
    border-radius: var(--radius-full);
    color: var(--text-gold);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.02em;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-download-audio svg {
    width: 17px;
    height: 17px;
    stroke: var(--flame-gold);
    transition: transform 0.2s ease;
}

.btn-download-audio:hover {
    background: rgba(48, 25, 72, 0.95);
    border-color: var(--amber);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(255, 170, 0, 0.25);
}

.btn-download-audio:hover svg {
    transform: translateY(2px);
}

.btn-download-audio:active {
    transform: translateY(0);
}

/* PIE DE MEMORIA CONMEMORATIVO */
.memorial-footer {
    width: 100%;
    margin-top: 0.4rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(255, 170, 0, 0.15);
    text-align: center;
}

.memorial-quote {
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 0.6rem;
    opacity: 0.85;
}

.views-counter {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-gold);
    background: rgba(255, 170, 0, 0.08);
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
}

/* Enlace inferior */
.site-credit {
    margin-top: 0.5rem;
    text-align: center;
}

.back-link {
    color: var(--text-muted);
    font-size: 0.82rem;
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.back-link:hover {
    color: var(--text-gold);
}

/* PANTALLA NO ENCONTRADA */
.not-found-wrapper {
    text-align: center;
}

.candle-icon-pulse {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: flamePulse 2s infinite ease-in-out;
}

.not-found-desc {
    color: var(--text-secondary);
    margin: 1rem 0 1.5rem 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.75rem;
    background: var(--gradient-flame);
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-full);
    border: none;
    box-shadow: 0 8px 24px rgba(255, 84, 0, 0.45);
    transition: all 0.25s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(255, 84, 0, 0.6);
}

/* Notificación Flotante (Toast) */
.toast-msg {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    background: rgba(26, 14, 38, 0.95);
    border: var(--border-glow);
    color: #ffffff;
    padding: 0.75rem 1.4rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-msg.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* RESPONSIVE */
@media (max-width: 420px) {
    body.veladora-theme {
        padding: 0.8rem 0.6rem;
    }

    .feston-header-banner {
        max-width: 100%;
        top: 0;
    }

    .player-wrapper {
        margin: 3.4rem auto 0.8rem auto;
    }

    .candle-card {
        padding: 1.25rem 1rem 1.1rem 1rem;
        border-radius: 26px;
    }

    .cover-container {
        max-width: 260px;
        margin-bottom: 1.1rem;
    }

    .memorial-title {
        font-size: 1.3rem;
    }

    .mourning-ribbon-badge {
        width: 36px;
        height: 48px;
    }

    .btn-play-main {
        width: 72px;
        height: 72px;
    }

    .btn-play-main svg {
        width: 30px;
        height: 30px;
    }

    .btn-secondary {
        width: 46px;
        height: 46px;
    }
}
