/* Tryouts interactive map — self-contained (no Vite rebuild required) */

:root {
  --tm-bg: #f1f5f9;
  --tm-surface: rgba(255, 255, 255, 0.92);
  --tm-surface-solid: #ffffff;
  --tm-border: rgba(15, 23, 42, 0.1);
  --tm-text: #0f172a;
  --tm-muted: #64748b;
  --tm-accent: #047857;
  --tm-accent-soft: #d1fae5;
  --tm-gold: #f59e0b;
  --tm-gold-deep: #b45309;
  --tm-blue: #3b82f6;
  --tm-blue-deep: #1e3a8a;
  --tm-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  --tm-radius: 1.1rem;
  --tm-panel-width: min(26rem, 100%);
  --tm-map-height: min(72vh, 760px);
  --tm-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html.tm-dark,
html.tm-dark body,
.tm-dark .tryouts-map-page {
  --tm-bg: #0b1220;
  --tm-surface: rgba(15, 23, 42, 0.92);
  --tm-surface-solid: #0f172a;
  --tm-border: rgba(148, 163, 184, 0.18);
  --tm-text: #e2e8f0;
  --tm-muted: #94a3b8;
  --tm-accent: #34d399;
  --tm-accent-soft: rgba(16, 185, 129, 0.15);
  --tm-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
}

.tryouts-map-page {
  font-family: var(--tm-font);
  color: var(--tm-text);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(16, 185, 129, 0.16), transparent 55%),
    radial-gradient(900px 420px at 95% 0%, rgba(245, 158, 11, 0.14), transparent 50%),
    linear-gradient(180deg, var(--tm-bg), var(--tm-bg));
  min-height: 100%;
  padding-bottom: 5.5rem;
}

.tm-shell {
  max-width: 80rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

@media (min-width: 640px) {
  .tm-shell {
    padding: 1.25rem 1.5rem 2.5rem;
  }
}

/* Hero */
.tm-hero {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--tm-radius) + 0.25rem);
  border: 1px solid var(--tm-border);
  background:
    linear-gradient(135deg, rgba(4, 120, 87, 0.95), rgba(30, 58, 138, 0.88) 55%, rgba(180, 83, 9, 0.75)),
    #065f46;
  color: #fff;
  box-shadow: var(--tm-shadow);
  margin-bottom: 1rem;
}

.tm-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.18), transparent 40%),
    linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.18));
  pointer-events: none;
}

.tm-hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1.35rem;
}

@media (min-width: 768px) {
  .tm-hero-inner {
    grid-template-columns: 1.4fr 1fr;
    align-items: end;
    padding: 1.75rem 1.75rem 1.6rem;
  }
}

.tm-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(236, 253, 245, 0.92);
  margin-bottom: 0.45rem;
}

.tm-hero h1 {
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.15;
  font-weight: 900;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.tm-hero p {
  margin: 0;
  max-width: 40rem;
  color: rgba(236, 253, 245, 0.92);
  font-size: 0.98rem;
  line-height: 1.5;
}

.tm-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.tm-stat {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.9rem;
  padding: 0.7rem 0.75rem;
  backdrop-filter: blur(8px);
}

.tm-stat strong {
  display: block;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.1;
}

.tm-stat span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.88;
}

/* Toolbar */
.tm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.tm-search-wrap {
  position: relative;
  flex: 1 1 16rem;
  min-width: 12rem;
}

.tm-search {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid var(--tm-border);
  background: var(--tm-surface-solid);
  color: var(--tm-text);
  padding: 0.78rem 0.95rem 0.78rem 2.55rem;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  outline: none;
}

.tm-search:focus {
  border-color: rgba(4, 120, 87, 0.55);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.tm-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tm-muted);
  pointer-events: none;
}

.tm-search-results {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  max-height: 18rem;
  overflow: auto;
  border-radius: 0.9rem;
  border: 1px solid var(--tm-border);
  background: var(--tm-surface-solid);
  box-shadow: var(--tm-shadow);
  display: none;
}

.tm-search-results.is-open {
  display: block;
}

.tm-search-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--tm-text);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.tm-search-item:hover,
.tm-search-item:focus {
  background: var(--tm-accent-soft);
  outline: none;
}

.tm-search-item small {
  color: var(--tm-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
}

.tm-btn {
  appearance: none;
  border: 1px solid var(--tm-border);
  background: var(--tm-surface-solid);
  color: var(--tm-text);
  border-radius: 0.9rem;
  padding: 0.72rem 0.95rem;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
  touch-action: manipulation;
}

.tm-btn:hover {
  border-color: rgba(4, 120, 87, 0.45);
}

.tm-btn:active {
  transform: scale(0.98);
}

.tm-btn-primary {
  background: linear-gradient(135deg, #047857, #065f46);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(4, 120, 87, 0.28);
}

.tm-btn-ghost {
  background: transparent;
}

/* Layout */
.tm-layout {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 1024px) {
  .tm-layout {
    grid-template-columns: minmax(0, 1fr) var(--tm-panel-width);
    align-items: start;
  }
}

.tm-map-card {
  position: relative;
  border-radius: var(--tm-radius);
  border: 1px solid var(--tm-border);
  background: var(--tm-surface-solid);
  box-shadow: var(--tm-shadow);
  overflow: hidden;
}

#tryouts-map {
  width: 100%;
  height: var(--tm-map-height);
  min-height: 420px;
  background: #0f172a;
  z-index: 1;
}

.tm-legend {
  position: absolute;
  z-index: 500;
  left: 0.75rem;
  bottom: 0.75rem;
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.85rem;
  border: 1px solid var(--tm-border);
  background: var(--tm-surface);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--tm-text);
  min-width: 9.5rem;
  pointer-events: none;
}

.tm-legend-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tm-muted);
  margin-bottom: 0.1rem;
}

.tm-legend-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tm-swatch {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 0.25rem;
  border: 1.5px solid rgba(15, 23, 42, 0.25);
  flex: 0 0 auto;
}

.tm-swatch-gold {
  background: #f59e0b;
  border-color: #b45309;
  border-width: 2.5px;
}

.tm-swatch-blue {
  background: #3b82f6;
  border-color: #1e3a8a;
}

.tm-swatch-rainbow {
  background: linear-gradient(
    135deg,
    #ef4444 0%,
    #f59e0b 18%,
    #84cc16 36%,
    #06b6d4 54%,
    #3b82f6 72%,
    #a855f7 88%,
    #ec4899 100%
  );
  border-color: rgba(15, 23, 42, 0.35);
}

.tm-swatch-selected {
  background: #34d399;
  border-color: #047857;
  border-width: 2.5px;
}

.tm-swatch-state {
  background: transparent;
  border: 1.5px dashed #64748b;
}

.tm-map-float {
  position: absolute;
  z-index: 500;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 800;
  border: 1px solid var(--tm-border);
  background: var(--tm-surface);
  color: var(--tm-text);
  backdrop-filter: blur(10px);
}

.tm-chip-live {
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--tm-accent);
}

/* Side panel */
.tm-panel {
  border-radius: var(--tm-radius);
  border: 1px solid var(--tm-border);
  background: var(--tm-surface-solid);
  box-shadow: var(--tm-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 22rem;
  max-height: var(--tm-map-height);
}

.tm-panel-head {
  padding: 1rem 1.05rem 0.85rem;
  border-bottom: 1px solid var(--tm-border);
  background:
    linear-gradient(180deg, rgba(16, 185, 129, 0.08), transparent);
}

.tm-panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.tm-panel-head p {
  margin: 0.35rem 0 0;
  color: var(--tm-muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.tm-panel-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.tm-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tm-badge-gold {
  background: rgba(245, 158, 11, 0.18);
  color: var(--tm-gold-deep);
}

.tm-dark .tm-badge-gold {
  color: #fbbf24;
}

.tm-badge-blue {
  background: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
}

.tm-dark .tm-badge-blue {
  color: #93c5fd;
}

.tm-badge-soft {
  background: var(--tm-accent-soft);
  color: var(--tm-accent);
}

.tm-panel-body {
  padding: 0.75rem 1rem 1rem;
  overflow: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.tm-empty {
  text-align: center;
  padding: 1.75rem 0.75rem;
  color: var(--tm-muted);
}

.tm-empty strong {
  display: block;
  color: var(--tm-text);
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.tm-tryout-list {
  display: grid;
  gap: 0.55rem;
}

.tm-tryout-card {
  display: block;
  border-radius: 0.85rem;
  border: 1px solid var(--tm-border);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.06), transparent);
  padding: 0.75rem 0.8rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.tm-tryout-card:hover {
  border-color: rgba(4, 120, 87, 0.45);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.tm-tryout-card h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.3;
}

.tm-tryout-meta {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  color: var(--tm-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.tm-panel-actions {
  display: grid;
  gap: 0.5rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--tm-border);
  background: rgba(148, 163, 184, 0.05);
}

.tm-panel-actions .tm-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

/* Leaflet overrides */
.tryouts-map-page .leaflet-container {
  font: inherit;
  background: #0b1220;
}

.tryouts-map-page .leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  border-radius: 0.55rem !important;
  color: var(--tm-text) !important;
  background: var(--tm-surface-solid) !important;
  border: 1px solid var(--tm-border) !important;
}

.tryouts-map-page .leaflet-control-zoom {
  border: 0 !important;
  box-shadow: var(--tm-shadow) !important;
  border-radius: 0.7rem !important;
  overflow: hidden;
}

.tryouts-map-page .leaflet-control-attribution {
  background: rgba(15, 23, 42, 0.55) !important;
  color: #cbd5e1 !important;
  font-size: 10px !important;
  max-width: 55%;
}

.tryouts-map-page .leaflet-control-attribution a {
  color: #a7f3d0 !important;
}

.tm-tooltip {
  background: var(--tm-surface-solid) !important;
  color: var(--tm-text) !important;
  border: 1px solid var(--tm-border) !important;
  border-radius: 0.55rem !important;
  box-shadow: var(--tm-shadow) !important;
  padding: 0.35rem 0.55rem !important;
  font-weight: 800 !important;
  font-size: 0.78rem !important;
}

.tm-tooltip::before {
  border-top-color: var(--tm-surface-solid) !important;
}

.tm-marker-featured,
.tm-marker-standard {
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.tm-marker-featured {
  background: #f59e0b;
}

.tm-marker-standard {
  background: #3b82f6;
}

/* Loading */
.tm-loading {
  position: absolute;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.35);
  color: #fff;
  font-weight: 800;
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
}

.tm-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.tm-spinner {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: tm-spin 0.7s linear infinite;
  margin: 0 auto 0.55rem;
}

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tm-btn,
  .tm-tryout-card,
  .tm-loading,
  .tm-spinner {
    transition: none !important;
    animation: none !important;
  }
}

/* Mobile bottom safe area for PWA */
@supports (padding: max(0px)) {
  .tryouts-map-page {
    padding-bottom: max(5.5rem, env(safe-area-inset-bottom));
  }
}
