/* ==========================================================================
   Quiet Jukebox palette. Classic English pub, heritage colours:
     bottle green walls, mahogany wood, oxblood leather, aged brass, cream.
   Reuse these tokens everywhere. Do not introduce off-palette colours.
   ========================================================================== */
:root {
  --bg:          #14201a;  /* deep bottle green, walls in shadow (Studio/Minster green) */
  --bg-panel:    #1b2a20;  /* raised felt green */
  --bg-inset:    #101913;  /* input wells, darker recesses */
  --wood:        #2a1d12;  /* dark oak / mahogany */
  --border:      #3a2c1c;  /* aged wood hairline */
  --oxblood:     #7a2a2f;  /* burgundy leather */
  --oxblood-soft:rgba(122, 42, 47, 0.20);
  --brass:       #c2a05c;  /* aged brass, the jukebox glow */
  --brass-bright:#ddbd7e;
  --brass-soft:  rgba(194, 160, 92, 0.14);
  --cream:       #d8ccb0;  /* warm parchment text (softened from #ece0c8 to cut halation on the dark ground) */
  --cream-dim:   #bcb09a;  /* muted text (AAA: 7.0:1 on panels, 7.8:1 on bg) */
  --radius: 8px;
}

* { box-sizing: border-box; }

/* Keep the `hidden` attribute authoritative even when an element also has a
   class that sets display (e.g. .overlay { display: flex }). Without this the
   name prompt shows on load and its handlers are never wired. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    radial-gradient(1100px 520px at 50% -8%, #22332700 0%, #22332700 1%),
    radial-gradient(1200px 700px at 50% -12%, rgba(194,160,92,0.06), transparent 55%),
    var(--bg);
  font-family: 'Lora', Georgia, serif;
  font-size: 17px;
  /* Crisper light-on-dark text (Mac/WebKit; ignored on Windows, harmless). */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.brand,
.panel-title,
.now-card h2 {
  font-family: 'Playfair Display', Georgia, serif;
}

/* Small muted/italic lines read thin on the dark ground; give them weight. */
.masthead .hero-sub,
.np-artist, .np-idle, .np-live,
.q-sub, .sel-artist, .chat-here, .me,
.listeners { font-weight: 500; }

/* ---- Inputs & buttons ---- */
input[type=text], textarea {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--cream);
  border-radius: 6px;
  padding: 11px 13px;
  font: inherit;
  width: 100%;
  outline: none;
}
input[type=text]::placeholder, textarea::placeholder { color: var(--cream-dim); }
input[type=text]:focus, textarea:focus { border-color: var(--brass); }
textarea { resize: vertical; min-height: 62px; }

button {
  background: var(--brass);
  color: #1c1509;
  border: 1px solid var(--brass-bright);
  border-radius: 6px;
  padding: 11px 18px;
  font-family: 'Lora', serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--brass-bright); }
button:disabled { opacity: 0.5; cursor: default; }
.btn-primary { width: 100%; margin-top: 11px; }
.btn-ghost { background: transparent; color: var(--cream-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-inset); color: var(--cream); }

.label {
  font-family: 'Lora', Georgia, serif;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brass-bright);
}
.error { color: #d98a86; }
.small { font-size: 14px; }

/* ---- Top bar ---- */
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 16px 26px;
  background: var(--wood);
  border-bottom: 2px solid var(--brass);
  box-shadow: 0 2px 14px rgba(0,0,0,0.35);
  position: sticky; top: 0; z-index: 10;
}
.masthead { grid-column: 2; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; min-width: 0; }
.status { grid-column: 3; justify-self: end; display: flex; align-items: center; }
.brand {
  grid-column: 1; justify-self: start;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 21px; font-weight: 700; color: var(--cream); letter-spacing: 0.4px;
}
.masthead h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 27px; font-weight: 700; line-height: 1.1;
  color: var(--cream); margin: 0;
}
.masthead .hero-sub { margin: 2px 0 0; color: var(--cream-dim); font-size: 16px; font-style: italic; }
.listeners { color: var(--cream-dim); font-size: 15px; display: flex; align-items: center; gap: 7px; }
.listeners .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--brass);
  box-shadow: 0 0 9px var(--brass);
  animation: pulse 2s ease-in-out infinite;
}
.listeners .live-word { color: var(--brass); font-weight: 600; letter-spacing: 0.5px; }
.listeners .sep { opacity: 0.5; }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 9px var(--brass); }
  50%      { opacity: 0.45; box-shadow: 0 0 3px var(--brass); }
}

.me { margin-left: 18px; color: var(--cream-dim); font-size: 15px; font-style: italic; }

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "now    chat"
    "panels chat";
  gap: 28px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 32px;
  align-items: start;
}
.now-card { grid-area: now; }
.stage { grid-area: panels; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.chat { grid-area: chat; }

/* ---- In focus ---- */
.now-card {
  background:
    linear-gradient(180deg, rgba(194,160,92,0.06), transparent 42%),
    var(--bg-panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brass);
  border-radius: var(--radius);
  padding: 42px 44px;
}
.np-idle { text-align: center; padding: 48px 0; }
.np-idle-title { margin: 0; font-family: 'Playfair Display', Georgia, serif; font-size: 30px; color: var(--cream); }
.np-idle-sub { margin: 10px 0 0; color: var(--cream-dim); font-style: italic; font-size: 19px; }
.np-idle-cta {
  margin-top: 24px; padding: 14px 30px; font-size: 18px;
  background: var(--brass); color: #1c1509; border: 1px solid var(--brass-bright); border-radius: 8px;
}
.np-idle-cta:hover { background: var(--brass-bright); }
.np-top { display: flex; gap: 30px; align-items: center; }
.np-art {
  width: 190px; height: 190px; border-radius: 6px; object-fit: cover;
  background: var(--bg-inset); flex-shrink: 0;
  border: 1px solid var(--border);
  box-shadow: 0 16px 36px rgba(0,0,0,0.55);
}
.np-meta { min-width: 0; }
.np-meta .label { margin-bottom: 10px; font-size: 13px; }
.now-card h2 { font-size: 46px; font-weight: 700; margin: 0 0 6px; line-height: 1.08; color: var(--cream); }
.np-artist { color: var(--cream-dim); font-size: 24px; font-style: italic; margin-bottom: 20px; }
.np-links { display: flex; gap: 10px; }
.btn-link {
  display: inline-block; text-decoration: none;
  background: var(--brass); color: #1c1509;
  padding: 7px 16px; border-radius: 6px; font-weight: 600; font-size: 15px;
  border: 1px solid var(--brass-bright);
}
.btn-link:hover { background: var(--brass-bright); }
.btn-link.ghost { background: transparent; color: var(--cream); border-color: var(--border); }
.btn-link.ghost:hover { border-color: var(--brass); }

.np-note-wrap { margin: 22px 0 44px; }
.np-by { font-size: 16px; color: var(--cream-dim); margin-bottom: 18px; }
.np-by strong { color: var(--cream); font-weight: 600; }
.np-note {
  position: relative;
  margin: 0; padding: 2px 0 0 50px;
  font-size: 24px; line-height: 1.5; font-style: italic;
  color: var(--cream);
  white-space: pre-wrap; word-wrap: break-word;
}
.np-note::before {
  content: '\201C';                 /* a big opening quote: this is a story, not a field */
  position: absolute; left: -2px; top: 22px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 72px; line-height: 0; color: var(--brass);
}
.np-note:empty { display: none; }

.progress-bar { height: 8px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brass), var(--brass-bright)); transition: width 0.2s linear; }
.progress-times { display: flex; justify-content: space-between; color: var(--cream-dim); font-size: 16px; margin-top: 9px; font-variant-numeric: tabular-nums; }


/* ---- Panels ---- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
}
.panel-title { margin: 0 0 16px; font-size: 23px; font-weight: 600; color: var(--cream); display: flex; align-items: center; gap: 10px; }
.badge { background: var(--brass-soft); color: var(--brass); border: 1px solid var(--border); border-radius: 20px; padding: 0 9px; font-size: 13px; font-family: 'Lora', serif; }

/* ---- Queue list ---- */
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 15px; }
.queue-list:empty { display: none; }
.queue-list li { display: flex; gap: 15px; align-items: center; }
.queue-list img { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; background: var(--bg-inset); border: 1px solid var(--border); flex-shrink: 0; }
.q-info { min-width: 0; }
.q-title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-sub { color: var(--cream-dim); font-size: 16px; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Up Next is deliberately quiet: it is secondary to the song in focus. */
.upnext-count { color: var(--brass); font-size: 15px; font-weight: 500; font-style: italic; font-family: 'Lora', serif; }
.upnext { display: flex; gap: 11px; align-items: center; }
.un-art { width: 38px; height: 38px; border-radius: 4px; object-fit: cover; background: var(--bg-inset); border: 1px solid var(--border); flex-shrink: 0; }
.un-body { min-width: 0; }
.un-line { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.un-title { color: var(--cream); }
.un-artist { color: var(--cream-dim); font-style: italic; font-weight: 500; }
.un-by { color: var(--cream-dim); font-size: 13px; font-weight: 500; margin-top: 1px; }
.un-by strong { color: var(--cream); font-weight: 600; }
.queue-summary { margin: 0; color: var(--cream-dim); font-size: 16px; font-style: italic; font-weight: 500; }
.upnext + .queue-summary { margin-top: 12px; color: var(--brass); }
.your-position { margin: 10px 0 0; color: var(--brass-bright); font-size: 18px; font-weight: 600; }

/* ---- Recently played (history) ---- */
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history-list li { position: relative; display: flex; gap: 16px; padding: 26px 0; border-top: 1px solid var(--border); }
.history-list li:first-child { border-top: none; padding-top: 4px; }
.history-list img { width: 60px; height: 60px; border-radius: 4px; object-fit: cover; background: var(--bg-inset); border: 1px solid var(--border); flex-shrink: 0; }
.h-body { min-width: 0; flex: 1; }
/* Title + artist flow together; the time is pinned top-right so it never pushes
   the "Queued by" line around. */
.h-head { padding-right: 66px; }
.h-title { font-size: 19px; color: var(--cream); }
.h-artist { color: var(--cream-dim); font-size: 16px; font-style: italic; font-weight: 500; margin-left: 8px; }
.h-time { position: absolute; top: 26px; right: 0; color: var(--cream-dim); font-size: 14px; font-style: italic; font-weight: 500; white-space: nowrap; }
.h-note { position: relative; margin: 8px 0 0; padding: 0 0 0 26px; font-size: 16px; font-style: italic; line-height: 1.45; color: var(--cream); white-space: pre-wrap; word-wrap: break-word; }
.h-note::before { content: '\201C'; position: absolute; left: 0; top: 20px; font-family: 'Playfair Display', Georgia, serif; font-size: 38px; line-height: 0; color: var(--brass); }
.h-note:empty { display: none; }
.h-by { margin: 8px 0 0; color: var(--cream-dim); font-size: 15px; font-weight: 500; }
.h-by strong { color: var(--cream); font-weight: 600; }
.history-more { width: 100%; margin-top: 16px; }

/* ---- Search ---- */
.search-results { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 320px; overflow-y: auto; }
.search-results:empty { margin: 0; }
.search-results li { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 6px; cursor: pointer; }
.search-results li:hover { background: var(--bg-inset); }
.search-results img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; background: var(--bg-inset); border: 1px solid var(--border); }
.dur { margin-left: auto; color: var(--cream-dim); font-size: 14px; font-variant-numeric: tabular-nums; }

.queue-form { margin-top: 16px; }
.selected { display: flex; align-items: center; gap: 12px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 10px; }
.sel-art { width: 46px; height: 46px; border-radius: 4px; object-fit: cover; }
.sel-meta { min-width: 0; }
.sel-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-artist { color: var(--cream-dim); font-size: 14px; font-style: italic; }
.sel-clear { margin-left: auto; background: transparent; color: var(--cream-dim); border: none; padding: 6px 10px; font-size: 18px; }
.sel-clear:hover { color: var(--cream); background: transparent; }

/* ---- Chat ---- */
.chat {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  display: flex; flex-direction: column;
  height: calc(100vh - 138px);
  min-height: 460px;
  position: sticky; top: 112px;
}
.chat-here { color: var(--cream-dim); font-size: 16px; font-weight: 400; font-style: italic; font-family: 'Lora', serif; }
/* Bottom-anchored: newest message sits just above the input, history scrolls up. */
.chat-list { list-style: none; margin: 0; padding: 0 4px 0 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; }
.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  margin: 0; padding: 0 24px; color: var(--cream-dim); font-style: italic; font-size: 16px; line-height: 1.5;
}
.chat-list li { font-size: 15px; line-height: 1.45; }
.chat-list .who { font-weight: 600; color: var(--brass); margin-right: 7px; }
.chat-list .txt { color: var(--cream); }
.chat-list .txt { word-wrap: break-word; }
.chat-error { margin: 10px 0 0; }
.chat-form { display: flex; gap: 9px; margin-top: 12px; }

/* ---- Name prompt overlay ---- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  /* Solid scrim, no backdrop-filter: blurring the whole viewport on every
     repaint made typing in the name box feel laggy. */
  background: rgba(6, 10, 7, 0.9);
  z-index: 50; padding: 20px;
}
.name-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brass);
  border-radius: var(--radius);
  padding: 26px;
  width: 100%; max-width: 340px;
  box-shadow: 0 26px 70px rgba(0,0,0,0.55);
}
.name-card .label { display: block; margin-bottom: 10px; }
.name-actions { display: flex; gap: 10px; margin-top: 12px; }
.name-actions button { flex: 1; }

/* ---- Scrollbars ---- */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--wood); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* The page must never scroll sideways; wide content stays inside its box. */
body { overflow-x: hidden; }

@media (max-width: 900px) {
  /* Stack single-column, and lift Talk right under the song so it is easy to
     reach: song, then chat, then the queue / history panels. */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas: "now" "chat" "panels";
  }
  /* Let grid items shrink instead of forcing the page wider than the viewport. */
  .now-card, .stage, .chat { min-width: 0; }
  .chat { height: 460px; min-height: 0; position: static; }
  /* Header scrolls away on mobile to free vertical space. */
  .topbar { position: static; }
}

@media (max-width: 640px) {
  .topbar { grid-template-columns: 1fr; justify-items: center; gap: 8px; }
  .brand { grid-column: auto; justify-self: center; }
  .masthead { grid-column: auto; }
  .status { grid-column: auto; justify-self: center; }

  /* Now-playing: stack the cover above the text so nothing overflows. */
  .layout { padding: 18px; gap: 20px; }
  .now-card { padding: 24px 22px; }
  .np-top { flex-direction: column; align-items: flex-start; gap: 18px; }
  .np-art { width: 150px; height: 150px; }
  .panel { padding: 20px; }

  /* Smaller type scale on phones */
  .masthead h1 { font-size: 23px; }
  .now-card h2 { font-size: 26px; overflow-wrap: anywhere; }
  .np-artist { font-size: 18px; }
  .np-note { font-size: 20px; }
  .panel-title { font-size: 20px; }
  .np-idle-title { font-size: 25px; }
  .np-idle-sub { font-size: 17px; }
  .h-title { font-size: 17px; }
  .h-artist { font-size: 15px; }
  .h-note { font-size: 15px; }
  .chat-list li { font-size: 15px; }
}
