/* ============================================================
   Tecnoimpianti Group S.r.l. — Stylesheet
   Palette brand: #049CDC (azzurro logo), grigio, navy
   ============================================================ */

:root {
    --blue: #049CDC;
    --blue-dark: #0277a8;
    --blue-darker: #036389;
    --navy: #12212f;
    --navy-soft: #1c3040;
    --grey: #6b7683;
    --grey-light: #eef2f6;
    --grey-lighter: #f7f9fb;
    --white: #ffffff;
    --text: #22303c;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 30px rgba(18, 33, 47, .08);
    --shadow-lg: 0 22px 50px rgba(18, 33, 47, .16);
    --maxw: 1180px;
    --ease: cubic-bezier(.2, .7, .3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    line-height: 1.65;
    background: var(--white);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

h1, h2, h3, h4 { line-height: 1.15; color: var(--navy); font-weight: 800; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); }
h3 { font-size: 1.2rem; }

.eyebrow {
    display: inline-block;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--blue);
    margin-bottom: .6rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
    font-size: .98rem;
    padding: .85rem 1.6rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--blue);
    cursor: pointer;
    transition: transform .2s var(--ease), background .2s, box-shadow .2s;
    box-shadow: 0 8px 18px rgba(4, 156, 220, .28);
}
.btn:hover { background: var(--blue-dark); border-color: var(--blue-dark); transform: translateY(-2px); }
.btn--ghost {
    background: transparent;
    color: var(--blue);
    box-shadow: none;
}
.btn--ghost:hover { background: rgba(4, 156, 220, .08); color: var(--blue-dark); }
.btn--sm { padding: .55rem 1.05rem; font-size: .88rem; }

/* ===== Topbar ===== */
.topbar {
    background: var(--navy);
    color: #cdd7e0;
    font-size: .84rem;
}
.topbar__inner { display: flex; justify-content: space-between; align-items: center; min-height: 40px; flex-wrap: wrap; gap: .3rem 1.2rem; }
.topbar__info { display: flex; gap: 1.4rem; flex-wrap: wrap; align-items: center; min-width: 0; }
.topbar__info a, .topbar__hours { display: inline-flex; align-items: center; gap: .4rem; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.topbar__info a:hover { color: #fff; }
.topbar__social { display: flex; gap: 1rem; }
.topbar__social a { font-weight: 600; }
.topbar__social a:hover { color: var(--blue); }
.ic { font-size: .95em; }

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--grey-light);
    transition: box-shadow .3s;
}
.header.scrolled { box-shadow: var(--shadow); }
.header__inner { display: flex; align-items: center; justify-content: space-between; min-height: 74px; gap: 1rem; }
.header__logo img { height: 34px; width: auto; }
.nav { display: flex; align-items: center; gap: 1.6rem; }
.nav > a { font-weight: 600; font-size: .96rem; color: var(--navy); transition: color .2s; }
.nav > a:not(.btn):hover { color: var(--blue); }
.nav__cta { color: #fff; }
.nav__cta:hover { color: #fff; }

.nav__toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav__toggle span { width: 26px; height: 3px; background: var(--navy); border-radius: 3px; transition: .3s; }

/* ===== Hero ===== */
.hero {
    position: relative;
    min-height: 88vh;
    display: flex;
    align-items: center;
    color: #fff;
    overflow: hidden;
}
.hero__bg {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    transform: scale(1.05);
}
.hero__overlay {
    position: absolute; inset: 0;
    background: linear-gradient(105deg, rgba(9, 22, 34, .93) 0%, rgba(12, 33, 51, .82) 42%, rgba(4, 156, 220, .55) 100%);
}
.hero__content { position: relative; z-index: 2; padding: 6rem 24px; max-width: 760px; }
.hero__eyebrow {
    display: inline-block;
    font-size: .82rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: #fff;
    background: rgba(4, 156, 220, .85);
    padding: .4rem .9rem;
    border-radius: 40px;
    margin-bottom: 1.3rem;
}
.hero h1 { color: #fff; margin-bottom: 1.1rem; }
.hero p { font-size: 1.14rem; color: #dce6ee; max-width: 620px; margin-bottom: 2rem; }
.hero__actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero .btn--ghost { color: #fff; border-color: rgba(255,255,255,.6); }
.hero .btn--ghost:hover { background: rgba(255,255,255,.14); }
.hero__stats {
    list-style: none; display: flex; gap: 2.6rem; margin-top: 3rem; flex-wrap: wrap;
}
.hero__stats li { display: flex; flex-direction: column; }
.hero__stats strong { font-size: 2rem; color: #fff; font-weight: 800; line-height: 1; }
.hero__stats span { font-size: .86rem; color: #c3d2dd; margin-top: .3rem; }

/* ===== Sections ===== */
.section { padding: 5.5rem 0; }
.section--alt { background: var(--grey-lighter); }
.section__head { max-width: 680px; margin: 0 auto 3rem; text-align: center; }
.section__head p { color: var(--grey); font-size: 1.05rem; margin-top: .6rem; }

/* ===== Chi siamo ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 3.5rem; align-items: center; }
.about__media img { border-radius: var(--radius); box-shadow: var(--shadow-lg); aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.about__text h2 { margin-bottom: 1rem; }
.about__text p { color: var(--grey); margin-bottom: 1rem; }
.checklist { list-style: none; margin-top: 1.4rem; display: grid; gap: .7rem; }
.checklist li { position: relative; padding-left: 2rem; font-weight: 500; color: var(--text); }
.checklist li::before {
    content: "✓";
    position: absolute; left: 0; top: 0;
    width: 1.4rem; height: 1.4rem;
    background: var(--blue); color: #fff;
    border-radius: 50%; font-size: .78rem; font-weight: 700;
    display: grid; place-items: center;
}

/* ===== Cards / servizi ===== */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6rem; }
.card {
    background: #fff;
    border: 1px solid var(--grey-light);
    border-radius: var(--radius);
    padding: 2rem 1.7rem;
    transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: transparent; }
.card__icon {
    width: 56px; height: 56px;
    display: grid; place-items: center;
    font-size: 1.7rem;
    background: linear-gradient(135deg, rgba(4,156,220,.14), rgba(4,156,220,.05));
    border-radius: 14px;
    margin-bottom: 1.1rem;
}
.card h3 { margin-bottom: .5rem; }
.card p { color: var(--grey); font-size: .96rem; }

/* ===== Settori ===== */
.sectors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6rem; }
.sector {
    position: relative;
    padding: 2.2rem 1.8rem;
    border-radius: var(--radius);
    background: var(--navy);
    color: #fff;
    overflow: hidden;
}
.sector::before {
    content: ""; position: absolute; top: -30px; right: -30px;
    width: 120px; height: 120px; border-radius: 50%;
    background: rgba(4, 156, 220, .35);
}
.sector h3 { color: #fff; margin-bottom: .6rem; position: relative; }
.sector p { color: #b9c7d3; font-size: .95rem; position: relative; }

/* ===== Gallery ===== */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.gallery__item {
    padding: 0; border: none; cursor: pointer;
    border-radius: var(--radius); overflow: hidden;
    aspect-ratio: 4/3; background: #ddd;
    position: relative;
}
.gallery__item img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.gallery__item::after {
    content: "🔍"; position: absolute; inset: 0;
    display: grid; place-items: center; font-size: 1.6rem;
    background: rgba(4, 156, 220, .0); opacity: 0; transition: .3s;
}
.gallery__item:hover img { transform: scale(1.08); }
.gallery__item:hover::after { background: rgba(9, 22, 34, .45); opacity: 1; }

/* ===== Contatti ===== */
.contact { display: grid; grid-template-columns: 1fr 1.05fr; gap: 2.5rem; align-items: start; }
/* Le celle della griglia devono poter rimpicciolirsi (altrimenti l'email le allarga) */
.contact, .contact__info, .contact__form { min-width: 0; }
.contact__card, .contact__map, .contact__map iframe { max-width: 100%; }
.contact__card {
    background: var(--navy); color: #fff;
    border-radius: var(--radius); padding: 2rem;
    margin-bottom: 1.4rem;
}
.contact__card h3 { color: #fff; margin-bottom: 1.2rem; }
.contact__list { list-style: none; display: grid; gap: .9rem; }
.contact__list li { display: flex; gap: .7rem; align-items: flex-start; color: #d6e0e8; font-size: .98rem; min-width: 0; }
.contact__list li a { min-width: 0; overflow-wrap: anywhere; }
.contact__list a:hover { color: var(--blue); }
.contact__map { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.contact__map iframe { width: 100%; height: 260px; border: 0; display: block; }
.map-consent {
    height: 260px;
    display: flex; flex-direction: column; gap: .8rem;
    align-items: center; justify-content: center; text-align: center;
    padding: 1.5rem;
    background: var(--grey-light);
    color: var(--grey);
}
.map-consent p { font-size: .9rem; max-width: 320px; }

/* honeypot: nascosto agli utenti, visibile ai bot */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Alert esito form */
.form-alert {
    padding: .85rem 1rem; border-radius: var(--radius-sm);
    font-size: .92rem; font-weight: 500; margin-bottom: 1.2rem;
}
.form-alert--ok { background: #e6f7ee; color: #12703f; border: 1px solid #b7e4cd; }
.form-alert--errore { background: #fdecec; color: #a12626; border: 1px solid #f4c4c4; }

.contact__form {
    background: #fff;
    border: 1px solid var(--grey-light);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: block; margin-bottom: 1.1rem; }
.field > span { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .4rem; color: var(--navy); }
.field em { color: var(--blue); font-style: normal; }
.field input, .field textarea {
    width: 100%;
    padding: .8rem .9rem;
    border: 1.5px solid var(--grey-light);
    border-radius: var(--radius-sm);
    font: inherit; font-size: .96rem;
    background: var(--grey-lighter);
    transition: border-color .2s, background .2s;
}
.field input:focus, .field textarea:focus {
    outline: none; border-color: var(--blue); background: #fff;
    box-shadow: 0 0 0 3px rgba(4, 156, 220, .12);
}
.field textarea { resize: vertical; }
.field--check { display: flex; gap: .6rem; align-items: flex-start; font-size: .86rem; color: var(--grey); }
.field--check input { width: auto; margin-top: .25rem; }
.field--check a { color: var(--blue); text-decoration: underline; }
.recaptcha-wrap { overflow: hidden; margin-bottom: 1.1rem; }
.g-recaptcha { display: inline-block; }
.contact__form .btn { width: 100%; margin-top: .4rem; }
.form-note { font-size: .8rem; color: var(--grey); margin-top: .8rem; text-align: center; }

/* ===== Footer ===== */
.footer { background: var(--navy); color: #b9c7d3; padding-top: 3.5rem; }
.footer__inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2.5rem; padding-bottom: 2.5rem; }
.footer__brand img { background: #fff; padding: 10px 14px; border-radius: 8px; margin-bottom: 1rem; height: auto; }
.footer__brand p { font-size: .92rem; max-width: 340px; }
.footer__col h4 { color: #fff; font-size: 1rem; margin-bottom: 1rem; }
.footer__col p { font-size: .92rem; margin-bottom: .5rem; overflow-wrap: anywhere; }
.footer__col a:hover { color: var(--blue); }
.footer__bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 1.3rem 0; font-size: .84rem; }
.footer__bottom .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem; }
.footer__totop:hover { color: var(--blue); }

/* ===== Lightbox ===== */
.lightbox {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(9, 15, 22, .92);
    display: none; align-items: center; justify-content: center;
    padding: 4vw;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; box-shadow: var(--shadow-lg); }
.lightbox__close {
    position: absolute; top: 20px; right: 28px;
    background: none; border: none; color: #fff;
    font-size: 2.6rem; line-height: 1; cursor: pointer;
}

/* ===== Cookie banner ===== */
/* Rispetta l'attributo hidden: senza questa regola il display:flex sotto lo tiene visibile */
.cookie-banner[hidden] { display: none; }
.cookie-banner {
    position: fixed; left: 50%; bottom: 20px;
    transform: translateX(-50%);
    z-index: 900;
    width: min(960px, calc(100% - 32px));
    background: #fff;
    border: 1px solid var(--grey-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.3rem 1.6rem;
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
    animation: cookieUp .4s var(--ease);
}
@keyframes cookieUp { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
.cookie-banner__text { flex: 1 1 340px; }
.cookie-banner__text strong { display: block; color: var(--navy); margin-bottom: .25rem; }
.cookie-banner__text p { font-size: .88rem; color: var(--grey); }
.cookie-banner__text a { color: var(--blue); text-decoration: underline; }
.cookie-banner__actions { display: flex; gap: .7rem; flex-shrink: 0; }

/* ===== Pagine legali ===== */
.legal-header {
    background: var(--navy); padding: 1.1rem 0;
}
.legal-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.legal-header img { height: 30px; background: #fff; padding: 5px 8px; border-radius: 6px; }
.legal-header a.back { color: #cdd7e0; font-weight: 600; font-size: .92rem; }
.legal-header a.back:hover { color: var(--blue); }
.legal {
    max-width: 820px; margin: 0 auto; padding: 3.5rem 24px 4.5rem;
}
.legal h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin-bottom: .4rem; }
.legal .updated { color: var(--grey); font-size: .9rem; margin-bottom: 2.2rem; }
.legal h2 { font-size: 1.25rem; margin: 2.2rem 0 .7rem; color: var(--navy); }
.legal h3 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; }
.legal p, .legal li { color: var(--text); font-size: .98rem; margin-bottom: .8rem; }
.legal ul { padding-left: 1.3rem; margin-bottom: 1rem; }
.legal li { margin-bottom: .4rem; }
.legal a { color: var(--blue); text-decoration: underline; }
.legal table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: .9rem; }
.legal th, .legal td { border: 1px solid var(--grey-light); padding: .6rem .8rem; text-align: left; vertical-align: top; }
.legal th { background: var(--grey-lighter); font-weight: 700; color: var(--navy); }
.legal .note { background: var(--grey-lighter); border-left: 3px solid var(--blue); padding: 1rem 1.2rem; border-radius: 0 8px 8px 0; margin: 1.2rem 0; }

/* ===== Reveal animation ===== */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ===== Responsive ===== */
@media (max-width: 940px) {
    .cards, .sectors, .gallery { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .contact { grid-template-columns: 1fr; }
    .about__media { order: 2; }
    .footer__inner { grid-template-columns: 1fr 1fr; }
    .footer__brand { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
    .topbar__hours { display: none; }
    /* La tendina si ancora all'header (non alla viewport): niente sovrapposizioni con la topbar */
    .header__inner { position: relative; }
    .nav {
        position: absolute; top: calc(100% + 1px); left: 0; right: 0;
        flex-direction: column; align-items: stretch;
        background: #fff;
        padding: .25rem 0 .5rem;
        gap: 0;
        border-top: 1px solid var(--grey-light);
        border-bottom-left-radius: var(--radius);
        border-bottom-right-radius: var(--radius);
        box-shadow: var(--shadow-lg);
        transform: translateY(-10px);
        opacity: 0; visibility: hidden; pointer-events: none;
        transition: opacity .25s var(--ease), transform .25s var(--ease), visibility .25s;
    }
    .nav.open { transform: translateY(0); opacity: 1; visibility: visible; pointer-events: auto; }
    .nav > a { padding: .9rem 1.1rem; border-bottom: 1px solid var(--grey-light); font-size: 1.02rem; }
    .nav > a:last-child { border-bottom: none; }
    .nav__toggle { display: flex; }
    .nav__toggle.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .nav__toggle.open span:nth-child(2) { opacity: 0; }
    .nav__toggle.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
}

@media (max-width: 560px) {
    .section { padding: 4rem 0; }
    .cards, .sectors, .gallery, .field-row { grid-template-columns: 1fr; }
    /* Su mobile niente centraggio flex (spingeva il contenuto sotto l'header):
       l'hero diventa un blocco normale con spazio garantito in cima. */
    .hero { min-height: auto; display: block; padding-top: 2.5rem; padding-bottom: 1rem; }
    .hero__stats { gap: 1.4rem 2rem; margin-top: 2.2rem; }
    .hero__content { padding-top: 0; padding-bottom: 3rem; }
    .hero p { font-size: 1.05rem; }
    .topbar { font-size: .8rem; }
    .topbar__info { gap: .4rem 1rem; }
    .footer__inner { grid-template-columns: 1fr; text-align: center; }
    .footer__brand img { margin-inline: auto; }
    .footer__brand p { margin-inline: auto; }
    .footer__bottom .container { justify-content: center; text-align: center; }
    .contact__form, .contact__card { padding: 1.5rem 1.3rem; }
    .contact__map iframe, .map-consent { height: 220px; }
}

/* Telefoni stretti: evita scroll orizzontale (logo, container, reCAPTCHA) */
@media (max-width: 420px) {
    .container { padding: 0 16px; }
    .header__logo img { height: 30px; }
    .hero__eyebrow { font-size: .74rem; }
    .g-recaptcha { transform: scale(.9); transform-origin: 0 0; }
}
@media (max-width: 360px) {
    .header__logo img { height: 27px; }
    .g-recaptcha { transform: scale(.8); }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
}
