/* Audioguide — frontend pubblico (mobile first, WCAG AA) */

/* Palette from accessosenzalimiti.it (primary #1079bf); text and dark tones tuned for WCAG AA */
:root {
    --c-primary: #1079bf;        /* site brand blue: 4.6:1 on white */
    --c-primary-dark: #0b5e96;   /* hover / small text on light backgrounds */
    --c-primary-soft: #e7f2fa;
    --c-accent: #1079bf;
    --c-accent-ink: #ffffff;
    --c-bg: #f7f7f7;             /* site light section background */
    --c-surface: #ffffff;
    --c-ink: #333333;            /* site body text */
    --c-muted: #5a5a5a;
    --c-line: #e3e3e3;
    --c-ok: #1d7a46;
    --c-error: #b3261e;
    --c-focus: #ffbf47;
    --f-head: "Poppins", Arial, Helvetica, sans-serif;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(16, 121, 191, .10);
    --fs: 18px;
    --tap: 56px;
    font-size: var(--fs);
}

html[data-size="l"] { --fs: 21px; }
html[data-size="xl"] { --fs: 25px; }

html[data-contrast="high"] {
    --c-primary: #000;
    --c-primary-dark: #000;
    --c-accent: #ffe600;
    --c-accent-ink: #000;
    --c-bg: #fff;
    --c-surface: #fff;
    --c-ink: #000;
    --c-muted: #000;
    --c-line: #000;
    --shadow: none;
}
html[data-contrast="high"] .topbar-strip, html[data-contrast="high"] .site-footer { background: #000; }
html[data-contrast="high"] .topbar-inner { border-bottom: 3px solid #000; }
html[data-contrast="high"] .btn-primary, html[data-contrast="high"] .btn-scan { background: #000; color: #ffe600; border-color: #000; }
html[data-contrast="high"] a { text-decoration: underline; }
html[data-contrast="high"] .stop, html[data-contrast="high"] .info-box,
html[data-contrast="high"] .player, html[data-contrast="high"] .tour-card { border: 2px solid #000; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--c-bg);
    color: var(--c-ink);
    font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--c-primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-family: var(--f-head); font-weight: 600; color: var(--c-ink); }
h1 { color: var(--c-primary-dark); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; margin-top: 1.5em; }
.h3, h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

:focus-visible {
    outline: 4px solid var(--c-focus);
    outline-offset: 2px;
    border-radius: 6px;
}

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

.skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 100;
    background: var(--c-accent); color: var(--c-accent-ink);
    padding: 12px 16px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 8px; }

.container { width: 100%; max-width: 900px; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }
.narrow { max-width: 680px; }
.lead { font-size: 1.1rem; color: var(--c-muted); }
.hint, .meta { color: var(--c-muted); font-size: .9rem; }
.eyebrow { font-size: .9rem; color: var(--c-muted); margin-bottom: .3em; }
.eyebrow a { color: inherit; }

/* Top bar: blue strip + white header with logo, as on accessosenzalimiti.it */
.topbar { background: var(--c-surface); position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 8px rgba(0, 0, 0, .08); }
.topbar-strip { background: var(--c-primary); color: #fff; font-size: .8rem; padding: calc(4px + env(safe-area-inset-top)) 16px 4px; text-align: center; letter-spacing: .03em; font-family: var(--f-head); font-weight: 500; }
.topbar-inner { display: flex; align-items: center; gap: 8px; max-width: 900px; margin: 0 auto; padding: 6px 8px; min-height: 64px; }
.brand { display: flex; align-items: center; flex: 1; min-width: 0; text-decoration: none; }
.brand img { height: 54px; width: auto; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 48px; height: 48px; border-radius: 10px; padding: 0 8px;
    background: transparent; border: 0; color: var(--c-primary); cursor: pointer; font: inherit;
}
.icon-btn:hover { background: var(--c-primary-soft); }
.icon-btn-a11y { border: 2px solid var(--c-primary); }
.icon-btn-a11y[aria-expanded="true"] { background: var(--c-primary); color: #fff; }
.a11y-label { font-family: var(--f-head); font-weight: 600; font-size: .85rem; }
@media (max-width: 380px) { .a11y-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
.icon-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg circle { fill: currentColor; stroke: none; }

.a11y-panel { background: var(--c-surface); color: var(--c-ink); padding: 16px; border-bottom: 1px solid var(--c-line); display: flex; flex-wrap: wrap; gap: 16px; align-items: end; justify-content: center; }
.a11y-panel[hidden] { display: none; }
.a11y-panel fieldset { border: 0; padding: 0; margin: 0; }
.a11y-panel legend { font-weight: 700; margin-bottom: 6px; }
.seg { display: inline-flex; border: 2px solid var(--c-primary); border-radius: 12px; overflow: hidden; }
.seg button { min-width: var(--tap); min-height: 48px; border: 0; background: var(--c-surface); color: var(--c-primary); font: inherit; font-weight: 700; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--c-primary); }
.seg button[aria-pressed="true"] { background: var(--c-primary); color: #fff; }
.seg .seg-l { font-size: 1.2em; }
.seg .seg-xl { font-size: 1.45em; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: var(--tap); padding: 12px 22px;
    border-radius: var(--radius); border: 2px solid transparent;
    font: inherit; font-family: var(--f-head); font-weight: 600; text-decoration: none; cursor: pointer;
    text-align: center;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-outline { background: var(--c-surface); color: var(--c-primary); border-color: var(--c-primary); }
.btn-scan {
    width: 100%; background: var(--c-accent); color: var(--c-accent-ink);
    font-size: 1.2rem; min-height: 72px; box-shadow: var(--shadow);
}
.btn-scan svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.btn-scan-small { font-size: 1rem; min-height: var(--tap); }

/* Hero */
.hero { margin-bottom: 20px; }
.hero-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); margin-bottom: 16px; }
.preview-banner { background: #fff3cd; color: #5c4400; border: 2px dashed #c79100; padding: 10px 14px; border-radius: 10px; font-weight: 700; }

/* Info boxes / details */
.info-box, details.transcript {
    background: var(--c-surface); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 4px 18px; margin: 20px 0;
}
details > summary {
    min-height: var(--tap); display: flex; align-items: center; gap: 10px;
    font-weight: 700; cursor: pointer; list-style: none; color: var(--c-primary);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+"; display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border: 2px solid currentColor; border-radius: 50%; font-size: 1.1rem; line-height: 1; }
details[open] > summary::before { content: "−"; }
details[open] { padding-bottom: 12px; }
aside.info-box { padding: 16px 18px; }
.prose p { font-size: 1.05rem; }

/* View switch */
.view-switch { display: flex; margin: 24px 0 0; border: 2px solid var(--c-primary); border-radius: var(--radius); overflow: hidden; }
.seg-btn { flex: 1; min-height: var(--tap); border: 0; background: var(--c-surface); color: var(--c-primary); font: inherit; font-weight: 700; cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--c-primary); color: #fff; }

/* Stops list */
.count { color: var(--c-muted); font-weight: 400; }
.stop-list, .card-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.stop {
    display: flex; align-items: center; gap: 14px;
    background: var(--c-surface); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px 14px; min-height: 76px; text-decoration: none; color: var(--c-ink);
}
.stop:hover { outline: 2px solid var(--c-primary); }
.stop-n {
    flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%;
    background: var(--c-primary); color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: 1.15rem;
}
.stop-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stop-title { font-weight: 700; font-size: 1.05rem; }
.stop-done { color: var(--c-ok); }
.stop-done svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.stop.is-done .stop-n { background: var(--c-ok); }

.view-switch + #view-list, .view-switch ~ #view-map { margin-top: 16px; }

/* Compact tour cards: thumbnail left, text right (many tours fit on one screen) */
.tour-card {
    display: flex; align-items: center; gap: 14px; min-height: 96px;
    background: var(--c-surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
    text-decoration: none; color: var(--c-ink); padding-right: 12px;
}
.tour-card:hover { outline: 2px solid var(--c-primary); }
.tour-card > img { flex: 0 0 96px; width: 96px; height: 96px; object-fit: cover; align-self: stretch; height: auto; min-height: 96px; }
.tour-card-ph { flex: 0 0 96px; width: 96px; align-self: stretch; display: grid; place-items: center; background: var(--c-primary-soft); }
.tour-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 12px 0; gap: 2px; }
.tour-card-body strong { font-family: var(--f-head); font-weight: 600; font-size: 1.05rem; color: var(--c-primary-dark); line-height: 1.25; }
.tour-card-sub { font-size: .95rem; }
.tour-card-go { flex: 0 0 auto; font-size: 2rem; line-height: 1; color: var(--c-primary); }

/* Map */
.map { height: 60vh; min-height: 320px; border-radius: var(--radius); margin-bottom: 12px; z-index: 1; }
.map-pin { background: var(--c-primary); color: #fff; border: 3px solid #fff; border-radius: 50%; display: grid !important; place-items: center; font-weight: 700; font-size: 16px; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.map-pin.is-done { background: var(--c-ok); }
.me-pin { background: #e8590c; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 6px rgba(232, 89, 12, .25); }
.leaflet-popup-content { font-size: 16px; }
.leaflet-popup-content a.btn { color: #fff; min-height: 44px; padding: 8px 14px; margin-top: 8px; }

/* Checkpoint page */
.cp-image { width: 100%; border-radius: var(--radius); margin: 4px 0 16px; max-height: 45vh; object-fit: cover; }
.info-img { width: 100%; border-radius: 8px; margin: 4px 0 14px; max-height: 260px; object-fit: cover; }

.player { background: var(--c-surface); border-radius: calc(var(--radius) + 6px); box-shadow: var(--shadow); padding: 20px 16px; margin: 16px 0; text-align: center; }
.player audio { width: 100%; }
.player.is-enhanced audio { display: none; }
.play-btn {
    width: 120px; height: 120px; border-radius: 50%; border: 0;
    background: var(--c-primary); color: #fff; cursor: pointer;
    display: inline-grid; place-items: center; box-shadow: 0 6px 20px rgba(16, 121, 191, .35);
    transition: transform .12s;
}
.play-btn:active { transform: scale(.96); }
.play-btn svg { width: 56px; height: 56px; fill: currentColor; grid-area: 1 / 1; }
.play-btn .i-pause, .player.is-playing .play-btn .i-play { display: none; }
.player.is-playing .play-btn .i-pause { display: block; }
.play-btn .i-play { margin-left: 6px; }
.player.is-loading .play-btn { opacity: .75; }
.play-label { font-weight: 700; font-size: 1.15rem; margin: 10px 0 14px; color: var(--c-primary); }

.progress-row { display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; font-size: .95rem; }
.seek { flex: 1; min-width: 0; height: 44px; accent-color: var(--c-primary); cursor: pointer; }
.controls-row { display: flex; justify-content: center; gap: 12px; margin-top: 12px; }
.ctl {
    min-width: 76px; min-height: var(--tap); border-radius: var(--radius);
    border: 2px solid var(--c-primary); background: var(--c-surface); color: var(--c-primary);
    font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 4px; cursor: pointer;
}
.ctl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.resume { margin: 14px 0 0; }

/* Footer install link (always available while the app is not installed) */
.footer-install {
    min-height: var(--tap); padding: 10px 20px; margin: 4px 0 12px;
    background: #fff; color: var(--c-primary-dark); border: 0; border-radius: var(--radius);
    font: inherit; font-family: var(--f-head); font-weight: 600; cursor: pointer;
}
.footer-install:hover { background: var(--c-primary-soft); }

/* Add to home screen: bottom banner */
.install-banner {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; gap: 12px; align-items: flex-start;
    max-width: 680px; margin: 0 auto;
    background: var(--c-surface); color: var(--c-ink);
    border-top: 4px solid var(--c-primary); border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .18);
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom)) 16px;
    transform: translateY(110%); transition: transform .35s ease-out;
}
.install-banner.is-in { transform: none; }
.install-icon { flex: 0 0 auto; border-radius: 12px; box-shadow: 0 1px 6px rgba(0, 0, 0, .15); }
.install-body { flex: 1; min-width: 0; }
.install-title { font-family: var(--f-head); font-weight: 600; margin: 0 0 2px; color: var(--c-primary-dark); }
.install-text { margin: 0 0 10px; font-size: .95rem; }
.install-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.install-actions .btn { flex: 1; min-width: 120px; }
.install-close { flex: 0 0 auto; width: 44px; height: 44px; margin: -6px -4px 0 0; border: 0; background: transparent; color: var(--c-muted); border-radius: 50%; cursor: pointer; }
.install-close:hover { background: var(--c-primary-soft); color: var(--c-ink); }
.install-close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.ios-share { width: 20px; height: 20px; vertical-align: -4px; fill: none; stroke: var(--c-primary); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-small { min-height: 44px; font-size: .95rem; padding: 8px 14px; }
html[data-contrast="high"] .install-banner { border: 3px solid #000; }

/* Offline download */
.offline { padding: 16px 18px; }
.offline h2 { margin-top: 0; }
.offline .btn { width: 100%; margin-bottom: 8px; }
.offline-size { font-weight: 400; }
.offline-progress progress { width: 100%; height: 18px; accent-color: var(--c-primary); margin: 4px 0 10px; }
.offline-status { font-weight: 700; }
.offline-status:empty { display: none; }
.offline.is-saved { border-left: 6px solid var(--c-ok); }
.check-big { display: flex; gap: 12px; align-items: center; min-height: var(--tap); cursor: pointer; margin-bottom: 8px; }
.check-big input { width: 28px; height: 28px; accent-color: var(--c-primary); flex: 0 0 auto; }

/* LIS video */
.lis { margin: 16px 0; }
.btn-lis {
    width: 100%; background: var(--c-surface); color: var(--c-primary); border-color: var(--c-primary);
    flex-wrap: wrap; font-size: 1.1rem; min-height: 64px;
}
.btn-lis svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-lis[aria-expanded="true"] { background: var(--c-primary); color: #fff; }
.lis-sub { font-weight: 400; font-size: .85rem; width: 100%; margin-top: -6px; }
.lis-panel { margin-top: 12px; }
.lis-panel video, .lis-embed iframe { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); border: 0; display: block; }
.lis-panel video { max-height: 75vh; aspect-ratio: auto; }
/* "Apri sempre il video LIS": video first, audio becomes secondary */
.lis-first .lis { margin-top: 8px; }
.lis-first .player { padding: 14px 16px; }
.lis-first .player::before { content: "Audio per chi accompagna"; display: block; font-family: var(--f-head); font-weight: 600; color: var(--c-muted); margin-bottom: 10px; }
.lis-first .play-btn { width: 84px; height: 84px; }
.lis-first .play-btn svg { width: 40px; height: 40px; }
.lis-first .play-label { margin: 6px 0 10px; font-size: 1rem; }
.tag-lis { display: inline-block; margin-left: 8px; padding: 0 8px; border: 2px solid var(--c-primary); border-radius: 6px; color: var(--c-primary); font-weight: 700; font-size: .8rem; }

.cp-nav { display: grid; gap: 12px; margin-top: 28px; }

/* Scanner */
.scanner { margin: 16px 0 28px; }
.reader { width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 12px; }
.reader:empty { display: none; }
.reader video { width: 100% !important; display: block; }
.scan-status { font-weight: 700; min-height: 1.5em; margin-top: 10px; }
.manual { background: var(--c-surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.manual-form { display: flex; gap: 10px; }
.manual-form input {
    flex: 1; min-width: 0; min-height: var(--tap); font: inherit; font-size: 1.2rem; letter-spacing: .08em;
    padding: 8px 14px; border: 2px solid var(--c-muted); border-radius: var(--radius); text-transform: uppercase;
}

.alert { background: #fff6e0; border-left: 6px solid var(--c-accent); padding: 12px 14px; border-radius: 8px; }
.alert-error { background: #fdecea; border-color: var(--c-error); color: var(--c-error); font-weight: 700; }

/* Footer: brand blue with institutional logos, as on the main site */
.site-footer { background: var(--c-primary); color: #fff; text-align: center; font-size: .9rem; padding: 28px 16px calc(20px + env(safe-area-inset-bottom)); margin-top: 24px; }
.footer-inner { max-width: 900px; margin: 0 auto; }
.site-footer a { color: #fff; font-weight: 700; }
.footer-claim { font-family: var(--f-head); }
.footer-logos { width: 100%; max-width: 720px; height: auto; margin: 8px auto 18px; }
.site-footer .footer-admin { font-weight: 400; font-size: .8rem; opacity: .85; }

@media (min-width: 700px) {
    h1 { font-size: 2.1rem; }
    .cp-nav { grid-template-columns: 1fr 1fr; }
    .cp-nav .btn-scan { grid-column: 1 / -1; }
    .card-list { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
