/* ============================================================================
 * Pocket Austin — Track 3.7: Spatial Procedural Austin Soundscape
 * Warm ligne claire parchment pill controls & spatial mixer popover
 * ============================================================================ */

/* Fallback shared dock positioning if discovery_layers.css is absent */
#pa-explore-dock {
  position: fixed;
  top: 108px;
  right: 14px;
  z-index: 32;
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}

#pa-explore-dock > * {
  pointer-events: auto;
}

/* Joined compact Audio toggle + mixer chevron pill inside #pa-explore-dock */
.pa-sound-group {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  border: 1.5px solid var(--border, #4a3b2c);
  background: var(--paper, rgba(251, 246, 234, 0.95));
  box-shadow: 0 4px 14px rgba(20, 15, 10, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.pa-sound-group:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(20, 15, 10, 0.26);
}

.pa-sound-group.is-playing {
  border-color: var(--teal, #4c8e88);
  background: rgba(235, 246, 243, 0.96);
}

.pa-sound-group.is-open {
  border-color: var(--accent, #c45735);
}

/* Primary mute/unmute button (overrides standalone .pa-dock-btn chrome cleanly) */
#pa-sound-btn.pa-dock-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px 6px 11px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink, #2c221a);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  cursor: pointer;
  box-shadow: none;
  backdrop-filter: none;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}

#pa-sound-btn.pa-dock-btn:hover {
  background: rgba(74, 59, 44, 0.08);
  transform: none;
}

.pa-sound-group.is-playing #pa-sound-btn.pa-dock-btn {
  color: #1f4643;
}

#pa-sound-btn .pa-sound-ico {
  font-size: 12.5px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Tiny animated equalizer dot/bars when playing */
.pa-sound-eq {
  display: none;
  align-items: flex-end;
  gap: 1.5px;
  height: 10px;
  margin-left: 1px;
}

.pa-sound-group.is-playing .pa-sound-eq {
  display: inline-flex;
}

.pa-sound-eq i {
  display: block;
  width: 2px;
  height: 4px;
  border-radius: 2px;
  background: var(--teal, #4c8e88);
  transform-origin: bottom center;
  animation: paSoundBar 1.05s ease-in-out infinite;
}

.pa-sound-eq i:nth-child(2) {
  height: 8px;
  animation-delay: 0.18s;
  animation-duration: 0.85s;
}

.pa-sound-eq i:nth-child(3) {
  height: 6px;
  animation-delay: 0.36s;
  animation-duration: 1.18s;
}

@keyframes paSoundBar {
  0%, 100% {
    transform: scaleY(0.38);
    opacity: 0.72;
  }
  50% {
    transform: scaleY(1.0);
    opacity: 1;
  }
}

/* Secondary chevron trigger for the spatial mixer popover */
#pa-sound-mixer-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  padding: 0 2px 0 0;
  margin: 0;
  border: none;
  border-left: 1px solid rgba(74, 59, 44, 0.22);
  background: transparent;
  color: var(--ink-muted, #665848);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

#pa-sound-mixer-btn:hover {
  background: rgba(74, 59, 44, 0.10);
  color: var(--ink, #2c221a);
}

.pa-sound-group.is-open #pa-sound-mixer-btn {
  background: var(--accent, #c45735);
  color: #fbf6ea;
  border-left-color: rgba(44, 34, 26, 0.28);
}

#pa-sound-mixer-btn svg {
  width: 11px;
  height: 11px;
  display: block;
  transition: transform 0.16s ease;
}

.pa-sound-group.is-open #pa-sound-mixer-btn svg {
  transform: rotate(180deg);
}

/* ============================================================================
 * Spatial Soundscape Mixer Popover (#pa-sound-popover)
 * ============================================================================ */
#pa-sound-popover {
  position: fixed;
  top: 148px;
  right: 14px;
  z-index: 37;
  width: 314px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 200px);
  display: none;
  flex-direction: column;
  background: rgba(251, 246, 234, 0.96);
  border: 1.5px solid var(--border, #4a3b2c);
  border-radius: 11px;
  box-shadow: 0 10px 30px rgba(20, 15, 10, 0.30);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink, #2c221a);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

#pa-sound-popover.open {
  display: flex;
  animation: paSoundPopIn 0.16s ease-out;
}

@keyframes paSoundPopIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.pa-sound-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 13px 9px;
  border-bottom: 1px solid rgba(74, 59, 44, 0.18);
  background: linear-gradient(180deg, rgba(255, 252, 244, 0.92), rgba(245, 237, 220, 0.56));
}

.pa-sound-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink, #2c221a);
  line-height: 1.15;
}

.pa-sound-sub {
  margin-top: 2px;
  font-size: 10.6px;
  color: var(--ink-muted, #665848);
}

.pa-sound-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pa-sound-state-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(74, 59, 44, 0.34);
  background: rgba(255, 252, 244, 0.9);
  color: var(--ink-muted, #665848);
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.pa-sound-state-pill:hover {
  background: #f1e6ce;
  color: var(--ink, #2c221a);
}

.pa-sound-state-pill.active {
  background: rgba(76, 142, 136, 0.16);
  border-color: var(--teal, #4c8e88);
  color: #1f4d49;
}

.pa-sound-state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(102, 88, 72, 0.48);
}

.pa-sound-state-pill.active .pa-sound-state-dot {
  background: var(--teal, #4c8e88);
  box-shadow: 0 0 0 2px rgba(76, 142, 136, 0.25);
  animation: paSoundDotPulse 1.8s ease-in-out infinite;
}

@keyframes paSoundDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.65; }
}

.pa-sound-close {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(74, 59, 44, 0.26);
  background: rgba(255, 252, 244, 0.85);
  color: var(--ink, #2c221a);
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.14s ease;
}

.pa-sound-close:hover {
  background: #efe3c9;
}

.pa-sound-body {
  padding: 10px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

/* Live spatial status bar */
.pa-sound-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(74, 59, 44, 0.20);
  background: rgba(74, 59, 44, 0.055);
  font-size: 11.4px;
  font-weight: 600;
  color: var(--ink, #2c221a);
  line-height: 1.25;
}

.pa-sound-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(102, 88, 72, 0.45);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

#pa-sound-popover.is-playing .pa-sound-status {
  border-color: rgba(76, 142, 136, 0.36);
  background: rgba(76, 142, 136, 0.085);
}

#pa-sound-popover.is-playing .pa-sound-status-dot {
  background: var(--teal, #4c8e88);
  box-shadow: 0 0 0 3px rgba(76, 142, 136, 0.20);
}

#pa-sound-status-text {
  min-width: 0;
  flex: 1;
}

/* Master Volume Slider Row */
.pa-sound-vol-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid rgba(74, 59, 44, 0.16);
  background: rgba(255, 252, 245, 0.72);
}

.pa-sound-vol-label {
  font-size: 10.6px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted, #665848);
  flex-shrink: 0;
}

#pa-sound-volume {
  flex: 1;
  min-width: 0;
  margin: 0;
  accent-color: var(--accent, #c45735);
  cursor: pointer;
  height: 18px;
}

.pa-sound-vol-val {
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink, #2c221a);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* Toggle Pills Section */
.pa-sound-section-label {
  font-size: 9.8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted, #665848);
  margin: -2px 2px -4px;
}

.pa-sound-pills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.pa-sound-pill {
  position: relative;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 7px 9px 8px;
  border-radius: 8px;
  border: 1.2px solid rgba(74, 59, 44, 0.24);
  background: rgba(255, 252, 245, 0.62);
  color: var(--ink-muted, #665848);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  overflow: hidden;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.pa-sound-pill:hover {
  background: rgba(246, 238, 220, 0.92);
  border-color: rgba(74, 59, 44, 0.45);
}

.pa-sound-pill.active {
  background: rgba(255, 252, 244, 0.98);
  border-color: var(--border, #4a3b2c);
  color: var(--ink, #2c221a);
  box-shadow: 0 2px 6px rgba(20, 15, 10, 0.08);
}

.pa-sound-pill.foley-ping {
  border-color: var(--accent, #c45735);
  background: rgba(196, 87, 53, 0.12);
}

.pa-sound-pill-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.pa-sound-pill-name {
  font-size: 11.6px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pa-sound-pill-switch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.2px solid rgba(74, 59, 44, 0.45);
  background: transparent;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.pa-sound-pill.active .pa-sound-pill-switch {
  background: var(--teal, #4c8e88);
  border-color: #2c221a;
}

.pa-sound-pill[data-layer="music"].active .pa-sound-pill-switch {
  background: var(--accent, #c45735);
}

.pa-sound-pill[data-layer="night"].active .pa-sound-pill-switch {
  background: #6c5b8e;
}

.pa-sound-pill[data-layer="foley"].active .pa-sound-pill-switch {
  background: #9a6c32;
}

.pa-sound-pill-desc {
  font-size: 9.8px;
  color: var(--ink-muted, #665848);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Subtle live spatial activity meter along bottom edge of each toggle pill */
.pa-sound-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.5px;
  background: rgba(74, 59, 44, 0.08);
  pointer-events: none;
}

.pa-sound-meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--teal, #4c8e88);
  transition: width 0.35s ease;
}

.pa-sound-pill[data-layer="music"] .pa-sound-meter-fill {
  background: var(--accent, #c45735);
}

.pa-sound-pill[data-layer="night"] .pa-sound-meter-fill {
  background: #6c5b8e;
}

.pa-sound-pill[data-layer="foley"] .pa-sound-meter-fill {
  background: #9a6c32;
}

.pa-sound-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed rgba(74, 59, 44, 0.18);
  font-size: 10px;
  color: var(--ink-muted, #665848);
}

.pa-sound-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  padding: 0 4px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(74, 59, 44, 0.35);
  background: rgba(255, 252, 244, 0.9);
  color: var(--ink, #2c221a);
  font-size: 9.5px;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Dusk / Night shadow balance */
body.solar-dusk .pa-sound-group,
body.solar-night .pa-sound-group,
body.dusk .pa-sound-group {
  box-shadow: 0 5px 18px rgba(6, 9, 20, 0.42);
}

body.solar-dusk #pa-sound-popover,
body.solar-night #pa-sound-popover,
body.dusk #pa-sound-popover {
  box-shadow: 0 12px 34px rgba(6, 9, 20, 0.48);
}

/* Mobile responsiveness: hide cleanly when mobile shell is active, never overflow */
@media (max-width: 760px) {
  body.pa-mobile-active .pa-sound-group,
  body.pa-mobile-active #pa-sound-popover {
    display: none !important;
  }

  #pa-sound-btn.pa-dock-btn {
    padding: 5px 8px 5px 9px;
    font-size: 11.5px;
  }

  #pa-sound-popover {
    top: 98px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 210px);
  }
}
