:root {
  --lavender: #b8a9e0;
  --lavender-dark: #7c6ab5;
  --yellow: #f5c842;
  --teal: #3a8c7e;
  --green-dark: #2c6b5e;
  --red: #d7263d;
  --grey: #9a9a9a;
  --white: #fdfcf8;
  --paper: #f4f1ea;
  --dark: #1a1525;
  --text: #2d2540;
  --muted: #6b6478;
  --line: #e2dcd0;
  --topbar: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--white);
  color: var(--text);
  line-height: 1.5;
}
h1, h2, h3 { font-family: 'Syne', 'Space Grotesk', sans-serif; color: var(--dark); line-height: 1.15; margin: 0 0 .5em; }
a { color: var(--green-dark); }
[hidden] { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.25rem;
  background: var(--white);
  border-bottom: 2px solid var(--lavender);
  position: sticky; top: 0; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--dark); font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.brand img { height: 38px; width: auto; border-radius: 4px; }
.brand em { font-style: normal; font-weight: 700; font-size: .85rem; background: var(--yellow); padding: 2px 8px; border-radius: 4px; margin-left: .25rem; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: nowrap; overflow-x: auto; }
.topbar nav a { text-decoration: none; color: var(--text); font-weight: 500; font-size: .92rem; padding: .45rem .75rem; border-radius: 999px; white-space: nowrap; }
.topbar nav a:hover { background: var(--paper); }
.topbar nav a[aria-current="page"] { background: var(--dark); color: var(--white); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: 2px solid var(--dark); background: var(--dark); color: var(--white);
  font: inherit; font-weight: 600; padding: .6rem 1.1rem; border-radius: 999px; text-decoration: none; cursor: pointer;
  transition: transform .1s, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn-small { padding: .35rem .85rem; font-size: .88rem; }
.btn-big { padding: .8rem 2rem; font-size: 1.05rem; background: var(--teal); border-color: var(--teal); }
.btn-ghost { background: transparent; color: var(--dark); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red); }

/* ---------- home ---------- */
.page-home { overflow: hidden; }
.home { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar)); }
.sidebar { overflow-y: auto; border-right: 1px solid var(--line); background: var(--white); padding: 1.25rem; }
.map { height: 100%; background: #e6e0f5; } /* "mare" color lavanda alla scala nazionale */
.map.show-tiles { background: #dfe6e9; }

/* pallini delle iniziative */
.pin i { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--red); border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(26,21,37,.35); transition: transform .15s; }
.pin.is-past i { background: var(--grey); }
.pin:hover i, .pin.is-active i { transform: scale(1.35); }
.pin.is-active i { box-shadow: 0 0 0 4px rgba(215,38,61,.25), 0 1px 4px rgba(26,21,37,.35); }
.pin.is-past.is-active i { box-shadow: 0 0 0 4px rgba(120,120,120,.25), 0 1px 4px rgba(26,21,37,.35); }
.pin-cluster { border-radius: 50%; background: var(--red); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(26,21,37,.35); color: #fff; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; }
.pin-cluster.is-past { background: var(--grey); }
.pin-cluster span { line-height: 1; }

.intro h1 { font-size: 1.5rem; }
.intro p { margin: 0 0 1rem; color: var(--muted); font-size: .95rem; }
.intro-ctas { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }

.legend { display: flex; gap: 1.25rem; font-size: .85rem; color: var(--muted); margin: .5rem 0 1rem; }
.legend span { display: flex; align-items: center; gap: .4rem; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.dot-next { background: var(--red); }
.dot-past { background: var(--grey); }

.tabs { display: flex; gap: .25rem; background: var(--paper); padding: .25rem; border-radius: 999px; margin-bottom: .75rem; }
.tab { flex: 1; border: 0; background: transparent; font: inherit; font-weight: 600; font-size: .9rem; padding: .45rem .75rem; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tab b { font-weight: 600; font-size: .8rem; margin-left: .25rem; opacity: .75; }
.tab[aria-selected="true"] { background: var(--white); color: var(--dark); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.list { list-style: none; margin: 0; padding: 0; }
.item { width: 100%; display: flex; gap: .85rem; align-items: center; text-align: left; font: inherit; color: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: .75rem .25rem; cursor: pointer; border-radius: 6px; }
.item:hover { background: var(--paper); }
.cal { flex: 0 0 52px; height: 52px; border-radius: 10px; background: var(--red); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.cal b { font-size: 1.25rem; font-family: 'Syne', sans-serif; }
.cal small { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.is-past .cal { background: var(--grey); }
.item-txt { display: flex; flex-direction: column; min-width: 0; }
.item-txt strong { font-weight: 600; color: var(--dark); }
.meta { font-size: .85rem; color: var(--muted); }
.empty { color: var(--muted); font-size: .92rem; padding: 1rem .25rem; }

.back { font: inherit; font-weight: 600; background: none; border: 0; color: var(--green-dark); cursor: pointer; padding: 0; margin-bottom: 1rem; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .2rem .6rem; border-radius: 999px; margin-bottom: .6rem; }
.badge-next { background: var(--red); color: #fff; }
.badge-past { background: #e6e6e6; color: #555; }
#detail h2 { font-size: 1.45rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: 0 0 1rem; font-size: .95rem; }
.facts dt { font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding-top: .15rem; }
.facts dd { margin: 0; }
.facts dd:first-of-type::first-letter { text-transform: uppercase; }
.desc p { margin: 0 0 .75rem; white-space: pre-line; }
.detail-ctas { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.5rem; }
.contribs { border-top: 2px solid var(--lavender); padding-top: 1rem; }
.contribs h3 { font-size: 1.05rem; }
.contrib { background: var(--paper); border-radius: 10px; padding: .85rem 1rem; margin-bottom: .75rem; font-size: .93rem; }
.contrib p { margin: 0 0 .5rem; white-space: pre-line; }
.contrib .by { color: var(--muted); font-size: .85rem; margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.tag { font-size: .75rem; background: var(--white); border: 1px solid var(--lavender); color: var(--lavender-dark); padding: .1rem .5rem; border-radius: 999px; font-weight: 600; }
.muted { color: var(--muted); font-size: .92rem; }
.add-contrib { display: inline-block; margin-top: .25rem; font-weight: 600; font-size: .92rem; }

.leaflet-tooltip { font-family: 'Space Grotesk', sans-serif; font-weight: 500; }

/* ---------- form pages ---------- */
.page-form { background: var(--paper); }
.form-wrap { max-width: 720px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.form-wrap.narrow { max-width: 420px; padding-top: 4rem; }
.form-intro { background: var(--yellow); border-radius: 16px; padding: 1.5rem 1.75rem; margin-bottom: 1.25rem; }
.form-intro h1 { font-size: 1.9rem; }
.form-intro p { margin: 0 0 .6rem; }
.form-intro p:last-child { margin-bottom: 0; }
.form, .done { background: var(--white); border-radius: 16px; padding: 1.75rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.field { margin-bottom: 1.5rem; }
.field > label { display: block; font-weight: 700; color: var(--dark); margin-bottom: .15rem; }
.req { color: var(--red); }
.help { margin: 0 0 .5rem; font-size: .88rem; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--text); }
.field input:not([type=radio]):not([type=checkbox]), .field textarea, .field select {
  width: 100%; padding: .65rem .8rem; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(58,140,126,.18); }
.field textarea { resize: vertical; min-height: 8rem; }
.has-error input, .has-error textarea, .has-error select, .has-error .picker-map, .has-error .choices { border-color: var(--red) !important; }
.error { color: var(--red); font-size: .88rem; font-weight: 600; margin: .35rem 0 0; }
.form-error { background: #fde8ea; color: var(--red); font-weight: 600; padding: .6rem .9rem; border-radius: 10px; margin: 0 0 1.25rem; }
.choices { display: flex; flex-direction: column; gap: .35rem; border: 1.5px solid transparent; border-radius: 10px; }
.choice { display: flex; gap: .55rem; align-items: center; cursor: pointer; font-weight: 400; }
.choice input { accent-color: var(--teal); width: 18px; height: 18px; }
.picker-search { display: flex; gap: .5rem; margin-bottom: .35rem; }
.picker-search input { flex: 1; }
.geo-msg { font-size: .85rem; color: var(--green-dark); margin: 0 0 .35rem; min-height: 1em; }
.picker-map { height: 320px; border-radius: 10px; border: 1.5px solid var(--line); margin-bottom: .35rem; }
.captcha-row { display: flex; align-items: center; gap: .75rem; font-weight: 600; font-size: 1.1rem; }
.captcha-row input { max-width: 110px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.done h2 { color: var(--green-dark); }
.done .btn { margin: .25rem .25rem 0 0; }

/* ---------- admin ---------- */
.page-admin { background: var(--paper); }
.admin { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.admin-head { display: flex; justify-content: space-between; align-items: center; }
.admin-tabs { max-width: 480px; }
.admin-tabs .tab b { color: var(--red); opacity: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.toolbar select, .toolbar input { padding: .4rem .7rem; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; }
.toolbar input { min-width: 200px; }
.spacer { flex: 1; }
.status { min-height: 1.3em; font-size: .9rem; color: var(--green-dark); margin: 0 0 .5rem; }
.status.err { color: var(--red); font-weight: 600; }
.row-card { background: var(--white); border-radius: 12px; margin-bottom: .5rem; border-left: 5px solid var(--yellow); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.row-card.is-ok { border-left-color: var(--teal); }
.row-head { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; }
.row-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; padding: .2rem 0; }
.row-txt strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { display: flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 600; cursor: pointer; flex: 0 0 auto; }
.switch input { width: 20px; height: 20px; accent-color: var(--teal); }
.editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem 1rem; padding: .5rem 1rem 1rem; border-top: 1px solid var(--line); }
.ed-field { display: flex; flex-direction: column; font-size: .8rem; font-weight: 700; color: var(--muted); gap: .2rem; }
.ed-field input, .ed-field textarea, .ed-field select { font-size: .95rem; font-weight: 400; padding: .45rem .6rem; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
.ed-field input[readonly] { background: var(--paper); color: var(--muted); }
.wide, .ed-map { grid-column: 1 / -1; }
.ed-map { height: 240px; border-radius: 10px; }
.ed-actions { display: flex; gap: .5rem; justify-content: space-between; }

/* ---------- documenti: principi e volantino ---------- */
.page-doc { background: var(--paper); }
.doc-wrap { max-width: 880px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.doc-long { max-width: 1100px; }
.doc-hero { background: var(--yellow); border-radius: 16px; padding: 2rem 1.75rem; margin-bottom: 1.5rem; }
.eyebrow { margin: 0 0 .5rem; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--green-dark); }
.doc-hero h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); max-width: 26ch; }
.lead { font-size: 1.15rem; margin: 0 0 1rem; }
.doc-ctas { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }

.points { list-style: none; counter-reset: pt; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.points li { counter-increment: pt; background: var(--white); border-radius: 14px; padding: 1.25rem 1.25rem 1.25rem 4.25rem; position: relative; border-left: 6px solid var(--teal); }
.points li::before { content: counter(pt); position: absolute; left: 1rem; top: 1.1rem; width: 2.3rem; height: 2.3rem; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; justify-content: center; }
.points h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.05rem; font-weight: 700; margin: 0 0 .35rem; }
.points p { margin: 0; font-size: .96rem; }

.doc-cta-box { background: var(--white); border: 2px dashed var(--lavender); border-radius: 14px; padding: 1.25rem 1.5rem; margin-top: 2rem; }
.doc-cta-box h2 { font-size: 1.2rem; }
.doc-cta-box p { margin: 0 0 .75rem; }
.doc-cta-box .btn { margin: 0 .25rem .25rem 0; }

.doc-grid { display: grid; grid-template-columns: 240px 1fr; gap: 2rem; align-items: start; }
.toc { position: sticky; top: calc(var(--topbar) + 1rem); font-size: .92rem; }
.toc-title { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--muted); margin: 0 0 .5rem; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc ol ol { padding-left: .9rem; margin: .2rem 0 .4rem; font-size: .88rem; }
.toc li { margin: .25rem 0; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--green-dark); text-decoration: underline; }
.toc > ol > li > a { font-weight: 600; }
.toc-dl { display: inline-block; margin-top: 1rem; font-weight: 600; color: var(--green-dark); }
.prose { background: var(--white); border-radius: 16px; padding: 2rem 2.25rem; font-size: 1.02rem; line-height: 1.7; max-width: 72ch; }
.prose section { scroll-margin-top: calc(var(--topbar) + 1rem); }
.prose section + section { margin-top: 2.5rem; }
.prose h2 { font-size: 1.5rem; padding-bottom: .4rem; border-bottom: 2px solid var(--lavender); }
.prose h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; margin: 1.75rem 0 .5rem; color: var(--green-dark); scroll-margin-top: calc(var(--topbar) + 1rem); }
.prose p { margin: 0 0 1rem; }
.prose ul { padding-left: 1.25rem; margin: 0 0 1rem; }
.prose li { margin-bottom: .75rem; }
.prose li::marker { color: var(--teal); }
.intro-docs { font-size: .9rem !important; }
.intro-docs a { font-weight: 600; }

@media (max-width: 1150px) { .brand em { display: none; } }
@media (max-width: 800px) {
  .doc-grid { grid-template-columns: 1fr; }
  .toc { position: static; background: var(--white); border-radius: 14px; padding: 1rem 1.25rem; }
  .prose { padding: 1.25rem; }
  .points { grid-template-columns: 1fr; }
  .doc-hero { padding: 1.5rem 1.25rem; }
}
@media print {
  .topbar, .doc-ctas, .toc, .doc-cta-box { display: none; }
  .page-doc, .prose, .points li { background: #fff; }
}

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .brand em { display: none; }
  .topbar { height: auto; min-height: var(--topbar); flex-wrap: wrap; padding: .5rem 1rem; }
  .topbar nav { width: 100%; flex-wrap: wrap; }
  .topbar nav a { font-size: .85rem; padding: .35rem .6rem; }
  .page-home { overflow: auto; }
  .home { display: flex; flex-direction: column-reverse; height: auto; }
  .map { height: 55vh; }
  .sidebar { border-right: 0; overflow: visible; padding: 1rem; }
  .form-intro, .form, .done { padding: 1.25rem; }
  .form-intro h1 { font-size: 1.5rem; }
}
