/* =============================================================================
   Perspect Starter — Main Stylesheet
   Mobile-first · CSS custom properties · BEM + Bootstrap
   ============================================================================= */


/* ── Custom Properties ───────────────────────────────────────────────────────── */

:root {
    /* Colori brand */
    --color-black:         #000000;
    --color-black-rgb:     0, 0, 0;
    --color-white:         #ffffff;
    --color-white-rgb:     255, 255, 255;

    --color-accent:        #FA843C;
    --color-accent-rgb:    250, 132, 60;

    --color-footer:        #3B3D40;
    --color-footer-rgb:    59, 61, 64;

    --color-grey-1:        #FAFAFA;
    --color-grey-2:        #F6F6F6;

    --color-viola-1:       #38373F;
    --color-viola-1-rgb:   56, 55, 63;
    --color-viola-2:       #2A2930;
    --color-viola-2-rgb:   42, 41, 48;

    /* Alias semantici */
    --color-primary:       var(--color-black);
    --color-primary-rgb:   var(--color-black-rgb);
    --color-text:          #000000;
    --color-text-editorial:#545353;
    --color-text-muted:    #545353;
    --color-bg:            #ffffff;
    --color-bg-alt:        var(--color-grey-1);
    --color-bg-alt-2:      var(--color-grey-2);
    --color-border:        var(--color-grey-2);

    /* Bootstrap overrides */
    --bs-primary:          var(--color-accent);
    --bs-primary-rgb:      var(--color-accent-rgb);

    /* Typography */
    --font-family-base:    'Geist', system-ui, -apple-system, sans-serif;
    --font-family-heading: var(--font-family-base);
    --line-height-base:    1.6;

    /* Type scale — il nome riflette il valore px a 1920px */
    --fs-14:  0.875rem;
    --fs-16:  1rem;
    --fs-20:  clamp(1.125rem, 0.5vw + 0.875rem, 1.25rem);  /* 18→20px */
    --fs-22:  clamp(1.125rem, 1vw + 0.75rem,   1.375rem);  /* 18→22px */
    --fs-28:  clamp(1.25rem,  1.5vw + 0.75rem, 1.75rem);   /* 20→28px */
    --fs-40:  clamp(1.5rem,   2vw + 1rem,      2.5rem);    /* 24→40px */
    --fs-56:  clamp(2rem,     3vw + 1rem,      3.5rem);    /* 32→56px */
    --fs-70:  clamp(2.1875rem, 4vw + 1rem,     4.375rem);  /* 35→70px */
    --fs-80:  clamp(2.5rem,   5vw + 1rem,      5rem);      /* 40→80px */

    /* Spacing — il nome riflette il valore px a 1920px */
    --p-60:   clamp(20px, 3.125vw, 60px);
    --p-90:   clamp(30px, 4.69vw,  90px);
    --p-120:  clamp(60px, 6.25vw,  120px);
    --p-160:  clamp(90px, 8.33vw,  160px);

    /* Gutter container */
    --gutter-off:   max(1.25rem, 8.3333vw);   /* Bootstrap dimezza (× .5): padding laterale effettivo = gutter-half (80px @ 1920px) */
    --gutter-half:  calc(var(--gutter-off) / 2);
    --gutter-in:    max(0.9375rem, 0.8125vw); /* gap interno colonne row */

    /* Focus */
    --focus-rgba: rgba(var(--color-accent-rgb), 0.35);
    --focus-ring: 0 0 0 3px var(--focus-rgba);

    /* Transitions */
    --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base:   0.25s var(--transition-timing);

    /* Header — solo per scroll-padding e spacer, mai min-height su .header */
    --header-height:    72px;
    --header-height-lg: 80px;
}


/* ── Reset minimale ──────────────────────────────────────────────────────────── */
/* Bootstrap reboot copre il grosso. Qui solo ciò che non gestisce. */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-heading);
}

p {
    margin-block: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family:             var(--font-family-base);
    font-size:               var(--fs-16);
    line-height:             var(--line-height-base);
    color:                   var(--color-text);
    background:              var(--color-bg);
    -webkit-font-smoothing:  antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Nasconde il bordo su img senza src o con src vuoto */
img:not([src]),
img[src=""] {
    visibility: hidden;
}


/* ── Media utilities ─────────────────────────────────────────────────────────── */
/*
 * Pattern: wrapper posizionato + immagine assoluta che riempie il container.
 * Usare un <div class="media"> lascia <figure> libero per la semantica HTML:
 *
 *   Semplice:
 *   <div class="media" style="aspect-ratio: 16/9">
 *       <img class="img-cover" src="..." alt="..." loading="lazy">
 *   </div>
 *
 *   Con caption (semantica corretta):
 *   <figure>
 *       <div class="media" style="aspect-ratio: 16/9">
 *           <img class="img-cover" src="..." alt="..." loading="lazy">
 *       </div>
 *       <figcaption>Didascalia</figcaption>
 *   </figure>
 *
 * .media       — wrapper (position: relative, display: block)
 * .media-bg    — wrapper decorativo: no pointer-events, no select.
 *                Supporta ::after per overlay (solo su <div>, non su <img>)
 * .img-cover   — riempie il wrapper, object-fit: cover   (foto, hero, card)
 * .img-contain — riempie il wrapper, object-fit: contain (loghi, illustrazioni)
 * .img-scale   — riempie il wrapper, object-fit: scale-down (icone, asset misti)
 *
 * NB: Bootstrap ha .object-fit-cover ecc. ma senza il posizionamento assoluto —
 * queste classi coprono il pattern "fill container" completo.
 */

.media {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
}

.media-bg::after {
    user-select: none;
    pointer-events: none;
}

.img-cover,
.img-contain,
.img-scale,
.media-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.img-contain { object-fit: contain; }
.img-scale   { object-fit: scale-down; }

::selection {
    background: var(--color-accent);
    color: var(--color-white);
}


/* ── Link base ───────────────────────────────────────────────────────────────── */
/* Neutri di default — colore e stile aggiunto nel contesto (header, footer, .text…) */

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

/* Rimuove l'outline al click/tap ma lo preserva per navigazione da tastiera — EAA */
a:focus:not(:focus-visible) {
    outline: none;
}


/* ── Accessibility ───────────────────────────────────────────────────────────── */

/* Focus ring — EAA / WCAG 2.4.7 */
:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* WP core markup (search form, comments, Complianz…) la usa — il tema deve definirla */
.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    word-wrap: normal !important;
}

/* Skip link — usa .visually-hidden-focusable di Bootstrap per show-on-focus */
.skip-link {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    border-radius: 4px;
}


/* ── Loader ──────────────────────────────────────────────────────────────────── */

.site-loader {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.site-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.site-loader__bars {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 16px;
}

.site-loader__bars span {
    display: inline-block;
    width: 1px;
    height: 100%;
    background: var(--color-primary);
    animation: stretchdelay 1.2s ease-in-out infinite;
}

.site-loader__bars span:nth-child(2) { animation-delay: -1.1s; }
.site-loader__bars span:nth-child(3) { animation-delay: -1.0s; }
.site-loader__bars span:nth-child(4) { animation-delay: -0.9s; }
.site-loader__bars span:nth-child(5) { animation-delay: -0.8s; }

@keyframes stretchdelay {
    0%, 40%, 100% { transform: scaleY(0.4); }
    20%           { transform: scaleY(1); }
}


/* ── Header ──────────────────────────────────────────────────────────────────── */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.header .navbar           { padding-block: 1rem; }
.header .navbar-brand     { font-weight: 700; }

.header .navbar-nav .nav-link {
    color: var(--color-text);
    font-weight: 500;
    padding-inline: 1rem;
    transition: color var(--transition-base);
}

.header .navbar-nav .nav-link:hover,
.header .navbar-nav .nav-link:focus-visible,
.header .navbar-nav .nav-item.current-menu-item > .nav-link,
.header .navbar-nav .nav-item.current_page_item > .nav-link {
    color: var(--color-accent);
}


/* ── Footer ──────────────────────────────────────────────────────────────────── */

.footer {
    background: var(--color-primary);
    color: #fff;
}

.footer__main {
    padding-block: clamp(3rem, 6vw, 5rem);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.footer__logo        { display: inline-block; }
.footer__logo .brand { height: 36px; width: auto; color: #fff; }

.footer__tagline {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 0;
    margin-top: 0.75rem;
}

.footer__col-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    margin-bottom: 1rem;
}

.footer__nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer__nav li a {
    font-size: 0.9375rem;
    color: rgba(255,255,255,0.7);
}

.footer__nav li a:hover,
.footer__nav li a:focus-visible {
    color: #fff;
}

/* Footer Legal */

.footer__legal {
    padding-block: 1.25rem;
    background: rgba(0,0,0,0.2);
    font-size: 0.8125rem;
}

.footer__copy {
    color: rgba(255,255,255,0.5);
    margin-bottom: 0;
}

.footer__legal-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
}

@media (min-width: 768px) {
    .footer__legal-links { justify-content: flex-end; }
}

.footer__legal-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.footer__legal-menu li a { color: rgba(255,255,255,0.5); }
.footer__legal-menu li a:hover,
.footer__legal-menu li a:focus-visible { color: #fff; }

.footer__credits {
    color: rgba(255,255,255,0.4);
    margin-bottom: 0;
    white-space: nowrap;
}

.footer__credits a       { color: rgba(255,255,255,0.6); }
.footer__credits a:hover,
.footer__credits a:focus-visible { color: #fff; }


/* ── Layout — Bootstrap overrides ───────────────────────────────────────────── */

.container-fluid {
    --bs-gutter-x: var(--gutter-off);
}

.row {
    --bs-gutter-x: var(--gutter-in);
}


/* ── Sections ────────────────────────────────────────────────────────────────── */

.section,
[class^="section-"] {
    padding-block: var(--p-90);
}


/* ── Bootstrap .btn — override globali ──────────────────────────────────────── */
/*
 * Mai ricreare bottoni da zero — usare sempre classi Bootstrap native (.btn-primary, .btn-light…).
 * Le varianti progetto si definiscono sovrascrivendo --bs-btn-* sulla classe specifica.
 */

.btn {
    --bs-btn-font-family:      var(--font-family-base);
    --bs-btn-font-size:        var(--fs-16);
    --bs-btn-font-weight:      600;
    --bs-btn-padding-x:        1.875rem;
    --bs-btn-padding-y:        0.765rem;
    --bs-btn-border-radius:    100px;
    --bs-btn-focus-box-shadow: var(--focus-ring);
    letter-spacing: -0.01em;
}


/* ── .text — Prosa ───────────────────────────────────────────────────────────── */
/*
 * Classe riutilizzabile per qualsiasi box testuale (moduli, descrizioni, body...).
 * Usare class="text" sul wrapper del contenuto.
 * Per contenuto editoriale full (page.php): class="page-content__body text"
 * (.page-content__body = hook layout, tipografia in .text)
 */

.text {
    font-weight: 400;
    font-size: var(--fs-20);
    line-height: 1.75;
    color: var(--color-text-editorial);
}

/* Gerarchia heading relativa al font-size del contesto (.text)
   em è corretto qui: scala automaticamente se .text cambia dimensione */
.text :is(h1, h2)     { font-size: 1.5em; }
.text :is(h3, h4)     { font-size: 1.25em; }
.text :is(h5, h6)     { font-size: 1.1em; }

.text :is(h1, h2, h3, h4, h5, h6) {
    font-weight: 600;
    line-height: 1.3;
}

.text :is(h1, h2, h3, h4, h5, h6):not(:first-child) {
    padding-top: 2em;
}

.text :is(p, ul, ol):not(:first-child) {
    padding-top: 1.2em;
}

.text :is(ul, ol) {
    padding-left: 1em;
}

.text strong {
    font-weight: 600;
}

.text a:not(.btn) {
    color: var(--color-accent);
    text-decoration: underline;
}

.text a:not(.btn):hover {
    text-decoration: none;
}


/* ── Eyebrow & Title — tipografia modulare ───────────────────────────────────── */
/*
 * Classi standalone riutilizzabili nei moduli flessibili e ovunque serva
 * un blocco titolo strutturato. Non BEM — si usano da sole o in combinazione.
 *
 *   <p class="eyebrow">I nostri servizi</p>
 *   <h2 class="title">Cosa facciamo per te</h2>
 */

.eyebrow {
    display: block;
    font-size: var(--fs-14);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-accent);
    margin-bottom: 0.75rem;
}

.title {
    font-size: var(--fs-40);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 1.5rem;
}


/* ── Page wrap — pagine semplici (legal, 404…) ───────────────────────────────── */
/*
 * .page-wrap    — padding verticale di sezione, max-width leggibile, centrato
 * .page-title   — h1 standalone, usabile in page.php, 404.php e simili
 *
 * page.php:  class="page-wrap"  +  class="page-title"  +  class="text"
 * 404.php:   class="page-wrap"  +  class="page-title"
 */

.page-wrap {
    padding-block: var(--p-90);
}

.page-title {
    font-size: var(--fs-70);
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: var(--color-text);
    margin-bottom: 2rem;
}


/* ── Module: Hero ────────────────────────────────────────────────────────────── */

.module-hero {
    position: relative;
    min-height: clamp(60vh, 80vh, 90vh);
    display: flex;
    align-items: center;
    overflow: hidden;
    background: var(--color-primary);
    color: #fff;
}

.module-hero__media {
    position: absolute;
    inset: 0;
    margin: 0;
}

.module-hero__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.45;
}

.module-hero__overlay {
    position: relative;
    z-index: 1;
    width: 100%;
    padding-block: var(--p-90);
}

.module-hero__title {
    font-size: var(--fs-80);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
    color: inherit;
}

.module-hero__subtitle {
    font-size: var(--fs-22);
    margin-bottom: 2rem;
    color: rgba(255,255,255,0.85);
}

.module-hero__cta {
    padding: 0.75rem 2rem;
    font-weight: 600;
}


/* ── Card Post ───────────────────────────────────────────────────────────────── */

.card-post {
    margin-bottom: 2rem;
}

.card-post__img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.card-post__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-post__title a:hover,
.card-post__title a:focus-visible {
    color: var(--color-accent);
}

.card-post__excerpt p {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
}


/* ── 404 ─────────────────────────────────────────────────────────────────────── */
/* Nessuna regola specifica: usa il body text di default + .page-wrap + .page-title */
