/* Friendly, Waze-inspired look: soft surfaces, rounded everything, big touch targets. */
:root {
  --page: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f2328;
  --ink-2: #555a61;
  --muted: #858a90;
  --line: #e7e3da;
  --accent: #2a78d6;
  --play: #0ca30c;
  --okay: #6ea8dc;   /* "Okay" votes: calm blue, between green Great and amber Poor */
  --iffy: #fab219;
  --skip: #d03b3b;
  --play-soft: #e3f5e1;
  --iffy-soft: #fff3d6;
  --skip-soft: #fbe3e1;
  --shadow: 0 2px 10px rgb(40 35 25 / .14);
  --shadow-sm: 0 1px 4px rgb(40 35 25 / .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #141b23;
    --surface: #1f2833;
    --ink: #eef1f4;
    --ink-2: #b9c3cf;
    --muted: #8793a1;
    --line: #2c3846;
    --accent: #3987e5;
    --play-soft: #1d3a26;
    --iffy-soft: #3b3120;
    --skip-soft: #3d2326;
    --shadow: 0 2px 12px rgb(0 0 0 / .45);
    --shadow-sm: 0 1px 4px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font: 500 15px/1.4 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- header ---------- */
.top {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); box-shadow: var(--shadow-sm); position: relative; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; }
.ball {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #f4ff8a, #c9e021 60%, #a9c010);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / .7), var(--shadow-sm);
  position: relative; overflow: hidden;
}
.ball::before, .ball::after {
  content: ""; position: absolute; width: 26px; height: 26px; border: 2px solid #fff; border-radius: 50%;
}
.ball::before { left: -17px; top: 0; }
.ball::after { right: -17px; top: 0; }
h1 { font-size: 19px; font-weight: 800; margin: 0; letter-spacing: -.2px; }
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--page); border-radius: 999px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); padding: 7px 14px; border-radius: 999px;
  font-weight: 700; cursor: pointer; transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.toggle { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); font-weight: 700; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s;
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s;
}
.toggle input:checked + .track { background: var(--play); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: 0; }
.layout > * { min-width: 0; }
.mapwrap { position: relative; min-height: 0; }
/* isolation: the map is its own stacking layer, so markers' z-index (used to put
   notable courts on top of each other) can't lift them above the card or legend. */
#map { position: absolute; inset: 0; background: var(--page); isolation: isolate; z-index: 0; }

/* ---------- legend ---------- */
.legend {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  padding: 8px 12px; font-size: 12.5px; max-width: calc(100% - 24px);
}
.legend .title { font-weight: 800; color: var(--ink); }
.legend .bar { height: 8px; border-radius: 4px; margin: 6px 0 3px; width: 180px; max-width: 100%; }
.legend .ends { display: flex; justify-content: space-between; color: var(--ink-2); }
.legend .keys { display: flex; gap: 10px; margin-top: 4px; color: var(--ink-2); flex-wrap: wrap; }
.legend .keys i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* Legend swatches for the weather shading (rain / wind / striped both). */
.legend .sw { display: inline-block; width: 16px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- court markers ---------- */
.court-marker { cursor: pointer; display: flex; flex-direction: column; align-items: center; }
/* Each court: a small tennis court coloured by playability, with its number on a
   white label underneath. Shown at every zoom level. */
.pin {
  display: block; padding: 2px; background: var(--surface); border-radius: 6px; box-shadow: var(--shadow);
  border: 2px solid transparent; transition: transform .12s;
}
.pin svg.court { width: 32px; height: 19px; display: block; }
.pin.school svg.court { width: 26px; height: 16px; }
.lbl {
  display: inline-block; margin-top: 2px; padding: 2px 6px; border-radius: 999px; box-shadow: var(--shadow-sm);
  font-weight: 800; font-size: 12px; line-height: 1.1; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: var(--surface); color: var(--ink);
}
.court-marker:hover .pin, .court-marker.selected .pin { transform: scale(1.12); }
.court-marker.selected .pin { border-color: var(--accent); }
.ic { width: 15px; height: 15px; vertical-align: -2px; flex: none; }
.seg button { display: inline-flex; align-items: center; gap: 6px; }
.ball-dot { width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f4ff8a, #c9e021 60%, #a9c010); display: inline-block; }
.facts span { display: inline-flex; align-items: center; gap: 5px; }
.court-marker .nm {
  display: none; margin-top: 3px; padding: 1px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--ink-2); white-space: nowrap;
}
.show-names .court-marker .nm { display: block; }

/* ---------- court card ---------- */
.card {
  position: absolute; left: 12px; bottom: 12px; z-index: 4; width: 340px; max-width: calc(100% - 24px);
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px 16px;
}
.card .x {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--page); color: var(--ink-2); font-size: 18px; cursor: pointer;
}
.card .head { display: flex; gap: 10px; align-items: center; padding-right: 34px; }
.card .head svg.court { width: 46px; height: 28px; flex: none; }
.card h3 { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.2; }
.verdict {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; padding: 10px 12px; border-radius: 14px;
}
.verdict.play { background: var(--play-soft); }
.verdict.iffy { background: var(--iffy-soft); }
.verdict.skip { background: var(--skip-soft); }
.verdict .face { font-size: 28px; line-height: 1; }
.verdict strong { font-size: 16px; font-weight: 800; display: block; }
.verdict .score { margin-left: auto; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.verdict .score small { font-size: 12px; color: var(--muted); font-weight: 700; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
/* Court condition from courts.csv, shown above the weather. */
.status { margin: 10px 0 4px; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; color: var(--ink); }
.status.poor { background: var(--iffy-soft); }
.status.closed { background: var(--skip-soft); }
/* Google Maps / Street View buttons. */
.links { display: flex; gap: 8px; margin: 10px 0 2px; }
.links a {
  flex: 1; text-align: center; padding: 7px 10px; border-radius: 999px; background: var(--page);
  color: var(--ink); font-weight: 700; font-size: 13px; text-decoration: none;
}
.links a:hover { background: color-mix(in srgb, var(--accent) 12%, var(--page)); }

/* Court condition votes + comments, at the bottom of the court card. */
.community { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.community .ctitle { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
/* Bar chart: label | bar (share of votes) | count. The whole row is the tap target. */
.vbar {
  display: grid; grid-template-columns: 112px 1fr 26px; align-items: center; gap: 8px; width: 100%;
  border: 2px solid transparent; background: none; color: var(--ink); padding: 3px 6px; border-radius: 10px;
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.vbar:hover { background: var(--page); }
.vbar.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.vbar .vl { font-weight: 700; white-space: nowrap; }
.vbar .vt { height: 10px; border-radius: 5px; background: var(--page); overflow: hidden; }
.vbar .vt i { display: block; height: 100%; border-radius: 5px; min-width: 0; }
.vbar .vn { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.vhint { margin: 2px 6px 0; }
/* Comments, Instagram-style. */
.comments { margin-top: 12px; }
.comments ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 190px; overflow-y: auto; }
.comments li, .comments .add { display: flex; gap: 8px; align-items: flex-start; }
.comments .av {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 13px;
}
.comments .cbody { font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; }
.comments .cbody a { color: var(--muted); }
.comments .empty { margin: 2px 0 6px; }
.comments .add { margin-top: 10px; align-items: center; }
.comments .add input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px;
}
.comments .add button { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 800; cursor: pointer; }
.comments .add button:disabled { opacity: .5; }
.community .google {
  width: 100%; border: 0; border-radius: 999px; padding: 9px 12px; margin-top: 10px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 800; font-size: 13.5px;
}
.community .msg { margin-top: 4px; color: var(--ink-2); min-height: 1em; }
.community .acct { margin-top: 6px; }
.community .acct a { color: var(--muted); }
/* The card can now be tall on phones; let it scroll instead of covering the whole map. */
.card { max-height: calc(100% - 24px); overflow-y: auto; }
.facts span { background: var(--page); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 4px; }
.strip div { text-align: center; font-size: 10.5px; color: var(--muted); font-weight: 700; }
.strip i { display: block; height: 18px; border-radius: 5px; margin-bottom: 3px; }
.strip i.play { background: var(--play); } .strip i.iffy { background: var(--iffy); } .strip i.skip { background: var(--skip); }
.strip .dn { display: block; height: 14px; margin-bottom: 2px; }
.strip .dn svg { width: 13px; height: 13px; display: inline-block; }
.strip .dn.sun { color: #f2a900; }
.strip .dn.moon { color: #7c8da3; }
.best { margin-top: 10px; font-weight: 800; color: var(--ink); }

/* ---------- list ---------- */
.panel { background: var(--surface); overflow-y: auto; padding: 14px 14px 20px; box-shadow: var(--shadow-sm); z-index: 1; }
.panel h2 { font-size: 15px; margin: 2px 4px 10px; font-weight: 800; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
  display: grid; grid-template-columns: 50px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 14px; background: var(--page); cursor: pointer; transition: transform .1s;
}
.list li:hover { transform: translateY(-1px); }
.list li:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.list li svg.court { width: 46px; height: 28px; display: block; }
.list .name { font-weight: 800; line-height: 1.2; }
.list .sub { color: var(--ink-2); font-size: 12.5px; }
.list .num { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- time bar ---------- */
/* Big time label + buttons, then a slider whose bar is shaded day/night with hour ticks. */
.timebar {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px 18px;
  padding: 10px 16px 8px; max-width: 100vw;
  background: var(--surface); box-shadow: 0 -1px 4px rgb(0 0 0 / .08); position: relative; z-index: 3;
  --day: #ffe3a1; --night: #cbd5e3; --thumb: 24px;
}
@media (prefers-color-scheme: dark) { .timebar { --day: #6e5c2c; --night: #2c3847; } }
.timehead { display: flex; align-items: center; gap: 8px; }
.when { min-width: 170px; text-align: center; }
.when .big { font-size: 19px; font-weight: 800; line-height: 1.15; white-space: nowrap; font-variant-numeric: tabular-nums; }
.when .big .live { color: var(--accent); }
.round, .nowbtn {
  border: 0; background: var(--page); color: var(--ink); height: 38px; min-width: 38px;
  border-radius: 999px; cursor: pointer; font-weight: 800; font-size: 18px;
}
.nowbtn { padding: 0 16px; font-size: 14px; background: var(--accent); color: #fff; }
.nowbtn[aria-pressed="true"] { opacity: .55; }

.slider { position: relative; height: 46px; }
.slider .track {
  position: absolute; top: 9px; height: 10px; border-radius: 5px;
  left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2);
}
.slider input {
  position: absolute; inset: 0 0 auto 0; width: 100%; height: 28px; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.slider input::-webkit-slider-runnable-track { height: 28px; background: transparent; }
.slider input::-moz-range-track { height: 28px; background: transparent; }
.slider input::-webkit-slider-thumb {
  -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: 2px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: var(--shadow);
}
.slider input::-moz-range-thumb {
  width: var(--thumb); height: var(--thumb); border-radius: 50%; box-sizing: border-box;
  background: var(--accent); border: 3px solid #fff; box-shadow: var(--shadow);
}
.slider input:focus-visible::-webkit-slider-thumb { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.ticks { position: absolute; left: 0; right: 0; top: 26px; height: 18px; }
.ticks span {
  position: absolute; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.ticks span.day { color: var(--ink-2); font-weight: 800; }
.ticks span::before {
  content: ""; position: absolute; left: 50%; top: -7px; width: 1px; height: 5px; background: var(--muted);
}

/* MapLibre controls, softened */
.maplibregl-ctrl-group { border-radius: 14px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 760px) {
  html, body { height: auto; }
  .layout { flex: none; grid-template-columns: minmax(0, 1fr); grid-template-rows: 62vh auto; }
  .timebar { position: sticky; bottom: 0; z-index: 10; grid-template-columns: minmax(0, 1fr); }
  .timehead { justify-content: space-between; }
  .when { flex: 1; min-width: 0; }
  .card { left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; }
  .legend { top: 8px; left: 8px; }
  /* Phones: smaller court icon; the label number stays a readable 11.5px. */
  .pin { padding: 1.5px; }
  .pin svg.court { width: 24px; height: 14px; }
  .pin.school svg.court { width: 20px; height: 12px; }
  .lbl { font-size: 11.5px; padding: 1.5px 5px; margin-top: 1px; }}
