/* The Listening Room | Milestone 1 styles.
   Palette tokens are PROPOSED (spec §6); final tokens need owner design review.
   Spotify player surfaces follow Spotify's guidelines (#191414, unaltered art). */
:root {
  --walnut: #3b2a20;
  --walnut-deep: #241a14;
  --ivory: #f5efe3;
  --ivory-dim: #e8dfcf;
  --forest: #3d4a35;
  --burgundy: #6e2a38;
  --brass: #b38b4d;
  --ink: #2a1f18;
  --muted: #5e5045;
  --spotify-surface: #191414;
  --on-spotify: #ffffff;
  --focus: #6e2a38;
  --radius: 10px;
  --nav-h: 60px;
  --player-h: 76px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font: 1rem/1.5 var(--font-body);
}
body.connected { padding-bottom: calc(var(--nav-h) + var(--player-h) + env(safe-area-inset-bottom)); }
h1, h2, .wordmark { font-family: var(--font-display); font-weight: 600; color: var(--walnut); }
h1 { font-size: 1.9rem; margin: 0.2em 0 0.6em; }
h2 { font-size: 1.25rem; margin: 1.2em 0 0.4em; }
a { color: var(--burgundy); }
p { margin: 0.3em 0; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.player :focus-visible { outline-color: var(--brass); }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--walnut); color: var(--ivory); padding: 8px 12px; z-index: 50; }
.skip-link:focus { left: 8px; }

.app-header { padding: 14px 16px 0; }
.wordmark { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; }

.view { padding: 8px 16px 24px; max-width: 760px; margin: 0 auto; outline: none; }

.card { background: #fffaf1; border: 1px solid var(--ivory-dim); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.card ul { padding-left: 1.2em; margin: 0.4em 0; }

button { font: inherit; cursor: pointer; min-height: 44px; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-primary { background: var(--forest); color: var(--ivory); border: 0; border-radius: 999px; padding: 0 20px; }
.btn-secondary { background: transparent; color: var(--burgundy); border: 2px solid var(--burgundy); border-radius: 999px; padding: 0 18px; }
.btn-play { background: transparent; color: var(--forest); border: 2px solid var(--forest); border-radius: 999px; padding: 0 14px; min-width: 72px; }

/* Navigation: bottom bar on phones, side rail on wide screens. */
.main-nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--walnut-deep); z-index: 20;
}
.main-nav a { display: flex; align-items: center; justify-content: center; color: var(--ivory-dim); text-decoration: none; font-size: 0.95rem; }
.main-nav a[aria-current="page"] { color: #fff; font-weight: 600; box-shadow: inset 0 3px 0 var(--brass); }

.banners { position: sticky; top: 0; z-index: 30; padding: 0 16px; max-width: 760px; margin: 0 auto; }
.banner { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; border-radius: var(--radius); padding: 10px 12px; margin-top: 8px; }
.banner-error { background: #f6e3e4; border: 1px solid var(--burgundy); }
.banner-info { background: #e9eee4; border: 1px solid var(--forest); }
.banner-close { background: none; border: 0; font-size: 1.4rem; min-width: 44px; }

/* Search and results */
.search label { display: block; font-weight: 600; margin-bottom: 4px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; min-height: 44px; font: inherit; padding: 0 12px; border: 2px solid var(--muted); border-radius: var(--radius); background: #fff; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.track-list { list-style: none; padding: 0; margin: 0; }
.track-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--ivory-dim); }
.track-meta { min-width: 0; }
.track-meta p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-title { font-weight: 600; }
.track-title a, .track-artists a { color: var(--ink); }

/* Cover art: only resized, never cropped, filtered or overlaid. */
.cover { display: block; object-fit: contain; border-radius: 4px; background: transparent; }
.cover-sm { width: 56px; height: 56px; }
.cover-md { width: 120px; height: 120px; }
.cover-xl { width: min(70vw, 360px); height: min(70vw, 360px); border-radius: 8px; }
.cover-empty { background: var(--ivory-dim); }
.now-card { display: flex; gap: 16px; align-items: center; }

.spotify-attribution { display: inline-flex; align-items: center; }
.spotify-logo { height: 21px; width: auto; min-width: 70px; }
.spotify-logo-missing { font-weight: 700; font-size: 0.9rem; border: 1px dashed currentColor; padding: 1px 6px; border-radius: 4px; }

/* Persistent player (minimized by default) */
.player {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--spotify-surface); color: var(--on-spotify); z-index: 25;
}
.player a { color: var(--on-spotify); }
.player-inner {
  display: grid; grid-template-columns: 56px 1fr auto auto; grid-template-areas: "art meta controls toggle" "progress progress progress brand";
  gap: 4px 12px; align-items: center; padding: 8px 12px; max-width: 1100px; margin: 0 auto;
}
.player-art { grid-area: art; }
.player-meta { grid-area: meta; min-width: 0; }
.player-meta p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.player-title { font-weight: 600; }
.player-artists, .player-album, .player-status { font-size: 0.85rem; opacity: 0.85; }
.player-album { display: none; }
.player-controls { grid-area: controls; display: flex; gap: 4px; }
.player-progress { grid-area: progress; display: flex; align-items: center; gap: 8px; font-size: 0.75rem; }
.player-brand { grid-area: brand; justify-self: end; }
.ctl { background: transparent; color: var(--on-spotify); border: 0; min-width: 44px; font-size: 1.1rem; border-radius: 999px; }
.ctl-main { background: var(--on-spotify); color: var(--spotify-surface); }
.ctl-expand { grid-area: toggle; }
.progress { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.25); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--on-spotify); }
.time { font-variant-numeric: tabular-nums; min-width: 3ch; }
.player .spotify-logo-missing { color: var(--on-spotify); }

/* Expanded player: fills the screen above the navigation. */
.player.expanded { top: 0; overflow-y: auto; }
.player.expanded .player-inner {
  grid-template-columns: 1fr; grid-template-areas: "toggle" "art" "meta" "progress" "controls" "brand";
  justify-items: center; text-align: center; gap: 16px; padding: 16px 16px 24px; max-width: 520px;
}
.player.expanded .ctl-expand { justify-self: end; }
.player.expanded .player-meta { width: 100%; }
.player.expanded .player-meta p { white-space: normal; }
.player.expanded .player-title { font-size: 1.35rem; }
.player.expanded .player-album { display: block; }
.player.expanded .player-progress { width: 100%; }
.player.expanded .player-brand { justify-self: center; }
.player.expanded .ctl { min-width: 56px; min-height: 56px; font-size: 1.4rem; }

@media (min-width: 900px) {
  body.connected { padding-bottom: calc(var(--player-h) + 16px); padding-left: 180px; }
  .main-nav { top: 0; right: auto; width: 180px; height: auto; bottom: 0; display: flex; flex-direction: column; padding: 70px 0 0; }
  .main-nav a { justify-content: flex-start; padding: 12px 24px; flex: 0 0 auto; }
  .main-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--brass); }
  .player { left: 180px; bottom: 0; }
  .player-inner { grid-template-columns: 56px minmax(0, 1fr) auto minmax(200px, 2fr) auto auto; grid-template-areas: "art meta controls progress brand toggle"; }
  .connected .app-header { position: fixed; top: 0; left: 0; width: 180px; z-index: 21; }
  .connected .app-header .wordmark { color: var(--ivory); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
