@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400&display=swap');
/* ==========================================================================
   VARIABILI E REGOLE GENERALI
   ========================================================================== */
:root {
            --bg-primary: #f8fafc;
            --bg-card: #ffffff;
            --text-main: #1e293b;
            --text-muted: #64748b;
            --accent: #0f766e; 
            --accent-hover: #115e59;
        }
* {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
		
		body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-main);
            line-height: 1.5;
			overflow-x: hidden;
        }
		
/* Reset dei link per renderli coerenti ed eliminare il blu e la sottolineatura standard */
a {
    color: inherit; 
    text-decoration: none; 
    transition: color 0.2s ease; 
}

a:hover {
    color: var(--accent); 
} 
        header {
            background-color: #292c2f;
            border-bottom: 1px solid #e2e8f0;
            position: sticky;
            top: 0;
            z-index: 100;
            width: 100%;
       }

      .nav-container {
     max-width: var(--max-width);
     margin: 0 auto;
     padding: 1rem 2rem;
     display: flex;
     justify-content: space-between;
     align-items: center;
     gap: 1rem; 
     /* Modifiche per il mobile */
     flex-wrap: nowrap; /* Impedisce agli elementi di andare a capo */
}

/* Opzionale: ottimizzazione padding per schermi molto piccoli */
@media (max-width: 480px) {
    .nav-container {
        padding: 1rem; /* Riduce il padding laterale per guadagnare spazio */
    }
}
      .logo {
          font-size: 1.3rem;
          font-weight: 300;
          cursor: pointer;
          text-decoration: none;
          background: linear-gradient(to bottom, #cfc09f 27%, #ffecb3 40%, #8A6E2F 78%);    
         /* 2. Ritaglia lo sfondo seguendo il contorno delle lettere */
         -webkit-background-clip: text;
         background-clip: text;    
         /* 3. Rende il colore nativo del testo trasparente per mostrare il gradiente sotto */
         -webkit-text-fill-color: transparent;
         color: transparent; 
      }

       main {
          max-width: var(--max-width);
          margin: 2rem auto;
          padding: 0 2rem;
          min-height: 70vh;
      }

     .hero-section {
         text-align: center;
         margin-bottom: 3rem;
         padding: 0 1rem; /* Aggiunge un margine interno per non far toccare i bordi dello schermo su mobile */
     }

    .hero-section h1 {
        font-size: clamp(1.25rem, 5vw, 2.5rem); /* Dimensione dinamica: minimo 1.25rem, massimo 2.5rem */
        margin-bottom: 0.75rem;
        color: var(--text-main);
        line-height: 1.2; /* Riduce l'interlinea per evitare troppo spazio tra le parole se vanno a capo */
     }

    .hero-section p {
       color: var(--text-muted);
       font-size: clamp(0.95rem, 3vw, 1.15rem); /* Anche il sottotitolo si adatta fluidamente */
       max-width: 600px; /* Evita che le righe di testo diventino troppo lunghe e stancanti da leggere su PC */
       margin: 0 auto; /* Centra il paragrafo dopo aver impostato la larghezza massima */
     }
	 
	 .hero-section i {
       color: #ff111f;
     }

/* ==========================================================================
  STRUTTURA FLUIDA PRINCIPALE (LAYOUT)
   ========================================================================== */
.layout-container {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    margin-top: 2rem;
}

/* Colonna verticale delle Categorie */
.sidebar-categories {
    flex: 0 0 160px;
    min-width: 160px;
}

.sidebar-categories h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-main);
}

.sidebar-categories ul {
    list-style: none;
    padding: 0;
    margin: 0;
    line-height: 2;
}

/* Griglia dei giochi fluida e responsive */
.games-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
    gap: 1.5rem;
    justify-content: start;
} 

/* ==========================================================================
   SCHEDE GIOCO (GAME CARDS)
   ========================================================================== */
.game-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    width: 100%;             
    max-width: 290px;       
    height: 368.4px;         
    display: flex;
    flex-direction: column;     
    animation: fadeIn 0.3s ease-in-out;
}


.game-card {
    position: relative; /* Necessario per posizionare il cuore */
}

.btn-favorite {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.85);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s, color 0.2s;
    color: #6c757d;
}

.btn-favorite:hover {
    transform: scale(1.1);
}

/* Stato quando il gioco è salvato nei preferiti */
.btn-favorite.is-favorite {
    color: #e11d48 !important; /* Colore rosso */
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.game-card.hidden { display: none !important; }

.card-image {
    width: 100%;
    height: 180px;
    background-color: #cbd5e1; 
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: bold;
    background-size: cover;
    background-position: center;
}

.card-content {
    padding: 1.25rem;
    flex: 1;                        
    display: flex;
    flex-direction: column;
    justify-content: space-between;  
    overflow: hidden;
}

/* === NUOVO CONTENITORE: Affianca categoria e badge sulla stessa riga === */
.card-header-meta {
    display: flex;
    justify-content: space-between; /* Spinge la categoria a sinistra e il bollino a destra */
    align-items: center;            /* Li allinea geometricamente al centro in verticale */
    margin-bottom: 0.25rem;         /* Crea lo stacco corretto prima del titolo */
}

.card-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.05em;
    margin-bottom: 0;               /* Azzerato per non rompere l'allineamento flex */
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 4;           
    -webkit-box-orient: vertical;
    overflow: hidden;                
    text-overflow: ellipsis;        
}

/* === BADGE OTTIMIZZATO: Più piccolo e integrato in alto === */
.badge-feature {
    display: inline-block;
    background-color: #f0fdf4;  
    color: #16a34a;             
    font-size: 0.65rem;             /* Ridotto per essere discreto e raffinato */
    font-weight: 700;               /* Più marcato per compensare la dimensione */
    padding: 0.15rem 0.5rem;        /* Meno spessore per renderlo compatto */
    border-radius: 30px;        
    border: 1px solid #bbf7d0;  
    text-transform: uppercase;  
    letter-spacing: 0.02em;
    line-height: 1;                 /* Impedisce al testo di ereditare altezze strane */
}


/* Animazione di dissolvenza morbida all'apertura */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   SCHERMATA DI GIOCO (OVERLAY)
   ========================================================================== */
.game-view {
    /* La struttura principale viene gestita in linea dal JS per isolarla dal layout */
    font-family: inherit;
}

/* Il titolo del gioco sopra l'iframe (Stile Desktop standard) */
#game-title {
    color: #ffffff;
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* ─── I DUE BOTTONI STRUTTURALI (Identici e Speculari) ─── */
.btn-back,
.iframe-container .btn-fullscreen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e293b; 
    border: 1px solid #334155;
    color: #f8fafc; 
    cursor: pointer;
    border-radius: 50%;
    padding: 0;          
    
    /* Dimensioni identiche perfette per entrambi */
    width: 48px;         
    height: 48px;        
    
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    box-sizing: border-box;
    position: fixed; /* Entrambi fissi rispetto allo schermo */
    z-index: 999;    
}

/* Assegnazione icone e posizionamento speculare (Top: 20px per entrambi) */
.btn-back {
    font-size: 1.6rem;   
    top: 20px;         
    left: 20px; /* Angolo Sinistro */
}

.iframe-container .btn-fullscreen {
    font-size: 1.2rem; /* Icona compress/expand proporzionata */
    top: 20px;         
    right: 20px; /* Angolo Destro speculare */
}

.btn-back:hover,
.iframe-container .btn-fullscreen:hover {
    background: #334155;
    color: #ffffff;
    transform: scale(1.05); 
}

/* Contenitore responsive (Proporzioni nativo per monitor grandi) */
.iframe-container {
    position: relative;
    width: 100%;
    max-width: 1280px; 
    margin: 0 auto;
    padding-bottom: 56.25%; /* Rapporto nativo cinematografico 16:9 su PC */
    height: 0;
    overflow: hidden;
    background-color: #000000;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0;
}

/* ─── CORREZIONE BUG RIMICCIOLIMENTO IN FULLSCREEN ─── */
.iframe-container:fullscreen {
    max-width: 100% !important;
    width: 100vw !important;
    height: 100vh !important;
    padding-bottom: 0 !important; 
    border-radius: 0 !important;  
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #000000 !important; 
}

.iframe-container:-webkit-full-screen {
    max-width: 100% !important;
    width: 100vw !important;
    height: 100vh !important;
    padding-bottom: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #000000 !important;
}

/* Mantiene stabile e centrato l'iframe durante il tutto schermo */
.iframe-container:fullscreen iframe,
.iframe-container:-webkit-full-screen iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Massima priorità ai bottoni quando il tutto schermo è attivo */
.iframe-container:fullscreen .btn-fullscreen,
.iframe-container:-webkit-full-screen .btn-fullscreen {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 2147483647 !important; 
}

/* ==========================================================================
   5. FOOTER
   ========================================================================== */
footer {
    background-color: var(--bg-card);
    border-top: 1px solid #e2e8f0;
    padding: 2.5rem 2rem;
    margin-top: 5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

/* ==========================================================================
   6. MEDIA QUERIES RESPONSIVE (ORDINATE DALLA PIÙ GRANDE ALLA PIÙ PICCOLA)
   ========================================================================== */

/* Monitor medi e portatili (Larghezza fino a 1360px) */
@media (max-width: 1360px) {
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(275px, 1fr)); 
        width: 100%;
    }
    .game-card {
        width: 100%; 
    }
}

/* ==========================================================================
   VERSIONE MOBILE & TABLET (CANCELLAZIONE TOTALE SPAZI VUOTI)
   ========================================================================== */
@media (max-width: 768px) {
    .layout-container {
        flex-direction: column;
        gap: 1.5rem;
    }
    .sidebar-categories {
        width: 100%;
        min-width: 100%;
    }
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    
    /* ─── CANCELLAZIONE SPAZIO BORDI SU MOBILE ─── */
    .game-view {
        display: none; 
        width: auto !important;
        max-width: none !important;
        margin-left: -2rem !important; 
        margin-right: -2rem !important; 
        margin-top: -2rem !important; 
        padding: 0 !important; 
    }
    
    #game-title {
        display: none !important; 
    }

    /* IL GIOCO DIVENTA UNA VERA APP A SCHERMO INTERO */
    .iframe-container {
        padding-bottom: 0 !important; 
        height: 100vh !important; 
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important; 
        margin: 0 !important;
    }

    /* ─── ADATTAMENTO SIMMETRICO DEI BOTTONI SU MOBILE (Sotto i 768px - INVARIATI) ─── */
    .btn-back,
    .iframe-container .btn-fullscreen {
        width: 30px !important;        
        height: 30px !important;       
        top: 5px !important;           
    }
    
    .btn-back {
        font-size: 1.3rem !important;  
        left: 5px !important;          
    }
    
    .iframe-container .btn-fullscreen {
        font-size: 0.9rem !important;  
        right: 5px !important;         
    }
}

/* Protezione specifica per smartphone ruotati in orizzontale (Landscape - INVARIATI) */
@media (max-height: 480px) and (orientation: landscape) {
    .iframe-container {
        height: 100vh !important; 
        width: 100% !important;
        padding-bottom: 0 !important;
    }
    
    .btn-back,
    .iframe-container .btn-fullscreen {
        top: 8px !important;
        width: 28px !important;
        height: 28px !important;
    }
    .btn-back { left: 8px !important; font-size: 1.1rem !important; }
    .iframe-container .btn-fullscreen { right: 8px !important; font-size: 0.8rem !important; }
}

/* ==========================================================================
   UNIFORMAZIONE COMPORTAMENTO ADATTIVO GIOCHI LOCALI
   ========================================================================== */

/* Gestione su PC Desktop (Sopra i 768px) */
@media (min-width: 768px) {
    .iframe-container.local-game-container {
        width: 100% !important;
        max-width: 1100px !important;
        height: auto !important;
        aspect-ratio: 16 / 9 !important; /* Uniformato in formato widescreen standard */
        padding-bottom: 0 !important;   
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background-color: #000000 !important;
        overflow: hidden !important;
    }

    /* Rimosse le gabbie fisse da 1000x700, zoom e spostamenti negativi.
       Ora l'iframe locale occupa fluidamente il 100% dello spazio esatto, clonando GamePix. */
    .iframe-container iframe:not([src*="gamepix.com"]) {
        position: relative !important;
        width: 100% !important;  
        height: 100% !important;  
        border: none !important;
        top: 0 !important;
        left: 0 !important;
        margin-top: 0 !important;  
        margin-left: 0 !important; 
        transform: none !important;
    }

    /* Comportamento Fullscreen unificato al 100% di larghezza e altezza dello schermo */
    .iframe-container:fullscreen iframe:not([src*="gamepix.com"]),
    .iframe-container:-webkit-full-screen iframe:not([src*="gamepix.com"]) {
        transform: none !important;
        width: 100vw !important;
        height: 100vh !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        margin-top: 0 !important; 
        margin-left: 0 !important;
    }
}

/* Gestione su Smartphone Mobile (Sotto i 768px di larghezza) */
@media (max-width: 767px) {
    body #game-view .iframe-container {
        padding-bottom: 0 !important;
        height: 100vh !important; 
        width: 100vw !important;  
        display: flex !important;
        align-items: center !important;     
        justify-content: center !important;   
        background-color: #000000 !important;
        overflow: hidden !important;
        margin: 0 !important;
    }

    /* Anche su mobile raddrizziamo l'iframe locale togliendo i blocchi rigidi */
    .iframe-container iframe:not([src*="gamepix.com"]) {
        position: relative !important;
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        margin-top: 0 !important;
        margin-left: 0 !important;
        border: none !important;
    }
}

/* Mobile ::END:: */
              /* === CONTENITORE PAGINAZIONE RESPONSIVE === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 40px 0;
    flex-wrap: wrap; /* Permette ai bottoni di andare a capo se lo spazio finisce */
}

/* === STILE BOTTONI === */
.pagination button {
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    background-color: #ffffff;
    color: #333333;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Effetto al passaggio del mouse */
.pagination button:hover:not(:disabled) {
    background-color: #f4f4f4;
    border-color: #b5b5b5;
}

/* Bottone della pagina attiva */
.pagination button.active {
    background-color: #007BFF;
    color: #ffffff;
    border-color: #007BFF;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.25);
}

/* Stile per i puntini di sospensione (...) */
.pagination .dots {
    min-width: 32px;
    text-align: center;
    color: #888;
    font-weight: bold;
    user-select: none;
}

/* Bottoni disabilitati (es. freccia indietro sulla pagina 1) */
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #f9f9f9;
}

/* Nasconde le scritte delle frecce sui telefoni molto piccoli, lasciando solo i simboli */
@media (max-width: 480px) {
    .pagination button {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
} /* === CONTENITORE PAGINAZIONE RESPONSIVE ==FINE== */
/* Back to top button */
#btn-back-to-top {
  position: fixed;
  z-index: 9999; 
  display: none;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 12px 9px 12px;
  font-size: 16px;
  align-content: center;
  border-radius: 2px;
  max-width: 40px;
  right: 15px;
  bottom: 15px;
  transition: background 0.5s;
  cursor: pointer; 
}

@media (max-width: 768px) {
  #btn-back-to-top {
    bottom: 15px;
  }
}

#btn-back-to-top:focus {
  background: #880005;
  color: #fff;
  outline: none;
}

#btn-back-to-top:hover {
  background: rgba(255, 90, 90, 0.9);
  color: #fff;
}
/* Back to top button --END--*/


