/**
 * Stylesheet principale - Landing Page DEM
 * 
 * Approccio: Mobile-first, Flexbox/Grid, CSS Custom Properties
 * Font: SF Pro Display configurato con file .otf locali
 * 
 * Struttura:
 * 1. Font-face e Reset
 * 2. Variabili CSS
 * 3. Layout base
 * 4. Componenti
 * 5. Media queries
 */

/* ==========================================================================
   1. Font-face declarations
   ========================================================================== */

/* SF Pro Display - Regular */
@font-face {
    font-family: 'SF Pro Display';
    src: url('../fonts/SF-Pro-Display-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap; /* Migliora performance caricamento */
}

/* SF Pro Display - Medium */
@font-face {
    font-family: 'SF Pro Display';
    src: url('../fonts/SF-Pro-Display-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* SF Pro Display - Semibold */
@font-face {
    font-family: 'SF Pro Display';
    src: url('../fonts/SF-Pro-Display-Semibold.otf') format('opentype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* SF Pro Display - Bold */
@font-face {
    font-family: 'SF Pro Display';
    src: url('../fonts/SF-Pro-Display-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* SF Pro Display - Light (opzionale) */
@font-face {
    font-family: 'SF Pro Display';
    src: url('../fonts/SF-Pro-Display-Light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   Reset e box-sizing
   ========================================================================== */

/* Reset minimo + box-sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   2. Variabili CSS
   ========================================================================== */

/* Variabili globali */
:root {
    /* Font - Aggiornato con SF Pro Display */
    --brand-font: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Colori */
    --color-primary: #1a73e8;
    --color-secondary: #34a853;
    --color-text: #202124;
    --color-text-light: #5f6368;
    --color-bg: #ffffff;
    --color-bg-alt: #f8f9fa;
    --color-border: #dadce0;
    
    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 0.5rem;/*2rem;*/
    --space-xl: 3rem;
    
    /* Typography */
    --font-size-base: 16px;
    --line-height-base: 1.5;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.3);
    --shadow-md: 0 2px 6px 2px rgba(60,64,67,0.15);
    
    /* Animations */
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   2. Layout Base
   ========================================================================== */

html {
    font-size: var(--font-size-base);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--brand-font);
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    overflow-x: hidden;
    /* Previeni scroll orizzontale */
    margin: 0;
    padding: 0;
}

/* Background full-screen con ::before */
.page-wrapper {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Previeni scroll orizzontale dal footer */
}

.page-wrapper::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/background.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 1; /* Opacità piena per vedere i colori */
    z-index: -1;
    will-change: transform; /* Ottimizzazione performance */
}

/* Header - trasparente per far vedere il background */
.site-header {
    padding: var(--space-lg) var(--space-sm);
    text-align: center;
    background-color: transparent; /* Trasparente per mostrare background */
    position: relative; /* Cambiato da sticky per evitare sovrapposizioni */
    z-index: 100;
}

.logo {
    max-width: 200px;/*200px;*/
    height: auto;
    display: inline-block;
    /* Aggiungi ombra per far risaltare logo bianco su sfondo colorato */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Main content - sfondo semi-trasparente per leggibilità */
.main-content {
    flex: 1;
    padding: var(--space-lg) var(--space-sm);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 10;
}

/* Sezioni con sfondo per contrasto */
.video-section,
.podcast-section {
    background-color: rgba(255, 255, 255, 0.9);
    padding: var(--space-lg);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-xl);
}

/* Footer - sfondo semi-trasparente */
.site-footer {
    padding: var(--space-md);
    text-align: center;
    color: var(--color-text-light);
    background-color: rgba(248, 249, 250, 0.9);
    backdrop-filter: blur(10px);
    margin-top: auto;
    position: relative;
    z-index: 10;
    /* Fix per footer sempre 100% larghezza viewport */
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: 0;
    box-sizing: border-box;
}

/* ==========================================================================
   3. Componenti
   ========================================================================== */

/* Titoli sezioni */
.section-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 600;
    margin-bottom: var(--space-md);
    text-align: center;
    color: #fff; /*var(--color-primary);*/
}

/* Content Section - Nuovo layout per coppie trailer+episodio */
.content-section {
    margin-bottom: var(--space-xl);
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-lg);
}

/* Stile speciale quando c'è un solo episodio */
.content-grid.single-item {
    grid-template-columns: 1fr;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Content Group - Contenitore per trailer + episodio */
.content-group {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(218, 220, 224, 0.8);
    border-radius: 12px;
    padding: var(--space-lg);
    transition: var(--transition-base);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.content-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.group-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--color-primary);
    text-align: center;
}

/* Video container dentro il gruppo */
.group-video-container {
    position: relative;
    width: 100%;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
}

.group-video-player {
    width: 100%;
    height: auto;
    display: block;
}

/* Divisore visuale */
.content-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--color-border), transparent);
    margin: var(--space-md) 0;
}

/* Audio container nel gruppo */
.group-audio-container {
    background-color: rgba(248, 249, 250, 0.8);
    padding: var(--space-sm);
    border-radius: 8px;
}

.audio-label {
    font-size: 1.25rem;/*0.875rem;*/
    color: var(--color-text-light);
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

/* Rimuovi stili vecchi non più necessari */
.video-section,
.podcast-section {
    background-color: rgba(255, 255, 255, 0.9);
    padding: var(--space-lg);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-xl);
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.video-player {
    width: 100%;
    height: auto;
    display: block;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

/* Episode Card - migliore contrasto su background colorato */
.episode-card {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(218, 220, 224, 0.8);
    border-radius: 8px;
    padding: var(--space-md);
    transition: var(--transition-base);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.episode-card:hover,
.episode-card:focus-within {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.episode-number {
    font-size: 0.875rem;
    color: var(--color-text-light);
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.episode-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.audio-player {
    width: 100%;
    margin-top: var(--space-sm);
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    grid-column: 1 / -1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: var(--space-sm);
    color: var(--color-text-light);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error state */
.error-message {
    grid-column: 1 / -1;
    padding: var(--space-lg);
    text-align: center;
    color: #d93025;
    background-color: #fce8e6;
    border-radius: 8px;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles */
:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   4. Media Queries
   ========================================================================== */

/* Fix footer per schermi molto piccoli */
@media (max-width: 360px) {
    /* Rimuovi padding orizzontale dal wrapper e body */
    body {
        padding: 0;
        margin: 0;
        width: 100vw;
        overflow-x: hidden;
    }
    
    .page-wrapper {
        padding: 0;
        margin: 0;
        width: 100%;
        overflow-x: hidden;
    }
    
    /* Footer a larghezza piena viewport */
    .site-footer {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
        width: 100vw;
        margin-left: 0;
        left: 0;
        position: relative;
    }
    
    /* Aggiusta anche il main content */
    .main-content {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
    }
    
    /* Riduci padding header */
    .site-header {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
    }
    
    /* Griglia con minimo più piccolo per schermi tiny */
    .content-grid {
        grid-template-columns: 1fr;
        padding: 0 var(--space-xs);
    }
}

/* Media queries aggiornati per content groups */
@media (min-width: 768px) {
    .site-header {
        padding: var(--space-lg) var(--space-md);
    }
    
    .main-content {
        padding: var(--space-xl) var(--space-md);
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
        gap: var(--space-xl);
    }
    
    /* Mantieni singola colonna centrata anche su tablet quando c'è un solo item */
    .content-grid.single-item {
        grid-template-columns: 1fr;
        max-width: 700px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    }
    
    .content-group {
        padding: var(--space-xl);
    }
    
    /* Su desktop, il singolo item può essere leggermente più largo */
    .content-grid.single-item {
        max-width: 800px;
    }
}

/* Preferenze utente */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode (opzionale) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-text: #e8eaed;
        --color-text-light: #9aa0a6;
        --color-bg: #202124;
        --color-bg-alt: #303134;
        --color-border: #5f6368;
    }
    
    .page-wrapper::before {
        opacity: 0.05;
    }
    
    .site-header {
        background-color: rgba(32, 33, 36, 0.95);
    }
    
    .episode-card {
        background-color: var(--color-bg-alt);
    }
}

/* Print styles */
@media print {
    .video-container,
    .audio-player {
        display: none;
    }
    
    .page-wrapper::before {
        display: none;
    }
}