/* ============================================================================
   WHEN THE FIRE FADES - PUBLIC GAMES BOARD
   Page-specific layout inside the shared .stage (fire-theme.css). Reuses the
   theme tokens, buttons, nav and eyebrow; this file owns only the board grid,
   the lobby card, and the loading/empty states. No new design language.
   ========================================================================== */

.browse {
  position: relative; z-index: 4;
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: var(--sp-3) var(--sp-5) var(--sp-6);
  gap: clamp(var(--sp-4), 3vh, var(--sp-6));
  min-height: 0;
}

.browse-head { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.browse-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--fs-h2); letter-spacing: 0.04em;
  margin: 0; color: #f6ecda;
}
.browse-sub { font-size: var(--fs-sm); color: var(--c-ash-dim); margin: 0; max-width: 46ch; text-wrap: balance; }

/* ---- The board: a responsive grid of lobby cards ---------------------- */
.board {
  width: 100%; max-width: 760px;
  /* flex-wrap (not grid) so a lone card centres instead of sitting in the left track, and any
     partial final row stays centred too - the expected case is a handful of lobbies. */
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--sp-4);
  max-height: 52vh;
  overflow-y: auto;
  padding: 2px;
}

.fire-card {
  flex: 1 1 280px; max-width: 348px;
  display: flex; align-items: center; gap: var(--sp-4);
  text-align: left;
  padding: var(--sp-4);
  background: linear-gradient(180deg, rgba(40,36,26,0.78), rgba(20,20,15,0.86));
  border: 1px solid var(--c-bark-line);
  border-top-color: rgba(255,180,90,0.18);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.fire-card:hover { border-color: rgba(255,150,55,0.35); box-shadow: var(--glow-soft); }

.fire-card-glyph {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: var(--font-display); font-weight: 600; font-size: 1.1rem;
  color: var(--c-core);
  background: radial-gradient(circle at 50% 35%, rgba(255,180,90,0.28), rgba(20,20,15,0.55));
  border: 1px solid rgba(255,150,55,0.3);
  box-shadow: var(--glow-soft);
}

.fire-card-body { flex: 1; min-width: 0; }
.fire-card-host {
  font-weight: 600; color: var(--c-ash); font-size: 1.05rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fire-card-meta {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); color: var(--c-ash-dim); margin-top: 2px;
}
.fire-card-meta .cap strong { color: var(--c-gold); font-weight: 700; }
.fire-card-meta .sep { color: var(--c-ash-faint); }

/* compact primary button, sized to its label rather than the card width */
.join-btn { width: auto; flex: none; padding: var(--sp-3) var(--sp-5); font-size: 0.95rem; }

/* ---- Loading / empty states ------------------------------------------- */
.board-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  color: var(--c-ash-dim); font-size: var(--fs-sm);
  padding: var(--sp-6) var(--sp-4);
}
#boardLoading { flex-direction: row; }

.waiting-dots { display: inline-flex; gap: 4px; }
.waiting-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c-ember); display: block; animation: waitpulse 1.2s infinite; }
.waiting-dots i:nth-child(2) { animation-delay: .2s; }
.waiting-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes waitpulse { 0%,100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

.board-empty .empty-title { font-family: var(--font-display); font-size: var(--fs-lead); color: var(--c-ash); margin: 0 0 var(--sp-2); }
.board-empty .empty-sub { color: var(--c-ash-dim); font-size: var(--fs-sm); margin: 0 0 var(--sp-5); }
.empty-create { margin: 0; width: 100%; max-width: 320px; }

/* ---- Back to the fire (mirrors the lobby's leave-link) ---------------- */
.back-link {
  background: none; border: none; color: var(--c-ash-faint);
  font-family: var(--font-ui); font-size: var(--fs-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--r-sm); transition: color .2s var(--ease);
}
.back-link:hover { color: var(--c-gold); }
.back-link .ic { width: 16px; height: 16px; }

/* The campfire sits as ambient firelight pinned to the base of the stage, behind the board,
   so the card list (which scrolls within its own max-height) never shifts the flame. */
.browse-stage #fireCanvas {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  margin: 0; z-index: 1;
}

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 560px) {
  .nav { padding: var(--sp-3) var(--sp-4); }
  .brand span.full { display: none; }
  .board { max-height: 56vh; }
  .fire-card { flex-basis: 100%; max-width: none; }
}
