/* ============================================================================
   Planetary Health Check 2026 — interactive "Great Acceleration" figure.
   Companion stylesheet to figures.css (which supplies the theme tokens, the
   password gate, the ambient background and the shared .fig-* chrome). This
   file only adds the toolbar segmented controls, the SVG grid sizing and the
   hover read-out.
   ========================================================================== */

/* ── Toolbar (view + metric segmented controls) ─────────────────────────────*/
.ga-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin: 0 0 14px;
}
.ga-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--phc-border);
  border-radius: 12px;
  background: var(--phc-stage);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ga-seg-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--phc-text-faint);
  padding: 0 8px 0 6px;
}
.ga-seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--phc-text-dim);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s var(--phc-ease-soft), color 0.2s var(--phc-ease-soft);
}
.ga-seg-btn:hover:not(:disabled) { color: var(--phc-text); }
.ga-seg-btn.is-active {
  color: var(--phc-text);
  background: var(--phc-hover);
  box-shadow: inset 0 0 0 1px var(--phc-border);
}
/* Indexed is Charts-only — greyed out while the Stripes view is showing. */
.ga-seg-btn:disabled,
.ga-seg-btn.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* ── Button hover tooltips (what each view / metric means) ───────────────────*/
/* Left-anchored so the leftmost button never clips at the viewport edge; shown
   on hover and keyboard focus. Touch devices have no hover, so these stay out
   of the way on mobile. */
.ga-seg-btn[data-tip] { position: relative; }
.ga-seg-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 11px);
  left: 0;
  width: max-content;
  max-width: 240px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--phc-readout-bg);
  border: 1px solid var(--phc-tip-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  color: var(--phc-text);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  text-align: left;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.16s var(--phc-ease-soft), transform 0.16s var(--phc-ease-soft);
  z-index: 20;
}
/* little arrow tucked under the bubble, near the button's left edge */
.ga-seg-btn[data-tip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 6px);
  left: 16px;
  width: 9px;
  height: 9px;
  background: var(--phc-readout-bg);
  border-right: 1px solid var(--phc-tip-border);
  border-bottom: 1px solid var(--phc-tip-border);
  transform: rotate(45deg) translateY(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s var(--phc-ease-soft), transform 0.16s var(--phc-ease-soft);
  z-index: 21;
}
.ga-seg-btn[data-tip]:hover::after,
.ga-seg-btn[data-tip]:focus-visible::after { opacity: 1; transform: translateY(0); }
.ga-seg-btn[data-tip]:hover::before,
.ga-seg-btn[data-tip]:focus-visible::before { opacity: 1; transform: rotate(45deg) translateY(0); }
/* Disabled buttons don't fire :hover reliably across browsers, but keep the tip
   readable if it does show. */
.ga-seg-btn:disabled[data-tip]:hover::after,
.ga-seg-btn:disabled[data-tip]:hover::before { opacity: 1; }

/* ── The SVG grid ───────────────────────────────────────────────────────────*/
/* No outline around the 24-chart box (the grid reads as the panel itself). */
.fig-stage { border: 0; }
.ga-chart { line-height: 0; }
.ga-chart .ga-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  overflow: hidden;
}
.ga-chart[aria-busy="true"] { min-height: 420px; }
.fig-stage.is-fullscreen .ga-chart { max-width: min(98vw, 1800px); }
.fig-stage.is-fullscreen .ga-svg { max-height: calc(100vh - 120px); width: auto; }

/* ── Hover read-out ─────────────────────────────────────────────────────────*/
.ga-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  pointer-events: none;
  min-width: 110px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--phc-readout-bg);
  border: 1px solid var(--phc-tip-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  color: var(--phc-text);
  opacity: 0;
  transition: opacity 0.14s var(--phc-ease-soft);
  will-change: transform;
  /* column stack so the name can never sit on top of the value row */
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.2;
}
.ga-tip.is-on { opacity: 1; }
.ga-tip-name {
  position: static;
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--phc-text-dim);
  margin: 0;
}
.ga-tip-row {
  position: static;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}
.ga-tip-row b { font-size: 0.95rem; font-weight: 700; }
.ga-tip-val { font-size: 0.88rem; color: var(--phc-text); font-variant-numeric: tabular-nums; }

/* ── Per-indicator references (below the About section) ─────────────────────*/
.ga-refs-subhead {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 22px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--phc-border);
}
.ga-refs-subhead.ga-refs-socio { color: var(--phc-ga-socio, #c2410c); }
.ga-refs-subhead.ga-refs-bio { color: var(--phc-ga-bio, #0f766e); }
:root[data-theme="dark"] .ga-refs-subhead.ga-refs-socio { color: #f59e6b; }
:root[data-theme="dark"] .ga-refs-subhead.ga-refs-bio { color: #5eead4; }
/* Numbered list with each indicator as a small stacked block. */
.ga-refs-detailed { gap: 16px; counter-reset: none; }
.ga-refs-detailed li { display: flex; flex-direction: column; gap: 3px; }
.ga-ref-unit {
  display: inline;
  margin-left: 8px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--phc-text-faint);
  white-space: nowrap;
}
.ga-ref-desc { color: var(--phc-text-dim); font-size: 0.84rem; line-height: 1.5; }
.ga-ref-cite {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--phc-text-faint);
  padding-left: 0.9em;
  text-indent: -0.9em;
}

@media (max-width: 640px) {
  .ga-toolbar { gap: 10px 12px; }
  .ga-seg-btn { padding: 6px 11px; font-size: 0.8rem; }
  .ga-ref-unit { display: block; margin-left: 0; margin-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .ga-seg-btn, .ga-tip { transition: none; }
}
