/* =====================================================================
 * Studio DF — B's version: globe dashboard styles (.gd-*)
 * Loaded by both the home app and the authoring app. Kept namespaced so it
 * never collides with Erick's chart CSS. The layout is fluid: it fills a
 * result card at a modest height and fills the whole authoring canvas in
 * focus mode.
 * ===================================================================== */
.gd-dash {
  display: flex;
  gap: 14px;
  width: 100%;
  aspect-ratio: 1 / 1;   /* roughly square on the start-page result card */
  align-items: stretch;
  color: #e8eefb;
  font-family: inherit;
  /* One cohesive dark-blue surface: the globe stage AND the side panel both
     sit on this, so KPIs / Top regions read as part of the same dashboard. */
  padding: 14px;
  border-radius: 16px;
  background:
    radial-gradient(150% 130% at 18% 0%, #12294f 0%, #0b1a37 46%, #081327 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 160, 230, 0.16);
}
/* Authoring focus mode fills the whole canvas rather than the square card. */
body.gf-globe-dash .gd-dash { aspect-ratio: auto; height: 100%; }

/* Globe stage — the star of the dashboard. */
.gd-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 12px;
  background:
    radial-gradient(120% 120% at 50% 30%, #12244a 0%, #0a1830 55%, #070f20 100%);
  overflow: hidden;
}
.gd-globe {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: none;
}
.gd-globe:active { cursor: grabbing; }
/* globe.gl injects its own <canvas>; make it fill the mount cleanly. */
.gd-globe canvas { display: block; }
.gd-globe .scene-container { position: absolute; inset: 0; }

/* Region-filter chips (top-left overlay) — fly between the four books of
   business, mirroring the Data App's region vibe dashboard. */
.gd-chips {
  position: absolute;
  top: 12px;
  left: 12px;
  /* Reserve the top-right corner for the light/dark toggle: the chips wrap
     within this bound instead of flowing under the pill (they used to collide
     on the narrow start-page card). */
  right: 116px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gd-chip {
  --chip: #cfe0ff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(150, 180, 240, 0.28);
  background: rgba(10, 20, 40, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(220, 232, 252, 0.86);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.gd-chip:hover { border-color: var(--chip); color: #f3f7ff; }
.gd-chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chip);
  box-shadow: 0 0 7px 1px color-mix(in srgb, var(--chip) 70%, transparent);
}
.gd-chip.is-active {
  color: #fff;
  border-color: var(--chip);
  background: color-mix(in srgb, var(--chip) 26%, rgba(10, 20, 40, 0.6));
  box-shadow: 0 0 0 1px var(--chip), 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* Light/dark toggle — top-right corner. The chips (top-left) are bounded on
   the right so they wrap clear of it, and the legend lives bottom-left, so this
   corner stays free at any card width. Same glassy pill as the chips. */
.gd-theme-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(150, 180, 240, 0.28);
  background: rgba(10, 20, 40, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(220, 232, 252, 0.9);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.gd-theme-toggle:hover { border-color: #cfe0ff; color: #fff; }
.gd-theme-ico { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Dark shows the moon, light shows the sun (toggled by the gd-dash--light flag). */
.gd-theme-sun { display: none; }
.gd-theme-moon { display: inline-flex; fill: currentColor; stroke: none; }
.gd-dash--light .gd-theme-sun { display: inline-flex; }
.gd-dash--light .gd-theme-moon { display: none; }
.gd-legend {
  position: absolute;
  left: 16px;
  bottom: 14px;
  display: flex;
  gap: 16px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: rgba(210, 224, 250, 0.82);
  z-index: 2;
}
.gd-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.gd-legend-note { color: rgba(200, 216, 246, 0.6); }
.gd-key { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.gd-key-dot {
  background: #ffb454;
  box-shadow: 0 0 8px 1px rgba(255, 157, 60, 0.7);
}
.gd-key-arc {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #ffd08a, #7fd8ff);
}
.gd-key-spire {
  width: 4px;
  height: 13px;
  border-radius: 2px;
  background: linear-gradient(180deg, #fff, #86bcb6);
}

/* Side panel — minimal: KPIs + a compact top-regions list. */
.gd-side {
  flex: 0 0 236px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gd-side-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #eaf0fb;
}
.gd-kpis { display: flex; flex-direction: column; gap: 10px; }
.gd-kpi {
  border: 1px solid rgba(120, 160, 230, 0.2);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
}
.gd-kpi-label {
  font-size: 11.5px;
  color: rgba(200, 216, 246, 0.72);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}
.gd-kpi-val {
  font-size: 22px;
  font-weight: 700;
  color: #f3f7ff;
  line-height: 1.1;
}
.gd-kpi-delta { font-size: 12px; font-weight: 600; margin-left: 4px; }
.gd-kpi-delta.is-up { color: #58d59a; }
.gd-kpi-delta.is-down { color: #ff8080; }
.gd-kpi-delta.is-flat { color: rgba(200, 216, 246, 0.6); }

.gd-panel {
  border: 1px solid rgba(120, 160, 230, 0.2);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;   /* let .gd-bars scroll inside */
}
.gd-panel-head {
  font-size: 11.5px;
  font-weight: 700;
  color: rgba(200, 216, 246, 0.72);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.gd-bar-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}
.gd-bar-row:last-child { margin-bottom: 0; }
.gd-bar-val { font-size: 11px; color: rgba(200, 216, 246, 0.85); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gd-bar-name {
  font-size: 12px;
  color: rgba(216, 228, 250, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gd-bar-track {
  height: 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.gd-bar-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #4e79a7, #7fd8ff);
}
/* Bar lists fill the panel; scroll vertically only (never horizontally). */
.gd-bars { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; margin-top: 8px;
  /* Firefox: thin, barely-there thumb over a transparent track. */
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.07) transparent; }
.gd-bars::-webkit-scrollbar { width: 6px; height: 0; }
/* Faint by default; a touch more visible only while the list is hovered. */
.gd-bars::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.07); border-radius: 4px; }
.gd-bars:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); }
.gd-bars::-webkit-scrollbar-track { background: transparent; }
/* Clickable rows: fly-to-city / pin-customer. */
.gd-bar-row--click { cursor: pointer; border-radius: 6px; padding: 3px 5px; }
.gd-bar-row--click:hover { background: rgba(255, 255, 255, 0.07); }
.gd-bar-row.is-selected { background: rgba(255, 255, 255, 0.12); }

/* Shipping-lane tooltip — appears when you click a lane on the globe. Mounts
   inside .gd-stage (position:relative); left/top are set inline at the click
   point and the transform floats it above (or below, near the top edge). */
.gd-tip {
  position: absolute;
  z-index: 6;
  min-width: 196px;
  max-width: 232px;
  padding: 10px 12px 11px;
  border-radius: 10px;
  background: rgba(9, 18, 36, 0.96);
  border: 1px solid rgba(120, 160, 230, 0.3);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  color: #eaf0fb;
  transform: translate(-50%, calc(-100% - 12px));
  pointer-events: auto;
}
.gd-tip.gd-tip-below { transform: translate(-50%, 12px); }
.gd-tip-close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: rgba(210, 224, 250, 0.7);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 5px;
}
.gd-tip-close:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.gd-tip-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #f3f7ff;
  padding-right: 16px;
}
.gd-tip-sub {
  font-size: 11px;
  color: rgba(200, 216, 246, 0.7);
  margin: 2px 0 8px;
}
/* Spire hover tooltip (no close button, doesn't block the cursor). */
.gd-tip--spire { min-width: 0; max-width: 244px; padding: 9px 12px; pointer-events: none; }
.gd-tip--spire .gd-tip-title { padding-right: 0; display: flex; align-items: center; gap: 7px; }
.gd-tip--spire .gd-tip-sub { margin: 3px 0 0; }
.gd-tip-sw { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; display: inline-block; }
.gd-tip-row {
  display: grid;
  grid-template-columns: 72px 1fr 30px;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.gd-tip-row:last-child { margin-bottom: 0; }
.gd-tip-name {
  font-size: 11px;
  color: rgba(216, 228, 250, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gd-tip-track {
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.gd-tip-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #ffd08a, #7fd8ff);
}
.gd-tip-val {
  font-size: 11px;
  text-align: right;
  color: rgba(210, 224, 250, 0.85);
}

/* globe.gl hover tooltip — its .scene-tooltip wrapper holds our .gd-hover. */
.gd-stage .scene-tooltip {
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
}
.gd-hover {
  min-width: 150px;
  max-width: 240px;
  padding: 9px 12px 10px;
  border-radius: 10px;
  background: rgba(9, 18, 36, 0.96);
  border: 1px solid rgba(120, 160, 230, 0.3);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  color: #eaf0fb;
  font-family: inherit;
  text-align: left;
}
.gd-hover-city {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: #f3f7ff;
}
.gd-hover-city i { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; display: inline-block; }
.gd-hover-sub { font-size: 11px; color: rgba(200, 216, 246, 0.72); margin-top: 3px; }

/* ── LIGHT THEME (body defaults to dark; .gd-dash--light lightens the card) ──
   A daytime "blue-marble" globe (swapped in globe.js) sits on a soft, near-white
   panel with dark text. NOT stark white — a cool, gentle light that stays premium
   and reads well from the back of a big keynote room. The globe's own hover
   tooltips stay dark (they float over the globe, not the panel), so they're left
   untouched here. */
.gd-dash--light {
  color: #1d2740;
  background:
    radial-gradient(150% 130% at 18% 0%, #ffffff 0%, #eef2f9 46%, #e2e9f4 100%);
  box-shadow: inset 0 0 0 1px rgba(30, 60, 120, 0.12);
}
.gd-dash--light .gd-stage {
  background:
    radial-gradient(120% 120% at 50% 30%, #eaf1fb 0%, #d8e4f5 55%, #cad9ee 100%);
}
/* chips + toggle: light glassy pills with dark text */
.gd-dash--light .gd-chip,
.gd-dash--light .gd-theme-toggle {
  border-color: rgba(30, 60, 120, 0.16);
  background: rgba(255, 255, 255, 0.72);
  color: #2b3653;
}
.gd-dash--light .gd-chip:hover,
.gd-dash--light .gd-theme-toggle:hover { color: #10203f; border-color: var(--chip, #2b3653); }
.gd-dash--light .gd-chip.is-active {
  color: #10203f;
  border-color: var(--chip);
  background: color-mix(in srgb, var(--chip) 22%, #ffffff);
  box-shadow: 0 0 0 1px var(--chip), 0 6px 16px rgba(30, 60, 120, 0.18);
}
/* legend + titles */
.gd-dash--light .gd-legend { color: #46536e; }
.gd-dash--light .gd-legend-note { color: #7a869e; }
.gd-dash--light .gd-side-title { color: #1d2740; }
/* KPI + list cards: white on light */
.gd-dash--light .gd-kpi,
.gd-dash--light .gd-panel {
  border-color: rgba(30, 60, 120, 0.12);
  background: #ffffff;
}
.gd-dash--light .gd-kpi-label,
.gd-dash--light .gd-panel-head { color: #64708a; }
.gd-dash--light .gd-kpi-val { color: #16223c; }
.gd-dash--light .gd-kpi-delta.is-up { color: #1e9e6b; }
.gd-dash--light .gd-kpi-delta.is-down { color: #d23f3f; }
.gd-dash--light .gd-kpi-delta.is-flat { color: #7a869e; }
/* bar rows */
.gd-dash--light .gd-bar-name { color: #2b3653; }
.gd-dash--light .gd-bar-val { color: #55617a; }
.gd-dash--light .gd-bar-track { background: rgba(30, 60, 120, 0.09); }
.gd-dash--light .gd-bar-row--click:hover { background: rgba(30, 60, 120, 0.05); }
.gd-dash--light .gd-bar-row.is-selected { background: rgba(30, 60, 120, 0.09); }
.gd-dash--light .gd-bars { scrollbar-color: rgba(30, 60, 120, 0.18) transparent; }
.gd-dash--light .gd-bars::-webkit-scrollbar-thumb { background: rgba(30, 60, 120, 0.16); }
.gd-dash--light .gd-bars:hover::-webkit-scrollbar-thumb { background: rgba(30, 60, 120, 0.28); }

/* Start-screen card only (the dash lives inside .ns-ans there, but NOT in the
   authoring .gf-embed): keep it closer to square instead of a short, wide strip
   — a taller block makes the globe bigger and the whole dashboard read square-ish. */
.ns-ans .gd-dash { min-height: 460px; }

/* Narrow surfaces: stack the panel under the globe. */
@media (max-width: 620px) {
  .gd-dash { flex-direction: column; }
  .gd-side { flex-basis: auto; flex-direction: row; flex-wrap: wrap; }
  .gd-side-title { flex-basis: 100%; }
  .gd-kpis { flex: 1 1 140px; }
  .gd-panel { flex: 2 1 200px; }
}

/* ── Authoring focus mode (body.gf-globe-dash, set only by the globe Open) ──
   Let the dashboard fill the FULL vertical extent of the sheet canvas instead
   of sitting top-aligned at its 320px min-height. The empty-state container is
   normally top-aligned + scrollable for the question prompt; when the globe is
   embedded we stretch the whole chain so .gd-dash grows edge-to-edge. Scoped to
   the body flag so Erick's regular charts (which have no .gd-dash) are untouched. */
/* The globe is the whole viz — drop the little white "Global shipping" sheet
   title strip above it so the dashboard runs edge-to-edge. */
body.gf-globe-dash .sheet-title { display: none; }
body.gf-globe-dash .sheet-canvas-empty {
  align-items: stretch;
  justify-content: stretch;
  padding: 12px;
  overflow: hidden;
}
body.gf-globe-dash #sheetVisualization,
body.gf-globe-dash #sheetVisualization .gf-embed,
body.gf-globe-dash #sheetVisualization .ns-viz-plot {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
}
body.gf-globe-dash #sheetVisualization .gd-dash {
  flex: 1 1 auto;
  height: auto;   /* let flex own the height so it fills the canvas */
  min-height: 0;
}
