/* ===========================================
   CrateFlow Live — Native Mobile-First App CSS
   =========================================== */

:root {
  --bg0:    #0a0a14;
  --bg1:    #10101e;
  --bg2:    #181828;
  --bg3:    #1e1e30;
  --line:   #2a2a40;
  --text:   #e8eaf6;
  --muted:  #7a7a9a;
  --accent: rgb(0, 255, 200);
  --accent-glow: rgba(0, 255, 200, 0.25);
  --accent-bg:   rgba(0, 255, 200, 0.08);
  --warn:   #e6a23c;
  --good:   #06d6a0;
  --font:   "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:   "JetBrains Mono", monospace;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  touch-action: manipulation;
  min-height: 100%;
  background: var(--bg0);
}

body {
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  padding-bottom: 2rem;
}

/* Background noise & ambient glows */
.noise-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px;
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 70% at 50% -10%, rgba(0, 255, 200, 0.14) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 45%, #080812 100%);
  z-index: 0;
}

/* ---- App Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  font-size: 1.15rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); box-shadow: 0 0 6px var(--accent); }
  50% { transform: scale(1.3); box-shadow: 0 0 14px var(--accent); }
}

.brand-live {
  color: var(--accent);
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-bg);
  border: 1px solid var(--accent-glow);
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.live-badge.offline {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.live-badge.offline .live-dot {
  animation: none;
  background: var(--muted);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.3s step-start infinite;
}
.room-select {
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}
.room-select:focus {
  border-color: var(--accent);
}

/* ---- Container layout ---- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---- Cards ---- */
.card {
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.glass {
  background: linear-gradient(160deg, rgba(24, 24, 40, 0.95), rgba(16, 16, 30, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.section-sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ---- Player Card ---- */
.player-card {
  padding: 1rem;
  gap: 0.85rem;
}

.mixcloud-banner-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  padding: 0.75rem 1rem;
  border-radius: 12px;
}

.banner-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.banner-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.banner-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

.mixcloud-btn {
  background: var(--accent);
  color: #0a0a14;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  text-decoration: none;
  transition: transform 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.mixcloud-btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

.mixcloud-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.audio-player-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  padding: 0.75rem 1rem;
  border-radius: 12px;
}

.audio-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.audio-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

.audio-status {
  font-size: 0.7rem;
  color: var(--muted);
}

audio {
  width: 100%;
  height: 36px;
  border-radius: 6px;
  outline: none;
}

/* ---- Room Selector Card ---- */
.room-selector-card {
  padding: 1rem;
  gap: 0.6rem;
}

.room-selector-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.room-selector-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

/* ---- Custom Audio Player ---- */
.custom-audio-player {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.4rem 0.2rem;
}

.audio-play-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #0a0a14;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
  padding: 0;
}
.audio-play-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bg3);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

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

.volume-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.audio-play-btn:not(:disabled):active {
  transform: scale(0.94);
}

/* Play triangle */
.play-icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 9px 0 9px 13px;
  border-color: transparent transparent transparent #0a0a14;
  margin-left: 3px;
}
/* Pause bars — legacy; stop icon used for live stream */
.pause-icon {
  width: 12px;
  height: 15px;
  border-left: 4px solid #0a0a14;
  border-right: 4px solid #0a0a14;
  box-sizing: border-box;
}
/* Stop square */
.stop-icon {
  width: 14px;
  height: 14px;
  background: #0a0a14;
  border-radius: 2px;
}

.audio-volume-group {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.volume-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 10v4h4l5 5V5L7 10H3zm13.5 2a4.5 4.5 0 0 0-2.5-4.03v8.06A4.5 4.5 0 0 0 16.5 12z'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 10v4h4l5 5V5L7 10H3zm13.5 2a4.5 4.5 0 0 0-2.5-4.03v8.06A4.5 4.5 0 0 0 16.5 12z'/%3E%3C/svg%3E") no-repeat center / contain;
}

.volume-slider {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bg3);
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

/* ---- Meta Card (Telemetry: BPM, KEY, ENERGY) ---- */
.meta-card {
  gap: 0.75rem;
}

.meta-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.meta-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--accent-bg);
  border: 1px solid var(--accent-glow);
  color: var(--accent);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.now-meta-row {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
}

.now-meta-row.transition-next:not(.inactive) {
  border-color: rgba(0, 255, 200, 0.3);
  background: rgba(0, 255, 200, 0.04);
}

.now-meta-row.transition-next.inactive .meta-val {
  color: var(--muted);
}

.meta-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 0.4rem;
  gap: 0.2rem;
  border-right: 1px solid var(--line);
}
.meta-block:last-child { border-right: none; }

.meta-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
}

.meta-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
}

.meta-val.mono { font-family: var(--mono); }

/* ---- Genre Section ---- */
.genre-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 2rem;
}

.genre-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.genre-btn:hover {
  border-color: rgba(0, 255, 200, 0.35);
  color: var(--accent);
}

.genre-btn .pct {
  color: var(--muted);
  font-size: 0.7rem;
  font-family: var(--mono);
}

.genre-btn.active .pct {
  color: rgba(0, 255, 200, 0.75);
}

.genre-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ---- Rating Buttons ---- */
.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.rating-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0.7rem 0.2rem;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}

.rating-btn:not(:disabled):active {
  transform: scale(0.96);
}

.rating-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

.rating-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ---- Identity Row ---- */
.identity-row {
  display: flex;
  gap: 0.5rem;
}

.identity-row input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
}

.identity-row input:focus {
  border-color: var(--accent);
}

.identity-row button {
  background: var(--accent-bg);
  border: 1px solid var(--accent-glow);
  color: var(--accent);
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }
