:root {
  /* Palette pulled from ccameron.co.uk's theme stylesheet */
  --bg: #ebf1f3;
  --surface: #ffffff;
  --surface-2: #e8eaeb;
  --accent: #37788d;
  --accent-2: #45bdb8;
  --dark: #1d2e3c;
  --danger: #bd5345;
  --text: #1d2e3c;
  --text-dim: #555e66;
  --text-on-dark: #f2f3f5;
  --text-dim-on-dark: #9aa8b3;
  --font-heading: "Playfair Display", "Arial", serif;
  --font-body: "Source Sans Pro", "Arial", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, .brand-logo {
  font-family: var(--font-heading);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.screen {
  height: 100vh;
  width: 100vw;
}

/* Landing / join / exit cards */
#enterIdScreen,
#joinScreen,
#exitScreen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 10px;
  width: min(90vw, 380px);
  text-align: center;
  box-shadow: 0 10px 40px rgba(29, 46, 60, 0.12);
}

.card h1 {
  margin: 0 0 0.5rem;
}

.brand-logo {
  font-style: italic;
  color: var(--accent);
}

.exit-logo {
  height: 32px;
  width: auto;
  margin-bottom: 1.25rem;
}

.card p {
  color: var(--text-dim);
  margin: 0 0 1.5rem;
}

.card button {
  width: 100%;
  padding: 0.9rem;
  border: none;
  border-radius: 30px;
  background: var(--accent);
  color: white;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.card button:hover {
  filter: brightness(1.1);
}

.divider {
  color: var(--text-dim);
  margin: 1rem 0;
  font-size: 0.85rem;
}

#enterIdForm,
#joinPasswordForm {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.text-input {
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.75rem 0 0;
}

/* Call screen */
#call {
  display: flex;
  flex-direction: column;
  background: var(--dark);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-dim-on-dark);
}

.topbar-logo {
  height: 22px;
  width: auto;
  /* Site logo is brand teal on white; invert to white so it reads on the dark topbar */
  filter: brightness(0) invert(1);
}

.topbar button {
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-on-dark);
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--danger);
}

.recording-indicator i {
  font-size: 0.55rem;
  animation: pulse-dot 1.4s ease-in-out infinite;
}

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

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

.main-area {
  flex: 1;
  display: flex;
  min-height: 0;
}

.video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  grid-auto-rows: 1fr;
  gap: 0.75rem;
  padding: 1rem;
  overflow: hidden;
  background: #10151a;
}

.tile {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

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

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

/* Screen share: show the whole capture unmirrored and uncropped. */
.tile.sharing-screen video {
  object-fit: contain;
}

#tile-local.sharing-screen video {
  transform: scaleX(1);
}

.name-tag {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  background: rgba(29, 46, 60, 0.75);
  color: var(--text-on-dark);
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--dark);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.control-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-dim-on-dark);
}

.control-btn.active {
  background: var(--accent-2);
  color: white;
}

.control-btn.danger {
  background: var(--danger);
  color: white;
}

.control-btn:hover {
  filter: brightness(1.15);
}

.hangup-icon {
  transform: rotate(135deg);
}

/* Recordings modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(29, 46, 60, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-content {
  background: var(--surface);
  border-radius: 10px;
  width: min(90vw, 480px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--surface-2);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text);
}

.modal-header button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
}

.recordings-list {
  overflow-y: auto;
  padding: 0.5rem 1.25rem;
}

.recording-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--surface-2);
  font-size: 0.85rem;
  gap: 0.75rem;
}

.recording-item:last-child {
  border-bottom: none;
}

.recording-item .recording-links {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.recording-item a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}

.recording-item a:hover {
  text-decoration: underline;
}

.recordings-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 1rem 0;
}
