@charset "UTF-8";

/* ============================================
   0. VARIABILI GLOBALI
   ============================================ */
:root {
    --header-pannello-height: 54px;
    --mobile-header-height: 46px;
    --resize-duration: 0.4s;
    --resize-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --espanso-z: 50;
}

/* ============================================
   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. 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;
    min-height: 100dvh;
    padding: 20px;
}

/* ============================================
   4. GRIGLIA
   ============================================ */
.grid-container {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 180px));
    justify-content: center;
    max-width: 100%;
}

/* ============================================
   5. BOX GRIGLIA
   ============================================ */
.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;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    background-color: #4caf22;
}

.grid-item.with-image {
    background-color: #fff !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    padding: 0 !important;
}

.grid-item:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.grid-item, .grid-item:visited, .grid-item:active {
    color: white !important;
    text-decoration: none !important;
}

/* ============================================
   6. PAGINE SECONDARIE
   ============================================ */
body:not(.index-body) {
    background-color: #ffffff;
    font-family: 'JetBrainsMono', 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;
    min-height: 100dvh;
}

/* ============================================
   8. POPUP CONTAINER (FLUIDO E RESPONSIVO)
   ============================================ */
.popup-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11000;
    height: 90vh;
    height: 90dvh;
    display: none;
    background: transparent;
    overflow: visible;
    max-width: 96vw; /* Sicurezza per non strabordare mai */
}

/* 1 pannello: centrato, fluido fino a 615px */
.popup-container.layout-1 { 
    width: min(615px, 92vw); 
}
.popup-container.layout-1 #popupContent {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* 2, 3, 4 pannelli: fluidi fino a 1230px (Adatto a Tablet) */
.popup-container.layout-2,
.popup-container.layout-3,
.popup-container.layout-4 { 
    width: min(1230px, 95vw); 
}

.popup-container.layout-2 #popupContent {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.popup-container.layout-3 #popupContent,
.popup-container.layout-4 #popupContent {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* ============================================
   8a. ANCORAGGIO ESPLICITO GRIGLIA 2x2 (layout-3/4)
   ============================================ */
.popup-container.layout-3 #pannello1,
.popup-container.layout-4 #pannello1 { grid-area: 1 / 1; }
.popup-container.layout-3 #pannello2,
.popup-container.layout-4 #pannello2 { grid-area: 1 / 2; }
.popup-container.layout-3 #pannello3,
.popup-container.layout-4 #pannello3 { grid-area: 2 / 1; }
.popup-container.layout-3 #pannello4,
.popup-container.layout-4 #pannello4 { grid-area: 2 / 2; }

/* ============================================
   8b. GRIGLIA PANNELLI
   ============================================ */
#popupContent {
    display: grid !important;
    width: 100%;
    height: 100%;
    padding: 10px;
    gap: 15px;
    box-sizing: border-box;
}

/* ============================================
   8c. PANNELLI
   ============================================ */
.pannello {
    position: relative;
    background: white;
    border: 2px solid #000;
    border-radius: 15px;
    padding: 6px 20px 20px 20px;
    box-sizing: border-box;
    font-family: 'JetBrainsMono', Courier, monospace !important;
    font-size: clamp(15px, 1.3vw, 20px); /* Font fluido per schermi medi */
    line-height: 1.8;
    color: #000;
    white-space: pre-wrap;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
    transition:
        transform var(--resize-duration) var(--resize-easing),
        opacity var(--resize-duration) ease,
        box-shadow var(--resize-duration) ease;
}

.pannello::-webkit-scrollbar { display: none; }

.pannello[data-empty="true"] {
    display: none !important;
}

.pannello[data-empty="false"] {
    display: flex !important;
    flex-direction: column;
    height: 100% !important;
    min-height: 0;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

/* ============================================
   8d. HEADER STICKY
   ============================================ */
.header-pannello {
    position: sticky;
    top: 0;
    width: calc(100% + 40px);
    min-height: 50px;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    z-index: 10020;
    flex-shrink: 0;
    border-radius: 13px 13px 0 0;
    pointer-events: none;
    margin: -6px -20px 4px -20px;
}

.header-pannello .resize-btn,
.header-pannello .close-popup-btn {
    width: 38px;
    height: 38px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    padding: 0 !important;
    line-height: 0 !important;
    pointer-events: auto !important;
    flex-shrink: 0;
}

.header-pannello .resize-btn {
    background-color: #4caf22 !important;
    visibility: hidden;
}

.header-pannello .close-popup-btn {
    background-color: #ff0000 !important;
    color: #ffffff !important;
    font-size: 22px;
    font-family: 'JetBrainsMono', Courier, monospace;
}

.resize-icon {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.search-ricette {
    flex: 1;
    min-width: 0;
    height: 38px;
    margin: 0 10px;
    border: 2px solid #000;
    border-radius: 19px;
    padding: 0 14px;
    font-family: 'JetBrainsMono', Courier, monospace;
    font-size: 16px;
    background: #fff;
    color: #000;
    pointer-events: auto !important;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    outline: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: border-color 0.2s ease;
}

.search-ricette:focus {
    border-color: #4caf22;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), 0 0 0 2px rgba(76,175,34,0.25);
}

/* ============================================
   8e. CORPO PANNELLO
   ============================================ */
.pannello-body {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    scrollbar-width: none;
}

.pannello-body::-webkit-scrollbar { display: none; }

/* ============================================
   8f. RESIZE: EFFETTO TENDINA (DESKTOP E TABLET)
   ============================================ */
.pannello-espanso {
    z-index: var(--espanso-z) !important;
    box-shadow: 0 25px 70px rgba(0,0,0,0.55);
}

#pannello1.pannello-espanso,
#pannello3.pannello-espanso {
    grid-area: 1 / 1 / span 2 / span 1 !important;
}

#pannello2.pannello-espanso,
#pannello4.pannello-espanso {
    grid-area: 1 / 2 / span 2 / span 1 !important;
}

.pannello-coperto {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.15s linear !important;
}

/* ============================================
   9. ELENCO E LINK
   ============================================ */
a {
    text-decoration: none;
}

#Elenco-IT, #Elenco-EN {
    margin-top: 4px !important;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    text-align: center;
}

.ricetta-body {
    margin-top: 0 !important;
    padding-top: 30px;
}

/* h3 generico: usato come fallback dove non arriva una regola più mirata */
.ricetta-body h3 {
    margin-top: -20px;
    margin-bottom: 20px;
}
.ricetta-body .titolo-ricetta {
    font-size: 1.3em;
    font-weight: bold;
}
/* Titolo -> intro (se presente) o direttamente Ingredienti (se manca l'intro):
   massima vicinanza, quasi un'unica unità visiva col titolo */
.titolo-ricetta + p {
    margin-top: 20px;
}
.ricetta-body .titolo-ricetta + h3 {
    margin-top: 20px;
}

/* Intro -> h3 successivo: transizione fra sezioni concettualmente diverse */
.ricetta-body p + h3 {
    margin-top: 16px;
}

/* Ingredienti -> elenco: il contenuto "appartiene" al suo titolo appena sopra */
.ricetta-body h3 + ul {
    margin-top: -10px;
}

/* Procedimento -> primo paragrafo: il doppio del 4px, un po' più di respiro
   per la prosa rispetto a un elenco puntato */
.ricetta-body h3 + p {
    margin-top: -10px;
}

/* fra un ingrediente e il successivo: stessa vicinanza stretta del titolo-elenco */
.ricetta-body li {
    margin-bottom: 2px;
}

.ricetta-body li {
    line-height: 1.6;
}

.ricetta-body p + ul {
    margin-top: 4px;
}
.ricetta-body ul + p {
    margin-top: 8px;
}

.ricetta-body h3 .nota-h3 {
    font-weight: normal;
    font-size: 0.7em;
    color: #000;
}

.ricetta-body ul,
.ricetta-body li {
    list-style-type: disc !important;
}

.ricetta-body ul {
    list-style-position: inside;
    padding-left: 0;
}

.ricetta-body ul {
    white-space: normal;
}

.ricetta-body ul.senza-bullet li{
    list-style-type: none !important;
}

.ricetta-body:has([id^="Elenco-"]) {
    padding-top: 0;
}

.link-ricetta {
    color: #0000ee !important;
    width: 100%;
    text-align: center;
    text-decoration: none;
    font-size: clamp(16px, 1.2vw, 20px);
    line-height: 1.1;
    display: block;
    margin: 4px;
    transition: color 0.2s ease;
}
.link-ricetta:hover {
    color: #ff0000 !important;
    text-decoration: none;
}

/* ============================================
   10. OVERLAY
   ============================================ */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 10999;
}

/* ============================================
   11. TABLET / PAD (601px - 1024px)
   Calibrazione specifica per iPad in Portrait/Landscape
   ============================================ */
@media (min-width: 601px) and (max-width: 1024px) {
    #popupContent {
        gap: 10px;
        padding: 8px;
    }

    .pannello {
        padding: 6px 14px 14px 14px;
        font-size: 16px;
    }

    .header-pannello {
        width: calc(100% + 28px);
        margin: -6px -14px 4px -14px;
        padding: 6px 8px;
    }

    .search-ricette {
        font-size: 14px;
        height: 34px;
        margin: 0 6px;
    }

    .header-pannello .resize-btn,
    .header-pannello .close-popup-btn {
        width: 34px;
        height: 34px;
    }

    .link-ricetta {
        font-size: 17px;
        padding: 6px 0;
    }
}

/* ============================================
   12. 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,
    .popup-container.layout-1,
    .popup-container.layout-2,
    .popup-container.layout-3,
    .popup-container.layout-4 {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        transform: none !important;
        background: transparent !important;
        border: none;
        z-index: 9999;
        overflow: hidden;
        pointer-events: none;
        max-width: 100vw !important;
    }

    .popup-container.layout-1,
    .popup-container.layout-2,
    .popup-container.layout-3,
    .popup-container.layout-4 {
        display: none;
    }

    .popup-container.layout-1.aperto,
    .popup-container.layout-2.aperto,
    .popup-container.layout-3.aperto,
    .popup-container.layout-4.aperto {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        pointer-events: auto !important;
        z-index: 12000 !important;
    }

    #popupContent,
    .popup-container.layout-1 #popupContent,
    .popup-container.layout-2 #popupContent,
    .popup-container.layout-3 #popupContent,
    .popup-container.layout-4 #popupContent {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: repeat(4, 1fr) !important;
        gap: 15px;
        width: 100% !important;
        height: 92vh !important;
        height: 92dvh !important;
        margin: 0 !important;
        padding: 15px !important;
        box-sizing: border-box;
    }

    #pannello1 { grid-area: 1 / 1 !important; }
    #pannello2 { grid-area: 2 / 1 !important; }
    #pannello3 { grid-area: 3 / 1 !important; }
    #pannello4 { grid-area: 4 / 1 !important; }

    .popup-container.doppio #popupContent {
        grid-template-rows: 1fr 1fr !important;
    }
    
    .popup-container.layout-1 #popupContent {
        grid-template-rows: 1fr !important;
    }
    .popup-container.layout-3:not(.doppio) #popupContent {
        grid-template-rows: repeat(3, 1fr) !important;
    }

    .popup-container.full-screen #pannello1 {
        display: none !important;
    }

    .header-pannello {
        width: calc(100% + 30px);
        margin: -70px 5px 8px -15px;
        background: #ffffff !important;
        padding: 6px 12px;
        min-height: var(--mobile-header-height);
    }

    .header-pannello .resize-btn,
    .header-pannello .close-popup-btn {
        width: 34px;
        height: 34px;
    }

    .pannello-body {
        padding-top: 0;
    }
    
    .ricetta-body {
        padding-top: 20px;
    }

    .pannello {
        width: 100% !important;
        height: 100% !important;
        background: white !important;
        border: 2px solid #000 !important;
        border-radius: 25px !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 6px 15px 20px 15px !important;
        box-sizing: border-box;
        overflow: hidden;
        font-family: 'JetBrainsMono', 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;
        width: 100%;
        text-align: center;
        text-decoration: none;
        display: block;
        margin: 4px 0;
        font-size: 18px;
        line-height: 1.1;
        cursor: pointer !important;
        padding: 12px 5px;
        pointer-events: auto !important;
        -webkit-tap-highlight-color: transparent;
    }
    
    .search-ricette {
        height: 34px;
        font-size: 14px;
        margin: 0 6px;
        padding: 0 10px;
        border-radius: 17px;
    }

    .pannello[data-empty="true"] {
        display: none !important;
    }

    #pannello1.pannello-espanso,
    #pannello2.pannello-espanso {
        grid-area: 1 / 1 / span 2 / span 1 !important;
        z-index: var(--espanso-z) !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.55);
    }

    #pannello3.pannello-espanso,
    #pannello4.pannello-espanso {
        grid-area: 3 / 1 / span 2 / span 1 !important;
        z-index: var(--espanso-z) !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.55);
    }

    .pannello-coperto {
        opacity: 0 !important;
        pointer-events: none !important;
    }
    
    #pannello1.p1-step1 { grid-area: 1 / 1 / span 2 / span 1 !important; z-index: var(--espanso-z) !important; }
    #pannello1.p1-step2 { grid-area: 1 / 1 / span 3 / span 1 !important; z-index: var(--espanso-z) !important; }
    #pannello1.p1-step3 { grid-area: 1 / 1 / span 4 / span 1 !important; z-index: var(--espanso-z) !important; }

    #pannello2.p2-step1 { z-index: var(--espanso-z) !important; }
    #pannello2.p2-step2 { z-index: var(--espanso-z) !important; }
    #pannello2.p2-step3 { grid-area: 1 / 1 / span 4 / span 1 !important; z-index: var(--espanso-z) !important; }

    #pannello3.p3-step1 { z-index: var(--espanso-z) !important; }
    #pannello3.p3-step2 { z-index: var(--espanso-z) !important; }
    #pannello3.p3-step3 { grid-area: 1 / 1 / span 4 / span 1 !important; z-index: var(--espanso-z) !important; }

    #pannello4.p4-step1 { z-index: var(--espanso-z) !important; }
    #pannello4.p4-step2 { z-index: var(--espanso-z) !important; }
    #pannello4.p4-step3 { grid-area: 1 / 1 / span 4 / span 1 !important; z-index: var(--espanso-z) !important; }
}

/* ============================================
   13. 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;
    }

    .pannello {
        font-size: 16px;
        line-height: 1.3;
        overflow-wrap: break-word;
    }

    .link-ricetta {
        font-size: 18px;
        margin: 12px 0;
        text-decoration: none;
    }
}

/* ============================================
   14. DARK MODE
   ============================================ */
@media (prefers-color-scheme: dark) {
    body.index-body { background-color: #121212; }

    .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;
    }

    .header-pannello {
        background-color: #1e1e1e !important;
    }

    .link-ricetta { color: #bb86fc !important; }
    .link-ricetta:hover { color: #cf6679 !important; }
}