/* ==========================================================================
   ELEVATOR, PLEASE! — Cabin Background Music Widget (P4.5)
   Elevator-door control docked in the floor-indicator bar: doors OPEN = music on, CLOSE = music off.
   Strict CSP Compliant (pure static CSS, no external fonts or images)
   ========================================================================== */

/* Docked in the sticky floor-indicator bar (owner decision 2026-10-20): never covers page content,
   store CTAs or the mini-game at any width */
.cabin-indicator-controls {
  gap: 0.5rem;
}

.cabin-music {
  display: flex;
  align-items: center;
}

.cabin-music[hidden] {
  display: none;
}

.cabin-music-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.2rem 0.65rem 0.2rem 0.4rem;
  background: rgba(27, 35, 55, 0.85);
  border: 1px solid var(--cabin-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cabin-music-btn:hover {
  background: rgba(35, 45, 70, 0.95);
  border-color: var(--cabin-gold);
}

.cabin-music[data-state="playing"] .cabin-music-btn {
  border-color: var(--cabin-gold-bright);
  box-shadow: 0 0 10px var(--cabin-gold-glow);
}

/* Miniature landing doors: closed when off, slide apart to reveal the "sound" when playing */
.cabin-music-doors {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 26px;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--cabin-gold);
  border-radius: 4px 4px 2px 2px;
  background: var(--cabin-led-bg);
}

.cabin-music-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background: linear-gradient(180deg, #3a4867 0%, #222c43 100%);
  transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
  z-index: 1;
}

.cabin-music-leaf-left {
  left: 0;
  box-shadow: inset -1px 0 0 rgba(245, 176, 65, 0.6);
}

.cabin-music-leaf-right {
  right: 0;
  box-shadow: inset 1px 0 0 rgba(245, 176, 65, 0.6);
}

.cabin-music[data-state="playing"] .cabin-music-leaf-left {
  transform: translateX(-85%);
}

.cabin-music[data-state="playing"] .cabin-music-leaf-right {
  transform: translateX(85%);
}

/* Loading: doors stay shut (still OFF) while the frame lamp pulses; ON is shown only once playing */
.cabin-music[data-state="loading"] .cabin-music-doors {
  animation: cabinMusicLoading 0.8s ease-in-out infinite alternate;
}

@keyframes cabinMusicLoading {
  0% { box-shadow: 0 0 0 rgba(245, 176, 65, 0); }
  100% { box-shadow: 0 0 10px var(--cabin-gold-glow); }
}

.cabin-music-eq {
  position: absolute;
  inset: 4px 3px 3px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}

.cabin-music-eq span {
  display: block;
  width: 3px;
  height: 40%;
  border-radius: 1px;
  background: var(--cabin-gold-bright);
}

.cabin-music[data-state="playing"] .cabin-music-eq span {
  animation: cabinMusicEq 0.9s ease-in-out infinite alternate;
}

.cabin-music[data-state="playing"] .cabin-music-eq span:nth-child(2) { animation-delay: -0.3s; }
.cabin-music[data-state="playing"] .cabin-music-eq span:nth-child(3) { animation-delay: -0.6s; }

@keyframes cabinMusicEq {
  0% { height: 25%; }
  100% { height: 95%; }
}

.cabin-music-text {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.cabin-music-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.cabin-music-action {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--cabin-gold-bright);
}

/* Narrow bars: drop the "MUSIC" caption (the accessible name keeps it); OPEN/CLOSE stays visible */
@media (max-width: 640px) {
  .cabin-music-label {
    display: none;
  }
}

@media (max-width: 360px) {
  .cabin-indicator-controls {
    gap: 0.3rem;
  }

  .cabin-music-btn {
    gap: 0.3rem;
    padding: 0.2rem 0.4rem 0.2rem 0.3rem;
  }

  .cabin-music-action {
    font-size: 0.78rem;
  }
}

/* Error: visible RETRY label in red plus a red lamp (the polite status message mirrors it for AT) */
.cabin-music[data-state="error"] .cabin-music-action {
  color: #f87171;
}

.cabin-music[data-state="error"] .cabin-music-btn {
  border-color: rgba(239, 68, 68, 0.7);
}

.cabin-music[data-state="error"] .cabin-music-action::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 0.35rem;
  vertical-align: middle;
  border-radius: 50%;
  background: #ef4444;
}

/* Status for assistive technology (visually hidden) */
.cabin-music-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media print {
  .cabin-music {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cabin-music-leaf,
  .cabin-music-btn {
    transition: none !important;
  }

  .cabin-music-eq span,
  .cabin-music-doors {
    animation: none !important;
  }
}
