/* ========================================= */
/* BASE STYLES                             */
/* ========================================= */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    line-height: 1.6;
}
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}
a {
    text-decoration: none;
    color: #007bff;
    transition: color 0.2s;
}
a:hover {
    color: #0056b3;
}
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================= */
/* HEADER & SEARCH BAR                     */
/* ========================================= */
.header {
    background: #fff;
    padding: 15px 0;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header .container.header-container { /* Classe specifica per l'header */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Permette di andare a capo su schermi piccoli */
}
.logo {
    font-size: 1.6em;
    font-weight: 700;
    color: #333;
    flex-shrink: 0; /* Impedisce al logo di rimpicciolirsi */
}
.search-bar {
    width: 350px;
    display: flex;
    align-items: center;
}
.search-bar input {
    flex-grow: 1;
    padding: 8px 12px;
    font-size: 0.95em;
    border: 1px solid #ced4da;
    border-radius: 5px 0 0 5px;
    border-right: none;
    outline: none;
}
.search-bar input:focus {
     border-color: #80bdff;
     box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}
.search-bar button {
    padding: 8px 15px;
    font-size: 0.95em;
    border: 1px solid #007bff;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    border-radius: 0 5px 5px 0;
    transition: background-color 0.2s;
    white-space: nowrap;
}
.search-bar button:hover {
    background-color: #0056b3;
}

/* ========================================= */
/* NAVIGAZIONE (Desktop & Mobile)           */
/* ========================================= */

/* Navigazione Desktop */
.main-nav {
    display: none; /* Nascosta su mobile, mostrata da media query */
}
.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 30px;
}
.main-nav a {
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    font-size: 1.05em;
    padding: 8px 12px;
    border-radius: 6px;
    transition: color 0.2s, background-color 0.2s;
}
.main-nav a:hover {
    color: #007bff;
    background-color: #eef6ff;
}

/* Pulsante Hamburger (Mobile) */
.mobile-nav-toggle {
    display: block; /* Visibile su mobile */
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    z-index: 1100;
    order: 2; /* Dopo il logo */
}
.hamburger-icon {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #333;
    position: relative;
    transition: background-color 0.3s ease-in-out;
}
.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    display: block;
    width: 25px;
    height: 3px;
    background-color: #333;
    position: absolute;
    left: 0;
    transition: transform 0.3s ease-in-out, top 0.3s ease-in-out;
}
.hamburger-icon::before { top: -8px; }
.hamburger-icon::after { top: 8px; }

.mobile-nav-toggle[aria-expanded="true"] .hamburger-icon { background-color: transparent; }
.mobile-nav-toggle[aria-expanded="true"] .hamburger-icon::before { transform: rotate(45deg); top: 0; }
.mobile-nav-toggle[aria-expanded="true"] .hamburger-icon::after { transform: rotate(-45deg); top: 0; }

/* Sidebar Mobile */
.mobile-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background-color: #f8f9fa; /* Sfondo grigino */
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1200;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.mobile-nav.is-open {
    transform: translateX(0);
}
.mobile-nav-header {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mobile-nav-header .logo-mobile {
     font-size: 1.5em;
     font-weight: 700;
     color: #333;
     text-decoration: none;
}
.mobile-nav-close {
    background: none;
    border: none;
    font-size: 2.5em;
    color: #adb5bd;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.mobile-nav-close:hover { color: #333; }
.mobile-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}
.mobile-nav li { margin-bottom: 8px; }
.mobile-nav a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    font-size: 1.1em;
    color: #495057;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}
.mobile-nav a i { /* Stile per icone Feather */
    width: 20px;
    height: 20px;
    stroke-width: 2;
    color: #6c757d;
    transition: color 0.2s;
}
.mobile-nav a:hover {
    background-color: #e9ecef;
    color: #007bff;
}
.mobile-nav a:hover i { color: #007bff; }

/* Overlay Mobile */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1150;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}
.mobile-nav-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Media Query per Desktop (mostra nav, nascondi hamburger) */
@media (min-width: 992px) {
    .main-nav {
        display: block;
        order: 2;
        margin-left: auto;
        margin-right: 30px;
    }
    .mobile-nav-toggle {
        display: none;
    }
    .search-bar {
        order: 3;
        width: 350px;
        margin-top: 0;
    }
    .header .container.header-container {
        flex-wrap: nowrap;
    }
}


/* ========================================= */
/* HERO SECTION (index.php)                */
/* ========================================= */
.hero {
    background: #fff;
    text-align: center;
    padding: 3em 2em;
    border-bottom: 1px solid #e9ecef;
}
.hero h1 {
    font-size: 2.2em;
    margin-top: 0;
    color: #212529;
}
.hero p {
    font-size: 1.1em;
    color: #495057;
    max-width: 750px;
    margin: 1em auto;
    line-height: 1.7;
}

/* ========================================= */
/* SECTIONS & TITLES                       */
/* ========================================= */
.section { padding: 2.5em 0; }
.section-title {
    font-size: 1.8em;
    font-weight: 700;
    color: #333;
    text-align: center;
    margin-bottom: 1.2em;
}
.section-subtitle {
    font-size: 1.4em;
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.5em;
    padding-bottom: 8px;
    border-bottom: 2px solid #007bff;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.section-subtitle a {
    font-size: 0.7em;
    font-weight: 600;
    border: 1px solid #007bff;
    padding: 6px 12px;
    border-radius: 5px;
}
.category-description {
    font-size: 0.95em;
    color: #555;
    margin-top: -0.5em;
    margin-bottom: 1.5em;
    font-style: italic;
}

/* ========================================= */
/* PODCAST CARD STYLES (Generale)          */
/* ========================================= */
.podcast-card {
    display: block;
    white-space: normal;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    color: #333;
}
.podcast-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}
.podcast-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid #eee;
}
.card-content { padding: 12px; }
.card-content h4 {
    margin: 0 0 5px 0;
    font-size: 1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}
.card-content .cat-tag {
    font-size: 0.8em;
    color: #007bff;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}
.card-content .card-desc {
    font-size: 0.85em;
    color: #555;
    line-height: 1.4;
    /* Tronca il testo dopo 3 righe */
    height: calc(1.4em * 3); /* Altezza totale per 3 righe (line-height * numero righe) */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Numero di righe da mostrare */
    -webkit-box-orient: vertical;
    word-break: break-word;
}
/* Rimuovi margini dai <p> interni per un troncamento pulito */
.card-content .card-desc p,
.card-content .card-desc div {
    margin: 0;
    padding: 0;
}


/* ========================================= */
/* GRID LAYOUTS                            */
/* ========================================= */
/* Grid 2 Colonne (per "Podcast a Caso" in index.php) */
.grid-2-col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
}
@media (max-width: 768px) {
    .grid-2-col {
        grid-template-columns: 1fr;
    }
}

/* Grid per Risultati Ricerca & Categoria */
.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}
.search-results-grid .podcast-card img {
    height: 135px;
}
.search-results-grid .podcast-card .card-content h4 {
    font-size: 0.9em;
}
.search-results-grid .podcast-card .card-content .card-desc {
    font-size: 0.8em;
    height: calc(1.4em * 3); /* 3 righe anche qui */
    -webkit-line-clamp: 3;
}

@media (max-width: 576px) {
    .search-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}


/* ========================================= */
/* SLIDERS                                 */
/* ========================================= */
.slider-container {
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px 0 20px 0;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
}
.slider-track {
    display: flex;
    gap: 15px;
}
.slider-track .podcast-card {
    flex: 0 0 220px;
    scroll-snap-align: start;
}

@media (max-width: 768px) {
    .slider-track .podcast-card {
        flex-basis: 65%;
    }
}


/* ========================================= */
/* PODCAST DETAIL PAGE (podcast.php)       */
/* ========================================= */
.podcast-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 25px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
    margin-bottom: 2em;
}
.podcast-header img {
    width: 180px;
    height: 180px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}
.header-info {
    flex: 1;
    min-width: 280px;
}
.header-info h1 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-size: 1.8em;
}
.descrizione-podcast {
    font-size: 0.95em;
    color: #333;
    word-wrap: break-word;
    margin-bottom: 1em;
}
.descrizione-podcast p { margin: 0 0 1em 0; line-height: 1.6; }
.descrizione-podcast a { color: #007bff; text-decoration: underline; }
.descrizione-podcast strong, .descrizione-podcast b { font-weight: 600; }
.descrizione-podcast em, .descrizione-podcast i { font-style: italic; }

.category-tags { margin-top: 10px; }
.tag {
    display: inline-block;
    background-color: #e9ecef;
    color: #495057;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    margin-right: 5px;
    margin-bottom: 5px;
}

.lista-episodi h2 {
    font-size: 1.5em;
    margin-bottom: 1em;
}
.episodio {
    border: 1px solid #e9ecef;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    background-color: #fff;
}
.episodio h3 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-size: 1.1em;
    font-weight: 600;
}
.episodio p {
    font-size: 0.85em;
    color: #6c757d;
    margin-bottom: 1em;
}
audio {
    width: 100%;
    margin-top: 10px;
    height: 40px;
}
.back-link {
    display: inline-block;
    margin-bottom: 15px;
    font-size: 0.9em;
}


/* ========================================= */
/* SUBMIT CTA                              */
/* ========================================= */
.submit-cta {
    background: #007bff;
    color: #fff;
    text-align: center;
    padding: 3em 2em;
    border-radius: 12px;
}
.submit-cta h2 { font-size: 1.8em; margin: 0 0 0.5em 0; }
.submit-cta p { font-size: 1.1em; margin-bottom: 1.5em; }
.submit-cta .btn-white {
    background: #fff;
    color: #007bff;
    padding: 12px 25px;
    border-radius: 5px;
    font-weight: 700;
    font-size: 1.1em;
}


/* ========================================= */
/* TOP 10 LISTS & CHARTS                   */
/* ========================================= */
.top-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}
.chart-column h3 {
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
    margin-bottom: 1em;
    text-align: center;
}
@media (max-width: 992px) {
    .top-charts-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    .chart-column h3 {
        margin-top: 1.5em;
    }
    .top-10-list .rank {
        padding: 0 15px;
        font-size: 1.5em;
    }
}

.top-10-list ol { list-style: none; padding-left: 0; }
.top-10-list li {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 15px;
    overflow: hidden;
}
.top-10-list .rank {
    font-size: 1.8em;
    font-weight: 700;
    color: #007bff;
    padding: 0 25px;
    align-self: center;
}
.top-10-list img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    flex-shrink: 0;
    margin: 10px;
    border-radius: 4px;
}
.top-10-list .info {
    padding: 10px 15px 10px 0;
    flex-grow: 1;
}
.top-10-list .info h4 {
    margin: 0 0 3px 0;
    font-size: 1em;
    font-weight: 600;
    line-height: 1.3;
}
.top-10-list .info span {
    font-size: 0.85em;
    color: #6c757d;
    display: block;
}
.spotify-list .rank { color: #1DB954; } /* Colore verde Spotify */


/* ========================================= */
/* FOOTER                                  */
/* ========================================= */
.footer {
    text-align: center;
    padding: 2em 0;
    margin-top: 2em;
    border-top: 1px solid #e9ecef;
    color: #6c757d;
    font-size: 0.9em;
}
.footer-categories {
    margin: 1.5em auto 2em auto;
    max-width: 900px;
    text-align: center;
}
.footer-categories h3 {
    font-size: 1.1em;
    color: #495057;
    margin-bottom: 1em;
}
.footer-categories .btn-cat {
    display: inline-block;
    text-decoration: none;
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #dee2e6;
    padding: 4px 10px;
    border-radius: 15px;
    margin: 4px;
    font-size: 0.85em;
    transition: all 0.2s;
}
.footer-categories .btn-cat:hover {
    background-color: #dee2e6;
    border-color: #ced4da;
}

/* ========================================= */
/* UTILITY CLASSES                         */
/* ========================================= */
.sr-only {
    border: 0 !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    -webkit-clip-path: inset(50%) !important;
    clip-path: inset(50%) !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
    white-space: nowrap !important;
}
.main-content {
    /* padding-top: 70px; */ /* Decommenta se l'header fisso dà problemi */
}

/* ========================================= */
/* NUOVI STILI (per categories.php)         */
/* ========================================= */

/* Stile per la classifica delle categorie */
.category-chart-list .top-10-list li {
    align-items: center; /* Allinea verticalmente */
}
.category-chart-list .chart-icon-placeholder {
    width: 60px;
    height: 60px;
    margin: 10px;
    border-radius: 4px;
    background-color: #e9ecef; /* Grigio chiaro */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.category-chart-list .chart-icon-placeholder i {
    width: 32px;
    height: 32px;
    color: #6c757d; /* Grigio medio */
    stroke-width: 1.5;
}
.category-chart-list .info span {
    font-size: 0.85em;
    color: #555;
    font-style: italic;
    /* Troncamento per la descrizione */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    max-height: calc(1.4em * 2);
}

/* Stili per le card degli episodi nello slider */
.slider-track .podcast-card .card-content h4.episode-title {
    white-space: normal; /* Permette di andare a capo */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limita a 2 righe */
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Assicura un'altezza minima per 2 righe per allineare le card */
    min-height: calc(1em * 1.4 * 2); /* font-size * line-height * 2 righe */
    font-size: 1em; /* Assicura che sia la dimensione giusta */
    margin-bottom: 5px;
}
.slider-track .podcast-card .card-content .podcast-title-tag {
    font-size: 0.85em;
    color: #555;
    font-weight: 500;
    margin-bottom: 0;
    /* Troncamento per il titolo del podcast */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================= */
/* FIX LAYOUT CARD (HTML "che scappa")     */
/* ========================================= */

.card-content .card-desc {
    font-size: 0.85em;
    color: #555;
    line-height: 1.4;
    
    /* Tronca il testo dopo 3 righe */
    height: calc(1.4em * 3); /* Altezza fissa: line-height * 3 righe */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Limita a 3 righe */
    -webkit-box-orient: vertical;
    word-break: break-word; /* Va a capo se necessario */
}

/* * QUESTA È LA REGOLA CHIAVE:
 * Azzera i margini e i padding di qualsiasi tag <p>, <div>, <ul>, ecc.
 * che si trovi DENTRO la descrizione della card,
 * impedendogli di aggiungere spazi bianchi verticali.
*/
.card-content .card-desc * {
    margin: 0 !important;
    padding: 0 !important;
    display: inline !important; /* Tratta tutto come testo sulla stessa riga */
    line-height: 1.4; /* Mantieni l'interlinea corretta */
}
/* * Eccezione per i <br> per permettergli di andare a capo,
 * ma senza aggiungere spazio extra.
*/
.card-content .card-desc br {
    display: block !important; /* Permette di andare a capo */
    content: "" !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ========================================= */
/* STATS BAR (Homepage)                  */
/* ========================================= */
.stats-bar {
    background-color: #ffffff; /* Sfondo bianco */
    padding: 2em 0;
    border-bottom: 1px solid #e9ecef; /* Separa dal contenuto sotto */
}
.stats-grid-3-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    text-align: center;
}
.stat-item-compact {
    background: #f8f9fa; /* Sfondo grigio chiaro */
    padding: 1.5em 1em;
    border-radius: 8px;
    display: flex; /* Utilizziamo flexbox per allineare icona, numero e label */
    flex-direction: column; /* Impila gli elementi verticalmente */
    align-items: center; /* Centra orizzontalmente */
    justify-content: center; /* Centra verticalmente */
}
.stat-item-compact .stat-icon {
    font-size: 2.5em; /* Dimensione icona */
    color: #007bff; /* Colore blu primario per l'icona */
    margin-bottom: 0.3em; /* Spazio sotto l'icona */
}
.stat-item-compact .stat-number {
    display: block;
    font-size: 2.2em;
    font-weight: 700;
    color: #343a40; /* Colore più scuro per il numero per un buon contrasto */
    line-height: 1.2;
}
.stat-item-compact .stat-label {
    font-size: 0.95em;
    color: #495057;
    font-weight: 500;
    margin-top: 0.2em; /* Piccolo spazio sopra la label */
}

/* Responsive per la stats-bar */
@media (max-width: 768px) {
    .stats-grid-3-col {
        grid-template-columns: 1fr; /* Una colonna su mobile */
    }
    .stats-bar {
        padding: 1.5em 0;
    }
}