/* nycboardgames.com. Tokens first; dark mode is its own set of validated steps, not an inversion. */
:root {
  color-scheme: light;
  --bg: #f3eee3;
  --surface: #fbf8f1;
  --ink: #1d1b16;
  --ink-2: #55514a;
  --muted: #7d786e;
  --line: #e2dccf;
  --accent: #1f5c45;
  --accent-2: #e6efe9;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(29, 27, 22, .06), 0 4px 16px rgba(29, 27, 22, .05);

  --t-current: #eb6834;
  --t-shortlist: #2a78d6;
  --t-lead: #1baf7a;
  --t-other: #8a857b;

  --yes-ink: #006300; --yes-bg: #e3f1e0;
  --no-ink: #b02e2e; --no-bg: #f8e3df;
  --unk-ink: #6b665d; --unk-bg: #ece7dc;

  --pos2: #256abf; --pos1: #6da7ec; --neg1: #ec8a84; --neg2: #c93a39;
  --imp3: #104281; --imp2: #2a78d6; --imp1: #6da7ec; --imp0: #e2dccf;
  --bar: #2a78d6;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12110f; --surface: #1c1b19; --ink: #f4f1ea; --ink-2: #c3c2b7; --muted: #959083; --line: #2f2d29;
    --accent: #6cbf97; --accent-2: #1f2e27; --on-accent: #0f1a14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --t-current: #d95926; --t-shortlist: #3987e5; --t-lead: #199e70; --t-other: #8f8a80;
    --yes-ink: #5fd35f; --yes-bg: #183019; --no-ink: #ff8a80; --no-bg: #3a1d1b; --unk-ink: #b9b4a9; --unk-bg: #2a2925;
    --pos2: #6da7ec; --pos1: #256abf; --neg1: #b43c3b; --neg2: #e66767;
    --imp3: #9ec5f4; --imp2: #3987e5; --imp1: #1c5cab; --imp0: #3a3935;
    --bar: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12110f; --surface: #1c1b19; --ink: #f4f1ea; --ink-2: #c3c2b7; --muted: #959083; --line: #2f2d29;
  --accent: #6cbf97; --accent-2: #1f2e27; --on-accent: #0f1a14;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --t-current: #d95926; --t-shortlist: #3987e5; --t-lead: #199e70; --t-other: #8f8a80;
  --yes-ink: #5fd35f; --yes-bg: #183019; --no-ink: #ff8a80; --no-bg: #3a1d1b; --unk-ink: #b9b4a9; --unk-bg: #2a2925;
  --pos2: #6da7ec; --pos1: #256abf; --neg1: #b43c3b; --neg2: #e66767;
  --imp3: #9ec5f4; --imp2: #3987e5; --imp1: #1c5cab; --imp0: #3a3935;
  --bar: #3987e5;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---- Top bar ---------------------------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 16px; white-space: nowrap; }
.brand img { border-radius: 7px; }
.views { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.views a { padding: 6px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.views a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

/* ---- Controls --------------------------------------------------------------------------- */
.controls { padding: 12px 16px 4px; display: grid; gap: 8px; }
.controls .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.controls input[type="search"] { flex: 1 1 260px; min-width: 0; }
input[type="search"], select {
  height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
input[type="search"]:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; min-width: 76px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 13.5px;
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-2); color: var(--ink); font-weight: 600; }
.chips .chip[aria-pressed="false"] .shape { opacity: .35; }
.from label { font-size: 13.5px; color: var(--ink-2); }
.btn, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  text-decoration: none; font-size: 13.5px; white-space: nowrap;
}
.ghost:hover, .btn:hover { border-color: var(--muted); }

/* ---- Split layout ---------------------------------------------------------------------- */
.split { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 8px 16px 24px; }
.map-col { order: -1; }
#map { height: 46vh; min-height: 280px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); z-index: 0; }
#map.picking { cursor: crosshair; outline: 3px solid var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 4px 0; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(380px, 540px) 1fr; align-items: start; }
  .map-col { order: 0; position: sticky; top: 72px; }
  #map { height: calc(100dvh - 120px); }
}

/* ---- Cards ------------------------------------------------------------------------------ */
.count { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 12px; box-shadow: var(--shadow); scroll-margin-top: 80px; cursor: pointer;
}
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card.baseline { border-style: dashed; border-width: 1.5px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--t-current); font-weight: 700; }
.card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card h3 { font-size: 17px; }
.tier { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; padding-top: 2px; }
.meta { margin: 2px 0 0; color: var(--ink-2); font-size: 13.5px; }
.dist { color: var(--ink); font-weight: 600; }
.addr { margin: 2px 0 10px; color: var(--muted); font-size: 13px; }
.flag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 6px; background: var(--unk-bg); color: var(--unk-ink); font-size: 11.5px; }
.checks { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.checks li { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-2); min-width: 0; }
.checks li.needed { font-weight: 600; color: var(--ink); }
.mark {
  flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.mark.yes { background: var(--yes-bg); color: var(--yes-ink); }
.mark.no { background: var(--no-bg); color: var(--no-ink); }
.mark.unk { background: var(--unk-bg); color: var(--unk-ink); }
.cmp { margin-left: auto; font-size: 11px; padding: 0 5px; border-radius: 5px; white-space: nowrap; }
.cmp.up { color: var(--yes-ink); background: var(--yes-bg); }
.cmp.down { color: var(--no-ink); background: var(--no-bg); }
.pc p { margin: 0 0 4px; font-size: 13.5px; }
.card details { margin-top: 6px; }
.card summary { cursor: pointer; color: var(--accent); font-size: 13.5px; width: fit-content; }
.facts { margin: 8px 0; display: grid; gap: 6px; }
.facts div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.try {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px; border-radius: 10px;
  border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 13.5px;
}
.try.on { background: var(--accent); color: var(--on-accent); }
.try:disabled { opacity: .55; cursor: default; }
.try-n { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 7px; display: inline-grid; place-items: center; background: var(--accent-2); color: var(--ink); font-variant-numeric: tabular-nums; }
.try.on .try-n { background: color-mix(in srgb, var(--on-accent) 22%, transparent); color: var(--on-accent); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.foot { margin-top: 20px; font-size: 13px; color: var(--ink-2); }
.foot p { margin: 0 0 8px; }
.foot .mark { width: 16px; height: 16px; font-size: 10px; vertical-align: -3px; }

/* ---- Map pins --------------------------------------------------------------------------- */
.pin { background: none; border: 0; }
.pin svg { display: block; filter: drop-shadow(0 0 1.5px var(--surface)) drop-shadow(0 0 1.5px var(--surface)) drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.pin.sel svg { filter: drop-shadow(0 0 0 2px var(--surface)) drop-shadow(0 0 3px var(--accent)) drop-shadow(0 0 3px var(--accent)); }
.from-pin { stroke: var(--ink); fill: var(--surface); }
.leaflet-container { font: inherit; background: var(--surface); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content { margin: 10px 14px; line-height: 1.5; }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--ink-2); }

/* ---- Toast & tooltip ------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px);
}
.tip {
  position: fixed; left: 0; top: 0; z-index: 2000; pointer-events: none; max-width: 280px;
  background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 13px;
}

/* ---- Survey ------------------------------------------------------------------------------ */
.survey { max-width: 820px; margin: 0 auto; padding: 20px 16px 48px; }
.survey-head h1 { font-size: 28px; margin-bottom: 8px; }
.survey-head p { margin: 0 0 6px; color: var(--ink-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 20px 0 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile b { display: block; font-size: 26px; font-weight: 650; }
.tile b small { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.tile span { color: var(--ink-2); font-size: 13.5px; }
.viz { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.viz h2 { font-size: 17px; }
.viz .sub { margin: 4px 0 10px; color: var(--ink-2); font-size: 13.5px; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); margin: 6px 0 10px; }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.pos2 { background: var(--pos2); } .pos1 { background: var(--pos1); } .neg1 { background: var(--neg1); } .neg2 { background: var(--neg2); }
.imp3 { background: var(--imp3); } .imp2 { background: var(--imp2); } .imp1 { background: var(--imp1); } .imp0 { background: var(--imp0); }
.lbl { font-size: 13.5px; color: var(--ink); min-width: 0; }
.val { font-size: 13px; color: var(--ink-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.seg { display: block; height: 18px; flex-shrink: 0; flex-grow: 0; }

/* Diverging: negatives grow left from the centre line, positives right. 2px surface gap between segments. */
.div-row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr 1fr 64px; align-items: center; gap: 0 0; padding: 4px 0; }
.div-row .lbl { padding-right: 10px; }
.half { display: flex; height: 18px; gap: 2px; }
.half.neg { justify-content: flex-end; padding-right: 1px; border-right: 1px solid var(--muted); }
.half.pos { padding-left: 1px; }
.half.neg .seg:first-child { border-radius: 4px 0 0 4px; }
.half.pos .seg:last-child { border-radius: 0 4px 4px 0; }
.div-row .val { padding-left: 8px; }

.stack-row { display: grid; grid-template-columns: minmax(120px, 230px) 1fr 48px; align-items: center; gap: 10px; padding: 4px 0; }
.stack { display: flex; gap: 2px; height: 18px; }
.stack .seg:last-child { border-radius: 0 4px 4px 0; }

.bar-row { display: grid; grid-template-columns: minmax(140px, 300px) 1fr; align-items: center; gap: 10px; padding: 4px 0; }
.track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar { display: block; height: 16px; min-width: 2px; background: var(--bar); border-radius: 0 4px 4px 0; }
.track b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.tbl { margin-top: 10px; }
.tbl summary { cursor: pointer; color: var(--accent); font-size: 13px; width: fit-content; }
.tbl table { border-collapse: collapse; margin-top: 8px; font-size: 13px; width: 100%; display: block; overflow-x: auto; }
.tbl th, .tbl td { padding: 4px 10px 4px 0; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
.tbl thead th { color: var(--muted); font-weight: 500; }
.tbl tbody th { font-weight: 400; }

@media (max-width: 560px) {
  .brand span b { display: none; }
  .views a { padding: 6px 10px; font-size: 13px; }
  /* Filters: one swipeable line per row so the map shows on the first screen. */
  .controls { gap: 6px; }
  .controls select { flex: 1 1 40%; min-width: 0; }
  .controls .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chips .chip, .chips .row-label { flex: none; }
  .from .muted { display: none; }
  .checks { grid-template-columns: 1fr; }
  .div-row { grid-template-columns: 1fr 1fr 56px; }
  .div-row .lbl { grid-column: 1 / -1; padding: 0 0 2px; }
  .stack-row, .bar-row { grid-template-columns: 1fr 44px; }
  .stack-row .lbl, .bar-row .lbl { grid-column: 1 / -1; }
  .bar-row .track { grid-column: 1 / -1; }
  .row-label { min-width: 0; }
}

/* ---- Landing page ------------------------------------------------------------------------ */
.landing { min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; }
.hero { max-width: 620px; }
.hero .logo { border-radius: 14px; }
.hero h1 { font-size: clamp(32px, 7vw, 48px); margin: 18px 0 10px; letter-spacing: -.01em; }
.hero .lede { font-size: 18px; color: var(--ink-2); margin: 0 0 20px; }
.when { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
.when p { margin: 0 0 4px; }
.when b { font-size: 17px; }
.cta { display: inline-flex; align-items: center; height: 46px; padding: 0 20px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 650; text-decoration: none; }
.hero ul { padding-left: 18px; color: var(--ink-2); }

.leaflet-tile-pane { filter: saturate(.75); }
/* OSM has no dark style: invert and soften the tiles only (pins and popups stay true-colour). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
}
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
