/* ============================================================================
   astrochart — chart-level controls
   ----------------------------------------------------------------------------
   The floating control bar (reset, aspect toggles, settings, help) and the
   two modals (settings, keyboard help). Settings uses only button controls:
   switch rows for display toggles, and button menus for theme / wheel style.
   No native selects (they glitch inside fixed/overflow modals).
   ============================================================================ */

/* --- control bar — sits above the wheel, never over the chart ----------- */
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.chart-control-btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--ink-secondary);
  background: var(--bg-surface);
  border: 0.5px solid var(--ink-quaternary);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}
@media (max-width: 720px) {
  .chart-controls {
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .chart-control-btn {
    min-height: 44px;
    flex: 0 0 auto;
    font-size: 10px;
    letter-spacing: 0.1em;
  }
}
.chart-control-btn:hover {
  color: var(--ink-primary);
  border-color: var(--ink-tertiary);
}
.chart-control-btn:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}
.chart-control-btn.is-active {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

/* --- toggle effects on the chart ----------------------------------------- */
svg.chart.hide-aspects .ring-aspects { display: none; }
svg.chart.hide-minor-aspects .aspect-line[data-is-major="false"] { display: none; }
svg.chart.hide-degrees .degree-text,
svg.chart.hide-degrees .sign-label { display: none; }
svg.chart.hide-markers .marker { display: none; }

/* --- modal shell --------------------------------------------------------- */
body.chart-modal-open {
  overflow: hidden;
}

.chart-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out),
              visibility var(--duration-base) var(--ease-out);
}
.chart-modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.chart-modal-overlay[hidden] {
  display: none !important;
}
.chart-modal-overlay.is-open[hidden] {
  display: flex !important;
}

.chart-modal {
  position: relative;
  z-index: 1;
  width: min(440px, 92vw);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 0.5px solid var(--ink-quaternary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  /* No transform on the dialog: transform + overflow breaks hit-testing
     and OS-drawn controls in Safari/Chrome. */
  overflow: hidden;
}

.chart-modal-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-shrink: 0;
  padding: var(--space-5);
  border-bottom: 0.5px solid var(--ink-quaternary);
}
.chart-modal-title {
  font-family: var(--font-display);
  font-weight: var(--weight-light);
  font-size: var(--text-lg);
  color: var(--ink-primary);
}
.modal-close-btn {
  cursor: pointer;
  touch-action: manipulation;
  min-width: 36px;
  min-height: 36px;
}
.chart-modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-group { margin-bottom: var(--space-5); }
.modal-group:last-child { margin-bottom: 0; }
.modal-group-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-wide);
  color: var(--ink-tertiary);
  margin-bottom: var(--space-3);
}

/* --- display switches (button rows, not checkboxes) -------------------- */
.modal-switch-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 0.5px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.modal-switch:hover {
  background: var(--bg-deep);
  color: var(--ink-primary);
}
.modal-switch:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}
.modal-switch.is-on {
  color: var(--ink-primary);
}
.modal-switch-label {
  flex: 1 1 auto;
}
.modal-switch-state {
  flex-shrink: 0;
  min-width: 2.5rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0.5px solid var(--ink-quaternary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--ink-tertiary);
  text-align: center;
}
.modal-switch.is-on .modal-switch-state {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background: var(--accent-gold-soft, color-mix(in oklab, var(--accent-gold) 14%, transparent));
}

/* --- chart look: button menus (not native selects) --------------------- */
.modal-choice {
  position: relative;
  margin-bottom: var(--space-3);
}
.modal-choice:last-of-type { margin-bottom: 0; }
.modal-choice-label {
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}

.modal-menu-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-deep);
  color: var(--ink-primary);
  border: 0.5px solid var(--ink-quaternary);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.modal-menu-trigger:hover {
  border-color: var(--ink-tertiary);
}
.modal-menu-trigger:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
  border-color: var(--accent-gold);
}
.modal-choice.is-open .modal-menu-trigger {
  border-color: var(--accent-gold);
}
.modal-menu-value {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-menu-chevron {
  flex-shrink: 0;
  color: var(--ink-tertiary);
  font-size: 12px;
  line-height: 1;
}

.modal-menu {
  /* JS pins this to position:fixed against the trigger so the scrolling
     modal body never clips options or steals clicks. */
  z-index: 600;
  max-height: min(240px, 40vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px;
  background: var(--bg-elevated, var(--bg-surface));
  border: 0.5px solid var(--ink-quaternary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md, 0 12px 32px rgba(0, 0, 0, 0.35));
}
.modal-menu[hidden] {
  display: none !important;
}
.modal-menu-item {
  display: block;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.modal-menu-item:hover,
.modal-menu-item:focus-visible {
  background: var(--bg-deep);
  color: var(--ink-primary);
  outline: none;
}
.modal-menu-item.is-selected {
  color: var(--accent-gold);
  background: var(--accent-gold-soft, color-mix(in oklab, var(--accent-gold) 12%, transparent));
}

.modal-note {
  margin: var(--space-4) 0 0;
  padding: var(--space-3);
  background: var(--bg-deep);
  border: 0.5px solid var(--ink-quaternary);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  color: var(--ink-tertiary);
}

/* keyboard help table */
.shortcut-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 0.5px solid var(--ink-quaternary);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-keys { display: flex; gap: var(--space-1); }
.shortcut-key {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-primary);
  background: var(--bg-deep);
  border: 0.5px solid var(--ink-quaternary);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
}
.shortcut-desc {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}

@media (prefers-reduced-motion: reduce) {
  .chart-modal-overlay { transition-duration: 0.01ms !important; }
}
