:root {
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #181c27;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #e8eaf0;
  --text-dim: #8a90a3;
  --accent-a: #8b5cf6;
  --accent-b: #ec4899;
  --accent-gradient: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

.layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: relative;
  width: 400px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- form ---------- */

#search-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 11px 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.btn-primary {
  margin-top: 4px;
  background: var(--accent-gradient);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 12px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  filter: saturate(0.4) brightness(0.75);
  cursor: wait;
}

/* ---------- saved artists ---------- */

.section-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.saved-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.saved-chip:hover {
  border-color: var(--accent-a);
  background: var(--surface);
}

.saved-chip .chip-name {
  font-weight: 600;
  font-size: 13px;
}

.saved-chip .chip-when {
  color: var(--text-dim);
  font-size: 11px;
}

.saved-chip .chip-delete {
  display: none;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 2px;
  cursor: pointer;
}

.saved-chip:hover .chip-delete {
  display: inline;
}

.saved-chip .chip-delete:hover {
  color: var(--red);
}

/* ---------- status / errors ---------- */

.error-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 10px;
  color: #fca5a5;
  font-size: 13px;
  padding: 11px 13px;
  white-space: pre-line;
}

.status {
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status::before {
  content: "";
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-a);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- artist candidates ---------- */

.candidates {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.candidate-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.candidate-button {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  padding: 11px 13px;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.candidate-button:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.candidate-button:focus-visible {
  outline: none;
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.candidate-name {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.candidate-meta {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}

/* ---------- results ---------- */

.results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.artist-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.artist-avatar {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border-strong);
}

.artist-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.results-summary {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

.external-tour-link {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
}

.external-tour-copy {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.45;
}

.external-tour-cta {
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

.sort-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px;
}

.segmented button {
  border: none;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.15s;
}

.segmented button.active {
  background: var(--accent-gradient);
  color: #fff;
}

/* ---------- filters ---------- */

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-toggle {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.filter-toggle.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
}

.filter-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.filter-slider {
  width: 120px;
  accent-color: var(--accent-a);
  cursor: pointer;
}

.filter-date {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 4px 8px;
  color-scheme: dark;
}

.filter-clear {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent-a);
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
}

.filter-clear:hover {
  text-decoration: underline;
}

/* ---------- cards ---------- */

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.15s;
}

.card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.card.selected {
  border-color: var(--accent-a);
  background: var(--surface);
}

.card.selected::before {
  opacity: 1;
}

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

.card-venue {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}

.badge-distance {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--green);
  white-space: nowrap;
}

.card-city {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.card-tickets,
.popup-tickets {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent-b);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 6px;
  padding: 3px 7px;
  white-space: nowrap;
}

.card-tickets:hover,
.card-tickets:focus-visible,
.popup-tickets:hover,
.popup-tickets:focus-visible {
  color: #fff;
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.55);
}

.card-tickets:focus-visible,
.popup-tickets:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.75);
  outline-offset: 2px;
}

.card-date {
  appearance: none;
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.card-date-text {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-bottom: 1px dotted rgba(232, 236, 245, 0.6);
}

.card-date:hover .card-date-text,
.card-date:focus-visible .card-date-text,
.card-date.open .card-date-text {
  color: #fff;
  border-bottom-color: var(--accent-b);
}

.card-date:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.75);
  outline-offset: 4px;
  border-radius: 4px;
}

.date-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  min-width: max-content;
  max-width: 190px;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: rgba(11, 13, 18, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}

.date-popover::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: var(--border-strong);
}

.card-date:hover .date-popover,
.card-date:focus-visible .date-popover,
.card-date.open .date-popover {
  opacity: 1;
  transform: translateY(0);
}

.chip {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 3px 7px;
}

.chip-soldout {
  color: var(--amber);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.chip-unreachable {
  color: var(--red);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.card-error {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 11px;
  word-break: break-word;
}

/* skeletons */

.card.skeleton {
  pointer-events: none;
  height: 88px;
  background: linear-gradient(
    100deg,
    var(--surface-2) 40%,
    var(--surface) 50%,
    var(--surface-2) 60%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

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

#map {
  flex: 1;
  min-width: 0;
  background: var(--bg);
}

.map-pin {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s;
}

.map-pin.selected {
  transform: scale(1.45);
  border-color: #fff;
}

.legend {
  position: absolute;
  z-index: 1000;
  right: 14px;
  bottom: 26px;
  background: rgba(18, 21, 29, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text);
  backdrop-filter: blur(6px);
}

.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
}

/* ---------- mobile view toggle ---------- */

/* Hidden on desktop; the media query below reveals it once results exist. */
.view-toggle {
  display: none;
  position: fixed;
  z-index: 1100;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(18, 21, 29, 0.94);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.view-toggle button {
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  padding: 9px 26px;
  cursor: pointer;
  transition: color 0.15s;
}

.view-toggle button.active {
  background: var(--accent-gradient);
  color: #fff;
}

/* leaflet dark-theme adjustments */

.leaflet-container {
  font-family: var(--font-body);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.leaflet-popup-content {
  margin: 10px 14px;
  font-size: 13px;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--text-dim);
}

.leaflet-bar a {
  background: var(--surface-2);
  color: var(--text);
  border-bottom-color: var(--border-strong);
}

.leaflet-bar a:hover {
  background: var(--surface);
}

.leaflet-control-attribution {
  background: rgba(11, 13, 18, 0.75);
  color: var(--text-dim);
}

.leaflet-control-attribution a {
  color: var(--text-dim);
}

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

@media (max-width: 900px) {
  html,
  body {
    height: auto;
  }

  /* Sidebar and map each own the full screen; the toggle picks which shows. */
  .layout {
    display: block;
    height: auto;
  }

  .sidebar {
    width: 100%;
    min-height: 100dvh;
    overflow: visible;
    border-right: none;
    padding: 22px 18px calc(104px + env(safe-area-inset-bottom));
  }

  #map {
    position: fixed;
    inset: 0;
    height: 100dvh;
    z-index: 500;
  }

  body[data-view="list"] #map {
    display: none;
  }

  body[data-view="map"] .sidebar {
    display: none;
  }

  /* Reveal the toggle only once there are concerts to look at on the map. */
  body.has-results .view-toggle {
    display: inline-flex;
  }

  /* Lift the legend clear of the floating toggle. */
  .legend {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  /* Let filter controls breathe and grow touch targets. */
  .filter-row {
    gap: 14px;
  }

  .filter-toggles {
    width: 100%;
  }

  .filter-toggle,
  .segmented button {
    padding: 8px 16px;
  }

  .filter-distance-group,
  .filter-date-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .filter-slider {
    flex: 1;
    width: auto;
  }

  .filter-date {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
  }
}
