@charset "UTF-8";

/* ============================================
   1. CARICAMENTO FONT
   ============================================ */
@font-face {
    font-family: 'JetBrainsMono';
    src: url('./Fonts/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Regular.woff2') format('woff2'),
         url('./Fonts/JetBrainsMono-2.304/fonts/webfonts/JetBrainsMono-Regular.woff') format('woff'),
         url('./Fonts/JetBrainsMono-2.304/fonts/ttf/JetBrainsMono-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   2. REGOLE GENERALI (RESET)
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ============================================
   3. BODY INDEX
   ============================================ */
body.index-body {
    background-image: url('IMG/SmokingNoSmoking_Artwork_copia.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* ============================================
   4. LA GRIGLIA - RESPONSIVE
   ============================================ */
.grid-container {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 180px));
    justify-content: center;
    max-width: 100%;
}

/* ============================================
   5. I SINGOLI BOX (RIPRISTINO BANDIERE E TESTO)
   ============================================ */
.grid-item {
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: 'JetBrainsMono', Courier, monospace !important;
    font-size: clamp(18px, 0.5vw + 23px, 34px);
    border-radius: 35px;
    text-align: center;
    line-height: 1.1;
    padding: 15px;
    cursor: pointer;
    text-decoration: none !important; /* Rimosso sottolineatura */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden; /* Fondamentale per le bandiere */
    background-color: #4caf22;
}

/* Fix Bandiere: devono coprire tutto il box */
.grid-item.with-image {
    background-color: #fff !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    padding: 0 !important; /* Le bandiere non devono avere padding interno */
}

.grid-item:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Assicuriamoci che i link della Home non diventino blu o viola */
.grid-item, .grid-item:visited, .grid-item:active {
    color: white !important;
    text-decoration: none !important;
}

/* ============================================
   6. PAGINE SECONDARIE (non index)
   ============================================ */
body:not(.index-body) {
    background-color: #ffffff;
    font-family: 'Atwriter', Courier, monospace !important;
    color: #000000;
    padding: 20px;
    line-height: 1.5;
}

/* ============================================
   7. PAGINA DOMAINS
   ============================================ */
.domains-body {
    background-image: url('IMG/SmokingNoSmoking.svg');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ============================================
    8. POPUP - CONFIGURAZIONE FISSA (DESKTOP)
   ============================================ */
.popup-container {
    position: fixed;
    top: 50%; 
    left: 50%;
    transform: translate(-50%, -50%); 
    z-index: 11000;
    width: 615px; 
    height: 90vh;
    display: none;
    overflow: visible;
    background: transparent;
}

/* Gestione Pulsanti - Forza lo z-index e la posizione */
.pannello .resize-btn, 
.pannello .close-popup-btn {
    position: absolute !important; 
    top: 20px !important; /* Leggermente più su per sicurezza */
    z-index: 99999 !important; /* Valore altissimo per stare sopra il contenuto */
    width: 38px; height: 38px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: flex !important; 
    justify-content: center; align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* Nasconde il resize del Pannello 1 se ci sono altri pannelli aperti */
.popup-container:has(.pannello[data-empty="false"]:not(#pannello1)) #pannello1 .resize-btn {
    display: none !important;
}

.pannello .resize-btn { 
    left: 20px !important; 
    background-color: #4caf22 !important; 
    color: #fff !important; 
}

.pannello .close-popup-btn { 
    right: 20px !important; 
    background-color: #ff0000 !important; 
    color: #fff !important; 
}

#popupContent {
    display: grid !important;
    width: 100%; 
    height: 100%;
    gap: 15px;
    padding: 10px;
    box-sizing: border-box;
    grid-template-columns: 1fr;
}

/* Espansione per pannelli 2, 3 o 4 */
.popup-container:has(.pannello[data-empty="false"]:not(#pannello1)) { 
    width: 1230px; 
}

.popup-container:has(.pannello[data-empty="false"]:not(#pannello1)) #popupContent { 
    grid-template-columns: 1fr 1fr !important; 
}

/* ============================================
    8b. LOGICA PANNELLI (STRUTTURA UNIFICATA)
   ============================================ */

.pannello[data-empty="false"] {
    display: flex !important;
    flex-direction: column;
    height: 100% !important; 
    min-height: 0;
    background: #ffffff;
    border: 2px solid #000;
    border-radius: 15px;
    position: relative !important; /* Forza il riferimento per i bottoni */
    overflow-y: auto !important; /* Permette lo scroll interno */
    scrollbar-width: none;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    
    /* Aumentato il padding per spingere giù il contenuto ed evitare sovrapposizioni */
    padding-top: 70px !important; 
    box-sizing: border-box;
}

/* SICUREZZA: Forza il primo elemento interno al pannello a rispettare il margine */
.pannello[data-empty="false"] > *:first-child {
    margin-top: 0 !important;
}

.pannello::-webkit-scrollbar {
    display: none;
}

/* ============================================
    9. I PANNELLI (STILE CONSERVATO)
   ============================================ */
.pannello {
    position: relative; 
    background: white;
    border: 2px solid #000;
    border-radius: 15px;
    padding: 60px 45px 20px 45px; 
    box-sizing: border-box;
    overflow-y: auto;
    font-family: 'Atwriter', Courier, monospace !important;
    font-size: 22px;
    line-height: 1.2;
    color: #000;
    white-space: pre-wrap;
    scrollbar-width: none;
    display: flex;  /* FLEXBOX per controllare l'allineamento verticale del contenuto */
    flex-direction: column;
    justify-content: flex-start; 
}

.pannello::-webkit-scrollbar { width: 0; height: 0; }

.pannello[data-empty="true"] {
    display: none !important;
}

/* ============================================
   10. ELENCO E LINK (STILE CONSERVATO)
   ============================================ */
#Elenco-IT, #Elenco-EN {
    
    margin-top: 80px !important; 
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    text-align: center;
}

.ricetta-body {
    margin-top: -140px !important; /* Regola questo valore: più è negativo, più sale */
}

.link-ricetta {
    color: #0000ee !important;
    width: 100%;
    text-align: center;
    text-decoration: none;
    display: block;
    margin: 10px 0;
    transition: color 0.2s ease;
}

.link-ricetta:hover {
    color: #ff0000 !important;
    text-decoration: underline;
}

/* ============================================
    11. MEDIA QUERY - MOBILE (max 600px)
   ============================================ */
@media (max-width: 600px) {
    
    html, body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }    

    .grid-container,
    .ricette-body .grid-container, 
    .domains-body .grid-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr); 
        padding: 10px;
        gap: 12px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .grid-item {
        aspect-ratio: 1 / 1;
        font-size: 28px;
        border-radius: 25px;
        padding: 12px;
        max-width: none;
    }

    .popup-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        transform: none !important;
        background: transparent !important;
        border: none;
        z-index: 9999;
        overflow: hidden; 
        display: none;
        pointer-events: none;
    }

    .popup-container:has(.pannello[data-empty="false"]) {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        pointer-events: auto !important; 
    }

    #popupContent {
        display: grid !important; 
        grid-template-columns: 1fr !important;
        grid-template-rows: repeat(auto-fit, minmax(0, 1fr)) !important;
        gap: 15px;
        width: 100% !important;
        height: 92vh !important; 
        margin: 0 !important;
        padding: 15px !important;
        box-sizing: border-box;
        transition: grid-template-rows 0.3s ease;
    }
    
    .popup-container.doppio #popupContent {
        grid-template-rows: 1fr 1fr !important;
    }

    .popup-container.full-screen #popupContent {
        grid-template-rows: 0fr 1fr !important;
        gap: 0;
    }

    .popup-container.full-screen #pannello1 {
        display: none !important;
    }

       /* HEADER FISSO PER TASTI (Mobile) */
    
    .header-pannello {
        position: sticky;
        top: 0;
        left: 0;
        width: calc(100% + 55px); 
        height: 50px;
        background: transparent !important; 
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 15px;
        z-index: 10020;
        border-bottom: none !important;
        margin-top: -20px; 
        margin-left: -35px;
        margin-bottom: 10px;
        border-radius: 13px 13px 0 0; 
        pointer-events: none; /* Il tocco passa attraverso il box trasparente */
    }

    /* RESET DELLA X SOLO PER MOBILE HEADER */
    .header-pannello .close-popup-btn {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        margin: 0 !important;
        align-self: center !important;
        flex-shrink: 0;
        pointer-events: auto !important; /* Riattiva il clic sulla X */
    }

    /* PULSANTE RESIZE (Mobile) */
    .resize-btn {
        position: relative;
        width: 34px;
        height: 34px;
        background: #4caf50;
        color: #fff;
        border: 1px solid #fff;
        border-radius: 6px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 24px;
        cursor: pointer;
        line-height: 1;
        z-index: 10021;
        margin-left: 15px;
        pointer-events: auto !important; /* Riattiva il clic sul Resize */
    }

    .pannello {
        width: 100% !important;
        height: 100% !important; 
        background: white !important;
        border: 2px solid #000 !important;
        border-radius: 25px !important; 
        display: block;
        padding: 20px 20px 20px 35px !important; 
        box-sizing: border-box;
        overflow-y: auto;
        overflow-x: hidden;
        font-family: 'Atwriter', Courier, monospace !important;
        font-size: 18px;
        line-height: 1.1; 
        color: black !important;
        white-space: pre-wrap;
        scrollbar-width: none;
        position: relative;
    }
    
    .pannello::-webkit-scrollbar { display: none; }

    #Elenco-IT, #Elenco-EN {
        margin-top: 10px !important; 
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .link-ricetta {
        color: #0000ee !important;
        position: relative;
        width: 100%;
        text-align: center;
        text-decoration: none;
        display: block;
        margin: 4px 0;
        font-size: 20px;
        cursor: pointer !important;
        padding: 12px 5px;
        z-index: 10010;
        pointer-events: auto !important;
        -webkit-tap-highlight-color: transparent;
    }
    
    #pannello2[data-empty="false"] {
        display: block !important;
    }

    .pannello[data-empty="true"],
    .pannello:nth-child(n+3) {
        display: none !important;
    }

    .popup-overlay:not([style*="display: block"]) {
        display: none !important;
    }

    .popup-container:not(:has(.pannello[data-empty="false"])) {
        display: none !important;
        height: 0 !important;
        pointer-events: none !important;
    }
}

/* ============================================
    12. MEDIA QUERY - MOBILE SMALL (max 480px)
   ============================================ */
@media (max-width: 480px) {
    .grid-container,
    .ricette-body .grid-container,
    .domains-body .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }

    .grid-item {
        font-size: 21px;
        border-radius: 12px;
    }

    .popup-container {
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        background: rgba(0,0,0,0.6);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    #popupContent {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px;
        width: 100%;
        margin: auto;
        padding: 40px 6px 120px 6px;
        box-sizing: border-box;
    }

    .pannello {
        width: 95%;
        height: auto;
        background: white !important;
        border: 2px solid #000 !important;
        border-radius: 20px;
        padding: 20px 15px !important;
        box-sizing: border-box;
        font-family: 'Atwriter', Courier, monospace !important;
        font-size: 16px;
        line-height: 1.3;
        white-space: pre-wrap;
        overflow-wrap: break-word;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .pannello *, .content-wrapper * {
        font-family: 'Atwriter', Courier, monospace !important;
        margin-top: 0 !important;
        text-align: center;
    }

    #Elenco-IT, #Elenco-EN {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .link-ricetta {
        font-size: 18px;
        margin: 12px 0;
        color: #0000ee !important;
        text-decoration: underline;
    }

    #pannello2 {
        display: none !important;
        margin-left: 0 !important;
    }

    .popup-container.doppio #pannello2 {
        display: flex !important;
    }

    .popup-container::-webkit-scrollbar { display: none; }

    /* Fix per la X in mobile 480px */
    .close-popup-btn {
        margin-bottom: -30px;
    }
}

/* ============================================
   13. DARK MODE (PULIZIA INTERFERENZE)
   ============================================ */
@media (prefers-color-scheme: dark) {
    body.index-body { background-color: #121212; }
    
    /* Box della Home: NO sottolineatura, testo bianco */
    .grid-item {
        background-color: #1e1e1e;
        border: 1px solid #333;
        color: #ffffff !important;
    }
    
    .popup-container, .pannello {
        background-color: #1e1e1e !important;
        color: #e0e0e0 !important;
        border-color: #444 !important;
    }

    /* Solo i link dentro il popup cambiano colore, non quelli della home */
    .link-ricetta { color: #bb86fc !important; }
    .link-ricetta:hover { color: #cf6679 !important; }
}

/* ==========================================================================
   14. CREDITS: - MAX VURRO per la struttura di partenza del codice, Gemini, CoPilot per le implementazioni, anche quelle inutili
   ========================================================================= */
