/**
 * ThemeTVD Interactive 3D Globe Stylesheet
 * 
 * Hardware-accelerated CSS for Three.js WebGL Earth Globe, Markers & Tooltips.
 * Clean, lightweight, responsive, supporting dark/light UI and reduced motion.
 */

:root {
  --globe-width: 100%;
  --globe-height: 560px;
  --globe-radius: 16px;
  --globe-zindex: 1;
  --globe-accent: #38bdf8;
  --globe-accent-glow: rgba(56, 189, 248, 0.35);
}

.tvd-interactive-globe {
  position: relative;
  width: var(--globe-width, 100%);
  max-width: 100%;
  height: var(--globe-height, 560px);
  min-height: 280px;
  border-radius: var(--globe-radius, 16px);
  overflow: hidden;
  z-index: var(--globe-zindex, 1);
  box-sizing: border-box;
}

/* Alignments */
.tvd-interactive-globe--align-center {
  margin-left: auto;
  margin-right: auto;
}
.tvd-interactive-globe--align-left {
  margin-left: 0;
  margin-right: auto;
}
.tvd-interactive-globe--align-right {
  margin-left: auto;
  margin-right: 0;
}

/* Responsive Heights */
@media (max-width: 1024px) {
  .tvd-interactive-globe {
    height: var(--globe-height-md, var(--globe-height, 480px));
  }
  .tvd-interactive-globe--align-md-center {
    margin-left: auto;
    margin-right: auto;
  }
  .tvd-interactive-globe--align-md-left {
    margin-left: 0;
    margin-right: auto;
  }
  .tvd-interactive-globe--align-md-right {
    margin-left: auto;
    margin-right: 0;
  }
}

@media (max-width: 767px) {
  .tvd-interactive-globe {
    height: var(--globe-height-sm, 380px);
  }
  .tvd-interactive-globe--align-sm-center {
    margin-left: auto;
    margin-right: auto;
  }
  .tvd-interactive-globe--align-sm-left {
    margin-left: 0;
    margin-right: auto;
  }
  .tvd-interactive-globe--align-sm-right {
    margin-left: auto;
    margin-right: 0;
  }
}

/* Stage & Canvas Container */
.tvd-globe-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tvd-globe-canvas-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.tvd-globe-canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.tvd-globe-canvas:active,
.tvd-globe-canvas.is-grabbing {
  cursor: grabbing;
}

/* Loading Skeleton & Spinner */
.tvd-globe-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 0.8) 100%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
  z-index: 4;
}

.tvd-globe-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tvd-globe-spinner {
  width: 46px;
  height: 46px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: tvdGlobeSpin 0.9s linear infinite;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

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

/* Header Overlay */
.tvd-globe-header {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  z-index: 6;
  pointer-events: none;
  text-align: center;
}

.tvd-globe-badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 999px;
  margin-bottom: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.tvd-globe-title {
  margin: 0 0 6px 0;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.25;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.tvd-globe-tagline {
  margin: 0;
  font-size: 0.95rem;
  color: #94a3b8;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Floating Controls */
.tvd-globe-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  pointer-events: auto;
}

.tvd-globe-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #e2e8f0;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tvd-globe-btn:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.3);
}

.tvd-globe-btn:active {
  transform: translateY(0);
}

.tvd-globe-btn.is-active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

/* Markers & Tooltips Layer */
.tvd-globe-popups {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

/* Projected 3D Popup Card */
.tvd-globe-popup {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -100%) translateY(-14px);
  pointer-events: auto;
  min-width: 200px;
  max-width: 300px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 14px 16px;
  color: #f8fafc;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.tvd-globe-popup::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: rgba(15, 23, 42, 0.92);
  border-right: 1px solid rgba(56, 189, 248, 0.35);
  border-bottom: 1px solid rgba(56, 189, 248, 0.35);
}

.tvd-globe-popup.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -100%) translateY(-14px) scale(1);
}

.tvd-globe-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.tvd-globe-popup__title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tvd-globe-popup__indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--marker-color, #38bdf8);
  box-shadow: 0 0 8px var(--marker-color, #38bdf8);
}

.tvd-globe-popup__close {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.tvd-globe-popup__close:hover {
  color: #ffffff;
}

.tvd-globe-popup__desc {
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
  margin: 0 0 10px 0;
}

.tvd-globe-popup__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  text-decoration: none;
  transition: color 0.15s ease;
}

.tvd-globe-popup__link:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

/* Pulsing 2D Marker Beacon (Overlay projection) */
.tvd-globe-marker-pin {
  position: absolute;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  z-index: 12;
}

.tvd-globe-marker-pin__dot {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background-color: var(--marker-color, #38bdf8);
  box-shadow: 0 0 10px var(--marker-color, #38bdf8);
  transition: transform 0.2s ease;
}

.tvd-globe-marker-pin__ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--marker-color, #38bdf8);
  opacity: 0.8;
  animation: tvdGlobePulse 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes tvdGlobePulse {
  0% {
    transform: scale(0.6);
    opacity: 1;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

.tvd-globe-marker-pin:hover .tvd-globe-marker-pin__dot {
  transform: scale(1.3);
}

/* BuildWeb Editor adjustments */
.tvd-interactive-globe--builder {
  user-select: none;
}

/* Reduced Motion Mode */
@media (prefers-reduced-motion: reduce) {
  .tvd-globe-marker-pin__ring {
    animation: none;
    display: none;
  }
  .tvd-globe-spinner {
    animation-duration: 2.5s;
  }
  .tvd-globe-popup {
    transition: opacity 0.1s linear;
  }
}

/* Background Mode for Section & Banner Integration */
.tvd-interactive-globe--mode-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
  pointer-events: auto;
  overflow: hidden;
  border-radius: 0 !important;
}

.tvd-interactive-globe--mode-background .tvd-globe-stage,
.tvd-interactive-globe--mode-background .tvd-globe-canvas-wrap {
  height: 100% !important;
  min-height: 100% !important;
}

/* Location Filter & Navigation Pills */
.tvd-globe-location-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 10px auto 16px auto;
  max-width: 90%;
  position: relative;
  z-index: 12;
}

.tvd-globe-nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.tvd-globe-nav-pill:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--pill-color, #38bdf8);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 10px rgba(56, 189, 248, 0.25);
}

.tvd-globe-nav-pill.is-active {
  background: rgba(2, 132, 199, 0.35);
  border-color: var(--pill-color, #38bdf8);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 16px rgba(56, 189, 248, 0.4);
}

.tvd-globe-nav-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pill-color, #38bdf8);
  box-shadow: 0 0 8px var(--pill-color, #38bdf8);
  flex-shrink: 0;
}

