/* Colours from StreetComplete's own theme (ui/theme/Color.kt): primary indigo #4141ba, secondary
   orange #D14000 (#ff6600 in the dark theme), the traffic-sign green and red, and its quest pins. */
:root {
  color-scheme: light;
  --brand: #4141ba;
  --brand-2: #3939a3;
  --page: #f2f2f4;
  --surface: #ffffff;
  --ink: #111111;
  --ink-2: #4f5250;
  --muted: #8e9291;
  --grid: #e6e6ea;
  --axis: #c9c9d0;
  --ring: rgba(17, 17, 17, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.10), 0 3px 10px rgba(0, 0, 0, 0.06);
  --series-1: #4141ba;  /* needs mapping */
  --series-2: #d14000;  /* aged: needs resurvey */
  --release: #6e6ec9;
  --bar: #4141ba;
  --wash: rgba(65, 65, 186, 0.08);
  --good: #008351;
  --bad: #c1121c;
  --link: #3535a8;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand: #34349a;
    --brand-2: #2b2b80;
    --page: #111111;
    --surface: #222222;
    --ink: #ffffff;
    --ink-2: #c3c3c8;
    --muted: #8e9291;
    --grid: #303033;
    --axis: #45454a;
    --ring: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    --series-1: #9a9aff;
    --series-2: #ff6600;
    --release: #8a8ae0;
    --bar: #8080f0;
    --wash: rgba(154, 154, 255, 0.12);
    --good: #3fbf7f;
    --bad: #ff6b6b;
    --link: #a8a8ff;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  accent-color: var(--series-1);
}
a { color: var(--link); }
h1, h2 { font-weight: 600; margin: 0; }
h1 { font-size: 1.7rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }

.page-head, main, .page-foot { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ---------- header: the app's indigo, with a faint street grid and a few quest pins ---------- */
.band {
  color: #fff;
  background:
    repeating-linear-gradient(28deg, transparent 0 46px, rgba(255, 255, 255, 0.06) 46px 49px, transparent 49px 120px),
    repeating-linear-gradient(-62deg, transparent 0 70px, rgba(255, 255, 255, 0.05) 70px 72px, transparent 72px 150px),
    linear-gradient(160deg, var(--brand), var(--brand-2));
  margin-bottom: 8px;
}
.band .page-head { position: relative; padding-top: 28px; }
.brand { display: flex; gap: 16px; align-items: center; position: relative; z-index: 1; max-width: 720px; }
.app-icon { flex: none; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.band .lede { color: rgba(255, 255, 255, 0.85); margin: 4px 0 0; }
.band a { color: #fff; }
.pins { position: absolute; top: 10px; right: 20px; width: 300px; height: 110px; }
.pin {
  position: absolute; left: var(--x); top: var(--y);
  width: 40px; height: 51px; background: url(img/pin.svg) center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
}
.pin img { position: absolute; left: 4px; top: 4px; width: 32px; height: 32px; }
@media (max-width: 900px) { .pins { display: none; } }

.tabs { display: flex; gap: 4px; padding-top: 22px; position: relative; z-index: 1; }
.tab {
  padding: 9px 18px; color: rgba(255, 255, 255, 0.85); text-decoration: none; font-weight: 500;
  border-radius: 12px 12px 0 0;
}
.tab:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.band .tab[aria-current="page"] { background: var(--page); color: var(--ink); font-weight: 600; }
.band { margin-bottom: 0; }
@media (max-width: 480px) {
  .tabs { overflow-x: auto; }
  .tab { padding: 9px 10px; white-space: nowrap; }
}

/* ---------- map view: the tiles step back so the counted cities stand out ----------
   By id, because Leaflet's stylesheet loads with the tab, after this one. */
#coverage-map { height: min(70vh, 640px, 90vw); min-height: 340px; border-radius: 12px; font: inherit; background: var(--grid); }
#coverage-map .leaflet-tile-pane { filter: grayscale(1) brightness(1.04); }
#coverage-map .leaflet-popup-content-wrapper, #coverage-map .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
#coverage-map .leaflet-popup-content { margin: 10px 14px; font-size: 0.9rem; }
#coverage-map .leaflet-popup-content a { color: var(--link); }
#coverage-map path:focus { outline: none; }   /* a click would box the shape */
/* hover: CSS beats Leaflet's presentation attributes, so these win without setStyle and can ease */
#coverage-map .city-shape { transition: fill-opacity 0.12s, stroke-width 0.12s; }
#coverage-map .city-shape.hot { fill-opacity: 0.6; stroke-width: 3px; }
#coverage-map .city-dot { transition: transform 0.12s, stroke-width 0.12s; transform-box: fill-box; transform-origin: center; }
#coverage-map .city-dot.hot { transform: scale(1.5); stroke-width: 2px; }
.map-where { color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  #coverage-map .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(0.8) contrast(0.9); }
  #coverage-map .leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--grid); }
  #coverage-map .leaflet-control-attribution { background: rgba(34, 34, 34, 0.8); color: var(--ink-2); }
  #coverage-map .leaflet-control-attribution a { color: var(--link); }
}

/* ---------- controls ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; padding: 18px 0 16px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--ink-2); }
.field.check { flex-direction: row; align-items: center; gap: 8px; font-size: 0.95rem; color: var(--ink); }
.field[hidden] { display: none; }
.field.check.small { font-size: 0.85rem; color: var(--ink-2); }
.table-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.btn {
  font: inherit; font-size: 0.85rem; color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--wash); color: var(--ink); }
select, input[type="search"] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; min-width: 200px;
}
select:focus, input:focus { outline: 2px solid var(--series-1); outline-offset: 1px; }

/* ---------- the city picker: a button, and a sheet that fills a phone ---------- */
.city-button {
  display: flex; align-items: center; gap: 16px; width: 100%; max-width: 420px; padding: 10px 14px;
  font: inherit; text-align: left; color: var(--ink); background: var(--surface);
  border: 0; border-radius: 14px; box-shadow: var(--shadow); cursor: pointer;
}
.city-button:hover { background: var(--wash); }
.city-button b { display: block; font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
#city-where { color: var(--ink-2); font-size: 0.85rem; }
.city-change { margin-left: auto; color: var(--link); font-size: 0.9rem; }
.city-sheet {
  width: min(480px, 100vw); max-width: 100vw; height: min(680px, 100dvh); max-height: 100dvh;
  padding: 0; border: 0; border-radius: 16px; color: var(--ink); background: var(--page); overflow: hidden;
}
.city-sheet[open] { display: flex; flex-direction: column; }
.city-sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
.sheet-top { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface); box-shadow: var(--shadow); }
.sheet-top input { flex: 1; min-width: 0; padding: 10px 12px; font-size: 1rem; border-radius: 12px; }
.sheet-close { font: inherit; color: var(--link); background: none; border: 0; padding: 8px 4px; cursor: pointer; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 16px; }
.sheet-head {
  display: flex; justify-content: space-between; gap: 12px; margin: 16px 16px 6px;
  font-size: 0.8rem; font-weight: 600; color: var(--ink-2);
}
.sheet-head span + span { font-weight: 400; }
.sheet-list { list-style: none; margin: 0 12px; padding: 0; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.sheet-list li + li { border-top: 1px solid var(--grid); }
.sheet-more { margin-top: 12px; }
.sheet-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 44px; padding: 8px 14px;
  font: inherit; text-align: left; color: var(--ink); background: none; border: 0; cursor: pointer;
}
.sheet-row:hover, .sheet-row:focus-visible { background: var(--wash); outline: none; }
.sheet-more .sheet-row, .sheet-row.sheet-back { color: var(--link); }
.sheet-row.sheet-back { width: auto; margin: 8px 4px 0; }
.sheet-name { display: block; font-weight: 500; }
.sheet-where { display: block; color: var(--ink-2); font-size: 0.82rem; }
.sheet-value { color: var(--ink-2); font-size: 0.88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 520px) {
  .city-button { max-width: none; }
  .city-sheet { width: 100vw; height: 100dvh; margin: 0; border-radius: 0; }
}

.notice { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 14px; }

/* ---------- tiles and cards: the app's rounded white surfaces ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 600px) { .tile.hero { grid-column: 1 / -1; } }
.tile { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; }
.tile .label { color: var(--ink-2); font-size: 0.85rem; }
.tile .value { font-size: 1.7rem; font-weight: 600; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.hero { background: linear-gradient(160deg, var(--brand), var(--brand-2)); color: #fff; position: relative; overflow: hidden; }
.tile.hero .label, .tile.hero .delta, .tile.hero .note { color: rgba(255, 255, 255, 0.85); }
.tile.hero .value { font-size: 2.8rem; }
.tile.hero::after {
  content: ""; position: absolute; right: 12px; top: 12px; width: 22px; height: 28px;
  background: url(img/pin.svg) center / contain no-repeat; opacity: 0.9;
}
.tile .delta, .tile .note { font-size: 0.85rem; color: var(--ink-2); margin-top: 2px; }
.key { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; margin-right: 6px; border-radius: 50%; }

.card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.head-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.sub { color: var(--ink-2); font-size: 0.88rem; margin: 4px 0 10px; }
.chart { width: 100%; min-height: 40px; }
.hover-note { min-height: 1.3em; margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-2); }
.hover-note b { color: var(--release); }
.breaks { list-style: none; padding: 0; margin: 6px 0 0; color: var(--ink-2); font-size: 0.85rem; }
.breaks:empty { display: none; }

.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; margin-bottom: 16px; }
.multiples:empty { display: none; }
.multiples .card { margin: 0; padding: 12px 14px; }
.multiples h3 { font-size: 1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 10px; }
.multiples h3 .q-title { flex: 1; }
.multiples h3 button {
  font: inherit; font-size: 1.2rem; line-height: 1; color: var(--ink-2); background: none; border: 0;
  cursor: pointer; padding: 2px 6px; border-radius: 50%;
}
.multiples h3 button:hover { background: var(--wash); }

/* a quest icon: SC draws them as round badges already */
.q-icon { flex: none; width: 32px; height: 32px; vertical-align: middle; }
.q-icon.lg { width: 40px; height: 40px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th { text-align: left; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--axis); padding: 6px 8px; white-space: nowrap; }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[aria-sort="ascending"]::after { content: " ▲"; font-size: 0.7em; }
table.data th[aria-sort="descending"]::after { content: " ▼"; font-size: 0.7em; }
table.data td { border-bottom: 1px solid var(--grid); padding: 6px 8px; vertical-align: middle; }
table.data tbody tr:hover td { background: var(--wash); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.off td { color: var(--muted); }
table.data tr.off a { color: var(--muted); }
table.data tr.off .q-icon { filter: grayscale(1); opacity: 0.55; }
table.data tr.picked td, table.data tr.pinned td { background: var(--wash); }
table.data tr.unselected td { color: var(--muted); }
table.data tr.unselected a { color: var(--muted); }
table.data tr.group-head th { text-align: left; font-weight: 600; font-size: 0.82rem; color: var(--ink-2);
  padding: 18px 8px 6px; border-bottom: 1px solid var(--axis); }
table.data tbody tr.group-head:hover th { background: none; }
.c-pick input { vertical-align: middle; margin: 0; }
.c-pin { width: 30px; }
/* the app's map pin, grey until the quest is pinned */
.pin-btn {
  display: block; width: 18px; height: 23px; padding: 0; border: 0; cursor: pointer;
  background: var(--axis);
  -webkit-mask: url(img/pin.svg) center / contain no-repeat; mask: url(img/pin.svg) center / contain no-repeat;
}
.pin-btn:hover { background: var(--muted); }
.pin-btn[aria-pressed="true"] { background: var(--series-1); }
.pin-btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.quest-cell { display: flex; align-items: center; gap: 10px; }
.quest-cell a { text-decoration: none; color: inherit; font-weight: 500; }
.quest-cell a:hover { text-decoration: underline; color: var(--link); }
.code { display: block; color: var(--muted); font-size: 0.76rem; }
.c-pick { width: 28px; }
.c-trend { width: 112px; }
.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--series-1); }
.up { color: var(--bad); }
.down { color: var(--good); }

.chip { font-size: 0.72rem; color: var(--ink-2); border: 1px dashed var(--axis); border-radius: 4px; padding: 0 4px; margin-left: 6px; white-space: nowrap; }

.bar-col { width: 32%; }
.hbar { height: 10px; background: var(--bar); border-radius: 0 5px 5px 0; min-width: 1px; }

.page-foot { color: var(--ink-2); font-size: 0.85rem; padding-top: 8px; padding-bottom: 40px; }
.page-foot p { margin: 4px 0; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* uPlot chrome in our tokens */
.u-legend { font-size: 0.85rem; color: var(--ink-2); text-align: left; }
.u-legend .u-value { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.u-legend .u-marker { height: 10px !important; width: 10px !important; border-radius: 50%; border-width: 5px !important; }
.u-legend th { font-weight: 400; }
.uplot { font-family: inherit; }

/* ---------- places ---------- */
.place-results { list-style: none; padding: 0; margin: 0; }
.place-results:empty { display: none; }
.place-results li { padding: 6px 0; border-bottom: 1px solid var(--grid); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.place-results a { font-weight: 500; }
.place-kind { color: var(--muted); font-size: 0.8rem; }
.place-chain { color: var(--ink-2); font-size: 0.85rem; flex-basis: 100%; }
.place-n { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; margin-left: 6px; }
.chip.counted { border-style: solid; border-color: var(--series-1); color: var(--series-1); }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 0.88rem; margin-bottom: 6px; }
.crumbs .sep { color: var(--muted); }
.place-head h2 { font-size: 1.5rem; }
.place-head h2 .place-kind { font-size: 0.85rem; font-weight: 400; margin-left: 10px; }
.place-grid { list-style: none; padding: 0; margin: 4px 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.place-grid .chip { margin-left: 6px; }
.card h3 { font-size: 0.95rem; font-weight: 600; margin: 12px 0 2px; color: var(--ink-2); text-transform: capitalize; }
.counted-list { list-style: none; padding: 0; margin: 0 0 8px; }
.counted-list li { padding: 6px 0; border-bottom: 1px solid var(--grid); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.counted-list .num { margin-left: auto; font-variant-numeric: tabular-nums; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); text-decoration: none; display: inline-block; font-weight: 500; }
.btn.primary:hover { background: var(--brand-2); color: #fff; }
.ask p { margin: 6px 0; }
