/* ------------------------------------------------------------------
   Sydney NYE vantage points — dark harbour theme
   Layout: fixed top bar, sidebar + map split, mobile stacks.
   ------------------------------------------------------------------ */

:root {
  --bg: #0b1220;
  --panel: #111c2e;
  --panel-2: #16233a;
  --line: #24344f;
  --text: #e6edf7;
  --muted: #8fa3bf;
  --accent: #38bdf8;
  --free: #34d399;
  --ticket: #60a5fa;
  --paid: #f59e0b;
  --inside: #34d399;
  --outside: #f87171;
  --radius: 12px;
  --shadow: 0 10px 30px rgb(0 0 0 / 35%);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.05rem; }
h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
h3 { font-size: 1rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 1000;
  background: var(--accent); color: #04121f; padding: 0.5rem 0.75rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 1rem;
  background: linear-gradient(180deg, #0e1930, #0b1220);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand-mark { color: var(--accent); display: grid; place-items: center; }
.brand-mark svg { display: block; }
.sub { margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--muted); }

.verdict-wrap {
  display: flex; align-items: center; gap: 1rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.5rem 0.9rem;
  min-width: 22rem;
}

.verdict {
  font-weight: 800; letter-spacing: 0.06em; font-size: 0.82rem;
  padding: 0.3rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
  min-width: 6.5rem; text-align: center;
}
.verdict[data-state="inside"]  { color: #06281c; background: var(--inside); border-color: var(--inside); }
.verdict[data-state="outside"] { color: #2b0a0a; background: var(--outside); border-color: var(--outside); }
.verdict[data-state="none"]    { color: var(--muted); }

.verdict-meta { font-size: 0.76rem; color: var(--muted); flex: 1; }
.verdict-stats { display: flex; gap: 1rem; margin: 0; }
.verdict-stats div { text-align: right; }
.verdict-stats dt { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.verdict-stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 0.85rem; }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 22rem 1fr;
  height: calc(100vh - 4.1rem);
}

.sidebar {
  overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.8rem;
}
.panel > h2 { margin-bottom: 0.6rem; }

.list-panel { flex: 1 1 auto; min-height: 24rem; display: flex; flex-direction: column; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.5rem; }
.count { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 0.83rem; font-weight: 600;
  padding: 0.45rem 0.8rem; border-radius: 9px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { background: #1c2c46; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: #1d4ed8; border-color: #2563eb; }
.btn-primary:hover { background: #2563eb; }
.btn-primary[aria-pressed="true"] { background: var(--accent); color: #04121f; border-color: var(--accent); }
.btn-ghost { background: transparent; }

.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; padding: 0.2rem 0; }
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }

.hint { font-size: 0.76rem; color: var(--muted); margin: 0.5rem 0 0; }
.muted { color: var(--muted); }
kbd {
  font: 0.72rem/1 ui-monospace, monospace; padding: 0.1rem 0.3rem;
  border: 1px solid var(--line); border-radius: 4px; background: var(--panel-2);
}

textarea {
  width: 100%; margin-top: 0.5rem; resize: vertical;
  background: #0a1526; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem;
  font: 0.8rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.coords-panel[hidden] { display: none; }
#coordsFeedback[data-state="warn"] { color: var(--paid); }
#coordsFeedback[data-state="ok"] { color: var(--free); }

/* ---------- card list ---------- */

.card-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.4rem; }

.card { border: 1px solid transparent; border-radius: 10px; background: var(--panel-2); }
.card.is-selected { border-color: var(--accent); background: #17304d; }
.card-btn {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; color: inherit; font: inherit; padding: 0.55rem 0.6rem;
  border-radius: 10px;
}
.card-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.card-head { display: flex; align-items: center; gap: 0.45rem; font-size: 0.87rem; }
.card-head strong { font-weight: 620; }
.card-sub { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 0.1rem; }
.card-row { display: flex; gap: 0.3rem; margin-top: 0.35rem; flex-wrap: wrap; }

.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--dot, var(--free)); flex: none; }

.pill {
  font-size: 0.68rem; font-weight: 650; padding: 0.12rem 0.42rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.pill-free     { color: var(--free);   border-color: color-mix(in oklab, var(--free) 45%, transparent); }
.pill-onsale   { color: var(--paid);   border-color: color-mix(in oklab, var(--paid) 45%, transparent); }
.pill-soldout  { color: var(--outside); border-color: color-mix(in oklab, var(--outside) 45%, transparent); }
.pill-pending  { color: var(--ticket); border-color: color-mix(in oklab, var(--ticket) 45%, transparent); }
.pill-inside   { color: #06281c; background: var(--inside); border-color: var(--inside); }
.pill-outside  { color: var(--muted); }

/* ---------- map ---------- */

.map-wrap { position: relative; }
#map { position: absolute; inset: 0; background: #0a1526; }
#map.is-drawing { cursor: crosshair; }

/* The basemap is already dark (Esri Dark Gray Canvas), so no CSS inversion —
   inverting OSM's light tiles turned the harbour green and the labels muddy. */

.notice {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 1rem; z-index: 500;
  background: #0e1930; border: 1px solid var(--line); border-radius: 10px;
  padding: 0.5rem 0.85rem; font-size: 0.8rem; max-width: 34rem; box-shadow: var(--shadow);
  /* Informational only — it must never intercept a map click while drawing. */
  pointer-events: none;
}
.notice[data-state="warn"] { border-color: var(--paid); }
.notice[data-state="error"] { border-color: var(--outside); }

/* markers */
.vp-marker { background: none; border: 0; }
.vp-dot {
  display: block; width: 12px; height: 12px; border-radius: 50%;
  background: var(--dot); border: 2px solid #04121f;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--dot) 25%, transparent);
}
.vp-dot.is-inside { box-shadow: 0 0 0 4px rgb(52 211 153 / 55%); }
.vp-dot.is-outside { opacity: 0.45; }
.vp-label {
  position: absolute; left: 16px; top: -2px; white-space: nowrap;
  font-size: 0.68rem; font-weight: 600; color: #dbe7f7;
  background: rgb(8 18 32 / 82%); padding: 0.05rem 0.3rem; border-radius: 4px;
  pointer-events: none;
  /* Labels only appear once the map is close enough for them not to collide. */
  display: none;
}
.leaflet-container.show-labels .vp-label { display: block; }
.leaflet-container.show-labels .vp-marker:focus .vp-label { display: block; }

.probe-marker { background: none; border: 0; }
.probe-pulse {
  display: block; width: 18px; height: 18px; border-radius: 50%;
  background: #f472b6; border: 2px solid #fff;
  box-shadow: 0 0 0 4px rgb(244 114 182 / 30%);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgb(244 114 182 / 45%); }
  70%  { box-shadow: 0 0 0 14px rgb(244 114 182 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(244 114 182 / 0%); }
}
@media (prefers-reduced-motion: reduce) {
  .probe-pulse { animation: none; }
}

/* detail card */
.detail {
  position: absolute; right: 1rem; top: 1rem; z-index: 600; width: min(22rem, calc(100% - 2rem));
  background: rgb(14 25 48 / 96%); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem;
  box-shadow: var(--shadow);
}
.detail header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.detail-body { display: grid; grid-template-columns: 7rem 1fr; gap: 0.25rem 0.6rem; margin: 0.7rem 0 0; font-size: 0.8rem; }
.detail-body dt { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 0.1rem; }
.detail-body dd { margin: 0; }
.detail-links { margin: 0.7rem 0 0; font-size: 0.76rem; color: var(--muted); }

/* schedule + evidence */
.schedule { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.schedule li { display: flex; gap: 0.6rem; font-size: 0.8rem; }
.schedule time { font-variant-numeric: tabular-nums; color: var(--accent); min-width: 3.2rem; font-weight: 650; }

.evidence { font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }
.evidence ul { margin: 0 0 0.5rem; padding-left: 1rem; }
.evidence h4 { margin: 0.6rem 0 0.3rem; font-size: 0.75rem; color: var(--text); }
details summary { cursor: pointer; font-size: 0.8rem; color: var(--accent); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .verdict-wrap { min-width: 0; justify-content: space-between; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .map-wrap { order: -1; height: 55vh; }
  .sidebar { border-right: 0; border-top: 1px solid var(--line); }

  /* The detail panel becomes a fixed bottom sheet. Anchored inside .map-wrap it
     opened off-screen whenever the user was scrolled down at the card list — the
     tap worked, the panel rendered, and nobody could see it. Fixed positioning is
     independent of scroll, so it appears wherever the user is. */
  .detail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    margin: 0;
    max-height: 72vh;
    overflow-y: auto;
    border-radius: 14px 14px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    /* Leaflet's .leaflet-bottom (attribution) sits at z-index 1000, so the sheet
       has to clear that or the attribution prints over the panel text. */
    z-index: 1200;
    box-shadow: 0 -12px 30px rgb(0 0 0 / 55%);
    -webkit-overflow-scrolling: touch;
  }
  .detail header { position: sticky; top: -0.9rem; background: rgb(14 25 48 / 97%); padding: 0.4rem 0 0.4rem; margin-top: -0.4rem; }
  .detail-body { grid-template-columns: 6rem 1fr; font-size: 0.85rem; }
  .detail-links { font-size: 0.82rem; line-height: 1.9; }
  /* Make the ticket link a real tap target rather than a thin blue string. */
  .detail-links a { display: inline-block; padding: 0.3rem 0; }

  /* Marker box size is set in map-view.js from the pointer type; only the label
     needs adjusting here. */
  .vp-label { font-size: 0.72rem; left: 24px; }

  .notice { bottom: auto; top: 0.5rem; }
}
