/* Romantic theme with light and dark modes.
   Colours live in CSS variables. The theme is set on <html data-theme="light|dark">. */

/* ---------- Light theme (default): blush and rose on a soft radial gradient ---------- */
:root {
  --bg-inner: #fff3f7;
  --bg-mid: #f6c6d4;
  --bg-outer: #b0456e;
  --panel: rgba(255, 245, 249, 0.93);
  --movie-bg: rgba(107, 45, 92, 0.22);
  --text: #3d0e22;
  --muted: #6b2d5c;
  --accent: #e8799a;
  --accent-strong: #c2456f;
  --accent-soft: #fde6ee;
  --input-bg: #ffffff;
  --border: #f7b3c6;
  --bubble-mine-bg: #f7b3c6;
  --bubble-mine-text: #3d0e22;
  --bubble-theirs-bg: #6b2d5c;
  --bubble-theirs-text: #fff5fa;
  --heading: #5a1632;
  --shadow: 0 10px 30px rgba(61, 14, 34, 0.25);
  --bg-gradient: radial-gradient(circle at 25% 15%, var(--bg-inner) 0%, var(--bg-mid) 40%, var(--bg-outer) 85%, #5a1632 100%);
}

/* ---------- Dark theme: deep wine and plum, with rose accents ---------- */
:root[data-theme="dark"] {
  --bg-inner: #5a1632;
  --bg-mid: #2a0a18;
  --bg-outer: #1a0812;
  --panel: rgba(40, 10, 27, 0.92);
  --movie-bg: rgba(0, 0, 0, 0.45);
  --text: #ffe9f1;
  --muted: #f0b8cc;
  --accent: #ff8fb1;
  --accent-strong: #e8799a;
  --accent-soft: #4a1a33;
  --input-bg: #2a0c1d;
  --border: #8e3e66;
  --bubble-mine-bg: #ff9ec0;
  --bubble-mine-text: #3d0e22;
  --bubble-theirs-bg: #7a3b6b;
  --bubble-theirs-text: #fff5fa;
  --heading: #ffb3cc;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --bg-gradient: radial-gradient(circle at 25% 15%, var(--bg-inner) 0%, var(--bg-mid) 45%, var(--bg-outer) 100%);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  font-family: "Quicksand", system-ui, sans-serif;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* ---------- Layout: movie (flex 3) | chat (flex 1). Stacks under 700px. ---------- */

.app {
  display: flex;
  height: 100vh;
  gap: 14px;
  padding: 14px;
}

.movie-panel {
  flex: 3;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--movie-bg);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 0;
}

.chat-panel {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 0; /* lets the message list scroll inside the flex column */
}

@media (max-width: 700px) {
  body { overflow: auto; }
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .movie-panel { flex: 0 0 auto; }
  .player-wrap { flex: 0 0 auto; aspect-ratio: 16 / 9; }
  .chat-panel { flex: 1 1 auto; min-width: 0; min-height: 70vh; }
  .messages { max-height: 45vh; }
}

/* ---------- Movie toolbar and player ---------- */

.movie-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 9px 12px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}

.select:disabled { opacity: 0.6; }

.now-playing {
  margin: 0 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.player-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}

#player {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.no-movie {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--accent-soft);
  background: linear-gradient(160deg, var(--bg-inner), var(--bg-outer));
  pointer-events: none;
}

.no-movie h2 {
  font-family: "Dancing Script", cursive;
  font-size: 2.4rem;
  margin: 0 0 6px;
  color: var(--bubble-mine-bg);
}

.no-movie p { margin: 0; opacity: 0.85; }

/* ---------- Header ---------- */

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.chat-header h1 {
  font-family: "Dancing Script", cursive;
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--heading);
  line-height: 1.1;
}

.status { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }

.theme-toggle { white-space: nowrap; }

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  border: 2px solid var(--accent);
  background: var(--input-bg);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.1s ease, background 0.2s ease;
}

.btn:hover:not(:disabled) { background: var(--accent-soft); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .select:focus-visible, .heart-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); filter: brightness(1.06); }

/* ---------- Voice ---------- */

.voice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hint { font-size: 0.85rem; color: var(--muted); }

/* ---------- Hearts ---------- */

.hearts {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.heart-btn {
  font-size: 1.35rem;
  line-height: 1;
  padding: 6px 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
}

.heart-btn:hover { background: var(--accent-soft); transform: scale(1.15); }
.heart-btn:active { transform: scale(0.9); }

/* ---------- Chat ---------- */

.messages {
  list-style: none;
  margin: 0;
  padding: 4px 4px 4px 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  max-width: 82%;
  padding: 9px 14px;
  border-radius: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  animation: pop-in 0.2s ease-out;
}

.msg.mine {
  align-self: flex-end;
  background: var(--bubble-mine-bg);
  color: var(--bubble-mine-text);
  border-bottom-right-radius: 4px;
}

.msg.theirs {
  align-self: flex-start;
  background: var(--bubble-theirs-bg);
  color: var(--bubble-theirs-text);
  border-bottom-left-radius: 4px;
}

.msg-time {
  display: block;
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 2px;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-form { display: flex; gap: 8px; }

.chat-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}

.chat-form input:focus { outline: none; border-color: var(--accent); }
.chat-form input:disabled { opacity: 0.5; }

/* ---------- Floating hearts ---------- */

#float-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
}

.floater {
  position: absolute;
  bottom: -10px;
  font-size: 2.4rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
  animation: float-up 3.2s ease-in forwards;
}

@keyframes float-up {
  0%   { transform: translate3d(0, 0, 0) scale(0.6); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate3d(var(--drift, 0px), -105vh, 0) scale(1.15); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .floater { animation-duration: 1.2s; }
  .msg { animation: none; }
}

/* ---------- Blocker (room full, or not authorized) ---------- */

.blocker {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(40, 10, 27, 0.7);
  z-index: 100;
  padding: 20px;
}

.blocker-card {
  background: var(--panel);
  color: var(--text);
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}

.blocker-card h2 {
  font-family: "Dancing Script", cursive;
  font-size: 2rem;
  margin: 0 0 8px;
  color: var(--heading);
}

/* ---------- Password page ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  overflow: auto;
}

.login-card {
  background: var(--panel);
  color: var(--text);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
  width: min(380px, 100%);
  text-align: center;
}

.login-card h1 {
  font-family: "Dancing Script", cursive;
  font-size: 2.8rem;
  margin: 0;
  color: var(--heading);
  line-height: 1.1;
}

.login-card p { margin: 6px 0 0; color: var(--muted); }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
  text-align: left;
}

.login-form label { font-weight: 600; font-size: 0.9rem; }

.login-form input {
  font: inherit;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}

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

.login-form .btn { align-self: stretch; text-align: center; }

.login-error { color: var(--accent-strong); font-weight: 600; margin-top: 12px; }
