/* Opentonight: an evening tool. Cool paper by day, deep night blue in dark mode; the one
   loud colour is the red of an "open" sign, and green means open. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --sunk: #e8ecf3;
  --line: #d9dfe9;
  --ink: #172033;
  --muted: #5b6478;
  --sign: #e23d28;
  --open: #12873f;
  --soon: #b45309;
  --unknown: #7b8496;
  --you: #2e8bc0;
  --land: #f7f8fb;
  --outside: #e3e7ef;
  --road: #c9cfdb;
  --road-major: #e2a65a;
  --water: #9fcbe6;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(23 32 51 / .06), 0 6px 20px rgb(23 32 51 / .06);
  color-scheme: light dark;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1522;
    --surface: #18202f;
    --sunk: #111827;
    --line: #2a3447;
    --ink: #eef1f7;
    --muted: #98a2b5;
    --sign: #ff5a43;
    --open: #34d17a;
    --soon: #f2a541;
    --unknown: #8792a6;
    --you: #5fb8e8;
    --land: #1b2435;
    --outside: #121a29;
    --road: #33405a;
    --road-major: #8a6a3e;
    --water: #2d5876;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--you); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px max(18px, env(safe-area-inset-left)) 6px; }
.mark { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-stretch: 78%; font-size: 1.45rem; letter-spacing: -.01em; }
.mark svg { width: 28px; height: 28px; color: var(--sign); }
.mark-dot { fill: var(--open); }
.ghost { background: none; border: 0; color: var(--muted); padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.ghost:hover { color: var(--ink); background: var(--sunk); }

/* layout: one column on phones, search + list beside the map on wide screens */
.shell { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 18px 18px; display: grid; gap: 14px; }
@media (min-width: 960px) {
  .shell { grid-template-columns: 380px 1fr; align-items: start; }
  .results { position: sticky; top: 12px; }
}

/* search panel */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 16px; align-self: start; }
.field { display: grid; gap: 8px; }
.field > label, .label, .label-row label { font-weight: 700; font-size: .95rem; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row output { font-weight: 700; font-variant-numeric: tabular-nums; }
.where-row { display: flex; gap: 8px; }
.town-box { position: relative; flex: 1; min-width: 0; }
input[type="search"], select, input[type="time"] { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); min-height: 46px; }
input[type="search"]:focus, select:focus, input[type="time"]:focus { border-color: var(--you); outline: none; }
.suggest { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 300px; overflow: auto; }
.suggest li { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.suggest li small { color: var(--muted); }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--sunk); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn svg { width: 18px; height: 18px; }
.btn.locate { color: var(--you); }
.btn.locate[aria-busy="true"] svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.hint { margin: 0; color: var(--muted); font-size: .9rem; min-height: 1.3em; }
.hint.warn { color: var(--soon); }
input[type="range"] { width: 100%; accent-color: var(--sign); height: 28px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chips button { border: 1.5px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 13px; cursor: pointer; font-weight: 600; min-height: 38px; }
.seg button[aria-checked="true"], .chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.when-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.more summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.more[open] summary { margin-bottom: 12px; }
.more summary span { color: var(--sign); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 12px; }
.checks label { display: flex; align-items: center; gap: 8px; min-height: 34px; cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--sign); }

/* results */
.results { display: grid; gap: 12px; min-width: 0; }
.results-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.headline { margin: 0; font-size: clamp(1.5rem, 5.4vw, 2.25rem); line-height: 1.08; font-weight: 800; font-stretch: 82%; letter-spacing: -.015em; max-width: 22ch; text-wrap: balance; }
.headline b { color: var(--open); font-weight: 800; }
.view { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 3px; }
.view button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; cursor: pointer; font-weight: 700; color: var(--muted); }
.view button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
/* phones: List / Map tabs. Wider: no tabs; map above the list, then (very wide) beside it */
.results.show-map .list-view, .results:not(.show-map) .map-view { display: none; }
@media (min-width: 960px) {
  .view { display: none; }
  .results .list-view, .results .map-view { display: block !important; }
  .map-view { height: 46vh; }
}
@media (min-width: 1240px) {
  .results { grid-template-columns: minmax(300px, 420px) 1fr; grid-template-areas: "head head" "list map"; height: calc(100dvh - 76px); grid-template-rows: auto minmax(0, 1fr); }
  .results-head { grid-area: head; }
  .list-view { grid-area: list; overflow: auto; padding: 2px 6px 12px 2px; }
  .map-view { grid-area: map; height: 100%; }
}

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 12px; display: grid; gap: 6px; align-content: start; border: 2px solid transparent; scroll-margin: 80px; }
.card.on { border-color: var(--sign); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card h3 { margin: 0; font-size: 1.12rem; line-height: 1.2; font-weight: 750; }
.dist { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .92rem; }
.meta { color: var(--muted); font-size: .92rem; margin: 0; }
.status { margin: 0; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.status.open { color: var(--open); }
.status.soon { color: var(--soon); }
.status.unknown { color: var(--unknown); }
.status.closed { color: var(--unknown); }
.status small { color: var(--muted); font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 0; padding: 0; list-style: none; }
.tags li { font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.actions .btn { min-height: 38px; padding: 0 12px; font-size: .92rem; }
.actions .btn.primary { background: var(--sign); border-color: var(--sign); color: #fff; }
.hours-box summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: 4px 0; }
.hours-box table { border-collapse: collapse; font-size: .9rem; margin: 4px 0 2px; }
.hours-box td { padding: 2px 14px 2px 0; vertical-align: top; }
.hours-box tr.today td { font-weight: 700; }
.hours-box .fix { font-size: .85rem; color: var(--muted); }
.no-hours { margin-top: 16px; }
.no-hours > summary { cursor: pointer; list-style: none; display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--radius); background: var(--sunk); margin-bottom: 10px; }
.no-hours > summary::-webkit-details-marker { display: none; }
.no-hours > summary span { font-weight: 750; }
.no-hours > summary span::after { content: " ▾"; color: var(--muted); }
.no-hours[open] > summary span::after { content: " ▴"; }
.no-hours > summary small { color: var(--muted); }
.empty { background: var(--surface); border-radius: var(--radius); padding: 18px; color: var(--muted); }
.more-btn { margin: 10px auto 0; display: flex; }

/* map */
.map-view { position: relative; height: min(68dvh, 620px); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--outside); touch-action: none; }
.map-view canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.map-view canvas.dragging { cursor: grabbing; }
.map-tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 1.3rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow); }
.map-tools .btn { box-shadow: var(--shadow); }
.map-pop { position: absolute; left: 10px; right: 10px; bottom: 30px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 4px; max-width: 420px; }
.map-pop h3 { margin: 0; font-size: 1.05rem; }
.map-pop .actions { margin: 4px 0 0; }
.map-credit { position: absolute; right: 6px; bottom: 4px; margin: 0; font-size: .72rem; color: var(--muted); background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 1px 6px; border-radius: 6px; }

/* footer, dialog */
.foot { color: var(--muted); font-size: .85rem; padding: 10px 18px 24px; max-width: 1280px; margin: 0 auto; width: 100%; }
.foot p { margin: 4px 0; }
.sheet { border: 0; border-radius: 18px; padding: 22px; max-width: 560px; width: calc(100% - 28px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.sheet::backdrop { background: rgb(10 14 24 / .5); }
.sheet h2 { margin: 0 0 6px; font-weight: 800; font-stretch: 82%; font-size: 1.6rem; }
.sheet h3 { margin: 16px 0 4px; font-size: 1rem; }
.sheet p, .sheet li { color: var(--muted); }
.sheet .close { float: right; border: 0; background: var(--sunk); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
