/* ==========================================================================
   TITIS.it — GLOBAL DESIGN SYSTEM
   Versione: 2.0 — Refactoring Giugno 2026
   Architettura: Token-first, Mobile-First, Component-ready
   ========================================================================== */

/* ==========================================================================
   1. FONTS (Google Fonts Import)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Roboto:wght@400;500;700&display=swap');

/* ==========================================================================
   2. DESIGN TOKENS — Variabili CSS (Unica fonte di verità)
   ========================================================================== */
:root {

    /* --- Palette Colori --- */
    --bg-primary:       #F8F9FA;   /* Sfondo pagina principale */
    --bg-dark:          #131C26;   /* Sezioni scure / Footer */
    --bg-dark-2:        #0E1620;   /* Variante più profonda per contrasto interno */
    --bg-white:         #FFFFFF;   /* Card e blocchi bianchi */

    --text-main:        #131C26;   /* Testo principale */
    --text-light:       #FFFFFF;   /* Testo su sfondi scuri */
    --text-muted:       #5A6A85;   /* Testo secondario / descrizioni */
    --text-muted-dark:  rgba(255, 255, 255, 0.55); /* Testo secondario su sfondo scuro */

    --primary:          #005F98;   /* Blu corporate — CTA, link attivi, icone primarie */
    --primary-dark:     #004b79;   /* Hover sul primario */
    --primary-alpha:    rgba(0, 95, 152, 0.07); /* Sfondo icone e badge leggeri */

    --accent:           #FCD400;   /* Oro vivo — overline, active states, decori */
    --accent-muted:     #FCD400;   /* Oro opaco — indici FAQ, dettagli asimmetrici */
    --accent-dark:      #FCD400;   /* Oro scuro — bordi card stat, badge tecnici */

    --border-color:     #E2E8F0;   /* Bordi neutri su sfondo chiaro */
    --border-dark:      rgba(255, 255, 255, 0.08); /* Bordi su sfondo scuro */

    /* --- Tipografia --- */
    --font-titles:      'JetBrains Mono', monospace;
    --font-body:        'Roboto', sans-serif;

    /* --- Spaziature (Scale 4px) --- */
    --space-1:   4px;
    --space-2:   8px;
    --space-3:   12px;
    --space-4:   16px;
    --space-5:   20px;
    --space-6:   24px;
    --space-8:   32px;
    --space-10:  40px;
    --space-12:  48px;
    --space-16:  64px;
    --space-20:  80px;
    --space-24:  96px;
    --space-30:  120px;

    /* --- Border Radius --- */
    --radius-sm:    6px;
    --radius-btn:   8px;
    --radius-card:  16px;
    --radius-lg:    24px;

    /* --- Ombre (Sistema di Elevation) --- */
    --shadow-xs:  0 1px 3px rgba(19, 28, 38, 0.06);
    --shadow-sm:  0 4px 12px rgba(19, 28, 38, 0.06);
    --shadow-md:  0 8px 24px rgba(19, 28, 38, 0.07);
    --shadow-lg:  0 16px 48px rgba(19, 28, 38, 0.09);
    --shadow-xl:  0 24px 64px rgba(19, 28, 38, 0.12);

    /* --- Transizioni --- */
    --transition-fast:    0.2s ease;
    --transition-base:    0.3s ease;
    --transition-smooth:  0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-spring:  0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* --- Layout --- */
    --container-max:    1200px;
    --section-padding:  60px 0;   /* Mobile-First base */
}

/* Scale responsiva dei token di sezione */
@media (min-width: 768px) {
    :root {
        --section-padding: 100px 0;
    }
}


/* ==========================================================================
   3. RESET & BASE
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing:  antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
}

img, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-base);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    background: none;
    border: none;
    outline: none;
}

/* Accessibilità: focus visibile su tastiera */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}


/* ==========================================================================
   4. LAYOUT & CONTAINER
   ========================================================================== */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 20px;
}

/* Container ridotto per contenuti testuali centrati */
.container-narrow {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Sezione con max-width 75% su desktop (ottimizzazione layout Giugno 2026) */
.section-inner {
    width: 100%;
    max-width: 75%;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .section-inner {
        max-width: 100%;
    }
}

@media (min-width: 992px) {
    .container {
        padding: 0 40px;
    }
}

.section {
    padding: var(--section-padding);
}

.section-dark {
    background-color: var(--bg-dark);
    color: var(--text-light);
}


/* ==========================================================================
   5. GRIGLIE RESPONSIVE — Sistema corretto e non conflittuale
   ========================================================================== */

/* Tutte le classi grid abilitano esplicitamente display:grid */
.grid-responsive,
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: var(--space-6);  /* 24px — default gap */
}

/* Mobile-First: tutte partono a 1 colonna */
.grid-responsive,
.grid-2,
.grid-3,
.grid-4 {
    grid-template-columns: 1fr;
}

/* Grid-2: 2 colonne da 576px */
@media (min-width: 576px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Grid-3: 2 colonne su tablet, 3 su desktop */
@media (min-width: 768px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 1024px) {
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Grid-4: 2 colonne su tablet, 4 su desktop — usata come UNICA classe per i pilastri */
@media (min-width: 768px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Gap variants */
.gap-sm   { gap: var(--space-4); }
.gap-lg   { gap: var(--space-8); }
.gap-xl   { gap: var(--space-10); }


/* ==========================================================================
   6. TIPOGRAFIA — Gerarchia e Utility
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-titles);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.25rem;
    color: inherit;
}

/* Scale tipografica Mobile-First */
h1 { font-size: clamp(2rem,    5vw, 3rem);   }
h2 { font-size: clamp(1.65rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.2rem,  3vw, 1.5rem);  }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem;   }
h6 { font-size: 0.9rem; }

/* Classi h contestuali: overriding sicuro per i titoli dentro card/sezioni */
.h1-display {
    font-size: clamp(2.5rem, 6vw, 4rem);
    letter-spacing: -1px;
    line-height: 1.1;
}

/* Testo corpo — classi utility */
.lead {
    font-size: 1.15rem;
    line-height: 1.65;
    color: var(--text-muted);
}

.lead-large {
    font-size: 1.25rem;
    line-height: 1.65;
    color: var(--text-muted);
}

.text-sm   { font-size: 0.9rem;  }
.text-xs   { font-size: 0.8rem;  }
.text-mono {
    font-family: var(--font-titles);
    font-weight: 700;
}

/* Sopratitolo [ STANDARD ] — unica definizione canonica */
.overline {
    font-family: var(--font-titles);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    margin-bottom: var(--space-4);
    display: block;
}

/* Overline su sfondi scuri (eredita già accent, ma per explicitness) */
.section-dark .overline {
    color: var(--accent);
}

/* Overline variante azzurra (usata in sidebar FAQ, sezioni chiare) */
.overline-blue {
    font-family: var(--font-titles);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary);
    margin-bottom: var(--space-4);
    display: block;
}

/* Decorazione inline — linea orizzontale affiancata all'overline */
.overline-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.decor-line {
    display: inline-block;
    width: 40px;
    height: 2px;
    background-color: var(--accent);
    flex-shrink: 0;
}

.decor-line-blue {
    background-color: var(--primary);
}

.decor-line-thick {
    display: block;
    width: 56px;
    height: 4px;
    background-color: var(--primary);
    border-radius: 2px;
}


/* ==========================================================================
   7. UTILITY
   ========================================================================== */
.text-center   { text-align: center; }
.text-left     { text-align: left; }
.text-right    { text-align: right; }

.text-accent   { color: var(--accent); }
.text-accent-muted { color: var(--accent-muted); }
.text-primary  { color: var(--primary); }
.text-muted    { color: var(--text-muted); }
.text-light    { color: var(--text-light); }

.font-titles   { font-family: var(--font-titles); font-weight: 700; }

/* Max-width utility */
.max-w-600  { max-width: 600px;  margin-left: auto; margin-right: auto; }
.max-w-800  { max-width: 800px;  margin-left: auto; margin-right: auto; }
.max-w-900  { max-width: 900px;  margin-left: auto; margin-right: auto; }
.max-w-1000 { max-width: 1000px; margin-left: auto; margin-right: auto; }

/* Spacing utility */
.mb-0  { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-4); }
.mb-md { margin-bottom: var(--space-6); }
.mb-lg { margin-bottom: var(--space-10); }
.mb-xl { margin-bottom: var(--space-16); }

.mt-sm { margin-top: var(--space-4); }
.mt-md { margin-top: var(--space-6); }
.mt-lg { margin-top: var(--space-10); }


/* ==========================================================================
   8. ANIMAZIONI SCROLL (Intersection Observer) — Definite globalmente
      JS in main.js aggiunge la classe .active quando l'elemento entra nel viewport
   ========================================================================== */
.scroll-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition:
        opacity  0.6s cubic-bezier(0.215, 0.610, 0.355, 1.000),
        transform 0.6s cubic-bezier(0.215, 0.610, 0.355, 1.000);
    will-change: transform, opacity;
}

.scroll-reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Delay staggered su Desktop (il JS deve aggiungere .active, il CSS gestisce il ritardo) */
@media (min-width: 992px) {
    .scroll-reveal.active {
        transition-delay: calc(var(--card-index, 0) * 0.12s);
    }
}

/* Su mobile: niente delay, niente translate laterale — animazione verticale semplice */
@media (max-width: 991px) {
    .scroll-reveal {
        transform: translateY(16px); /* Ridotto su mobile */
    }
}

/* Variante slide-from-left per elementi sidebar / intestazioni asimmetriche */
.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-30px);
    transition:
        opacity  0.65s cubic-bezier(0.215, 0.610, 0.355, 1.000),
        transform 0.65s cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
.scroll-reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

/* Accessibilità: rispetta la preferenza di riduzione del movimento */
@media (prefers-reduced-motion: reduce) {
    .scroll-reveal,
    .scroll-reveal-left {
        opacity: 1;
        transform: none;
        transition: none;
    }
}


/* ==========================================================================
   9. COMPONENTI UI — Bottoni
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 13px 28px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition:
        background-color var(--transition-base),
        color var(--transition-base),
        border-color var(--transition-base),
        transform var(--transition-fast),
        box-shadow var(--transition-base);
    text-align: center;
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.98);
}

/* Primario — Blu */
.btn-primary {
    background-color: var(--primary);
    color: var(--text-light);
    box-shadow: 0 4px 14px rgba(0, 95, 152, 0.25);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(0, 95, 152, 0.35);
    transform: translateY(-1px);
}

/* Secondario — Outline */
.btn-secondary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background-color: transparent;
}
.btn-secondary:hover {
    background-color: var(--primary);
    color: var(--text-light);
    transform: translateY(-1px);
}

/* Accento — Oro */
.btn-accent {
    background-color: var(--accent);
    color: var(--text-main);
    box-shadow: 0 4px 14px rgba(252, 212, 0, 0.3);
}
.btn-accent:hover {
    background-color: #e2be00;
    box-shadow: 0 6px 20px rgba(252, 212, 0, 0.4);
    transform: translateY(-1px);
}

/* Ghost — Per hero su sfondi scuri */
.btn-ghost-light {
    border: 2px solid rgba(255, 255, 255, 0.7);
    color: var(--text-light);
    background-color: transparent;
}
.btn-ghost-light:hover {
    background-color: var(--text-light);
    color: var(--bg-dark);
    border-color: var(--text-light);
}

/* Size variants */
.btn-sm {
    padding: 9px 18px;
    font-size: 0.85rem;
}
.btn-lg {
    padding: 16px 36px;
    font-size: 1rem;
}


/* ==========================================================================
   10. COMPONENTI UI — Card
   ========================================================================== */

/* Card base (sfondo chiaro) */
.card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: var(--space-6);
    transition:
        transform var(--transition-smooth),
        box-shadow var(--transition-base),
        border-color var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Card con hover elevato (servizi, link) */
.card-hover {
    border: 1px solid transparent;
}
.card-hover:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

/* Card scura (sezioni dark) */
.card-dark {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-card);
    padding: var(--space-6);
    transition:
        background-color var(--transition-base),
        border-color var(--transition-base);
}

.card-dark:hover {
    background-color: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Badge / tag piccolo */
.badge {
    display: inline-block;
    font-family: var(--font-titles);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background-color: var(--primary-alpha);
    color: var(--primary);
}

.badge-accent {
    background-color: rgba(252, 212, 0, 0.12);
    color: var(--accent-muted);
}


/* ==========================================================================
   11. STRUTTURA HEADER & FOOTER (Scheletro globale — stile completato nei Web Component)
   ========================================================================== */
#main-header {
    width: 100%;
    background-color: var(--bg-white);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition-base);
}

#main-header.scrolled {
    box-shadow: var(--shadow-sm);
}

.header-container-fluid {
    width: 100%;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
}

@media (min-width: 992px) {
    .header-container-fluid {
        padding: 0 40px;
    }
}

#main-footer {
    background-color: var(--bg-dark);
    color: var(--text-light);
    padding: 64px 0 24px 0;
    font-size: 0.95rem;
}


/* ==========================================================================
   12. SEZIONE FAQ — Struttura canonica multi-pagina
       I CSS di pagina aggiungono solo override locali (colori, max-width, ecc.)
   ========================================================================== */
.section-faq {
    background-color: var(--bg-primary);
}

/* Layout affiancato su Desktop */
@media (min-width: 992px) {
    .section-faq > .container {
        display: grid;
        grid-template-columns: 1fr 1.3fr;
        gap: var(--space-20);
        align-items: flex-start;
    }
}

/* Sidebar sinistra */
.faq-sidebar {
    display: flex;
    flex-direction: column;
}

.faq-title {
    font-family: var(--font-titles);
    font-size: clamp(2.2rem, 4vw, 2.8rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: var(--space-5);
}

.faq-title .text-accent-muted {
    color: var(--accent-muted);
    display: block;
}

.faq-lead {
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text-muted);
    margin-bottom: var(--space-10);
}

/* Card Badge tecnico (es. uptime) */
.faq-badge-card {
    background-color: #F5F7FA;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-card);
    padding: var(--space-5);
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    max-width: 300px;
}

.badge-icon-wrapper {
    background-color: rgba(192, 154, 69, 0.1);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.badge-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.badge-code,
.badge-status {
    font-family: var(--font-titles);
    font-weight: 700;
    line-height: 1.3;
}

.badge-code   { font-size: 0.75rem; color: var(--text-main); }
.badge-status { font-size: 0.7rem;  color: var(--primary); }

/* Accordion FAQ */
.faq-accordion-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.faq-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: var(--space-6) 0;
}

.faq-item:first-child {
    padding-top: 0;
}

/* Rimozione marker nativo del browser */
.faq-trigger {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    list-style: none;
    position: relative;
    user-select: none;
    gap: var(--space-5);
}
.faq-trigger::-webkit-details-marker { display: none; }
.faq-trigger::marker { display: none; }

.faq-index {
    font-family: var(--font-titles);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent-muted);
    margin-top: 5px;
    flex-shrink: 0;
    min-width: 44px;
}

.faq-question {
    font-family: var(--font-titles);
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    margin: 0;
    padding-right: var(--space-10);
    flex-grow: 1;
}

/* Icona +/× */
.faq-icon {
    position: absolute;
    right: 0;
    top: 6px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.faq-icon::before,
.faq-icon::after {
    content: '';
    position: absolute;
    background-color: var(--text-muted);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    border-radius: 2px;
}

.faq-icon::before {
    top: 8px; left: 0;
    width: 18px; height: 2px;
}

.faq-icon::after {
    top: 0; left: 8px;
    width: 2px; height: 18px;
}

.faq-item[open] .faq-icon::after {
    transform: rotate(90deg);
    opacity: 0;
}
.faq-item[open] .faq-icon::before {
    transform: rotate(180deg);
}

/* Animazione apertura accordion */
.faq-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-item[open] .faq-content {
    grid-template-rows: 1fr;
}

.faq-content-inner {
    overflow: hidden;
}

.faq-content p {
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-muted);
    padding-top: var(--space-4);
    padding-left: 64px; /* Allineamento sotto il testo della domanda */
    margin: 0;
}

/* Mobile FAQ: layout verticale */
@media (max-width: 991px) {
    .section-faq > .container {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    .faq-sidebar {
        margin-bottom: var(--space-12);
    }
    .faq-content p {
        padding-left: 52px;
    }
}