:root {
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --bg: #eef0f2; /* matches the day map (src/mapstyle.js) while it loads */
  --fg: #1c1b1a;
  --muted: #5d5a57;
  --panel: rgba(255, 255, 255, 0.96);
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --gap: 12px;
  color-scheme: light dark;
}

/* Dark: when the system says so (unless the page's button picked light), or when the button picked dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --accent: #ff7a33;
    --accent-ink: #1a0d05;
    --bg: #1b2330; /* matches the night map (src/mapstyle.js) while it loads */
    --fg: #f1f0ee;
    --muted: #b0aca7;
    --panel: rgba(30, 30, 32, 0.95);
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme='dark'] {
  --accent: #ff7a33;
  --accent-ink: #1a0d05;
  --bg: #1b2330; /* matches the night map (src/mapstyle.js) while it loads */
  --fg: #f1f0ee;
  --muted: #b0aca7;
  --panel: rgba(30, 30, 32, 0.95);
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

:root[data-theme='light'] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}

#map {
  position: fixed;
  inset: 0;
}

/* ---------- top bar: search + locate ---------- */

.topbar {
  position: fixed;
  z-index: 3;
  top: calc(env(safe-area-inset-top) + var(--gap));
  left: calc(env(safe-area-inset-left) + var(--gap));
  right: calc(env(safe-area-inset-right) + var(--gap));
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.search,
.locate,
.theme-btn,
.results,
.card,
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.search {
  display: flex;
  align-items: center;
  border-radius: 14px;
  min-width: 0;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 16px; /* >=16px stops iOS zooming on focus */
  padding: 12px 4px 12px 14px;
}

.search input::placeholder {
  color: var(--muted);
}

.search:focus-within {
  border-color: var(--accent);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
  border-radius: 12px;
}

.locate {
  border-radius: 14px;
  width: 48px;
  height: 48px;
}

.theme-btn {
  border-radius: 14px;
  width: 48px;
  height: 48px;
}

/* the button shows where it takes you: a moon in light mode, a sun in dark */
.theme-btn .sun,
.theme-btn[data-showing='dark'] .moon {
  display: none;
}

.theme-btn[data-showing='dark'] .sun {
  display: block;
}

.locate .dot {
  fill: var(--accent);
  stroke: none;
}

.locate[aria-busy='true'] svg {
  animation: pulse 1s ease-in-out infinite;
}

.search[aria-busy='true'] button svg {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.results {
  grid-column: 1 / -1;
  list-style: none;
  margin: 0;
  padding: 6px;
  border-radius: 14px;
  max-height: 45vh;
  overflow: auto;
}

.results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.results button:hover,
.results button:focus-visible {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  outline: none;
}

.results .empty {
  padding: 10px 12px;
  color: var(--muted);
}

/* ---------- neighborhood card ---------- */

.card {
  position: fixed;
  z-index: 2;
  left: calc(env(safe-area-inset-left) + var(--gap));
  right: calc(env(safe-area-inset-right) + var(--gap));
  bottom: calc(env(safe-area-inset-bottom) + var(--gap));
  border-radius: var(--radius);
  padding: 14px 18px 12px;
}

/* On phones the map's own attribution would hide under the card, so the
   card carries the credits instead (desktop uses the map control). */
.credits {
  margin: 12px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.credits a {
  color: inherit;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.tag {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  vertical-align: 1px;
}

.why {
  flex: none;
  width: 32px;
  height: 32px;
  margin: -6px -8px 0 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.card-buttons {
  display: flex;
  gap: 6px;
  margin: -6px -8px 0 0;
}

.card-buttons .why {
  margin: 0;
}

.card-close {
  display: grid;
  place-items: center;
  padding: 0;
}

.card-close[hidden] {
  display: none;
}

.card-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.card[hidden] {
  display: none;
}

.why:hover,
.why:focus-visible {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  outline: none;
}

.via {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- "why this name?" dialog ---------- */

.about {
  width: min(460px, calc(100vw - 24px));
  max-height: min(86vh, 760px);
  margin: auto;
  padding: 18px 20px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  color: var(--fg);
  box-shadow: var(--shadow);
  overflow: auto;
  overscroll-behavior: contain;
}

.about::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.about-close {
  position: sticky;
  top: 0;
  float: right;
  margin: -10px -12px 0 0;
}

.about h2 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.about h3,
.about legend {
  margin: 18px 0 8px;
  padding: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.about legend .hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.about-why p {
  margin: 0 0 6px;
  font-size: 15px;
}

.small {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.links {
  margin-top: 12px;
}

.links a {
  color: var(--fg);
}

.sources {
  margin: 0;
  padding: 0;
  border: 0;
}

.src {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 2px 10px;
  align-items: baseline;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.src + .src {
  margin-top: 6px;
}

.src:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.src input {
  margin: 0;
  accent-color: var(--accent);
  align-self: center;
}

.src-name {
  font-weight: 650;
  font-size: 14.5px;
}

.src-says {
  justify-self: end;
  text-align: right;
  font-size: 14.5px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.src-says small {
  display: block;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.src-says.pending {
  color: var(--muted);
  font-weight: 500;
}

.src-blurb {
  grid-column: 2 / -1;
  font-size: 12.5px;
  color: var(--muted);
}

.levels {
  margin: 0;
  padding: 0;
  list-style: none;
}

.levels li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}

.levels .lvl {
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.levels .skip {
  color: var(--muted);
  text-decoration: line-through;
}

.levels .why-note {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

@media (max-width: 719px) {
  .about {
    margin: auto 0 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

#hood {
  margin: 0;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.1;
  font-weight: 760;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.card[data-state='loading'] #hood,
.card[data-state='locating'] #hood {
  color: var(--muted);
}

.broader,
.where,
.note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.broader {
  color: var(--fg);
  font-weight: 560;
}

.note {
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.chip.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}

.chip:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.toast {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 76px);
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
}

/* ---------- neighborhood map switcher (shown near Austin) ---------- */

.hoodbar {
  position: fixed;
  z-index: 2;
  top: calc(env(safe-area-inset-top) + var(--gap) + 48px + 8px);
  left: calc(env(safe-area-inset-left) + var(--gap));
  right: calc(env(safe-area-inset-right) + var(--gap));
  padding: 8px 10px 7px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.hoodbar[hidden] {
  display: none;
}

.hoodbar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.hoodbar-head .hoodbar-title {
  margin: 0;
}

.hoodbar-fold {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: -4px -4px -4px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.hoodbar-fold:hover,
.hoodbar-fold:focus-visible {
  color: var(--fg);
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  outline: none;
}

.hoodbar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* folded: just a small pill in the corner */
.hoodbar-pill {
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hoodbar-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hoodbar[data-folded] {
  left: auto;
  width: auto;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.hoodbar[data-folded] .hoodbar-pill {
  display: inline-flex;
}

.hoodbar[data-folded] .hoodbar-panel {
  display: none;
}

.hoodbar-title {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.hoodbar-title span {
  color: var(--muted);
  font-weight: 500;
}

.hoodbar-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hoodbar-modes button {
  appearance: none;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hoodbar-modes button[aria-pressed='true'] {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.hoodbar-modes button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hoodbar-status {
  margin: 6px 2px 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}

.hoodbar-modes .short {
  display: none;
}

@media (max-width: 719px) {
  /* phones: one compact row, so the map keeps the room */
  .hoodbar {
    padding: 6px 8px;
  }

  .hoodbar-head {
    margin-bottom: 4px;
  }

  .hoodbar-title {
    font-size: 11.5px;
  }

  .hoodbar-modes {
    flex-wrap: nowrap;
  }

  .hoodbar-modes button {
    flex: 1;
    min-height: 28px;
    padding: 0 4px;
    font-size: 12.5px;
  }

  .hoodbar-modes .long,
  .hoodbar-status {
    display: none;
  }

  .hoodbar-modes .short {
    display: inline;
  }
}

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

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib {
  font-size: 11px;
}

@media (max-width: 719px) {
  /* pinch to zoom on phones; the +/- buttons and attribution would hide behind the card */
  .maplibregl-ctrl-group,
  .maplibregl-ctrl-attrib {
    display: none;
  }
}

/* ---------- wider screens: side panel ---------- */

@media (min-width: 720px) {
  .topbar {
    right: auto;
    width: 400px;
  }

  .card {
    right: auto;
    bottom: auto;
    top: calc(env(safe-area-inset-top) + var(--gap) + 48px + 10px);
    width: 400px;
    padding-bottom: 16px;
  }

  .credits {
    display: none;
  }

  .hoodbar {
    left: auto;
    top: calc(env(safe-area-inset-top) + var(--gap));
    width: 300px;
  }

  .results {
    position: relative;
    z-index: 4;
  }
}

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