/**
 * Mode pill — top-bar indicator for orchestration mode.
 *
 * Phase 4 of the mode-pill build. Amber pill for `cascade`, slate pill
 * for `observatory`. 44×44 minimum touch target on mobile per HQ's
 * mobile-first rule and the 2026-04-30 a11y audit.
 *
 * Color tokens:
 *   - cascade  → amber accent (active orchestration, default mode)
 *   - observatory → slate-gray (paused/quiet mode)
 *
 * Sits as the leftmost item in `.top-bar__right` (mounted by app.js).
 */

.mode-pill {
  /* Reset native <button> chrome — match the .btn-icon discipline used
     elsewhere in `.top-bar__right`. */
  background: transparent;
  border: 1px solid transparent;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;

  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 32px;
  border-radius: 999px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  user-select: none;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    transform 80ms ease;
}

.mode-pill__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}

.mode-pill__label-short {
  display: none;
}

/* ── Cascade (amber) ───────────────────────── */
.mode-pill--cascade {
  color: #d4a574;
  background: rgba(212, 165, 116, 0.12);
  border-color: rgba(212, 165, 116, 0.45);
}

.mode-pill--cascade:hover {
  background: rgba(212, 165, 116, 0.18);
  border-color: rgba(212, 165, 116, 0.7);
}

/* ── Observatory (slate) ───────────────────── */
.mode-pill--observatory {
  color: #9aa7b3;
  background: rgba(154, 167, 179, 0.10);
  border-color: rgba(154, 167, 179, 0.35);
}

.mode-pill--observatory:hover {
  background: rgba(154, 167, 179, 0.16);
  border-color: rgba(154, 167, 179, 0.55);
}

.mode-pill:active {
  transform: translateY(1px);
}

.mode-pill:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ── Responsive: ≤480px (phone portrait) ──────────────────────────
   Collapse to dot + single letter so the pill stays compact next to
   the alert badge / TTS / Settings / Logout cluster. Touch target
   stays ≥44×44 via min-height + padding. */
@media (max-width: 480px) {
  .mode-pill {
    padding: 0;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    gap: 4px;
  }

  .mode-pill__label-long {
    display: none;
  }

  .mode-pill__label-short {
    display: inline-block;
    font-size: var(--text-md);
    font-weight: 700;
  }

  .mode-pill__dot {
    display: none;
  }
}

/* ─────────────────────────────────────────────────────────────────
   Confirmation modal (mode-pill-modal)
   ───────────────────────────────────────────────────────────────── */

.mode-pill-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 1000;
  /* Fade-in handled by browser; explicit transition would race the
     focus-on-mount. */
}

.mode-pill-modal {
  background: var(--color-panel, #1c1917);
  border: 1px solid var(--color-border, #2a2622);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  padding: var(--space-5, 24px);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
  color: var(--color-text, #f5f0e8);
  font-family: inherit;
}

.mode-pill-modal__title {
  margin: 0 0 var(--space-3, 12px) 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: var(--text-xl, 22px);
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text, #f5f0e8);
}

.mode-pill-modal__body {
  margin: 0 0 var(--space-3, 12px) 0;
  font-size: var(--text-md, 14px);
  line-height: 1.5;
  color: var(--color-text, #f5f0e8);
}

.mode-pill-modal__body--dim {
  color: var(--color-dim, #9a9088);
  font-size: var(--text-sm, 13px);
}

.mode-pill-modal__actions {
  display: flex;
  gap: var(--space-3, 12px);
  justify-content: flex-end;
  margin-top: var(--space-4, 16px);
}

.mode-pill-modal__actions .btn-icon {
  min-height: 44px;
  padding: 10px 18px;
  cursor: pointer;
}

.mode-pill-modal__confirm {
  background: rgba(212, 165, 116, 0.16);
  border: 1px solid rgba(212, 165, 116, 0.6);
  color: #d4a574;
  font-weight: 600;
}

.mode-pill-modal__confirm:hover {
  background: rgba(212, 165, 116, 0.24);
  border-color: rgba(212, 165, 116, 0.85);
}

/* Mobile stacking for the modal — vertical buttons for thumb reach. */
@media (max-width: 480px) {
  .mode-pill-modal {
    padding: var(--space-4, 16px);
  }

  .mode-pill-modal__actions {
    flex-direction: column-reverse;
    gap: var(--space-2, 8px);
  }

  .mode-pill-modal__actions .btn-icon {
    width: 100%;
  }
}

/* ── Mode panel (per-project overrides, 2026-07-12) ─────────────── */
.mode-panel { max-width: 420px; width: calc(100vw - 32px); }
.mode-panel__rows { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.mode-panel__row {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 2px 2px;
  border-bottom: 1px solid rgba(58, 53, 45, 0.5);
}
.mode-panel__row--global { border-bottom: 0; }
.mode-panel__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mode-panel__dot--cascade { background: var(--color-amber, #d4a574); }
.mode-panel__dot--observatory { background: #7a8fa5; }
.mode-panel__name {
  flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mode-panel__sub { font-size: 10px; font-weight: 500; color: var(--color-dim, #9a9186); }
.mode-panel__segs { display: inline-flex; flex: none; border: 1px solid var(--color-border, #3a352d); border-radius: 8px; overflow: hidden; }
.mode-panel__seg {
  min-width: 40px; min-height: 36px; border: 0; cursor: pointer;
  background: transparent; color: var(--color-dim, #9a9186);
  font-size: 12px; font-weight: 700;
}
.mode-panel__seg + .mode-panel__seg { border-left: 1px solid var(--color-border, #3a352d); }
.mode-panel__seg.is-active { background: var(--color-amber, #d4a574); color: #17150f; }
.mode-panel__inherit {
  flex: none; border: 1px solid #a97e4e; border-radius: 6px;
  background: transparent; color: var(--color-amber, #d4a574);
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
  padding: 4px 7px; min-height: 28px; cursor: pointer; text-transform: uppercase;
}
.mode-panel__inherits {
  flex: none; font-size: 10px; color: var(--color-dim, #9a9186);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.mode-panel__hint {
  font-size: 11px; color: var(--color-dim, #9a9186); padding: 4px 2px 8px;
}
.mode-panel__resetall {
  margin-top: 12px; width: 100%; min-height: 44px;
  border: 1px solid var(--color-border, #3a352d); border-radius: 8px;
  background: transparent; color: var(--color-dim, #9a9186);
  font-size: 12px; cursor: pointer;
}
.mode-panel__resetall:hover { color: var(--color-text, #e8e2d8); border-color: #a97e4e; }
.mode-pill__ovbadge {
  margin-left: 4px; font-size: 9px; font-weight: 800;
  color: var(--color-amber, #d4a574);
}
