/* CAF Italia – stile del sito pubblico (mobile first, Bootstrap 5.3.8) */

:root {
  /* Colori del marchio, ripresi dal vecchio sito e dal logo, resi più morbidi e accessibili */
  --caf-red: #c8203a;          /* rosso istituzionale (contrasto 5,4:1 su bianco) */
  --caf-red-dark: #a3172e;
  --caf-red-deep: #7a1022;
  --caf-red-soft: #fcebee;
  --caf-sky: #0a7fb5;          /* azzurro della barra di navigazione storica */
  --caf-sky-dark: #076592;
  --caf-sky-soft: #e5f3fa;
  --caf-navy: #2a1e4c;         /* blu-viola della scritta "italia" nel logo */
  --caf-accent: #ffd200;       /* giallo "Convenzioni" */
  --caf-accent-dark: #e6bc00;
  --caf-ink: #232a31;
  --caf-slate: #2a333a;        /* grigio antracite dello sfondo storico */
  --caf-muted: #5c6670;
  --caf-line: #e3e6ea;
  --caf-bg-alt: #f6f5f4;
  --caf-radius: .75rem;

  --bs-primary: var(--caf-red);
  --bs-primary-rgb: 200, 32, 58;
  --bs-link-color: var(--caf-sky-dark);
  --bs-link-color-rgb: 7, 101, 146;
  --bs-link-hover-color: var(--caf-red);
  --bs-link-hover-color-rgb: 200, 32, 58;
  --bs-body-color: var(--caf-ink);
  --bs-secondary-color: var(--caf-muted);
  --bs-border-color: var(--caf-line);
  --bs-border-radius: .5rem;
  --bs-border-radius-lg: var(--caf-radius);
  --bs-focus-ring-color: rgba(200, 32, 58, .3);
}

body { font-size: 1rem; line-height: 1.6; text-rendering: optimizeLegibility; }
h1, h2, h3, .h1, .h2, .h3 { font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
a { text-underline-offset: .15em; }

/* Focus sempre visibile per chi naviga da tastiera */
:focus-visible { outline: 3px solid var(--caf-accent); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible { outline: 3px solid var(--caf-accent); outline-offset: 2px; box-shadow: none; }

.skip-link { position: absolute; top: .5rem; left: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .5rem; box-shadow: 0 2px 8px rgba(0,0,0,.2); }

/* Bottoni */
.btn-primary {
  --bs-btn-bg: var(--caf-red); --bs-btn-border-color: var(--caf-red);
  --bs-btn-hover-bg: var(--caf-red-dark); --bs-btn-hover-border-color: var(--caf-red-dark);
  --bs-btn-active-bg: var(--caf-red-deep); --bs-btn-active-border-color: var(--caf-red-deep);
  --bs-btn-disabled-bg: var(--caf-red); --bs-btn-disabled-border-color: var(--caf-red);
}
.btn-outline-primary {
  --bs-btn-color: var(--caf-red); --bs-btn-border-color: var(--caf-red);
  --bs-btn-hover-bg: var(--caf-red); --bs-btn-hover-border-color: var(--caf-red);
  --bs-btn-active-bg: var(--caf-red-dark); --bs-btn-active-border-color: var(--caf-red-dark);
}
.btn-accent {
  --bs-btn-color: var(--caf-ink); --bs-btn-bg: var(--caf-accent); --bs-btn-border-color: var(--caf-accent);
  --bs-btn-hover-color: var(--caf-ink); --bs-btn-hover-bg: var(--caf-accent-dark); --bs-btn-hover-border-color: var(--caf-accent-dark);
  --bs-btn-active-color: var(--caf-ink); --bs-btn-active-bg: var(--caf-accent-dark); --bs-btn-active-border-color: var(--caf-accent-dark);
  font-weight: 600;
}
.btn { min-height: 44px; }
.btn-sm { min-height: 36px; }

/* Barra superiore e intestazione */
.topbar { background: var(--caf-red); color: #fde4e8; font-size: .85rem; padding: .35rem 0; }
.topbar a { color: #fff; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.site-header { background: #fff; border-bottom: 1px solid var(--caf-line); transition: box-shadow .2s; }
.site-header.is-scrolled { box-shadow: 0 4px 16px rgba(42, 51, 58, .1); }
.site-header .navbar { padding: .5rem 0; }
.brand-logo { height: 46px; width: auto; }
@media (min-width: 992px) { .brand-logo { height: 58px; } }
.navbar-toggler { border: 0; font-size: 1.9rem; padding: .25rem .5rem; color: var(--caf-red); }
.navbar-toggler:focus { box-shadow: none; }
.navbar .nav-link { font-weight: 600; color: var(--caf-ink); padding: .75rem 0; }
.navbar .nav-link:hover, .navbar .nav-link.active { color: var(--caf-red); }
.navbar .nav-link:focus-visible { color: var(--caf-red); }
.dropdown-menu-services .dropdown-item { padding: .5rem 1rem; }
.dropdown-menu-services .bi { color: var(--caf-red); width: 1.4rem; display: inline-block; }
@media (min-width: 992px) {
  .navbar .nav-link { padding: .5rem .85rem !important; position: relative; }
  .navbar .nav-link.active::after { content: ""; position: absolute; left: .85rem; right: .85rem; bottom: -.55rem; height: 3px; background: var(--caf-red); border-radius: 2px; }
  .dropdown-menu-services { min-width: 15rem; }
}
@media (max-width: 991.98px) {
  .navbar-collapse { border-top: 1px solid var(--caf-line); margin-top: .5rem; padding-bottom: 1rem; }
  .navbar-nav .nav-item + .nav-item { border-top: 1px solid var(--caf-line); }
  .dropdown-menu-services { border: 0; padding-top: 0; }
}

/* Hero */
.hero { background: linear-gradient(120deg, var(--caf-red-deep) 0%, var(--caf-red-dark) 45%, var(--caf-red) 100%); color: #fff; padding: 2.5rem 0 3rem; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -10%; top: -30%; width: 55%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%); pointer-events: none; }
.hero .container { position: relative; z-index: 1; }
.hero-kicker { font-size: .9rem; color: #ffd9df; margin-bottom: .75rem; }
.hero-title { font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 800; margin-bottom: .75rem; }
.hero-lead { font-size: clamp(1.05rem, 2.2vw, 1.25rem); color: #fff1f3; margin-bottom: 1.5rem; }
.hero-search { background: rgba(0,0,0,.15); border: 1px solid rgba(255,255,255,.25); border-radius: var(--caf-radius); padding: 1rem; }
.hero-quick { color: #ffd9df; font-size: .95rem; }
.hero-card { background: #fff; color: var(--caf-ink); border-radius: var(--caf-radius); padding: 1.75rem; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
@media (min-width: 992px) { .hero { padding: 4rem 0 4.5rem; } }

.badge-link { display: inline-block; padding: .3rem .75rem; margin: .15rem .2rem .15rem 0; border-radius: 2rem; background: rgba(255,255,255,.15); color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; }
.badge-link:hover { background: var(--caf-accent); color: var(--caf-ink); }
main .badge-link { background: var(--caf-sky-soft); color: var(--caf-sky-dark); }
main .badge-link:hover { background: var(--caf-sky); color: #fff; }

.list-check { list-style: none; padding: 0; }
.list-check li { position: relative; padding-left: 1.8rem; margin-bottom: .6rem; }
.list-check li::before { content: "\F26E"; font-family: bootstrap-icons; position: absolute; left: 0; color: #198754; font-size: 1.15rem; line-height: 1.4; }

/* Sezioni */
.section { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.section-alt { background: var(--caf-bg-alt); }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; margin-bottom: 1.5rem; }
.section-head h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 1.9rem); }
.link-arrow { font-weight: 600; text-decoration: none; white-space: nowrap; }
.link-arrow::after { content: " →"; }
.link-back::after { content: ""; }
.link-back::before { content: "← "; }
@media (min-width: 992px) { .section { padding-top: 4rem; padding-bottom: 4rem; } }

.page-head { background: linear-gradient(120deg, var(--caf-red-deep), var(--caf-red-dark) 55%, var(--caf-red)); border-bottom: 4px solid var(--caf-sky); color: #fff; padding: 2rem 0 2.25rem; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800; margin-bottom: .5rem; }
.page-head .lead { color: #fff1f3; font-size: clamp(1rem, 2vw, 1.2rem); }
.page-head .form-label, .page-head .form-text { color: #fff1f3; }
.hero { border-bottom: 4px solid var(--caf-sky); }
nav[aria-label="Percorso"] + * .page-head { margin-top: 0; }
.breadcrumb { --bs-breadcrumb-divider-color: var(--caf-muted); --bs-breadcrumb-item-active-color: var(--caf-muted); }

/* Card */
.card { border-color: var(--caf-line); border-radius: var(--caf-radius); }
.service-card { transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
.service-card:hover, .service-card:focus-within { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(42,51,58,.12); border-color: #efb7c0; }
.service-card h2 a, .service-card h3 a { color: var(--caf-ink); text-decoration: none; }
.service-card:hover h2 a, .service-card:hover h3 a { color: var(--caf-red); }
.service-icon { display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: .75rem; background: var(--caf-red-soft); color: var(--caf-red); font-size: 1.5rem; }
.service-icon-lg { width: 3.75rem; height: 3.75rem; font-size: 1.9rem; background: rgba(255,255,255,.15); color: #fff; flex-shrink: 0; }

.news-card { border-left: 4px solid var(--caf-sky); }
.news-card a { color: var(--caf-ink); text-decoration: none; }
.news-card:hover a { color: var(--caf-red); text-decoration: underline; }
.badge-cat { font-weight: 600; letter-spacing: .02em; }
.badge-news { background: var(--caf-sky-soft); color: var(--caf-sky-dark); }
.badge-scadenze { background: #fdf0d3; color: #7a5200; }
.badge-modulistica { background: #e3f4ea; color: #155c34; }

.deadline-card { background: #fffaf0; border-color: #f3dfb0; }
.deadline-item { display: flex; gap: .85rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid #f1e3c2; }
.deadline-item:last-child { border-bottom: 0; }
.deadline-item time { flex: 0 0 3.2rem; text-align: center; background: #fff; border: 1px solid #f3dfb0; border-radius: .5rem; padding: .25rem 0; font-size: .75rem; text-transform: uppercase; color: #7a5200; font-weight: 600; line-height: 1.1; }
.deadline-item time span { display: block; font-size: 1.25rem; color: var(--caf-ink); }

.region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: .6rem; margin: 0; }
.region-grid a { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; background: #fff; border: 1px solid var(--caf-line); border-radius: .6rem; color: var(--caf-ink); text-decoration: none; font-weight: 600; min-height: 48px; }
.region-grid a:hover { border-color: var(--caf-red); color: var(--caf-red); }
.region-grid .badge { background: var(--caf-red-soft); color: var(--caf-red-dark); }

.sede-card a { color: var(--caf-ink); text-decoration: none; }
.sede-card:hover { border-color: var(--caf-red); }
.sede-card:hover a { color: var(--caf-red); }
.province-title { border-bottom: 2px solid var(--caf-red); padding-bottom: .4rem; display: inline-block; }
.sede-detail address { font-style: normal; }

.cta-card { background: var(--caf-sky-soft); border-color: #bfe0f0; }
.doc-card { text-decoration: none; color: var(--caf-ink); background: #fff; border: 2px dashed #bfe0f0; }
.doc-card:hover { border-color: var(--caf-red); color: var(--caf-red); }
.doc-card .bi { color: #c0392b; }
.other-services li a { display: block; padding: .35rem 0; text-decoration: none; }
.other-services .bi { width: 1.4rem; display: inline-block; }
.sidebar-sticky { top: 6rem; z-index: 1; }

.cta-band { background: var(--caf-sky-dark); color: #fff; }
.cta-band p { color: #e5f3fa; }

/* Testi lunghi (servizi, news, pagine) */
.prose { font-size: 1.05rem; max-width: 72ch; }
.prose h2 { font-size: 1.4rem; margin-top: 2rem; margin-bottom: .75rem; }
.prose h3 { font-size: 1.15rem; margin-top: 1.5rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: .35rem; }
.prose img { max-width: 100%; height: auto; border-radius: .5rem; }
.prose table { width: 100%; display: block; overflow-x: auto; }
.prose blockquote { border-left: 4px solid var(--caf-accent); padding-left: 1rem; color: var(--caf-muted); }
.article-title { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 800; }

.list-news { list-style: none; padding: 0; }
.list-news li { padding: .55rem 0; border-bottom: 1px solid var(--caf-line); }
.list-news li:last-child { border-bottom: 0; }
.list-news time { display: block; font-size: .8rem; color: var(--caf-muted); }

/* Ricerca sedi con risultati in tempo reale */
.sede-search { position: relative; }
.live-results { max-height: 22rem; overflow-y: auto; box-shadow: 0 12px 28px rgba(0,0,0,.15); border-radius: .6rem; position: relative; z-index: 5; }
.live-results .list-group-item { color: var(--caf-ink); }
.live-results .list-group-item small { color: var(--caf-muted); }

/* Moduli */
.form-control, .form-select { min-height: 44px; }
.form-check-input { width: 1.25em; height: 1.25em; }
.hp-field { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* Piè di pagina */
.site-footer { background: var(--caf-slate); color: #c9d0d6; margin-top: 2rem; border-top: 4px solid var(--caf-red); }
.site-footer a { color: #fff; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-brand { font-weight: 700; color: #fff; font-size: 1.15rem; margin-bottom: .5rem; }
.footer-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: #f0a3af; margin-bottom: .9rem; }
.footer-links li { margin-bottom: .45rem; }
.site-footer address { font-style: normal; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); background: #232b31; font-size: .875rem; }
.cta-band + .site-footer, .section-alt + .site-footer { margin-top: 0; }

.back-to-top { position: fixed; right: 1rem; bottom: 1rem; width: 48px; height: 48px; border-radius: 50%; display: none; align-items: center; justify-content: center; z-index: 1030; box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.back-to-top.is-visible { display: inline-flex; }

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

@media print {
  .topbar, .site-header, .site-footer, .back-to-top, .cta-card, .cta-band, .breadcrumb { display: none !important; }
  .page-head { background: none; color: #000; padding: 0; }
  .page-head .lead { color: #000; }
  a { color: #000; }
}

/* Barra servizi in stile "bottoni" del vecchio sito, ripensata come scorciatoie */
.quick-services { background: #fff; border-bottom: 1px solid var(--caf-line); }
.quick-services ul { display: flex; gap: .5rem; overflow-x: auto; padding: .6rem 0; margin: 0; list-style: none; scrollbar-width: thin; }
.quick-services a { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; padding: .35rem .8rem; border-radius: 2rem; border: 1px solid var(--caf-line); color: var(--caf-ink); text-decoration: none; font-weight: 600; font-size: .9rem; min-height: 36px; }
.quick-services a:hover { border-color: var(--caf-red); color: var(--caf-red); background: var(--caf-red-soft); }
.quick-services .bi { color: var(--caf-red); }
.section-head h2 { position: relative; padding-left: .85rem; }
.section-head h2::before { content: ""; position: absolute; left: 0; top: .2em; bottom: .2em; width: 5px; border-radius: 3px; background: var(--caf-red); }
.badge-link { background: rgba(255,255,255,.18); }
.btn-sky { --bs-btn-color: #fff; --bs-btn-bg: var(--caf-sky); --bs-btn-border-color: var(--caf-sky); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--caf-sky-dark); --bs-btn-hover-border-color: var(--caf-sky-dark); --bs-btn-active-bg: var(--caf-sky-dark); }
@media (min-width: 1200px) {
  .quick-services ul { justify-content: space-between; overflow: visible; gap: .25rem; }
  .quick-services a { padding: .3rem .6rem; font-size: .85rem; }
}
.hero .badge-link { background: rgba(255,255,255,.18); color: #fff; }
.hero .badge-link:hover { background: var(--caf-accent); color: var(--caf-ink); }
.hero .form-text, .page-head .form-text { color: #ffe3e7; }

/* File da scaricare */
.download-list li + li { border-top: 1px solid var(--caf-line); }
.download-item { display: flex; align-items: center; gap: .9rem; padding: .8rem .25rem; color: var(--caf-ink); text-decoration: none; border-radius: .5rem; }
.download-item:hover { background: var(--caf-red-soft); color: var(--caf-ink); }
.download-item:hover strong { color: var(--caf-red); }
.download-icon { flex: 0 0 2.75rem; height: 2.75rem; border-radius: .6rem; display: inline-flex; align-items: center; justify-content: center; background: var(--caf-red-soft); color: var(--caf-red); font-size: 1.4rem; }
.download-text { flex: 1; min-width: 0; }
.download-action { font-size: 1.5rem; color: var(--caf-sky); }
.downloads { border-top: 4px solid var(--caf-red); }

/* Notizie nella scheda servizio */
.service-news li { display: flex; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--caf-line); }
.service-news li:last-child { border-bottom: 0; }
.service-news time { flex: 0 0 3.6rem; text-align: center; background: var(--caf-sky-soft); color: var(--caf-sky-dark); border-radius: .5rem; padding: .35rem 0; font-size: .7rem; font-weight: 600; text-transform: uppercase; line-height: 1.15; align-self: flex-start; }
.service-news time span { display: block; font-size: 1.3rem; color: var(--caf-ink); }
.service-news h3 a { color: var(--caf-ink); text-decoration: none; }
.service-news h3 a:hover { color: var(--caf-red); text-decoration: underline; }
.page-jump { display: flex; flex-wrap: wrap; gap: .5rem; }
.page-jump a { color: #fff; font-size: .9rem; padding: .3rem .8rem; border: 1px solid rgba(255,255,255,.4); border-radius: 2rem; text-decoration: none; }
.page-jump a:hover { background: #fff; color: var(--caf-red); }
#descrizione, #documenti, #notizie, #titolo-faq { scroll-margin-top: 7rem; }

/* Immagini e file inseriti con l'editor */
.prose img.img-sm { width: 220px; }
.prose img.img-md { width: 420px; }
.prose img.img-full { width: 100%; }
.prose img.img-left { float: left; margin: .25rem 1.25rem .75rem 0; }
.prose img.img-right { float: right; margin: .25rem 0 .75rem 1.25rem; }
.prose img.img-center { display: block; margin: 1.25rem auto; }
.prose::after { content: ""; display: table; clear: both; }
@media (max-width: 575.98px) {
  .prose img.img-left, .prose img.img-right { float: none; display: block; margin: 1rem auto; }
  .prose img.img-md, .prose img.img-full { width: 100%; }
}
.prose a.file-link { font-weight: 600; }
.prose a.file-link::before { content: "\f356"; font-family: bootstrap-icons; font-weight: normal; margin-right: .3rem; color: var(--caf-red); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; }
.prose th, .prose td { border: 1px solid var(--caf-line); padding: .45rem .65rem; vertical-align: top; }
.prose th { background: var(--caf-bg-alt); }

/* Copertina delle notizie */
.news-cover { border-radius: var(--caf-radius); overflow: hidden; margin-bottom: 1.5rem; }
.news-cover img { width: 100%; height: auto; max-height: 420px; object-fit: cover; display: block; }
.news-card-img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; border-top-left-radius: inherit; border-top-right-radius: inherit; }

/* ---------- v5: avvisi, in primo piano, nuove categorie ---------- */
.badge-avvisi { background: #fde5e8; color: #8f1527; }
.badge-circolari { background: #ece8f7; color: #45307a; }
.badge-primo { background: var(--caf-red, #c8203a); color: #fff; font-weight: 600; }
.notice-bar .notice-item { background: #fff4d6; color: #5c3d00; padding: .6rem 3rem; border-bottom: 1px solid #f0d995 !important; }
.notice-bar .notice-link { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.notice-bar .notice-link:hover { color: #000; }
.notice-bar .btn-close { padding: .9rem 1rem; }
.news-lead { border: 0; box-shadow: 0 6px 24px rgba(16, 42, 80, .1); overflow: hidden; border-left: 4px solid var(--caf-red, #c8203a); }
.news-lead-img { width: 100%; height: 100%; min-height: 200px; max-height: 320px; object-fit: cover; }
.news-lead h3 a { color: inherit; text-decoration: none; }
.news-lead h3 a:hover { text-decoration: underline; }

/* ---------- v7: pulsante Accessibilità ---------- */
.a11y-toggle {
  position: fixed; bottom: 1rem; z-index: 1045; width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid #fff; background: var(--caf-sky-dark); color: #fff; font-size: 1.9rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); cursor: pointer;
}
.a11y-toggle:hover { background: var(--caf-navy); }
.a11y-toggle:focus-visible { outline: 3px solid var(--caf-accent); outline-offset: 2px; }
.a11y-toggle.is-active::after { content: ""; position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--caf-accent); border: 2px solid #fff; }
.a11y-destra .a11y-toggle { right: 1rem; }
.a11y-sinistra .a11y-toggle { left: 1rem; }
body.has-a11y-destra .back-to-top { bottom: calc(1rem + 68px); right: calc(1rem + 4px); }
.a11y-panel {
  position: fixed; bottom: calc(1rem + 68px); z-index: 1046; width: min(360px, calc(100vw - 2rem)); max-height: calc(100vh - 7rem); overflow-y: auto;
  background: #fff; color: var(--caf-ink); border-radius: var(--caf-radius); box-shadow: 0 12px 40px rgba(0, 0, 0, .3); border: 1px solid var(--caf-line);
}
.a11y-destra .a11y-panel { right: 1rem; }
.a11y-sinistra .a11y-panel { left: 1rem; }
.a11y-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; background: var(--caf-sky-soft); border-bottom: 1px solid var(--caf-line); border-radius: var(--caf-radius) var(--caf-radius) 0 0; }
.a11y-head h2 { color: var(--caf-sky-dark); }
.a11y-body { padding: 1rem; }
.a11y-size { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.a11y-size-label { font-weight: 600; }
.a11y-size-ctrl { display: flex; align-items: center; gap: .4rem; }
.a11y-size-ctrl .btn { min-width: 48px; min-height: 44px; font-weight: 700; }
.a11y-size-value { min-width: 3.2rem; text-align: center; font-variant-numeric: tabular-nums; }
.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.a11y-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-height: 84px; padding: .6rem .4rem;
  border: 2px solid var(--caf-line); border-radius: .6rem; background: #fff; color: var(--caf-ink); font-size: .9rem; line-height: 1.2; text-align: center;
}
.a11y-opt i { font-size: 1.5rem; color: var(--caf-sky-dark); }
.a11y-opt:hover { border-color: var(--caf-sky); }
.a11y-opt[aria-pressed="true"] { border-color: var(--caf-sky-dark); background: var(--caf-sky-soft); font-weight: 600; }
.a11y-opt[aria-pressed="true"]::after { content: "\F26E"; font-family: bootstrap-icons; color: var(--caf-sky-dark); font-size: 1rem; line-height: 1; }
.a11y-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1rem; }
.a11y-note { font-size: .8rem; color: var(--caf-muted); margin: .75rem 0 0; }

/* Dimensione del testo (Bootstrap usa rem: tutto si ingrandisce in proporzione) */
html.a11y-size-1 { font-size: 112.5%; }
html.a11y-size-2 { font-size: 125%; }
html.a11y-size-3 { font-size: 137.5%; }
html.a11y-size-4 { font-size: 150%; }
html[class*="a11y-size-"] .a11y-panel, html[class*="a11y-size-"] .a11y-toggle { font-size: 16px; }
html[class*="a11y-size-"] .a11y-toggle { font-size: 30px; }

/* Evidenzia i link */
html.a11y-links a:not(.btn) { text-decoration: underline !important; text-decoration-thickness: 2px !important; text-underline-offset: .2em; }
html.a11y-links a { outline: 2px dashed currentColor; outline-offset: 2px; }
html.a11y-links .a11y-panel a { outline: 0; }

/* Testo più leggibile */
html.a11y-font body, html.a11y-font .btn, html.a11y-font .form-control, html.a11y-font .form-select { font-family: Verdana, Tahoma, "Segoe UI", Arial, sans-serif !important; }
html.a11y-font .prose, html.a11y-font p { text-align: left !important; }

/* Più spazio nel testo (WCAG 1.4.12) */
html.a11y-spacing body *:not(i):not(.bi) { line-height: 1.8 !important; letter-spacing: .12em !important; word-spacing: .16em !important; }
html.a11y-spacing p { margin-bottom: 2em !important; }
html.a11y-spacing .a11y-panel * { letter-spacing: normal !important; word-spacing: normal !important; line-height: 1.3 !important; }

/* Ferma le animazioni */
html.a11y-motion *, html.a11y-motion *::before, html.a11y-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

/* Cursore grande */
html.a11y-cursor, html.a11y-cursor * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M6 3l30 18-13 3 8 15-6 3-8-15-11 9z' fill='%23000' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 6 3, auto !important; }
html.a11y-cursor a, html.a11y-cursor button, html.a11y-cursor [role="button"], html.a11y-cursor label, html.a11y-cursor select { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M6 3l30 18-13 3 8 15-6 3-8-15-11 9z' fill='%23c8203a' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 6 3, pointer !important; }

/* Guida di lettura */
.a11y-guide-bar { position: fixed; left: 0; right: 0; height: 40px; z-index: 1040; pointer-events: none; background: rgba(255, 210, 0, .18); border-top: 3px solid var(--caf-accent-dark); border-bottom: 3px solid var(--caf-accent-dark); }

/* Scala di grigi (il pannello resta a colori) */
html.a11y-gray body > *:not(.a11y-root):not(.a11y-guide-bar) { filter: grayscale(1); }

/* Alto contrasto: fondo nero, testo bianco, link gialli */
html.a11y-contrast body, html.a11y-contrast body *:not(.a11y-guide-bar) {
  background-color: #000 !important; background-image: none !important; color: #fff !important;
  border-color: #fff !important; box-shadow: none !important; text-shadow: none !important;
}
html.a11y-contrast a, html.a11y-contrast a * { color: #ffeb3b !important; }
html.a11y-contrast .btn, html.a11y-contrast .form-control, html.a11y-contrast .form-select, html.a11y-contrast .card, html.a11y-contrast .badge { border: 2px solid #fff !important; }
html.a11y-contrast .btn:hover, html.a11y-contrast a:hover { outline: 2px solid #ffeb3b; }
html.a11y-contrast .brand-logo, html.a11y-contrast .prose img, html.a11y-contrast .news-card-img { background-color: #fff !important; padding: 2px; }
html.a11y-contrast .form-control::placeholder { color: #ccc !important; }
html.a11y-contrast .btn-close { background: transparent var(--bs-btn-close-bg) center / 1em auto no-repeat !important; filter: invert(1); opacity: 1; }
html.a11y-contrast .a11y-opt[aria-pressed="true"] { outline: 3px solid #ffeb3b; }
html.a11y-contrast .a11y-toggle { border: 3px solid #ffeb3b !important; }
html.a11y-contrast *:focus-visible { outline: 3px solid #ffeb3b !important; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print { .a11y-root, .a11y-guide-bar { display: none !important; } }
.form-privacy-note { font-size: .82rem; color: var(--caf-muted); margin: .5rem 0 0; line-height: 1.45; }

/* ---------- v7: esperienza d'uso su smartphone e tocco ---------- */
.header-quick { display: flex; gap: .25rem; margin-right: .25rem; }
.header-quick-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; padding: .2rem .4rem; border-radius: .5rem; color: var(--caf-red); text-decoration: none; font-size: .7rem; font-weight: 600; line-height: 1.1; }
.header-quick-btn i { font-size: 1.35rem; }
.header-quick-btn:hover, .header-quick-btn:focus-visible { background: var(--caf-red-soft); color: var(--caf-red-dark); }
.navbar-toggler { min-width: 48px; min-height: 48px; }
/* Bersagli di tocco ampi (WCAG 2.5.8) */
.link-arrow { display: inline-block; padding: .55rem 0; }
.footer-links a { display: inline-block; padding: .2rem 0; }
.footer-bottom a { display: inline-block; padding: .55rem 0; }
.breadcrumb a { display: inline-block; padding: .35rem 0; }
/* Testi delle anteprime più compatti */
.news-card .card-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.news-lead p { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 575.98px) {
  .brand-logo { height: 42px; }
  .service-card-home .card-body { padding: .9rem; display: flex; flex-direction: column; align-items: flex-start; }
  .service-card-home h3 { font-size: 1rem; margin-top: .6rem !important; margin-bottom: 0; }
  .service-card-home .service-icon { width: 2.5rem; height: 2.5rem; font-size: 1.25rem; }
  .news-lead p { -webkit-line-clamp: 3; }
  .news-lead .card-body { padding: 1.1rem !important; }
  .contact-submit { width: 100%; justify-content: center; }
  .section-head { flex-wrap: wrap; row-gap: .25rem; }
  .prose { overflow-wrap: anywhere; }
}
/* Spazio in fondo per i pulsanti fissi, così non coprono l'ultima riga del piè di pagina */
body.has-a11y-destra .footer-bottom, body.has-a11y-sinistra .footer-bottom { padding-bottom: 4.5rem; }
@media (min-width: 768px) { body.has-a11y-destra .footer-bottom, body.has-a11y-sinistra .footer-bottom { padding-bottom: 0; } }
.preferred-source a { display: inline-flex; gap: .4rem; align-items: center; padding: .55rem .8rem; border: 1px solid var(--caf-line); border-radius: .5rem; text-decoration: none; color: var(--caf-ink); background: #fff; }
.preferred-source a:hover { border-color: var(--caf-sky); color: var(--caf-sky-dark); }
.topbar .topbar-highlight { background: var(--caf-accent); color: var(--caf-ink) !important; padding: .1rem .6rem; border-radius: .35rem; font-weight: 600; text-decoration: none; }
.topbar .topbar-highlight:hover { background: #fff; }
.navbar-nav .nav-link, .navbar .btn-accent { white-space: nowrap; }
@media (min-width: 992px) and (max-width: 1199.98px) {
  .navbar-nav .nav-link { padding-left: .5rem !important; padding-right: .5rem !important; }
  .brand-logo { height: 50px; }
}

/* ---------- v12: voci dei menu configurabili ---------- */
.menu-btn { font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.site-header .menu-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.topbar .menu-btn, .topbar .menu-highlight { padding: .1rem .6rem; border-radius: .35rem; font-weight: 600; text-decoration: none !important; }
.topbar .menu-btn:hover, .topbar .menu-highlight:hover { filter: brightness(1.08); }
.footer-sublinks { margin: .3rem 0 0 .9rem; font-size: .9rem; }
.footer-sublinks li { margin-bottom: .3rem; }
.dropdown-item .bi { width: 1.4rem; display: inline-block; }
/* Sito in costruzione */
body.construction { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1rem; background: linear-gradient(135deg, var(--caf-red-soft), #fff 55%, var(--caf-sky-soft)); }
.construction-box { max-width: 40rem; width: 100%; text-align: center; background: #fff; padding: 2.5rem 1.5rem; border-radius: var(--caf-radius); box-shadow: 0 12px 40px rgba(42, 51, 58, .12); border-top: 5px solid var(--caf-red); }
.construction-box img { max-width: 100%; height: auto; }
.construction-contacts li { margin: .35rem 0; }
.construction-contacts .bi { color: var(--caf-red); }
.staff-preview { position: fixed; left: 1rem; bottom: 1rem; z-index: 1050; max-width: calc(100vw - 6rem); background: #232a31; color: #fff; padding: .55rem .9rem; border-radius: .5rem; font-size: .85rem; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.staff-preview a { color: var(--caf-accent); }

/* ---------- v13: card della home (loghi, convenzioni, pubblicazioni, partner) ---------- */
.section-intro { color: var(--caf-muted); max-width: 48rem; margin: -.75rem 0 1.5rem; }
.hcard-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.hcard-piccole { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.hcard-grandi { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.hcard { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--caf-line); border-radius: var(--caf-radius); overflow: hidden; transition: box-shadow .15s, transform .15s; }
.hcard:hover, .hcard:focus-within { box-shadow: 0 10px 24px rgba(42, 51, 58, .12); transform: translateY(-2px); }
.hcard-media { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 10; background: #fff; padding: .75rem; border-bottom: 1px solid var(--caf-line); }
.hcard-piccole .hcard-media { aspect-ratio: 3 / 2; }
.hcard-grandi .hcard-media { padding: 0; }
.hcard-media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hcard-grandi .hcard-media img { width: 100%; height: 100%; object-fit: cover; }
.hcard-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.hcard-text { margin: 0; font-size: .95rem; color: var(--caf-ink); }
.hcard-link { margin-top: auto; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; padding: .25rem 0; }
.hcard-link:hover { text-decoration: underline; }
.hcard-body:only-child .hcard-link { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .hcard { transition: none; } .hcard:hover { transform: none; } }
@media (max-width: 575.98px) {
  .hcard-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
  .hcard-piccole { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .hcard-grandi { grid-template-columns: 1fr; }
  .hcard-body { padding: .7rem .75rem .8rem; }
  .hcard-text { font-size: .875rem; }
}

/* Notizia in finestra nella home */
.news-modal .modal-content { border: 0; border-radius: .75rem; overflow: hidden; box-shadow: 0 1rem 3rem rgba(0,0,0,.25); }
.news-modal .modal-header { border-top: 4px solid var(--caf-red, #c8203a); }
.news-modal-kicker { font-size: .8125rem; font-weight: 600; color: #a3192f; text-transform: uppercase; letter-spacing: .03em; }
.news-modal-img { display: block; width: 100%; max-height: 240px; object-fit: cover; }
.news-modal .modal-footer { background: #f6f7f9; }
@media (max-width: 575.98px) {
  .news-modal .modal-footer { flex-wrap: nowrap; align-items: stretch; gap: .5rem; }
  .news-modal .modal-footer > .btn { flex: 1 1 0; margin: 0; padding-inline: .5rem; font-size: .9375rem; }
}
.news-modal .btn-outline-secondary { --bs-btn-color: #4b5258; --bs-btn-border-color: #8a939b; --bs-btn-hover-bg: #4b5258; --bs-btn-hover-border-color: #4b5258; }

/* Visore dei file (PDF e immagini in finestra) */
.file-viewer .modal-content { border: 0; border-radius: .75rem; overflow: hidden; }
.file-viewer .modal-header { gap: .75rem; flex-wrap: wrap; padding: .6rem .75rem .6rem 1rem; }
.file-viewer .modal-title { flex: 1 1 14rem; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-viewer-tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; }
.file-viewer-tools .btn-outline-secondary { --bs-btn-color: #4b5258; --bs-btn-border-color: #8a939b; --bs-btn-hover-bg: #4b5258; --bs-btn-hover-border-color: #4b5258; }
.file-viewer-body { padding: 0; height: min(80vh, 60rem); background: #525659; display: flex; align-items: center; justify-content: center; }
.file-viewer-body iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.file-viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.file-viewer.is-image .file-viewer-body { background: #1f2327; }
.file-viewer.is-full .modal-content { border-radius: 0; }
.file-viewer.is-full .file-viewer-body { height: auto; flex: 1 1 auto; }
.file-viewer:fullscreen { background: #fff; }
@media (max-width: 575.98px) {
  .file-viewer .modal-dialog { margin: .5rem; }
  .file-viewer-tools { width: 100%; }
  .file-viewer-tools > * { flex: 1 1 0; }
  .file-viewer-body { height: 70vh; }
}
.file-viewer-tools .btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; white-space: nowrap; }
@media (max-width: 575.98px) {
  .file-viewer-tools .btn { padding-inline: .4rem; font-size: .875rem; }
}

.file-viewer.is-page .file-viewer-body { background: #fff; }
/* Pagina mostrata dentro la finestra del sito (?finestra=1) */
body.in-finestra { background: #fff; }
body.in-finestra main { padding-top: .5rem; }
body.in-finestra .page-hero, body.in-finestra .page-header { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.draft-bar { background: #fff3cd; color: #5c4400; font-size: .9375rem; padding: .5rem 0; border-bottom: 1px solid #f0d78c; }
/* Copertina delle pagine */
.page-banner { margin: 0; background: #e9edf1; }
.page-banner img { display: block; width: 100%; height: clamp(160px, 26vw, 380px); object-fit: cover; }
.page-aside-img { position: sticky; top: 6rem; margin: 0; }
.page-aside-img img { display: block; width: 100%; height: auto; border-radius: .75rem; box-shadow: 0 .5rem 1.5rem rgba(35, 42, 49, .12); }
.page-head.has-cover-bg { position: relative; overflow: hidden; isolation: isolate; padding: 3rem 0 3.25rem; }
.page-head-bg { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover; mix-blend-mode: luminosity; }
.page-head-bg.op-15 { opacity: .15; }
.page-head-bg.op-30 { opacity: .3; }
.page-head-bg.op-50 { opacity: .5; }
.page-head.has-cover-bg h1, .page-head.has-cover-bg .lead { text-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
@media (max-width: 991.98px) {
  .page-aside-img { position: static; }
  .page-aside-img img { max-height: 280px; object-fit: cover; }
}
@media print { .page-head-bg, .page-banner { display: none; } }
/* velatura scura sul lato del testo: il titolo resta leggibile anche con immagini molto chiare o contrastate */
.page-head.has-cover-bg::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(74, 8, 22, .6) 0%, rgba(74, 8, 22, .35) 55%, rgba(74, 8, 22, .1) 100%); pointer-events: none; }
@media (max-width: 767.98px) { .page-head.has-cover-bg::after { background: rgba(74, 8, 22, .5); } }

/* PDF nel corpo della pagina (PDF.js, senza iframe) */
.pdf-embed { border: 1px solid #dfe5ec; border-radius: .75rem; overflow: hidden; background: #eef1f4; }
.pdf-embed-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem .9rem; background: #2a333a; color: #fff; }
.pdf-embed-bar h2 { color: #fff; flex: 1 1 14rem; min-width: 0; }
.pdf-embed-info { color: #d5dbe0; }
.pdf-embed-tools { display: flex; gap: .4rem; margin-left: auto; }
.pdf-embed-pages { padding: 1rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; overflow-x: auto; }
.pdf-embed.is-zoomed .pdf-embed-pages { align-items: flex-start; }
.pdf-embed-msg { margin: 2rem 0; color: #3d4650; text-align: center; }
.pdf-page { position: relative; width: 100%; max-width: 100%; background: #fff; box-shadow: 0 .25rem 1rem rgba(35, 42, 49, .15); flex-shrink: 0; }
.pdf-embed.is-zoomed .pdf-page { max-width: none; }
.pdf-page:not(.is-ready) { background: #fff linear-gradient(90deg, #fff 0%, #f3f5f8 50%, #fff 100%); }
.pdf-page canvas { display: block; }
.pdf-links { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pdf-links a { position: absolute; pointer-events: auto; border-radius: 2px; }
.pdf-links a:hover, .pdf-links a:focus-visible { background: rgba(11, 94, 215, .15); outline: 2px solid #0b5ed7; }
/* livello di testo di PDF.js (da web/pdf_viewer.css, ridotto) */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; text-size-adjust: none; -webkit-text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgba(0, 92, 230, .3); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }
@media (max-width: 575.98px) {
  .pdf-embed-pages { padding: .5rem; }
  .pdf-embed-tools { width: 100%; }
  .pdf-embed-tools .btn:last-child { flex: 1 1 auto; }
}
@media print { .pdf-embed-bar .pdf-embed-tools { display: none; } }
