/* Kithira Sound Map - styles */

/* ── Design tokens ─────────────────────────── */

:root {
  --ksm-bg:         #0c1f2e;
  --ksm-sea:        #2d6b8f;
  --ksm-stone:      #ede0c4;
  --ksm-ochre:      #d49a3a;
  --ksm-text:       #f4f0e6;
  --ksm-panel-bg:   #142a3d;
  --ksm-divider:    rgba(237, 224, 196, 0.15);
  --ksm-text-muted: rgba(244, 240, 230, 0.65);

  /* Tag colours - must mirror TAG_COLORS in js/map.js */
  --tag-sea:       #4ea8d8;
  --tag-water:     #7dd3c0;
  --tag-ambience:  #a8c060;
  --tag-wind:      #c8b870;
  --tag-birdsong:  #e07050;
  --tag-invisible: transparent;
}

/* ── Reset + base ──────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ksm-text);
  background: var(--ksm-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────── */

#ksm-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  pointer-events: none;
  z-index: 1000;
}

#ksm-header > * { pointer-events: auto; }

#ksm-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  background: rgba(12, 31, 46, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ksm-divider);
  border-radius: 2px;
  color: var(--ksm-stone);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  font: inherit;
}

#ksm-logo svg { display: block; width: 24px; height: 24px; }

#ksm-logo .ksm-logo-text {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ksm-text);
  white-space: nowrap;
}

#ksm-logo:hover {
  color: var(--ksm-ochre);
  border-color: var(--ksm-ochre);
}

#ksm-logo:focus-visible {
  outline: 2px solid var(--ksm-ochre);
  outline-offset: 2px;
}

#ksm-logo:active { transform: scale(0.97); }

/* Wander chip on the right of the floating header */
.ksm-toggle--chip {
  margin-left: auto;
  background: rgba(12, 31, 46, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ksm-divider);
  border-radius: 2px;
  padding: 6px 12px;
}

@media (max-width: 480px) {
  #ksm-logo .ksm-logo-text { display: none; }
}

/* ── Header info button ────────────────────── */

.ksm-info-btn {
  background: rgba(12, 31, 46, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ksm-divider);
  border-radius: 2px;
  color: var(--ksm-stone);
  cursor: pointer;
  width: 32px;
  height: 32px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.ksm-info-btn:hover {
  color: var(--ksm-ochre);
  border-color: var(--ksm-ochre);
}

.ksm-info-btn:focus-visible {
  outline: 2px solid var(--ksm-ochre);
  outline-offset: 2px;
}

/* ── Main layout ───────────────────────────── */

#ksm-main {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

#ksm-map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

/* ── Status message ────────────────────────── */

.ksm-status {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: rgba(12, 31, 46, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ksm-divider);
  border-radius: 2px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ksm-text-muted);
  white-space: nowrap;
  z-index: 999;
  pointer-events: none;
  text-align: center;
}

.ksm-status.is-loading {
  color: var(--ksm-ochre);
  animation: ksm-pulse 1.6s ease-in-out infinite;
}

.ksm-status.is-error {
  color: #e05050;
}

.ksm-status.is-hidden {
  display: none;
}

@keyframes ksm-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1;   }
}

@media (max-width: 480px) {
  .ksm-status {
    white-space: normal;
    max-width: calc(100vw - 24px);
    font-size: 11px;
  }
}

/* ── Feed overlay ──────────────────────────── */

.ksm-feed {
  position: fixed;
  left: 16px;
  bottom: 24px;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 200px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(12, 31, 46, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--ksm-divider);
  border-radius: 2px;
  z-index: 998;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ksm-feed.is-visible { opacity: 1; }

/* ── Wander toggle ─────────────────────────── */

.ksm-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--ksm-text);
  font-size: 14px;
}

.ksm-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  margin: 0;
  border-radius: 10px;
  background: rgba(237, 224, 196, 0.22);
  border: 1px solid var(--ksm-divider);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ksm-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ksm-stone);
  transition: transform 0.2s ease, background 0.2s ease;
}

.ksm-toggle input[type="checkbox"]:checked {
  background: var(--ksm-ochre);
  border-color: var(--ksm-ochre);
}

.ksm-toggle input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: var(--ksm-bg);
}

.ksm-toggle input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--ksm-ochre);
  outline-offset: 2px;
}

/* ── Readout / section label ───────────────── */

.ksm-readout {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 12px;
  color: var(--ksm-text-muted);
  padding: 6px 8px;
  background: transparent;
  border: 1px solid var(--ksm-divider);
  border-radius: 2px;
}

.ksm-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ksm-text-muted);
  margin-top: 4px;
}

/* ── Audible list ──────────────────────────── */

.ksm-audible { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }

.ksm-audible li {
  font-size: 13px;
  color: var(--ksm-text);
  padding: 5px 10px;
  border-radius: 2px;
  border-left: 3px solid var(--ksm-stone);
}

/* Tag accent borders (active once data-tag is set by JS) */
.ksm-audible li[data-tag="sea"]       { border-left-color: var(--tag-sea); }
.ksm-audible li[data-tag="water"]     { border-left-color: var(--tag-water); }
.ksm-audible li[data-tag="ambience"]  { border-left-color: var(--tag-ambience); }
.ksm-audible li[data-tag="wind"]      { border-left-color: var(--tag-wind); }
.ksm-audible li[data-tag="birdsong"]  { border-left-color: var(--tag-birdsong); }
.ksm-audible li[data-tag="invisible"] { border-left-color: var(--tag-invisible); }

.ksm-audible-empty { font-size: 13px; color: var(--ksm-text-muted); font-style: italic; }

/* ── Markers ───────────────────────────────── */

.ksm-marker {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tag-color, var(--ksm-stone));
  transition: transform 0.2s ease, filter 0.2s ease;
}

.ksm-marker svg { display: block; width: 32px; height: 32px; }

.ksm-marker:hover {
  transform: scale(1.25);
  filter: drop-shadow(0 0 6px currentColor);
}

.ksm-marker.active {
  color: var(--ksm-ochre);
  filter: drop-shadow(0 0 8px var(--ksm-ochre));
}

/* ── User listener pin ─────────────────────── */

.ksm-user-pin {
  background: none;
  border: none;
}

.ksm-user-pin-inner {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ksm-user-pin-inner::before,
.ksm-user-pin-inner::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  border: 2px solid var(--ksm-ochre);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.35);
  opacity: 0.85;
  animation: ksm-user-pulse 2s ease-out infinite;
  pointer-events: none;
}

.ksm-user-pin-inner::after {
  animation-delay: 1s;
}

.ksm-user-pin-dot {
  position: relative;
  width: 12px;
  height: 12px;
  background: var(--ksm-ochre);
  border: 2px solid var(--ksm-bg);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(212, 154, 58, 0.7),
              0 0 0 1px rgba(212, 154, 58, 0.35);
  z-index: 2;
}

@keyframes ksm-user-pulse {
  0%   { transform: translate(-50%, -50%) scale(0.35); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(1.6);  opacity: 0;    }
}

/* ── Leaflet overrides ─────────────────────── */

.leaflet-container { background: var(--ksm-bg); }

/* Push zoom controls below the floating header chip */
.leaflet-top.leaflet-left { padding-top: 56px; }

/* Brighten land/sea on the dark basemap - applies only to tile imagery,
   leaves markers, circles, and controls untouched (they're in other panes). */
.leaflet-tile-pane {
  filter: saturate(1.6) brightness(1.25) hue-rotate(-6deg);
}

.leaflet-control-attribution {
  background: rgba(12, 31, 46, 0.7) !important;
  color: var(--ksm-text-muted) !important;
  font-size: 10px !important;
}

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

.leaflet-control-zoom a {
  background: var(--ksm-panel-bg) !important;
  color: var(--ksm-text) !important;
  border: 1px solid var(--ksm-divider) !important;
}

.leaflet-control-zoom a:hover { background: var(--ksm-sea) !important; }

/* ── Responsive: mobile ────────────────────── */

@media (max-width: 768px) {
  .ksm-feed {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    bottom: 16px;
    max-height: 45vh;
    padding: 10px;
  }

  .ksm-status {
    top: 68px;
  }
}

/* ── Info overlay ──────────────────────────── */

.ksm-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 28, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.ksm-info-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.ksm-info-card {
  position: relative;
  background: var(--ksm-panel-bg);
  border: 1px solid var(--ksm-divider);
  border-radius: 4px;
  padding: 32px 28px 24px;
  max-width: 520px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  color: var(--ksm-text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

.ksm-info-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: var(--ksm-text-muted);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  padding: 4px 8px;
  transition: color 0.15s ease;
}

.ksm-info-close:hover { color: var(--ksm-ochre); }
.ksm-info-close:focus-visible { outline: 2px solid var(--ksm-ochre); outline-offset: 2px; }

.ksm-info-title {
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ksm-text);
  margin: 0 0 4px;
}

.ksm-info-subtitle {
  font-size: 13px;
  color: var(--ksm-text-muted);
  margin: 0 0 20px;
  font-style: italic;
}

.ksm-info-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ksm-text);
  margin: 0 0 24px;
}

.ksm-info-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ksm-ochre);
  margin: 16px 0 10px;
}

.ksm-info-controls {
  margin: 0 0 16px;
  display: grid;
  grid-template-columns: 140px 1fr;
  row-gap: 6px;
  column-gap: 12px;
  font-size: 13px;
}

.ksm-info-controls dt {
  color: var(--ksm-stone);
  font-weight: 600;
}

.ksm-info-controls dd {
  color: var(--ksm-text-muted);
  margin: 0;
}

.ksm-info-credits {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ksm-text-muted);
  margin: 0;
}

.ksm-info-credits a {
  color: var(--ksm-stone);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ksm-info-credits a:hover { color: var(--ksm-ochre); }

@media (max-width: 480px) {
  .ksm-info-card {
    padding: 28px 20px 20px;
    max-height: calc(100vh - 32px);
  }
  .ksm-info-controls {
    grid-template-columns: 110px 1fr;
    column-gap: 10px;
    font-size: 12px;
  }
}

/* ── Reduced motion ────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ksm-marker,
  .ksm-status,
  .ksm-feed,
  .ksm-info-overlay,
  .ksm-user-pin-inner::before,
  .ksm-user-pin-inner::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
