/* Portale Amministrazione Trasparente - area pubblica
   Ispirato alle linee guida di design per i siti della PA (Designers Italia). */

@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/titillium-web-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/titillium-web-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/titillium-web-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/titillium-web-latin-700-normal.woff2") format("woff2"); }

:root {
  --primary: #0066cc;
  --primary-dark: color-mix(in srgb, var(--primary) 78%, #000);
  --primary-darker: color-mix(in srgb, var(--primary) 55%, #000);
  --primary-tint: color-mix(in srgb, var(--primary) 8%, #fff);
  --primary-tint-2: color-mix(in srgb, var(--primary) 16%, #fff);
  --ink: #1a1f26;
  --ink-2: #3d4652;
  --muted: #5c6773;
  --line: #d9dfe6;
  --line-soft: #ebeff3;
  --bg: #ffffff;
  --bg-soft: #f4f6f8;
  --ok: #00805a;
  --warn: #9a5b00;
  --danger: #c0182b;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --font: "Titillium Web", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --wrap: 1240px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 1.0625rem; line-height: 1.6; color: var(--ink); background: var(--bg); }
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-underline-offset: .18em; }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid #f90; outline-offset: 2px; border-radius: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 1.4rem + 1.8vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.22rem; }
p { margin: 0 0 1em; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: #fff; color: var(--primary-darker); padding: 10px 16px; font-weight: 700; border-radius: var(--radius); box-shadow: var(--shadow); }
.skip-link:focus { top: 12px; }

/* ---------- header ---------- */
.slim-header { background: var(--primary-darker); color: #fff; font-size: .9rem; }
.slim-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; }
.slim-header a { color: #fff; text-decoration: none; font-weight: 600; }
.slim-header a:hover { text-decoration: underline; color: #fff; }

.center-header { background: var(--primary); color: #fff; }
.center-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 22px; padding-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 16px; color: #fff; text-decoration: none; min-width: 0; }
.brand:hover { color: #fff; }
.brand-logo { flex: 0 0 auto; width: 64px; height: 64px; border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.brand-logo img { max-width: 56px; max-height: 56px; object-fit: contain; }
.brand-logo .mono { color: var(--primary); font-weight: 700; font-size: 1.5rem; letter-spacing: -.02em; }
.brand-text { min-width: 0; }
.brand-name { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.15; }
.brand-sub { display: block; font-size: 1rem; opacity: .92; }
.header-search { display: flex; align-items: center; flex: 0 1 340px; }
.header-search input { flex: 1; min-width: 0; height: 44px; border: 0; border-radius: var(--radius) 0 0 var(--radius); padding: 0 14px; font: inherit; font-size: 1rem; color: var(--ink); }
.header-search button { height: 44px; width: 48px; border: 0; border-radius: 0 var(--radius) var(--radius) 0; background: #fff; color: var(--primary); display: grid; place-items: center; cursor: pointer; border-left: 1px solid var(--line); }
.header-search button:hover { background: var(--primary-tint); }

.section-bar { background: var(--primary-dark); }
.section-bar .wrap { display: flex; align-items: center; gap: 12px; min-height: 52px; color: #fff; }
.section-bar .at-title { font-weight: 700; color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; letter-spacing: .01em; }
.section-bar .at-title svg { opacity: .9; }
.nav-toggle { display: none; margin-left: auto; background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: var(--radius); padding: 6px 12px; font: inherit; font-weight: 600; cursor: pointer; }

/* ---------- breadcrumb ---------- */
.breadcrumb { padding: 18px 0 6px; font-size: .95rem; }
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 0; }
.breadcrumb li { color: var(--muted); }
.breadcrumb li + li::before { content: "/"; margin: 0 10px; color: #a3adb8; }
.breadcrumb a { color: var(--primary); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 48px; padding: 16px 0 72px; }
.layout.full { grid-template-columns: minmax(0, 1fr); }
.sidenav { align-self: start; padding-right: 4px; }
.sidenav-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 6px 0 10px; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav > ul > li { border-bottom: 1px solid var(--line-soft); }
.sidenav a { display: block; text-decoration: none; color: var(--ink-2); padding: 9px 10px; border-radius: 4px; line-height: 1.3; }
.sidenav a:hover { background: var(--bg-soft); color: var(--primary); }
.sidenav > ul > li > a { font-weight: 600; }
.sidenav li.open > a { color: var(--primary); }
.sidenav ul ul { padding: 0 0 8px 12px; border-left: 2px solid var(--primary-tint-2); margin-left: 10px; }
.sidenav ul ul a { font-size: .95rem; padding: 6px 10px; }
.sidenav a[aria-current="page"] { background: var(--primary-tint); color: var(--primary-darker); font-weight: 700; box-shadow: inset 3px 0 0 var(--primary); }
.sidenav .na-dot { color: #98a2ad; font-weight: 400; }

.page-head { margin-bottom: 28px; }
.page-head .eyebrow { display: inline-block; font-size: .82rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--primary); margin-bottom: 6px; }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--muted); font-size: .95rem; }
.meta-line strong { color: var(--ink-2); font-weight: 600; }
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 70ch; }
.prose { max-width: 75ch; }
.prose > :last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.prose blockquote { margin: 1em 0; padding: .5em 1em; border-left: 4px solid var(--primary-tint-2); color: var(--ink-2); }

/* ---------- avvisi ---------- */
.notice { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); background: var(--bg-soft); border-left: 4px solid #8b96a3; margin: 0 0 24px; }
.notice svg { flex: 0 0 auto; margin-top: 2px; }
.notice p:last-child { margin-bottom: 0; }
.notice.na { background: #f5f6f7; border-left-color: #8b96a3; color: var(--ink-2); }
.notice.info { background: var(--primary-tint); border-left-color: var(--primary); }

/* ---------- home ---------- */
.hero { padding: 8px 0 8px; }
.hero .lead { margin-bottom: 0; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-top: 36px; }
.sec-card { position: relative; border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px 18px; background: #fff; transition: box-shadow .15s, border-color .15s; display: flex; flex-direction: column; }
.sec-card:hover { box-shadow: var(--shadow); border-color: var(--primary-tint-2); }
.sec-card h2 { font-size: 1.18rem; margin: 0 0 10px; }
.sec-card h2 a { color: var(--ink); text-decoration: none; }
.sec-card h2 a:hover { color: var(--primary); }
.sec-card h2 a::after { content: ""; position: absolute; inset: 0; }
.sec-card ul { list-style: none; margin: 0; padding: 0; font-size: .93rem; color: var(--muted); }
.sec-card li { padding: 2px 0; }
.sec-card .num { font-variant-numeric: tabular-nums; font-size: .8rem; font-weight: 700; color: var(--primary); letter-spacing: .05em; margin-bottom: 4px; }
.sec-card.is-na { background: #fafbfc; }
.sec-card.is-na h2 a { color: var(--ink-2); }
.tag-na { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #5c6773; background: #eceff2; border-radius: 3px; padding: 1px 7px; margin-top: auto; align-self: flex-start; }

.home-tools { margin-top: 48px; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.tool { display: flex; gap: 14px; align-items: center; border-radius: 8px; background: var(--bg-soft); padding: 16px 18px; text-decoration: none; color: var(--ink); }
.tool:hover { background: var(--primary-tint); color: var(--ink); }
.tool strong { display: block; }
.tool span { color: var(--muted); font-size: .92rem; }
.tool svg { color: var(--primary); flex: 0 0 auto; }

/* ---------- sottosezioni figlie ---------- */
.child-list { list-style: none; margin: 0 0 36px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.child-list a { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); font-weight: 600; line-height: 1.3; height: 100%; }
.child-list a:hover { border-color: var(--primary); color: var(--primary); }
.child-list a.is-na { color: var(--muted); font-weight: 400; }
.child-list svg { flex: 0 0 auto; color: var(--primary); }

/* ---------- obblighi ---------- */
.obligation { border-top: 1px solid var(--line); padding: 28px 0 8px; }
.obligation:first-of-type { border-top: 0; padding-top: 4px; }
.obl-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; align-items: baseline; margin-bottom: 14px; }
.obl-head h2 { font-size: 1.35rem; margin: 0; flex: 1 1 420px; }
.obl-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .9rem; color: var(--muted); margin-bottom: 14px; }
.obl-meta span { display: inline-flex; align-items: center; gap: 6px; }
.obl-desc { color: var(--ink-2); font-size: .98rem; margin-bottom: 16px; max-width: 80ch; }
.obl-desc summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .93rem; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.obl-desc summary::-webkit-details-marker { display: none; }
.obl-desc summary::before { content: "+"; display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1.5px solid currentColor; border-radius: 50%; font-size: .8rem; line-height: 1; }
.obl-desc[open] summary::before { content: "–"; }
.obl-desc .desc-body { margin-top: 10px; padding: 12px 16px; background: var(--bg-soft); border-radius: var(--radius); font-size: .95rem; }
.empty { color: var(--muted); font-style: italic; margin: 8px 0 20px; }

/* documenti */
.doc { padding: 18px 0; border-bottom: 1px dashed var(--line); }
.doc:last-child { border-bottom: 0; }
.doc h3 { margin: 0 0 6px; font-size: 1.12rem; }
.doc .meta-line { font-size: .88rem; margin-bottom: 10px; }
.doc .prose { font-size: 1rem; margin-bottom: 10px; }
.files { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.file:hover { border-color: var(--primary-tint-2); background: var(--primary-tint); }
.file-badge { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 4px; display: grid; place-items: center; font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: #fff; background: #6b7785; }
.file-badge.pdf { background: #b3261e; }
.file-badge.sheet { background: #1e7b45; }
.file-badge.data { background: #6a42a8; }
.file-badge.image { background: #0d6b8c; }
.file-badge.zip { background: #6b5a2a; }
.file-body { min-width: 0; flex: 1; }
.file-body a { font-weight: 600; text-decoration: none; display: block; overflow-wrap: anywhere; }
.file-body a:hover { text-decoration: underline; }
.file-meta { font-size: .85rem; color: var(--muted); }

/* tabelle dati */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin: 4px 0 12px; }
table.data { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.data caption { text-align: left; padding: 10px 14px; font-size: .88rem; color: var(--muted); caption-side: bottom; border-top: 1px solid var(--line-soft); }
table.data th, table.data td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
table.data thead th { background: var(--bg-soft); font-weight: 700; font-size: .85rem; color: var(--ink-2); white-space: nowrap; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .file-link { display: inline-flex; gap: 6px; align-items: baseline; text-decoration: none; }
table.data .file-ext { font-size: .7rem; font-weight: 700; background: var(--primary-tint-2); color: var(--primary-darker); padding: 0 5px; border-radius: 3px; }
table.data .file-size { color: var(--muted); font-size: .8rem; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.export-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 6px 0 24px; font-size: .92rem; }
.export-bar .label { color: var(--muted); margin-right: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--primary-tint-2); background: var(--primary-tint); color: var(--primary-darker); font-weight: 600; text-decoration: none; font-size: .88rem; }
.chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.chip.ghost:hover { border-color: var(--primary); color: var(--primary); background: transparent; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 20px; }
.pager a, .pager span { min-width: 38px; height: 38px; padding: 0 10px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; text-decoration: none; font-weight: 600; }
.pager span[aria-current] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* scheda */
.sheet { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sheet dl { margin: 0; display: grid; grid-template-columns: minmax(200px, 34%) 1fr; }
.sheet dt, .sheet dd { margin: 0; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.sheet dt { background: var(--bg-soft); font-weight: 600; color: var(--ink-2); font-size: .95rem; }
.sheet dd { overflow-wrap: anywhere; }
.sheet dl > :nth-last-child(-n+2) { border-bottom: 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; margin-top: 24px; }

/* ricerca */
.search-form { display: flex; gap: 8px; max-width: 640px; margin-bottom: 28px; }
.search-form input { flex: 1; height: 48px; padding: 0 14px; border: 1px solid #8f99a4; border-radius: var(--radius); font: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 22px; border-radius: var(--radius); border: 0; background: var(--primary); color: #fff; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--primary-dark); color: #fff; }
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.results .type { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); }
.results a { font-size: 1.12rem; font-weight: 600; text-decoration: none; }
.results a:hover { text-decoration: underline; }
.results .path { font-size: .88rem; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { background: #17324d; color: #dbe4ee; font-size: .95rem; margin-top: auto; }
.site-footer a { color: #fff; }
.site-footer .wrap { padding-top: 40px; padding-bottom: 28px; }
.footer-top { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding-bottom: 28px; border-bottom: 1px solid rgba(255,255,255,.18); }
.footer-top h2 { color: #fff; font-size: 1.1rem; margin-bottom: 10px; }
.footer-top p { margin: 0 0 4px; }
.footer-top ul { list-style: none; margin: 0; padding: 0; }
.footer-top li { margin-bottom: 6px; }
.footer-bottom { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding-top: 18px; font-size: .88rem; color: #b8c6d4; }
.footer-bottom ul { display: flex; flex-wrap: wrap; gap: 6px 20px; list-style: none; margin: 0; padding: 0; }

body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidenav { position: static; max-height: none; display: none; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
  .sidenav.open { display: block; }
  .nav-toggle { display: inline-flex; }
  .footer-top { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .center-header .wrap { flex-direction: column; align-items: stretch; gap: 16px; padding-top: 16px; padding-bottom: 16px; }
  .brand-logo { width: 48px; height: 48px; }
  .brand-logo img { max-width: 42px; max-height: 42px; }
  .brand-name { font-size: 1.2rem; }
  .header-search { flex-basis: auto; }
  .slim-header .hide-sm { display: none; }
  .sheet dl { grid-template-columns: 1fr; }
  .sheet dt { border-bottom: 0; padding-bottom: 4px; }
  .sheet dd { padding-top: 4px; }
  table.data thead th { position: static; }
}
@media print {
  .slim-header, .center-header, .section-bar, .sidenav, .site-footer, .export-bar, .nav-toggle, .skip-link { display: none !important; }
  .layout { display: block; }
  a { color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
[hidden] { display: none !important; }
@media (max-width: 720px) {
  .section-bar .at-title { font-size: .95rem; }
  .nav-toggle { white-space: nowrap; padding: 6px 10px; }
}
