/* Chrome for /map, styled after docs/design/map.html. MapLibre draws into
   #ski-map-host, which lives outside the Blazor render tree (docs/adr/0007) and
   is steered onto #ski-map-slot by ski-map.js. */

#ski-map-host {
  position: fixed;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #eef4fb 0%, #dbe8f5 100%);
}
#ski-map-host.is-hidden { display: none; }

#ski-map-slot { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

/* Drop either half and the chrome swallows every pan and zoom before it reaches
   the canvas underneath. */
.map-chrome, #ski-map-slot, .map-toast, .map-basemap-notice, .map-debug-hud, .map-debug-legend { pointer-events: none; }
.map-loading,
.map-search-bar,
.map-search-results,
.locate-btn,
.filter-fab,
.filter-sheet,
.map-chrome nav { pointer-events: auto; }

.map-loading {
  position: absolute; top: 0; left: 0; right: 0; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(180deg, #eef4fb 0%, #dbe8f5 100%);
}
.map-loading-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(30, 58, 138, 0.15); border-top-color: #1E3A8A;
  animation: map-loading-spin 0.8s linear infinite;
}
.map-loading-text { font-size: 12.5px; font-weight: 700; color: #1E3A8A; text-align: center; padding: 0 24px; }
.map-retry-btn {
  border: none; cursor: pointer; background: #1E3A8A; color: #fff;
  border-radius: 999px; padding: 9px 20px; font-size: 12.5px; font-weight: 700;
}
@keyframes map-loading-spin { to { transform: rotate(360deg); } }

.map-search-bar {
  position: absolute; top: 16px; left: 16px; right: 16px; z-index: 5;
  background: #fff; border-radius: 999px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
}
.map-search-input { border: none; outline: none; flex: 1; font-size: 13.5px; color: #0F172A; background: transparent; min-width: 0; }
.map-search-input::placeholder { color: #94A3B8; }
.map-search-clear { border: none; background: transparent; color: #94A3B8; cursor: pointer; display: flex; padding: 0; }

.map-search-results {
  position: absolute; top: 62px; left: 16px; right: 16px; z-index: 5;
  background: #fff; border-radius: 14px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
  list-style: none; margin: 0; padding: 6px; max-height: 40vh; overflow-y: auto;
}
.map-search-results button {
  display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: transparent;
  text-align: left; padding: 9px 10px; border-radius: 10px; font-size: 13.5px; color: #0F172A; cursor: pointer;
}
.map-search-results button:hover { background: #F1F5F9; }
.map-search-kind {
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em; color: #64748B;
  background: #F1F5F9; border-radius: 999px; padding: 2px 7px; flex-shrink: 0;
}

.locate-btn {
  position: absolute; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom) + 150px); z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.2); display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; color: #1E3A8A;
}
.locate-btn:disabled { opacity: 0.5; cursor: default; }

.map-toast {
  position: absolute; left: 16px; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom) + 70px); z-index: 6;
  background: rgba(15, 23, 42, 0.9); color: #fff; border-radius: 12px; padding: 10px 14px;
  font-size: 12.5px; text-align: center;
}

.map-basemap-notice {
  position: absolute; top: 70px; left: 16px; z-index: 5;
  background: rgba(15, 23, 42, 0.85); color: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: 11.5px; font-weight: 600;
}

/* The compass stays visible, unlike the mockup: it is the only way back from a
   rotated 3D camera. */
#ski-map-host .maplibregl-ctrl-bottom-right { right: 16px; bottom: calc(70px + env(safe-area-inset-bottom) + 16px); }
#ski-map-host .maplibregl-ctrl-group {
  border-radius: 20px; box-shadow: 0 2px 10px rgba(15, 23, 42, 0.2); border: none; overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
}

.filter-fab {
  position: absolute; left: 16px; bottom: calc(70px + env(safe-area-inset-bottom) + 16px); z-index: 2;
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.2); font-size: 12.5px; font-weight: 700; color: #334155;
  border: none; cursor: pointer;
}
.filter-fab:disabled { opacity: 0.5; cursor: default; }

.filter-backdrop {
  position: absolute; top: 0; right: 0; left: 0; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 3;
  background: rgba(15, 23, 42, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.filter-backdrop.is-open { opacity: 1; pointer-events: auto; }

.filter-sheet {
  position: absolute; left: 0; right: 0; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 4;
  background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.25); padding: 10px 20px 20px;
  transform: translateY(calc(100% + 70px + env(safe-area-inset-bottom)));
  transition: transform 0.25s ease; max-height: 60vh; overflow-y: auto;
}
.filter-sheet.is-open { transform: translateY(0); }
.filter-sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: #E2E8F0; margin: 0 auto 14px; }
.filter-sheet-header { display: flex; align-items: center; justify-content: space-between; }
.filter-sheet-title { font-size: 16px; font-weight: 800; color: #0F172A; }
.filter-settings-btn {
  width: 30px; height: 30px; border-radius: 50%; background: #F1F5F9;
  display: flex; align-items: center; justify-content: center; color: #334155; flex-shrink: 0;
}
.field-label { font-size: 11px; font-weight: 700; color: #94A3B8; letter-spacing: 0.03em; margin: 18px 2px 8px; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid #E2E8F0; background: #fff; font-size: 12px; font-weight: 600; line-height: 1.35;
  color: #64748B; cursor: pointer;
}
.chip.is-selected { background: #1E3A8A; border-color: #1E3A8A; color: #fff; }

.chip-piste { border-color: var(--chip-color, #E2E8F0); color: var(--chip-color, #64748B); }
.chip-piste.is-selected { background: var(--chip-color, #1E3A8A); border-color: var(--chip-color, #1E3A8A); color: #fff; }

.chip-lift { padding-left: 8px; }
.chip-icon { display: flex; flex-shrink: 0; }
.chip-icon svg { width: 20px; height: 20px; }

.filter-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px; border-bottom: 1px solid #E2E8F0; }
.filter-toggle-row:last-of-type { border-bottom: none; }
.filter-toggle-label { font-size: 13.5px; font-weight: 600; color: #334155; }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 24px; flex-shrink: 0; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-switch .track { position: absolute; inset: 0; border-radius: 999px; background: #E2E8F0; transition: background 0.15s ease; }
.toggle-switch .track::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3); transition: transform 0.15s ease;
}
.toggle-switch input:checked + .track { background: #1E3A8A; }
.toggle-switch input:checked + .track::before { transform: translateX(16px); }

.filter-apply-btn {
  width: 100%; margin-top: 16px; border: none; cursor: pointer;
  background: #1E3A8A; color: #fff; border-radius: 999px; padding: 13px; font-size: 14px; font-weight: 700;
}

/* ?debug=1 only. */
.map-debug-hud {
  position: absolute; top: 68px; left: 16px; z-index: 5;
  background: rgba(255, 255, 255, 0.92); padding: 10px 14px; border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); font-size: 13px; line-height: 1.5;
  max-width: min(280px, calc(100% - 120px));
}
.map-debug-hud h2 { font-size: 14px; font-weight: 700; margin: 0 0 6px; }
.map-debug-hud span { font-weight: bold; font-size: 20px; }
.map-debug-hud span.good { color: #2e7d32; }
.map-debug-hud span.ok { color: #e6a100; }
.map-debug-hud span.bad { color: #c62828; }

.map-debug-legend {
  position: absolute; left: 16px; bottom: calc(70px + env(safe-area-inset-bottom) + 66px); z-index: 5;
  background: rgba(255, 255, 255, 0.92); padding: 10px 14px; border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); font-size: 12px;
  max-width: min(320px, calc(100% - 32px));
}
.map-debug-legend div { display: flex; align-items: center; margin: 2px 0; }
.map-debug-legend .swatch { display: inline-block; width: 14px; height: 10px; margin-right: 6px; border-radius: 2px; flex-shrink: 0; }
.map-debug-legend .swatch-lift { background: #1a1a1a; }
