/* ============================================================
   Remnant Biome — styles
   Consistent with Spectral Glimpse / LesselGeospatial design language
============================================================ */

/* ============================================================
   CSS VARIABLES
============================================================ */

:root {
  --panel-bg:           #1a2b38;
  --panel-bg-card:      #213345;
  --panel-border:       rgba(255,255,255,0.08);
  --panel-text:         #e8eef2;
  --panel-text-muted:   #7a9ab0;
  --panel-text-label:   #4d7a96;
  --panel-accent:       #3ecfcf;
  --panel-accent-warm:  #f59e3a;
  --panel-header-bg:    #0f1e2b;
  --panel-radius:       10px;

  --card-bg:     rgba(13, 25, 38, 0.92);
  --card-border: rgba(62, 207, 207, 0.18);

  --ctrl-bg:     rgba(13, 25, 38, 0.92);
  --ctrl-border: rgba(255,255,255,0.1);
  --ctrl-text:   #94b4c8;
  --ctrl-hover:  rgba(62,207,207,0.15);

  --color-viable:   #4ade80;
  --color-marginal: #f59e3a;
  --color-deficit:  #f87171;
}

/* ============================================================
   RESET + BASE
============================================================ */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0c1f2c;
  color: var(--panel-text);
  overflow: hidden;
}

.hidden { display: none !important; }

/* ============================================================
   APP SHELL
============================================================ */

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   MAP
============================================================ */

#map {
  position: absolute;
  inset: 0;
  background: #0c1f2c;
  cursor: crosshair;
}

/* ============================================================
   TOP LEFT: ZOOM + SELECTOR
============================================================ */

#top-left-wrap {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 900;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Zoom controls */
#zoom-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#zoom-controls button {
  width: 30px;
  height: 30px;
  background: var(--ctrl-bg);
  border: 1px solid var(--ctrl-border);
  border-radius: 6px;
  color: var(--ctrl-text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

#zoom-controls button:hover {
  background: var(--ctrl-hover);
  color: var(--panel-accent);
}

/* Selector panel */
#selector-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--panel-radius);
  backdrop-filter: blur(12px);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}

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

.selector-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--panel-text-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill {
  padding: 4px 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  color: var(--panel-text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.pill:hover {
  background: rgba(62,207,207,0.1);
  color: var(--panel-text);
  border-color: rgba(62,207,207,0.3);
}

.pill.active {
  background: rgba(62,207,207,0.15);
  border-color: rgba(62,207,207,0.5);
  color: var(--panel-accent);
  font-weight: 500;
}

.selector-divider {
  height: 1px;
  background: var(--panel-border);
  margin: 2px 0;
}

/* Deficit badge */
#deficit-badge {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 20px;
  width: fit-content;
}

#deficit-text {
  font-size: 10px;
  color: var(--color-deficit);
  font-weight: 500;
}

/* ============================================================
   TOP RIGHT: SCENARIO + YEAR
============================================================ */

#scenario-year-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 900;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--panel-radius);
  backdrop-filter: blur(12px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 210px;
}

/* Scenario 2x2 grid */
#scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.scenario-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  gap: 2px;
  font-family: inherit;
}

.scenario-btn:hover {
  background: rgba(62,207,207,0.08);
  border-color: rgba(62,207,207,0.25);
}

.scenario-btn.active {
  background: rgba(62,207,207,0.12);
  border-color: rgba(62,207,207,0.45);
}

.scenario-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--panel-text);
  text-align: center;
  line-height: 1.2;
}

.scenario-code {
  font-size: 9px;
  color: var(--panel-text-label);
  font-family: monospace;
  text-align: center;
}

.scenario-btn.active .scenario-label {
  color: var(--panel-accent);
}

.scenario-btn.active .scenario-code {
  color: rgba(62,207,207,0.6);
}

/* Year scrubber */
#year-scrubber {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#year-display {
  text-align: center;
}

#year-label {
  font-size: 22px;
  font-weight: 600;
  color: var(--panel-accent);
  font-family: monospace;
  letter-spacing: 0.05em;
}

#scrubber-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#play-btn {
  width: 26px;
  height: 26px;
  background: rgba(62,207,207,0.1);
  border: 1px solid rgba(62,207,207,0.3);
  border-radius: 50%;
  color: var(--panel-accent);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  padding-left: 2px; /* optical center for play triangle */
}

#play-btn:hover { background: rgba(62,207,207,0.2); }

#play-btn.playing {
  background: rgba(62,207,207,0.2);
  padding-left: 0;
}

#year-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--panel-accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(62,207,207,0.4);
}

#year-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--panel-accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

#scrubber-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--panel-text-label);
  padding: 0 2px;
}

/* ============================================================
   TIMELINE PANEL
============================================================ */

#timeline-panel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--panel-radius);
  backdrop-filter: blur(12px);
  padding: 14px;
  width: min(520px, calc(100vw - 28px));
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#timeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

#timeline-location {
  font-size: 13px;
  font-weight: 600;
  color: var(--panel-text);
  line-height: 1.3;
}

#timeline-meta {
  font-size: 10px;
  color: var(--panel-text-muted);
  margin-top: 2px;
}

#timeline-close {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--panel-text-muted);
  font-size: 11px;
  padding: 3px 7px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

#timeline-close:hover {
  background: rgba(255,255,255,0.12);
  color: var(--panel-text);
}

#timeline-chart-wrap {
  position: relative;
  height: 140px;
}

#timeline-chart {
  width: 100% !important;
  height: 140px !important;
}

/* ============================================================
   CLICK HINT
============================================================ */

#click-hint {
  position: fixed;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  background: rgba(13,25,38,0.88);
  border: 0.5px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12px;
  color: #7a9ab0;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s;
}

#click-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   BOTTOM LEFT: TITLE CARD
============================================================ */

#title-card {
  position: fixed;
  bottom: 28px;
  left: 14px;
  z-index: 900;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  max-width: 300px;
  overflow: hidden;
  pointer-events: all;
}

#title-card-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
}

#title-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: contain;
}

#title-text { flex: 1; min-width: 0; }

#title-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e8eef2;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#title-tagline {
  font-size: 0.68rem;
  color: #6a8fa8;
  margin-top: 1px;
  line-height: 1.3;
}

#about-toggle {
  width: 24px;
  height: 24px;
  background: rgba(62,207,207,0.1);
  border: 1px solid rgba(62,207,207,0.3);
  border-radius: 50%;
  color: var(--panel-accent);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
  font-family: inherit;
}

#about-toggle:hover { background: rgba(62,207,207,0.22); }

#about-panel {
  border-top: 1px solid rgba(62,207,207,0.12);
  padding: 10px 13px 12px;
  font-size: 0.77rem;
  color: #7a9ab0;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#about-panel a {
  color: var(--panel-accent);
  text-decoration: none;
}

#about-panel a:hover { text-decoration: underline; }

/* ============================================================
   LEGEND
============================================================ */

#legend {
  position: fixed;
  bottom: 52px;
  right: 14px;
  z-index: 900;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  color: var(--panel-text-muted);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   MAPLIBRE OVERRIDES
============================================================ */

.maplibregl-canvas { cursor: crosshair; }

.maplibregl-ctrl-attrib {
  background: rgba(13,25,38,0.80) !important;
  color: #7a9ab0 !important;
  font-size: 10px !important;
}

.maplibregl-ctrl-attrib a { color: #5a9ab8 !important; }

/* ============================================================
   CLICK MARKER
============================================================ */

.click-marker {
  width: 12px;
  height: 12px;
  background: #38bdf8;
  border: 2px solid #fff;
  border-radius: 50%;
  position: relative;
}

.click-marker::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 24px; height: 24px;
  border: 1.5px solid rgba(56,189,248,0.4);
  border-radius: 50%;
  animation: ring 2s infinite;
}

@keyframes ring {
  0%,100% { opacity: 0.6; transform: translate(-50%,-50%) scale(1); }
  50%      { opacity: 0.1; transform: translate(-50%,-50%) scale(1.4); }
}

/* ============================================================
   RESPONSIVE
============================================================ */

@media (max-width: 600px) {
  #selector-panel { max-width: calc(100vw - 60px); }

  #timeline-panel {
    bottom: 70px;
    width: calc(100vw - 28px);
  }

  #title-card { max-width: calc(100vw - 140px); }

  #legend { display: none; }
}
