/* =============================================
   Radiopachanga — Styles
   Light theme, mobile-first
   ============================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #e0e0e0;
  --primary: #e52b1d;
  --primary-hover: #c82516;
  --primary-glow: rgba(229, 43, 29, 0.18);
  --secondary: #1a1a1a;
  --secondary-hover: #333333;
  --text-primary: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;
  --status-live: #16a34a;
  --status-connecting: #d97706;
  --status-stopped: #999999;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.22s ease;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
}

html {
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

/* --- Install Banner (bottom slide-up) --- */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--surface-2);
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  animation: slideUp 0.35s ease forwards;
}

.install-banner[hidden] {
  display: none;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.install-banner__content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.install-banner__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.install-banner__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.install-banner__text strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-banner__text span {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-banner__text em {
  font-style: normal;
  color: var(--primary);
  font-weight: 500;
}

.install-banner__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ios-share-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin: 0 1px;
}

.install-banner--ios .install-banner__text span {
  white-space: normal;
  font-size: 0.78rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
  font-size: 0.85rem;
  padding: 8px 16px;
  transition: background var(--transition), color var(--transition), filter var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn--primary {
  background: var(--primary);
  color: #ffffff;
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--primary-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  color: var(--text-primary);
}

/* --- Install button in header --- */
.install-header-btn {
  display: none; /* shown via JS when prompt available */
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}

.install-header-btn:hover {
  background: var(--primary-hover);
}

.install-header-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.install-header-btn.visible {
  display: inline-flex;
}

/* --- Header bar --- */
.header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top));
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  pointer-events: none; /* only the button is interactive */
}

.header > * {
  pointer-events: auto;
}

/* --- Main Layout --- */
.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 80px 24px 32px;
  width: 100%;
  max-width: 480px;
}

/* --- Logo Section --- */
.logo-section {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.logo {
  position: relative;
  z-index: 2;
  width: min(240px, 65vw);
  height: auto;
  display: block;
  transform-origin: center;
  will-change: transform, filter;
  user-select: none;
  -webkit-user-drag: none;
}

/* Fallback pulse when Web Audio API is unavailable (CORS) */
@keyframes logo-pulse-fallback {
  0%, 100% { transform: scale(1.00); filter: drop-shadow(0 0 0px rgba(229,43,29,0)); }
  50%       { transform: scale(1.40); filter: drop-shadow(0 0 32px rgba(229,43,29,0.55)); }
}

body.is-playing.no-visualiser .logo {
  animation: logo-pulse-fallback 1.6s ease-in-out infinite;
}

/* Pulsing ring */
.logo-ring {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  width: min(240px, 65vw);
  height: min(240px, 65vw);
  border: 2px solid var(--primary);
  opacity: 0;
  will-change: transform, opacity;
}

/* Radial glow */
.logo-glow {
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  width: min(320px, 85vw);
  height: min(320px, 85vw);
  background: radial-gradient(circle, rgba(229, 43, 29, 0.10) 0%, transparent 70%);
  opacity: 0;
  will-change: opacity;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

body.is-playing .logo-glow { opacity: 1; }
body.is-playing .logo-ring { opacity: 1; }

/* --- Status Indicator --- */
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-stopped);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.status--live .status__dot {
  background: var(--status-live);
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.5);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status--live .status__label { color: var(--status-live); }

.status--connecting .status__dot {
  background: var(--status-connecting);
  animation: blink-dot 0.8s ease-in-out infinite;
}

.status--connecting .status__label { color: var(--status-connecting); }

.status--error .status__dot { background: #dc2626; }
.status--error .status__label { color: #dc2626; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

/* --- Player Controls --- */
.player {
  display: flex;
  align-items: center;
  gap: 20px;
}

.player__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.player__btn:active { transform: scale(0.93); }

.player__btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Play/Pause — primary red */
.player__btn--play {
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.player__btn--play svg {
  width: 26px;
  height: 26px;
}

.player__btn--play:hover,
.player__btn--play:focus-visible {
  background: var(--primary-hover);
  box-shadow: 0 6px 28px rgba(229, 43, 29, 0.30);
}

/* Stop — secondary dark */
.player__btn--stop {
  width: 44px;
  height: 44px;
  background: var(--secondary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.player__btn--stop svg { width: 18px; height: 18px; }

.player__btn--stop:hover,
.player__btn--stop:focus-visible {
  background: var(--secondary-hover);
}

/* --- Volume Control --- */
.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 100px;
  max-width: 160px;
}

.volume-control__icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: flex;
  flex-shrink: 0;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.volume-control__icon:hover,
.volume-control__icon:focus-visible { color: var(--text-primary); }

.volume-control__icon svg { width: 20px; height: 20px; }

/* Range slider */
.volume-control__slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  outline: none;
  cursor: pointer;
}

.volume-control__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--secondary);
  cursor: pointer;
  transition: transform var(--transition);
}

.volume-control__slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--secondary);
  border: none;
  cursor: pointer;
}

.volume-control__slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* --- Footer --- */
.footer {
  width: 100%;
  text-align: center;
  padding: 16px 24px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* --- Responsive --- */
@media (max-width: 360px) {
  .app { gap: 22px; padding: 70px 16px 24px; }
  .player { gap: 14px; }
  .volume-control { min-width: 80px; max-width: 120px; }
}

@media (min-width: 768px) {
  .logo { width: 280px; }
  .logo-ring { width: 280px; height: 280px; }
  .logo-glow { width: 380px; height: 380px; }
  .app { gap: 36px; }
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
