/* ===== Reset & base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
    sans-serif;
  background: #ffffff;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* ===== App shell ===== */
#container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#controls:not([data-controls="external"]) {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#controls:not([data-controls="external"]) label {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

#controls:not([data-controls="external"]) #projection-select {
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: #333;
}
#controls:not([data-controls="external"]) #projection-select:hover {
  border-color: #999;
}
#controls:not([data-controls="external"]) #projection-select:focus {
  outline: none;
  border-color: #0099ff;
  box-shadow: 0 0 0 2px rgba(0, 153, 255, 0.2);
}

/* ===== Globe container ===== */
#globe-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;

  /* Prevent page scroll/overscroll from stealing gestures on mobile */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: auto;
}

/* Fill parent; parent is already sized to viewport via #container/body */
#globe-container canvas {
  display: block;
  cursor: grab;
  width: 100%;
  height: 100%;

  /* Stop iOS/Android selection/callouts/highlights on fast taps/double-taps */
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-user-drag: none;

  /* Ensure D3 gets the whole gesture stream */
  touch-action: none;
}

#globe-container canvas:active {
  cursor: grabbing;
}

/* ===== Tooltip ===== */
.tooltip {
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none; /* never steal events */
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  color: #333;
  white-space: nowrap;
}
.tooltip.visible {
  visibility: visible;
  opacity: 1;
}
.tooltip::before {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 9px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid #333;
}
.tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 10px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(255, 255, 255, 0.95);
}

/* ===== Removed (unstable selector) =====
#globe-container:not(:has(parent)) { width: 100vw; height: 100vh; }
*/

/* ===== Version display ===== */
/* Version is now inside #controls container */
#controls:not([data-controls="external"]) #version {
  /* ƒ Config: Version display styling */
  /* Modify: adjust font-size, color, margin values to change appearance */
  font-size: 0.5rem;
  font-family: "American Typewriter", serif;
  color: #666;
  margin-left: 10px; /* Spacing from the select dropdown */
  pointer-events: none;
  /* ƒ Config: Text color - increase contrast for better visibility */
  /* Modify: use darker color (e.g., #333) for better visibility, lighter for subtle appearance */
}

/* Mobile and tablet: slightly larger font and ensure visibility */
@media (max-width: 768px) {
  #controls:not([data-controls="external"]) #version {
    font-size: 0.625rem; /* 50% larger on mobile (0.5rem → 0.625rem) */
    color: #555; /* Slightly darker for better contrast */
  }
}
