/* ============================================
   OnFire Call - Styles (matched to onf.to design)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-primary: #FF6B1F;
  --color-primary-hover: #E85A10;
  --color-primary-light: #FFCE54;
  --color-danger: #FF3B30;
  --color-danger-hover: #E0342A;
  --color-success: #34C759;

  /* Always dark — matches onf.to */
  --bg-primary: transparent;
  --bg-secondary: rgba(31, 41, 55, 0.5);
  --bg-card: rgba(31, 41, 55, 0.8);
  --bg-input: rgba(55, 65, 81, 0.6);
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --text-primary: #f5f5f7;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;
  --border-color: rgba(55, 65, 81, 0.5);
  --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.4);

  /* Call screen */
  --bg-call: #111111;
  --bg-participant: #1c1c1e;
  --bg-controls: rgba(30, 30, 32, 0.9);
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom right, #0f172a, #1e3a8a, #1e293b);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* Background pattern — matches onf.to */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fillRule='evenodd'%3E%3Cg fill='%23ffffff' fillOpacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

a {
  color: #fb923c;
  text-decoration: none;
}

a:hover {
  color: #f97316;
  text-decoration: underline;
}

/* ============================================
   Screen System
   ============================================ */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* ============================================
   Loading Screen
   ============================================ */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.logo {
  animation: fadeIn 0.6s ease;
}

.logo-icon {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 4px 12px rgba(255, 107, 31, 0.3));
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #f97316;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 15px;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Error Screen
   ============================================ */

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.error-icon {
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.error-container h2 {
  font-size: 22px;
  font-weight: 600;
  color: white;
}

.error-container p {
  color: #d1d5db;
  font-size: 15px;
  max-width: 320px;
  line-height: 1.5;
}

/* ============================================
   Join Screen
   ============================================ */

.join-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 440px;
  padding: 24px;
  animation: fadeIn 0.5s ease;
}

.join-header {
  margin-bottom: 24px;
}

.logo-small svg {
  width: 44px;
  height: 44px;
}

.join-card {
  width: 100%;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
}

/* Creator Info */
.creator-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fb923c, #ef4444);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar span {
  color: white;
  font-size: 20px;
  font-weight: 600;
}

.creator-details h2 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: white;
}

.call-type-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 2px;
}

.call-type-icon {
  display: inline-flex;
}

/* Form */
.join-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.input-field {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg-input);
  border: 1.5px solid transparent;
  border-radius: 12px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

/* Video Preview */
.video-preview-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: rgba(55, 65, 81, 0.5);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 4px;
}

.video-preview-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-controls {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.preview-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s;
}

.preview-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.preview-btn.muted {
  background: var(--color-danger);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(to right, #f97316, #dc2626);
  color: white;
  box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(to right, #ea580c, #b91c1c);
  transform: scale(1.05);
  box-shadow: 0 10px 20px -3px rgba(249, 115, 22, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: scale(1);
}

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

.btn-secondary {
  background: rgba(55, 65, 81, 0.6);
  color: white;
}

.btn-secondary:hover {
  background: rgba(75, 85, 99, 0.7);
  text-decoration: none;
}

.btn-join {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  margin-top: 4px;
}

.btn-text {
  display: inline;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-spinner.hidden, .hidden {
  display: none !important;
}

/* App prompt */
.mobile-app-prompt {
  margin-top: 20px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.btn-app {
  width: 100%;
  background: rgba(55, 65, 81, 0.5);
  color: white;
  font-weight: 500;
  border-radius: 9999px;
}

.btn-app:hover {
  background: rgba(75, 85, 99, 0.6);
  text-decoration: none;
}

.btn-app svg {
  flex-shrink: 0;
}

.app-hint {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  margin-top: 8px;
}

.footer-text {
  color: var(--text-tertiary);
  font-size: 12px;
  margin-top: 20px;
}

/* ============================================
   Call Screen
   ============================================ */

.call-container {
  position: fixed;
  inset: 0;
  background: var(--bg-call);
  display: flex;
  flex-direction: column;
}

/* Call header */
.call-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  z-index: 10;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
}

.call-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-status {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.call-status.connected {
  color: var(--color-success);
}

.call-timer {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Participants grid */
.participants-grid {
  flex: 1;
  display: grid;
  gap: 4px;
  padding: 4px;
  padding-top: max(60px, calc(env(safe-area-inset-top) + 48px));
  padding-bottom: 100px;
  overflow: hidden;
}

/* Grid layouts by participant count */
.participants-grid[data-count="1"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.participants-grid[data-count="2"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}

.participants-grid[data-count="3"],
.participants-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.participants-grid[data-count="5"],
.participants-grid[data-count="6"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}

/* Participant tile */
.participant-tile {
  position: relative;
  background: var(--bg-participant);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.participant-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.participant-tile.local video {
  transform: scaleX(-1);
}

.participant-tile .avatar-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fb923c, #ef4444);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  color: white;
}

.participant-name {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.participant-name .mic-indicator {
  flex-shrink: 0;
}

.mic-indicator.muted svg {
  color: var(--color-danger);
}

/* Call controls */
.call-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  background: var(--bg-controls);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.control-btn.muted {
  background: rgba(255, 255, 255, 0.95);
  color: #1f2937;
}

.control-btn-hangup {
  background: var(--color-danger) !important;
  width: 64px;
  height: 64px;
}

.control-btn-hangup:hover {
  background: var(--color-danger-hover) !important;
}

/* ============================================
   Call Ended Screen
   ============================================ */

.ended-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.ended-icon {
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.ended-container h2 {
  font-size: 22px;
  font-weight: 600;
  color: white;
}

.ended-duration {
  color: var(--text-secondary);
  font-size: 15px;
}

.ended-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ============================================
   Responsive
   ============================================ */

@media (min-width: 768px) {
  .participants-grid[data-count="2"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
  }

  .join-card {
    padding: 40px 36px;
  }
}

@media (max-width: 480px) {
  .join-card {
    border-radius: 16px;
    padding: 24px 20px;
  }

  .join-container {
    padding: 16px;
  }

  .creator-info {
    margin-bottom: 24px;
  }
}

/* ============================================
   Animations
   ============================================ */

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.participant-tile {
  animation: slideUp 0.3s ease;
}

/* ============================================
   Connecting overlay
   ============================================ */

.connecting-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-call);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 20;
}

.connecting-overlay .spinner {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: #f97316;
}

.connecting-overlay p {
  color: rgba(255, 255, 255, 0.6);
  font-size: 15px;
}

/* ============================================
   Landing Page
   ============================================ */

#screen-landing {
  overflow-y: auto;
}

body.landing-active,
body.landing-active html {
  overflow: auto;
}

.landing-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
}

/* Header */
.landing-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.landing-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 18px;
}

.header-logo:hover {
  text-decoration: none;
  color: white;
}

.header-logo-icon {
  width: 34px;
  height: 34px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.header-nav a {
  color: #d1d5db;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

.header-nav a:hover {
  color: white;
  text-decoration: none;
}

.header-cta {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  background: linear-gradient(to right, #f97316, #dc2626);
  color: white;
  font-size: 14px;
  font-weight: 600;
  border-radius: 9999px;
  text-decoration: none;
  transition: all 0.2s;
}

.header-cta:hover {
  transform: scale(1.05);
  text-decoration: none;
  color: white;
}

/* Hero */
.landing-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

.hero-content {
  max-width: 560px;
  text-align: center;
  animation: fadeIn 0.6s ease;
}

.hero-icon-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(249, 115, 22, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 28px;
  color: #f97316;
}

.hero-content h1 {
  font-size: 36px;
  font-weight: 700;
  color: white;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 17px;
  color: #9ca3af;
  line-height: 1.6;
  margin-bottom: 40px;
}

/* Feature cards */
.hero-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 40px;
  text-align: left;
}

.hero-feature {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(31, 41, 55, 0.6);
  border: 1px solid rgba(55, 65, 81, 0.4);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(249, 115, 22, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fb923c;
}

.hero-feature h3 {
  font-size: 15px;
  font-weight: 600;
  color: white;
  margin-bottom: 2px;
}

.hero-feature p {
  font-size: 13px;
  color: #9ca3af;
  line-height: 1.4;
}

/* CTA */
.hero-cta-group {
  text-align: center;
}

.hero-prompt {
  font-size: 15px;
  color: #d1d5db;
  margin-bottom: 16px;
}

.hero-prompt-sub {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
}

.hero-download-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.download-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}

.download-badge:hover {
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
  color: white;
}

/* Footer */
.landing-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 11, 20, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 24px;
  display: flex;
  gap: 60px;
}

.footer-brand {
  flex-shrink: 0;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 8px;
}

.footer-logo:hover {
  text-decoration: none;
  color: white;
}

.footer-tagline {
  font-size: 13px;
  color: #6b7280;
}

.footer-columns {
  display: flex;
  gap: 48px;
  flex: 1;
}

.footer-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-column h4 {
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.footer-column a {
  font-size: 14px;
  color: #d1d5db;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-column a:hover {
  color: white;
  text-decoration: none;
}

.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.footer-bottom p {
  font-size: 12px;
  color: #6b7280;
}

/* Landing page responsive */
@media (max-width: 640px) {
  .header-nav {
    display: none;
  }

  .hero-content h1 {
    font-size: 28px;
  }

  .hero-subtitle {
    font-size: 15px;
  }

  .hero-icon-circle {
    width: 96px;
    height: 96px;
  }

  .hero-icon-circle svg {
    width: 48px;
    height: 48px;
  }

  .footer-inner {
    flex-direction: column;
    gap: 32px;
  }

  .footer-columns {
    gap: 32px;
  }

  .landing-hero {
    padding: 40px 20px;
  }
}
