/* FW2-UX-027 — flywheel is the Active Orbit canvas; practical panels must not crush it */

.orbit-optional-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin: 0.25rem 0 0;
  flex-shrink: 0;
}

/*
 * Metric / practical stacks were dumped inside .orbit-stage and stole all
 * vertical flex space (min-height:auto), collapsing #orbit-svg to nothing.
 * Keep them collapsed while the flywheel is the primary surface.
 */
.orbit-stage > #orbit-practical-views {
  flex: 0 0 0;
  margin: 0;
  min-height: 0 !important;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

body.orbit-practical-expanded .orbit-stage > #orbit-practical-views {
  flex: 0 1 auto;
  margin: 0.35rem 0 0;
  min-height: 4rem;
  max-height: min(36vh, 22rem);
  overflow: auto;
  opacity: 1;
  pointer-events: auto;
}

.orbit-practical-views {
  margin: 0;
  min-height: 0;
}

.orbit-practical-panel {
  border: 1px solid var(--fw-border, rgba(255, 255, 255, 0.12));
  border-radius: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: var(--fw-surface-muted, rgba(0, 0, 0, 0.18));
}

.orbit-practical-panel[hidden] {
  display: none !important;
}

.orbit-practical-panel h3 {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.orbit-practical-panel .orbit-practical-empty {
  opacity: 0.72;
  font-size: 0.85rem;
}

.orbit-practical-panel ul {
  margin: 0;
  padding-left: 1.1rem;
}

.orbit-practical-panel li {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

/* Prefer a real flywheel canvas height even if siblings fight for flex */
.orbit-stage > .orbit-workspace {
  flex: 1 1 auto;
  min-height: min(56vh, 460px);
}

/* Pane must be a flex column so .orbit-viz-frame's flex:1 / height:100% resolve */
#flywheel-orbit-pane:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.orbit-viz-column {
  flex: 1 1 auto;
  min-height: 0;
}

.orbit-stage > .orbit-workspace .orbit-viz-frame {
  flex: 1 1 auto;
  min-height: min(52vh, 420px);
}

#orbit-svg {
  flex: 1 1 auto;
  min-height: min(48vh, 380px);
}

.orbit-viz-frame[data-orbit-hidden="true"],
.orbit-workspace[data-orbit-hidden="true"] .orbit-viz-frame {
  display: none;
}

.orbit-workspace[data-orbit-hidden="false"] .orbit-viz-frame,
.orbit-viz-frame[data-orbit-hidden="false"] {
  display: flex;
}

.orbit-workspace[data-orbit-hidden="false"] .orbit-side-panel {
  display: flex;
}

/* VIEW OPTIONS drawer — slim trigger; panel overlays so the flywheel keeps space */
.orbit-optional-drawer {
  position: relative;
  flex-shrink: 0;
  z-index: 28;
  margin-top: 0.15rem;
}

.orbit-optional-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 1.45rem;
  padding: 0.1rem 0.55rem;
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a5b4fc;
  background: rgba(11, 18, 32, 0.85);
  border: 1px solid rgba(129, 140, 248, 0.28);
  border-radius: 8px;
  cursor: pointer;
}

.orbit-optional-trigger:hover,
.orbit-optional-trigger:focus-visible {
  border-color: rgba(129, 140, 248, 0.65);
  color: #c7d2fe;
}

.orbit-optional-trigger:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.65);
  outline-offset: 1px;
}

.orbit-optional-caret {
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

.orbit-optional-drawer:hover .orbit-optional-caret,
.orbit-optional-drawer:focus-within .orbit-optional-caret,
.orbit-optional-drawer.is-open .orbit-optional-caret {
  transform: rotate(180deg);
}

.orbit-optional-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  /* Open upward over the flywheel; .orbit-stage uses overflow:visible so menus stay visible */
  bottom: calc(100% + 0.2rem);
  top: auto;
  z-index: 40;
  padding: 0.55rem 0.65rem 0.65rem;
  background: rgba(8, 13, 26, 0.97);
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 10px;
  box-shadow: 0 -10px 28px rgba(2, 6, 18, 0.55);
}

.orbit-optional-drawer:hover > .orbit-optional-panel,
.orbit-optional-drawer:focus-within > .orbit-optional-panel,
.orbit-optional-drawer.is-open > .orbit-optional-panel {
  display: block;
}

.orbit-optional-panel .orbit-optional-controls {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .orbit-viz-frame {
    animation: none !important;
    transition: none !important;
  }
  .orbit-optional-caret {
    transition: none;
  }
}


/* ----- View Options v2: expanded toolbox + tool effects ----- */
.orbit-optional-panel {
  max-height: min(78vh, 38rem);
  overflow: auto;
  padding: 0.65rem 0.7rem 0.75rem;
  min-width: min(22rem, 92vw);
}

.orbit-optional-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  flex-wrap: nowrap;
}

.vo-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(129, 140, 248, 0.14);
}
.vo-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.vo-section-title {
  margin: 0;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a5b4fc;
  font-weight: 700;
}
.vo-view-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.vo-view-chip.is-active,
.vo-view-chip[aria-pressed="true"] {
  background: linear-gradient(180deg, #818cf8, #4f46e5);
  color: #eef2ff;
  border-color: transparent;
}
.vo-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.3rem;
}
.vo-check {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  min-height: 2rem;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  justify-content: flex-start;
  width: 100%;
  cursor: pointer;
}
.vo-check input {
  margin: 0;
  flex: 0 0 auto;
}
.vo-select {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
}
.vo-select select {
  min-height: 2rem;
  border-radius: 8px;
  border: 1px solid rgba(129, 140, 248, 0.28);
  background: rgba(6, 10, 18, 0.9);
  color: inherit;
  font: inherit;
  padding: 0.25rem 0.4rem;
}
.vo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.vo-actions .chip,
.vo-presets .chip {
  min-height: 1.9rem;
  cursor: pointer;
}
.vo-section-foot {
  gap: 0.25rem;
}
.vo-hint {
  margin: 0;
  opacity: 0.8;
}

.vo-zoom-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.vo-zoom-label {
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: #c7d2fe;
}
.vo-zoom-slider {
  width: 100%;
  accent-color: #818cf8;
  height: 1.25rem;
  cursor: pointer;
}

.vo-pan-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(2.2rem, 1fr));
  gap: 0.3rem;
  max-width: 10.5rem;
  margin: 0.15rem 0 0.25rem;
}
.vo-pan-btn {
  min-height: 2rem !important;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
.vo-pan-spacer {
  display: block;
  min-height: 2rem;
}

/* chrome-clean: click-only open (no hover stack) */
body.chrome-clean .orbit-optional-drawer:hover > .orbit-optional-panel,
body.chrome-clean .orbit-optional-drawer:focus-within > .orbit-optional-panel {
  display: none;
}
body.chrome-clean .orbit-optional-drawer.is-open > .orbit-optional-panel {
  display: block;
}

/* ----- Tool body effects ----- */
body.orbit-hide-hud #orbit-hud {
  display: none !important;
}
body.orbit-hide-legend .orbit-side-panel,
.orbit-side-panel.vo-force-hidden {
  display: none !important;
}
body.orbit-hide-docks #hub-voice,
#hub-voice.vo-force-hidden,
#hub-voice.vo-dock-hidden {
  display: none !important;
}

/* Labels / spokes / status */
body.orbit-hide-labels #orbit-svg .node text,
body.orbit-hide-labels #orbit-svg text {
  opacity: 0 !important;
  pointer-events: none;
}
body.orbit-hide-labels #orbit-svg .node text {
  display: none;
}
body.orbit-hide-spokes #orbit-svg .orbit-spoke,
body.orbit-hide-spokes #orbit-svg line.orbit-spoke {
  opacity: 0 !important;
}
body.orbit-hide-status #orbit-svg .node text[fill="#2dd4bf"],
body.orbit-hide-status #orbit-svg text {
  /* status badges are small mono texts near nodes; hide STBY/ON via size heuristic not reliable.
     Prefer class if present; otherwise leave labels and only hide known status strings via JS-less CSS is hard.
     Hide common status y-offset texts by targeting smaller mono fonts if browsers support: */
}
body.orbit-hide-status #orbit-svg text[font-family*="IBM Plex Mono"],
body.orbit-hide-status #orbit-svg text[font-size="10"],
body.orbit-hide-status #orbit-svg text[font-size="9"] {
  display: none !important;
}

/* Dim idle / non-hot spokes */
body.orbit-dim-idle #orbit-svg .node:not(.node-active):not(.node-orchestrator):not(.is-hot):not(.is-active):not(.active):not(.resident):not(.is-live),
body.orbit-dim-idle #orbit-svg .orbit-spoke:not(.is-hot):not(.is-active):not(.active) {
  opacity: 0.32;
  transition: opacity 160ms ease;
}
body.orbit-dim-idle #orbit-svg .node.node-active,
body.orbit-dim-idle #orbit-svg .node.node-orchestrator,
body.orbit-dim-idle #orbit-svg .node.is-hot,
body.orbit-dim-idle #orbit-svg .node.is-active,
body.orbit-dim-idle #orbit-svg .node.active,
body.orbit-dim-idle #orbit-svg .node.resident,
body.orbit-dim-idle #orbit-svg .node.is-live {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(45, 212, 191, 0.35));
}

/* Compact density */
body.orbit-compact .orbit-hud-cell {
  padding: 0.15rem 0.35rem;
  font-size: 0.72rem;
}
body.orbit-compact .orbit-zoom-controls .chip {
  min-height: 1.5rem;
  padding: 0.1rem 0.4rem;
}
body.orbit-compact #orbit-svg {
  min-height: min(40vh, 320px);
}

/* Large type */
body.orbit-large-type #orbit-svg .node text,
html.orbit-tools-large #orbit-svg .node text {
  font-size: 15px !important;
  font-weight: 600;
}
body.orbit-large-type .orbit-hud-cell,
html.orbit-tools-large .orbit-hud-cell {
  font-size: 0.95rem;
}
body.orbit-large-type .orbit-nav-help {
  font-size: 0.9rem;
}

/* High contrast orbit */
body.orbit-high-contrast .orbit-viz-frame,
html.orbit-tools-contrast .orbit-viz-frame {
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
body.orbit-high-contrast #orbit-svg,
html.orbit-tools-contrast #orbit-svg {
  filter: contrast(1.15) saturate(1.2);
}
body.orbit-high-contrast .orbit-hud-cell {
  background: rgba(0, 0, 0, 0.75);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

/* Night canvas */
body.orbit-night-canvas .orbit-viz-frame,
html.orbit-tools-night .orbit-viz-frame,
body.orbit-night-canvas .orbit-canvas {
  background: radial-gradient(ellipse at center, #0a1020 0%, #03050c 70%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.65);
}
body.orbit-night-canvas #orbit-svg {
  filter: brightness(0.92) saturate(0.9);
}

/* Mono palette */
body.orbit-mono-palette #orbit-svg,
html.orbit-tools-mono #orbit-svg {
  filter: grayscale(0.92) contrast(1.08);
}
body.orbit-mono-palette.orbit-high-contrast #orbit-svg,
html.orbit-tools-mono.orbit-tools-contrast #orbit-svg {
  filter: grayscale(1) contrast(1.25);
}

/* Focus mode — hide secondary chrome around orbit (keep View Options usable) */
body.orbit-focus-mode .orbit-toolbar,
body.orbit-focus-mode .orbit-nav-help,
body.orbit-focus-mode .orbit-pan-hint,
body.orbit-focus-mode #flywheel-adapter-pie-panel,
body.orbit-focus-mode .orbit-status-row {
  opacity: 0.15;
  pointer-events: none;
}
body.orbit-focus-mode .orbit-optional-drawer {
  opacity: 1;
  pointer-events: auto;
  z-index: 40;
}
body.orbit-focus-mode .orbit-optional-trigger {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Alignment grid */
.orbit-align-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background-image:
    linear-gradient(to right, rgba(129, 140, 248, 0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(129, 140, 248, 0.12) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center center;
  border-radius: inherit;
  mix-blend-mode: screen;
}
.orbit-align-grid[hidden] {
  display: none !important;
}
.orbit-viz-frame,
.orbit-canvas {
  position: relative;
}

/* Pan / zoom lock cursor */
body.orbit-pan-locked #orbit-svg.orbit-svg-pannable {
  cursor: default;
}
body.orbit-pan-locked #orbit-svg.orbit-svg-pannable.is-panning {
  cursor: default;
}
body.orbit-zoom-locked #orbit-svg.orbit-svg-pannable {
  cursor: grab;
}
body.orbit-zoom-locked.orbit-pan-locked #orbit-svg.orbit-svg-pannable {
  cursor: default;
}

/* Hide live pulse FX */
body.orbit-hide-pulse #orbit-svg circle animate,
body.orbit-hide-pulse #orbit-svg circle animateMotion,
body.orbit-hide-pulse #orbit-svg .orbit-radar-ring,
body.orbit-hide-pulse #orbit-svg .orbit-sweep {
  display: none !important;
}
body.orbit-hide-pulse #orbit-svg circle[filter] {
  /* keep static nodes */
}

/* Hide guides */
body.orbit-hide-guides .orbit-nav-help,
body.orbit-hide-guides .orbit-pan-hint {
  display: none !important;
}

/* Reduce motion pulses when toggled from View Options */
body.orbit-reduce-motion #orbit-svg .orbit-radar-ring,
body.orbit-reduce-motion #orbit-svg .orbit-sweep,
body.orbit-reduce-motion .orbit-hud-cell.is-live {
  animation: none !important;
}
body.orbit-reduce-motion #orbit-svg animate,
body.orbit-reduce-motion #orbit-svg animateMotion {
  display: none !important;
}

@media (max-width: 640px) {
  .orbit-optional-panel {
    max-height: min(70vh, 30rem);
    min-width: min(18rem, 94vw);
  }
  .vo-check-grid {
    grid-template-columns: 1fr 1fr;
  }
  .vo-pan-pad {
    max-width: 100%;
  }
}
