/* terra-map.css — Civ-style hex map page styles */

.terra-map-container {
  height: 720px;
  width: 100%;
  border-radius: 15px;
  overflow: hidden;
  position: relative;
  background: #0b1e33;
}

/* map card — header removed, map fills the glass card edge-to-edge */
#terra-map-card {
  padding: 0;
  overflow: hidden;
}
#terra-map-card .map-legend-compact { padding: 0 12px; }

#terra-wrap {
  position: absolute;
  inset: 0;
}

#terra-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#terra-canvas:active { cursor: grabbing; }

/* HTML overlay layer — banners, labels (children opt-in to pointer events) */
#terra-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}

/* soft cinematic vignette inside the map frame */
#terra-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  box-shadow: inset 0 0 140px 20px rgba(6, 18, 32, 0.55);
  border-radius: inherit;
}

/* ------------------------------------------------ Civ-style plant banners */
.terra-banner {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 4px;
  border-radius: 999px;
  background: rgba(18, 30, 44, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  z-index: 5;
}
.terra-banner:hover {
  transform: translate(-50%, -100%) scale(1.12);
  background: rgba(24, 42, 62, 0.95);
  z-index: 9;
}
.terra-banner .tb-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}
.terra-banner .tb-dot svg {
  width: 10px;
  height: 10px;
}
.terra-banner .tb-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.terra-banner .tb-mw {
  font-weight: 700;
  font-size: 10px;
  color: #ffd75e;
  letter-spacing: 0.2px;
}
.terra-banner .tb-plus {
  font-size: 9px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0 4px;
}

/* dot marker used when zoomed out */
.terra-dot {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
  pointer-events: auto;
  cursor: pointer;
}
.terra-dot:hover { transform: translate(-50%, -50%) scale(1.4); }

/* ------------------------------------------------------- map name labels */
.terra-label {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6), 0 0 12px rgba(0,0,0,0.4);
}
.terra-label.sea {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-style: italic;
  color: rgba(230, 242, 255, 0.55);
  font-size: 15px;
  letter-spacing: 0.35em;
}
.terra-label.lake {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-style: italic;
  color: rgba(190, 225, 250, 0.65);
  font-size: 10.5px;
  letter-spacing: 0.18em;
}
.terra-label.country {
  font-family: 'Poppins', sans-serif;
  color: rgba(255, 255, 255, 0.30);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.4em;
}
.terra-label.city {
  font-family: 'Inter', sans-serif;
  color: rgba(255, 255, 255, 0.85);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  transform: translate(-50%, 60%);
}
.terra-city-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgba(255,255,255,0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
/* interconnector landing billboards — name over live MW */
.terra-label.ic {
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  transform: translate(-50%, -50%);
}
.terra-label.ic b {
  display: block;
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.terra-label.ic span { color: rgba(190, 200, 210, 0.85); }
.terra-label.ic.import span { color: #ffc46b; }
.terra-label.ic.export span { color: #7fd4ff; }
.terra-label.ic.unknown b { color: rgba(255, 255, 255, 0.38); }

/* -------------------------------------------------------------- tooltip */
#terra-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 8;
  display: none;
  background: rgba(18, 30, 44, 0.92);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 6px 10px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
#terra-tooltip .tt-title { font-weight: 600; color: #ffd75e; }
#terra-tooltip .tt-sub { font-size: 11px; opacity: 0.8; }

/* ----------------------------------------------------------- info panel */
#terra-info-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 300px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
  z-index: 7;
  background: rgba(20, 32, 48, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 14px;
  padding: 14px 16px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(.2,.8,.3,1);
}
#terra-info-panel.open { transform: translateX(0); }
#terra-info-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 20px;
  opacity: 0.7;
  cursor: pointer;
  line-height: 1;
}
#terra-info-close:hover { opacity: 1; }
#terra-info-panel .ip-title {
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  padding-right: 16px;
}
#terra-info-panel .ip-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 10px;
}
#terra-info-panel .ip-output {
  font-size: 26px;
  font-weight: 700;
  color: #ffd75e;
  margin-bottom: 10px;
}
#terra-info-panel .ip-output small {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.7;
}
#terra-info-panel .ip-unit {
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 12px;
}
#terra-info-panel .ip-unit-head {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}
#terra-info-panel .ip-unit-mw { color: #ffd75e; }
#terra-info-panel .ip-unit-sub { font-size: 11px; opacity: 0.7; margin-top: 2px; }
#terra-info-panel .ip-terrain {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 10px;
}
#terra-info-panel .ip-site {
  margin-bottom: 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 8px;
}
#terra-info-panel .ip-site-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
#terra-info-panel .ip-site-name {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}
#terra-info-panel .ip-ic {
  background: rgba(89, 199, 255, 0.10);
  border: 1px solid rgba(89, 199, 255, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
#terra-info-panel .ip-ic-head {
  font-weight: 600;
  font-size: 12px;
  color: #9fdcff;
  margin-bottom: 2px;
}
#terra-info-panel .ip-ic-flow {
  font-size: 15px;
  font-weight: 700;
  color: #ffd75e;
  margin-top: 4px;
}
#terra-info-panel .ip-ic-flow small {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.7;
}
#terra-tooltip .tt-plants { margin-top: 4px; line-height: 1.45; white-space: normal; min-width: 140px; }
#terra-tooltip .tt-ic { color: #9fdcff; margin-top: 3px; }
#terra-info-panel .ip-coords {
  font-size: 10px;
  opacity: 0.45;
  margin-top: 8px;
  font-family: monospace;
}

/* -------------------------------------------------------------- minimap */
#terra-minimap {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 150px;
  height: 220px;
  z-index: 6;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  cursor: pointer;
  background: rgba(8, 20, 34, 0.85);
}

/* ---------------------------------------------------- initial 3D loader */
#terra-loading-3d {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #173a5e 0%, #0b1e33 75%);
  transition: opacity 0.8s ease;
}
#terra-loading-3d.done { opacity: 0; pointer-events: none; }
.terra-loading-inner { text-align: center; }
.terra-loading-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 6px;
  color: #ffd75e;
  text-shadow: 0 0 30px rgba(255, 215, 94, 0.4);
  animation: terra-pulse 1.6s ease-in-out infinite;
}
.terra-loading-sub {
  margin-top: 10px;
  font-family: 'Georgia', serif;
  font-style: italic;
  color: rgba(220, 235, 255, 0.75);
  font-size: 14px;
  letter-spacing: 1px;
}
@keyframes terra-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; text-shadow: 0 0 44px rgba(255, 215, 94, 0.7); }
}

/* ---------------------------------------------------------- civ toggles */
.terra-toggles .layer-button { min-width: 52px; }
.terra-toggle:not(.active) { opacity: 0.55; }
#toggle-sat:disabled { opacity: 0.3; cursor: default; }

/* Plants All/Active switch — bigger knob that actually fills the track
   (shared .toggle-text style is a small 16px dot on a 40px track) */
.terra-toggles .toggle-text { padding-left: 54px; line-height: 24px; }
.terra-toggles .toggle-text:before {
  width: 46px;
  height: 24px;
  border-radius: 12px;
}
.terra-toggles .toggle-text:after {
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
}
.terra-toggles .toggle-input:checked + .toggle-label .toggle-text:after {
  transform: translateX(22px);
}

/* live wind chip — bottom left, above the drag hint */
#terra-wind-hud {
  position: absolute;
  left: 14px;
  bottom: 44px;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 8px;
  background: rgba(10, 22, 36, 0.62);
  border: 1px solid rgba(140, 200, 255, 0.18);
  color: #dceaf7;
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  pointer-events: none;
}
#terra-wind-hud .wind-arrow { font-size: 14px; color: #8fd0ff; line-height: 1; }
#terra-wind-hud .wind-ms { font-weight: 600; }
#terra-wind-hud .wind-src { opacity: 0.5; font-size: 10px; }

/* opt-in renderer diagnostics — /terra-map/?perf */
#terra-perf {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 6;
  min-width: 168px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(8, 18, 30, 0.72);
  border: 1px solid rgba(140, 200, 255, 0.2);
  color: #dceaf7;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
  white-space: pre-line;
}
#terra-perf strong { color: #8fd0ff; font-size: 13px; }

/* imagery attribution — bottom right */
#terra-credit {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  display: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(10, 22, 36, 0.55);
  color: rgba(220, 234, 247, 0.6);
  font-family: 'Inter', sans-serif;
  font-size: 9.5px;
  pointer-events: none;
}

/* ------------------------------------------------------------- tour mode */
#terra-wrap:fullscreen { width: 100vw; height: 100vh; background: #060b14; }
#terra-wrap:fullscreen #terra-canvas { width: 100%; height: 100%; }
body.terra-touring #terra-canvas { cursor: none; }
body.terra-touring .terra-hint,
body.terra-touring #terra-wind-hud,
body.terra-touring #terra-perf,
body.terra-touring #terra-info-panel,
body.terra-touring #terra-tooltip,
body.terra-touring #terra-minimap { display: none; }

#terra-veil {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, rgba(190, 206, 222, 0.96), rgba(168, 190, 210, 0.96));
}

#terra-tour-card {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%) translateY(24px);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 34px;
  border-radius: 16px;
  background: rgba(8, 18, 32, 0.78);
  border: 1px solid rgba(140, 200, 255, 0.22);
  backdrop-filter: blur(10px);
  color: #eef5fc;
  font-family: 'Inter', sans-serif;
  text-align: center;
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
  pointer-events: none;
  max-width: 70%;
}
#terra-tour-card.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#terra-tour-card .tt-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid;
}
#terra-tour-card .tt-name { font-size: 30px; font-weight: 700; letter-spacing: 0.01em; }
#terra-tour-card .tt-stats { display: flex; align-items: baseline; gap: 14px; }
#terra-tour-card .tt-mw { font-size: 34px; font-weight: 800; color: #7fd0ff; }
#terra-tour-card .tt-mw em { font-style: normal; font-size: 15px; font-weight: 600; margin-left: 4px; opacity: 0.7; }
#terra-tour-card .tt-sub { font-size: 13px; opacity: 0.72; }

#terra-tour-exit {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 9;
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(10, 22, 36, 0.7);
  border: 1px solid rgba(140, 200, 255, 0.25);
  color: #dceaf7;
  font-size: 15px;
  cursor: pointer;
}
body.terra-touring #terra-tour-exit { display: flex; }
body.terra-touring #terra-tour-exit:hover { background: rgba(20, 40, 64, 0.85); }

/* manual fullscreen — same slot as the tour exit (never overlaps: hidden
   while touring) */
#terra-fs {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 9;
  display: flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(10, 22, 36, 0.7);
  border: 1px solid rgba(140, 200, 255, 0.25);
  color: #dceaf7;
  font-size: 17px;
  cursor: pointer;
}
#terra-fs:hover { background: rgba(20, 40, 64, 0.85); }
body.terra-touring #terra-fs { display: none; }

/* compass-ish hint */
.terra-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 6;
  color: rgba(255,255,255,0.55);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  background: rgba(10, 22, 36, 0.6);
  padding: 5px 10px;
  border-radius: 8px;
  pointer-events: none;
}

/* ----------------------------------------------------------- responsive */
@media (max-width: 768px) {
  /* tighter page chrome on phones */
  .container { padding: 8px; }
  .glass-card { margin: 12px 0; }
  .terra-map-container { height: 560px; }
  #terra-minimap { width: 96px; height: 140px; }

  /* control panel wraps cleanly on narrow screens */
  .compact-controls .control-group,
  .compact-controls .type-selector { flex-wrap: wrap; }
  .compact-controls .type-selector .layer-button { flex: 0 0 auto; }

  /* wind readout top-left so the info sheet can never cover it */
  #terra-wind-hud { top: 14px; bottom: auto; }

  /* info panel becomes a bottom sheet */
  #terra-info-panel {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    width: auto;
    max-height: 42%;
    transform: translateY(130%);
  }
  #terra-info-panel.open { transform: translateY(0); }
  body.terra-ip-open #terra-minimap { display: none; }

  /* compact tour card */
  #terra-tour-card { bottom: 3%; max-width: 92%; padding: 10px 16px; gap: 5px; }
  #terra-tour-card .tt-name { font-size: 19px; }
  #terra-tour-card .tt-mw { font-size: 22px; }
  #terra-tour-card .tt-sub { font-size: 11px; }

  .terra-label.country { font-size: 15px; }
  .terra-label.sea { font-size: 11px; }
}
