/* =========================
   RESET & FULLSCREEN BASE
========================= */

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

html, body {

    /* Occupa TUTTO lo schermo, incluso notch e barra di sistema */
    width: 100%;
    height: 100%;

    /* Nessuno scroll */
    overflow: hidden;
    overflow-x: hidden;

    background: #111;

    font-family: Arial, sans-serif;

    /* Disabilita selezione testo */
    user-select: none;
    -webkit-user-select: none;

    /* Disabilita callout su long-press iOS */
    -webkit-touch-callout: none;

    /* Colore sfondo sotto safe area */
    background-color: #111111;
}

/* =========================
   CONTAINER PLAYER
========================= */

#radio-player {
    width: 100%;
    height: 100%;
}

.radio-player {

    --primary-color: #C81703;

    /* Fullscreen vero con supporto safe-area (notch, Dynamic Island, barra home) */
    width: 100%;
    height: 100%;
    min-height: 100dvh; /* dynamic viewport height � gestisce la barra browser */

    /* Padding che rispetta le aree di sistema iOS/Android */
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));

    background: #111111;
    color: #fff;

    position: relative;
    overflow: hidden;

    display: flex;
    flex-direction: column;
}

/* =========================
   SFONDO BLUR DINAMICO
========================= */

.player-bg {

    position: absolute;
    inset: -40px;

    background-size: cover;
    background-position: center;

    filter: blur(70px) saturate(1.4);
    transform: scale(1.3);

    opacity: 0.18;

    transition:
        background-image 0.8s ease,
        opacity 1.2s ease;

    pointer-events: none;
    z-index: 0;
}

/* Blur pi� intenso durante la riproduzione */
.radio-player.is-playing .player-bg {
    opacity: 0.38;
    filter: blur(60px) saturate(1.8);
}

/* Overlay scuro per leggibilit� */
.radio-player::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.35) 0%,
        rgba(0,0,0,0.10) 40%,
        rgba(0,0,0,0.55) 100%
    );
    z-index: 1;
    pointer-events: none;
}

/* =========================
   CONTENUTO PRINCIPALE
========================= */

.player-content {

    position: relative;
    z-index: 2;

    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding: 0 32px;
    padding-top: 70px; /* spazio per l'header */
    gap: 0;

    overflow: hidden;
}

/* =========================
   COVER � cerchio perfetto
========================= */

.cover {

    /* Dimensione relativa alla viewport per adattarsi a tutti gli iPhone */
    width: min(240px, 56vw);
    height: min(240px, 56vw);

    border-radius: 22px;

    overflow: hidden;

    box-shadow:
        0 20px 60px rgba(0,0,0,0.6),
        0 0 0 4px rgba(255,255,255,0.06);

    margin-bottom: 14px;

    flex-shrink: 0;

    /* Leggera animazione di comparsa */
    animation: coverIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes coverIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.cover img {

    width: 100%;
    height: 100%;
    object-fit: cover;

    transition:
        opacity 0.4s ease,
        transform 0.4s ease;

    opacity: 1;
}

/* =========================
   TESTI
========================= */

/* =========================
   BLOCCO TESTI — altezza fissa
   Il layout non si sposta mai
========================= */

.text-block {

    width: 100%;
    /* Altezza fissa: radio-name + titolo + artista */
    height: 90px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    overflow: hidden;
    flex-shrink: 0;

    margin-bottom: 12px;
}

.radio-name {

    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    opacity: 0.7;

    margin-bottom: 4px;
    flex-shrink: 0;

    animation: fadeUp 0.5s 0.1s ease both;
}

/* =========================
   TITOLO CON MARQUEE
========================= */

.track-title-wrap {

    width: 100%;
    overflow: hidden;
    flex-shrink: 0;
    margin-bottom: 4px;

    animation: fadeUp 0.5s 0.15s ease both;
}

.track-title {

    font-family: Arial, sans-serif;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.2;

    white-space: nowrap;
    display: inline-block;

    /* Default: centrato se entra */
    text-align: center;
    width: 100%;
}

/* Animazione marquee — attiva solo se il testo è troppo lungo */
.track-title.marquee {
    animation: marquee 12s linear infinite;
    text-align: left;
    width: auto;
    padding-right: 60px; /* spazio tra fine e inizio */
}

@keyframes marquee {
    0%   { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

.track-artist {

    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
    opacity: 0.8;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    text-align: center;
    flex-shrink: 0;

    animation: fadeUp 0.5s 0.2s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================
   CONTROLLI
========================= */

.controls {

    display: flex;
    justify-content: center;
    align-items: center;

    margin-bottom: 16px;
}

.play-btn {

    width: auto;
    height: auto;

    padding: 0;

    border: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;

    background: none;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;

    transition: transform 0.25s ease;

    -webkit-tap-highlight-color: transparent;
}

.play-btn:hover {
    transform: scale(1.08);
}

.play-btn:focus {
    outline: none;
}

.play-icon {

    width: 72px;
    height: 72px;
    display: block;
    pointer-events: none;

    filter: drop-shadow(0 6px 16px rgba(0,0,0,0.35));

    transition:
        transform 0.25s ease,
        opacity 0.25s ease;
}

/* =========================
   VOLUME
========================= */

.volume-wrap {

    display: flex;
    align-items: center;
    gap: 14px;

    width: 100%;
    max-width: 320px;

    animation: fadeUp 0.5s 0.3s ease both;
}

.volume-icon img {
    width: 40px;
    height: 40px;
    opacity: 0.6;
    flex-shrink: 0;
}

.volume-slider {

    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    outline: none;
    background: rgba(255,255,255,0.15);
    cursor: pointer;

    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

.volume-slider:focus {
    outline: none;
}

.volume-slider:focus-visible {
    outline: none;
}

.volume-slider::-webkit-slider-thumb {

    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform 0.15s ease;
}

.volume-slider::-webkit-slider-thumb:active {
    transform: scale(1.25);
}

.volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

/* =========================
   STATUS
========================= */

.status {

    font-family: Arial, sans-serif;
    font-size: 15px;
    font-weight: 400;
    opacity: 0.7;

    margin-top: 10px;
    text-align: center;

    animation: fadeUp 0.5s 0.35s ease both;
}

/* =========================
   INSTALL BUTTON
========================= */

/* =========================
   INSTALL BAR — fissa in basso
========================= */

.install-bar {

    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 20px;
    right: 20px;
    z-index: 100;

    display: flex;
    align-items: center;

    /* Pill completamente arrotondata */
    border-radius: 999px;

    padding: 10px 10px 10px 20px;

    background: var(--primary-color);

    box-shadow:
        0 8px 24px rgba(0,0,0,0.4),
        0 2px 8px rgba(0,0,0,0.2);

    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.install-btn {

    flex: 1;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    background: none;
    border: none;
    padding: 0;

    color: #fff;

    font-family: Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;

    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.install-btn:active {
    opacity: 0.8;
}

.install-close {

    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;

    color: #fff;
    font-size: 18px;
    line-height: 1;

    cursor: pointer;
    flex-shrink: 0;
    margin-left: 12px;

    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease;
}

.install-close:active {
    background: rgba(255,255,255,0.35);
}

/* =========================
   RESPONSIVE � schermi piccoli
   (iPhone SE, 375x667)
========================= */

@media (max-height: 680px) {

    .cover {
        width: min(180px, 50vw);
        height: min(180px, 50vw);
        border-radius: 18px;
        margin-bottom: 20px;
    }

    .track-artist {
        margin-bottom: 20px;
    }

    .controls {
        margin-bottom: 20px;
    }
}

/* Player sempre fullscreen — browser e PWA */
/* =========================
   SPLASH SCREEN
========================= */

#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #111111;
    display: var(--splash-display, flex);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    opacity: 1;
    transition: opacity 0.6s ease;
}

#splash-screen.hide {
    opacity: 0;
    pointer-events: none;
}

#splash-logo {
    width: min(200px, 52vw);
    height: min(200px, 52vw);
    object-fit: cover;
    border-radius: 22px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 4px rgba(255,255,255,0.06);
    animation: splashLogoIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#splash-name {
    font-family: Arial, sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
    animation: splashTextIn 0.5s 0.15s ease both;
}

@keyframes splashLogoIn {
    from { opacity: 0; transform: scale(0.82); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes splashTextIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================
   SPACER — spinge storico/social
   in fondo senza spostare la cover
========================= */

.player-spacer {
    flex: 1;
    min-height: 0;
    max-height: 40px;
}

.history-wrap {
    width: 100%;
    max-width: 320px;
    margin-top: 20px;
    animation: fadeUp 0.5s 0.4s ease both;
    flex-shrink: 0;
}

.history-title {
    font-family: Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.4;
    margin-bottom: 12px;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-cover {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    opacity: 0.8;
}

.history-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-track {
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-artist {
    font-family: Arial, sans-serif;
    font-size: 12px;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time {
    font-family: Arial, sans-serif;
    font-size: 11px;
    opacity: 0.4;
    flex-shrink: 0;
}

/* =========================
   SOCIAL
========================= */

.social-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 8px;
    animation: fadeUp 0.5s 0.45s ease both;
    flex-shrink: 0;
}

.social-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.social-btn img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

.social-btn:active {
    transform: scale(0.88);
    opacity: 0.7;
}

/* Bottone playlist — stessa riga dei social */
.playlist-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, opacity 0.2s ease;
    background: none;
    border: none;
    padding: 0;
}

.playlist-btn img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

.playlist-btn:active {
    transform: scale(0.88);
    opacity: 0.7;
}

/* =========================
   PAGINA STORICO
========================= */

.history-page {

    position: absolute;
    inset: 0;
    z-index: 10;

    background: #111111;

    display: flex;
    flex-direction: column;

    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: 24px;
    padding-right: 24px;

    /* Entra da destra */
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-page.open {
    transform: translateX(0);
}

.history-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.history-page-title {
    font-family: Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.history-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease;
}

.history-close-btn::before,
.history-close-btn::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

.history-close-btn::before { transform: rotate(45deg); }
.history-close-btn::after  { transform: rotate(-45deg); }

.history-close-btn:active {
    background: rgba(255,255,255,0.16);
}

.history-page-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
}

.history-page-item {
    display: flex;
    align-items: center;
    gap: 14px;
}

.history-page-cover {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.history-page-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.history-page-track {
    font-family: Arial, sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-page-artist {
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-page-time {
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    flex-shrink: 0;
}

.history-page-empty {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: rgba(255,255,255,0.4);
    text-align: center;
    margin-top: 40px;
}

/* =========================
   LIVE TV PAGE
========================= */

.livetv-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

#livetv-video {
    width: 100%;
    max-height: 75vh;
    border-radius: 12px;
    background: #000;
    display: block;
    /* Permette al video di espandersi in landscape */
    object-fit: contain;
}

/* In landscape il video occupa tutto lo schermo */
@media (orientation: landscape) {

    #livetv-video {
        max-height: 100vh;
        border-radius: 0;
    }

    .history-page-header {
        display: none;
    }
}

.livetv-note {
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: rgba(255,255,255,0.4);
    text-align: center;
}

/* Bottone Live TV — stessa dimensione dei social */
.livetv-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.livetv-btn img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

.livetv-btn:active {
    transform: scale(0.88);
    opacity: 0.7;
}

/* =========================
   HEADER — nome radio + share + menu
========================= */

.player-header {

    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: 16px;
    padding-right: 12px;
    padding-bottom: 10px;

    /* Gradiente per leggibilità sul blur */
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.45) 0%,
        transparent 100%
    );
}

.header-station-name {

    font-family: Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;

    opacity: 0.9;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.header-actions {

    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Pulsanti header — share e menu */
.header-btn {

    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(255,255,255,0.10);
    border: none;
    border-radius: 50%;

    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
}

.header-btn:active {
    background: rgba(255,255,255,0.22);
    transform: scale(0.88);
}

.header-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
    filter: brightness(0) invert(1); /* bianco */
}

/* Tre puntini verticali — stile nativo */
.header-btn-dots {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.header-btn-dots span {
    display: block;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
}



/* =========================
   OVERLAY CONTATTI
========================= */

.contacts-overlay {
    position: fixed;
    inset: 0;
    z-index: 19;
    background: transparent;
    pointer-events: none;
    transition: background 0.3s ease;
}

.contacts-overlay.open {
    background: rgba(0,0,0,0.5);
    pointer-events: all;
}

/* =========================
   PANNELLO CONTATTI
========================= */

.contacts-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: #1c1c1c;
    border-radius: 24px 24px 0 0;
    padding: 12px 24px max(24px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.contacts-panel.open {
    transform: translateY(0);
}

.contacts-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.2);
    margin: 0 auto 16px;
}

.contacts-title {
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
    text-align: center;
}

.contacts-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.06);
    border-radius: 14px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease;
}

.contact-item:active {
    background: rgba(255,255,255,0.12);
}

.contact-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.contact-label {
    font-family: Arial, sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    min-width: 70px;
}

.contact-value {
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
