/* ========================================
   Musicalissima - Web Radio
   ======================================== */

:root {
    --bg-dark: #050b1f;
    --bg-darker: #020516;
    --accent: #4a9eff;
    --accent-glow: #2980ff;
    --accent-soft: rgba(74, 158, 255, 0.25);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.65);
    --card-bg: rgba(8, 14, 32, 0.55);
    --card-border: rgba(74, 158, 255, 0.25);
    --player-bg: rgba(6, 12, 28, 0.92);
    --danger: #ff5b6a;
    --success: #4ade80;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-darker);
    color: var(--text);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 110px;
}

/* Background */
.bg-image {
    position: fixed;
    inset: 0;
    background-image: url('../img/fundo.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -2;
}

.bg-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at top, rgba(74, 158, 255, 0.08) 0%, transparent 60%),
        linear-gradient(180deg, rgba(2, 5, 22, 0.35) 0%, rgba(2, 5, 22, 0.75) 100%);
    z-index: -1;
}

/* ========== Header ========== */
.site-header {
    padding: 32px 40px 0;
    position: relative;
    z-index: 5;
    display: flex;
    justify-content: center;
}

.logo-wrap {
    display: inline-block;
    transition: transform 0.4s ease;
}

.logo-wrap:hover { transform: scale(1.04); }

.logo {
    max-width: 240px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 25px rgba(74, 158, 255, 0.4));
    display: block;
    transition: max-width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========== Main ========== */
.main {
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 1;
}

.channels-section {
    padding: 50px 40px 30px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ========== Channel Cards ========== */
.channels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    max-width: 1200px;
    margin: 30px auto 0;
}

.channel-card {
    position: relative;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    color: inherit;
    font: inherit;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.channel-card[data-channel]:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
    box-shadow: 0 18px 40px rgba(74, 158, 255, 0.3);
}

.channel-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft), 0 18px 40px rgba(74, 158, 255, 0.4);
}

.channel-img {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #000;
}

.channel-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.channel-card[data-channel]:hover .channel-img img {
    transform: scale(1.06);
}

.channel-img::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.85) 100%);
    pointer-events: none;
}

.channel-label {
    position: absolute;
    bottom: 18px;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--text);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.9);
    padding: 0 16px;
    z-index: 2;
}

/* Playing indicator on cards */
.channel-playing {
    position: absolute;
    top: 14px;
    right: 14px;
    display: none;
    align-items: flex-end;
    gap: 3px;
    height: 22px;
    padding: 6px 10px;
    background: var(--accent);
    border-radius: 20px;
    z-index: 2;
}

.channel-card.active .channel-playing { display: flex; }

.channel-playing span {
    width: 3px;
    height: 100%;
    background: #fff;
    border-radius: 2px;
    animation: bars 1s ease-in-out infinite;
}

.channel-playing span:nth-child(2) { animation-delay: 0.15s; }
.channel-playing span:nth-child(3) { animation-delay: 0.3s; }
.channel-playing span:nth-child(4) { animation-delay: 0.45s; }

@keyframes bars {
    0%, 100% { height: 30%; }
    50% { height: 100%; }
}

/* Now playing card */
.now-playing-card {
    cursor: default;
}

.now-playing-card .channel-label {
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    font-weight: 500;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 16px;
    bottom: 0;
    backdrop-filter: blur(6px);
}

/* ========== Header buttons (app & contact) ========== */
.app-btn,
.contact-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
}

.contact-btn { right: 28px; }
.app-btn     { left: 28px; }

.contact-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-50%) scale(1.06);
    box-shadow: 0 8px 20px rgba(74, 158, 255, 0.45);
}

.app-btn:hover {
    background: #34a853;
    border-color: #34a853;
    transform: translateY(-50%) scale(1.06);
    box-shadow: 0 8px 20px rgba(52, 168, 83, 0.45);
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 5, 22, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: linear-gradient(160deg, rgba(20, 30, 60, 0.95), rgba(8, 14, 32, 0.95));
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 30px 24px 22px;
    max-width: 400px;
    width: 100%;
    position: relative;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
    transform: scale(0.92) translateY(10px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.3s ease, color 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 22px;
    color: var(--text);
}

.modal-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 22px;
}

.modal-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 30px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.modal-link i { font-size: 1.05rem; }

.modal-link:hover { transform: translateY(-2px); }

.modal-link.app:hover {
    background: #34a853;
    border-color: #34a853;
    box-shadow: 0 10px 25px rgba(52, 168, 83, 0.45);
}

.modal-link.email:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 10px 25px rgba(74, 158, 255, 0.45);
}

.modal-link.instagram:hover {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    border-color: transparent;
    box-shadow: 0 10px 25px rgba(220, 39, 67, 0.45);
}

.modal-footer {
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}

.modal-copy,
.modal-credit {
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.3px;
    margin: 0;
    line-height: 1.5;
}

.modal-credit { margin-top: 6px; }

.modal-credit a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.modal-credit a:hover { text-decoration: underline; }

body.modal-open { overflow: hidden; }

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

@keyframes coverDropIn {
    from {
        opacity: 0;
        transform: translateY(-28px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========== Player Bar ========== */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--player-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(74, 158, 255, 0.25);
    display: flex;
    align-items: center;
    padding: 12px 24px;
    gap: 20px;
    z-index: 100;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ctrl-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: background 0.3s ease, transform 0.2s ease, color 0.3s ease;
}

.ctrl-btn:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.08);
}

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

.ctrl-play {
    position: relative;
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 6px 20px rgba(74, 158, 255, 0.45);
}

.ctrl-play:hover {
    background: var(--accent-glow);
    transform: scale(1.05);
}

.player-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    text-align: center;
}

.track-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-channel {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.track-progress {
    margin-top: 4px;
}

.progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-glow));
    border-radius: 2px;
    transition: width 0.5s ease;
}

.player-bar.live .progress-fill {
    width: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-glow), var(--accent));
    background-size: 200% 100%;
    animation: liveProgress 2s linear infinite;
}

@keyframes liveProgress {
    0% { background-position: 0 0; }
    100% { background-position: 200% 0; }
}

.player-volume {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#volSlider {
    width: 90px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

#volSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(74, 158, 255, 0.6);
}

#volSlider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(74, 158, 255, 0.6);
}

/* Loading state */
.ctrl-play.loading > i { visibility: hidden; }
.ctrl-play.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    pointer-events: none;
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
    .channels {
        gap: 20px;
    }

    .site-header { padding: 22px 24px 0; }
    .channels-section { padding: 35px 24px 20px; }
}

@media (max-width: 640px) {
    body { padding-bottom: 300px; }

    .site-header { padding: 18px 14px 0; }

    .logo { max-width: 170px; }

    .channels-section {
        padding: 18px 14px 12px;
        padding-top: 14vh;
        transition: padding-top 0.55s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .app-btn,
    .contact-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .contact-btn { right: 14px; }
    .app-btn     { left: 14px; }

    .modal-title { font-size: 1.4rem; }
    .modal-link { font-size: 0.86rem; padding: 11px 16px; }

    /* Estado inativo (sem canal): capa oculta, só os 2 botões centralizados */
    .channels {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "instr soft";
        gap: 12px;
        margin-top: 0;
    }

    .now-playing-card {
        grid-area: cover;
        display: none;
    }

    .channel-card[data-channel="instrumental"] { grid-area: instr; }
    .channel-card[data-channel="softcult"]     { grid-area: soft; }

    .channel-side .channel-label {
        font-size: 1.05rem;
        bottom: 10px;
    }

    .now-playing-card .channel-label {
        font-size: 0.9rem;
    }

    /* Estado ativo (canal selecionado): capa aparece, logo encolhe, botões descem */
    body.channel-active .logo { max-width: 125px; }

    body.channel-active .channels-section { padding-top: 18px; }

    body.channel-active .channels {
        grid-template-areas:
            "cover cover"
            "instr soft";
    }

    body.channel-active .now-playing-card {
        display: flex;
        animation: coverDropIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
    }

    .player-bar {
        padding: 10px 14px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .player-info {
        order: -1;
        flex-basis: 100%;
    }

    .player-controls {
        flex-basis: 100%;
        justify-content: center;
        gap: 18px;
    }

    .track-title { font-size: 0.85rem; }
    .track-channel { font-size: 0.7rem; }

    .player-volume {
        display: none;
    }

    .fullscreen-btn { display: none; }
}

@media (max-width: 380px) {
    .ctrl-btn { width: 34px; height: 34px; font-size: 0.85rem; }
    .ctrl-play { width: 44px; height: 44px; font-size: 1rem; }
}

/* iOS safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
    .player-bar {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    body {
        padding-bottom: calc(110px + env(safe-area-inset-bottom));
    }
    @media (max-width: 640px) {
        body { padding-bottom: calc(300px + env(safe-area-inset-bottom)); }
    }
}
