/* =============================================
   G.TOSI - Modern Professional Website v2
   Mobile-First · Responsive · Accessible
   ============================================= */

/* --- CSS Variables --- */
:root {
    --primary: #1a3a5c;
    --primary-light: #2a5a8c;
    --primary-dark: #0f2440;
    --accent: #c8a44e;
    --accent-light: #ddc478;
    --text: #2c2c2c;
    --text-light: #666;
    --bg: #f5f5f0;
    --white: #ffffff;
    --border: #ddd;
    --shadow: 0 4px 20px rgba(0,0,0,.12);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: .35s cubic-bezier(.4,0,.2,1);

    --font-main: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-heading: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

    --spacing-xs: .5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    --header-h: 62px;       /* Default / mobile header height */
    --header-h-d: 80px;     /* Desktop header height */
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }
ul { list-style: none; }

/* =============================================
   SITE SHELL — uno sticky wrapper unico
   Header + Nav nello stesso contesto di stacking
   ============================================= */
.site-shell {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
}

/* --- Header --- */
.site-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    color: var(--white);
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: .7rem var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo {
    flex-shrink: 0;
}
.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1.2;
}
.logo a { color: var(--white); }
.logo-accent { color: var(--accent); }

.social-links {
    margin-left: auto;
    display: flex;
    gap: .4rem;
}
.social-links a {
    opacity: .85;
    transition: opacity var(--transition), transform var(--transition);
}
.social-links a:hover { opacity: 1; transform: scale(1.15); }
.social-links img { width: 26px; height: 26px; border-radius: 4px; }

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--white);
    margin: 5px 0;
    transition: var(--transition);
    border-radius: 2px;
}
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* --- Navigation --- */
.main-nav {
    background: var(--primary);
    border-top: 2px solid var(--accent);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 0;
}
.nav-item {
    position: relative;
}
.nav-link {
    display: flex;
    align-items: center;
    padding: .65rem 1.1rem;
    color: var(--white);
    font-size: .92rem;
    font-weight: 500;
    letter-spacing: .02em;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    height: 100%;
}
.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,.12);
    color: var(--accent-light);
}
.nav-link.external::after {
    content: ' ↗';
    font-size: .75em;
}

/* Submenu (desktop: dropdown) */
.submenu-toggle { cursor: pointer; }
.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--white);
    min-width: 220px;
    box-shadow: 0 8px 30px rgba(0,0,0,.18);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 10;
    overflow: hidden;
}
.nav-item:hover .submenu,
.nav-item.submenu-open .submenu {
    display: block;
    animation: submenuIn .25s ease;
}
@keyframes submenuIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.submenu a {
    display: block;
    padding: .65rem 1.2rem;
    color: var(--text);
    font-size: .9rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition), color var(--transition);
}
.submenu a:last-child { border-bottom: none; }
.submenu a:hover,
.submenu a.active {
    background: var(--primary);
    color: var(--white);
}

/* --- Body offset for fixed shell --- */
/* Default (mobile): compensa l'altezza dell'header fixed */
body { padding-top: calc(var(--header-h) + 10px); }

/* =============================================
   HERO
   ============================================= */
.hero {
    position: relative;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: var(--white);
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-sm);
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../images/principale.jpg') center/cover no-repeat;
    opacity: .15;
}
.hero-content {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}
.hero h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.hero p {
    font-size: 1.1rem;
    line-height: 1.7;
    text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.hero-divider {
    width: 60px;
    height: 3px;
    background: var(--accent);
    margin: var(--spacing-md) auto;
    border-radius: 2px;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-area {
    flex: 1;
}

/* Content section with background */
.bg-section {
    position: relative;
    padding: var(--spacing-xl) 0;
}
.bg-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    opacity: .12;
    z-index: 0;
}
.bg-section > * { position: relative; z-index: 1; }

.bg-rocche::before  { background-image: url('../images/background-5.jpg'); }
.bg-matasse::before { background-image: url('../images/background-3.jpg'); }
.bg-ambiente::before { background-image: url('../images/laboratorio.png'); }
.bg-tintoria::before { background-image: url('../images/background-2.jpg'); }

/* Content card */
.content-card {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-sm);
}
.content-card-inner {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--spacing-lg);
    overflow: hidden;
}

/* --- Two Column Layout --- */
.two-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}
.two-col .col-img {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.two-col .col-img img {
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    max-height: 420px;
    width: 100%;
    max-width: 400px;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform var(--transition), box-shadow var(--transition);
}
.two-col .col-img img:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow);
}
/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    padding: 1rem;
}
.lightbox.active { display: flex; }
.lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.two-col .col-text h2 {
    color: var(--primary);
    font-size: 1.6rem;
    margin-bottom: .25rem;
}
.two-col .col-text h3 {
    color: var(--primary);
    font-size: 1.4rem;
    margin-bottom: .25rem;
}
.two-col .col-text .subtitle {
    color: var(--accent);
    font-style: italic;
    font-size: 1.05rem;
    margin-bottom: var(--spacing-sm);
}
.two-col .col-text p {
    margin-bottom: var(--spacing-sm);
    line-height: 1.75;
}
.two-col .col-text .en-text {
    color: var(--text-light);
    font-style: italic;
}

.col-divider {
    border: none;
    border-top: 2px solid var(--accent);
    margin: var(--spacing-md) 0;
}

/* --- Certifications Grid --- */
.cert-section { margin-top: var(--spacing-lg); }
.cert-section h3 {
    color: var(--primary);
    font-size: 1.3rem;
    margin-bottom: var(--spacing-sm);
    text-align: center;
}
.cert-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
}
.cert-item {
    background: var(--bg);
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: var(--spacing-sm) var(--spacing-md);
    transition: transform var(--transition), box-shadow var(--transition);
}
.cert-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.cert-item h4 {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: .25rem;
}
.cert-item .cert-eng {
    color: var(--text-light);
    font-size: .85rem;
}
.cert-item p {
    font-size: .9rem;
    margin-top: .25rem;
}

/* --- Contact Page --- */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}
.contact-list { list-style: none; }
.contact-list li {
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border);
}
.contact-list li:last-child { border-bottom: none; }
.contact-label {
    display: block;
    font-weight: 600;
    color: var(--primary);
    font-size: .95rem;
    margin-bottom: .2rem;
}
.contact-value { color: var(--text); font-size: 1rem; }
.contact-value a { color: var(--primary-light); }
.contact-value a:hover { color: var(--accent); }

/* --- Bagni Table --- */
.bagni-section { margin-top: var(--spacing-xl); }
.bagni-section h3 {
    text-align: center;
    color: var(--primary);
    margin-bottom: var(--spacing-md);
}
.bagni-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}
.bagni-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}
.bagni-card h4 {
    color: var(--primary);
    text-align: center;
    margin-bottom: var(--spacing-sm);
    font-size: 1.05rem;
}
.bagni-card img {
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
}
.bagni-card ul {
    list-style: disc;
    padding-left: var(--spacing-md);
    font-size: .95rem;
}
.bagni-card li { padding: .2rem 0; }

/* --- Footer --- */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,.85);
    text-align: center;
    padding: var(--spacing-md) var(--spacing-sm);
    font-size: .9rem;
    margin-top: auto;
}
.site-footer a { color: var(--accent-light); }
.site-footer a:hover { color: var(--white); }
.map-link {
    display: inline;
    color: var(--accent-light);
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.25);
    transition: border-color var(--transition), color var(--transition);
}
.map-link:hover {
    color: var(--white);
    border-bottom-color: var(--white);
}
.map-icon {
    display: inline-block;
    vertical-align: middle;
    margin-left: .25rem;
    margin-top: -2px;
    color: var(--accent-light);
}
.map-link:hover .map-icon { color: var(--white); }
.map-hint {
    font-size: .75rem;
    opacity: .6;
    margin-left: .2rem;
    transition: opacity var(--transition);
}
.map-link:hover .map-hint { opacity: 1; }

/* Contatti page map-link */
.contact-list .map-link {
    display: inline;
    color: var(--accent);
    border-bottom: 1px solid rgba(0,107,107,.25);
}
.contact-list .map-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.contact-list .map-icon { color: var(--accent); }
.contact-list .map-link:hover .map-icon { color: var(--primary); }
.contact-list .map-hint {
    display: block;
    font-size: .8rem;
    margin-top: .15rem;
    opacity: .5;
}
.footer-contacts {
    margin-top: .5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: .5rem;
}
.footer-contacts a {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: 0 .5rem;
    transition: color var(--transition);
}
.footer-contacts a:hover {
    color: var(--white);
    text-decoration: underline;
}
.footer-contacts .sep {
    color: rgba(255,255,255,.4);
    user-select: none;
}

/* --- Animations --- */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .6s ease, transform .6s ease;
}
.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   MOBILE (<768px)
   Menu drawer che scende dall'header
   ============================================= */
@media (max-width: 767px) {
    .hamburger { display: block; }
    .social-links { display: none; }

    /* Nav diventa un pannello che scende sotto l'header */
    .main-nav {
        max-height: 0;
        overflow: hidden;
        transition: max-height .4s ease;
    }
    .main-nav.nav-open {
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Blocca scroll del body quando il drawer è aperto */
    body.menu-open {
        overflow: hidden;
        /* Su iOS serve anche position fixed per evitare scroll bounce */
        position: fixed;
        width: 100%;
    }

    .nav-inner {
        flex-direction: column;
        padding: 0;
    }

    .nav-item {
        border-bottom: 1px solid rgba(255,255,255,.1);
    }
    .nav-link {
        padding: .85rem 1.2rem;
    }

    /* Submenu: si espande inline — nessun position:absolute */
    .submenu {
        position: static;
        box-shadow: none;
        background: rgba(0,0,0,.15);
        max-height: 0;
        overflow: hidden;
        transition: max-height .3s ease;
    }
    .nav-item.submenu-open .submenu {
        display: block;
        max-height: 500px;
        animation: none;
    }
    .submenu a {
        color: rgba(255,255,255,.85);
        border-bottom-color: rgba(255,255,255,.08);
        padding-left: 2rem;
    }
    .submenu a:hover,
    .submenu a.active {
        background: rgba(255,255,255,.15);
        color: var(--white);
    }

    body { padding-top: var(--header-h); }

    .content-card-inner { padding: var(--spacing-md); }
    .two-col .col-text h2 { font-size: 1.35rem; }
    .two-col .col-text h3 { font-size: 1.2rem; }
    .hero h2 { font-size: 1.5rem; }
    .hero p { font-size: 1rem; }
}

/* =============================================
   TABLET+ (≥768px)
   ============================================= */
@media (min-width: 768px) {
    body { padding-top: calc(var(--header-h-d) + 10px); }
    .two-col { grid-template-columns: 1fr 1.4fr; }
    .contact-grid { grid-template-columns: 1fr 1.2fr; }
    .cert-grid { grid-template-columns: 1fr 1fr; }
    .bagni-grid { grid-template-columns: 1fr 1fr; }
    .hero h2 { font-size: 2.4rem; }
    .social-links { display: flex; }
}

@media (min-width: 1024px) {
    .cert-grid { grid-template-columns: 1fr 1fr 1fr; }
    .hero { padding: 4rem var(--spacing-lg); }
}

/* --- Print Styles --- */
@media print {
    .site-shell, .site-footer, .social-links, .hamburger { display: none; }
    body { padding-top: 0; }
    .content-card-inner { box-shadow: none; }
    .bg-section::before { display: none; }
}