/* FretStage Listen: a slim bar over the stage and the room's chat, and the
   transport only for its notices. */
body {
  grid-template-columns: minmax(0, 1fr) var(--chat-w);
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "bar bar" "lost lost" "stage chat" "transport transport";
}

#listen-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  justify-content: flex-end;
  padding: 0 6px 0 14px;
  background: var(--board);
  border-bottom: 1px solid var(--board-line);
}
#listen-room { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
#listen-bar > button:not(.icon) { display: flex; align-items: center; gap: 5px; padding: 3px 10px; font-size: 12px; color: var(--board-dim); border-radius: 999px; }
#listen-bar > button.icon { width: 28px; height: 28px; color: var(--board-dim); background: transparent; border-color: transparent; }
#listen-bar > button:hover { color: var(--board-text); }
#listen-notes[aria-pressed="true"] { color: var(--brass); border-color: var(--brass); }
#listen-bar > #listen-notes[hidden] { display: none; }
/* The part and the view switch, only while the notes are shown. */
#listen-bar > #views { margin-right: 4px; }
#listen-bar > #views button { padding: 3px 10px; font-size: 12px; }
body:is(.audience, :not(.in-room)) :is(#views, #listen-part) { display: none; }
#listen-bar > #listen-part { min-width: 0; max-width: 220px; color: var(--board-text); }
#listen-part[hidden] { display: none; }
#listen-part-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#listen-part > [aria-hidden] { color: var(--board-dim); font-size: 10px; }
body:has(#parts:popover-open) #listen-part { border-color: var(--brass); }
#parts {
  inset: auto;
  min-width: 200px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: calc(100vh - 54px);
  margin: 0;
  padding: 4px;
  overflow: auto;
  color: var(--board-text);
  background: var(--board-raised);
  border: 1px solid var(--board-line);
  border-radius: 8px;
  box-shadow: 0 12px 36px var(--shadow);
  font-size: 13px;
}
#parts button {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 6px 10px 6px 26px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  text-align: left;
  position: relative;
}
#parts button:is(:hover, :focus-visible) { background: color-mix(in srgb, var(--board-text) 9%, transparent); outline: none; }
#parts button[aria-checked="true"]::before { content: "✓"; position: absolute; left: 9px; color: var(--brass); font-weight: 700; }
#parts button[aria-checked="true"] .part-name { font-weight: 600; }
.part-name { white-space: nowrap; }
.part-detail { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--board-dim); }
body:not(.in-room) :is(#listen-room, #listen-notes, #room-open) { display: none; }
/* Who's here has the delay; the button keeps to the head count. */
#room-open-delay { display: none; }
/* The transport is here only for its notices. */
#transport:not(:has(> :not([hidden]))) { display: none; }

/* The door: the join form, the joining screen, and why a join failed or a
   room ended, over everything under the bar. */
#door {
  position: fixed;
  inset: 38px 0 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow: auto;
  color: var(--board-text);
  background: var(--board);
}
#door[hidden], #door [hidden] { display: none; }
.door-panel { display: flex; flex-direction: column; align-items: center; gap: 4px; width: min(280px, 100%); text-align: center; }
.door-panel h2 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.door-panel p { margin: 0; color: var(--board-dim); font-size: 13px; line-height: 1.45; }
.door-panel .door-small { font-size: 12px; }
.door-fields { display: flex; flex-direction: column; gap: 8px; align-self: stretch; margin: 10px 0 6px; }
.door-fields input {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--board-line);
  border-radius: 6px;
  background: var(--board-raised);
  color: var(--board-text);
  font: inherit;
  font-size: 14px;
  user-select: text;
}
.door-fields input:first-child { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.12em; }
.door-panel button.primary { padding: 9px 16px; font-weight: 600; color: #fff; background: var(--brass); border-color: var(--brass); }
.door-fields button.primary { padding: 9px; }
.door-link { padding: 0; border: 0; background: none; color: var(--brass); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
#door-joining { gap: 10px; }
#door-joining h2 { font-size: 17px; }
#door-bar { --track: var(--board-line); align-self: stretch; height: 4px; margin: 4px 0; }
#door-cancel { margin-top: 6px; padding: 4px 14px; border-radius: 999px; font-size: 12px; color: var(--board-dim); }
#door-failed, #door-ended { gap: 6px; }
#door-why, #door-ended-line { margin-bottom: 10px; }
.door-buttons { display: flex; gap: 8px; }
.door-card { padding: 22px 20px 20px; border: 1px solid var(--board-line); border-radius: 12px; background: var(--board-raised); box-shadow: 0 12px 36px var(--shadow); }
/* Behind the door, the room's step and the stage's own controls stay out of the way. */
#home-step { display: none; }
body.door #listen-notes { display: none; }

/* A dropped connection: a banner over the stage and the chat, which dim
   until the room is back. */
#listen-lost {
  grid-area: lost;
  margin: 0;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, var(--board));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, var(--board-line));
}
#listen-lost[hidden] { display: none; }
body.lost :is(#audience, #chat-panel) > * { opacity: 0.55; }

/* Words for a screen reader alone. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Who's here: a card dropped from the people button. */
body:has(#people:popover-open) #room-open { color: var(--board-text); border-color: var(--brass); }
#people {
  inset: 42px 8px auto auto;
  width: min(300px, calc(100vw - 16px));
  max-height: calc(100vh - 54px);
  margin: 0;
  padding: 14px 0 0;
  overflow: auto;
  color: var(--board-text);
  background: var(--board-raised);
  border: 1px solid var(--board-line);
  border-radius: 10px;
  box-shadow: 0 12px 36px var(--shadow);
  font-size: 13px;
  transform: translateY(-6px);
  opacity: 0;
  transition: transform var(--panel-down) ease-in, opacity var(--panel-down) ease-in, display var(--panel-down) allow-discrete, overlay var(--panel-down) allow-discrete;
}
#people:popover-open { transform: none; opacity: 1; transition: transform var(--panel-up) cubic-bezier(0.2, 0.8, 0.2, 1), opacity var(--panel-up); }
@starting-style {
  #people:popover-open { transform: translateY(-6px); opacity: 0; }
}
#people h2 { margin: 0 16px 4px; font-size: 14px; font-weight: 700; }
#people h3 { margin: 12px 16px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--board-dim); }
#people ul { margin: 0; padding: 0; list-style: none; }
#people li { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 16px; }
#people li[data-state="away"] { color: var(--board-dim); }
.people-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--board-line); }
#people-listeners .people-dot { visibility: hidden; }
#people li[data-state="playing"] .people-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
#people li[data-state="away"] .people-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--board-dim); }
.people-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-tag { flex: none; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--brass); background: color-mix(in srgb, var(--brass) 14%, transparent); }
.people-note { flex: none; margin-left: auto; font-size: 12px; font-style: italic; }
#people-song { display: flex; align-items: center; gap: 8px; min-height: 28px; margin: 0; padding: 0 16px 0 32px; }
.people-level { flex: none; display: flex; align-items: center; gap: 2px; margin-left: auto; }
.people-note + .people-level { margin-left: 0; }
.people-mute { width: 24px; height: 24px; padding: 0; font-size: 13px; line-height: 1; border-color: transparent; background: transparent; }
.people-mute[aria-pressed="true"] { color: var(--mute); border-color: color-mix(in srgb, var(--mute) 40%, transparent); }
.people-level input { width: 72px; margin: 0; accent-color: var(--brass); }
.people-level.muted input { opacity: 0.4; }
#people-no-players { margin: 2px 16px; color: var(--board-dim); }
#people-no-players[hidden] { display: none; }
#people-foot { margin-top: 14px; padding: 12px 16px 14px; border-top: 1px solid var(--board-line); background: var(--board); }
#people-room { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
#people-code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: text; }
#people-copy { flex: none; padding: 3px 10px; font-size: 12px; }
#people-delay { margin: 8px 0 0; color: var(--board-dim); line-height: 1.4; }
#people-leave { width: 100%; margin-top: 12px; padding: 6px; color: var(--mute); }
#people-leave:hover { border-color: var(--mute); }

/* The stage: the song, a glowing tile per player, the emotes and the volume,
   over the notes until Notes is on. */
#audience { display: none; }
body.audience #audience {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding: 24px 28px 18px;
  overflow: auto;
  color: var(--board-text);
  background: radial-gradient(90% 80% at 30% 20%, color-mix(in srgb, var(--brass) 12%, var(--board)), var(--board));
}
#audience-now { margin: 0; font-size: 12px; color: var(--board-dim); }
#audience-title { margin: 4px 0 0; font-size: 24px; font-weight: 700; line-height: 1.25; }
#audience-title.waiting { color: var(--board-dim); }
#audience-artist { margin: 4px 0 0; font-size: 14px; color: var(--board-dim); }
#audience-artist[hidden] { display: none; }
/* How far into the song the room is, with what comes after it. */
#audience-time { max-width: 520px; margin: 14px 0 0; }
#audience-time[hidden] { display: none; }
.audience-bar { height: 4px; border-radius: 2px; background: var(--board-line); overflow: hidden; }
.audience-done { display: block; height: 100%; width: 0; background: var(--brass); }
#audience-time p { display: flex; gap: 12px; margin: 6px 0 0; font-size: 12px; color: var(--board-dim); font-variant-numeric: tabular-nums; }
#audience-next { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
/* The song on its way here, or why it could not come. */
#audience-step { max-width: 520px; margin: 14px 0 0; }
#audience-step[hidden] { display: none; }
#audience-step .step-bar { display: block; height: 4px; background: var(--board-line); }
#audience-step .step-bar[hidden] { display: none; }
#audience-step p { margin: 6px 0 0; font-size: 12px; color: var(--board-dim); }
#audience-step[data-missed="true"] p { color: var(--mute); }
#audience-step button { margin-left: 6px; padding: 2px 10px; font-size: 12px; }
#audience-step button[hidden] { display: none; }
#audience-players { display: flex; flex-wrap: wrap; gap: 20px; margin: 26px 0 0; padding: 0; list-style: none; }
#audience-none { margin: 22px 0 0; color: var(--board-dim); font-size: 13px; }
#audience-none[hidden] { display: none; }
.audience-player { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 80px; font-size: 13px; text-align: center; }
.audience-player[data-state="away"] { opacity: 0.45; }
.audience-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audience-state { margin-top: -4px; font-size: 11px; color: var(--board-dim); }
.audience-player:is([data-state="playing"], [data-state="ready"]) .audience-state { color: var(--good); }
.audience-player[data-state="getting"] .audience-state { color: var(--brass); }
.audience-avatar {
  --c: hsl(var(--hue) 70% 52%);
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  color: color-mix(in oklab, var(--c) 70%, var(--board-text));
  background: color-mix(in srgb, var(--c) 22%, var(--board-raised));
}
/* The ring follows the player's level; the fade smooths the ticks. */
.audience-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--c), 0 0 26px var(--c);
  opacity: var(--glow, 0);
  transition: opacity 450ms ease-out;
}

#audience-foot { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 20px; }
#audience-reacts { display: flex; gap: 8px; }
#audience-reacts[hidden] { display: none; }
#audience-reacts button {
  border: 0;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 17px;
  line-height: 1;
  background: color-mix(in srgb, var(--board-text) 9%, transparent);
  transition: transform 120ms;
}
#audience-reacts button:hover { background: color-mix(in srgb, var(--board-text) 16%, transparent); }
#audience-reacts button:active { transform: scale(0.92); }
#audience-volume { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 15px; }
#listen-volume { width: 120px; accent-color: var(--brass); }
@media (prefers-reduced-motion: reduce) {
  .audience-avatar::after, #audience-reacts button, #people { transition: none; }
}

/* Notices start under the bar. */
#notice, #audio-progress { top: 54px; }
#notice:popover-open ~ #audio-progress { top: 106px; }

/* Reduced motion stops every animation and transition but the chat's emotes
   and floating lines, which player.css fades in place for their time. */
@media (prefers-reduced-motion: reduce) {
  *:not(.chat-burst, #chat-float .chat-line), ::before, ::after { animation-duration: 1ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0s !important; }
}
