/* CityPulse: token visivi da CLAUDE.md, layout mobile-first fino a ~480 px. */
:root {
  --bg: #F4FBF7; --ink: #14231F; --muted: #4A5A55; --line: #EEF2F0;
  --green: #1E7A5A; --green-dark: #145C43; --green-live: #2FBF7F; --green-tint: #DDF4E7;
  --yellow: #FFC24B; --yellow-tint: #FFF1CC; --amber: #E8A33D;
  --coral: #FF7A5C; --coral-tint: #FFE3DB;
  --lilac: #C9B8FA; --lilac-tint: #ECE5FF; --lilac-deep: #9B7BF2;
  --sky: #8CCBFA; --sky-tint: #DCEFFF; --sky-deep: #4AA8F0;
  --head: 'Fredoka', 'Manrope', system-ui, sans-serif;
  --text: 'Manrope', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 480px; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); font: 500 15px/1.45 var(--text);
}
body.wide { max-width: 760px; }
a { color: var(--green); }
a:hover { color: var(--green-dark); }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.1; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 22px; margin-top: 4px; }
h3 { font-size: 18px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 2px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 800; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.page { display: flex; flex-direction: column; gap: 16px; padding: 0 16px 8px; flex: 1; }

/* intestazione */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 4px; }
.top-left, .top-right { display: flex; align-items: center; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); min-height: 44px; padding: 0 8px; }
.wordmark { font-size: 21px; line-height: 1; letter-spacing: -0.03em; }
.wm-a { font-weight: 500; color: var(--green); }
.wm-b { font-weight: 800; }
.back { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px; font-size: 15px; font-weight: 700; text-decoration: none; }
.lang { position: relative; }
.lang summary {
  list-style: none; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px;
  border-radius: 22px; background: var(--yellow-tint); font-size: 14px; font-weight: 800; cursor: pointer;
}
.lang summary::-webkit-details-marker { display: none; }
.lang ul {
  position: absolute; right: 0; top: 48px; z-index: 20; margin: 0; padding: 6px; list-style: none;
  background: #FFFFFF; border-radius: 16px; box-shadow: 0 8px 24px rgba(20, 35, 31, .15); min-width: 140px;
}
.lang a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 700; }
.lang a[aria-current] { background: var(--green-tint); }
.chip-place { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--green-tint); font-size: 13px; font-weight: 800; }
.round-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: none; border-radius: 22px; background: var(--yellow-tint); }

.intro { display: flex; flex-direction: column; gap: 6px; padding: 4px 4px 0; }
.note-cmp { margin: 0; padding: 8px 12px; border-radius: 14px; background: var(--coral-tint); font-weight: 700; font-size: 14px; }

/* passi della ricerca */
.steps ol { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.steps li {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border-radius: 20px;
  background: #FFFFFF; color: var(--muted); font-size: 14px; font-weight: 700;
}
.steps li.done { background: var(--green-tint); color: var(--ink); }
.steps li.current { background: var(--green); color: #FFFFFF; font-weight: 800; }
.num { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 11px; font-size: 12px; color: var(--ink); }
.num.n1 { background: var(--yellow); } .num.n2 { background: var(--lilac-tint); } .num.n3 { background: var(--coral-tint); }
.steps li.current .num { background: var(--yellow); }
.steps li.done .num { background: var(--green-live); }

/* mappe statiche dei passi 1 e 2 */
.mapbox { display: flex; justify-content: center; }
.static-map { position: relative; width: 350px; max-width: 100%; aspect-ratio: 350 / 330; border-radius: 24px; background: var(--sky-tint); overflow: hidden; }
.static-map.it { aspect-ratio: 350 / 282; container-type: inline-size; }
.static-map img { display: block; width: 100%; height: auto; }
.dot { position: absolute; width: 10px; height: 10px; border-radius: 5px; background: var(--ink); border: 2px solid #FFFFFF; }
.map-hint { position: absolute; left: 10px; top: 10px; padding: 4px 10px; border-radius: 10px; background: #FFFFFF; color: var(--muted); font-size: 12px; font-weight: 700; }
.city-tag { position: absolute; transform: translate(-50%, -130%); padding: 5px 10px; border-radius: 12px; background: var(--green); color: #FFFFFF; font-size: 13px; font-weight: 800; white-space: nowrap; }
.city-tag.at-below { transform: translate(-50%, 35%); }
.city-tag.at-left { transform: translate(calc(-100% - 9px), -50%); }
.city-tag.at-right { transform: translate(9px, -50%); }
.city-tag.at-above-right { transform: translate(-6px, -130%); }
.city-tag.soon, .city-tag.nodata { background: #C8452A; }
/* sotto i 350 px la mappa si restringe: le etichette scalano con lei, altrimenti si sovrappongono */
.static-map.it .city-tag { font-size: min(13px, 3.72cqw); padding: min(5px, 1.43cqw) min(10px, 2.86cqw); border-radius: min(12px, 3.43cqw); }
/* passo 2: punti ed etichette cliccabili, nome al passaggio del mouse dove manca l'etichetta */
a.dot, a.city-tag { cursor: pointer; text-decoration: none; }
.static-map.it .dot::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; }
.static-map.it .dot:hover { z-index: 3; }
a.dot:hover, a.dot:has(+ a.city-tag:hover) { background: var(--green-live); }
a.city-tag:hover, a.dot:hover + a.city-tag { background: var(--green-dark); }
.dot-tip {
  position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
  padding: 4px 9px; border-radius: 10px; background: var(--green); color: #FFFFFF;
  font-size: 12px; font-weight: 800; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s;
}
.dot-tip.at-below { bottom: auto; top: calc(100% + 7px); }
.dot.soon .dot-tip, .dot.nodata .dot-tip { background: #C8452A; }
.dot:hover .dot-tip { opacity: 1; }

/* card e pillole */
.card-link {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; border-radius: 20px;
  background: #FFFFFF; border: 2px solid var(--green-live); text-decoration: none; color: var(--ink);
}
.card-link.off { border-color: #FFA58F; opacity: .85; }
.card-title { font-family: var(--head); font-size: 19px; font-weight: 600; }
.small-title { font-size: 16px; }
.badge-soon { padding: 4px 10px; border-radius: 999px; background: var(--coral-tint); font-size: 12px; font-weight: 800; white-space: nowrap; }
.soon-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.soon-label { font-size: 13px; font-weight: 800; color: var(--muted); }
.pills { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.pills li { padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.pills.big li { padding: 9px 14px; font-size: 14px; font-weight: 800; }
.later { margin: 0; display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--muted); }
.later strong { color: var(--ink); font-weight: 800; }
.later-box { flex: none; width: 14px; height: 14px; margin-top: 2px; border-radius: 4px; background: #FFFFFF; border: 2px solid #8FCFAF; }

/* pulsanti */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border: none; border-radius: 26px; font-size: 16px; font-weight: 800; text-decoration: none; text-align: center;
}
.btn.primary { background: var(--green); color: #FFFFFF; }
.btn.primary:hover { background: var(--green-dark); color: #FFFFFF; }
.btn.yellow { background: var(--yellow); color: var(--ink); }
.btn.dark { background: var(--ink); color: #FFFFFF; }
.btn.ghost { background: #FFFFFF; color: var(--ink); border: 2px solid var(--green-tint); }
.btn.small-btn { min-height: 44px; font-size: 15px; padding: 0 16px; border-radius: 22px; }
.btn.disabled { opacity: .45; pointer-events: none; }
.cta-bottom { margin-top: auto; padding-top: 6px; }

/* ricerca */
.label { font-size: 14px; font-weight: 800; }
.search { display: flex; flex-direction: column; background: #FFFFFF; border: 2px solid var(--green); border-radius: 18px; overflow: hidden; }
.search-row { display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.search input { flex: 1; min-width: 0; height: 50px; border: none; outline: none; background: transparent; font: 600 16px var(--text); color: var(--ink); }
.sugg { margin: 0; padding: 4px 6px 8px; list-style: none; border-top: 1px solid #DDE3DF; max-height: 290px; overflow-y: auto; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 12px; font-weight: 600; cursor: pointer; }
.opt.active { background: var(--yellow-tint); font-weight: 800; }
.opt-dot { flex: none; width: 10px; height: 10px; border-radius: 5px; background: #B9C4BF; }
.opt.active .opt-dot { background: var(--amber); }
.opt-sub { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.warn { margin: 0; padding: 10px 12px; border-radius: 14px; background: var(--yellow-tint); font-size: 13px; font-weight: 600; }
#search-msg, #pick-score { margin: 0; }
/* vuoto non occupa spazio nella colonna, ma resta una regione annunciata */
#search-msg:empty { position: absolute; }
.pick-head { display: flex; flex-direction: column; gap: 2px; }
.pick-head p { margin: 0; }
.chip-btn {
  position: relative; display: inline-flex; align-items: center; gap: 5px; margin-left: 2px; padding: 3px 10px;
  border: none; border-radius: 999px; background: var(--yellow-tint); color: var(--ink); font-size: 13px; font-weight: 800;
}
.chip-btn[aria-expanded="true"] { background: var(--yellow); }
/* area toccabile di 44 px senza allargare la riga */
.chip-btn::after { content: ""; position: absolute; inset: -10px -2px; }

/* mappe MapLibre */
.map { width: 100%; border-radius: 24px; overflow: hidden; background: #E9F5EE; }
.map.pick { height: 240px; }
.map.mini { height: 220px; }
.map.heat { height: min(62vh, 520px); border-radius: 28px; }
.map-fallback { margin: 0; padding: 24px; color: var(--muted); font-size: 13px; }
.pin { width: 22px; height: 22px; border-radius: 11px; background: var(--amber); border: 4px solid #FFFFFF; box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* scheda */
.hero { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: 28px; background: var(--green); color: #FFFFFF; overflow: hidden; }
.deco { position: absolute; }
.deco.d1 { right: -14px; top: -10px; } .deco.d2 { right: 52px; top: 46px; } .deco.d3 { right: 22px; top: 86px; }
.hero-head { display: flex; flex-direction: column; gap: 4px; padding-right: 70px; }
.hero h1 { font-size: 27px; overflow-wrap: anywhere; }
.hero-sub { margin: 0; font-size: 14px; font-weight: 600; color: var(--green-tint); }
.hero-score { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.hexscore { position: relative; width: 92px; height: 92px; flex: none; }
.hexscore svg { position: absolute; inset: 0; }
.hexscore span { position: absolute; inset: 0 0 -4px; display: flex; align-items: center; justify-content: center; font: 600 36px var(--head); color: var(--green); }
.hero-label { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hero-k { font-size: 13px; font-weight: 700; color: var(--green-tint); }
.hero-note { font-size: 12px; font-weight: 600; color: var(--green-tint); }
.hero-foot { margin: 0; font-size: 12px; font-weight: 600; color: var(--green-tint); }
.band-pill { align-self: flex-start; padding: 4px 12px; border-radius: 999px; background: var(--yellow); color: var(--ink); font: 600 20px var(--head); }
.hero .band-pill { box-shadow: 0 0 0 2px #FFFFFF; }
.badge-demo { align-self: flex-start; padding: 4px 10px; border-radius: 999px; background: var(--yellow-tint); color: #6B4A10; font-size: 12px; font-weight: 800; }
.flags { display: flex; flex-direction: column; gap: 8px; }
.flags:empty { display: none; }
.hero-prof { display: flex; align-items: center; gap: 8px; }
.hero-prof .hero-note { flex: 1 1 auto; min-width: 0; }
.chip-btn.hero-edit { flex: none; margin-left: 0; background: var(--yellow); }
.chip-btn.hero-edit[aria-expanded="true"] { background: #FFFFFF; }
.stdline { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-radius: 24px; background: #FFFFFF; }
.stdline > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stdline-score { display: flex; align-items: center; gap: 10px; flex: none; }
.stdline .band-pill { font-size: 14px; padding: 3px 10px; }
.mid-num { font: 600 28px/1 var(--head); }
.position { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: 24px; background: var(--lilac-tint); }
.position p { margin: 0; font-size: 15px; font-weight: 600; }
.position b { font-weight: 800; }
.pos-bar { position: relative; height: 12px; border-radius: 6px; background: #FFFFFF; margin-top: 5px; }
#pos-fill { position: absolute; left: 0; top: 0; height: 12px; border-radius: 6px; background: var(--lilac-deep); width: 0; transition: width .3s; }
#pos-knob { position: absolute; top: -5px; left: -11px; width: 22px; height: 22px; border-radius: 11px; background: var(--yellow); border: 3px solid #FFFFFF; transition: left .3s; }
.ind-card { display: flex; gap: 12px; padding: 14px; border-radius: 20px; background: #FFFFFF; }
.ind-card.na { border: 2px dashed var(--lilac); }
.ind-card .grow { gap: 6px; }
.ind-icon { flex: none; width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; }
.ind-top { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.bar { height: 10px; border-radius: 5px; }
.bar > div { height: 10px; border-radius: 5px; }
.ind-detail { margin: 0; font-size: 13px; font-weight: 600; }
.ind-ref { margin: 0; font-size: 12px; color: var(--muted); }
.q3-more summary { font-size: 13px; font-weight: 700; color: var(--green); cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.q3-more ul { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.q3-more li { display: grid; grid-template-columns: 1fr auto 36px; gap: 8px; }
.q3-more li span:last-child { text-align: right; }
.legend-inline { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; font-weight: 700; }
.legend-inline li, .legend li { display: flex; align-items: center; gap: 6px; }
.sw { flex: none; width: 16px; height: 16px; border-radius: 5px; }
.sw.round { border-radius: 8px; }
.sw.line { height: 0; border-radius: 0; border-top: 3px dashed #1E7A5A; }
.sw.nd { background: #D9DEDB; }
.actions { padding-top: 4px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; margin: 0; padding: 10px 18px; border-radius: 22px; background: var(--ink); color: #FFFFFF; font-weight: 700; }

/* pannello delle preferenze */
.prefs-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 24px; background: #FFFFFF; border: 2px solid var(--yellow); }
.prefs-panel h2 { margin: 0; font-size: 24px; }
.prefs-panel h3 { margin-top: 6px; }
.prefs-head p { margin: 4px 0 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.profile-btn { min-height: 48px; border: 2px solid; border-radius: 24px; font-size: 15px; font-weight: 800; }
.profile-btn.mine { border: 2px dashed var(--green); background: #FFFFFF; }
.profile-btn.mine[aria-pressed="true"] { border-style: solid; background: var(--green-tint); }
.mine-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.mine-row p { margin: 0; }
.weight-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 20px; background: var(--bg); }
.weight-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.weight-top .strong { display: flex; align-items: center; gap: 8px; }
.weight-card p { margin: 0; }
.dot-i { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 6px; margin-right: 6px; vertical-align: -1px; }
.seg5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.seg4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.seg5 button, .seg4 button { min-height: 44px; border: none; border-radius: 14px; font-size: 15px; font-weight: 800; }
.seg4 button { font-size: 13px; padding: 0 2px; }
.seg5 button[aria-pressed="true"], .seg4 button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }

/* confronto */
.cmp-heads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cmp-head { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 22px; text-decoration: none; }
.cmp-head.a { background: var(--green); color: #FFFFFF; }
.cmp-head.b { background: #FFA58F; color: var(--ink); }
.cmp-head.empty { background: #FFFFFF; color: var(--ink); border: 2px dashed #FFA58F; }
.cmp-key { align-self: flex-start; padding: 2px 10px; border-radius: 999px; background: #FFFFFF; color: var(--ink); font-size: 12px; font-weight: 800; }
.cmp-head.a .cmp-key { color: var(--green); }
.cmp-name { font: 600 17px/1.2 var(--head); overflow-wrap: anywhere; }
.cmp-city { font-size: 13px; font-weight: 700; }
.cmp-score { font: 600 34px/1 var(--head); }
.cmp-k { font-size: 12px; font-weight: 600; opacity: .85; }
.cmp-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #FFFFFF; border-radius: 20px; overflow: hidden; font-size: 14px; }
.cmp-table caption { caption-side: bottom; padding-top: 8px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); }
.cmp-table th, .cmp-table td { padding: 9px 12px; border-top: 1px solid var(--line); }
.cmp-table thead th { border-top: none; font-size: 12px; font-weight: 800; background: var(--lilac-tint); text-align: left; }
.cmp-table thead .ca { background: var(--green-tint); text-align: center; }
.cmp-table thead .cb { background: var(--coral-tint); text-align: center; }
.cmp-table tbody th { text-align: left; font-weight: 600; }
.cmp-table tbody td { text-align: center; font-weight: 600; }
.cmp-table .strong-row th { font-weight: 800; }
.best { padding: 3px 10px; border-radius: 999px; background: var(--yellow); font-weight: 800; }

/* mappa della città */
.legend { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; font-size: 13px; font-weight: 700; }
.cell-card { padding: 14px 16px; border-radius: 24px; background: #FFFFFF; }
.cell-card p { margin: 0; }
.cell-info { display: flex; align-items: center; gap: 10px; }
.dot-c { flex: none; width: 14px; height: 14px; border-radius: 7px; background: var(--coral); }

/* metodologia */
.prose section { display: flex; flex-direction: column; gap: 8px; }
.prose p, .prose ul { margin: 0; }
.prose ul { padding-left: 20px; }
.prose .legend { padding-left: 0; }
.table-wrap { overflow-x: auto; border-radius: 16px; }
.data { width: 100%; border-collapse: collapse; background: #FFFFFF; font-size: 13px; }
.data th, .data td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.data thead th { background: var(--green-tint); border-top: none; font-weight: 800; }
.data td:nth-child(2), .data td:nth-child(3) { white-space: nowrap; }
.prose h3 { font-size: 17px; margin-top: 6px; }

/* guida della città, quartieri e profili: testi resi dal server */
.guide { display: flex; flex-direction: column; gap: 22px; margin-top: 10px; }
.facts { display: flex; flex-direction: column; gap: 6px; }
.facts strong { font-family: var(--head); font-size: 17px; color: var(--green); }
.profile-links { display: flex; flex-direction: column; gap: 6px; }
.crumbs { margin: 0; color: var(--muted); }
.crumbs a { color: var(--muted); }
.streets { line-height: 1.7; font-size: 13px; }
.near { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-left: 0 !important; list-style: none; }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; }
.band-tag { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.band-scarso { background: #FFE7A3; }
.band-sufficiente { background: #A7E0B5; }
.band-buono { background: #4CC38A; }
.band-ottimo { background: #1E7A5A; color: #FFFFFF; }
.guides { display: flex; flex-direction: column; gap: 6px; }
.hero-link { color: #FFFFFF; }

.foot { margin-top: auto; padding: 18px 20px 24px; font-size: 12px; font-weight: 500; color: var(--muted); }
.maplibregl-ctrl-attrib { font-size: 10px; }
