:root {
  --bg: #0e1116;
  --panel: #161a22;
  --panel-2: #1d2330;
  --border: #262d3b;
  --text: #e7ecf3;
  --text-dim: #98a2b3;
  --text-mute: #8590a4;       /* AA: 4.88:1 on panel-2 */
  --accent: #ff3b6b;          /* brand pink — decorative use (dots, marker fills) */
  --accent-strong: #c0193f;   /* AA-safe accent for text-on-fill (buttons/active chips) */
  --accent-2: #00d1b2;        /* teal */
  --gold: #f5b400;

  --fifa: #ff3b6b;
  --fanzone: #f5b400;
  --community: #00d1b2;
  --bar: #7c8cff;
  --private: #c084fc;

  --focus: #6ae7ff;           /* high-contrast focus ring */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; -webkit-font-smoothing: antialiased; }

/* === FOCUS STYLES (WCAG 2.4.7) === */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible, [role="button"]:focus-visible, input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* === SKIP LINK === */
.skip-link {
  position: absolute; top: -100px; left: 8px; z-index: 9999;
  background: var(--accent-strong); color: #fff; padding: 10px 16px;
  border-radius: 6px; font-weight: 600; font-size: 14px;
  text-decoration: none; transition: top 0.15s;
}
.skip-link:focus { top: 8px; }

/* Screen-reader-only utility */
.sr-only {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}

/* === TOPBAR === */
.topbar {
  position: relative;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 22px;
  background: linear-gradient(180deg, #161a22, #11141b);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--accent); }
.brand-title { font-family: 'Bricolage Grotesque', serif; font-weight: 800; font-size: 17px; color: var(--text); letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px 18px; font-size: 12px; color: var(--text-dim); align-items: center; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; border: 1px solid rgba(255,255,255,0.25); }
.dot-fifa { background: var(--fifa); }
.dot-fanzone { background: var(--fanzone); }
.dot-community { background: var(--community); }
.dot-bar { background: var(--bar); }
.dot-private { background: var(--private); }

/* === LAYOUT === */
.layout { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 64px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; }
.map-wrap { position: relative; }
#map { height: 100%; width: 100%; background: #0a0c10; }

/* === FILTERS === */
.filters { padding: 18px 18px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.filter-group { margin-bottom: 14px; border: 0; padding: 0; margin-left: 0; margin-right: 0; min-width: 0; }
fieldset.filter-group { margin-block-end: 14px; }
.filter-group > label, .filter-legend {
  display: block; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 7px;
  padding: 0;
}
#search { width: 100%; padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; outline: none; transition: border-color 0.15s; font-family: inherit; }
#search::placeholder { color: var(--text-mute); }
#search:focus-visible { border-color: var(--focus); outline: 3px solid var(--focus); outline-offset: 1px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit; line-height: 1.2;
}
.chip:hover { color: var(--text); border-color: #4a5468; background: #232a39; }
.chip[aria-pressed="true"] {
  background: var(--accent-strong); border-color: var(--accent-strong); color: #fff;
}
.chip-sub { font-size: 9.5px; opacity: 0.85; font-weight: 400; display: block; margin-top: 2px; }

/* === CONFEDERATION-GROUPED TEAM CHIPS === */
.chip-all { margin-bottom: 10px; font-weight: 600; }
.chip-confederation { margin-top: 10px; }
.chip-conf-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--text-dim);
  margin-bottom: 5px; padding-left: 2px;
}
.chip-conf-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.chip-team {
  padding: 4px 8px; font-size: 11.5px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px; line-height: 1.2;
}
.chip-team.chip-dim { opacity: 0.7; }
.chip-team.chip-dim:hover { opacity: 1; }
.chip-count {
  font-size: 10px; font-weight: 700; background: rgba(255,255,255,0.14);
  color: var(--text); padding: 1px 5px; border-radius: 999px;
  margin-left: 2px; line-height: 1.3;
}
.chip-team[aria-pressed="true"] .chip-count { background: rgba(255,255,255,0.3); color: #fff; }

.filter-summary { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-dim); padding-top: 4px; }
.filter-summary #resultCount { font-weight: 700; color: var(--text); }
.reset { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 4px 10px; border-radius: 6px; font-size: 11.5px; cursor: pointer; font-family: inherit; }
.reset:hover { border-color: var(--accent); }

/* === VENUE LIST === */
.venue-list { padding: 8px 12px 24px; }
.venue-list[role="list"] { list-style: none; margin: 0; }
.venue-card {
  padding: 12px 12px; margin-bottom: 8px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s; position: relative;
  width: 100%; text-align: left; color: inherit; font-family: inherit; font-size: inherit;
  display: block;
}
.venue-card:hover { border-color: #4a5468; transform: translateY(-1px); }
.venue-card.active { border-color: var(--accent); background: #1f1620; }
.venue-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.vc-type {
  position: absolute; top: 12px; right: 12px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
}
.vc-name { font-family: 'Bricolage Grotesque', serif; font-weight: 700; font-size: 14px; line-height: 1.25; margin-bottom: 4px; padding-right: 22px; color: var(--text); }
.vc-meta { font-size: 12px; color: var(--text-dim); display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.vc-meta span::after { content: '·'; margin-left: 8px; opacity: 0.5; }
.vc-meta span:last-child::after { content: ''; }
.vc-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.vc-tag { font-size: 10.5px; background: rgba(255,255,255,0.08); color: var(--text); padding: 2px 7px; border-radius: 4px; font-weight: 500; }
.vc-tag.team { background: rgba(255,158,181,0.18); color: #ffc4d2; }
.vc-tag.free { background: rgba(106,231,212,0.18); color: #8af1de; }
.vc-tag.ticketed { background: rgba(245,203,80,0.18); color: #f7d566; }

/* === DETAIL PANEL === */
.detail-panel {
  position: fixed; right: 0; top: 64px; bottom: 0;
  width: 440px; max-width: 95vw;
  background: var(--panel); border-left: 1px solid var(--border);
  transform: translateX(110%); transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 1500; overflow-y: auto; box-shadow: -20px 0 40px rgba(0,0,0,0.4);
}
.detail-panel.open { transform: translateX(0); }
.close-btn {
  position: sticky; top: 12px; float: right; margin: 12px 14px 0 0;
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 10;
  font-family: inherit; line-height: 1;
}
.close-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
#detailContent { padding: 8px 24px 32px; }
.dp-type {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 4px 9px; border-radius: 4px; margin-bottom: 10px;
}
.dp-type-fifa { background: rgba(255,158,181,0.22); color: #ffc4d2; }
.dp-type-fanzone { background: rgba(245,203,80,0.22); color: #f7d566; }
.dp-type-community { background: rgba(106,231,212,0.22); color: #8af1de; }
.dp-type-bar { background: rgba(168,180,255,0.22); color: #c2cbff; }
.dp-type-private { background: rgba(214,179,255,0.22); color: #dec2ff; }
.dp-name { font-family: 'Bricolage Grotesque', serif; font-weight: 800; font-size: 22px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; color: var(--text); }
.dp-neighborhood { font-size: 13px; color: var(--accent-2); margin-bottom: 16px; font-weight: 600; }
.dp-section { padding: 12px 0; border-top: 1px solid var(--border); }
.dp-section:first-of-type { border-top: none; }
.dp-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 5px; }
.dp-value { font-size: 14px; color: var(--text); line-height: 1.55; }
.dp-value.address { color: var(--text-dim); font-size: 13px; }
.dp-pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.dp-pill {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.08); color: var(--text); font-weight: 500;
}
.dp-pill.free { background: rgba(106,231,212,0.2); color: #8af1de; }
.dp-pill.ticketed { background: rgba(245,203,80,0.2); color: #f7d566; }
.dp-pill.team { background: rgba(255,158,181,0.2); color: #ffc4d2; font-weight: 600; }
.dp-matches { font-size: 13.5px; line-height: 1.6; color: var(--text); white-space: pre-wrap; }
.dp-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.dp-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; background: var(--accent-strong); color: #fff;
  border: 1px solid transparent; border-radius: 8px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; font-family: inherit;
}
.dp-btn.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.dp-btn:hover { filter: brightness(1.1); }
.dp-sources { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.6; }
.dp-sources a { color: var(--accent-2); text-decoration: underline; }
.dp-sources a:hover { text-decoration: none; }

/* === LEAFLET CUSTOM === */
/* Lift the base tiles so streets/freeways/water are legible without washing out markers */
.wc-base-tiles { filter: brightness(1.18) contrast(1.05) saturate(0.95); }
.wc-label-tiles { filter: brightness(1.6) contrast(1.15); }
.leaflet-container { background: #1a1f2a !important; font-family: 'Inter', sans-serif !important; }
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 10px; border: 1px solid var(--border); box-shadow: 0 12px 30px rgba(0,0,0,0.5); }
.leaflet-popup-tip { background: var(--panel); border: 1px solid var(--border); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; min-width: 200px; }
.leaflet-popup-content .pop-name { font-family: 'Bricolage Grotesque', serif; font-weight: 700; font-size: 14px; margin-bottom: 4px; color: var(--text); }
.leaflet-popup-content .pop-meta { font-size: 11.5px; color: var(--text-dim); margin-bottom: 8px; }
.leaflet-popup-content .pop-btn { background: var(--accent-strong); color: #fff; padding: 6px 11px; border-radius: 6px; font-size: 12px; font-weight: 600; text-decoration: none; display: inline-block; }
.leaflet-popup-content .pop-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--border) !important; font-weight: 700; }
.leaflet-control-zoom a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.leaflet-control-attribution { background: rgba(20,24,32,0.9) !important; color: var(--text-dim) !important; font-size: 11px !important; }
.leaflet-control-attribution a { color: var(--accent-2) !important; }

/* Custom markers — focusable & with visible focus ring */
.wc-marker {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 3px 12px rgba(0,0,0,0.5);
  font-size: 13px; color: #fff; font-weight: 700;
  cursor: pointer; transition: transform 0.15s;
}
.wc-marker:hover { transform: scale(1.15); }
.wc-marker.m-fifa { background: var(--fifa); }
.wc-marker.m-fanzone { background: var(--fanzone); color: #000; }
.wc-marker.m-community { background: var(--community); color: #000; }
.wc-marker.m-bar { background: var(--bar); }
.wc-marker.m-private { background: var(--private); }
.wc-marker.active-marker { transform: scale(1.3); box-shadow: 0 0 0 4px rgba(255,59,107,0.5), 0 3px 12px rgba(0,0,0,0.5); }
.leaflet-marker-icon:focus-visible { outline: none; }
.leaflet-marker-icon:focus-visible .wc-marker {
  box-shadow: 0 0 0 4px var(--focus), 0 3px 12px rgba(0,0,0,0.5);
}

/* === RESPONSIVE === */
@media (max-width: 880px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
  .legend { font-size: 11px; gap: 8px 14px; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr; height: calc(100vh - 110px); }
  .sidebar {
    position: absolute; bottom: 0; left: 0; right: 0; height: 50%;
    z-index: 1000; border-right: none; border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }
  .map-wrap { height: 100%; }
  .detail-panel { width: 100%; top: 0; max-width: 100vw; }
}

/* Forced colors (Windows High Contrast) */
@media (forced-colors: active) {
  .chip, .venue-card, .dp-btn, .close-btn, .reset {
    border: 1px solid CanvasText;
  }
  .chip[aria-pressed="true"] {
    background: Highlight;
    color: HighlightText;
  }
  :focus-visible { outline: 3px solid Highlight; }
}
