:root {
    --crema: #F7F4EF;
    --verde-loggione: #3B4A40;
    --verde-notte: #151A17;
    --amarone: #66252C;
    --oro-terroir: #D4C3A3;
    --bianco-card: #FFFFFF;
    --testo-soft: #556256;
    --bordo: #EAE3D5;
    --rame-mutazione: #D27D46;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--crema);
    color: var(--verde-loggione);
    font-family: 'DM Sans', sans-serif;
    font-size: 18px; 
    line-height: 1.6; 
    display: flex;
    justify-content: center;
    min-height: 100vh;
    transition: background-color 0.5s ease;
}

body.dark-mode {
    background-color: var(--verde-notte);
    color: var(--crema);
}

.app-container {
    width: 100%;
    max-width: 520px; 
    padding: 40px 25px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* =========================================================================
   SISTEMA HEADER (VERSIONE STANDARD HUB & VERSIONE COMPATTA)
   ========================================================================= */
header {
    text-align: center;
    margin-bottom: 20px;
    position: relative; 
}

body.dark-mode header h1 { color: var(--crema); }

.admin-egg-link {
    position: absolute;
    top: -10px;
    right: 5px;
    color: var(--testo-soft);
    opacity: 0.18; 
    font-size: 16px;
    text-decoration: none;
    transition: opacity 0.3s ease, color 0.3s ease;
    padding: 10px;
}
.admin-egg-link:hover { opacity: 0.9; color: var(--amarone); }
body.dark-mode .admin-egg-link { color: #8A9A8E; }

.logo-svg {
    width: 100%;
    max-width: 260px;
    height: 140px;
    transition: all 0.4s ease;
}

h1 {
    font-family: 'Lora', serif;
    font-size: 64px;        
    font-weight: 500;       
    font-style: italic;     
    color: var(--verde-loggione);
    margin: -10px 0 0 0;    
    letter-spacing: 2px;
    text-transform: lowercase;
    display: inline-block;
    transform: skewX(-12deg); 
    transition: all 0.4s ease;
}

.tagline {
    font-family: 'DM Sans', sans-serif;
    font-size: 13.5px;       
    color: var(--amarone);
    margin: 4px 0 0 0;     
    letter-spacing: 4px;
    font-weight: 600;
    transition: all 0.4s ease;
}

/* --- CHICCA DESIGN: REGOLE PER L'HEADER COMPATTO NELLE SCHERMATE --- */
.compact-header {
    margin-bottom: 5px;
}
.compact-header .logo-svg {
    max-width: 130px; /* Logo dimezzato per lasciare spazio ai contenuti didattici */
    height: 75px;
}
.compact-header h1 {
    font-size: 34px; /* Scritta duetto rimpicciolita ed elegante */
    margin: -5px 0 0 0;
}
.compact-header .tagline {
    font-size: 10px;
    letter-spacing: 2.5px;
    margin-top: 0px;
}

/* =========================================================================
   STRUTTURA DELLE VISTE E HUB CARD
   ========================================================================= */
.view { display: none; animation: fadeIn 0.5s ease forwards; }
.view.active { display: flex; flex-direction: column; gap: 20px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hub-card {
    background-color: var(--bianco-card);
    border: 1px solid var(--bordo);
    border-radius: 24px;
    padding: 30px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(59,74,64,0.02);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.hub-card:hover { transform: translateY(-3px); box-shadow: 0 16px 35px rgba(59,74,64,0.06); }
.hub-card.dark { background-color: #1C221F; border-color: #2D3731; color: var(--crema); }
.hub-card.dark .phase-title { color: var(--crema); font-family: 'Lora', serif; font-style: italic; font-size: 28px; }
.hub-card.dark .phase-subtitle { color: #8A9A8E; }

.phase-title { font-family: 'Lora', serif; font-style: italic; font-size: 28px; margin: 0; font-weight: 400; color: var(--verde-loggione); } 
.phase-subtitle { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; font-weight: 600; color: var(--amarone); } 
.phase-desc { font-size: 15px; color: var(--testo-soft); margin-top: 6px; font-weight: 300; line-height: 1.6; } 
.hub-card.dark .phase-desc { color: #A4B2A7; }

.card {
    background-color: var(--bianco-card);
    border: 1px solid var(--bordo);
    border-radius: 24px;
    padding: 35px;
    box-shadow: 0 12px 30px rgba(59,74,64,0.03);
}

.card-title {
    font-family: 'Lora', serif;
    font-size: 26px; 
    margin: 0 0 10px 0;
    font-weight: 500;
    color: var(--verde-loggione);
}

.btn-back {
    background: none; border: none; color: var(--testo-soft); font-size: 14px; text-transform: uppercase; 
    letter-spacing: 2px; cursor: pointer; display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-weight: 600;
}
body.dark-mode .btn-back { color: #8A9A8E; }
body.dark-mode .btn-back:hover { color: var(--oro-terroir); }

/* Sliders */
.control-group { margin-bottom: 26px; }
.control-group:last-child { margin-bottom: 0; }
.label-zone { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;} 
.label-desc { font-size: 13.5px; color: var(--testo-soft); display: block; margin-top: -2px; margin-bottom: 12px; font-weight: 300; line-height: 1.4; } 

.slider {
    -webkit-appearance: none; appearance: none; width: 100%; height: 5px; background: var(--bordo); border-radius: 3px; outline: none;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--amarone); cursor: pointer;
}

/* Dessert Switch Toggle */
.toggle-group {
    display: flex; justify-content: space-between; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--bordo); margin-bottom: 25px;
}
.switch { position: relative; display: inline-block; width: 52px; height: 28px; } 
.switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bordo); transition: .3s; border-radius: 24px;
}
.toggle-slider:before {
    position: absolute; content: ""; height: 22px; width: 22px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%;
}
input:checked + .toggle-slider { background-color: var(--amarone); }
input:checked + .toggle-slider:before { transform: translateX(24px); }

/* Pulsanti e Risultati */
.result-zone { border-left: 4px solid var(--amarone); display: none; animation: fadeIn 0.6s ease forwards; margin-top: 20px;}
.btn-match {
    background-color: var(--amarone); color: var(--crema); border: none; border-radius: 16px; padding: 20px; 
    font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; cursor: pointer; width: 100%; box-shadow: 0 8px 20px rgba(102,37,44,0.15); margin-top: 12px;
}
.btn-match.gold {
    background-color: #8C7355; border-color: #9C8568; color: var(--crema); box-shadow: 0 8px 20px rgba(140,115,85,0.15);
}

/* --- STILI GENESI --- */
.genesi-card {
    background-color: #1C221F; border: 1px solid #2D3731; border-radius: 24px; padding: 30px; display: flex; flex-direction: column; align-items: center;
}
.geo-nav {
    display: flex; width: 100%; justify-content: space-between; background: #151A17; padding: 5px; border-radius: 14px; margin-bottom: 20px; border: 1px solid #252E29;
}
.geo-btn {
    background: none; border: none; color: #617568; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; padding: 12px 14px; cursor: pointer; border-radius: 10px; transition: all 0.3s;
}
.geo-btn.active { background-color: var(--verde-loggione); color: var(--crema); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

.wireframe-container { 
    width: 100%; 
    height: 195px !important; /* BLINDATO: Forza l altezza corretta scavalcando i vecchi comandi inline HTML */
    margin-bottom: 20px; 
    display: flex; 
    justify-content: center; 
    overflow: visible !important; /* Sblocca i vettori della mappa geografica */
}

.wireframe-mesh { stroke: var(--oro-terroir); stroke-width: 0.8; fill: none; opacity: 0.4; transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.telemetry-deck { width: 100%; background: #151A17; border: 1px solid #252E29; border-radius: 16px; padding: 22px; box-sizing: border-box; }
.telemetry-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 12px; letter-spacing: 0.5px; }
.progress-bar-bg { width: 100%; height: 4px; background: #252E29; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--oro-terroir); width: 0%; transition: width 0.6s ease; }
.verdetto-box { background: linear-gradient(135deg, #231215 0%, #1A0D0F 100%); border: 1px solid #421B20; border-radius: 20px; padding: 25px; margin-top: 12px; }

/* --- SELETTORE PREZZO DISCRETO --- */
.price-zone { margin-bottom: 25px; display: flex; flex-direction: column; gap: 8px; }
.price-title-label { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--amarone); font-weight: 700; }
.price-nav { display: flex; background: var(--crema); padding: 5px; border-radius: 14px; border: 1px solid var(--bordo); justify-content: space-between; gap: 6px; }
.price-btn { flex: 1; background: none; border: none; color: var(--testo-soft); font-size: 15px; font-weight: 600; padding: 12px; cursor: pointer; border-radius: 10px; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; gap: 4px; }
.price-btn small { font-size: 11.5px; font-weight: 300; text-transform: lowercase; opacity: 0.7; }
.price-btn.active { background-color: var(--bianco-card); color: var(--amarone); box-shadow: 0 4px 10px rgba(102,37,44,0.05); }

/* =========================================================================
   SUPER-OTTIMIZZAZIONE TIPOGRAFICA PER SMARTPHONE (HYPER-READABLE)
   ========================================================================= */
@media (max-width: 480px) {
    
    body { font-size: 19px !important; }

    #main-header h1 { font-size: 42px !important; letter-spacing: 3px !important; }
    .tagline { font-size: 15px !important; letter-spacing: 4px !important; }

    /* Riduzione extra su Mobile per le sottopagine compattate */
    .compact-header .logo-svg { max-width: 95px !important; height: 55px !important; }
    .compact-header h1 { font-size: 26px !important; }
    .compact-header .tagline { font-size: 9px !important; }

    #verdetto-testo { font-size: 21px !important; line-height: 1.75 !important; margin: 15px 0 30px 0 !important; font-weight: 400 !important; }
    .active-vitigno-badge { font-size: 17px !important; padding: 10px 30px !important; letter-spacing: 2px !important; font-weight: 600 !important; }
    .clean-search-field { font-size: 22px !important; padding: 14px 0 !important; }
    .geo-nav button { font-size: 12px !important; padding: 12px 1px !important; font-weight: 700 !important; }
    .control-group style, .control-group div span, #telemetry-box div div span { font-size: 17px !important; }

    .card-title { font-size: 30px !important; }
    .label-zone span:first-child { font-size: 20px !important; font-weight: 600 !important; }
    .label-zone span:last-child { font-size: 24px !important; color: var(--oro-terroir) !important; font-weight: 700 !important; }
    .label-desc { font-size: 15px !important; line-height: 1.5 !important; color: rgba(255, 255, 255, 0.8) !important; }
    .toggle-group span { font-size: 17px !important; }

    #match-wine-name { font-size: 32px !important; font-weight: 700 !important; }
    #match-wine-details { font-size: 18px !important; line-height: 1.6 !important; }
    .btn-match { font-size: 19px !important; padding: 20px !important; font-weight: 600 !important; }
}