/* ================================================================
   AnyStudio Guest Join Page
   Dark theme — mobile-first responsive
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:          #1A1A2E;
  --surface:     #16213E;
  --surface-2:   #1E2A4A;
  --accent:      #FF6B35;
  --accent-dark: #D4502A;
  --danger:      #E5484D;
  --danger-dark: #C03437;
  --text-primary: #FFFFFF;
  --text-secondary: #8B8B9E;
  --border:      rgba(255, 255, 255, 0.08);
  --radius-card: 16px;
  --radius-btn:  10px;
  --radius-input: 10px;
  --radius-video: 12px;

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Utility ──────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── States ───────────────────────────────────────────────────── */
.state {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 32px 24px;
  width: 100%;
  max-width: 480px;
}

.card--centered {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.card--overlay {
  position: relative;
  z-index: 10;
}

/* ── Logo ─────────────────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.logo-img {
  width: 32px;
  height: 32px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

/* ── Typography ───────────────────────────────────────────────── */
.heading {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  line-height: 1.25;
}

.subheading {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.icon-large {
  font-size: 48px;
  line-height: 1;
}

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.spinner--sm {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--border);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger:hover {
  background: var(--danger-dark);
}

.btn--full {
  width: 100%;
}

.btn--sm {
  padding: 10px 16px;
  font-size: 14px;
}

/* ── Form ─────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 16px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
}

.form-input::placeholder {
  color: var(--text-secondary);
}

.form-input:focus {
  border-color: var(--accent);
}

/* ── Show header (Lobby) ──────────────────────────────────────── */
.show-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.show-artwork-wrap {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.show-artwork-wrap--sm {
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
}

.show-artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.show-artwork-placeholder {
  width: 100%;
  height: 100%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: inherit;
}

.show-meta {
  flex: 1;
  min-width: 0;
}

.show-meta .heading {
  font-size: 18px;
}

/* ── Camera preview (Lobby) ───────────────────────────────────── */
.preview-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-video);
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 16 / 9;
  margin-bottom: 20px;
}

.video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1); /* mirror self-view */
}

.preview-label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.4);
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
}

.permission-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface-2);
  padding: 16px;
  text-align: center;
}

.permission-prompt p {
  font-size: 14px;
  color: var(--text-secondary);
}

.lobby-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* ── Copy feedback ────────────────────────────────────────────── */
.copy-feedback {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
}

/* ── WAITING layout ───────────────────────────────────────────── */
.layout-waiting {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.pip-wrap--waiting {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 20;
}

/* ── CONNECTED layout ─────────────────────────────────────────── */
#state-connected {
  padding: 0;
  align-items: stretch;
}

.layout-connected {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

/* Host video fills the screen */
.host-video-wrap {
  position: absolute;
  inset: 0;
}

.host-video {
  width: 100%;
  height: 100%;
}

.host-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.host-video-label {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.4);
  padding: 4px 10px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Self-preview PiP */
.pip-wrap {
  position: absolute;
  bottom: 100px;
  right: 16px;
  width: 100px;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 20;
}

.video-pip {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}

/* Recording indicator */
.recording-indicator {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 999px;
  z-index: 30;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse-rec 1.2s ease-in-out infinite;
}

.rec-label {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Countdown overlay */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

.countdown-number {
  font-size: 120px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -4px;
  text-shadow: 0 4px 32px rgba(0,0,0,0.6);
  animation: countdown-pop 0.25s ease-out;
}

@keyframes countdown-pop {
  from { transform: scale(1.3); opacity: 0.5; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Host disconnected overlay */
.host-disconnected-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 35;
  padding: 24px;
  text-align: center;
}

/* Controls bar */
.controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 24px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
  background: rgba(22, 33, 62, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 25;
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.15s ease, transform 0.1s ease;
  min-width: 64px;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.16);
}

.ctrl-btn--danger {
  background: rgba(229, 72, 77, 0.25);
  border-color: rgba(229, 72, 77, 0.4);
  color: var(--danger);
}

.ctrl-btn--danger:hover {
  background: rgba(229, 72, 77, 0.35);
}

.ctrl-btn--muted {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.ctrl-icon {
  width: 22px;
  height: 22px;
}

.ctrl-label {
  font-size: 11px;
  font-weight: 600;
}

/* ── Responsive: tablet and up ────────────────────────────────── */
@media (min-width: 640px) {
  .card {
    padding: 40px 36px;
  }

  .pip-wrap {
    width: 140px;
    height: 190px;
    bottom: 110px;
    right: 24px;
  }

  .controls-bar {
    gap: 24px;
  }

  .ctrl-btn {
    min-width: 80px;
    padding: 14px 20px;
  }
}

@media (min-width: 1024px) {
  .pip-wrap {
    width: 180px;
    height: 240px;
  }
}
