/*
 * Styles for the meeting test client.
 *
 * Intentionally minimal and framework-free. The page exists to verify that
 * media flows, so the CSS covers layout and legibility and stops there.
 * Honours the OS light/dark preference because a video call UI that forces a
 * bright background is genuinely unpleasant in a dark room.
 */

:root {
  --bg: #ffffff;
  --surface: #f4f5f7;
  --border: #d8dade;
  --text: #16181d;
  --text-dim: #5c6270;
  --accent: #1f6feb;
  --danger: #c8392b;
  --recording: #d92b2b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #191c22;
    --border: #2b303a;
    --text: #e9ebf0;
    --text-dim: #9aa1b0;
    --accent: #4c8dff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* --- lobby ---------------------------------------------------------------- */

.panel {
  max-width: 26rem;
  margin: 4rem auto;
  padding: 0 1.25rem;
}

.panel h1 { margin: 0 0 .35rem; font-size: 1.4rem; }

.hint { margin: 0 0 1.5rem; color: var(--text-dim); font-size: .9rem; }

#join-form { display: flex; flex-direction: column; gap: 1rem; }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }

label small { font-weight: 400; color: var(--text-dim); font-size: .8rem; }

input, select {
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  padding: .55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* Marks a control whose feature is currently OFF (muted, camera stopped), so
   the state is visible at a glance rather than only in the label text. */
button.active { border-color: var(--danger); color: var(--danger); }

button.danger { border-color: var(--danger); color: var(--danger); }

#join-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.error {
  margin-top: 1rem;
  padding: .6rem .75rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: .88rem;
}

/* --- call view ------------------------------------------------------------ */

.call { display: flex; flex-direction: column; height: 100vh; }

.call-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.call-meta { display: flex; align-items: center; gap: .6rem; }

.status { color: var(--text-dim); font-size: .85rem; }

.badge-recording {
  color: var(--recording);
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .04em;
  /* Pulses so it reads as live rather than as a static label. */
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: .35; } }

/* Respect users who have asked for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .badge-recording { animation: none; }
}

.call-controls { display: flex; flex-wrap: wrap; gap: .5rem; }

/*
 * auto-fit + minmax gives a responsive grid with no JS: one large tile alone,
 * splitting into columns as participants join, down to a single column on a
 * phone. min() keeps it from overflowing narrow viewports.
 */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: .75rem;
  padding: .75rem;
  overflow-y: auto;
  align-content: start;
}

.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #000;
  overflow: hidden;
}

.tile-video {
  width: 100%;
  height: 100%;
  /* cover rather than contain: letterboxing every tile wastes the grid. */
  object-fit: cover;
}

/* Self-view is mirrored, matching what every other conferencing tool does. */
.mirrored { transform: scaleX(-1); }

/* Audio elements must be in the DOM to play, but have nothing to show. */
.tile-audio { display: none; }

.tile-label {
  position: absolute;
  left: .5rem;
  bottom: .5rem;
  z-index: 1;
  padding: .15rem .45rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: .8rem;
}

#call-error { margin: 0 .75rem .75rem; }
