/* ============================================================
   VIZ 1.1 — Centralized vs. Market
   Two tabs: Topology + Cost & efficiency
   ============================================================ */

.viz11 {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 18px;
  gap: 10px;
}

/* ----- Tab bar at top (same look as Viz 1.2 mode toggle) ----- */
.viz11-header {
  display: flex;
  justify-content: center;
}
.viz11-mode-toggle {
  display: inline-flex;
  background: rgba(26, 36, 54, 0.06);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
body.theme-dark .viz11-mode-toggle {
  background: rgba(255, 255, 255, 0.06);
}
.viz11-tab-btn {
  background: none;
  border: none;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-family: inherit;
}
.viz11-tab-btn:hover { color: var(--text); }
.viz11-tab-btn.active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(26, 36, 54, 0.10);
}
body.theme-dark .viz11-tab-btn.active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.viz11-tab-btn i { font-size: 15px; }

/* ----- Panes (swap on tab change) ----- */
.viz11-pane {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.viz11-pane.active {
  display: flex;
}

/* ----- Canvas area (SVG) ----- */
.viz11-canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viz11-svg, .viz11-cost-svg {
  width: 100%;
  height: auto;
  max-height: 100%;
  font-family: "Lato", -apple-system, sans-serif;
}

/* In dark mode: invert dark-fill text/strokes to light */
body.theme-dark .viz11-svg text[fill="#1a2436"],
body.theme-dark .viz11-svg text[fill="#4a5670"],
body.theme-dark .viz11-cost-svg text[fill="#1a2436"] { fill: #e8e8ef; }
body.theme-dark .viz11-cost-svg text[fill="#8090a8"] { fill: #8090a8; }
body.theme-dark .viz11-svg rect[fill="#1a2436"],
body.theme-dark .viz11-svg circle[fill="#1a2436"] { fill: #0f1220; }
body.theme-dark .viz11-cost-svg rect[fill="rgba(26,36,54,0.08)"] { fill: rgba(255,255,255,0.08); }

/* ----- Controls below canvas (toggle pair, slider, story) ----- */
.viz11-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

/* Centralized / Market toggle (inside Topology tab) */
.viz11-toggle-pair {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.viz11-mode-btn {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.viz11-mode-btn:hover {
  color: var(--text);
  border-color: var(--accent-soft);
}
.viz11-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.viz11-mode-btn.active i { color: #fff; }
.viz11-mode-btn i { font-size: 14px; }

/* Slider (Cost tab) */
.viz11-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.3px;
}
.viz11-slider-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

/* Slider wrapper (to position marks below) */
.viz11-slider-wrap {
  position: relative;
  padding-bottom: 24px;
}

/* Marker ticks + labels under the slider */
.viz11-slider-marks {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  height: 20px;
  pointer-events: none;
}
.viz11-mark {
  position: absolute;
  transform: translateX(-50%);
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.viz11-mark::before {
  content: "";
  width: 1px;
  height: 6px;
  background: var(--text-mute);
  opacity: 0.5;
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
}
.viz11-mark span {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

#viz11-accuracy {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(26, 36, 54, 0.15);
  appearance: none;
  outline: none;
  cursor: pointer;
}
body.theme-dark #viz11-accuracy { background: rgba(255, 255, 255, 0.15); }
#viz11-accuracy::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(26, 36, 54, 0.2);
  transition: transform 0.15s;
}
#viz11-accuracy::-webkit-slider-thumb:hover { transform: scale(1.15); }
#viz11-accuracy::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
  border: 2px solid var(--bg-card);
}

/* Story text (both tabs) */
.viz11-story {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-soft);
  text-align: center;
  font-style: italic;
  padding: 4px 8px;
  min-height: 36px;
}

/* ----- "Show costs" toggle (checkbox) ----- */
.viz11-cost-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  margin-top: -2px;
}
.viz11-cost-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
}
.viz11-cost-toggle span {
  transition: color 0.2s;
}
.viz11-cost-toggle:hover span {
  color: var(--text);
}

/* ----- Pulsing animation for dispatched plants (Cost tab) ----- */
@keyframes viz11-pulse-r {
  0%, 100% { r: 12; stroke-width: 2; }
  50%      { r: 26; stroke-width: 9; }
}
@keyframes viz11-pulse-opacity {
  0%, 100% { fill-opacity: 0.50; }
  50%      { fill-opacity: 1; }
}
.viz11-plant-active circle {
  animation:
    viz11-pulse-r 1.3s ease-in-out infinite,
    viz11-pulse-opacity 1.3s ease-in-out infinite;
}
.viz11-plant-inactive {
  transition: opacity 0.3s;
}

/* ----- Dark mode adjustments for cost toggle ----- */
body.theme-dark .viz11-cost-toggle input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ----- Responsive ----- */
@media (max-width: 900px) {
  .viz11 { padding: 14px 16px; }
  .viz11-tab-btn { padding: 6px 14px; font-size: 12px; }
  .viz11-mode-btn { padding: 6px 12px; font-size: 11px; }
}
