/* --- VARIABLES GLOBALES --- */
:root {
    --header-height: 110px; 
    --primary-cyan: #00ccff; 
    --primary-gradient: linear-gradient(135deg, #00ccff 0%, #0077ff 100%);
    --card-bg: #2d2d2d;
    --error-bg: #0d0d0d;
    --bg-color: #151515;
}

/* --- RESET Y BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Roboto', sans-serif; }

::-webkit-scrollbar { display: none; }
html, body { scrollbar-width: none; -ms-overflow-style: none; }

html { scroll-snap-type: y mandatory; }

body { 
    background-color: var(--bg-color); 
    color: #ffffff; 
    overflow-x: hidden; 
}

#dim-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: #000; z-index: 9000; opacity: 0; pointer-events: none;
    transition: opacity 1.5s ease-in-out;
}
body.is-idle #dim-overlay { opacity: 0.85; }

#splash-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: #151515; z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.5s ease;
}
#splash-screen.hidden { opacity: 0; pointer-events: none; }

.splash-img { width: 150px; height: 150px; object-fit: contain; animation: splashSpin 3s linear infinite; }
@keyframes splashSpin { 100% { transform: rotate(360deg); } }
.splash-loader { width: 60px; height: 60px; border: 5px solid rgba(255, 255, 255, 0.1); border-top-color: var(--primary-cyan); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- HEADER PRINCIPAL --- */
header { 
    position: fixed; 
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    z-index: 1000; 
    background-color: var(--bg-color); 
    
    display: grid; 
    grid-template-columns: 1fr auto 1fr; 
    align-items: center; 
    
    padding-top: 20px; 
    padding-bottom: 10px;
    padding-left: 40px;         
    padding-right: 40px;
    
    box-shadow: none; 
    border: none;
}

.brand-logo { 
    display: flex; align-items: flex-start; justify-self: start; 
    height: 70px; 
    width: auto; outline: none; 
}
.brand-logo img { max-height: 70px; width: auto; object-fit: contain; display: block; }

.player-wrapper { display: flex; justify-content: center; width: 100%; height: 70px; align-items: center; }

.player-bar { 
    display: flex; align-items: center; gap: 15px; 
    opacity: 0; 
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.25, 1, 0.5, 1); 
    background: rgba(255, 255, 255, 0.08);
    padding: 10px 25px; border-radius: 50px; backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1); 
    transform: translateY(-20px); 
    
    max-width: 45vw; 
    
    position: relative;
    z-index: 10;
    overflow: hidden; 
}
.player-bar.active { opacity: 1; transform: translateY(0); } 
.player-bar.shift-box { transform: translate(-40px, 0) !important; }

.player-logo { width: 45px; height: 45px; border-radius: 50%; overflow: hidden; background: #000; position: relative; flex-shrink: 0; display: flex; align-items: center; justify-content: center;}
.player-logo img { width: 100%; height: 100%; object-fit: cover; display: none; }

.player-logo.is-radio { 
    border: 2px solid var(--primary-cyan); 
    border-radius: 50% !important; 
}

.player-logo.is-music { 
    border: 2px solid var(--primary-cyan); 
    border-radius: 6px; 
}

.player-svg-container { 
    width: 100%; 
    height: 100%; 
    padding: 3px; 
    display: flex; align-items: center; justify-content: center; 
}
.player-svg-container svg { fill: var(--primary-cyan); width: 100%; height: 100%; shape-rendering: geometricPrecision; }

.text-circle { 
    font-family: 'Montserrat', sans-serif; 
    font-weight: 900; 
    letter-spacing: -1px;
    transform: none; 
    border: 3px solid var(--primary-cyan); 
    border-radius: 50%; 
    width: 100%; height: 100%; 
    display: flex; align-items: center; justify-content: center; 
    background: rgba(0,0,0,0.3);
    font-size: 0.9rem; 
}
.music-card .text-circle { font-size: 1.4rem; }

.player-info { 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: flex-start; 
    overflow: hidden; 
    position: relative;
    max-width: 40vw; 
}

.player-info.mask-active {
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
}

.player-title { 
    font-size: 1rem; 
    font-weight: 700; 
    color: #fff; 
    white-space: nowrap; 
    display: block;
    text-overflow: ellipsis; 
    overflow: hidden;
    max-width: 100%;
    will-change: transform;
    padding-right: 15px; 
}

.player-title.scroll-active {
    text-overflow: clip; 
    overflow: visible;
    animation-name: dynamic-scroll; 
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.clock-container { 
    text-align: right; justify-self: end; 
    height: 70px; display: flex; align-items: center; justify-content: flex-end; 
    min-width: 140px; 
    white-space: nowrap; 
}

.time { font-size: 2.8rem; font-weight: 300; line-height: 1; }
.date { font-size: 1.2rem; color: #ccc; margin-left: 10px; line-height: 1; }

/* --- CONTENEDOR PRINCIPAL --- */
#main-content {
    padding-top: calc(var(--header-height) + 25px);
    padding-left: 40px;
    padding-right: 40px;
    padding-bottom: 400px; 
}

.section-title { 
    font-size: 1.4rem; color: #eee; font-weight: 500; 
    border-left: 4px solid var(--primary-cyan); padding-left: 10px; 
    margin-bottom: 20px;
}

.music-sticky-bar {
    position: -webkit-sticky; 
    position: sticky;
    top: var(--header-height); 
    z-index: 900; 
    background-color: var(--bg-color); 
    padding-top: 25px; 
    padding-bottom: 15px;
    margin-bottom: 10px;
    margin-left: -40px; 
    margin-right: -40px;
    padding-left: 40px; 
}

.radios-wrapper {
    margin-bottom: 25px; 
    scroll-snap-align: start; 
    scroll-margin-top: calc(var(--header-height) + 20px);
}

/* --- SCROLL Y CURSOR --- */
.items-scroll-row { 
    display: flex; 
    gap: 20px; 
    overflow-x: auto; 
    padding: 10px 0 20px 0; 
    scrollbar-width: none; 
    scroll-behavior: smooth;
    cursor: grab; 
    cursor: -webkit-grab;
}
.items-scroll-row::-webkit-scrollbar { display: none; }

.items-scroll-row.active-drag {
    cursor: grabbing;
    cursor: -webkit-grabbing;
    scroll-behavior: auto;
}

.radio-item { 
    display: flex; flex-direction: column; align-items: center; 
    min-width: 140px; 
    text-align: center; cursor: pointer; outline: none; position: relative; 
    scroll-margin-top: calc(var(--header-height) + 50px);
}

@media (min-width: 1200px) {
    .radio-item { flex: 0 0 calc((100% - 140px) / 8); width: calc((100% - 140px) / 8); min-width: 0; }
}

.radio-circle { width: 120px; height: 120px; border-radius: 50%; overflow: hidden; border: 3px solid transparent; transition: transform 0.3s, border-color 0.3s; background: transparent; }
.radio-circle img { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; }
.radio-name { margin-top: 12px; font-size: 0.95rem; font-weight: 500; color: #aaa; transition: color 0.3s; }

.radio-item:focus .radio-circle, .radio-item:hover .radio-circle { border-color: var(--primary-cyan); transform: scale(1.08); }
.radio-item:focus .radio-name, .radio-item:hover .radio-name { color: var(--primary-cyan); font-weight: 700; }

/* --- MÚSICA GRID --- */
.music-grid { display: grid; gap: 15px; padding-bottom: 40px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1000px) { .music-grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 1000px) and (hover: hover) { .music-grid { grid-template-columns: repeat(8, 1fr); } }
@media (min-width: 769px) and (max-width: 999px) { .music-grid { grid-template-columns: repeat(4, 1fr); } }

.music-card { 
    aspect-ratio: 1 / 1; background-color: var(--card-bg); border-radius: 12px; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    cursor: pointer; transition: transform 0.2s, background-color 0.2s; border: 2px solid transparent; outline: none; 
    position: relative; overflow: hidden; padding: 10px;
    scroll-snap-align: start; 
    scroll-margin-top: calc(var(--header-height) + 80px); 
}
.music-card:focus, .music-card:hover { transform: translateY(-5px) scale(1.05); background-color: #383838; border-color: var(--primary-cyan); z-index: 2; }

.music-number { font-size: 2rem; font-weight: 900; color: rgba(255,255,255,0.06); position: absolute; top: 5px; right: 8px; line-height: 1; pointer-events: none; }
.visual-wrapper { width: 85px; height: 85px; margin-top: 15px; position: relative; display: flex; align-items: center; justify-content: center; z-index: 5; }
.music-real-img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; position: absolute; top: 0; left: 0; display: none; }
.music-card.image-loaded .music-real-img { display: block; } 
.music-card.image-loaded .svg-container { display: none; } 

.svg-container { 
    width: 100%; height: 100%; 
    display: flex; align-items: center; justify-content: center; 
    position: absolute; top: 0; left: 0;
    padding: 10px; 
}
.music-svg { 
    fill: var(--primary-cyan); 
    width: 100%; height: 100%;
    shape-rendering: geometricPrecision; 
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.5));
}

.music-title { font-size: 0.95rem; color: #ddd; text-align: center; line-height: 1.2; font-weight: 400; width: 100%; z-index: 5; margin-top: 5px; }

.state-overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 20; pointer-events: none; }
.state-overlay > * { grid-area: 1 / 1; }
.icon-play { font-size: 3rem; color: #fff; transform: scale(0); transition: transform 0.3s; margin: 0; line-height: 1; padding-left: 5px; }
.radio-item:not(.is-playing):hover .icon-play, .radio-item:not(.is-playing):focus .icon-play, .music-card:not(.is-playing):hover .icon-play, .music-card:not(.is-playing):focus .icon-play { transform: scale(1); }
.equalizer { display: none; align-items: flex-end; justify-content: center; gap: 5px; height: 35px; width: 40px; }
.is-playing .equalizer { display: flex; }
/* Modifica la clase de la barra */
.bar {
    width: 8px;
    background-color: #fff;
    /* Cambia la animación para usar la nueva keyframe */
    animation: bounce 1s infinite ease-in-out;
    box-shadow: 0 0 10px var(--primary-cyan);
    border-radius: 2px;
    
    /* PROPIEDADES NUEVAS IMPORTANTES */
    transform-origin: bottom; /* Para que crezca desde el piso */
    will-change: transform;   /* Le avisa al navegador que prepare la GPU */
}
.bar:nth-child(1) { height: 40%; animation-delay: 0s; }
.bar:nth-child(2) { height: 100%; animation-delay: 0.2s; }
.bar:nth-child(3) { height: 60%; animation-delay: 0.4s; }
@keyframes bounce { 0%, 100% { height: 30%; } 50% { height: 100%; } }
/* @keyframes reemplazado por Joaco */
@keyframes bounce {
    0%, 100% {
        transform: scaleY(0.3); /* Equivale a height: 30% */
    }
    50% {
        transform: scaleY(1);   /* Equivale a height: 100% */
    }
}
.icon-stop { display: none; width: 26px; height: 26px; background-color: var(--primary-cyan); border-radius: 4px; box-shadow: 0 0 15px var(--primary-cyan); }
.radio-item.is-playing:hover .equalizer, .music-card.is-playing:hover .equalizer { display: none; }
.radio-item.is-playing:hover .icon-stop, .music-card.is-playing:hover .icon-stop { display: block; }
.radio-item:hover img, .radio-item:focus img, .radio-item.is-playing img, .music-card:hover .music-real-img, .music-card:focus .music-real-img, .music-card.is-playing .music-real-img { opacity: 0.3; filter: blur(2px); }

/* --- MEDIA QUERIES --- */
@media (max-width: 1000px) and (min-width: 601px) {
    header { padding-left: 20px; padding-right: 20px; }
    #main-content { padding-left: 20px; padding-right: 20px; }
    .music-sticky-bar { margin-left: -20px; margin-right: -20px; padding-left: 20px; }
}

@media (max-width: 600px) {
    :root {
        --header-height: 220px; 
    }

    header {
        display: flex;
        flex-direction: column;
        align-items: center; 
        justify-content: flex-start;
        
        padding-top: 30px; 
        padding-left: 15px; 
        padding-right: 15px;
        padding-bottom: 20px;
        gap: 15px;
    }

    .brand-logo { 
        justify-content: center; 
        width: 100%; height: auto;
        order: 1; 
    }
    .brand-logo img { max-height: 50px; }

    .player-wrapper { 
        width: 100%; height: auto;
        justify-content: center; 
        order: 2;
        min-height: 50px; 
    }
    
    .player-bar {
        width: 100%;
        max-width: 350px; 
        justify-content: center;
    }

    .player-info { max-width: 80vw; }

    .clock-container { 
        width: 100%; height: auto;
        justify-content: center; 
        text-align: center;
        order: 3;
        min-width: auto; 
    }
    .time { font-size: 2.5rem; }
    .date { font-size: 1.2rem; }

    #main-content {
        padding-left: 15px;
        padding-right: 15px;
    }

    .music-sticky-bar {
        margin-left: -15px;
        margin-right: -15px;
        padding-left: 15px;
    }
}