/* Room layout and components (docs/phase1-ux-spec.md §2.1). Tokens live in theme.css. */

/* ---------- Header ---------- */

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 28px; background: rgba(13, 10, 20, 0.78); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); flex: 0 0 auto;
}
.brand-mark.big { width: 64px; height: 64px; box-shadow: 0 0 0 10px var(--accent-soft); }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0.01em; }
.room-chip { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); padding: 4px 12px; border-radius: 999px; background: var(--surface); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--live); }
.pill.bad { color: var(--danger); }

/* ---------- Page grid ---------- */

.room {
  max-width: 1380px; margin: 0 auto; padding: 24px 28px 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; align-items: start;
  /* Troubleshooting sits under the stage, not under the sticky sidebar, so long search results
     can't slide over it. The spare height of a tall sidebar goes to the second row. */
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "lineup lineup" "main side" "trouble side";
}
.lineup-row { grid-area: lineup; min-width: 0; }
.main-col { grid-area: main; }
.side-col { grid-area: side; position: sticky; top: 84px; max-height: calc(100vh - 100px); }
.trouble-row { grid-area: trouble; min-width: 0; }
.main-col, .side-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 960px) {
  .room { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "lineup" "main" "side" "trouble"; padding: 16px; }
  .side-col { position: static; max-height: none; }
  .app-header { padding: 10px 16px; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* ---------- Lineup (docs/phase1-feedback-spec.md F3) ---------- */

.lineup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.lineup-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.lineup-track { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.lineup-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); flex: 0 0 auto; max-width: 260px; min-width: 0;
  animation: lineup-in 320ms ease-out;
}
.lineup-card.now { background: var(--live-soft); max-width: 380px; padding-left: 8px; }
.lineup-card.mine { box-shadow: inset 0 0 0 1px var(--accent); }
.lineup-card.later { opacity: 0.8; }
.lineup-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lineup-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.now .lineup-label { color: var(--live); }
.lineup-who { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine .lineup-who { color: var(--accent); }
.lineup-song { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineup-empty { margin: 0; padding: 8px; color: var(--faint); display: flex; align-items: center; gap: 8px; font-size: 14px; flex: 1 1 auto; }
.lineup-more { flex: 0 0 auto; }
.lineup-paused { flex: 0 0 auto; }
.lineup-panel { border-top: 1px solid var(--line); padding: 8px; max-height: 360px; overflow-y: auto; }
.lineup-panel .entry[draggable=true] { cursor: grab; }
.lineup-panel .entry.dragging { opacity: 0.4; }
.grip { color: var(--faint); display: grid; place-items: center; width: 18px; flex: 0 0 auto; }
@keyframes lineup-in { from { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) { .lineup-card { animation: none; } }
.add-hint { margin-top: 12px; }

/* ---------- Stage ---------- */

.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
/* The rounded corners are clipped per part, not on the whole stage, so tooltips in the transport
   bar can open past its edge. */
.stage > .player-slot { border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.stage > .now { border-radius: 0 0 var(--radius) var(--radius); }
.player-wrap { aspect-ratio: 16 / 9; background: #000; display: grid; place-items: center; }
.player-wrap iframe { width: 100%; height: 100%; display: block; border: 0; }
.player-wrap .empty { color: var(--faint); padding: 20px; text-align: center; }
.now { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.now-mine { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }
.now-live { background: linear-gradient(90deg, var(--live-soft), transparent 70%); }
.now-text { min-width: 0; flex: 1 1 320px; }
.now-title { font-size: 24px; font-weight: 700; margin-top: 8px; }
.now-sub { color: var(--muted); margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.badge-mine { color: var(--accent); }
.badge-live { color: var(--live); }
.badge-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .badge-live::before { animation: none; } }

/* Reactions (docs/phase1-feedback-spec.md F5): buttons in the stage card, bubbles rising inside it. */
.reactions { display: flex; align-items: center; gap: 6px; flex: 1 1 100%; position: relative; z-index: 1; }
.react-btn { width: 44px; height: 44px; padding: 0; font-size: 22px; border-radius: 50%; background: var(--surface-2); border-color: transparent; }
.react-btn:hover:not(:disabled) { background: var(--surface-3); transform: scale(1.08); }
.react-btn:active:not(:disabled) { transform: scale(0.94); }
.react-vol { margin-left: auto; }
.react-vol input[type=range] { width: 90px; }
.react-float { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bubble {
  position: absolute; bottom: -8px; left: calc(10% + var(--lane, 50%) * 0.8);
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px;
  background: rgba(21, 17, 30, 0.82); border: 1px solid var(--line-strong); white-space: nowrap;
  animation: bubble-up 3s ease-out forwards;
}
.bubble.mine { border-color: var(--accent); }
.bubble-emoji { font-size: 22px; line-height: 1; }
.bubble-name { font-size: 12px; font-weight: 600; color: var(--muted); }
@keyframes bubble-up {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  12% { transform: translateY(-20px) scale(1.1); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(-120px) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .bubble { animation: bubble-fade 3s linear forwards; bottom: 12px; } }
@keyframes bubble-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* Under the video, never over it (docs/phase1-feedback-spec.md F1). */
.transport { display: flex; align-items: center; gap: 18px; padding: 10px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.seek { display: flex; align-items: center; gap: 10px; flex: 1 1 320px; min-width: 0; }
.seek input[type=range] { flex: 1 1 auto; min-width: 0; }
.time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; }
.volumes { display: flex; align-items: center; gap: 18px; margin-left: auto; flex-wrap: wrap; }
.vol { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.vol input[type=range] { width: 110px; }

/* A small (i) that explains a control on hover or keyboard focus. */
.info-tip { position: relative; display: inline-flex; }
.info-tip > button { padding: 2px; border: 0; background: transparent; color: var(--faint); border-radius: 50%; }
.info-tip > button:hover, .info-tip > button:focus-visible { color: var(--text); background: transparent; }
.info-tip .tip {
  /* Opens downward: upward would cover the video, which YouTube's terms don't allow. */
  /* Right-aligned to the icon: the control sits at the right of the bar, and a centered bubble
     would run off narrow screens. */
  position: absolute; top: calc(100% + 8px); right: -8px; z-index: 30;
  width: max-content; max-width: min(280px, 80vw); padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  color: var(--text); font-size: 13px; line-height: 1.45; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity 120ms; pointer-events: none;
}
.info-tip:hover .tip, .info-tip:focus-within .tip { opacity: 1; visibility: visible; }

/* ---------- Get ready ---------- */

.steps { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.steps li.done { opacity: 0.6; }
.steps li.current { box-shadow: inset 0 0 0 1px var(--accent); }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-weight: 600; flex: 0 0 auto; }
.done .step-dot { background: var(--live); color: var(--accent-ink); }
.step-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; font-size: 14px; }

/* ---------- Songs: search, results, queue ---------- */

.songs { display: flex; flex-direction: column; min-height: 0; flex: 0 1 auto; overflow: hidden; }
.people { flex: 0 0 auto; }
.songs > .results, .songs > .queue { display: flex; flex-direction: column; min-height: 0; overflow: hidden; margin-top: 16px; }
.songs .list { overflow-y: auto; }
.search { display: flex; align-items: center; gap: 8px; padding: 5px 5px 5px 14px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line-strong); color: var(--faint); }
.search:focus-within { border-color: var(--accent); }
.search input[type=text] { flex: 1 1 auto; border: 0; background: transparent; padding: 7px 0; outline: none; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.result, .entry { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); }
.result:hover, .entry:hover { background: var(--surface-2); }
.thumb { width: 96px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--surface-3); flex: 0 0 auto; }
.thumb.small { width: 64px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result-text, .entry-text { flex: 1 1 auto; min-width: 0; }
.result-title { font-size: 14px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result .thumb { width: 84px; }
.result-channel { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.result-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.result-state { color: var(--live); font-weight: 600; }
.add-btn { flex: 0 0 auto; width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.add-btn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.add-btn.done:disabled { opacity: 1; color: var(--live); border-color: transparent; background: var(--live-soft); cursor: default; }
.skeleton .thumb, .skeleton .bar { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton .bar { height: 12px; border-radius: 6px; margin: 6px 0; }
.skeleton .bar.short { width: 55%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.notice { margin: 4px 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 14px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.fineprint { font-size: 12px; color: var(--faint); margin: 10px 4px 0; }
.pos { width: 18px; text-align: center; color: var(--faint); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.entry-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-who { font-size: 12px; color: var(--muted); }
.entry-who.you { color: var(--accent); }
.entry.mine { background: var(--accent-soft); }
.empty-state { text-align: center; color: var(--faint); padding: 28px 12px; }
.empty-state p { margin: 8px 0 0; font-size: 14px; }

/* ---------- People ---------- */

.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.people-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.people-list li.away { opacity: 0.45; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; font-weight: 600; flex: 0 0 auto; }
.avatar.singing { background: var(--live); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--live-soft); }
.person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Settings drawer ---------- */

.drawer-root { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.drawer-root.open { pointer-events: auto; }
.scrim { position: absolute; inset: 0; background: rgba(5, 3, 10, 0.55); opacity: 0; transition: opacity 180ms; }
.open .scrim { opacity: 1; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform 200ms ease;
}
.open .drawer { transform: none; }
@media (prefers-reduced-motion: reduce) { .drawer, .scrim { transition: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; }
.drawer-body { overflow-y: auto; padding: 8px 22px 28px; }
.settings-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; }
.settings-section > h3 { margin-bottom: 12px; font-size: 16px; }
.subhead { font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
.meter { flex: 1 1 140px; height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
#meterBar, .meter-bar { height: 100%; width: 0; background: var(--live); transition: width 60ms linear; }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.offset-readout { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--accent); }
.offset-readout small { font-size: 15px; color: var(--muted); font-weight: 500; }

/* ---------- Troubleshooting ---------- */

.trouble { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.trouble > summary { list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; color: var(--muted); font-weight: 500; }
.trouble > summary::-webkit-details-marker { display: none; }
.trouble[open] > summary { color: var(--text); border-bottom: 1px solid var(--line); }
.trouble-body { padding: 18px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 960px) { .trouble-body { grid-template-columns: 1fr; } }
.diag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-content: start; }
.panel { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; }
.panel h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-title h2 { margin: 0; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; font-variant-numeric: tabular-nums; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; }
#log { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; font-size: 13px; }
#log li { padding: 4px 0; border-bottom: 1px solid var(--line); }
#log time { color: var(--faint); margin-right: 8px; font-variant-numeric: tabular-nums; }
#log .err { color: var(--danger); }

/* ---------- Join ---------- */

.join { max-width: 460px; margin: 8vh auto 40px; padding: 0 16px; }
.join-hero { text-align: center; margin-bottom: 28px; }
.join-hero h1 { font-size: 40px; margin-top: 22px; }
.join-hero p { color: var(--muted); margin: 10px auto 0; max-width: 36ch; }
.join-card { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.join-card label { font-weight: 500; }
.join-tips { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.join-tips li + li { margin-top: 3px; }

/* ---------- Report a problem (docs/testing-tools-spec.md §1) ---------- */

.modal-root { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 16px; }
.modal-root .scrim { opacity: 1; }
.modal { position: relative; width: min(480px, 100%); display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.modal textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; resize: vertical; }
.modal textarea:focus { outline: none; border-color: var(--accent); }
.modal-actions { justify-content: flex-end; gap: 10px; }
details.mini > summary { cursor: pointer; margin-top: 14px; }

/* ---------- Toasts ---------- */

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--danger); color: var(--text); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 14px; }

/* ---------- Created rooms: invite, host, 13+, ended (docs/phase1-rooms-spec.md §1) ---------- */

a.brand-name { color: var(--text); text-decoration: none; }
.menu-anchor { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 30; width: min(420px, calc(100vw - 32px));
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.popover p { margin: 0; }
.copy-row { display: flex; gap: 8px; width: 100%; }
.copy-row input[type=text] { flex: 1 1 auto; font-size: 13px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; cursor: pointer; }
.host-tag { margin-left: auto; }
.people-list li .remove-person { margin-left: 4px; }
.people-list li .host-tag + .remove-person { margin-left: 4px; }
.people-list li:not(:has(.host-tag)) .remove-person { margin-left: auto; }
.ended .join-hero p { max-width: 44ch; }
.muted-mark { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.ended-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.button-link { color: var(--muted); font-size: 14px; }

/* ---------- Song card, Sung tonight (docs/fun-spec.md G1) ---------- */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.song-card { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); position: relative; z-index: 1; }
.summary-line { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.summary-song { font-size: 14px; }
.summary-counts { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
.summary-count { font-variant-numeric: tabular-nums; }
.sparkline { width: 100%; height: 28px; display: block; fill: var(--accent); opacity: 0.85; }
.panel-tabs { display: flex; gap: 4px; margin: 10px 0 6px; }
.tab { background: transparent; border-color: transparent; color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.tab.active { background: var(--surface-3); color: var(--text); }

/* ---------- Pitch ribbon (docs/fun-spec.md G2) ---------- */

/* Between the video and the transport bar, never over the video. */
.ribbon { position: relative; height: 90px; border-top: 1px solid var(--line); background: var(--bg); }
.ribbon.ribbon-hidden { height: auto; display: flex; justify-content: flex-end; padding: 2px 8px; }
.ribbon-canvas { display: block; width: 100%; height: 90px; }
.ribbon-toggle { position: absolute; top: 4px; right: 8px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.ribbon-hidden .ribbon-toggle { position: static; }
