/* Whisk Geo Talk — Zoom-shaped dark meeting UI
 * Layout: header + stage + toolbar + side-panels + ticker
 */

:root {
  --bg-0: #0f0f0f;
  --bg-1: #1a1a1a;
  --bg-2: #242424;
  --bg-3: #303030;
  --bg-hover: #3a3a3a;
  --border: #333;
  --fg: #f0f0f0;
  --fg-dim: #a0a0a0;
  --fg-mute: #666;
  --accent: #2d8cff;         /* Zoom blue */
  --accent-hover: #4a9eff;
  --danger: #e02c2c;
  --danger-hover: #f04444;
  --success: #22c55e;
  --warning: #f59e0b;
  --tile-bg: #1e1e1e;
  --toolbar-bg: rgba(36, 36, 36, 0.95);
  --panel-bg: #1a1a1a;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
}

input, textarea, select {
  font: inherit;
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* ============ Landing page ============ */
.talk-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
.talk-header .brand {
  font-size: 18px; font-weight: 700; color: var(--fg);
  text-decoration: none;
}
.talk-header .tag { color: var(--fg-dim); font-size: 13px; }
.talk-header .auth-state { color: var(--fg-dim); font-size: 13px; }

.talk-landing {
  padding: 40px 20px;
  max-width: 1200px;
  margin: 0 auto;
  overflow-y: auto;
  height: calc(100vh - 56px);
}
.hero { text-align: center; margin-bottom: 40px; }
.hero h1 { font-size: 42px; font-weight: 700; margin: 0 0 12px; }
.hero p { font-size: 17px; color: var(--fg-dim); max-width: 640px; margin: 0 auto; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card h2 { margin: 0 0 12px; font-size: 20px; }
.card p { color: var(--fg-dim); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
.card .stack { display: flex; flex-direction: column; gap: 12px; }
.card label { display: flex; flex-direction: column; gap: 4px; color: var(--fg-dim); font-size: 13px; }

button.primary {
  background: var(--accent);
  color: white;
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
}
button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { background: var(--bg-3); color: var(--fg-mute); cursor: not-allowed; }
button.danger { background: var(--danger); color: white; padding: 10px 18px; border-radius: 6px; }
button.danger:hover { background: var(--danger-hover); }

.result-block {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-2);
  border-radius: var(--radius);
}
.result-block input { width: 100%; margin-bottom: 12px; font-family: ui-monospace, monospace; font-size: 12px; }
.qr-wrap { text-align: center; margin: 12px 0; }
.qr-wrap img { border-radius: 8px; background: white; padding: 8px; }
.subs-hint { font-size: 12px; color: var(--fg-mute); margin-top: 6px; }

.fine-print {
  margin-top: 40px; padding: 24px;
  background: var(--bg-1);
  border-radius: var(--radius-lg);
}
.fine-print h3 { margin-top: 0; }
.fine-print ul { padding-left: 20px; }
.fine-print li { color: var(--fg-dim); font-size: 14px; margin-bottom: 8px; line-height: 1.5; }
.fine-print li b { color: var(--fg); }

/* ============ Meeting room — Zoom-shaped ============ */

.room-shell {
  display: grid;
  grid-template-rows: 48px 1fr 84px 32px;
  grid-template-columns: 1fr 320px;
  grid-template-areas:
    "topbar topbar"
    "stage panel"
    "toolbar toolbar"
    "ticker ticker";
  height: 100vh; height: 100dvh;
}

/* Top bar — meeting info */
.top-bar {
  grid-area: topbar;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  font-size: 13px;
  color: var(--fg-dim);
}
.top-bar .meeting-id {
  color: var(--fg);
  font-family: ui-monospace, monospace;
  padding: 4px 10px;
  background: var(--bg-2);
  border-radius: 6px;
}
.top-bar .peer-status { margin-left: auto; }
.top-bar .top-info { display: flex; gap: 12px; align-items: center; }

/* Stage — video grid */
.stage {
  grid-area: stage;
  background: var(--bg-0);
  position: relative;
  overflow: hidden;
  padding: 12px;
}
.backdrop {
  position: absolute; inset: 0;
  z-index: 0;
  background-size: cover; background-position: center;
  opacity: 0.15;
  transition: background-image 0.6s;
}
.videos {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  display: grid;
  gap: 8px;
  align-content: center;
  justify-content: center;
  /* grid-template-columns set dynamically by JS based on tile count */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  grid-auto-rows: 1fr;
}
.video-tile {
  position: relative;
  background: var(--tile-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 160px;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.video-tile.speaking {
  box-shadow: 0 0 0 3px var(--accent), var(--shadow);
}
.video-tile video, .video-tile canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
.video-tile .label {
  position: absolute; bottom: 8px; left: 8px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  font-size: 13px;
  color: white;
  z-index: 2;
  max-width: 60%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.video-tile .mode-tag {
  position: absolute; top: 8px; left: 8px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  font-size: 12px;
  color: white;
  z-index: 2;
}
.video-tile .mic-status {
  position: absolute; bottom: 8px; right: 8px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  font-size: 14px;
  z-index: 2;
}
.video-tile .mic-status.muted { color: var(--danger); }

/* Self tile — smaller, corner overlay-style on mobile */
#tile-self {
  aspect-ratio: 16 / 9;
}
#tile-self video {
  transform: scaleX(-1); /* mirror preview so it feels natural */
}

/* Side panel — chat / participants / settings */
.side-panel {
  grid-area: panel;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s;
}
.side-panel.hidden { transform: translateX(100%); display: none; }

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.panel-tabs button {
  flex: 1;
  padding: 12px 8px;
  color: var(--fg-dim);
  border-bottom: 2px solid transparent;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
.panel-tabs button.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.panel-tabs button:hover { color: var(--fg); }

.panel-section { flex: 1; overflow-y: auto; padding: 12px; display: none; }
.panel-section.active { display: block; }

.chat-log {
  height: 100%;
  overflow-y: auto;
  padding: 4px;
}
.msg {
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}
.msg.self { background: var(--accent); color: white; margin-left: 24px; }
.msg.peer { background: var(--bg-3); color: var(--fg); margin-right: 24px; }
.msg.system { background: transparent; color: var(--fg-mute); font-size: 11px; font-style: italic; text-align: center; padding: 4px 0; margin-bottom: 4px; }
.msg .translated {
  display: block;
  color: var(--fg-dim);
  font-size: 12px;
  margin-top: 4px;
  font-style: italic;
}
.chat-composer {
  display: flex; gap: 8px;
  padding: 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}
.chat-composer input { flex: 1; }
.chat-composer button { padding: 8px 12px; background: var(--accent); color: white; border-radius: 6px; }

.participants-list li {
  padding: 8px 10px;
  border-radius: 6px;
  display: flex; align-items: center; gap: 10px;
  list-style: none;
  color: var(--fg);
  font-size: 14px;
}
.participants-list li:hover { background: var(--bg-2); }
.participants-list .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 13px;
}

.settings-section { margin-bottom: 20px; }
.settings-section h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; color: var(--fg-dim); letter-spacing: 0.5px; }
.settings-section > label {
  display: block; margin-bottom: 8px;
  color: var(--fg); font-size: 14px;
}
.settings-section > label input,
.settings-section > label select {
  margin-top: 4px;
  width: 100%;
}
.settings-section .row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.settings-section .sub { color: var(--fg-mute); font-size: 12px; margin-top: 4px; }

/* Toolbar — Zoom-style bottom bar with circular icon buttons */
.toolbar {
  grid-area: toolbar;
  background: var(--toolbar-bg);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 0 16px;
}
.toolbar .tool-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg-3);
  color: var(--fg);
  transition: background 0.15s, color 0.15s;
  font-size: 22px;
  gap: 2px;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.toolbar .tool-btn:hover { background: var(--bg-hover); }
.toolbar .tool-btn .label {
  font-size: 10px;
  color: var(--fg-dim);
  margin-top: 0px;
  display: none;
}
.toolbar .tool-btn.on { background: var(--bg-hover); color: var(--fg); }
.toolbar .tool-btn.off { background: var(--danger); color: white; }
.toolbar .tool-btn.active { background: var(--accent); color: white; }
.toolbar .end-btn {
  width: 88px; height: 40px;
  border-radius: 20px;
  background: var(--danger);
  color: white;
  font-size: 14px;
  font-weight: 600;
  margin-left: 16px;
  display: flex; align-items: center; justify-content: center;
}
.toolbar .end-btn:hover { background: var(--danger-hover); }

.tool-btn .badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* Ticker — segment-swap rotator */
.ticker {
  grid-area: ticker;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  height: 32px; overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.ticker-track {
  padding: 0 16px;
  font-size: 12px; color: var(--fg-dim);
  text-align: center; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  opacity: 1; transition: opacity 260ms ease, color 200ms ease, background 200ms ease;
  width: 100%;
}
.ticker-track.fade-out { opacity: 0; }
.ticker-track.fade-in  { opacity: 1; }
.ticker-track b { color: var(--fg); }
.ticker-track.alert {
  color: #fff; background: var(--danger); font-weight: 600;
  animation: tickerAlertPulse 0.9s ease-in-out infinite alternate;
}
@keyframes tickerAlertPulse {
  from { background: #b91c1c; }
  to   { background: #ef4444; }
}

/* Pre-join / waiting screen */
.pre-join {
  position: fixed; inset: 0;
  background: var(--bg-0);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 20px;
  padding: 20px;
}
.pre-join.hidden { display: none; }
.pre-join .preview {
  width: min(640px, 90vw);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  position: relative; overflow: hidden;
}
.pre-join .preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pre-join .info { text-align: center; }
.pre-join .info h1 { margin: 0 0 8px; font-size: 24px; }
.pre-join .info p { color: var(--fg-dim); margin: 0 0 8px; }
.pre-join .prejoin-controls {
  display: flex; gap: 12px; align-items: center;
  flex-wrap: wrap; justify-content: center;
}
.pre-join .prejoin-controls input {
  width: 240px;
}

/* Recording indicator */
#rec-indicator {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 9999;
  padding: 6px 12px;
  background: var(--danger);
  color: #fff;
  font: 600 12px/1 system-ui, sans-serif;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px;
}
#rec-indicator span:first-child {
  width: 8px; height: 8px; background: #fff; border-radius: 50%;
  animation: recBlink 1s infinite;
}
@keyframes recBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* Whisk widget overlay (voice-in/widget-out) */
#whisk-widget {
  position: fixed;
  bottom: 130px; right: 20px;
  width: 320px; max-width: 90vw;
  background: var(--bg-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  z-index: 998;
  transition: transform 0.25s, opacity 0.25s;
}
#whisk-widget.hidden { transform: translateY(20px); opacity: 0; pointer-events: none; }
#whisk-widget .whisk-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
#whisk-widget .whisk-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 700;
}
#whisk-widget .whisk-name { font-weight: 600; color: var(--fg); }
#whisk-widget .whisk-close {
  margin-left: auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-dim);
}
#whisk-widget .whisk-close:hover { background: var(--bg-3); color: var(--fg); }
#whisk-widget .whisk-body { color: var(--fg); font-size: 14px; line-height: 1.4; }
#whisk-widget .whisk-source { color: var(--fg-mute); font-size: 11px; margin-top: 8px; }

/* Emoji reactions floating */
.reaction-float {
  position: fixed;
  bottom: 100px;
  font-size: 32px;
  z-index: 997;
  animation: floatUp 3s ease-out forwards;
  pointer-events: none;
}
@keyframes floatUp {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-400px); opacity: 0; }
}

/* Responsive — mobile */
@media (max-width: 768px) {
  .room-shell {
    grid-template-rows: 44px 1fr 72px 26px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "stage"
      "toolbar"
      "ticker";
  }
  .side-panel {
    position: fixed;
    top: 44px; right: 0; bottom: 98px;
    width: 100%; max-width: 320px;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.25s;
  }
  .side-panel:not(.hidden) { transform: translateX(0); }
  .videos {
    grid-template-columns: 1fr !important;
    grid-auto-rows: 1fr;
  }
  .videos.tiles-2 { grid-template-columns: 1fr !important; grid-template-rows: 1fr 1fr; }
  .videos.tiles-3 { grid-template-rows: 1fr 1fr 1fr; }
  .videos.tiles-4 { grid-template-columns: 1fr 1fr !important; grid-template-rows: 1fr 1fr; }
  #tile-self {
    position: absolute;
    top: 12px; right: 12px;
    width: 100px; height: auto;
    aspect-ratio: 16 / 9;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  }
  .toolbar { padding: 0 8px; gap: 4px; }
  .toolbar .tool-btn { width: 48px; height: 48px; font-size: 20px; }
  .toolbar .end-btn { width: 72px; height: 40px; font-size: 13px; margin-left: 4px; }
  .hero h1 { font-size: 28px; }
  .cards { grid-template-columns: 1fr; }
  .top-bar { font-size: 12px; padding: 0 12px; }
  .top-bar .meeting-id { padding: 3px 8px; font-size: 11px; }
}

/* Compact tile grids for participant count */
.videos.tiles-1 { grid-template-columns: 1fr; }
.videos.tiles-2 { grid-template-columns: 1fr 1fr; }
.videos.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.videos.tiles-4 { grid-template-columns: repeat(2, 1fr); }
.videos.tiles-5,
.videos.tiles-6 { grid-template-columns: repeat(3, 1fr); }
.videos.tiles-7,
.videos.tiles-8,
.videos.tiles-9 { grid-template-columns: repeat(3, 1fr); }
.videos.tiles-10,
.videos.tiles-11,
.videos.tiles-12 { grid-template-columns: repeat(4, 1fr); }
.videos.tiles-many { grid-template-columns: repeat(5, 1fr); }
