/* ============================
   Legal Documents (Privacy Policy / Termini e Condizioni)
   Stile condiviso per le pagine in public/apps/ — coerente con main.css
   Richiede che main.css sia caricato PRIMA di questo file (usa le sue
   variabili :root, il reset, header, footer e wipe).
   ============================ */

/* ============================
   Hero del documento
   ============================ */
.legal-hero {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.legal-hero::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: -6%;
    width: 34%;
    background: var(--bg-secondary);
    transform: skewX(-18deg);
}

.legal-hero-inner {
    position: relative;
    max-width: var(--container);
    margin: 0 auto;
    padding: 56px var(--gutter) 48px;
}

.legal-back {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.legal-back svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.legal-back:hover svg {
    transform: translateX(-3px);
}

.legal-eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.legal-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(64px, 10vw, 120px);
    line-height: 0.95;
    text-transform: uppercase;
    margin-bottom: 20px;
    overflow-wrap: anywhere;
}

.legal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 28px;
    font-size: 14px;
    color: var(--text-muted);
}

.legal-meta strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============================
   Layout: indice laterale + testo
   ============================ */
.legal-layout {
    max-width: var(--container);
    margin: 0 auto;
    padding: 56px var(--gutter) 96px;
    display: flex;
    flex-wrap: wrap;
    gap: 56px;
    align-items: flex-start;
}

.legal-aside {
    flex: 0 1 240px;
    min-width: 220px;
    position: sticky;
    top: calc(var(--header-h) + 24px);
    max-height: calc(100vh - var(--header-h) - 48px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.legal-aside-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.legal-toc .legal-aside-label {
    margin-bottom: 6px;
}

/* ============================
   Selettore lingua (N lingue, gestito da legal.js)
   ============================ */
.legal-lang-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 0 4px;
}

.legal-lang-btn {
    padding: 8px 0;
    border: none;
    cursor: pointer;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.06em;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transform: skewX(-12deg);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.legal-lang-btn:hover {
    color: var(--text-primary);
}

.legal-lang-btn.active {
    background: var(--primary-color);
    color: var(--bg-primary);
}

/* ============================
   Indice (generato da legal.js)
   ============================ */
.legal-toc-list {
    list-style: none;
}

.legal-toc-link {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 8px 0 8px 12px;
    border-left: 2px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.legal-toc-link:hover,
.legal-toc-link[aria-current="true"] {
    color: var(--text-primary);
    border-left-color: var(--primary-color);
}

.legal-toc-num {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-color);
}

/* ============================
   Contenuto / sezioni
   ============================ */
.legal-article {
    flex: 1 1 440px;
    min-width: 0;
    max-width: 680px;
}

.legal-content {
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.legal-content[hidden] {
    display: none;
}

.legal-section {
    scroll-margin-top: calc(var(--header-h) + 32px);
}

.legal-section h2 {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    font-family: var(--font-family);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.legal-num {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    background: var(--primary-color);
    color: var(--bg-primary);
    padding: 3px 10px;
    transform: skewX(-12deg);
}

.legal-section p,
.legal-section li {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 16.5px;
    text-wrap: pretty;
}

.legal-section p {
    margin-bottom: 14px;
}

.legal-section p:last-child {
    margin-bottom: 0;
}

.legal-section ul,
.legal-section ol {
    padding-left: 1.4rem;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legal-section ul {
    list-style: none;
    padding-left: 0;
}

.legal-section ul > li {
    position: relative;
    padding-left: 22px;
}

.legal-section ul > li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0.72em;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    transform: rotate(45deg);
}

.legal-section ol > li::marker {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--primary-color);
}

.legal-section strong {
    color: var(--text-primary);
    font-weight: 600;
}

.legal-section code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--bg-secondary);
    padding: 1px 6px;
    color: var(--text-primary);
}

.legal-section a {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.legal-section a:hover {
    color: var(--text-primary);
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 800px) {
    /* Su schermi stretti l'indice non resta fisso: sta sopra al testo */
    .legal-aside {
        position: static;
        max-height: none;
        overflow: visible;
        flex-basis: 100%;
        min-width: 0;
    }

    .legal-layout {
        gap: 40px;
    }
}

@media (max-width: 640px) {
    .legal-hero-inner {
        padding-top: 32px;
        padding-bottom: 36px;
    }

    .legal-layout {
        padding-top: 40px;
        padding-bottom: 72px;
    }

    .legal-section h2 {
        font-size: 18px;
    }
}
