/* ==========================================================
   Versione accessibile del Virtual Tour — EAA / WCAG 2.1 AA
   Obiettivi: contrasto AA, testo ridimensionabile, focus visibile,
   layout responsive e leggibile, ma gradevole anche per tutti.
   ========================================================== */

:root {
    --vta-bg: #ffffff;
    --vta-surface: #f5f6f8;
    --vta-surface-2: #eceef1;
    --vta-text: #14181f;       /* contrasto ~14:1 su bianco */
    --vta-muted: #4a5160;      /* contrasto ~7:1 su bianco */
    --vta-accent: #0a5ad6;     /* blu, contrasto AA su bianco */
    --vta-accent-ink: #ffffff;
    --vta-border: #c9cfd8;
    --vta-focus: #0a5ad6;
    --vta-radius: 12px;
    --vta-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --vta-scale: 1;            /* moltiplicatore dimensione testo (toolbar) */
    --vta-maxw: 860px;
}

* { box-sizing: border-box; }

html {
    /* Base 100% → rispetta le preferenze utente; toolbar agisce su --vta-scale */
    font-size: calc(100% * var(--vta-scale));
}

body {
    margin: 0;
    background: var(--vta-bg);
    color: var(--vta-text);
    font-family: var(--vta-font);
    font-size: 1.0625rem;
    line-height: 1.65;
    -webkit-text-size-adjust: 100%;
}

/* ── Font ad alta leggibilità (dislessia) ────────────────── */
html.vta-readable body {
    font-family: "Atkinson Hyperlegible", "Verdana", "Tahoma", var(--vta-font);
    letter-spacing: 0.01em;
    word-spacing: 0.06em;
    line-height: 1.8;
}

/* ── Contrasto elevato ───────────────────────────────────── */
html.vta-contrast {
    --vta-bg: #000000;
    --vta-surface: #0c0c0c;
    --vta-surface-2: #161616;
    --vta-text: #ffffff;
    --vta-muted: #e6e6e6;
    --vta-accent: #ffd400;
    --vta-accent-ink: #000000;
    --vta-border: #ffffff;
    --vta-focus: #ffd400;
}
html.vta-contrast img { /* mantieni leggibilità bordi immagini su nero */
    outline: 1px solid var(--vta-border);
}

/* ── Riduci animazioni (toggle utente o preferenza sistema) ── */
html.vta-reduce-motion *,
html.vta-reduce-motion *::before,
html.vta-reduce-motion *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* ── Focus visibile coerente ovunque ─────────────────────── */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
audio:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--vta-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Skip link ───────────────────────────────────────────── */
.vta-skip {
    position: absolute;
    left: 12px;
    top: -100px;
    z-index: 100;
    background: var(--vta-accent);
    color: var(--vta-accent-ink);
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    transition: top 160ms ease;
}
.vta-skip:focus { top: 12px; }

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

/* ── Header ──────────────────────────────────────────────── */
.vta-header {
    background: var(--vta-surface);
    border-bottom: 2px solid var(--vta-border);
    padding: 18px clamp(16px, 4vw, 40px);
}
.vta-header-inner {
    max-width: var(--vta-maxw);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.vta-tour-title {
    margin: 0 0 6px;
    font-size: 1.7rem;
    line-height: 1.25;
}
.vta-360-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--vta-accent);
    font-weight: 700;
    text-decoration: none;
}
.vta-360-link:hover { text-decoration: underline; }

/* Selettore lingua */
.vta-langs ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0; padding: 0;
}
.vta-langs a {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid var(--vta-border);
    border-radius: 999px;
    text-decoration: none;
    color: var(--vta-text);
    font-size: 0.95rem;
}
.vta-langs a[aria-current="true"] {
    background: var(--vta-accent);
    color: var(--vta-accent-ink);
    border-color: var(--vta-accent);
    font-weight: 700;
}

/* Barra strumenti accessibilità */
.vta-tools {
    max-width: var(--vta-maxw);
    margin: 14px auto 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.vta-tools-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--vta-surface-2);
    border-radius: 999px;
}
.vta-tools-label {
    font-size: 0.85rem;
    color: var(--vta-muted);
    margin-right: 4px;
}
.vta-tool {
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 7px 12px;
    background: var(--vta-bg);
    color: var(--vta-text);
    border: 1px solid var(--vta-border);
    border-radius: 999px;
    min-height: 40px;     /* target tocco WCAG 2.5.5 */
    min-width: 40px;
}
.vta-tool:hover { background: var(--vta-surface-2); }
.vta-tools-group .vta-tool { border: none; background: transparent; }
.vta-tools-group .vta-tool:hover { background: var(--vta-bg); }
.vta-toggle[aria-pressed="true"] {
    background: var(--vta-accent);
    color: var(--vta-accent-ink);
    border-color: var(--vta-accent);
}

/* ── Indice (TOC) ────────────────────────────────────────── */
.vta-toc {
    max-width: var(--vta-maxw);
    margin: 28px auto 0;
    padding: 0 clamp(16px, 4vw, 40px);
}
.vta-toc-title { font-size: 1.15rem; margin: 0 0 10px; }
.vta-toc ol {
    margin: 0; padding-left: 1.4em;
    columns: 2;
    column-gap: 32px;
}
.vta-toc li { margin: 4px 0; break-inside: avoid; }
.vta-toc a { color: var(--vta-accent); }
@media (max-width: 560px) { .vta-toc ol { columns: 1; } }

/* ── Main ────────────────────────────────────────────────── */
.vta-main {
    max-width: var(--vta-maxw);
    margin: 0 auto;
    padding: 20px clamp(16px, 4vw, 40px) 80px;
}
.vta-main:focus { outline: none; }

.vta-intro {
    background: var(--vta-surface);
    border: 1px solid var(--vta-border);
    border-radius: var(--vta-radius);
    padding: 16px 20px;
    margin: 16px 0 8px;
}
.vta-intro p { margin: 0 0 8px; }
.vta-intro p:last-child { margin-bottom: 0; }

/* ── Scena ───────────────────────────────────────────────── */
.vta-scene {
    padding: 28px 0;
    border-top: 2px solid var(--vta-border);
    scroll-margin-top: 16px;
}
.vta-scene:first-of-type { border-top: none; }
.vta-scene-title {
    margin: 0 0 14px;
    font-size: 1.5rem;
    line-height: 1.25;
}
.vta-scene-kicker {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--vta-muted);
    font-weight: 700;
}
/* Piani (multipiano): intestazione di gruppo sopra le scene di un piano
   ("Piano 2", "Piano terra", "Altro"). Emessa solo con >= 2 piani distinti. */
.vta-floor-heading {
    margin: 36px 0 0;
    padding-top: 22px;
    border-top: 3px solid var(--vta-border);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--vta-muted);
}
/* La riga di separazione la fa gia' l'intestazione di gruppo. */
.vta-floor-heading + .vta-scene { border-top: none; padding-top: 20px; }
.vta-scene-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 420px;
    object-fit: cover;
    border-radius: var(--vta-radius);
    margin: 0 0 16px;
    background: var(--vta-surface-2);
}
.vta-scene-desc {
    font-size: 1.08rem;
    margin: 0 0 16px;
}

/* ── Audio + trascrizione ────────────────────────────────── */
.vta-audio {
    background: var(--vta-surface);
    border: 1px solid var(--vta-border);
    border-radius: var(--vta-radius);
    padding: 16px;
    margin: 0 0 18px;
}
.vta-audio-head { margin: 0 0 10px; }
.vta-audio-eyebrow {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--vta-muted);
    font-weight: 700;
}
.vta-audio-title { display: block; font-weight: 700; font-size: 1.1rem; }
.vta-audio-player { width: 100%; margin: 4px 0 0; }
.vta-transcript {
    margin-top: 12px;
    border-top: 1px solid var(--vta-border);
    padding-top: 10px;
}
.vta-transcript summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--vta-accent);
    padding: 4px 0;
}
.vta-transcript-body { margin-top: 8px; }

/* ── Punti di interesse ──────────────────────────────────── */
.vta-poi h3, .vta-nav h3 {
    font-size: 1.15rem;
    margin: 0 0 12px;
}
.vta-poi-list { list-style: none; margin: 0 0 18px; padding: 0; }
.vta-poi-item {
    background: var(--vta-surface);
    border: 1px solid var(--vta-border);
    border-radius: var(--vta-radius);
    padding: 16px;
    margin: 0 0 12px;
}
.vta-poi-title { margin: 0 0 8px; font-size: 1.1rem; }
.vta-poi-img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0 0 10px;
}
.vta-poi-body :first-child { margin-top: 0; }
.vta-poi-body :last-child { margin-bottom: 0; }
.vta-link { color: var(--vta-accent); font-weight: 600; }

/* ── Pannello (story card -> lista lineare accessibile) ──── */
.vta-pannello-slide { margin: 0 0 16px; }
.vta-pannello-slide:last-child { margin-bottom: 0; }
.vta-pannello-slide img { max-width: 100%; height: auto; }

/* ── Navigazione tra scene ───────────────────────────────── */
.vta-nav-list { list-style: none; margin: 0; padding: 0; }
.vta-nav-list li { margin: 0 0 8px; }
.vta-nav-link {
    display: block;
    padding: 12px 16px;
    background: var(--vta-surface-2);
    border: 1px solid var(--vta-border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--vta-text);
}
.vta-nav-link:hover { background: var(--vta-surface); border-color: var(--vta-accent); }
.vta-nav-link strong { color: var(--vta-accent); }
.vta-nav-tip { color: var(--vta-muted); }

.vta-backtop { margin: 18px 0 0; }
.vta-backtop a { color: var(--vta-muted); font-size: 0.95rem; }

/* ── Stampa ──────────────────────────────────────────────── */
@media print {
    .vta-tools, .vta-langs, .vta-360-link, .vta-skip, .vta-backtop, .vta-audio-player { display: none; }
    body { font-size: 12pt; color: #000; background: #fff; }
    .vta-scene { page-break-inside: avoid; }
}
