/* Ported from src/css/style.css — "Submersible Intelligence" design system */
/* ── Leaflet base (imported here so Embroider bundles it) ─────────────────── */

/* ── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  /* Surface layers — tonal descent through the water column */
  --surface: #02161d;
  --surface-dim: #02161d;
  --surface-container-lowest: #011219;
  --surface-container-low: #071f2a;
  --surface-container: #0d2a38;
  --surface-container-high: #122f3f;
  --surface-container-highest: #1a3a4c;
  --surface-bright: #1f4558;
  --surface-tint: #00daf3;

  /* Palette */
  --primary: #00daf3;
  --primary-container: #00606c;
  --secondary: #abcaea;
  --tertiary: #76db8f;

  /* Text */
  --on-surface: #e1f0f5;
  --on-surface-variant: #bfc8cc;

  /* Outline */
  --outline: #899296;
  --outline-variant: #3f484c;

  /* Typography */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Spacing */
  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --spacing-5: 1.1rem;
  --spacing-6: 1.5rem;
  --spacing-8: 2rem;
  --spacing-10: 2.5rem;
  --spacing-12: 3rem;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--surface);
  color: var(--on-surface);
}

/* ── Map canvas ──────────────────────────────────────────────────────────── */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#map.map-hidden {
  visibility: hidden;
}

/* ── Globe canvas ────────────────────────────────────────────────────────── */
#globe {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ── Glassmorphism helper ─────────────────────────────────────────────────── */
.glass-panel {
  background: rgb(13 42 56 / 60%);
  backdrop-filter: blur(16px);
  border-radius: 10px;
}

/* ── Info panel wrapper — positions panel + popup as a flex row ──────────── */
#info-panel-wrapper {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1001;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

/* ── Info panel ──────────────────────────────────────────────────────────── */
#info-panel {
  position: relative;
  pointer-events: auto;

  /* Width adapts so the whale-list rows (checkbox + dot + label + date range)
     don't overflow. clamp(min, ideal, max) — min keeps things tight on
     narrow viewports, max prevents the panel from dominating wide screens. */
  width: clamp(260px, 22vw, 310px);
  min-width: 40px;
  max-width: calc(50vw - 14px);
  padding: var(--spacing-4) var(--spacing-5);
  background: rgb(13 42 56 / 60%);
  backdrop-filter: blur(16px);
  border-radius: 10px;
  min-height: 44px;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  overflow-y: auto;
  resize: both;
  transition:
    width 0.25s ease,
    padding 0.25s ease;
}

/* Resize handle affordance — corner bracket in bottom-right */
#info-panel:not(.collapsed)::after {
  content: '';
  position: absolute;
  bottom: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--outline);
  border-bottom: 2px solid var(--outline);
  border-radius: 0 0 2px;
  pointer-events: none;
  opacity: 0.5;
}

#info-panel.collapsed {
  width: 40px;
  padding: 8px;
  resize: none;
}

#info-panel h2 {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
  letter-spacing: -0.01em;
  padding-right: 32px;
}

/* ── View mode toggle (Map / Globe) ──────────────────────────────────────── */
#view-mode-toggle,
#basemap-toggle {
  display: flex;
  gap: 0;
  margin-bottom: var(--spacing-4);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--outline-variant);
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 5px 0;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.mode-btn:not(:last-child) {
  border-right: 1px solid var(--outline-variant);
}

.mode-btn:hover:not(:disabled) {
  background: rgb(137 146 150 / 12%);
  color: var(--on-surface);
}

.mode-btn.active {
  background: rgb(0 218 243 / 12%);
  color: var(--primary);
  cursor: default;
}

#info-subtitle {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-5);
  padding-right: 32px;
}

/* ── Layer controls ──────────────────────────────────────────────────────── */
#layer-controls {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

#layer-controls fieldset {
  border: none;
  background: rgb(18 47 63 / 70%);
  border-radius: 6px;
  padding: var(--spacing-3) var(--spacing-4);
}

#layer-controls legend {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0;
  margin-bottom: var(--spacing-2);
}

#layer-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  transition: color 0.15s ease;
}

#layer-controls label:hover {
  color: var(--on-surface);
}

#layer-controls input[type='checkbox'] {
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Layer items with opacity controls ──────────────────────────────────────── */
.layer-item {
  margin-bottom: 8px;
}

.opacity-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 4px;
  margin-left: 24px;
  padding: 4px 0;
}

.opacity-control input[type='range'] {
  flex: 1 1 auto;
  min-width: 80px;
  height: 4px;
  border-radius: 2px;
  background: rgb(137 146 150 / 20%);
  outline: none;
  accent-color: var(--primary);
  cursor: pointer;
}

.opacity-control input[type='range']::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

.opacity-control input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

.opacity-value {
  font-size: 0.7rem;
  color: var(--on-surface-variant);
  min-width: 2.5em;
  text-align: right;
  flex-shrink: 0;
}

/* ── Track group (collapsible whale list) ────────────────────────────────── */
.track-group-header {
  display: flex;
  align-items: center;
  padding: 3px 0;
}

/* stylelint-disable-next-line no-descending-specificity */
.track-group-header label {
  flex: 1;
  min-width: 0;
}

.track-group-toggle {
  flex-shrink: 0;
  background: rgb(137 146 150 / 12%);
  border: none;
  color: var(--on-surface-variant);
  font-size: 0.5rem;
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition:
    transform 0.2s ease,
    color 0.15s ease,
    background 0.15s ease;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.track-group-toggle:hover {
  color: var(--on-surface);
  background: rgb(137 146 150 / 25%);
}

.track-group-toggle[aria-expanded='true'] {
  transform: rotate(180deg);
}

.track-sublist {
  /* Indent shrunk from 22px → 8px so the long whale row (checkbox + dot
     + "Whale 00840" + date range) fits within the panel without truncation. */
  padding: 4px 0 0 8px;
  flex-direction: column;
  gap: 1px;
}

.track-sublist:not([hidden]) {
  display: flex;
}

/* stylelint-disable-next-line no-descending-specificity */
.track-sublist label {
  display: flex;
  align-items: center;
  font-size: 0.6875rem;
  gap: 5px;
  min-width: 0;
}

.track-sublist .whale-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.track-sublist .whale-label {
  /* Truncate gracefully if a label is unexpectedly long. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-sublist .whale-date-range {
  font-size: 0.5625rem;
  color: var(--outline);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Whale list row (label + stats button) ──────────────────────────────── */
.whale-list-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* stylelint-disable-next-line no-descending-specificity */
.whale-list-row label {
  flex: 1;
  min-width: 0;
}

.whale-stats-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--outline);
  border-radius: 3px;
  color: var(--outline);
  cursor: pointer;
  font-size: 0.6rem;
  line-height: 1;
  padding: 1px 3px;
}

.whale-stats-btn:hover,
.whale-stats-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Whale stats panel ──────────────────────────────────────────────────── */
.whale-stats-panel {
  padding: 4px 4px 4px 16px;
}

.whale-stats-table {
  border-collapse: collapse;
  font-size: 0.6rem;
  width: 100%;
}

.whale-stats-table th {
  color: var(--outline);
  font-weight: normal;
  padding: 1px 6px 1px 0;
  text-align: left;
  white-space: nowrap;
}

.whale-stats-table td {
  color: var(--on-surface);
  padding: 1px 0;
}

/* ── Layer label row (checkbox label + info button) ─────────────────────── */
.layer-label-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* stylelint-disable-next-line no-descending-specificity */
.layer-label-row label {
  flex: 1;
  min-width: 0;
}

/* ── Info button (ⓘ) ─────────────────────────────────────────────────────── */
.layer-info-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--outline);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 3px;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}

.layer-info-btn:hover {
  color: var(--primary);
  background: rgb(0 218 243 / 10%);
}

.layer-info-btn.active {
  color: var(--primary);
  background: rgb(0 218 243 / 15%);
}

/* ── Sightings dataset rows ──────────────────────────────────────────────── */
.sighting-row {
  display: flex;
  align-items: center;
  padding: 3px 0;
}

/* stylelint-disable-next-line no-descending-specificity */
.sighting-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  transition: color 0.15s ease;
}

/* stylelint-disable-next-line no-descending-specificity */
.sighting-row label:hover {
  color: var(--on-surface);
}

.sighting-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgb(255 255 255 / 40%);
}

.sighting-dot-na,
.legend-dot-sightings-na {
  background: #f4a261;
}

.sighting-dot-np,
.legend-dot-sightings-np {
  background: #e76f51;
}

.sighting-count {
  font-size: 0.625rem;
  color: var(--outline);
  margin-left: auto;
  padding-right: 4px;
}

/* ── Info popup (flex sibling of panel, appears to its right) ────────────── */
#info-popup {
  position: relative;
  pointer-events: auto;
  width: 240px;
  padding: var(--spacing-4);
  background: rgb(13 42 56 / 88%);
  backdrop-filter: blur(16px);
  border: 1px solid var(--outline-variant);
  border-radius: 10px;
  animation: info-popup-in 0.15s ease;
}

@keyframes info-popup-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.info-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.15s ease;
}

.info-popup-close:hover {
  color: var(--on-surface);
}

.info-popup-title {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--spacing-3);
  padding-right: 20px;
  line-height: 1.3;
}

.info-popup-section-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
  margin-top: var(--spacing-3);
  margin-bottom: 4px;
}

.info-popup-body {
  font-size: 0.6875rem;
  color: var(--on-surface-variant);
  line-height: 1.5;
}

/* ── Active date ─────────────────────────────────────────────────────────── */
#active-date {
  margin-top: var(--spacing-4);
  font-size: 0.6875rem;
  color: var(--on-surface-variant);
  text-align: center;
}

#current-date-label {
  font-family: var(--font-display);
  color: var(--primary);
  font-weight: 600;
}

/* ── Legend (bottom-left, above TimeDimension control) ───────────────────── */
#legend {
  position: absolute;
  bottom: 20px;
  left: 14px;
  z-index: 1000;
  background: rgb(13 42 56 / 60%);
  backdrop-filter: blur(16px);
  border-radius: 8px;
  padding: var(--spacing-3) var(--spacing-4);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  padding: 2px 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Time control panel (bottom-centre, Ember component) ─────────────────── */
.time-control-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: calc(100vw - 28px); /* prevent overflow on narrow screens */
}

.leaflet-bar-timecontrol {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgb(13 42 56 / 60%);
  backdrop-filter: blur(16px);
  border-radius: 12px;
  color: var(--on-surface);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgb(63 72 76 / 15%),
    0 12px 40px -4px rgb(0 218 243 / 8%);
}

.leaflet-bar-timecontrol .leaflet-control-timecontrol {
  background: transparent;
  border: none;
  border-right: 1px solid rgb(63 72 76 / 20%);
  color: var(--secondary);
  cursor: pointer;
  padding: 0 14px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
}

.leaflet-bar-timecontrol .leaflet-control-timecontrol:last-child {
  border-right: none;
}

.leaflet-bar-timecontrol .leaflet-control-timecontrol:hover {
  background: rgb(137 146 150 / 12%);
  color: var(--on-surface);
}

.leaflet-bar-timecontrol .timecontrol-play {
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  color: var(--surface);
  width: 36px;
}

.leaflet-bar-timecontrol .timecontrol-play:hover {
  opacity: 0.88;
  color: var(--surface);
}

.leaflet-bar-timecontrol .timecontrol-date {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02rem;
  min-width: 130px;
  text-align: center;
}

.leaflet-bar-timecontrol .timecontrol-slider {
  padding: 0 12px;
  min-width: 200px;
}

.leaflet-bar-timecontrol .timecontrol-slider input[type='range'] {
  width: 100%;
  accent-color: var(--primary);
  background: transparent;
  cursor: pointer;
  height: 4px;
}

.leaflet-bar-timecontrol .timecontrol-speed {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
}

.leaflet-bar-timecontrol .timecontrol-speed .speed-label {
  font-size: 0.6875rem;
  color: var(--on-surface-variant);
  min-width: 22px;
  text-align: right;
  white-space: nowrap;
}

.leaflet-bar-timecontrol .timecontrol-speed .speed-range {
  width: 70px;
  accent-color: var(--primary);
  background: transparent;
  cursor: pointer;
  height: 4px;
}

/* ── Attribution control override ──────────────────────────────────────── */
.leaflet-control-attribution {
  background: rgb(13 42 56 / 55%) !important;
  backdrop-filter: blur(8px) !important;
  color: var(--on-surface-variant) !important;
  font-size: 0.5625rem !important;
  border-radius: 6px 0 0 !important;
  padding: 2px 6px !important;
  border: none !important;
  box-shadow: none !important;
}

.leaflet-control-attribution a {
  color: var(--secondary) !important;
}

.leaflet-control-attribution a:hover {
  color: var(--primary) !important;
}

/* ── Zoom control override ───────────────────────────────────────────────── */
.leaflet-control-zoom {
  background: rgb(13 42 56 / 60%) !important;
  backdrop-filter: blur(16px) !important;
  border: none !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgb(63 72 76 / 15%),
    0 12px 40px -4px rgb(0 218 243 / 8%) !important;
}

/* stylelint-disable-next-line no-descending-specificity */
.leaflet-control-zoom a {
  background: transparent !important;
  border-bottom-color: rgb(63 72 76 / 20%) !important;
  color: var(--secondary) !important;
  font-family: var(--font-display) !important;
  font-weight: 500 !important;
  transition:
    background 0.15s ease,
    color 0.15s ease !important;
}

.leaflet-control-zoom a:hover {
  background: rgb(137 146 150 / 12%) !important;
  color: var(--on-surface) !important;
}

.leaflet-control-zoom a:first-child {
  border-radius: 12px 12px 0 0 !important;
}

.leaflet-control-zoom a:last-child {
  border-radius: 0 0 12px 12px !important;
  border-bottom: none !important;
}

/* ── Popups (Leaflet + MapLibre globe mode) ──────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: rgb(1 12 18 / 97%) !important;
  backdrop-filter: blur(16px) !important;
  color: var(--on-surface) !important;
  border-radius: 10px !important;
  border: 1px solid var(--outline-variant) !important;
  box-shadow:
    0 0 0 1px rgb(0 218 243 / 10%),
    0 12px 40px -4px rgb(0 0 0 / 70%) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: var(--spacing-4) !important;

  /* give the × button room on the right */
  padding-right: var(--spacing-4) !important;
}

.leaflet-popup-close-button {
  position: absolute !important;
  color: var(--on-surface-variant) !important;
  font-size: 1rem !important;
  line-height: 20px !important;
  text-align: center !important;
  top: 8px !important;
  right: 8px !important;
  width: 20px !important;
  height: 20px !important;
  border-radius: 4px !important;
  transition:
    color 0.15s ease,
    background 0.15s ease !important;
}

.leaflet-popup-close-button:hover {
  color: var(--on-surface) !important;
  background: rgb(137 146 150 / 15%) !important;
}

.leaflet-popup-tip-container {
  /* keep tip color in sync */
}

.leaflet-popup-tip {
  background: rgb(1 12 18 / 97%) !important;
}

.whale-popup h3 {
  font-family: var(--font-display);
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: var(--spacing-3);
  padding-right: var(--spacing-4);
}

.whale-popup p {
  font-size: 0.75rem;
  color: var(--secondary);
  margin: 3px 0;
  line-height: 1.4;
}

.whale-popup p strong {
  color: var(--on-surface);
  font-weight: 600;
}

.whale-popup hr {
  border: none;
  border-top: 1px solid var(--outline-variant);
  margin: var(--spacing-3) 0;
}

/* ── Sanctuary popups ────────────────────────────────────────────────────── */
.sanctuary-popup h3 {
  font-family: var(--font-display);
  color: #1a8faa;
  font-size: 0.8125rem;
  margin: 0 0 var(--spacing-2) 0;
  padding-right: var(--spacing-4);
}

.sanctuary-popup p {
  font-size: 0.75rem;
  color: var(--secondary);
  margin: 3px 0;
  line-height: 1.4;
}

.sanctuary-popup p strong {
  color: var(--on-surface);
  font-weight: 600;
}

.sanctuary-popup .sanctuary-desc {
  color: var(--on-surface-variant);
  margin-top: var(--spacing-2);
  font-style: italic;
}

/* ── MapLibre popups (globe mode) ────────────────────────────────────────── */
.maplibregl-popup-content {
  background: rgb(1 12 18 / 97%) !important;
  backdrop-filter: blur(16px) !important;
  color: var(--on-surface) !important;
  border-radius: 10px !important;
  border: 1px solid var(--outline-variant) !important;
  box-shadow:
    0 0 0 1px rgb(0 218 243 / 10%),
    0 12px 40px -4px rgb(0 0 0 / 70%) !important;
  padding: var(--spacing-4) !important;
  padding-right: calc(var(--spacing-4) + 20px) !important;
  font-family: var(--font-body) !important;
}

.maplibregl-popup-close-button {
  color: var(--on-surface-variant) !important;
  font-size: 1.125rem !important;
  line-height: 1 !important;
  top: 8px !important;
  right: 8px !important;
  width: 20px !important;
  height: 20px !important;
  border-radius: 4px !important;
  transition:
    color 0.15s ease,
    background 0.15s ease !important;
}

.maplibregl-popup-close-button:hover {
  color: var(--on-surface) !important;
  background: rgb(137 146 150 / 15%) !important;
}

.maplibregl-popup-tip {
  border-top-color: rgb(1 12 18 / 97%) !important;
  border-bottom-color: rgb(1 12 18 / 97%) !important;
}

/* ── Primary CTA button ──────────────────────────────────────────────────── */
.btn-primary {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  color: var(--surface-dim);
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.88;
}

/* ── Secondary (ghost) button ────────────────────────────────────────────── */
.btn-secondary {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  background: transparent;
  color: var(--on-surface);
  box-shadow: 0 0 0 1px rgb(137 146 150 / 20%);
  border: none;
  transition: box-shadow 0.15s ease;
}

.btn-secondary:hover {
  box-shadow: 0 0 0 1px rgb(137 146 150 / 40%);
}

/* ── Info panel collapse button ─────────────────────────────────────────── */
.panel-collapse-btn {
  position: absolute;
  top: 10px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgb(137 146 150 / 12%);
  border: none;
  color: var(--on-surface-variant);
  font-size: 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  z-index: 1;
  flex-shrink: 0;
}

.panel-collapse-btn:hover {
  background: rgb(137 146 150 / 25%);
  color: var(--on-surface);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

/*
 * Breakpoints (add more as the UI grows):
 *   sm: ≤640px  — mobile / portrait tablet
 *   md: ≤1024px — landscape tablet / small laptop
 *
 * Approach: the info panel collapse button lets users reclaim map space on
 * any screen. The time-control bar is made fluid so it never overflows.
 */

@media (width <= 640px) {
  /* Pin the time bar edge-to-edge instead of centring */
  .time-control-bar {
    left: 14px;
    right: 14px;
    bottom: 10px;
    transform: none;
    max-width: none;
  }

  .leaflet-bar-timecontrol {
    width: 100%;
  }

  /* Let the slider absorb available space */
  .leaflet-bar-timecontrol .timecontrol-slider {
    flex: 1;
    min-width: 0;
    padding: 0 8px;
  }

  /* Shrink the date display slightly */
  .leaflet-bar-timecontrol .timecontrol-date {
    min-width: 90px;
    font-size: 0.75rem;
    padding: 0 6px;
  }

  /* Lift legend above the full-width time bar (10px bottom + 36px height + 10px gap) */
  #legend {
    bottom: 56px;
  }
}

/* ── Map loading overlay ─────────────────────────────────────────────────── */

.map-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgb(2 22 29 / 92%);
  gap: var(--spacing-4);
  pointer-events: none;
}

.loading-ring {
  width: 52px;
  height: 52px;
  border: 4px solid var(--outline-variant);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  box-shadow: 0 0 16px rgb(0 218 243 / 20%);
}

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

.layer-loading-spinner {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  vertical-align: middle;
}

.layer-loading-ring {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--outline-variant);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loading-label {
  font-size: 0.8125rem;
  color: var(--on-surface-variant);
  letter-spacing: 0.06em;
}

/* ── Vessel Traffic (GFW) Layer Controls ────────────────────────────────── */

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.layer-note {
  font-size: 0.7rem;
  color: var(--on-surface-variant);
  margin-top: 2px;
  padding-left: var(--spacing-2);
  opacity: 0.8;
}

/* ── Season selector (SOFAR layer) ──────────────────────────────────────── */

.season-control {
  margin-top: 4px;
  margin-left: 24px;
}

.season-control select {
  width: 100%;
  max-width: 180px;
  padding: 3px 6px;
  font-size: 0.75rem;
  background: var(--surface-variant);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  border-radius: 4px;
  cursor: pointer;
  outline: none;
}

.season-control select:focus {
  border-color: var(--primary);
}

/* ── Legend: SOFAR depth band colour swatch ──────────────────────────────── */

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── Legend: line swatch (bathymetry contours) ───────────────────────────── */

.legend-line {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 1px;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  opacity: 0.9;
}

/* ── Legend: Ship entries ────────────────────────────────────────────────── */

.legend-separator {
  height: 1px;
  background: var(--outline-variant);
  margin: var(--spacing-2) 0;
}

.legend-heading {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-2);
}

.legend-gradient-item {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.legend-gradient {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    rgb(0 160 240 / 15%),
    rgb(0 160 240 / 100%)
  );
}

.legend-gradient-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--on-surface-variant);
}

.legend-note {
  font-size: 0.65rem;
  color: var(--on-surface-variant);
  opacity: 0.7;
  padding-top: 2px;
}

/* Ship popup styling */
.ship-popup h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.ship-popup p {
  margin: 2px 0;
  font-size: 0.82rem;
}

/* ── Skeleton loading states ────────────────────────────────────────────── */

.skeleton-bar {
  height: 0.85rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--surface-container-high) 25%,
    var(--surface-bright) 50%,
    var(--surface-container-high) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  margin: 6px 0;
}

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

  100% {
    background-position: -200% 0;
  }
}

.timecontrol-skeleton {
  display: flex;
  align-items: center;
  gap: var(--spacing-3, 8px);
  padding: 0 var(--spacing-2, 4px);
  opacity: 0.7;
}

.timecontrol-loading-label {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.timecontrol-skeleton .timecontrol-slider {
  flex: 1;
}

.whale-list--loading .skeleton-bar {
  margin: 8px var(--spacing-2, 4px);
}

/* ── Responsive (continued) ─────────────────────────────────────────────── */

@media (width <= 640px) {
  /* Tighter height cap on small screens.
     svh = "small viewport height" — worst-case with browser chrome fully visible.
     dvh = dynamic (tracks chrome show/hide). vh fallback for older browsers. */
  #info-panel {
    /* Never overflow the viewport on phones — 28px = top/left offset (14) × 2. */
    width: min(310px, calc(100vw - 28px));
    max-height: calc(100vh - 250px);
    max-height: calc(100svh - 250px);
    max-height: calc(100dvh - 250px);
    resize: none;
  }
}
