:root {
  /* sunset-mountain palette pulled from the reference image */
  --sky-1: #e88a57;   /* warm coral (top of sky)   */
  --sky-2: #efa56a;   /* peach                     */
  --sky-3: #d98f78;   /* dusty rose transition     */
  --mist:  #8fd4c8;   /* pale teal mist            */
  --teal:  #4aa79e;   /* mountain teal             */
  --blue:  #3f6f96;   /* mid blue range            */
  --peak:  #5a6b9e;   /* far blue-purple peak      */
  --deep:  #16223e;   /* navy foreground / trees   */

  --ink: #fbf3e9;     /* warm cream text           */
  --ink-soft: #d8c3b4;/* muted warm grey           */

  --x: #ef8354;       /* Cost      — coral         */
  --y: #f4b860;       /* Social    — gold/peach    */
  --z: #4cc0b0;       /* Adventure — teal          */
  --size: #8e96c8;    /* Size      — soft lavender */

  --panel: rgba(18, 28, 52, 0.66);
  --panel-strong: rgba(14, 22, 42, 0.9);
  --border: rgba(245, 222, 200, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  /* vertical sunset gradient: sky -> mist -> mountains -> navy */
  background:
    linear-gradient(
      to bottom,
      var(--sky-1) 0%,
      var(--sky-2) 14%,
      var(--sky-3) 30%,
      #9a9b8f 44%,
      var(--teal) 58%,
      var(--blue) 72%,
      #243a55 86%,
      var(--deep) 100%
    );
}

/* ---------- Mountain horizon backdrop (behind the 3D canvas) ---------- */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
#backdrop svg { position: absolute; bottom: 0; left: 0; width: 100%; height: 62%; }

#scene { position: fixed; inset: 0; z-index: 1; }

/* ---------- World map view ---------- */
#map {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: var(--deep);
}
.leaflet-container { background: #16223e; font-family: inherit; }

/* themed marker tooltip + popup */
.leaflet-tooltip.holiday-tip {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(8, 14, 28, 0.5);
}
.leaflet-tooltip.holiday-tip::before { display: none; }
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--border);
}
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-popup-content .pop-title { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.leaflet-popup-content .pop-stat { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-soft); }
.leaflet-popup-content .pop-stat b { color: var(--ink); font-weight: 600; }
.leaflet-popup-content .pop-open {
  display: inline-block;
  margin-top: 10px;
  background: var(--x);
  color: #2a1206;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

/* ---------- View toggle ---------- */
#view-toggle {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(14px);
}
#view-toggle button {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#view-toggle button:hover { color: var(--ink); }
#view-toggle button.active {
  background: linear-gradient(120deg, var(--x), var(--z));
  color: #1a0d04;
}

/* ---------- HUD ---------- */
#hud-top {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 2px 16px rgba(40, 18, 6, 0.55);
}
#hud-top h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.5px;
  font-weight: 800;
}
#hud-top p {
  margin: 6px 0 0;
  color: var(--ink);
  opacity: 0.85;
  font-size: 14px;
}

/* ---------- Combined legend + parameter mapping ---------- */
#legend {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 16px 18px;
  font-size: 14px;
  min-width: 244px;
  box-shadow: 0 18px 50px rgba(8, 14, 28, 0.45);
}
#legend .panel-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 9px 0;
}
.ctrl-name { font-weight: 600; }
.ctrl-row select {
  margin-left: auto;
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 13px;
  cursor: pointer;
  min-width: 132px;
}
.ctrl-row select:hover { border-color: var(--ink-soft); }
.ctrl-row select:focus { outline: none; border-color: var(--z); }

.dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 12px currentColor; flex: none; }
.dot-x { background: var(--x); color: var(--x); }
.dot-y { background: var(--y); color: var(--y); }
.dot-z { background: var(--z); color: var(--z); }
.dot-size { background: var(--size); color: var(--size); width: 14px; height: 14px; }

#legend hr { border: none; border-top: 1px solid var(--border); margin: 14px 0 10px; }
.legend-hint { color: var(--ink-soft); font-size: 12px; line-height: 1.5; }

/* ---------- Bubble & axis labels (CSS2D) ---------- */
.bubble-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 9px;
  background: rgba(14, 22, 42, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-22px);
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
.axis-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(14, 22, 42, 0.6);
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Tooltip ---------- */
#tooltip {
  position: fixed;
  z-index: 6;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  max-width: 240px;
  transform: translate(14px, 14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(8, 14, 28, 0.5);
}
#tooltip .tt-title { font-weight: 700; margin-bottom: 6px; }
#tooltip .tt-stat { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-soft); }
#tooltip .tt-stat b { color: var(--ink); font-weight: 600; }

/* ---------- Modal ---------- */
#modal { position: fixed; inset: 0; z-index: 20; }
#modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 22, 0.66);
  backdrop-filter: blur(5px);
}
#modal-window {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1100px, 92vw);
  height: min(740px, 88vh);
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 90px rgba(6, 10, 22, 0.7);
}
#modal-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to right, rgba(239,131,84,0.15), rgba(76,192,176,0.12));
}
#modal-title { font-weight: 700; font-size: 16px; }
#modal-meta { color: var(--ink-soft); font-size: 13px; flex: 1; }
#modal-close {
  margin-left: auto;
  background: rgba(245, 222, 200, 0.08);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
#modal-close:hover { background: rgba(245, 222, 200, 0.18); }
#modal-body { flex: 1; position: relative; background: #0f1830; }
#modal-frame { width: 100%; height: 100%; border: 0; background: #0f1830; }

#modal-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 40px;
  color: var(--ink-soft);
}
#modal-fallback a {
  background: var(--x);
  color: #2a1206;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  text-decoration: none;
}

.hidden { display: none !important; }
