/* ==========================================================================
   Hybrid Premium + Apple Native CSS (Audit Resolved)
   ========================================================================== */

/* 1. Variabili & Reset */
:root {
    --ios-primary: #005BB5; /* Scurito per superare contrast ratio WCAG AA */
    --ios-text: #1C1C1E;
    --ios-text-secondary: #636366; /* Scurito per accessibilità WCAG */
    
    --color-mesh-1: #0A2463;
    --color-mesh-2: #3E92CC;
    --color-mesh-3: #FF715B;
    
    /* Contrasto aumentato (0.75) per leggibilità del testo sul mesh background */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-blur: blur(16px) saturate(180%); /* Blur ridotto per performance */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ios-text);
    background-color: #f8f9fa;
    background-image: url('../img/vieste-bg.png');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    overscroll-behavior-y: none; /* Impedisce il rubber-banding dello sfondo su iOS */
}

html {
    scroll-behavior: smooth;
}

/* Utils */
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.w-100 { width: 100%; }
.d-block { display: block; }
.mt-top-nav { margin-top: 80px !important; }
.scroll-mt { scroll-margin-top: 80px !important; }

/* Padding safe area solo su mobile */
.pb-safe { padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px)); }
@media (min-width: 768px) {
    .pb-safe { padding-bottom: 40px; }
}

/* ==========================================================================
   2. Typography
   ========================================================================== */
.ios-title { font-size: 2.5rem; font-weight: 700; letter-spacing: -1px; margin-bottom: 0.5rem; color: #111; }
.ios-headline { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.5px; margin-bottom: 0.5rem; color: #111; }
.ios-caption { font-size: 0.75rem; font-weight: 700; letter-spacing: 1px; color: var(--ios-primary); text-transform: uppercase; }
.ios-body { font-size: 1.05rem; color: #333; margin-bottom: 1rem; }
.text-accent { color: var(--ios-primary); font-weight: 600; }

/* ==========================================================================
   3. Background Aurora (Performance ottimizzate)
   ========================================================================== */
/* Sfondo Aurora statico: massime performance senza repaint costanti */
.mesh-bg { 
    position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; z-index: -3; 
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(62, 146, 204, 0.25) 0%, transparent 60%), 
        radial-gradient(circle at 85% 80%, rgba(255, 113, 91, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 50% 50%, rgba(10, 36, 99, 0.1) 0%, transparent 70%);
}

/* ==========================================================================
   4. Top Navigation Bar
   ========================================================================== */
.top-nav {
    position: fixed;
    top: 0; left: 0; width: 100%;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    z-index: 1600;
    transition: all 0.3s ease;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-logo { 
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700; 
    font-size: 1.2rem; 
    color: var(--ios-primary); 
    cursor: pointer; 
    background: transparent; 
    border: none; 
    font-family: inherit; 
    padding: 0; 
}
/* Hamburger Menu */
.hamburger {
    display: inline-block;
    cursor: pointer;
    z-index: 2000;
}
.hamburger div {
    width: 25px;
    height: 2px;
    background-color: var(--ios-primary);
    margin: 5px 0;
    transition: 0.4s;
    border-radius: 2px;
}
.hamburger.open .bar1 {
    transform: translate(0, 7px) rotate(-45deg);
}
.hamburger.open .bar2 {
    opacity: 0;
}
.hamburger.open .bar3 {
    transform: translate(0, -7px) rotate(45deg);
}

/* Fullscreen Menu */
.fullscreen-menu {
    height: 100vh;
    width: 100%;
    position: fixed;
    z-index: 1500;
    top: 0;
    left: 0;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow-x: hidden;
    transition: 0.4s;
    opacity: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fullscreen-menu.active {
    opacity: 1;
    pointer-events: auto;
}
.fullscreen-menu-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.fullscreen-menu-content a {
    text-decoration: none;
    font-size: 2rem;
    font-weight: 600;
    color: var(--ios-text);
    transition: 0.3s;
}
.fullscreen-menu-content a:hover {
    color: var(--ios-primary);
}


/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
    width: 92%;
    max-width: 800px;
    margin: 0 auto; /* Viene sovrascritto dalla classe mt-top-nav se non stiamo attenti */
    margin-bottom: 24px;
    position: relative;
}

.hero-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    border-radius: 24px;
    opacity: 0.15;
    z-index: -1;
}

.hero-content {
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   5. Glass Panels & Layout
   ========================================================================== */
.container { width: 92%; max-width: 800px; margin: 0 auto; }
.glass-panel { background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); border-radius: 24px; padding: 24px 20px; position: relative; overflow: hidden; }
.ios-shadow { box-shadow: 0 8px 32px rgba(0,0,0,0.06); }
.ios-corner { border-radius: 16px; overflow: hidden; }

.image-wrapper { width: 100%; height: 200px; margin-bottom: 24px; position: relative; }
.organic-image { width: 100%; height: 100%; object-fit: cover; }

/* ==========================================================================
   6. Griglia Servizi
   ========================================================================== */
.services-grid { display: grid; grid-template-columns: 1fr; gap: 16px; text-align: center; }
@media (min-width: 768px) { .services-grid { grid-template-columns: 1fr 1fr; } }
.service-card { padding: 20px; text-align: center !important; }
.service-card .item-icon { margin: 0 auto 12px auto; }
.service-card h4 { margin-top: 12px; margin-bottom: 4px; font-size: 1.1rem; }
.service-card p { font-size: 0.9rem; color: var(--ios-text-secondary); margin: 0; }
.bg-blue { background: var(--ios-primary); color: white; }
.bg-orange { background: #FF9500; color: white; }

/* ==========================================================================
   7. FAQ Accordion (Animato con CSS Grid)
   ========================================================================== */
.faq-accordion { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.faq-item { background: rgba(255,255,255,0.7); cursor: pointer; border: none; width: 100%; text-align: left; font-family: inherit; }

.faq-question {
    padding: 16px 20px;
    font-weight: 600;
    font-size: 1.05rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-icon {
    color: var(--ios-primary);
    font-size: 1.2rem;
    transition: transform 0.3s ease;
    flex-shrink: 0; /* Previene lo schiacciamento dell'icona */
    margin-left: 12px;
}

/* Animazione dinamica per contenuti ad altezza variabile */
.faq-answer-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}

.faq-answer {
    overflow: hidden;
}

.faq-answer-inner {
    padding: 0 20px 16px 20px;
    font-size: 0.95rem;
    color: var(--ios-text-secondary);
}

.faq-item.active .faq-answer-wrapper {
    grid-template-rows: 1fr;
}

.faq-item.active .faq-icon {
    transform: rotate(45deg);
}

/* ==========================================================================
   8. Liste & Bottoni
   ========================================================================== */
.ios-inset-list { background: rgba(255,255,255,0.7); border-radius: 16px; overflow: hidden; text-align: left; width: 100%; }
@media (min-width: 768px) {
    /* Vincola l'estensione su schermi grandi */
    .ios-inset-list.max-desktop { max-width: 600px; margin: 0 auto; }
}

.ios-list-item { display: flex; align-items: center; padding: 16px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.item-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; margin-right: 16px; }
.item-content { font-size: 15px; color: var(--ios-text); }

.ios-btn { display: inline-block; padding: 14px 24px; border-radius: 14px; font-size: 17px; font-weight: 600; text-align: center; border: none; cursor: pointer; transition: transform 0.2s, opacity 0.2s; text-decoration: none; font-family: inherit; }
.ios-btn:active { transform: scale(0.97); opacity: 0.8; }
.ios-btn-primary { background: var(--ios-primary); color: white; }
.ios-btn-secondary { background: rgba(0, 122, 255, 0.1); color: var(--ios-primary); }

/* ==========================================================================
   9. Reveal Animations & Tab Bar
   ========================================================================== */
.reveal-item { opacity: 0; transform: translateY(30px); transition: all 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); will-change: opacity, transform; }
.reveal-item.is-visible { opacity: 1; transform: translateY(0); }

.ios-tab-bar { position: fixed; bottom: 0; left: 0; width: 100%; height: calc(56px + env(safe-area-inset-bottom, 16px)); padding-bottom: env(safe-area-inset-bottom, 16px); background: rgba(255,255,255,0.75); backdrop-filter: blur(20px) saturate(180%); border-top: 0.5px solid rgba(0,0,0,0.1); display: flex; justify-content: space-around; align-items: center; z-index: 1000; }
@media (min-width: 768px) { .ios-tab-bar { display: none; } }
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 56px; color: var(--ios-text-secondary); cursor: pointer; background: transparent; border: none; font-family: inherit; }
.tab-item.active { color: var(--ios-primary); }
.tab-icon { width: 24px; height: 24px; margin-bottom: 2px; }
.tab-label { font-size: 0.65rem; font-weight: 500; } /* Uso rem anzichè px fissi */

/* ==========================================================================
   10. Bottom Sheets (Modali a Scorrimento)
   ========================================================================== */
.ios-sheet-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 2000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease; display: flex; align-items: flex-end; justify-content: center; touch-action: none; /* Impedisce scroll sfondo su iOS */ }
.ios-sheet-overlay.active { opacity: 1; visibility: visible; }

.ios-sheet { width: 100%; background: #f2f2f7; border-radius: 20px 20px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom, 20px)); transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: 0 -10px 40px rgba(0,0,0,0.15); position: relative; }
.ios-sheet-overlay.active .ios-sheet { transform: translateY(0); }

/* Su Desktop diventa un modale centrato */
@media (min-width: 768px) {
    .ios-sheet-overlay { align-items: center; }
    .ios-sheet { width: 500px; border-radius: 20px; padding-bottom: 24px; transform: scale(0.9); opacity: 0; }
    .ios-sheet-overlay.active .ios-sheet { transform: scale(1); opacity: 1; }
    .sheet-handle-container { display: none; } /* Niente maniglia su desktop */
}

.sheet-handle-container { width: 100%; height: 32px; display: flex; justify-content: center; align-items: center; cursor: grab; }
.sheet-handle-container:active { cursor: grabbing; }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: rgba(0,0,0,0.2); }
.sheet-content { padding: 0 24px; }

/* Bottone chiusura Modale */
.sheet-close-btn { position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,0.05); border: none; border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ios-text-secondary); transition: background 0.2s; }
.sheet-close-btn:hover { background: rgba(0,0,0,0.1); }
