/* Cassette-deck page (cassettes#show) — the rail · main · dock layout
   (ADR-016). The tape visualization itself lives in cassette-shell.css.
   Colours are theme tokens (themes.css) so the deck holds up across every
   theme; the marker font (--font-marker) carries the vintage identity on
   labels, the now-playing title and section headings. */

.page--deck {
  max-width: 1560px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
}

.deck {
  /* Neutrals derived from tokens so light + dark themes both read well. */
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --soft: color-mix(in srgb, var(--text) 5%, transparent);
  --soft-2: color-mix(in srgb, var(--text) 8%, transparent);

  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 340px;
  gap: 1.25rem;
  align-items: start;
}

/* Shared panel surface — soft chrome, no more toy borders / hard shadows. */
.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem 1.25rem;
}

.panel-label,
.rail-label {
  font-family: var(--font-marker);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ============ LEFT RAIL ============ */
.deck-rail {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 0.7rem;
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-group .rail-label { padding: 0 0.6rem; margin-bottom: 0.4rem; }

.rail-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.92rem;
  transition: background 0.12s ease, color 0.12s ease;
}
.rail-link:hover { background: var(--soft); color: var(--text); text-decoration: none; }
.rail-link.is-active {
  color: var(--text);
  background: var(--wash-accent);
  box-shadow: inset 3px 0 0 var(--accent-strong);
}
.rail-ico { width: 20px; text-align: center; opacity: 0.85; font-size: 0.95rem; }

.rail-foot {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rail-foot .theme-select { max-width: 100%; width: 100%; }

/* ============ MAIN COLUMN ============ */
.deck-main { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

.now-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.75rem;
  align-items: center;
  background:
    radial-gradient(560px 220px at 12% 0%, var(--wash-accent), transparent 60%),
    var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.5rem 1.75rem;
}

/* The tape shrinks into a "now playing" hero. The layout box of a scaled
   element keeps its pre-transform size, so negative margins collapse the
   empty space down to the *visual* footprint (534x335 → ~332x209 at 0.62). */
.now-cassette { display: grid; place-items: center; }
.now-cassette .cassette-wrap { margin: 0; }
.now-cassette .cassette {
  transform: scale(0.62);
  transform-origin: center;
  margin: -63px -101px;
}

.now-info { min-width: 0; }
.now-track {
  font-family: var(--font-marker);
  font-size: 2rem;
  line-height: 1.15;
  color: var(--text);
  margin-top: 0.35rem;
  text-wrap: balance;
}
.now-album { color: var(--text-dim); margin-top: 0.35rem; font-size: 0.95rem; }

.now-seek { margin-top: 1.4rem; }
.deck .progress-bar {
  position: relative;
  height: 8px;
  background: var(--soft-2);
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
}
.deck .progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 999px;
  transition: width 0.1s linear;
}
.progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-top: 0.5rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* --- source picker (tabs + lists) --- */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel-tabs { display: flex; gap: 0.3rem; }
.panel-tab {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.12s ease;
}
.panel-tab:hover { color: var(--text); }
.panel-tab.active { background: var(--accent); border-color: var(--accent-strong); color: var(--paper); }

.cassette-filter {
  flex: 0 1 200px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
.cassette-filter::placeholder { color: var(--text-dim); }
.cassette-filter:focus { border-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Albums render as a cover grid; artists / favorites as tidy rows. */
.album-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  max-height: 340px;
  overflow-y: auto;
  padding: 0.15rem;
}
.album-item {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.6rem;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.album-item:hover { background: var(--soft); border-color: var(--line); transform: translateY(-2px); }
.album-item.active { border-color: var(--accent); background: var(--wash-accent); }
.album-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  object-fit: cover;
  background: var(--accent-3);
}
.album-thumb--empty {
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--paper);
  background: linear-gradient(135deg, var(--accent-3), var(--accent-strong));
}

.artist-list,
.favorite-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 340px;
  overflow-y: auto;
  padding: 0.15rem;
}
.artist-item,
.favorite-item {
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.artist-item:hover,
.favorite-item:hover { background: var(--soft); border-color: var(--line); }
.artist-item.active,
.favorite-item.active { border-color: var(--accent); background: var(--wash-accent); }

.album-info { min-width: 0; }
.album-title {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.album-artist { font-size: 0.8rem; color: var(--text-dim); }

/* ============ RIGHT DOCK ============ */
.deck-dock {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 1rem;
}

.transport-panel .panel-label { display: block; margin-bottom: 1rem; }

.transport-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}
.transport-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--soft-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.transport-btn:hover { background: var(--soft); }
.transport-btn:active { transform: scale(0.94); }
.transport-btn svg { width: 22px; height: 22px; fill: var(--text); }
.transport-btn.play {
  width: 64px;
  height: 64px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
}
.transport-btn.play svg { fill: var(--paper); width: 26px; height: 26px; }

.fx-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}
.knob-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}
.knob-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  white-space: nowrap;
}
.knob-label b { color: var(--accent-2); }
.knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--paper) 55%, transparent) 0%, transparent 32%),
    conic-gradient(from 210deg, var(--soft-2), var(--bg) 60%, var(--soft-2));
  border: 1px solid var(--line);
  position: relative;
  cursor: ns-resize;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.35);
}
/* Initial states the controller later overrides via CSSOM — inline style
   attributes are blocked by the CSP (style-src 'self', no unsafe-inline). */
.knob--fx { transform: rotate(-20deg); }
.transport-btn svg[data-cassette-target="pauseIcon"] { display: none; }

.knob::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 3px;
  height: 15px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--accent-2);
  transform-origin: 50% 20px;
}

.visualizer {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 52px;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 8%, var(--bg));
  border: 1px solid var(--line);
}
.visualizer-bar {
  width: 5px;
  height: 8px; /* idle height; the controller drives it per frame while playing */
  background: var(--accent-2);
  border-radius: 2px;
  transition: height 0.1s ease;
}
.visualizer-bar:nth-child(odd) { background: var(--accent); }

/* --- playlist --- */
.playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}
.playlist-count {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.deck .playlist {
  max-height: 360px;
  overflow-y: auto;
  margin: 0 -0.3rem;
  padding: 0 0.3rem;
}
.playlist-track {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.6rem;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.86rem;
  transition: background 0.12s ease;
}
.playlist-track:hover { background: var(--soft); }
.playlist-track.active {
  background: var(--wash-accent);
  box-shadow: inset 3px 0 0 var(--accent-strong);
}
.playlist-track-no {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.playlist-track.active .playlist-track-no { color: var(--accent-2); }
.playlist-track-title {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Custom scrollbars for the scroll regions */
.deck .album-list::-webkit-scrollbar,
.deck .artist-list::-webkit-scrollbar,
.deck .favorite-list::-webkit-scrollbar,
.deck .playlist::-webkit-scrollbar { width: 8px; }
.deck ::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 50%, transparent);
  border-radius: 999px;
}
.deck ::-webkit-scrollbar-track { background: transparent; }

/* --- empty states --- */
.deck .empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-dim);
  font-style: italic;
}
.deck .now-empty { padding: 3rem 1rem; grid-column: 1 / -1; }
.deck .empty-state p { margin: 0 0 1rem; }
.empty-cta {
  display: inline-block;
  padding: 0.6rem 1.3rem;
  background: var(--accent);
  color: var(--paper);
  border-radius: 999px;
  font-weight: 700;
  font-style: normal;
  transition: background 0.15s ease;
}
.empty-cta:hover { background: var(--accent-strong); text-decoration: none; }

/* ============ FLANKING SPEAKERS (ADR-020) ============ */
/* The ADR-015 boombox hardware back on the deck — only where there is real
   room beside the rail·main·dock shell. The page cap widens by exactly the
   two speaker tracks so the rail·main·dock keeps its ≤1560px geometry; the
   speaker height clears the ~80px titlebar plus the deck's own padding so
   the VU panel is fully visible without scrolling. The chassis inherits
   --speaker-pump from .deck (published per frame by cassette_controller). */
.deck-speaker { display: none; }

@media (min-width: 1860px) {
  .page--deck { max-width: 2160px; }
  .deck {
    grid-template-columns:
      minmax(200px, 280px) 210px minmax(0, 1fr) 340px minmax(200px, 280px);
  }
  .deck-speaker {
    display: block;
    position: sticky;
    top: 1rem;
    height: calc(100vh - var(--titlebar-height) - 3.75rem);
    min-height: 520px;
  }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1180px) {
  .deck { grid-template-columns: 190px minmax(0, 1fr); }
  .deck-dock {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    position: static;
  }
  .deck-dock .panel { flex: 1 1 300px; }
}

@media (max-width: 820px) {
  .deck { grid-template-columns: 1fr; }
  .deck-rail { position: static; }
  .deck-rail .rail-group { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .deck-rail .rail-group .rail-label { width: 100%; padding: 0; }
  .now-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .now-info { text-align: center; }
}

@media (max-width: 480px) {
  .now-track { font-size: 1.5rem; }
  .deck-dock { flex-direction: column; }
}
