/* ═══════════════════════════════════════════════════════════
   LievoEngine — core.css
   Versione: 06-05-2026

   Reset moderno + layout primitives.
   Dipende da tokens.css (variabili --lv-*): caricare tokens.css PRIMA.

   Convenzioni classi:
     .lv-*         tutto namespacato per evitare collisioni
     .lv-stack     pila verticale con gap
     .lv-cluster   gruppo orizzontale wrap con gap
     .lv-grid      griglia auto-fit
     .lv-container limite larghezza centrato
     .lv-sidebar   layout sidebar + main

   Filosofia: zero stile estetico (colori finali, ombre, decorazioni).
   Quello sta nei componenti. Qui solo struttura e reset.
   ═══════════════════════════════════════════════════════════ */


/* ─── Reset moderno minimale ─────────────────────────── */

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

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    tab-size: 4;
    -moz-tab-size: 4;
}

body {
    min-height: 100vh;
    font-family: var(--lv-ff-sans);
    font-size: var(--lv-fs-base);
    font-weight: var(--lv-fw-regular);
    line-height: var(--lv-lh-base);
    color: var(--lv-c-fg);
    background-color: var(--lv-c-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}


/* ─── Reset tipografia (titoli ed elenchi) ───────────── */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--lv-ff-display);
    font-weight: var(--lv-fw-semibold);
    line-height: var(--lv-lh-tight);
}

p, ul, ol, dl, blockquote, pre, figure {
    margin: 0;
}

ul, ol {
    list-style: none;
}

/* Quando serve una vera lista bullet, usare .lv-list */
.lv-list ul,
.lv-list ol,
ul.lv-list,
ol.lv-list {
    list-style: revert;
    padding-left: var(--lv-s-5);
}


/* ─── Reset media ─────────────────────────────────────── */

img, picture, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
}

img, video {
    height: auto;
}


/* ─── Reset link ──────────────────────────────────────── */

a {
    color: var(--lv-c-accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: color var(--lv-d-fast) var(--lv-ease);
}

a:hover {
    color: var(--lv-c-accent-strong);
}


/* ─── Reset form ──────────────────────────────────────── */

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
    background: transparent;
    border: 0;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

textarea {
    resize: vertical;
}


/* ─── Reset tabelle ───────────────────────────────────── */

table {
    border-collapse: collapse;
    border-spacing: 0;
}


/* ─── Focus ring globale (accessibilità) ─────────────── */

:focus {
    outline: 0;
}

:focus-visible {
    outline: 0;
    box-shadow: var(--lv-focus-ring);
}


/* ═══════════════════════════════════════════════════════════
   Layout primitives
   ═══════════════════════════════════════════════════════════ */


/* ─── Container ──────────────────────────────────────── */

.lv-container {
    width: 100%;
    max-width: var(--lv-container-lg);
    margin-inline: auto;
    padding-inline: var(--lv-s-4);
}

.lv-container--sm  { max-width: var(--lv-container-sm); }
.lv-container--md  { max-width: var(--lv-container-md); }
.lv-container--lg  { max-width: var(--lv-container-lg); }
.lv-container--xl  { max-width: var(--lv-container-xl); }


/* ─── Stack (pila verticale) ─────────────────────────── */

.lv-stack {
    display: flex;
    flex-direction: column;
    gap: var(--lv-s-4);
}

.lv-stack--1  { gap: var(--lv-s-1); }
.lv-stack--2  { gap: var(--lv-s-2); }
.lv-stack--3  { gap: var(--lv-s-3); }
.lv-stack--4  { gap: var(--lv-s-4); }
.lv-stack--5  { gap: var(--lv-s-5); }
.lv-stack--6  { gap: var(--lv-s-6); }
.lv-stack--8  { gap: var(--lv-s-8); }
.lv-stack--10 { gap: var(--lv-s-10); }


/* ─── Cluster (gruppo orizzontale wrap) ──────────────── */

.lv-cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--lv-s-3);
    align-items: center;
}

.lv-cluster--1 { gap: var(--lv-s-1); }
.lv-cluster--2 { gap: var(--lv-s-2); }
.lv-cluster--3 { gap: var(--lv-s-3); }
.lv-cluster--4 { gap: var(--lv-s-4); }
.lv-cluster--6 { gap: var(--lv-s-6); }

.lv-cluster--start  { justify-content: flex-start; }
.lv-cluster--end    { justify-content: flex-end; }
.lv-cluster--center { justify-content: center; }
.lv-cluster--between { justify-content: space-between; }


/* ─── Grid (auto-fit responsive) ─────────────────────── */

.lv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--lv-s-4);
}

.lv-grid--narrow { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.lv-grid--wide   { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }


/* ─── Sidebar (sidebar fissa + main fluido) ──────────── */

.lv-sidebar {
    display: grid;
    grid-template-columns: var(--lv-sidebar-w) 1fr;
    min-height: 100vh;
}

@media (max-width: 768px) {
    .lv-sidebar {
        grid-template-columns: 1fr;
    }
}


/* ─── Center (centratura singolo elemento) ───────────── */

.lv-center {
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ═══════════════════════════════════════════════════════════
   Helper utility
   ═══════════════════════════════════════════════════════════ */


/* ─── Screen-reader only ─────────────────────────────── */

.lv-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;
}


/* ─── Hidden visivo ──────────────────────────────────── */

.lv-hidden {
    display: none !important;
}


/* ─── Truncate testo ─────────────────────────────────── */

.lv-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ─── Flex helpers leggeri ───────────────────────────── */

.lv-flex-1 { flex: 1 1 0%; }
.lv-flex-auto { flex: 0 1 auto; }
.lv-flex-none { flex: 0 0 auto; }
