/*
 * Chatter Royale · Buzzer Pop components.
 * Uses only tokens from tokens.css: no raw colour values here.
 * Link tokens.css first, then this file.
 *
 * Contents: base · button · status light · name plate · guest tile · HONK sticker
 *           · lower third · now-on panel · queue panel · OBS overlay stage
 */

/* ---------- Base ---------- */
.cr-root {
  font-family: var(--cr-font-ui);
  color: var(--cr-fg);
  background: var(--cr-bg);
}
.cr-display { font-family: var(--cr-font-display); font-weight: 400; letter-spacing: 0; }
.cr-eyebrow {
  font-size: var(--cr-text-xs);
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

/* ---------- Button ---------- */
.cr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cr-space-1);
  min-height: 48px;
  padding: var(--cr-space-2) var(--cr-space-4);
  border: var(--cr-outline);
  border-radius: var(--cr-radius-pill);
  box-shadow: var(--cr-shadow);
  font-family: var(--cr-font-display);
  font-size: var(--cr-text-md);
  line-height: 1.1;
  color: var(--cr-ink);
  background: var(--cr-white);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--cr-dur-fast), box-shadow var(--cr-dur-fast);
}
.cr-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 0 var(--cr-ink); }
.cr-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--cr-ink); }
.cr-btn:focus-visible { outline: var(--cr-line) solid var(--cr-blue); outline-offset: 4px; }
.cr-btn--primary { background: var(--cr-action); }
.cr-btn--secondary { background: var(--cr-white); }
.cr-btn--buzzer {
  width: 240px;
  height: 240px;
  border-width: var(--cr-line-thick);
  border-radius: 50%;
  background: var(--cr-action);
  box-shadow: var(--cr-shadow-lg);
  font-size: var(--cr-text-lg);
  text-align: center;
}
.cr-btn:disabled,
.cr-btn[aria-disabled="true"] {
  background: var(--cr-grey);
  color: var(--cr-ink-muted);
  border-color: var(--cr-ink-muted);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

/* ---------- Status light (red → amber → green) ----------
 * <div class="cr-status" data-state="red|amber|green">
 *   <span class="cr-status__bulb cr-status__bulb--red"></span> ×3, then .cr-status__label
 */
.cr-status {
  display: inline-flex;
  align-items: center;
  gap: var(--cr-space-2);
  font-weight: 800;
  font-size: var(--cr-text-md);
}
.cr-status__bulbs { display: inline-flex; gap: var(--cr-space-1); }
.cr-status__bulb {
  width: 36px;
  height: 36px;
  border: var(--cr-outline);
  border-radius: 50%;
  box-sizing: border-box;
  background: var(--cr-status-off);
}
.cr-status[data-state="red"] .cr-status__bulb--red { background: var(--cr-status-red); }
.cr-status[data-state="amber"] .cr-status__bulb--amber { background: var(--cr-status-amber); animation: cr-pulse var(--cr-dur-pulse) ease-in-out infinite; }
.cr-status[data-state="green"] .cr-status__bulb--green { background: var(--cr-status-green); }

/* ---------- Name plate ---------- */
.cr-nameplate {
  display: inline-flex;
  align-items: center;
  gap: var(--cr-space-1);
  padding: var(--cr-space-1) var(--cr-space-3);
  border: var(--cr-outline);
  border-radius: var(--cr-radius-sm);
  background: var(--cr-cream);
  color: var(--cr-ink);
  font-family: var(--cr-font-display);
  font-size: var(--cr-text-lg);
  line-height: 1.1;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
}
.cr-nameplate__seat {
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--cr-ink);
  color: var(--cr-cream);
}
.cr-nameplate__name { overflow: hidden; text-overflow: ellipsis; }
.cr-nameplate--speaking { background: var(--cr-yellow); }
.cr-nameplate--censored { background: var(--cr-pink); }

/* ---------- Guest tile ----------
 * <figure class="cr-tile" data-state="empty|connecting|live|censored|disconnected">
 *   <div class="cr-tile__screen"> video | .cr-tile__message </div>
 *   <figcaption class="cr-tile__plate"> .cr-nameplate </figcaption>
 * </figure>
 * Add .cr-tile--speaking for the active speaker, .cr-tile--cutout to leave the
 * screen transparent so an OBS video source can sit underneath.
 */
.cr-tile {
  position: relative;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cr-tile__screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border: var(--cr-line-thick) solid var(--cr-ink);
  border-radius: var(--cr-radius-lg);
  background: var(--cr-video-bg);
  box-shadow: var(--cr-shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cr-tile__screen > video,
.cr-tile__screen > iframe,
.cr-tile__screen > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
}
.cr-tile__placeholder { color: var(--cr-blue-soft); font-size: var(--cr-text-md); }
.cr-tile__message {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--cr-space-1);
  padding: var(--cr-space-3);
  text-align: center;
  font-weight: 600;
  font-size: var(--cr-text-md);
}
.cr-tile__message .cr-display { font-size: var(--cr-text-xl); }
.cr-tile__plate {
  align-self: center;
  margin-top: -26px;
  position: relative;
  max-width: 90%;
}

.cr-tile[data-state="empty"] .cr-tile__screen {
  background: var(--cr-white);
  border-style: dashed;
  box-shadow: none;
  color: var(--cr-ink);
}
.cr-tile[data-state="connecting"] .cr-tile__screen {
  color: var(--cr-cream);
  animation: cr-ring var(--cr-dur-pulse) ease-in-out infinite;
}
.cr-tile[data-state="censored"] .cr-tile__screen { border-color: var(--cr-pink); }
.cr-tile[data-state="disconnected"] .cr-tile__screen {
  background: var(--cr-grey);
  color: var(--cr-ink);
  box-shadow: none;
}
.cr-tile[data-state="disconnected"] .cr-tile__screen > video { filter: grayscale(1); opacity: .35; }
.cr-tile[data-state="disconnected"] .cr-nameplate { background: var(--cr-grey); }
.cr-tile--speaking .cr-tile__screen {
  box-shadow: 0 0 0 10px var(--cr-yellow), 0 10px 0 10px var(--cr-ink);
}
.cr-tile--cutout[data-state="live"] .cr-tile__screen,
.cr-tile--cutout[data-state="censored"] .cr-tile__screen { background: var(--cr-transparent); }

/* ---------- HONK! sticker (censor moment) ----------
 * Drop into a .cr-tile__screen; remove after ~1.5s. */
.cr-sticker {
  position: absolute;
  right: 6%;
  top: 8%;
  width: 30%;
  aspect-ratio: 1;
  min-width: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--cr-line-thick) solid var(--cr-ink);
  border-radius: 50%;
  background: var(--cr-yellow);
  color: var(--cr-ink);
  font-family: var(--cr-font-display);
  font-size: clamp(18px, 2.2vw, 36px);
  transform: rotate(-12deg);
  animation: cr-pop var(--cr-dur-pop) var(--cr-ease-pop) both;
  z-index: 2;
}

/* ---------- Lower third ---------- */
.cr-lower-third {
  display: inline-flex;
  align-items: stretch;
  border: var(--cr-line-thick) solid var(--cr-ink);
  border-radius: var(--cr-radius-md);
  box-shadow: var(--cr-shadow);
  overflow: hidden;
  max-width: 100%;
}
.cr-lower-third__tag {
  display: flex;
  align-items: center;
  padding: var(--cr-space-2) var(--cr-space-3);
  background: var(--cr-pink);
  color: var(--cr-ink);
  font-family: var(--cr-font-display);
  font-size: var(--cr-text-md);
}
.cr-lower-third__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: var(--cr-space-2) var(--cr-space-4);
  background: var(--cr-cream);
}
.cr-lower-third__title { font-family: var(--cr-font-display); font-size: var(--cr-text-xl); line-height: 1.05; }
.cr-lower-third__sub { font-weight: 600; font-size: var(--cr-text-md); color: var(--cr-fg-muted); }

/* ---------- Panels: now-on and queue ---------- */
.cr-panel {
  border: var(--cr-line-thick) solid var(--cr-ink);
  border-radius: var(--cr-radius-lg);
  padding: var(--cr-space-2) var(--cr-space-4);
  box-sizing: border-box;
  box-shadow: var(--cr-shadow);
}
.cr-panel--now-on {
  display: flex;
  align-items: center;
  gap: var(--cr-space-3);
  background: var(--cr-yellow);
  color: var(--cr-ink);
}
.cr-panel__badge {
  flex-shrink: 0;
  padding: var(--cr-space-1) var(--cr-space-2);
  border-radius: 12px;
  background: var(--cr-ink);
  color: var(--cr-yellow);
  font-family: var(--cr-font-display);
  font-size: var(--cr-text-md);
}
.cr-panel__quote { font-weight: 800; font-size: 34px; line-height: 1.05; }
.cr-panel--queue {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: var(--cr-blue);
  color: var(--cr-cream);
  font-size: 19px;
}
.cr-panel--queue .cr-panel__head { font-family: var(--cr-font-display); font-size: var(--cr-text-sm); color: var(--cr-yellow); }
.cr-panel--queue ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }

/* ---------- Top bar pieces ---------- */
.cr-wordmark {
  display: inline-flex;
  padding: 10px 34px;
  border: var(--cr-line-thick) solid var(--cr-ink);
  border-radius: var(--cr-radius-pill);
  background: var(--cr-blue);
  color: var(--cr-cream);
  font-family: var(--cr-font-display);
  font-size: var(--cr-text-2xl);
  box-shadow: var(--cr-shadow);
}
.cr-wordmark__accent { color: var(--cr-yellow); margin-left: .35em; }
.cr-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--cr-space-1) var(--cr-space-3);
  border: var(--cr-outline);
  border-radius: var(--cr-radius-pill);
  background: var(--cr-yellow);
  color: var(--cr-ink);
  font-weight: 800;
  font-size: var(--cr-text-lg);
}
.cr-chip--live { background: var(--cr-pink); font-family: var(--cr-font-display); font-weight: 400; }

/* ---------- OBS overlay stage (1920×1080, transparent) ----------
 * Use as an OBS Browser Source at 1920×1080. The page background stays
 * transparent; only frames, plates and panels paint.
 */
html.cr-obs, html.cr-obs body { margin: 0; background: var(--cr-transparent); }
.cr-stage {
  width: 1920px;
  height: 1080px;
  box-sizing: border-box;
  padding: 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  font-family: var(--cr-font-ui);
  color: var(--cr-ink);
  background: var(--cr-transparent);
  overflow: hidden;
}
.cr-stage__top { display: flex; justify-content: space-between; align-items: center; height: 80px; }
.cr-stage__top-right { display: flex; gap: var(--cr-space-2); align-items: center; }
.cr-stage__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px 28px;
  align-content: start;
}
.cr-stage__bottom { display: flex; gap: var(--cr-space-4); flex-grow: 1; min-height: 0; }
.cr-stage__bottom .cr-panel--now-on { flex: 1; }
.cr-stage__bottom .cr-panel--queue { width: 360px; }
.cr-stage__host { width: 300px; }
.cr-stage__host .cr-tile__screen { height: 100%; aspect-ratio: auto; }

/* ---------- Motion ---------- */
@keyframes cr-pop {
  0% { transform: rotate(-30deg) scale(0); }
  100% { transform: rotate(-12deg) scale(1); }
}
@keyframes cr-pulse { 50% { opacity: .45; } }
@keyframes cr-ring {
  50% { box-shadow: 0 0 0 8px var(--cr-amber), var(--cr-shadow); }
}
@media (prefers-reduced-motion: reduce) {
  .cr-sticker, .cr-status__bulb, .cr-tile__screen { animation: none !important; }
  .cr-btn { transition: none; }
}
