/* ==========================================================================
   BLUEBIRD CLICKER — EXPÉRIENCE SENSORIELLE, SHADERS WEBGL & RADIO LO-FI
   Design System Titanium/Saphir — WebGL Cosmic Canvas, Gamepad HUD, Radio & Visualizer
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Canvas Shaders Fluides WebGL d'Arrière-Plan
   -------------------------------------------------------------------------- */
.cosmic-fluid-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.88;
  transition: opacity 0.6s ease;
  will-change: transform;
}

body.power-saver .cosmic-fluid-canvas {
  opacity: 0.45;
}

/* --------------------------------------------------------------------------
   2. Pulsation Harmonique Réactive sur l'Oiseau Central
   -------------------------------------------------------------------------- */
:root {
  --audio-bass-intensity: 0;
  --audio-bass-scale: 1;
  --audio-bass-glow: 0px;
  --audio-bass-hue: 0deg;
}

.bird-click-target {
  /* Dynamic scale based on real-time bass frequencies from Web Audio API AnalyserNode */
  transform: scale(var(--audio-bass-scale, 1));
  transition: transform 0.06s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.bird-aura {
  box-shadow: 0 0 calc(1.5rem + var(--audio-bass-glow, 0px)) rgba(56, 189, 248, calc(0.35 + var(--audio-bass-intensity, 0) * 0.45));
}

.bird-ring {
  filter: drop-shadow(0 0 var(--audio-bass-glow, 0px) rgba(2, 132, 199, calc(0.2 + var(--audio-bass-intensity, 0) * 0.5)));
}

/* --------------------------------------------------------------------------
   3. Header Shortcut Buttons (Radio & Manette)
   -------------------------------------------------------------------------- */
.btn-radio-header {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(14, 22, 38, 0.75);
  border: 0.0625rem solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: clamp(0.72rem, 1.8vw, 0.8rem);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s var(--ease-smooth);
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.3);
}

.btn-radio-header:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 1rem rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.btn-radio-header.playing {
  border-color: #38bdf8;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.3), rgba(56, 189, 248, 0.15));
  box-shadow: 0 0 0.85rem rgba(56, 189, 248, 0.45);
}

.header-wave-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  width: 14px;
}

.header-wave-bar {
  flex: 1;
  background: var(--accent-cyan);
  border-radius: 1px;
  height: 30%;
  transition: height 0.1s ease;
}

.btn-radio-header.playing .header-wave-bar:nth-child(1) {
  animation: waveBarAnim 0.7s infinite alternate ease-in-out;
}
.btn-radio-header.playing .header-wave-bar:nth-child(2) {
  animation: waveBarAnim 0.9s infinite alternate ease-in-out 0.2s;
}
.btn-radio-header.playing .header-wave-bar:nth-child(3) {
  animation: waveBarAnim 0.6s infinite alternate ease-in-out 0.4s;
}

@keyframes waveBarAnim {
  0% { height: 20%; }
  100% { height: 100%; }
}

/* Gamepad Header Pill */
.btn-gamepad-header {
  display: none;
  align-items: center;
  gap: 0.35rem;
  background: rgba(14, 22, 38, 0.85);
  border: 0.0625rem solid rgba(16, 185, 129, 0.45);
  color: #10b981;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: clamp(0.7rem, 1.6vw, 0.76rem);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-gamepad-header.connected {
  display: inline-flex;
  animation: gamepadGlow 2s infinite alternate;
}

@keyframes gamepadGlow {
  0% { box-shadow: 0 0 0.4rem rgba(16, 185, 129, 0.2); }
  100% { box-shadow: 0 0 0.9rem rgba(16, 185, 129, 0.5); }
}

/* --------------------------------------------------------------------------
   4. Widget Radio Lo-Fi Bluebird Floating Dock
   -------------------------------------------------------------------------- */
.bluebird-radio-dock {
  position: fixed;
  bottom: clamp(1rem, 3vh, 1.8rem);
  left: clamp(1rem, 2.5vw, 1.8rem);
  right: auto;
  z-index: 90;
  width: min(92vw, 22.5rem);
  background: rgba(10, 16, 29, 0.98);
  border: 0.0625rem solid rgba(56, 189, 248, 0.28);
  border-radius: var(--radius-lg);
  box-shadow: 
    0 1.25rem 3.5rem rgba(0, 0, 0, 0.75),
    0 0 1.5rem rgba(2, 132, 199, 0.25),
    inset 0 0 1rem rgba(56, 189, 248, 0.05);
  padding: clamp(0.85rem, 2vw, 1.15rem);
  color: var(--text-main);
  transition: all 0.35s var(--ease-smooth);
  user-select: none;
}

.bluebird-radio-dock.minimized {
  width: auto;
  max-width: max-content;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
}

.bluebird-radio-dock.minimized .radio-header-bar {
  margin-bottom: 0;
  cursor: pointer;
}

.bluebird-radio-dock.minimized .radio-expanded-body {
  display: none;
}

/* Radio Header Bar */
.radio-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: var(--space-xs);
}

.radio-brand-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.radio-logo-icon {
  width: 1.6rem;
  height: 1.6rem;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 0.65rem rgba(56, 189, 248, 0.5);
}

.radio-title-meta {
  display: flex;
  flex-direction: column;
}

.radio-title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.radio-live-badge {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
  border: 0.0625rem solid rgba(239, 68, 68, 0.5);
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.radio-title span { color: var(--accent-cyan); }

.radio-subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.radio-header-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-radio-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 0.0625rem solid var(--surface-border);
  color: var(--text-muted);
  width: 1.6rem;
  height: 1.6rem;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-radio-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: var(--accent-cyan);
}

/* Radio Track Banner */
.radio-track-card {
  background: rgba(4, 8, 18, 0.7);
  border: 0.0625rem solid rgba(56, 189, 248, 0.16);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.65rem;
}

.radio-track-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.radio-track-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.radio-station-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 0.0625rem solid rgba(56, 189, 248, 0.3);
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
}

/* Visualizer Frequency Bars */
.radio-visualizer-container {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2px;
  height: 1.85rem;
  width: 100%;
  padding-top: 0.2rem;
}

.radio-viz-bar {
  flex: 1;
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 60%, rgba(2, 132, 199, 0.2) 100%);
  border-radius: 2px 2px 0 0;
  height: 10%;
  min-height: 2px;
  transition: height 0.05s ease;
  box-shadow: 0 0 0.35rem rgba(56, 189, 248, 0.35);
}

.radio-viz-bar.peak {
  background: linear-gradient(180deg, #f59e0b 0%, #38bdf8 50%, #0284c7 100%);
}

/* Station Switcher Tabs */
.radio-stations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.btn-station-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 0.0625rem solid var(--surface-border);
  color: var(--text-muted);
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  transition: all 0.2s ease;
}

.btn-station-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-station-pill.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.3), rgba(56, 189, 248, 0.15));
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 0.75rem rgba(56, 189, 248, 0.3);
}

.btn-station-pill .station-bpm {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
}

.btn-station-pill.active .station-bpm {
  color: var(--accent-cyan);
}

/* Radio Playback Controls */
.radio-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.25rem;
  border-top: 0.0625rem solid rgba(255, 255, 255, 0.07);
}

.radio-playback-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-radio-ctrl {
  background: rgba(255, 255, 255, 0.07);
  border: 0.0625rem solid var(--surface-border);
  color: var(--text-main);
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-radio-ctrl:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
  transform: scale(1.08);
}

.btn-radio-play-main {
  width: 2.2rem;
  height: 2.2rem;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border: none;
  color: #fff;
  box-shadow: 0 0 0.85rem rgba(56, 189, 248, 0.55);
}

.btn-radio-play-main:hover {
  transform: scale(1.12);
  box-shadow: 0 0 1.25rem rgba(56, 189, 248, 0.8);
}

/* Volume Slider */
.radio-volume-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  max-width: 8.5rem;
}

.radio-vol-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.radio-vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.28rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  transition: background 0.2s;
}

.radio-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 0.5rem rgba(56, 189, 248, 0.7);
  transition: transform 0.15s ease;
}

.radio-vol-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* --------------------------------------------------------------------------
   5. Modal & Notification Guide Manette Gamepad API
   -------------------------------------------------------------------------- */
.gamepad-toast {
  position: fixed;
  bottom: clamp(1rem, 3vh, 1.8rem);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(14, 21, 38, 0.98);
  border: 0.0625rem solid #10b981;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.7), 0 0 1rem rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-pill);
  padding: 0.45rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: all 0.35s var(--ease-elastic);
}

.gamepad-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.gamepad-toast-icon {
  color: #10b981;
  display: flex;
  align-items: center;
}

/* Gamepad Guide Modal Body */
.gamepad-mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.75rem;
  margin-top: var(--space-sm);
}

.gamepad-map-card {
  background: rgba(4, 8, 18, 0.7);
  border: 0.0625rem solid var(--surface-border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.gamepad-key-badge {
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.4rem;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.35), rgba(56, 189, 248, 0.15));
  border: 0.0625rem solid var(--accent-cyan);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 0.5rem rgba(56, 189, 248, 0.3);
}

.gamepad-action-info {
  display: flex;
  flex-direction: column;
}

.gamepad-action-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
}

.gamepad-action-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   6. Responsive Adaptations
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .bluebird-radio-dock {
    bottom: clamp(4.5rem, 9vh, 5.5rem);
    left: 0.75rem;
    right: auto;
    width: calc(100vw - 1.5rem);
    max-width: 22rem;
  }

  .bluebird-radio-dock.minimized {
    width: auto;
    max-width: max-content;
  }
}
