/* Host screen (/host). Loaded after stylesheet.css; uses its tokens. */

.hostPage {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 0 var(--space-7);
  text-align: left;
}

/* ---------- Buttons (host page only; scoped to .hostBtn, not Bootstrap) ---------- */
.hostBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: var(--fs-base);
  line-height: 1.2;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.hostBtn:active { transform: translateY(1px); }
.hostBtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.hostBtn--ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.hostBtn--ghost:hover { background: var(--surface-2); }

.hostBtn--secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.hostBtn--secondary:hover { border-color: var(--ink-2); }

.hostBtn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.hostBtn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.hostBtn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.hostBtn--danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.hostBtn--dangerOutline { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.hostBtn--dangerOutline:hover { background: var(--danger); color: #fff; }

.hostBtn--lg { padding: 14px 22px; font-size: var(--fs-lg); min-height: 52px; flex: 1 1 0; }
.hostBtn--sm { padding: 6px 12px; min-height: 34px; font-size: var(--fs-sm); }

.hostBtn--state { background: var(--surface); border-color: var(--line); color: var(--ink); }
.hostBtn--state.hostBtn--locked { background: var(--warning); border-color: var(--warning); color: var(--warning-ink); }

.hostBtn--copied { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }

/* ---------- Toolbar ---------- */
.hostToolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-3);
}
.hostToolbar__group { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.hostQuickToggles {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.switchToggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-2);
  -webkit-user-select: none;
  user-select: none;
}
.switchToggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.switchTrack {
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: var(--line);
  position: relative;
  flex-shrink: 0;
  transition: background-color .15s ease;
}
.switchThumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform .15s ease;
}
.switchToggle input:checked + .switchTrack { background: var(--primary); }
.switchToggle input:checked + .switchTrack .switchThumb { transform: translateX(16px); }
.switchToggle input:focus-visible + .switchTrack { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Hero (game code) ---------- */
.heroCard {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--space-6) var(--space-5);
  text-align: center;
  margin-bottom: var(--space-5);
}
.heroCard__label {
  margin: 0 0 var(--space-1);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--muted);
}
.heroCard__code {
  font-family: 'BuzzIn Wordmark', 'Montserrat', sans-serif;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 6vw + 1rem, 5.5rem);
  letter-spacing: .04em;
  color: var(--brand-ink);
  line-height: 1;
  margin: 0 0 var(--space-4);
  word-break: break-all;
}
.heroCard__copy { margin: 0 auto; }
.hostBtn--copied i { color: #fff; }

/* ---------- Primary controls ---------- */
.hostControls {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.hostHint {
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
  margin: 0 0 var(--space-5);
}
kbd {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.9em;
  color: var(--ink);
}

/* ---------- Disconnected banner ---------- */
.hostBanner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-weight: 600;
}
.hostBanner--danger { background: #fdecef; border: 1px solid var(--danger); color: var(--danger); }

/* ---------- Timer card ----------
   #roundTimer / #timerDisplay / #timerSettings carry legacy ID rules in
   stylesheet.css (border, font-size, position); id+class compound selectors
   are used here so these host-owned styles win regardless of load order. */
#roundTimer.timerCard {
  position: static;
  display: block;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-5);
  margin: 0 0 var(--space-5);
  text-align: center;
}
.timerCard__header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: var(--space-3);
}
#timerSettings.timerCard__settings {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  cursor: pointer;
}
.timerCard__settings:hover { background: var(--surface-2); color: var(--ink); }
.timerCard__settings:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#timerDisplay.timerCard__display {
  font-family: 'BuzzIn Wordmark', 'Montserrat', sans-serif;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.5rem, 5vw + 1rem, 4rem);
  color: var(--brand-ink);
  line-height: 1;
  margin-bottom: var(--space-4);
}
.timerCard__controls {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ---------- Players / Teams cards ---------- */
.hostCard {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
.hostCard__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.hostCard__title { font-size: var(--fs-xl); font-weight: 700; color: var(--ink); margin: 0; }
.hostCard__count { color: var(--primary); }
.hostCard__meta { color: var(--muted); font-size: var(--fs-sm); }

#playersList .sectionLabel,
#teamsList .sectionLabel {
  text-align: left;
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: var(--space-3) 0 var(--space-1);
}
#playersList .sectionLabel:first-child { margin-top: 0; }
#playersList .emptyState,
.hostCard .emptyState {
  text-align: center;
  color: var(--muted);
  padding: var(--space-4) 0;
  margin: 0;
}

#playersList .remove, #teamsList .remove {
  color: var(--muted);
  cursor: pointer;
  border-radius: 50%;
}
#playersList .remove:hover, #teamsList .remove:hover { color: var(--danger); background: var(--surface-2); }

#playersList .name, #teamsList .name {
  cursor: pointer;
  border-radius: var(--radius-sm);
}
#playersList .name:hover, #teamsList .name:hover { background: var(--surface-2); }

#playersList .pointChanger, #teamsList .pointChanger {
  border-color: var(--line);
  color: var(--ink-2);
}
#playersList .pointChanger:hover, #teamsList .pointChanger:hover { background: var(--surface-2); color: var(--primary); }

.rankBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 700;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.rankBadge--first { background: var(--primary); color: #fff; }

.teamChip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.teamChip:hover { border-color: var(--accent); color: var(--ink); }
.teamChip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.teamChip--none { color: var(--muted); border-style: dashed; }

/* Host player and team lists: fixed columns shared by both lists, so the remove
   buttons, numbers, names, point controls and team buttons line up. */
.alignedList {
  --col-points: 0px;
  --col-team: 0px;
  overflow-x: auto;
}
.alignedList.showPoints { --col-points: 112px; }
.alignedList.showTeams { --col-team: 190px; }
.alignedList .row {
  margin-left: 0;
  margin-right: 0;
}
.alignedList .rowStuff {
  display: grid;
  grid-template-columns: 32px 30px 190px var(--col-points) var(--col-team);
  align-items: center;
  width: max-content;
  min-height: 38px;
  margin: 1px auto;
}
.alignedList .rowStuff > div {
  display: block;
  margin: 0;
  min-width: 0;
}
.alignedList .remove { text-align: center; }
.alignedList .order { text-align: center; }
.alignedList .name {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alignedList .points {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.alignedList .pointChanger {
  flex: 0 0 25px; /* keep the circles round inside the flex row */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin: 0;
}
.alignedList .points span:not(.pointChanger) {
  min-width: 3.5ch; /* same width for 0 and 125, so the circles stay in line */
  text-align: center;
}
.alignedList .team { text-align: left; }
/* Phones: names take the spare width and the team button drops under the name */
@media (max-width: 575px) {
  .alignedList .rowStuff {
    grid-template-columns: 30px 28px minmax(0, 1fr) var(--col-points);
    width: 100%;
    max-width: 420px;
  }
  .alignedList.showPoints { --col-points: 104px; }
  .alignedList .team { grid-column: 3 / -1; padding-bottom: 4px; }
}

/* ---------- Modals (Settings / Timer settings) ---------- */
.hostModal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(26, 31, 54, 0.55);
}
.hostModal__panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  width: 100%;
  max-width: 640px;
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
}
.hostModal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.hostModal__title { margin: 0; font-size: var(--fs-lg); font-weight: 700; color: var(--ink); }
.hostModal__close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
.hostModal__close:hover { background: var(--surface-2); color: var(--ink); }
.hostModal__close:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hostModal__body {
  padding: var(--space-4) var(--space-5) var(--space-5);
  overflow-y: auto;
}

.settingsSection { margin-bottom: var(--space-5); }
.settingsSection:last-child { margin-bottom: 0; }
.settingsSection__title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.settingsSection--danger { display: flex; flex-direction: column; gap: var(--space-2); }
.settingsSection--danger .settingsSection__title { color: var(--danger); }

.settingRow,
.settingRow--select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  background: transparent;
  border: none;
  border-top: 1px solid var(--line);
  padding: var(--space-3) 6px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
}
.settingsSection > .settingRow:first-of-type,
.settingsSection > .settingRow--select:first-of-type { border-top: none; }
.settingRow__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settingRow__label { font-weight: 600; font-size: var(--fs-base); }
.settingRow__desc { font-size: var(--fs-sm); color: var(--muted); }
/* Font Awesome's own .fas/.far rule sets display:inline-block and is linked
   after host.css (footer.ejs), so this needs to out-rank it explicitly. */
i.settingRow__icon { display: none !important; }
.settingRow__value {
  font-size: var(--fs-sm);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.settingRow:hover { background: var(--surface-2); border-radius: var(--radius-sm); }
.settingRow:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.settingRow--select { cursor: default; }

.hostSelect {
  max-width: 55%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 6px 10px;
  background: var(--surface);
  color: var(--ink);
}
.hostSelect:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.settingRow__notice {
  display: block;
  font-size: var(--fs-sm);
  color: var(--warning-ink);
  background: #fff4e0;
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
}

/* Switch UI, driven purely from the existing icon state (fa-check / fa-volume-up = on) */
.switchUi {
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: var(--line);
  position: relative;
  flex-shrink: 0;
  transition: background-color .15s ease;
}
.switchUi__dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform .15s ease;
}
.settingRow:has(.fa-check) .switchUi,
.settingRow:has(.fa-volume-up) .switchUi {
  background: var(--primary);
}
.settingRow:has(.fa-check) .switchUi__dot,
.settingRow:has(.fa-volume-up) .switchUi__dot {
  transform: translateX(16px);
}

/* ---------- Bootbox how-to / shortcuts dialogs ---------- */
.hostDialog { text-align: left; color: var(--ink-2); }
.hostDialog h3 {
  text-align: left;
  color: var(--ink);
  font-size: var(--fs-lg);
  margin-top: var(--space-4);
}
.hostDialog h3:first-child { margin-top: 0; }
.hostDialog ul { text-align: left; margin: 0 0 var(--space-2); padding-left: 20px; }
.hostDialog li { margin-bottom: 6px; }
.hostDialog b { color: var(--ink); }
.hostDialog kbd { margin-right: 2px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .hostBtn, .switchUi, .switchUi__dot, .switchTrack, .switchThumb, .settingRow {
    transition: none !important;
  }
}

/* Final pass: rows line up with the section labels inside the cards */
.hostCard .alignedList .rowStuff { margin-left: 0; }

/* Phones: one tidy toolbar row. Secondary actions go icon-only (their text stays
   in the DOM for screen readers). */
@media (max-width: 575px) {
  .hostToolbar { flex-wrap: nowrap; gap: var(--space-2); }
  .hostToolbar__group { flex-wrap: nowrap; }
  .hostToolbar .hostBtn--ghost { font-size: 0; min-width: 44px; justify-content: center; }
  .hostToolbar .hostBtn--ghost i { font-size: 1.1rem; margin: 0; }
  .hostQuickToggles { gap: var(--space-4); }
  .hostConn { min-width: 16px; }
}
/* the smallest phones (320 px): tighter gaps keep End game on screen */
@media (max-width: 359px) {
  .hostToolbar, .hostToolbar__group { gap: var(--space-1); }
}

/* Motion: new buzzes slide in (the #1 badge pops), new players fade in,
   dialogs ease in, and the timer ticks red for its last five seconds.
   The global prefers-reduced-motion rule in stylesheet.css turns these off. */
@keyframes hostRowIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@keyframes hostRankPop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.alignedList .row.is-new { animation: hostRowIn var(--dur) var(--ease-out) both; }
.alignedList .row.is-new-buzz .rankBadge { animation: hostRankPop var(--dur-slow) var(--ease-out) both; }
.alignedList .row.is-new-player { animation: hostRowIn var(--dur-slow) var(--ease-out) both; }

@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalRise { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.hostModal:not(.invisible) { animation: modalFade var(--dur) ease both; }
.hostModal:not(.invisible) .hostModal__panel { animation: modalRise var(--dur) var(--ease-out) both; }

#timerDisplay { transition: color var(--dur) ease; }
#timerDisplay.timer-low { color: var(--danger); }
#timerDisplay.timer-tick { animation: hostTimerTick 600ms var(--ease-out); }
@keyframes hostTimerTick {
  0% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* the connection light: first item in the toolbar, centred on the 44 px button row */
.hostConn { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 44px; }
