/* =========================================
   1. VARIABILI E RESET
   ========================================= */
:root {
    /* Palette Colori */
    --primary-color: #2E7D32;
    --primary-gradient: linear-gradient(135deg, #2E7D32 0%, #43A047 100%);
    --accent-color: #FF9800;
    --accent-gradient: linear-gradient(135deg, #FF9800 0%, #FFB74D 100%);
    
    /* Colori Specifici Menu */
    --menu-home: #2196F3;       /* Blu */
    --menu-belcastro: #F44336;  /* Rosso */
    --menu-raccolte: #FF9800;   /* Arancione */
    --menu-curiosita: #4CAF50;  /* Verde */
    
    /* Sfondi */
    --bg-body: #f4f6f8;
    --bg-card: #ffffff;
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.6);
    --blur: blur(15px);
    
    /* Spazi e Ombre */
    --radius-lg: 20px;
    --radius-sm: 10px;
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 15px 45px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Open Sans', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-body);
    color: #333;
    line-height: 1.8;
}

h1, h2, h3, h4 {
    font-family: 'Montserrat', sans-serif;
    color: var(--primary-color);
    margin-top: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    transition: all 0.3s ease;
}

img { max-width: 100%; height: auto; display: block; border-radius: var(--radius-sm); }

/* =========================================
   2. LAYOUT
   ========================================= */
.container {
    width: 92%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.main-content {
    padding-top: 30px;
    min-height: 60vh;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    margin-bottom: 40px;
    box-shadow: var(--shadow-soft);
    border: var(--glass-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0; /* Gestito da JS */
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.visible-element { opacity: 1 !important; transform: none !important; }

/* =========================================
   3. NAVIGAZIONE (FIXED & GLASS)
   ========================================= */
nav {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 1100px;
    z-index: 10000;
    
    background: var(--glass-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: var(--glass-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    
    border-radius: 50px;
    padding: 5px 20px;
    transition: top 0.3s;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
}

nav ul li { position: relative; }

/* Link Menu Principale */
nav ul li > a {
    display: block;
    padding: 12px 25px;
    color: #444;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    border-radius: 30px;
    transition: all 0.3s ease;
    background-color: transparent;
}

/* --- COLORI SPECIFICI PER LE VOCI DEL MENU (HOVER) --- */

/* Home -> Blu */
nav ul li.menu-home:hover > a {
    color: var(--menu-home);
    transform: scale(1.05);
    background-color: transparent;
}

/* Belcastro -> Rosso */
nav ul li.menu-belcastro:hover > a {
    color: var(--menu-belcastro);
    transform: scale(1.05);
    background-color: transparent;
}

/* Raccolte -> Arancione */
nav ul li.menu-raccolte:hover > a {
    color: var(--menu-raccolte);
    transform: scale(1.05);
    background-color: transparent;
}

/* Curiosità -> Verde */
nav ul li.menu-curiosita:hover > a {
    color: var(--menu-curiosita);
    transform: scale(1.05);
    background-color: transparent;
}

/* Sottolineature colorate nei menu a tendina */
nav ul li.menu-belcastro ul li a:hover { color: var(--menu-belcastro); }
nav ul li.menu-raccolte ul li a:hover { color: var(--menu-raccolte); }
nav ul li.menu-curiosita ul li a:hover { color: var(--menu-curiosita); }


/* Dropdown Menu */
nav ul li ul {
    display: block;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #fff;
    min-width: 240px;
    box-shadow: var(--shadow-hover);
    border-radius: var(--radius-lg);
    padding: 15px;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

nav ul li:hover > ul {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(10px);
}

nav ul li ul li a {
    padding: 10px 15px;
    font-size: 0.9rem;
    text-transform: none;
    color: #555;
    border-radius: 8px;
    display: block;
    text-align: left;
}

nav ul li ul li a:hover {
    background-color: #f9f9f9; 
    padding-left: 20px;
}

/* =========================================
   4. HEADER (LOGO E TITOLO)
   ========================================= */
header {
    margin-top: 100px; 
    background: var(--bg-card);
    padding: 30px;
    margin-bottom: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    position: relative;
    z-index: 1;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo-area { display: flex; align-items: center; gap: 20px; }
.logo-area img { height: 70px; width: auto; object-fit: contain; }

.header-utilities { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.site-badge {
    background: var(--primary-gradient);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(46, 125, 50, 0.2);
}

.social-icons { display: flex; gap: 10px; }
.social-icons img { width: 28px; height: 28px; transition: transform 0.3s; }
.social-icons img:hover { transform: scale(1.15) rotate(5deg); }

/* =========================================
   5. HERO IMAGE
   ========================================= */
.hero-container {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    margin-bottom: 40px;
    height: 450px;
    opacity: 0;
    position: relative;
}

#random-hero {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 5s ease;
}

.hero-container:hover #random-hero { transform: scale(1.05); }

/* =========================================
   6. BOTTONI & INTERAZIONI
   ========================================= */
.btn-download, .btn-secondary, button {
    display: inline-block;
    background: var(--accent-gradient);
    color: white !important;
    padding: 14px 35px;
    border-radius: 50px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(255, 152, 0, 0.25);
    transition: all 0.3s ease;
    font-size: 0.95rem;
    text-transform: uppercase;
}

.btn-download:hover, .btn-secondary:hover, button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(255, 152, 0, 0.4);
}

.story-link, .recipe-header {
    background: #fff;
    border: 1px solid #eee;
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    transition: all 0.3s;
    color: #333;
    cursor: pointer;
}

.story-link:hover, .recipe-header:hover {
    border-color: var(--primary-color);
    background: #f9fff9;
    transform: translateX(10px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.story-number, .toggle-icon {
    background: #eee;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: bold;
    color: #555;
    transition: 0.3s;
}

.story-link:hover .story-number, .recipe-card.open .toggle-icon {
    background: var(--primary-color);
    color: white;
}

/* =========================================
   7. FOOTER
   ========================================= */
footer {
    background: #fff;
    padding: 60px 20px;
    text-align: center;
    border-top: 1px solid #eee;
    margin-top: 80px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.03);
}

/* =========================================
   MODIFICA FOOTER LOGOS (CENTRATO, COLORI, ZOOM)
   ========================================= */
.footer-logos { 
    margin-top: 30px;
    
    /* 1. Centratura perfetta (anche mobile) */
    display: flex;
    justify-content: center;
    width: 100%;

    /* 2. Sempre a colori (rimossa l'opacità del 0.6) */
    opacity: 1; 
    filter: none; /* Assicura che non ci siano filtri grigi */
    
    /* Preparazione all'animazione */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.footer-logos:hover { 
    /* 3. Ingrandimento al passaggio del mouse */
    transform: scale(1.2); 
    cursor: pointer;
}

/* =========================================
   8. TASTO TORNA SU (CORRETTO DEFINITIVO)
   ========================================= */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(46, 125, 50, 0.4);
    z-index: 10001;
    transition: all 0.3s;
    
    /* Assicuriamo che il bottone non abbia testo visibile */
    font-size: 0;
    
    /* Non usiamo flexbox sul contenitore per evitare problemi, usiamo absolute sul figlio */
    display: none; /* Gestito da JS */
}

/* LA FRECCIA (Costruita e centrata con position: absolute) */
#back-to-top::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    
    /* Bordi bianchi per la freccia */
    border-top: 3px solid white;
    border-left: 3px solid white;
    
    /* Centratura assoluta:
       - translate(-50%, -50%) centra il quadrato.
       - rotate(45deg) ruota il quadrato per farlo diventare una freccia in su.
       - margin-top: 2px spinge leggermente in basso per correzione ottica (la punta visiva è più alta del centro geometrico)
    */
    transform: translate(-50%, -50%) rotate(45deg);
    margin-top: 2px;
}

#back-to-top:hover { 
    transform: translateY(-5px); 
    background: var(--accent-gradient);
}
/* --- STILE DEL TASTO HAMBURGER (Default nascosto su PC) --- */
.hamburger {
    display: none; /* Su PC non si vede */
    cursor: pointer;
    width: 30px;
    height: 25px;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger .bar {
    width: 100%;
    height: 3px;
    background-color: #333;
    border-radius: 3px;
    transition: all 0.3s ease;
}

/* Animazione trasformazione in X quando attivo */
.hamburger.active .bar:nth-child(2) { opacity: 0; }
.hamburger.active .bar:nth-child(1) { transform: translateY(11px) rotate(45deg); }
.hamburger.active .bar:nth-child(3) { transform: translateY(-11px) rotate(-45deg); }
/* =========================================
   9. MOBILE (VERSIONE DEFINITIVA COMPLETA)
   ========================================= */
@media (max-width: 900px) {
    
    /* --- 1. HEADER & LOGO (Logo e Testo affiancati orizzontalmente) --- */
    .header-top {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .logo-area {
        flex-direction: row !important; /* Forza logo e scritta vicini */
        align-items: center;
        justify-content: center;
        text-align: left;
    }

    .logo-area img {
        height: 50px; /* Logo ridimensionato per mobile */
        width: auto;
    }

    .welcome-wrapper {
        margin-left: 12px !important;
        margin-top: 0 !important;
        align-items: flex-start !important;
    }

    .welcome-text { font-size: 0.8rem; }
    .brand-name { font-size: 1.8rem; }

    .header-utilities { align-items: center; width: 100%; margin-top: 15px; }
    header { margin-top: 80px; padding: 20px; }


    /* --- 2. NAVBAR (HAMBURGER & MENU VERTICALE) --- */
    nav {
        top: 10px;
        width: 95%;
        padding: 10px 20px;
        border-radius: 15px;
        display: flex;
        flex-direction: column; /* Impila tasto hamburger e lista */
        align-items: center;
    }

    /* Rende visibile il tasto con le 3 linee */
    .hamburger { display: flex; }

    /* Nasconde la lista del menu finché non clicchi */
    nav ul {
        display: none; 
        flex-direction: column;
        width: 100%;
        margin-top: 15px;
        gap: 0;
        padding: 0;
    }

    nav ul li {
        width: 100%;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        position: relative; /* Fondamentale per contenere il sottomenu */
    }

    nav ul li > a {
        display: block;
        padding: 15px;
        width: 100%;
        font-size: 1rem;
        text-align: center;
    }


    /* --- 3. FIX SOTTOMENU (Risolve il problema del taglio a sinistra) --- */
    nav ul li ul {
        position: relative !important;   /* Si apre DENTRO la lista, non sopra */
        left: 0 !important;
        top: 0 !important;
        transform: none !important;      /* Blocca lo spostamento laterale */
        width: 100% !important;          /* Usa tutta la larghezza */
        box-shadow: none !important;
        background: rgba(0,0,0,0.03) !important; /* Sfondo leggermente diverso */
        margin: 0 !important;
        padding: 0 !important;
        visibility: visible !important;
        opacity: 1 !important;
        display: none; /* Chiuso di default */
        border-radius: 0 0 10px 10px;
    }

    /* Su mobile, cliccando/toccando si apre la tendina */
    nav ul li:hover > ul { display: block; }

    nav ul li ul li a {
        padding: 12px 15px 12px 30px !important; /* Sposta il testo a destra */
        font-size: 0.9rem !important;
        text-align: left;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }


    /* --- 4. FIX HERO IMAGE (Rimuove spazio bianco sotto) --- */
    .hero-container {
        height: auto !important;
        min-height: auto !important;
        margin-bottom: 20px;
        aspect-ratio: auto;
    }

    #random-hero {
        width: 100%;
        height: auto !important;
        object-fit: contain;
    }

    .card { padding: 20px; }
}