/* ==========================================================================
   Il Mercatino di Sara â€” Base
   Reset, tipografia, layout di pagina, accessibilitÃ , utilitÃ .
   ========================================================================== */

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

* {
    margin: 0;
}

/* --------------------------------------------------------------------------
   L'attributo `hidden` deve sempre vincere.
   Il browser nasconde gli elementi con [hidden] { display: none }, ma una
   classe che imposta display (per esempio .accesso { display: flex }) ha una
   specificitÃ  maggiore e lo riaccenderebbe. Qui riportiamo l'attributo al
   comando, cosÃ¬ `elemento.hidden = true` funziona in tutto il sito.
   -------------------------------------------------------------------------- */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

body {
    font-family: var(--font-testo);
    font-size: var(--fs-base);
    line-height: var(--lh-testo);
    color: var(--testo);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

body.niente-scroll {
    overflow: hidden;
}

/* Il footer resta in basso anche con poco contenuto */
main {
    flex: 1 0 auto;
}

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

input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

a {
    color: inherit;
    text-decoration: none;
}

ul,
ol {
    padding: 0;
    list-style: none;
}

/* ---- Titoli ---- */
h1,
h2,
h3,
h4 {
    font-family: var(--font-titoli);
    font-weight: 600;
    line-height: var(--lh-titoli);
    letter-spacing: var(--tracking-titoli);
    color: var(--inchiostro);
    text-wrap: balance;
}

h1 {
    font-size: var(--fs-3xl);
}

h2 {
    font-size: var(--fs-2xl);
}

h3 {
    font-size: var(--fs-xl);
}

h4 {
    font-size: var(--fs-lg);
}

p {
    text-wrap: pretty;
}

/* ---- Focus visibile e coerente ---- */
:focus-visible {
    outline: 2px solid var(--oro);
    outline-offset: 3px;
    border-radius: var(--r-xs);
}

.salta-a-contenuto {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999;
    background: var(--inchiostro);
    color: var(--crema);
    padding: var(--sp-3) var(--sp-5);
    border-radius: 0 0 var(--r-sm) 0;
}

.salta-a-contenuto:focus {
    left: 0;
}

/* ---- Solo per screen reader ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Layout ---- */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.container-stretto {
    max-width: var(--container-stretto);
}

.sezione {
    padding-block: clamp(3.5rem, 9vw, 7rem);
}

.sezione--alt {
    background: var(--bg-alt);
}

.sezione--crema {
    background: linear-gradient(180deg, var(--crema) 0%, var(--crema-2) 100%);
}

/* Sfondo decorativo opacizzato: l'immagine viene impostata da una classe
   specifica (per esempio .sezione--sfondo-4) tramite background-image.
   I pattern sono piastrellati e ripetuti su tutta la sezione. */
.sezione--sfondo {
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

.sezione--sfondo::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-repeat: repeat;
    background-size: var(--sfondo-piastrella, 440px auto);
    background-position: top left;
    opacity: var(--sfondo-opacita, 0.08);
    pointer-events: none;
}

.stack>*+* {
    margin-top: var(--sp-4);
}

/* ---- Testi di supporto ---- */
.occhiello {
    font-size: var(--fs-base);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--oro);
}

.sottotitolo {
    font-size: var(--fs-lg);
    color: var(--testo-morbido);
    max-width: 62ch;
}

.muto {
    color: var(--testo-morbido);
}

.piccolo {
    font-size: var(--fs-sm);
}

.tiny {
    font-size: var(--fs-xs);
}

.testo-centro {
    text-align: center;
}

.mx-auto {
    margin-inline: auto;
}

/* Intestazione di sezione riutilizzabile */
.intestazione-sezione {
    max-width: 68ch;
    margin-bottom: clamp(2rem, 5vw, 3.5rem);
    background: #ffffffe3;
    border-radius: 20px;
    padding: 40px;
}

.intestazione-sezione--centro {
    margin-inline: auto;
    text-align: center;
}

.intestazione-sezione .occhiello {
    display: block;
    margin-bottom: var(--sp-3);
}

.intestazione-sezione h2+p {
    margin-top: var(--sp-4);
}

/* Divisore decorativo */
.divisore {
    width: 64px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--oro), transparent);
    border: 0;
    margin-block: var(--sp-5);
}

/* ---- Griglie ---- */
.griglia {
    display: grid;
    gap: clamp(1.15rem, 3vw, 2rem);
}

.griglia-prodotti {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    background: #ffffffe3;
    border-radius: 20px;
    padding: 40px;
}

/* ---- Testo lungo (pagine informative) ---- */
.prosa {
    max-width: 72ch;
}

.prosa h2 {
    margin-top: var(--sp-7);
    margin-bottom: var(--sp-4);
}

.prosa h3 {
    margin-top: var(--sp-6);
    margin-bottom: var(--sp-3);
}

.prosa p,
.prosa ul,
.prosa ol {
    margin-bottom: var(--sp-4);
    color: var(--testo-morbido);
}

.prosa strong {
    color: var(--testo);
}

.prosa ul {
    list-style: none;
}

.prosa ul li {
    position: relative;
    padding-left: var(--sp-5);
    margin-bottom: var(--sp-2);
}

.prosa ul li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--oro);
}

.prosa ol {
    list-style: decimal;
    padding-left: var(--sp-5);
}

.prosa ol li {
    margin-bottom: var(--sp-2);
}

.prosa a {
    color: var(--inchiostro);
    text-decoration: underline;
    text-decoration-color: var(--rosa-scuro);
    text-underline-offset: 3px;
}

.prosa a:hover {
    color: var(--rosa-scuro);
}

/* ---- Carte informative ---- */
.box-info {
    background: var(--surface);
    border: 1px solid var(--bordo);
    border-radius: var(--r-md);
    padding: clamp(1.25rem, 3vw, 2rem);
    box-shadow: var(--om-1);
}

.box-info h3 {
    font-size: var(--fs-lg);
    margin-bottom: var(--sp-3);
}

.box-info--oro {
    background: var(--oro-tenue);
    border-color: var(--oro-chiaro);
}

.box-info--rosa {
    background: var(--rosa-tenue);
    border-color: var(--rosa);
}

/* ---- Avviso / nota ---- */
.avviso {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-radius: var(--r-sm);
    background: var(--oro-tenue);
    border: 1px solid var(--oro-chiaro);
    font-size: var(--fs-sm);
    color: var(--inchiostro-2);
}

.avviso--errore {
    background: #FBECEA;
    border-color: #E7BBB6;
    color: #7E2F28;
}

.avviso--info {
    background: var(--salvia-tenue);
    border-color: #C8D3BF;
    color: #43503B;
}

/* ---- Stati vuoti e caricamento ---- */
.stato {
    text-align: center;
    padding: clamp(3rem, 8vw, 5rem) var(--sp-4);
    color: var(--testo-morbido);
}

.stato h3 {
    margin-bottom: var(--sp-3);
}

.scheletro {
    background: linear-gradient(90deg, var(--crema-2) 25%, var(--crema-3) 50%, var(--crema-2) 75%);
    background-size: 200% 100%;
    animation: scheletro-onda 1.4s ease-in-out infinite;
    border-radius: var(--r-md);
    aspect-ratio: 1 / 1;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Chi preferisce meno animazioni non deve vedere lo scheletro pulsare */
@media (prefers-reduced-motion: reduce) {
    .scheletro {
        animation: none;
        background: var(--crema-2);
    }
}

@keyframes scheletro-onda {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ---- Selezione ---- */
::selection {
    background: var(--rosa);
    color: var(--inchiostro);
}

/* ---- Scrollbar discreta (WebKit) ---- */
@supports selector(::-webkit-scrollbar) {
    ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    ::-webkit-scrollbar-track {
        background: var(--crema-2);
    }

    ::-webkit-scrollbar-thumb {
        background: var(--linea-forte);
        border-radius: var(--r-pill);
        border: 2px solid var(--crema-2);
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--rosa-scuro);
    }
}

/* ---- Stampa ---- */
@media print {

    .site-header,
    .site-footer,
    .drawer-carrello,
    .toast-area,
    .btn {
        display: none !important;
    }

    body {
        background: #fff;
    }
}

@media (max-width: 640px) {
    :root {
        --lh-testo: 1.62;
    }
}