/* Altirra SDL netplay lobby — broker modal styling.
 *
 * Loaded by index.html alongside the page's main stylesheet.
 * Scoped under .broker-* so we don't touch the existing .modal /
 * .modal-wrap rules used by the entry-code prompt.  We deliberately
 * reuse the existing visual language (mono font, monochrome palette,
 * 1-px borders, no rounded corners) so the broker dialogs feel like
 * a continuation of the page rather than a separate widget.
 *
 * The broker has more states than the entry-code modal (handle entry
 * → waiting → intent-arrived → decided), so it needs more variants
 * than .modal supports — hence a dedicated stylesheet rather than
 * extending the existing rules in place.
 */

/* Wrap + backdrop — same translucent-black overlay as .modal-wrap. */
.broker-wrap {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  z-index: 60;
}
.broker-wrap.open { display: flex; }

.broker-card {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  font-family: var(--mono);
  color: var(--fg);
}

.broker-card h3 {
  font: 500 14px/1.3 var(--mono);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.broker-card p {
  font-size: 13px;
  color: var(--fg-dim);
  margin: 0 0 16px;
  line-height: 1.45;
}
.broker-card label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 14px 0 6px;
}
.broker-card input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font: 14px var(--mono);
  letter-spacing: 0.05em;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line-strong);
}
.broker-card input[type="text"]:focus {
  outline: none;
  border-color: var(--fg);
}
.broker-card .err {
  font-size: 12px;
  color: var(--r1);
  min-height: 1.2em;
  margin-top: 8px;
  font-family: var(--mono);
}

.broker-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.broker-row button {
  font: 500 13px/1 var(--mono);
  letter-spacing: 0.06em;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
}
.broker-row button.primary {
  background: var(--fg); color: var(--bg); border-color: var(--fg);
}
.broker-row button.danger {
  border-color: var(--r1); color: var(--r1);
}
.broker-row button.danger:hover { background: var(--r1); color: var(--bg); }
.broker-row button:hover { opacity: 0.85; }
.broker-row button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Pulsing status dot used in the "Waiting for joiners…" card.
 * Reuses --fg as the colour so the dot reads on every theme. */
.broker-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 18px;
  font-size: 13px;
  color: var(--fg);
}
.broker-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg);
  animation: broker-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes broker-pulse {
  0%, 100% { opacity: 1.0; transform: scale(1.0); }
  50%      { opacity: 0.3; transform: scale(0.7); }
}

/* The "intent arrived" card highlights the joiner's handle. */
.broker-handle {
  font: 500 14px/1 var(--mono);
  color: var(--fg);
  background: var(--line);
  padding: 8px 12px;
  display: inline-block;
  margin: 4px 0 14px;
  letter-spacing: 0.04em;
}
.broker-handle .meta {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--fg-dim);
  letter-spacing: 0.06em;
  margin-top: 4px;
  text-transform: uppercase;
}

/* Multi-intent stack (rare but allowed: a host can have several
 * pending joiners visible at once before deciding any). */
.broker-intents {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 6px;
}
.broker-intent {
  border: 1px solid var(--line-strong);
  padding: 12px;
}
.broker-intent .row {
  display: flex; align-items: center; gap: 10px;
}
.broker-intent .name {
  flex: 1;
  font: 500 13px/1 var(--mono);
  letter-spacing: 0.04em;
}
.broker-intent .age {
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.broker-intent .actions {
  display: flex; gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}
.broker-intent .actions button {
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.06em;
  padding: 7px 11px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
}
.broker-intent .actions .accept {
  background: var(--fg); color: var(--bg); border-color: var(--fg);
}
.broker-intent .actions .reject {
  border-color: var(--r1); color: var(--r1);
}

/* Game preview block — shown alongside the wait card. */
.broker-game {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.broker-game img {
  width: 64px; height: 48px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.broker-game .info {
  flex: 1; min-width: 0;
}
.broker-game .title {
  font: 500 13px/1.2 var(--mono);
  letter-spacing: 0.04em;
  color: var(--fg);
  margin-bottom: 4px;
}
.broker-game .sub {
  font: 11px var(--mono);
  color: var(--fg-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Minor: avoid layout shift when the modal swaps content panels. */
.broker-card[data-stage] { min-height: 220px; }
