/* KyivSafety — shared styles. Palette: primary #2563EB, bg #F8FAFC, text #1E293B,
   status green #16A34A / amber #D97706 / red #DC2626. Fonts: Fira Sans + Fira Code. */
:root {
  --primary: #2563EB;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #1E293B;
  --muted: #64748B;
  --border: #E2E8F0;
  --green: #16A34A;
  --amber: #D97706;
  --red: #DC2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.55 "Fira Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.num { font-family: "Fira Code", monospace; font-variant-numeric: tabular-nums; }

/* header */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1100; /* above leaflet panes (max 1000) */
  flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 18px; color: var(--text); text-decoration: none; }
.brand svg { color: var(--primary); }
header nav { margin-left: auto; display: flex; gap: 4px; }
header nav a {
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px;
  padding: 6px 12px; border-radius: 8px; transition: background .15s, color .15s;
}
header nav a:hover { background: var(--bg); color: var(--text); }
header nav a[aria-current="page"] { color: var(--primary); background: #EFF6FF; }
header nav a.support { color: #E11D48; }
header nav a.support:hover { color: #BE123C; background: #FFF1F2; }
header nav a.support[aria-current="page"] { color: #E11D48; background: #FFF1F2; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid #93C5FD; outline-offset: 1px;
}

/* districts dropdown — native <details>, no JS.
   ponytail: no click-outside-to-close; clicking the summary again closes it and
   navigating closes it anyway. Add a listener if it ever annoys someone. */
header nav .menu { position: relative; }
header nav .menu summary {
  list-style: none; cursor: pointer; user-select: none;
  color: var(--text); font-weight: 500; font-size: 15px;
  padding: 6px 12px; border-radius: 8px;
  display: flex; align-items: center; gap: 6px;
  transition: background .15s;
}
header nav .menu summary::-webkit-details-marker { display: none; }
header nav .menu summary::after {
  content: ""; width: 5px; height: 5px; margin-top: -3px; opacity: .5;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
}
header nav .menu summary:hover, header nav .menu[open] summary { background: var(--bg); }
header nav .menu[open] summary::after { margin-top: 2px; transform: rotate(225deg); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1200;
  display: flex; flex-direction: column; padding: 6px; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu-pop a { font-size: 14px; padding: 7px 10px; white-space: nowrap; }
.menu-pop a[aria-current="page"] { color: var(--primary); background: #EFF6FF; }

/* layout: sidebar + map */
main.app { flex: 1; display: flex; min-height: 0; }
#panel {
  width: 400px; flex: none; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 20px 32px;
}
#map { flex: 1; min-width: 0; background: #DDE7EF; }

/* search form */
.search-form { display: flex; gap: 8px; }
.search-form input {
  flex: 1; min-width: 0; font: inherit; color: inherit;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg);
}
.search-form input::placeholder { color: #94A3B8; }
.search-form button {
  font: inherit; font-weight: 600; color: #fff; background: var(--primary);
  border: 0; border-radius: var(--radius); padding: 10px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 7px; transition: background .15s;
  min-height: 44px;
}
.search-form button:hover { background: #1D4ED8; }
.search-form button:disabled { opacity: .6; cursor: default; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.error {
  margin: 14px 0 0; padding: 10px 12px; border-radius: var(--radius);
  background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; font-size: 14px;
}

/* example chips */
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.examples button {
  font: inherit; font-size: 13px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.examples button:hover { border-color: var(--primary); color: var(--primary); }

/* intro card */
.intro { margin-top: 22px; color: var(--muted); font-size: 14px; }
.intro h1 { font-size: 17px; line-height: 1.35; color: var(--text); margin: 16px 0 6px; }
.intro ul { padding-left: 18px; margin: 8px 0; }
.intro li { margin: 4px 0; }
.intro a { color: var(--primary); }
.intro h2 { font-size: 15px; color: var(--text); margin: 18px 0 6px; }
.districts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.districts a {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 8px; font-size: 13px; text-decoration: none;
}
.districts a:hover { border-color: var(--primary); }

/* report */
#report { margin-top: 18px; }
.addr { font-weight: 600; font-size: 15px; margin: 0 0 2px; }
.addr-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.score-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.score-ring { flex: none; width: 84px; height: 84px; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: "Fira Code", monospace; font-size: 26px; font-weight: 600;
}
.score-label { font-weight: 600; margin: 0 0 2px; }
.score-desc { color: var(--muted); font-size: 13px; margin: 0; }

.section-title {
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 8px; display: flex; align-items: center; gap: 6px;
}
.section-title svg { flex: none; }

/* component meters */
.comp { margin: 10px 0; }
.comp-head { display: flex; flex-wrap: wrap; justify-content: space-between; font-size: 14px; margin-bottom: 4px; gap: 2px 8px; }
.comp-head .v { color: var(--muted); white-space: nowrap; }
.meter { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.meter > div { height: 100%; border-radius: 3px; }

/* checklist badge */
.badge {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius); padding: 10px 12px; font-size: 14px;
}
.badge svg { flex: none; margin-top: 2px; }
.badge.ok { background: #F0FDF4; border: 1px solid #BBF7D0; color: #166534; }
.badge.bad { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }

/* result lists */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { border-bottom: 1px solid var(--border); }
.rows li:last-child { border-bottom: 0; }
.rows button {
  display: flex; gap: 12px; align-items: baseline; width: 100%; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; padding: 9px 4px;
  cursor: pointer; border-radius: 6px; transition: background .15s;
}
.rows button:hover { background: var(--bg); }
.rows-static { display: flex; gap: 12px; align-items: baseline; padding: 9px 4px; }
.dist { font-family: "Fira Code", monospace; font-size: 13px; white-space: nowrap; min-width: 62px; font-weight: 500; }
.dist.green { color: var(--green); }
.dist.red { color: var(--red); }
.dist.amber { color: var(--amber); }
.row-main { font-size: 14px; }
.row-sub { color: var(--muted); font-size: 12.5px; }

.foot-note { color: var(--muted); font-size: 12.5px; margin-top: 18px; }
.foot-note a { color: var(--primary); }
.notes { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--border); }
.notes .foot-note { margin-top: 10px; }
.notes .foot-note:first-child { margin-top: 0; }

/* map bits */
.leaflet-container { font: 13px/1.4 "Fira Sans", system-ui, sans-serif; }
.dist-label {
  background: rgba(255,255,255,.92); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow);
  font-family: "Fira Code", monospace; font-size: 11.5px; font-weight: 500;
  padding: 1px 6px; white-space: nowrap;
}
.dist-label::before { display: none; }
.pin { filter: drop-shadow(0 2px 3px rgba(15,23,42,.35)); }
.legend {
  background: rgba(255,255,255,.94); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 14px; font-size: 12.5px; line-height: 1.9;
}
.legend b { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.legend .k { display: flex; align-items: center; gap: 8px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content .row-sub { display: block; }

/* methodology article */
article.doc {
  max-width: 760px; margin: 0 auto; padding: 32px 24px 80px;
  background: var(--surface);
}
article.doc h1 { font-size: 30px; line-height: 1.25; margin: 8px 0 4px; }
article.doc h2 { font-size: 21px; margin: 36px 0 10px; }
article.doc .lede { color: var(--muted); font-size: 17px; }
article.doc p, article.doc li { max-width: 70ch; }
article.doc a { color: var(--primary); }
article.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; margin: 12px 0; }
article.doc th, article.doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
article.doc th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
/* reuses the existing .callout (defined below, also used by methodology.html);
   selector must out-specify `article.doc h2` to win */
article.doc .callout { margin: 32px 0; padding: 16px 18px; }
article.doc .callout h2 { margin: 0 0 8px; font-size: 18px; }
article.doc .callout p { margin: 0; }
.cta {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  font-weight: 600; font-size: 15px; color: #fff !important; background: var(--primary);
  border-radius: var(--radius); padding: 10px 16px; min-height: 44px;
  text-decoration: none; transition: background .15s;
}
.cta:hover { background: #1D4ED8; }

article.doc code {
  font-family: "Fira Code", monospace; font-size: .88em;
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}
.callout {
  border-left: 3px solid var(--primary); background: #EFF6FF;
  border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 16px; margin: 16px 0;
  font-size: 14.5px;
}
.callout.warn { border-left-color: var(--amber); background: #FFFBEB; }
.doc-wrap { flex: 1; overflow-y: auto; }

/* donate page */
.donate-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; color: #fff !important; background: var(--primary);
  border-radius: var(--radius); padding: 12px 20px; text-decoration: none;
  transition: background .15s;
}
.donate-btn:hover { background: #1D4ED8; }
.copy-btn {
  font: inherit; font-size: 13px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
  margin-left: 8px; cursor: pointer; transition: border-color .15s, color .15s;
}
.copy-btn:hover { border-color: var(--primary); color: var(--primary); }
.donate-row { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: flex-start; margin-top: 24px; }
.donate-row .qr { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: #fff; flex: none; }
.donate-row h2 { margin: 20px 0 6px; font-size: 17px; }
.donate-row p { margin: 0; }

/* mobile: map on top, panel below */
@media (max-width: 767px) {
  main.app { flex-direction: column-reverse; }
  #map { flex: none; height: 44dvh; }
  #panel { width: auto; flex: 1; border-right: 0; border-top: 1px solid var(--border); }
  /* 4 nav items + brand don't fit a phone: wrap the header row, and let nav
     wrap internally too (nav is one flex item — without this it overflows on
     its own line and scrolls the whole page sideways). */
  header { padding: 8px 12px; gap: 8px; flex-wrap: wrap; row-gap: 2px; }
  header nav { flex-wrap: wrap; justify-content: flex-end; }
  .brand { font-size: 16px; }
  header nav a, header nav .menu summary { font-size: 14px; padding: 6px 9px; }
  .menu-pop a { padding: 8px 10px; }
  .legend { display: none; } /* colors are explained by the sidebar lists */
}
