/* ============================================================
   American Billboard Music — styles.css
   Dark theme matching radio.iatebreakfast.com
   ============================================================ */

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

:root {
  --bg:          #0c0c0c;
  --panel:       #151515;
  --elev:        rgba(255,255,255,.055);
  --elev-2:      rgba(255,255,255,.10);
  --border:      rgba(255,255,255,.085);
  --border-2:    rgba(255,255,255,.16);
  --accent:      #e50914;
  --accent-lt:   #f9525f;
  --ink:         #f2f2f2;
  --ink-dim:     #a9a9a9;
  --ink-faint:   #7d7d7d;
  --on-accent:   #ffffff;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --font-sans:   ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  --transition:  140ms ease;
  --header-h:    60px;
  --player-bar-h:76px;

  /* Legacy aliases so JS-generated markup still works */
  --bg-surface:  var(--panel);
  --bg-elevated: var(--panel);
  --bg-dark:     #111111;
  --bg-teal:     var(--panel);
  --bg-teal-dk:  #0f0f0f;
  --cream:       var(--ink);
  --text-primary:   var(--ink);
  --text-secondary: var(--ink-dim);
  --text-muted:     var(--ink-faint);
  --text-on-dark:   var(--ink);
  --text-on-teal:   var(--ink);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────── */

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-box {
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .06em;
  padding: 4px 9px;
  border-radius: 6px;
  line-height: 1;
}

.logo-text {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.01em;
  color: var(--ink);
  text-transform: uppercase;
}

.tagline {
  font-size: .72rem;
  color: var(--ink-faint);
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ── Sticky player bar ───────────────────────────────────────── */

.sticky-bar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  z-index: 190;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.sticky-art-wrap { flex-shrink: 0; }

.sticky-art {
  width: 48px; height: 48px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent);
}

.sticky-info {
  min-width: 0;
  flex: 0 0 180px;
}

.sticky-title {
  font-weight: 650;
  font-size: .85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.01em;
}

.sticky-artist {
  font-size: .72rem;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticky-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.sticky-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

/* ── Control buttons ─────────────────────────────────────────── */

.ctrl-btn {
  font-size: 1rem;
  color: var(--ink-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  transition: color var(--transition);
  line-height: 1;
}

.ctrl-btn:hover { color: var(--ink); }

.ctrl-btn--play {
  color: var(--on-accent);
  background: var(--accent);
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}

.ctrl-btn--play:hover { background: var(--accent-lt); }

.time-cur, .time-dur {
  font-size: .72rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: .04em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.time-cur { color: var(--accent-lt); }

.progress-bar, .volume-bar {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.12);
  outline: none;
  cursor: pointer;
  border: none;
}

.progress-bar { flex: 1; }
.volume-bar   { width: 72px; }

.progress-bar::-webkit-slider-thumb,
.volume-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.vol-icon { font-size: .82rem; color: var(--ink-faint); }

/* ── Back-to-top ─────────────────────────────────────────────── */

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .72rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--border-2);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: .06em;
  display: none;
  transition: background var(--transition);
}

.back-to-top.visible { display: block; }
.back-to-top:hover { background: var(--elev-2); }

/* ── Main ────────────────────────────────────────────────────── */

.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ── Section labels ──────────────────────────────────────────── */

.section-label {
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 16px;
}

/* ── Decade nav ──────────────────────────────────────────────── */

.decade-nav-section {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}

.decade-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.decade-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: -.01em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.decade-btn:hover { background: var(--elev-2); color: var(--ink); }

.decade-btn.active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Year section ────────────────────────────────────────────── */

.year-section {
  margin-bottom: 48px;
  animation: fadeIn 200ms ease;
}

.year-section-header { margin-bottom: 20px; }

.year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.year-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .95rem;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  letter-spacing: -.01em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.year-btn:hover { background: var(--elev-2); color: var(--ink); }

.year-btn.active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Player section ──────────────────────────────────────────── */

.player-section {
  animation: slideUp 220ms ease;
  margin-bottom: 48px;
  padding-top: calc(var(--player-bar-h) + 12px);
  scroll-margin-top: calc(var(--header-h) + var(--player-bar-h) + 8px);
}

.player-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.back-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .82rem;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: -.01em;
  transition: background var(--transition), color var(--transition);
}

.back-btn:hover {
  background: var(--elev-2);
  color: var(--ink);
}

.player-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: -.02em;
}

.player-container {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 480px;
  display: flex;
  align-items: stretch;
}

/* ── Loading / error ─────────────────────────────────────────── */

.player-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 24px;
  color: var(--ink-dim);
  text-align: center;
}

.player-state h3 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  letter-spacing: -.01em;
}

.player-state p {
  font-size: .82rem;
  max-width: 360px;
  line-height: 1.7;
  color: var(--ink-dim);
}

.player-state code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .8rem;
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink);
}

.player-state-icon {
  font-size: 2.5rem;
  opacity: .4;
  color: var(--ink);
}

.player-state--error .player-state-icon {
  color: var(--accent);
  opacity: .9;
}

/* Spinner */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Grid player ─────────────────────────────────────────────── */

.grid-player {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.art-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0;
  overflow-y: auto;
  background: #0f0f0f;
}

.art-card {
  cursor: pointer;
  overflow: hidden;
  background: var(--panel);
  border: none;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: row;
  align-items: center;
  min-height: 72px;
  transition: background var(--transition);
}

.art-card:last-child { border-bottom: none; }
.art-card:hover  { background: var(--elev); }
.art-card.active { background: var(--elev-2); }
.art-card.active .card-title { color: var(--accent-lt); }

.card-art-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  background: #111;
  overflow: hidden;
}

.card-art {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .3s ease;
}

.card-art.loaded { opacity: 1; }

.card-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.art-card:hover .card-overlay,
.art-card.active .card-overlay { opacity: 1; }

.card-play-icon { font-size: 1.5rem; color: var(--ink); }

.card-rank {
  position: absolute;
  top: 4px; left: 4px;
  font-weight: 700;
  font-size: .6rem;
  color: var(--ink);
  background: rgba(0,0,0,.75);
  padding: 2px 4px;
  border-radius: 3px;
  letter-spacing: .04em;
}

.card-info {
  flex: 1;
  padding: 8px 16px;
  min-width: 0;
  border-top: none;
}

.card-title {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  letter-spacing: -.01em;
  transition: color var(--transition);
  line-height: 1.3;
}

.art-card:hover .card-title { color: var(--ink); }

.card-artist {
  font-size: .75rem;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* ── Hero ────────────────────────────────────────────────────── */

.hero { padding: 48px 0 0; }

.hero-inner {
  max-width: 800px;
  margin: 0 auto;
}

.hero-svg {
  width: 100%;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
  margin-top: 36px;
  padding-bottom: 48px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-num {
  font-weight: 800;
  font-size: 2.2rem;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -.03em;
}

.stat-label {
  font-size: .68rem;
  color: var(--ink-faint);
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ── Footer ──────────────────────────────────────────────────── */

.site-footer {
  background: var(--panel);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 18px 24px;
  font-size: .72rem;
  color: var(--ink-faint);
  letter-spacing: .06em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.bmc-btn {
  display: inline-block;
  font-weight: 650;
  font-size: .78rem;
  letter-spacing: .06em;
  color: var(--on-accent);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 140ms ease;
}

.bmc-btn:hover { background: var(--accent-lt); }

/* ── Animations ──────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* ── Mobile ──────────────────────────────────────────────────── */

@media (max-width: 640px) {
  :root {
    --header-h: 52px;
    --player-bar-h: 64px;
  }

  .main { padding: 0 16px 48px; }
  .header-inner { padding: 0 16px; }
  .logo-text { font-size: 1rem; }
  .tagline { display: none; }

  .decade-nav-section { padding: 20px 0 16px; margin-bottom: 20px; }
  .decade-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
  }
  .decade-btn {
    font-size: .78rem;
    padding: 8px 14px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .year-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .year-btn { padding: 12px 4px; font-size: .82rem; }

  .player-section {
    padding-top: calc(var(--player-bar-h) + 8px);
    scroll-margin-top: calc(var(--header-h) + var(--player-bar-h) + 8px);
  }

  .player-container { min-height: unset; }

  .card-art-wrap { width: 64px; height: 64px; }
  .card-info { padding: 8px 12px; }
  .card-title { font-size: .82rem; }
  .card-artist { font-size: .7rem; }

  .sticky-bar { padding: 8px 10px; gap: 8px; flex-wrap: nowrap; }
  .sticky-art { width: 40px; height: 40px; }
  .sticky-info { flex: 1; min-width: 0; flex-basis: auto; }
  .sticky-progress { flex-wrap: nowrap; min-width: 0; }
  .volume-wrap { display: none; }
  .sticky-controls { gap: 2px; }

  .back-to-top { bottom: 16px; right: 16px; }
  .player-title { font-size: 1rem; }
  .player-header { gap: 10px; margin-bottom: 14px; }
  .hero-stats { gap: 24px; }
}

/* ── Mobile refinements (phones) ─────────────────────────────── */

@media (max-width: 640px) {

  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }

  :root { --player-bar-h: 96px; }

  .sticky-bar {
    flex-wrap: wrap;
    row-gap: 6px;
    column-gap: 10px;
    padding: 8px 12px 10px;
  }
  .sticky-info     { flex: 1 1 0; min-width: 0; }
  .sticky-controls { order: 3; gap: 4px; }
  .sticky-progress { order: 4; flex: 1 0 100%; min-width: 0; gap: 10px; }

  .grid-player { min-height: 0; }
  .art-grid    { overflow-y: visible; }

  .decade-btn { min-height: 44px; padding: 10px 16px; }
  .year-btn   { min-height: 48px; }
  .back-btn   { min-height: 42px; padding: 10px 14px; }
  .art-card   { min-height: 60px; }
  .bmc-btn    { min-height: 44px; display: inline-flex; align-items: center; }

  .ctrl-btn {
    min-width: 42px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
  }
  .ctrl-btn--play { width: 44px; height: 44px; font-size: 1.05rem; }

  .progress-bar, .volume-bar {
    height: 26px;
    background: transparent;
    padding: 0;
  }
  .progress-bar::-webkit-slider-runnable-track,
  .volume-bar::-webkit-slider-runnable-track {
    height: 3px;
    background: rgba(255,255,255,.12);
  }
  .progress-bar::-webkit-slider-thumb,
  .volume-bar::-webkit-slider-thumb {
    width: 16px; height: 16px;
    margin-top: -6.5px;
    background: var(--accent);
  }
  .progress-bar::-moz-range-track,
  .volume-bar::-moz-range-track {
    height: 3px;
    background: rgba(255,255,255,.12);
  }
  .progress-bar::-moz-range-thumb,
  .volume-bar::-moz-range-thumb {
    width: 16px; height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
  }

  .decade-nav {
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    margin: 0 -16px;
    padding: 0 16px 4px;
  }
  .decade-nav::-webkit-scrollbar { display: none; }
  .decade-btn { scroll-snap-align: start; }

  .hero { padding: 28px 0 0; }
  .hero-stats { gap: 20px 28px; margin-top: 24px; padding-bottom: 32px; }
  .stat-num { font-size: 1.75rem; }
  .stat-label { font-size: .62rem; letter-spacing: .1em; }

  .sticky-bar {
    top: auto;
    bottom: 0;
    border-bottom: none;
    border-top: 1px solid var(--border);
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .player-section {
    padding-top: 0;
    scroll-margin-top: calc(var(--header-h) + 8px);
  }
  .year-section { margin-bottom: 20px; }

  body:has(.player-section:not([hidden]) .sticky-bar) .main {
    padding-bottom: calc(var(--player-bar-h) + env(safe-area-inset-bottom) + 16px);
  }
  body:has(.player-section:not([hidden]) .sticky-bar) .site-footer {
    padding-bottom: calc(18px + var(--player-bar-h) + env(safe-area-inset-bottom));
  }
  body:has(.player-section:not([hidden]) .sticky-bar) .back-to-top {
    bottom: calc(var(--player-bar-h) + 12px + env(safe-area-inset-bottom));
  }

  .back-to-top { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .site-footer { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .main { padding-bottom: 32px; }
}

/* ── Small phones ────────────────────────────────────────────── */

@media (max-width: 400px) {
  .year-grid  { grid-template-columns: repeat(3, 1fr); }
  .logo-text  { font-size: .88rem; }
  .logo-box   { font-size: 11px; padding: 3px 7px; }
  .decade-btn { font-size: .74rem; padding: 10px 12px; }
  .hero-stats { gap: 16px 20px; }
  .stat-num   { font-size: 1.5rem; }
  .sticky-art { width: 36px; height: 36px; }
  .time-cur, .time-dur { font-size: .66rem; }
}

/* ── Landscape phones ─────────────────────────────────────────── */

@media (max-height: 460px) and (orientation: landscape) {
  .hero { padding: 20px 0 0; }
  .hero-stats { margin-top: 16px; padding-bottom: 24px; }
  .decade-nav-section { padding: 14px 0 12px; margin-bottom: 16px; }
}

/* ── Touch devices ───────────────────────────────────────────── */

@media (hover: none) and (pointer: coarse) {
  .decade-btn { min-height: 44px; }
  .year-btn   { min-height: 48px; }
  .back-btn   { min-height: 42px; }
  .bmc-btn    { min-height: 44px; display: inline-flex; align-items: center; }
  .ctrl-btn   { min-width: 42px; min-height: 42px;
                display: inline-flex; align-items: center; justify-content: center; }
  .art-card:hover { border-color: transparent; }
  .art-card:hover .card-overlay { opacity: 0; }
}
