/* Stile condiviso - sito informativo lavori forestali. Mobile-first, nessuna dipendenza. */
:root {
  --forest: #1f4d2e;
  --forest-dark: #153822;
  --forest-soft: #e4eee6;
  --paper: #f6f4ee;
  --surface: #ffffff;
  --ink: #1d2420;
  --muted: #4a554e;
  --line: #cfd5cf;

  --info-bg: #e8f1f8;
  --info-line: #2b5f8a;
  --info-ink: #14344d;
  --warn-bg: #fff3d6;
  --warn-line: #b7791f;
  --warn-ink: #5c3b00;
  --crit-bg: #fde8e6;
  --crit-line: #a32a20;
  --crit-ink: #6b1510;

  --radius: 10px;
  --gutter: 16px;
  --measure: 46rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--font);
  overflow-wrap: break-word;
}
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; color: var(--forest-dark); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--forest); text-underline-offset: 3px; }
a:hover { color: var(--forest-dark); }

:focus-visible { outline: 3px solid #0b57d0; outline-offset: 2px; border-radius: 3px; }

.wrap { width: 100%; max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }

.skip-link {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 100;
  background: var(--surface); color: var(--ink); padding: .75rem 1rem; border-radius: var(--radius);
  border: 2px solid var(--forest);
}
.skip-link:focus { top: .5rem; }

/* Intestazione */
.site-header { background: var(--surface); border-bottom: 4px solid var(--forest); }
.site-header .wrap { padding-top: 12px; padding-bottom: 12px; }
.logos { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logos img { height: 52px; width: auto; }
.header-title { padding: 12px 0 4px; }
.header-title .eyebrow { margin: 0 0 4px; font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.header-title h1 { margin: 0; }
.header-title .subtitle { margin: .4rem 0 0; color: var(--muted); }

/* Navigazione tra le 4 sezioni: griglia 2x2 su mobile (tutte le voci sempre visibili), barra fissa su desktop */
.site-nav { background: var(--forest); }
.site-nav ul {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1px; margin: 0 auto; padding: 0; list-style: none;
  max-width: var(--measure); background: var(--forest-dark);
}
.site-nav a {
  display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 8px 12px; height: 100%;
  background: var(--forest); color: #fff; text-decoration: none; text-align: center; font-weight: 600; font-size: .95rem;
  line-height: 1.25; border-bottom: 3px solid transparent; overflow-wrap: anywhere;
}
.site-nav a:hover { background: var(--forest-dark); color: #fff; }
.site-nav a[aria-current="true"] { border-bottom-color: #fff; }
.site-nav a:focus-visible { outline-color: #fff; outline-offset: -3px; }

/* Sezioni e card */
main { padding-top: 16px; padding-bottom: 32px; }
.section { padding: 28px 0 8px; }
.section + .section { border-top: 1px solid var(--line); margin-top: 20px; }
.section-lead { color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 16px;
}
.card > :last-child { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }

/* Avvisi: sempre icona + testo, non solo colore */
.alert {
  display: flex; gap: 12px; align-items: flex-start; margin: 0 0 16px; padding: 14px 16px;
  border-radius: var(--radius); border: 2px solid; border-left-width: 8px;
}
.alert-icon { flex: none; font-weight: 700; font-size: 1.25rem; line-height: 1.4; }
.alert-body { flex: 1; min-width: 0; }
.alert-body > :last-child { margin-bottom: 0; }
.alert-title { font-weight: 700; display: block; }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.alert-critical { background: var(--crit-bg); border-color: var(--crit-line); color: var(--crit-ink); }

/* Badge di stato: simbolo + testo */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .85rem; font-weight: 700; border: 2px solid; max-width: 100%;
}
.badge-done { background: var(--forest-soft); border-color: var(--forest); color: var(--forest-dark); }
.badge-doing { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.badge-todo { background: #eef0ee; border-color: #6b756e; color: #343d37; }
.gpx-help { color: var(--muted); font-size: .95rem; }
.badge-unknown { background: #fff; border: 2px dashed #6b756e; color: #343d37; }
.progress-updated { margin: 0 0 12px; font-weight: 600; color: var(--muted); }
.badge-closed { background: var(--crit-bg); border-color: var(--crit-line); color: var(--crit-ink); }

/* Elenco fasi */
.phases { list-style: none; margin: 0; padding: 0; }
.phases li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.phases li:first-child { border-top: 0; }
.phases .phase-name { font-weight: 600; flex: 1 1 100%; }
@media (min-width: 720px) { .phases .phase-name { flex: 1 1 auto; } }
.phases .phase-note { flex-basis: 100%; margin: 0; color: var(--muted); font-size: .95rem; }

/* Barra di avanzamento */
.progress { margin: 0 0 16px; }
.progress-label { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.progress-track { height: 16px; background: #e3e7e3; border-radius: 999px; overflow: hidden; border: 1px solid #a9b2ab; }
.progress-fill { height: 100%; background: var(--forest); }

/* Pulsante grande (GPX e azioni principali) */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px;
  padding: 12px 20px; border-radius: var(--radius); border: 2px solid var(--forest); background: var(--forest);
  color: #fff; font: inherit; font-weight: 700; font-size: 1.05rem; text-decoration: none; text-align: center;
  cursor: pointer;
}
.btn:hover { background: var(--forest-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--forest-dark); }
.btn-secondary:hover { background: var(--forest-soft); color: var(--forest-dark); }
.btn-meta { display: block; font-weight: 400; font-size: .85rem; opacity: .95; }
.btn .btn-label { display: block; }

/* Planimetrie */
.figure { margin: 0 0 16px; }
.figure img { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.map-open { display: block; width: 100%; margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: zoom-in; }
.map-hint { display: block; padding: 8px 0 0; font-weight: 700; color: var(--forest-dark); }
.map-note { margin: 0 0 8px; color: var(--warn-ink); font-weight: 600; }

/* Visualizzatore a tutto schermo delle planimetrie */
.viewer { border: 0; padding: 0; width: 100%; height: 100%; max-width: none; max-height: none; background: #111; color: #fff; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(0, 0, 0, .85); }
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; padding: 6px 12px; background: #000; }
.viewer-title { order: 1; flex: 1 1 0; min-width: 0; font-weight: 700; font-size: .95rem; line-height: 1.3; }
.viewer .viewer-close { order: 2; width: auto; min-width: 6rem; min-height: 48px; padding: 8px 16px; background: #fff; color: #111; border-color: #fff; }
.viewer-link { order: 3; flex-basis: 100%; color: #fff; font-size: .9rem; min-height: 40px; display: inline-flex; align-items: center; }
.viewer .viewer-close:hover { background: #e4eee6; color: #111; }
.viewer-scroll { flex: 1; overflow: auto; background: #fff; touch-action: pan-x pan-y pinch-zoom; -webkit-overflow-scrolling: touch; }
.viewer-img { display: block; max-width: none; width: 1400px; height: auto; border: 0; border-radius: 0; }
body.viewer-open { overflow: hidden; }
@media (min-width: 720px) { .viewer-img { width: 100%; } }
.figure figcaption { padding-top: 8px; color: var(--muted); font-size: .95rem; }
.legend { margin: 8px 0 0; padding-left: 1.2em; font-size: .95rem; }

/* Testo informativo */
.lead-box { border-left: 8px solid var(--forest); }
.lead-box p { font-size: 1.1rem; }
.bullets { margin: 0 0 1em; padding-left: 1.25em; }
.bullets li { margin-bottom: .5em; }
.data-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0 16px; }
.data-box summary { cursor: pointer; padding: 14px 16px; min-height: 48px; font-weight: 700; color: var(--forest-dark); }
.data-box[open] summary { border-bottom: 1px solid var(--line); }
.facts { margin: 0; padding: 4px 16px 12px; }
.facts dt { margin-top: 12px; font-weight: 700; color: var(--forest-dark); }
.facts dd { margin: 2px 0 0; }
@media (min-width: 720px) {
  .facts { display: grid; grid-template-columns: 14rem 1fr; gap: 0 16px; }
  .facts dt { margin-top: 12px; }
  .facts dd { margin-top: 12px; }
}

/* Segnaposto per informazioni non ancora disponibili */
.placeholder {
  border: 2px dashed #6b756e; border-radius: var(--radius); padding: 14px 16px; background: #fbfbf8;
  color: var(--muted); font-style: italic;
}

/* Piè di pagina */
.site-footer { background: var(--forest-dark); color: #e9f0ea; padding: 20px 0 28px; font-size: .95rem; }
.site-footer a { color: #fff; }
.site-footer p { margin: 0 0 .5em; }
.last-update { font-weight: 700; }

@media (min-width: 720px) {
  :root { --gutter: 24px; }
  html { scroll-padding-top: 4.5rem; }
  .site-nav { position: sticky; top: 0; z-index: 50; }
  .site-nav ul { display: flex; padding: 0 calc(var(--gutter) - 16px); background: none; gap: 0; }
  .site-nav a { padding: 0 16px; height: auto; white-space: nowrap; justify-content: flex-start; text-align: left; min-height: 48px; }
  body { font-size: 1.125rem; }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.6rem; }
  .logos img { height: 64px; }
  .btn { width: auto; min-width: 280px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .grid-2 > .card { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
