/* =========================================================================
   Watch Party — "Marquee at Midnight"
   A dark theater palette (deep indigo, not neutral black) with two accents
   tied to the subject: warm marquee-bulb amber for calls to action and live
   status, cool projector-glow teal for sync/connection status.
   ========================================================================= */

:root {
  /* Color */
  --ink: #0d0e1a;
  --ink-raised: #14172a;
  --velvet: #1b1e36;
  --velvet-line: rgba(255, 255, 255, 0.08);
  --marquee: #f2a93b;
  --marquee-dim: #b9832c;
  --screen: #5fd0d6;
  --paper: #f3efe4;
  --dim: #9195b3;
  --danger: #e8637a;
  --danger-dim: #b84f63;

  /* Type */
  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Shape / motion */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.4);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  margin: 0 0 0.4em;
  color: var(--paper);
}

p { margin: 0 0 1em; color: var(--dim); }
.muted { color: var(--dim); }
.small { font-size: 0.875rem; }

a { color: var(--screen); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--screen);
  outline-offset: 2px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

img, video { max-width: 100%; display: block; }

/* ---------- Layout shell ---------- */

main { max-width: 1180px; margin: 0 auto; padding: 0 24px 80px; }

.glass {
  background: rgba(27, 30, 54, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--velvet-line);
}

/* ---------- Nav ---------- */

.nav {
  border-bottom: 1px solid var(--velvet-line);
  position: sticky;
  top: 0;
  background: rgba(13, 14, 26, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
}

.nav__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav__logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--paper);
}
.nav__logo:hover { text-decoration: none; color: var(--marquee); }

.nav__links { display: flex; align-items: center; gap: 20px; }
.nav__links a:not(.btn) { color: var(--dim); font-size: 0.95rem; }
.nav__links a:not(.btn):hover { color: var(--paper); text-decoration: none; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--marquee); color: #241505; }
.btn--primary:hover { background: #f7ba5c; }
.btn--ghost { background: transparent; border-color: var(--velvet-line); color: var(--paper); }
.btn--ghost:hover { border-color: var(--dim); }
.btn--danger { background: transparent; border-color: var(--danger-dim); color: var(--danger); }
.btn--danger:hover { background: rgba(232, 99, 122, 0.12); }
.btn--lg { padding: 14px 28px; font-size: 1.05rem; }
.btn--sm { padding: 7px 14px; font-size: 0.85rem; }
.btn--xs { padding: 4px 10px; font-size: 0.75rem; border-radius: 6px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---------- Hero ---------- */

.hero {
  padding: 88px 0 56px;
  max-width: 620px;
}
.hero h1 {
  font-size: clamp(2.5rem, 5.5vw, 4rem);
  letter-spacing: -0.01em;
}
.hero__sub { font-size: 1.15rem; margin-bottom: 32px; }

/* ---------- Live rooms grid ---------- */

.live-section { padding: 24px 0 64px; }
.live-section h2, .how-section h2 { font-size: 1.6rem; margin-bottom: 24px; }

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.empty-state {
  grid-column: 1 / -1;
  color: var(--dim);
  border: 1px dashed var(--velvet-line);
  border-radius: var(--radius-md);
  padding: 40px;
  text-align: center;
}

.room-card {
  display: block;
  background: var(--velvet);
  border-radius: var(--radius-md);
  overflow: hidden;
  border-top: 3px dotted var(--marquee-dim);
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease);
}
.room-card:hover { transform: translateY(-3px); border-top-color: var(--marquee); text-decoration: none; }

.room-card__thumb {
  height: 120px;
  background: linear-gradient(135deg, #23264a, #171a30);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 12px;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(13, 14, 26, 0.75);
  color: var(--marquee);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 100px;
}
.live-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--marquee);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.room-card__body { padding: 16px; }
.room-card__body h3 { font-size: 1.05rem; margin-bottom: 6px; }
.room-card__meta { font-size: 0.85rem; margin-bottom: 10px; }
.room-card__badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 0.75rem;
  color: var(--dim);
  background: var(--ink-raised);
  border: 1px solid var(--velvet-line);
  border-radius: 100px;
  padding: 3px 9px;
}

/* ---------- How it works ---------- */

.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}
.how-card { padding: 20px 0; border-top: 1px solid var(--velvet-line); }
.how-card__num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--marquee);
}
.how-card h3 { font-size: 1.05rem; margin: 10px 0 6px; }

.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--velvet-line);
}

/* ---------- Setup / join forms ---------- */

.setup, .join-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 65px);
  padding: 40px 20px;
}
.join-gate { min-height: 100vh; position: fixed; inset: 0; background: var(--ink); z-index: 30; }

.setup__card, .join-gate__card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  border-radius: var(--radius-lg);
}

.field { display: block; margin-bottom: 18px; }
.field span { display: block; font-size: 0.85rem; color: var(--dim); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  background: var(--ink-raised);
  border: 1px solid var(--velvet-line);
  color: var(--paper);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--screen); outline: none; }

.field-group {
  border: 1px solid var(--velvet-line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 18px;
}
.field-group legend { padding: 0 6px; color: var(--dim); font-size: 0.85rem; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; padding: 4px 0; color: var(--paper); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--marquee); }

.form-error {
  background: rgba(232, 99, 122, 0.12);
  border: 1px solid var(--danger-dim);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ---------- Room page ---------- */

.room-body { background: var(--ink); }

.room__topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--velvet-line);
}
.room__status { display: flex; gap: 8px; align-items: center; }

.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--ink-raised);
  color: var(--dim);
  border: 1px solid var(--velvet-line);
}
.status-pill--ok { color: var(--screen); border-color: var(--screen); }
.status-pill--warn { color: var(--marquee); border-color: var(--marquee); }

.room__layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

.room__main { min-width: 0; }

.player {
  position: relative;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.reactions-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.floating-reaction {
  position: absolute;
  bottom: 60px;
  font-size: 1.8rem;
  animation: floatUp 2.2s ease-out forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-160px); opacity: 0; }
}

.player__controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}
.player__btn {
  background: none;
  border: none;
  color: var(--paper);
  font-size: 1.1rem;
  padding: 4px 6px;
  border-radius: 6px;
}
.player__btn:hover { background: rgba(255,255,255,0.12); }
.player__seek { flex: 1; accent-color: var(--marquee); }
.player__volume { width: 70px; accent-color: var(--marquee); }
.player__time { font-size: 0.8rem; color: var(--dim); white-space: nowrap; }
.player__speed {
  background: rgba(255,255,255,0.08);
  color: var(--paper);
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  padding: 4px;
}

.reaction-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.reaction-bar button {
  background: var(--velvet);
  border: 1px solid var(--velvet-line);
  border-radius: 100px;
  font-size: 1.2rem;
  padding: 6px 12px;
  transition: transform 0.12s var(--ease);
}
.reaction-bar button:hover { transform: scale(1.15); background: var(--ink-raised); }

.call-bar { display: flex; gap: 8px; margin-left: auto; }
.call-bar .btn[aria-pressed="true"] { border-color: var(--screen); color: var(--screen); }

.video-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 14px;
}
.video-tile {
  position: relative;
  flex: 0 0 auto;
  width: 160px;
  aspect-ratio: 4 / 3;
  background: var(--ink-raised);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s var(--ease);
}
.video-tile.speaking { border-color: var(--screen); }
.video-tile video { width: 100%; height: 100%; object-fit: cover; }
.video-tile__initial {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--paper);
}
.video-tile.audio-only video { visibility: hidden; }
.video-tile.audio-only .video-tile__initial { display: flex; }
.video-tile__label {
  position: absolute;
  left: 6px; bottom: 6px;
  font-size: 0.72rem;
  background: rgba(0,0,0,0.6);
  padding: 2px 7px;
  border-radius: 100px;
}
.video-tile .status-pill--xs { position: absolute; top: 6px; right: 6px; }

.status-pill--xs { font-size: 0.62rem; padding: 2px 7px; }

.participant__status { font-size: 0.85rem; margin-right: 6px; white-space: nowrap; }
.participant__avatar.speaking { box-shadow: 0 0 0 2px var(--screen); }

.host-panel { border-radius: var(--radius-md); padding: 18px 20px; margin-top: 16px; }
.host-panel h2 { font-size: 1.05rem; }
.host-panel__row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }

/* ---------- Side panel: tabs, chat, participants ---------- */

.room__side {
  background: var(--velvet);
  border-radius: var(--radius-md);
  border: 1px solid var(--velvet-line);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  overflow: hidden;
}

.tabs { display: flex; border-bottom: 1px solid var(--velvet-line); }
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--dim);
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tab--active { color: var(--paper); border-bottom-color: var(--marquee); }

.tab-panel { display: none; flex-direction: column; flex: 1; min-height: 0; }
.tab-panel--active { display: flex; }

.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.chat-msg { font-size: 0.9rem; line-height: 1.45; word-break: break-word; }
.chat-msg--chat .chat-msg__nick { color: var(--marquee); font-weight: 600; }
.chat-msg--join, .chat-msg--leave { color: var(--dim); font-size: 0.8rem; font-style: italic; }
.chat-msg--system { color: var(--screen); font-size: 0.8rem; }
.chat-msg a { color: var(--screen); }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--velvet-line); }
.chat-form input {
  flex: 1;
  background: var(--ink-raised);
  border: 1px solid var(--velvet-line);
  color: var(--paper);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
}
.chat-form input:focus { outline: none; border-color: var(--screen); }

.participant-list { list-style: none; margin: 0; padding: 10px; overflow-y: auto; }
.participant {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--velvet-line);
  font-size: 0.9rem;
}
.participant__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.participant__name { flex: 1; }
.voice-note { padding: 12px 14px 0; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  main { padding: 0 16px 60px; }
  .hero { padding: 48px 0 40px; }
  .room__layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .room__side { height: 50vh; }
  .nav__links { gap: 12px; }
  .nav__links a:not(.btn) { display: none; }
}
