/* map.css */

/* -----------------------------
   Base card + header
----------------------------- */
.geo-map-card {
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.10);
}

.geo-map-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 10px;
}

.geo-map-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.geo-map-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

/* NEW: embedded map header block (asset_class.html) */
.geo-map-head{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.geo-map-head .geo-map-title-row{
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.geo-map-subtitle{
  font-size: 13px;
  line-height: 1.25;
  color: rgba(255,255,255,0.72);
}

.geo-map-assetline{
  font-size: 14px;
  opacity: 0.92;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.geo-map-updatedline{
  font-size: 12px;
  opacity: 0.75;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

/* -----------------------------
   Info button + popover (Map-specific)
   Works with your existing JS:
   - .info-btn nextElementSibling .info-popover
----------------------------- */
.geo-map-info{
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 80; /* must beat SVG + map layers */
}

.geo-map-info .info-btn{
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.6);
  background: transparent;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}

.geo-map-info .info-btn:focus{
  outline: 2px solid rgba(255, 214, 74, 0.85);
  outline-offset: 2px;
}

/* Popover placement + stacking */
.geo-map-info .info-popover{
  position: absolute;
  top: 28px;
  right: 0;

  z-index: 90;
}

/* Ensure the popover is not clipped by any ancestor */
.geo-map-card--embedded,
.geo-map-head,
.geo-map-title-row{
  overflow: visible;
}

/* -----------------------------
   Map container (single-page IDs)
   Keep aspect ratio consistent
----------------------------- */
#geoWrap {
  position: relative;
  width: 100%;

  /* aspect ratio first; height comes from width */
  aspect-ratio: 2 / 1;

  /* keep consistent max height, allow ratio-based growth up to this */
  max-height: 520px;

  border-radius: 14px;
  overflow: hidden;

  transform: translateZ(0);
}

.geo-exposure-card #geoWrap {
  margin-top: 10px;
}

#geoSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* Country outline styling */
.country {
  fill: rgba(255,255,255,0.03);
  stroke: rgba(255,255,255,0.60);
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  cursor: default;
}

/* Tooltip panel (single-page #geoPanel) */
#geoPanel {
  position: absolute;
  z-index: 10;
  width: 420px;
  max-width: min(520px, calc(100% - 24px));
  background: rgba(15,15,15,0.82);
  color: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.35);
  padding: 12px;
  line-height: 1.25;
  backdrop-filter: blur(6px);
  display: none;
  left: 0;
  top: 0;
  transform: none;
  pointer-events: none;
}

#geoPanel .kv {
  font-size: 12px;
}

#geoPanel .geo-events {
  font-size: 12px;
}

#geoPanel .geo-events li {
  margin: 3px 0;
}

#geoPanel .geo-panel-divider {
  margin: 10px 0 10px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

#geoPanel .geo-events-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 12px;
}

#geoPanel .geo-events-block {
  margin-top: 0;
}

.geo-events {
  margin: 0;
  padding-left: 18px;
}

.geo-events li {
  margin: 4px 0;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 10px;
  font-size: 12px;
}

.muted {
  color: rgba(255,255,255,0.65);
}

/* =========================================================
   Embedded map (asset_class.html)
   - card framing
   - inset canvas
   - richer tooltip
   ========================================================= */

/* Outer embedded card framing
   IMPORTANT: overflow must be visible so the info popover can escape */
.geo-map-card--embedded {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  box-shadow: 0 14px 40px rgba(0,0,0,0.40);

  overflow: visible; /* CHANGED from hidden */
  padding: 12px;

  position: relative;
  z-index: 1;
}

/* Embedded wrap(s)
   IMPORTANT: overflow must be visible for popovers/panels;
   clipping is handled by the ::before/::after overlays + SVG/canvas shape */
.geo-map-card--embedded #geoWrap-1,
.geo-map-card--embedded [id^="geoWrap-"] {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 520px;
  border-radius: 14px;

  overflow: visible; /* CHANGED from hidden */

  /* inset canvas feel */
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);

  transform: translateZ(0);

  z-index: 1;
}

/* subtle overlays to make the topo pop */
.geo-map-card--embedded [id^="geoWrap-"]::before,
.geo-map-card--embedded [id^="geoWrap-"]::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 14px;
}

.geo-map-card--embedded [id^="geoWrap-"]::before {
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.20;
  mix-blend-mode: overlay;
}

.geo-map-card--embedded [id^="geoWrap-"]::after {
  background: radial-gradient(
    120% 90% at 50% 45%,
    rgba(0,0,0,0.00) 0%,
    rgba(0,0,0,0.18) 55%,
    rgba(0,0,0,0.42) 100%
  );
  opacity: 0.9;
}

/* Embedded SVG(s) */
.geo-map-card--embedded [id^="geoSvg-"] {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;
  display: block;

  overflow: visible;

  z-index: 1; /* keep below info chrome */
}

/* Embedded panel baseline (you asked to keep this hook) */
.geo-map-card--embedded [id^="geoPanel-"] {
  position: absolute;
  z-index: 40; /* ABOVE svg */
  display: none;
}

/* Embedded panel styling (applied via the id selector) */
.geo-map-card--embedded [id^="geoPanel-"] {
  min-width: 320px;
  max-width: 420px;

  padding: 12px 14px;
  border-radius: 12px;

  background: rgba(10, 12, 16, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);

  color: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);

  line-height: 1.25;
  pointer-events: none;
}

.geo-map-card--embedded [id^="geoPanel-"] .kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  font-size: 12px;
}

.geo-map-card--embedded [id^="geoPanel-"] .kv > div:nth-child(odd) {
  color: rgba(255,255,255,0.60);
}

.geo-map-card--embedded [id^="geoPanel-"] .kv > div:nth-child(even) {
  color: rgba(255,255,255,0.92);
}

.geo-map-card--embedded [id^="geoPanel-"] .muted {
  color: rgba(255,255,255,0.45);
}

.geo-map-card--embedded [id^="geoPanel-"] .geo-panel-divider {
  margin: 10px 0;
  border-top: 1px solid rgba(255,255,255,0.10);
}

.geo-map-card--embedded [id^="geoPanel-"] .geo-events-title {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.geo-map-card--embedded [id^="geoPanel-"] .geo-events {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
}

.geo-map-card--embedded [id^="geoPanel-"] .geo-events li {
  margin: 4px 0;
  opacity: 0.92;
}

/* Country outline slightly softer in embedded */
.geo-map-card--embedded .country {
  fill: rgba(255,255,255,0.028);
  stroke: rgba(255,255,255,0.45);
  stroke-width: 0.75;
}

/* Small glow on the interactive ring (your JS sets this stroke color) */
.geo-map-card--embedded svg [stroke="rgba(255, 214, 74, 1)"] {
  filter: drop-shadow(0 0 6px rgba(255,214,74,0.35));
}

/* =========================================================
   Shared panel styling used by embedded (.geo-panel class)
   Keep for compatibility (your HTML uses class="geo-panel")
   ========================================================= */

.geo-panel {
  display: none;
  position: absolute;
  z-index: 40;

  min-width: 320px;
  max-width: 380px;

  padding: 12px 14px;
  border-radius: 12px;

  background: rgba(12, 16, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);

  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);

  pointer-events: none;
}

.geo-panel .kv {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 6px 12px;
  font-size: 12px;
  line-height: 1.25;
}

.geo-panel .kv > div:nth-child(odd) {
  color: rgba(255, 255, 255, 0.65);
}

.geo-panel .kv > div:nth-child(even) {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
}

.geo-panel .muted {
  color: rgba(255, 255, 255, 0.45);
}

/* -----------------------------
   Asset slider (unchanged)
----------------------------- */
.geo-asset-slider {
  width: 75%;
  margin: 25px auto 5px;
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  column-gap: 6px;
}

.geo-asset-nav {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
}

.geo-asset-nav svg {
  width: 20px;
  height: 20px;
}

.geo-asset-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.geo-asset-box {
  padding: 8px 10px;
  min-height: 34px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);

  font-weight: 700;
  font-size: 12px;
  line-height: 1.1;
  text-align: center;

  cursor: pointer;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  opacity: 0.90;
  background: rgba(255,255,255,0.10);
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);

  transition: transform 120ms ease, opacity 120ms ease, outline-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

/* Dim non-current boxes (prev/next) */
.geo-asset-box:not(.geo-asset-box--current) {
  opacity: 0.62;
  filter: saturate(0.90);
}

.geo-asset-box:hover {
  opacity: 0.90;
  transform: translateY(-1px);
}

.geo-asset-box--current:hover {
  opacity: 1;
}

.geo-asset-box--current {
  opacity: 1;
  outline: 2px solid rgba(255, 214, 74, 0.95);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(255, 214, 74, 0.14);
}

/* -----------------------------
   Responsive
----------------------------- */
@media (max-width: 720px) {
  .geo-asset-slider {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .geo-exposure-card,
  .heatmap-card {
    overflow: visible !important;
  }

  #geoWrap,
  .geo-map-card--embedded [id^="geoWrap-"] {
    max-height: 420px;
    min-height: 220px;
    overflow: visible;
  }

  .geo-map-card--embedded .geo-map-header {
    margin-bottom: 6px;
    gap: 4px;
  }

  /* Embedded card padding smaller on mobile to keep map big */
  .geo-map-card--embedded {
    padding: 8px;
    border-radius: 14px;
  }

  /* Keep boxes column-friendly */
  .geo-asset-boxes {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  /* Hide prev/next boxes on mobile (show only current) */
  #geoBoxPrev,
  #geoBoxNext {
    display: none;
  }
}
