/* ── STEM PLAYER — styles.css ───────────────────────────────────────────────
   Editorial/high-contrast dark theme.
   Palette: deep black + warm off-white + amber accent.
   Font: monospace — references DAW software and book typesetting alike.
   To retheme: edit the --variables in :root only.
─────────────────────────────────────────────────────────────────────────── */


/* ── DESIGN TOKENS ──────────────────────────────────────────────────────── */

:root {
  --bg:        #0a0a0a;   /* page background — very dark */
  --surface:   #1a1a1a;   /* player card surface — lifted slightly for contrast */
  --surface-2: #252525;   /* inset elements (track rows, inputs) */
  --border:    #3a3a3a;   /* dividers — visible but not loud */
  --accent:    #e8a020;   /* warm amber — the only real color */
  --text:      #f5f2ec;   /* warm off-white primary text */
  --text-dim:  #888;      /* de-emphasised labels — readable, not invisible */
  --font:      ui-monospace, 'Courier New', monospace;
  --radius:    4px;

  /* Fade durations — kept in sync with JS constants */
  --fade-fast: 200ms;
  --fade-mid:  400ms;
}


/* ── RESET / BASE ────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  padding: 48px 16px 80px;
}


/* ── PLAYER CARD ─────────────────────────────────────────────────────────── */

.player-container {
  width: 100%;
  max-width: 600px;
}


/* ── PLAYER HEADER ───────────────────────────────────────────────────────── */

.player-header {
  margin-bottom: 24px;
}

.song-title {
  font-size: 22px;
  font-weight: 400;  /* monospace bold is too heavy — keep it regular */
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 20px;
}

/* Time row: [dot] [current] [────seek bar────] [total] */
.time-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.elapsed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background var(--fade-fast);
}

.elapsed-dot--active {
  background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.time-display {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 34px;
  flex-shrink: 0;
}

.time-display--total {
  text-align: right;
}

/* Disabled seek bar — no thumb, dimmed track */
.seek-bar:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}


/* ── RANGE INPUTS ────────────────────────────────────────────────────────── */

/* Shared reset for all range inputs (volume sliders) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
}

/* ── Track (the line) */
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
}
input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
}

/* ── Thumb (the handle) */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5px;  /* vertically centres thumb on the 3px track */
  transition: transform var(--fade-fast);
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.2);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}


/* ── MASTER CONTROLS ─────────────────────────────────────────────────────── */

.master-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

/* Play / pause button — filled circle */
.play-pause-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--bg);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--fade-fast), filter var(--fade-fast), background var(--fade-fast);
  line-height: 1;
  padding: 0;
}

/* Loading state — fill from bottom using gradient */
.play-pause-btn--loading {
  font-size: 10px;
  letter-spacing: 0.02em;
  cursor: default;
}

/* Ready state — solid accent fill like before */
.play-pause-btn--ready {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.play-pause-btn--ready:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: scale(1.05);
}

.play-pause-btn:disabled:not(.play-pause-btn--loading) {
  opacity: 0.25;
  cursor: default;
}

.play-pause-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* "loading…" text — hidden once progress moves to the play button */
.loading-label {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.loading-label--hidden {
  visibility: hidden;
}


/* ── REMIX CONTROLS ──────────────────────────────────────────────────────── */
/* Inspired by Citizen DJ (Library of Congress). Flat outlined buttons —      */
/* distinct from the filled play button, which owns the accent-circle style.  */

.remix-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

/* Base remix button — outlined, not filled */
.remix-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
  cursor: pointer;
  transition: color var(--fade-fast), border-color var(--fade-fast);
}

.remix-btn:hover:not(:disabled) {
  border-color: var(--text-dim);
  color: var(--text);
}

.remix-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.remix-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Record button — accent color when recording is active */
.remix-btn--recording {
  border-color: var(--accent);
  color: var(--accent);
}


/* ── SONG GROUP HEADERS ──────────────────────────────────────────────────── */

/* Labels separating stem sections by song — not interactive, purely visual */
.song-group-header {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 20px 0 8px;
  border-top: 1px solid var(--border);
}

/* First header has no top border — the stem-tracks container already has one */
.song-group-header:first-child {
  border-top: none;
  padding-top: 16px;
}


/* ── SONG COLUMNS (desktop grid children) ────────────────────────────────── */

/* On mobile these are invisible wrappers — layout handled by stem-tracks flex */
.song-column {
  display: contents; /* flatten into parent so mobile layout is unchanged */
}


/* ── STEM TRACKS ─────────────────────────────────────────────────────────── */

.stem-tracks {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

/* Stem row — two-line layout via flex-wrap:
   Line 1: [label] [mute] [◄] [rate] [►]
   Line 2: [──slider──] [%]                */
.stem-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--fade-fast);
}

/* Rate controls group — keeps ◄ 1x ► together as one unit */
.rate-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stem-row-break {
  flex-basis: 100%;
  height: 0;
}

/* Stem name label — shrinks if needed to prevent wrapping */
.stem-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Mute toggle button */
.mute-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--fade-fast), border-color var(--fade-fast), background var(--fade-fast);
  line-height: 1;
  padding: 0;
}

.mute-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

/* Active mute state — accent border signals "this stem is muted" */
.mute-btn--muted {
  border-color: var(--accent);
  color: var(--accent);
}

.mute-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Rate arrow buttons — ◄ slow down, ► speed up */
.rate-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 10px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--fade-fast), border-color var(--fade-fast), opacity var(--fade-fast);
  line-height: 1;
  padding: 0;
}

.rate-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.rate-btn--at-limit {
  opacity: 0.2;
  cursor: default;
}

.rate-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Rate display between arrows */
.rate-display {
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.rate-display--active {
  color: var(--accent);
}

/* Volume slider — line 2, takes all remaining space */
.volume-slider {
  flex: 1;
  min-width: 0;
}

/* Volume percentage readout */
.vol-display {
  width: 34px;
  text-align: right;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-dim);
}

/* Muted row — visually dim everything except the mute button itself */
.stem-row--muted .stem-label,
.stem-row--muted .rate-btn,
.stem-row--muted .rate-display,
.stem-row--muted .volume-slider,
.stem-row--muted .vol-display {
  opacity: 0.3;
}

/* Failed-to-load row — dimmed to signal error without blocking the UI */
.stem-row--error {
  opacity: 0.2;
}


/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */

/* ── Phone (< 768px) — single column, unchanged layout */
@media (max-width: 480px) {
  body {
    padding: 24px 12px 60px;
  }

  .song-title {
    font-size: 18px;
  }

  .stem-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .stem-label {
    width: 100%;
    margin-bottom: 0;
  }
}


/* ── Desktop (≥ 768px) — controls top-left | 3 song columns below */
@media (min-width: 768px) {
  body {
    padding: 48px 32px 80px;
    align-items: flex-start;
  }

  /* 3-column grid — controls sits in col 1, stem-tracks spans all 3 */
  .player-container {
    max-width: 1280px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
  }

  /* Controls panel: first column only, width matches Song 1's column */
  .controls-panel {
    grid-column: 1;
    padding-right: 24px;
    padding-bottom: 24px;
  }

  /* Stem tracks: span full width below controls, use subgrid for column alignment */
  .stem-tracks {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    border-top: 1px solid var(--border);
    padding-top: 0;
  }

  /* Restore song-column from display:contents so grid can target it */
  .song-column {
    display: block;
    padding: 0 24px;
    border-right: 1px solid var(--border);
  }

  .song-column:first-child { padding-left: 0; }
  .song-column:last-child  { border-right: none; padding-right: 0; }

  /* Columns handle visual separation — remove header borders */
  .song-group-header {
    border-top: none;
    padding-top: 16px;
  }

  .song-group-header:first-child {
    padding-top: 16px;
  }

  /* Remove bottom margin from remix controls — panel padding handles spacing */
  .remix-controls {
    margin-bottom: 0;
  }
}


/* ── Large desktop (≥ 1280px) — more breathing room */
@media (min-width: 1280px) {
  .player-container {
    max-width: 1440px;
  }

  .controls-panel {
    padding-right: 32px;
  }

  .song-column {
    padding: 0 32px;
  }
}
