:root {
    --bg: #faf9f5;
    --surface: #ffffff;
    --surface-2: #f3f1ea;
    --ink: #1b1a17;
    --muted: #5f5c55;
    --line: #e6e3d9;
    --accent: #d0532a;
    --accent-dark: #b4441f;
    --accent-soft: #fbe8de;
    --dark: #161512;
    --dark-2: #211f1b;
    --dark-line: #34312b;
    --dark-muted: #b3ada1;
    --ok: #2f8f5b;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(27, 26, 23, .04), 0 8px 24px rgba(27, 26, 23, .05);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
    --header-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.4rem, 5.4vw, 4rem); font-weight: 800; }
h2 { font-size: clamp(1.9rem, 3.6vw, 2.75rem); font-weight: 750; }
h3 { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }

.container { width: min(1180px, 100% - 40px); margin-inline: auto; }

.skip-link {
    position: absolute; left: -9999px; top: 8px;
    background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { left: 8px; }

.eyebrow {
    font-family: var(--mono);
    font-size: .8rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
    font-weight: 500;
}
.lead { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5em;
    padding: .85em 1.4em;
    border-radius: 999px;
    font-weight: 600; font-size: .98rem;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.btn-ghost-light:hover { border-color: #fff; }
.btn-sm { padding: .6em 1.15em; font-size: .92rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-col { flex-direction: column; min-width: 220px; }

/* Header */
.site-header {
    position: fixed; inset: 0 0 auto 0; z-index: 50;
    height: var(--header-h);
    background: rgba(250, 249, 245, .85);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.nav-wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand img { height: 36px; width: auto; }

.menu { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 4px; }
.menu > li > a, .dropdown-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px; border-radius: 8px;
    font-size: .95rem; font-weight: 500; color: var(--ink);
    text-decoration: none; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.menu > li > a:hover, .dropdown-toggle:hover { background: var(--surface-2); }
.menu > li > a.btn { color: #fff; padding: .6em 1.15em; margin-left: 8px; }
.menu > li > a.btn:hover { background: var(--accent); }

.has-dropdown { position: relative; }
.dropdown {
    list-style: none; margin: 0; padding: 10px;
    position: absolute; top: calc(100% + 10px); left: -12px;
    width: 560px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 18px 40px rgba(27,26,23,.10);
    opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: opacity .18s, transform .18s, visibility .18s;
}
.dropdown::before { content: ""; position: absolute; top: -12px; left: 0; right: 0; height: 12px; }
.dropdown a {
    display: block; padding: 8px 10px; border-radius: 8px;
    font-size: .9rem; text-decoration: none; color: var(--ink);
}
.dropdown a:hover { background: var(--accent-soft); color: var(--accent-dark); }
.has-dropdown:hover .dropdown,
.has-dropdown:focus-within .dropdown,
.has-dropdown.open .dropdown { opacity: 1; visibility: visible; transform: none; }
.has-dropdown.open .dropdown-toggle svg { transform: rotate(180deg); }

.nav-toggle { display: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; padding: 0; flex-direction: column; justify-content: center; align-items: center; gap: 5px; }
.nav-toggle span { width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Hero */
.hero { padding: calc(var(--header-h) + 72px) 0 96px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 64px; align-items: center; }
.hero h1 { max-width: 14ch; }
.hero .lead { margin-bottom: 2rem; }
.stats { display: flex; gap: 40px; margin: 3rem 0 0; padding-top: 2rem; border-top: 1px solid var(--line); }
.stats dt { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stats dd { margin: 6px 0 0; color: var(--muted); font-size: .92rem; }

/* Window mockups */
.window {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.window-bar {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: #d9d5ca; }
.dots i:nth-child(1) { background: #ec6a5e; }
.dots i:nth-child(2) { background: #f4bf4f; }
.dots i:nth-child(3) { background: #61c554; }
.window-title { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.window-body { padding: 22px; }

.dash-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dash-label { font-size: .9rem; font-weight: 600; }
.live { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ok); background: #e6f4ec; padding: 4px 10px; border-radius: 999px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,143,91,.5); } 70% { box-shadow: 0 0 0 7px rgba(47,143,91,0); } 100% { box-shadow: 0 0 0 0 rgba(47,143,91,0); } }

.chart { width: 100%; height: 150px; color: var(--accent); display: block; }
.chart-grid line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart-line { stroke-dasharray: 420; stroke-dashoffset: 420; animation: draw 1.8s .3s ease-out forwards; }
.chart-area { opacity: 0; animation: fadein .8s 1.4s forwards; }
.chart-dot { opacity: 0; animation: fadein .4s 1.9s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { to { opacity: 1; } }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.kpi strong { display: block; font-size: 1.5rem; letter-spacing: -0.02em; }
.kpi span { font-size: .85rem; color: var(--muted); }

.ranking { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ranking li { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: .85rem; }
.ranking li:last-child { border-bottom: 0; }
.ranking .kw { color: var(--muted); }
.ranking .pos { font-weight: 500; }
.ranking em { font-style: normal; color: var(--ok); }

/* Sections */
.section { padding: 104px 0; }
.section-alt { background: var(--surface-2); border-block: 1px solid var(--line); }
.section-head { margin-bottom: 52px; max-width: 760px; }
.section-head-row { max-width: none; display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; }
.section-head-row h2 { margin-bottom: 0; }

.cards { display: grid; gap: 18px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-3 { grid-template-columns: repeat(3, 1fr); }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 26px;
    transition: border-color .2s, transform .2s, box-shadow .2s;
}
.service-card, .post-card { display: flex; flex-direction: column; }
.service-card:hover, .post-card:hover { border-color: #cfcabd; transform: translateY(-2px); box-shadow: var(--shadow); }
.service-card p { color: var(--muted); font-size: .96rem; flex: 1; }

.tag {
    align-self: flex-start;
    font-family: var(--mono); font-size: .74rem; font-weight: 500;
    color: var(--accent-dark); background: var(--accent-soft);
    padding: 4px 10px; border-radius: 6px; margin-bottom: 18px;
}
.more { font-weight: 600; font-size: .94rem; text-decoration: none; color: var(--ink); }
a.more:hover { color: var(--accent); }

/* Dark AI section */
.section-dark { background: var(--dark); color: #f4f2ec; }
.section-dark .lead { color: var(--dark-muted); }
.section-dark .eyebrow { color: #f08a5d; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: center; }
.split-top { align-items: start; }

.pills { list-style: none; padding: 0; margin: 2rem 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.pills li { border: 1px solid var(--dark-line); padding: 8px 16px; border-radius: 999px; font-size: .92rem; color: #e8e4da; }

.window-code { background: var(--dark-2); border-color: var(--dark-line); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.window-code .window-bar { background: #1b1a16; border-bottom-color: var(--dark-line); }
.window-code .window-title { color: var(--dark-muted); }
.code {
    margin: 0; padding: 22px 22px 24px 0; overflow-x: auto;
    font-family: var(--mono); font-size: .86rem; line-height: 1.75; color: #e9e5db;
    counter-reset: line;
}
.code .ln { display: block; padding-left: 3.4em; position: relative; white-space: pre; min-height: 1.75em; }
.code .ln::before {
    counter-increment: line; content: counter(line);
    position: absolute; left: 0; width: 2.4em; text-align: right; color: #5c574d;
}
.code .kw { color: #f08a5d; }
.code .fn { color: #7fc8f8; }
.code .at { color: #d6b4f7; }
.code .st { color: #a8d982; }
.code .nu { color: #f4bf4f; }
.code .cm { color: #7d776b; font-style: italic; }

/* Preventivi */
.quote-box {
    display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
    padding: 56px;
    background-image: radial-gradient(circle at 100% 0%, var(--accent-soft), transparent 45%);
}
.quote-box h2 { max-width: 18ch; }

/* Chi sono */
.why { margin-top: 2rem; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.checklist li { position: relative; padding-left: 32px; color: var(--muted); font-size: .97rem; }
.checklist li::before {
    content: ""; position: absolute; left: 0; top: .2em;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 10.5l2.6 2.5L14 7.5' fill='none' stroke='%23b4441f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat;
}
.about-side { display: grid; gap: 18px; position: sticky; top: calc(var(--header-h) + 24px); }
.quote-card { margin: 0; padding: 36px; }
.quote-card blockquote { margin: 0 0 28px; font-size: 1.5rem; line-height: 1.35; font-weight: 650; letter-spacing: -0.02em; }
.quote-card figcaption { display: flex; align-items: center; gap: 14px; }
.quote-card small { display: block; color: var(--muted); font-size: .88rem; }
.avatar {
    width: 48px; height: 48px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--ink); color: #fff; font-weight: 700; letter-spacing: .02em;
}
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.badge-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.badge-card strong { display: block; font-size: 1.8rem; letter-spacing: -0.03em; color: var(--accent); line-height: 1.1; }
.badge-card span { color: var(--muted); font-size: .9rem; }

/* Blog */
.post-card h3 { font-size: 1.08rem; line-height: 1.35; flex: 1; }
.post-card h3 a { text-decoration: none; }
.post-card h3 a::after { content: ""; position: absolute; inset: 0; }
.post-card { position: relative; }
.post-card:hover h3 a { color: var(--accent-dark); }
.post-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .88rem; color: var(--muted); }
.post-meta .more { font-size: .88rem; }

/* Contatti */
#contatti .btn { margin-top: .5rem; }
.contact-list { list-style: none; padding: 0; margin: 2.5rem 0 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.contact-list li { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.contact-label { font-family: var(--mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.contact-value { font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; word-break: break-all; }
a.contact-value:hover { color: var(--accent); }
.copy-btn {
    font-family: var(--mono); font-size: .74rem; padding: 4px 10px;
    border: 1px solid var(--line); background: var(--surface); border-radius: 6px; cursor: pointer; color: var(--muted);
}
.copy-btn:hover { border-color: var(--ink); color: var(--ink); }

.contact-form { padding: 32px; display: grid; gap: 18px; }
.field label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea {
    width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 12px 14px; transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 130px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--muted); }
.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-msg { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); font-size: .94rem; }
.form-msg.ok { background: #e6f4ec; color: #1f6b42; }
.form-msg.err { background: #fde8e4; color: #9a2f1a; }

/* CTA band */
.cta-band { background: var(--dark); color: #fff; padding: 96px 0; }
.cta-inner { display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; }
.cta-inner h2 { margin: 0; max-width: 22ch; }
.cta-band .btn-primary { background: var(--accent); }
.cta-band .btn-primary:hover { background: #fff; color: var(--ink); }

/* Footer */
.site-footer { background: var(--dark-2); color: var(--dark-muted); padding: 72px 0 28px; border-top: 1px solid var(--dark-line); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 40px; }
.footer-brand img { height: 36px; width: auto; margin-bottom: 18px; }
.footer-brand p { max-width: 32ch; font-size: .95rem; }
.footer-col h3 { color: #fff; font-size: .82rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; font-weight: 500; margin-bottom: 16px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: .94rem; }
.footer-col a, .footer-bottom a { text-decoration: none; color: var(--dark-muted); }
.footer-col a:hover, .footer-bottom a:hover { color: #fff; }
.footer-mail { word-break: break-all; }
.footer-bottom { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--dark-line); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: .88rem; }
.footer-bottom p { margin: 0; }
.footer-bottom ul { list-style: none; padding: 0; margin: 0; display: flex; gap: 24px; }

/* WhatsApp */
.wa-float {
    position: fixed; right: 20px; bottom: 20px; z-index: 40;
    width: 56px; height: 56px; border-radius: 50%;
    display: grid; place-items: center;
    background: #25d366; color: #fff;
    box-shadow: 0 10px 24px rgba(37, 211, 102, .35);
    transition: transform .2s;
}
.wa-float:hover { transform: scale(1.07); }

/* Reveal */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* Responsive */
@media (max-width: 1080px) {
    .cards-4 { grid-template-columns: repeat(2, 1fr); }
    .menu > li > a, .dropdown-toggle { padding: 8px 9px; font-size: .9rem; }
}

@media (max-width: 960px) {
    .nav-toggle { display: inline-flex; }
    .site-nav {
        position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
        background: var(--bg); border-top: 1px solid var(--line);
        overflow-y: auto; padding: 16px 20px 40px;
        transform: translateX(100%); transition: transform .25s ease;
        visibility: hidden;
    }
    .site-nav.open { transform: none; visibility: visible; }
    .menu { flex-direction: column; align-items: stretch; gap: 0; }
    .menu > li { border-bottom: 1px solid var(--line); }
    .menu > li > a, .dropdown-toggle { width: 100%; justify-content: space-between; padding: 16px 4px; font-size: 1.05rem; border-radius: 0; }
    .menu > li > a:hover, .dropdown-toggle:hover { background: none; }
    .menu-cta { border-bottom: 0 !important; padding-top: 20px; }
    .menu > li > a.btn { justify-content: center; margin: 0; padding: 14px; }
    .dropdown {
        position: static; width: auto; grid-template-columns: 1fr;
        box-shadow: none; border: 0; padding: 0 0 12px; background: transparent;
        opacity: 1; visibility: visible; transform: none;
        display: none;
    }
    .has-dropdown:hover .dropdown, .has-dropdown:focus-within .dropdown { display: none; }
    .has-dropdown.open .dropdown { display: grid; }
    .dropdown a { padding: 9px 8px; }
    body.nav-open { overflow: hidden; }

    .hero { padding-top: calc(var(--header-h) + 48px); }
    .hero-grid, .split, .cta-inner { grid-template-columns: 1fr; gap: 48px; }
    .about-side { position: static; }
    .quote-box { grid-template-columns: 1fr; padding: 40px 28px; gap: 28px; }
    .btn-col { flex-direction: row; min-width: 0; }
    .cards-3 { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
    body { font-size: 16px; }
    .section { padding: 72px 0; }
    .cards-4, .cards-3 { grid-template-columns: 1fr; }
    .stats { gap: 20px; justify-content: space-between; }
    .stats dt { font-size: 1.8rem; }
    .stats dd { font-size: .82rem; }
    .btn-row .btn { flex: 1 1 100%; }
    .badges { grid-template-columns: 1fr; }
    .quote-card { padding: 26px; }
    .quote-card blockquote { font-size: 1.25rem; }
    .contact-form { padding: 22px; }
    .footer-grid { grid-template-columns: 1fr; }
    .code { font-size: .78rem; }
    .cta-band { padding: 72px 0; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
    .chart-line { stroke-dashoffset: 0; }
    .chart-area, .chart-dot { opacity: 1; }
    .reveal { opacity: 1; transform: none; }
}
