@import url("https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Share+Tech+Mono&display=swap");
@import url("https://fonts.cdnfonts.com/css/enchanted-land");

/* ─────────────────────────────────────────────
   Abril Fatface = closest free web alternative
   to ITC Benguiat (the Stranger Things font).
   ───────────────────────────────────────────── */

:root {
  --bg:           #080808;
  --panel:        #0e0e0e;
  --panel-border: rgba(180, 10, 20, 0.22);
  --line:         #1a1a1a;
  --text:         #e8e8e8;
  --text-dim:     #c8c8c8;
  --accent:       #cc1020;
  --accent-glow:  rgba(200, 10, 30, 0.55);
  --muted:        #666666;
  --vein:         #550000;
  --tree:         #000000;
  --overlay-top: 86px;
  --overlay-bottom-gap: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Share Tech Mono", monospace;
  color: var(--text);
  background: var(--bg);
  /* subtle red atmospheric glow only at corners */
  background-image:
    radial-gradient(ellipse at 0% 0%,   rgba(120, 0, 0, 0.18) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 0%,  rgba(80,  0, 0, 0.10) 0%, transparent 35%),
    radial-gradient(ellipse at 50% 100%, rgba(60,  0, 0, 0.12) 0%, transparent 50%);
  overflow-x: hidden;
}

/* CRT scanlines — very subtle */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.08) 0,
    rgba(0, 0, 0, 0.08) 1px,
    transparent 2px,
    transparent 4px
  );
}

/* ── Typography ──────────────────────────────── */
h1, h2 {
  font-family: "Abril Fatface", serif;
  margin: 0 0 0.5rem;
  letter-spacing: 2px;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.8rem);
  color: #e8e8e8;             /* white — red only comes from glow */
  text-shadow:
    0 0 12px rgba(200, 10, 30, 0.75),
    0 0 35px rgba(160,  0, 20, 0.35);
}

h2 {
  font-size: 1.8rem;
  color: #dddddd;
  text-shadow: 0 0 8px rgba(180, 0, 20, 0.4);
}

/* title flicker */
@keyframes flicker {
  0%, 93%, 100% { opacity: 1; }
  94%            { opacity: 0.82; }
  96%            { opacity: 0.18; text-shadow: none; }
  97%            { opacity: 1; }
  99%            { opacity: 0.6; }
}
.topbar h1 { animation: flicker 8s ease-in-out infinite; }

/* ── Topbar ──────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.4rem;
  background: #000;
  border-bottom: 1px solid #1a1a1a;
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: blur(8px);
}

/* thin red line under topbar */
.topbar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(to right,
    transparent,
    rgba(200, 10, 30, 0.7) 30%,
    rgba(220, 15, 35, 0.9) 50%,
    rgba(200, 10, 30, 0.7) 70%,
    transparent);
}

.topbar div {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Panels ──────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 1.35rem;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.8),
    0 4px 30px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255,255,255,0.03);
}

/* ── Auth layout ─────────────────────────────── */
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-panel {
  width: min(680px, 95vw);
  display: grid;
  gap: 0;
}

/* ── Admin grid ──────────────────────────────── */
.grid-admin {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 1.1rem;
  padding: 1rem;
}

/* ── Player panel ────────────────────────────── */
.player-panel {
  margin: 1rem auto;
  max-width: 1240px;
  display: grid;
  gap: 0.95rem;
}

.player-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-toggle {
  min-width: 140px;
  position: fixed;
  right: 16px;
  top: calc(var(--overlay-top) - 2px);
  z-index: 450;
}

.chat-toggle {
  min-width: 120px;
  position: fixed;
  left: 16px;
  top: calc(var(--overlay-top) - 2px);
  z-index: 450;
}

.chat-sidebar {
  position: fixed;
  top: var(--overlay-top);
  left: 0;
  width: min(360px, 92vw);
  height: calc(100dvh - var(--overlay-top) - var(--overlay-bottom-gap));
  overflow: hidden;
  padding: 1rem;
  border-right: 1px solid rgba(200, 10, 30, 0.35);
  background: rgba(10, 12, 16, 0.98);
  box-shadow: 10px 0 25px rgba(0, 0, 0, 0.5);
  transform: translateX(-102%);
  transition: transform 220ms ease;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.chat-sidebar.open {
  transform: translateX(0);
}

.chat-title {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  border: 1px solid #1e1e1e;
  background: #0a0a0a;
  border-radius: 3px;
  padding: 0.5rem;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 0.45rem;
}

.chat-row {
  display: grid;
  gap: 0.2rem;
  padding: 0.35rem 0.45rem;
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid rgba(200, 10, 30, 0.45);
}

.chat-row.mine {
  border-left-color: rgba(42, 145, 255, 0.7);
}

.chat-name {
  font-size: 0.78rem;
  color: #b7c7dd;
}

.chat-text {
  font-size: 0.92rem;
  color: #ececec;
  line-height: 1.25;
  word-break: break-word;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
}

.user-sidebar {
  position: fixed;
  top: var(--overlay-top);
  right: 0;
  width: min(380px, 92vw);
  height: calc(100dvh - var(--overlay-top) - var(--overlay-bottom-gap));
  overflow-y: auto;
  padding: 1rem;
  border-left: 1px solid rgba(200, 10, 30, 0.35);
  background: rgba(10, 12, 16, 0.98);
  box-shadow: -10px 0 25px rgba(0, 0, 0, 0.5);
  transform: translateX(102%);
  transition: transform 220ms ease;
  z-index: 400;
  display: grid;
  gap: 0.7rem;
}

.user-sidebar.open {
  transform: translateX(0);
}

/* ── Forms ───────────────────────────────────── */
.stack { display: grid; gap: 0.7rem; }

/* ── Upload progress modal ───────────────────── */
.upload-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.80);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.upload-modal.active {
  opacity: 1;
  pointer-events: all;
}
.upload-modal-box {
  background: var(--panel, #0e0e0e);
  border: 1px solid var(--accent, #cc1020);
  box-shadow: 0 0 32px rgba(200, 10, 30, 0.25);
  padding: 2rem 2.4rem;
  min-width: 300px;
  max-width: 460px;
  width: 90%;
  display: grid;
  gap: 1rem;
}
.upload-modal-icon {
  font-size: 2rem;
  color: var(--accent, #cc1020);
  text-align: center;
  animation: upload-pulse 1.2s ease-in-out infinite;
}
.upload-modal-title {
  font-size: 1rem;
  letter-spacing: 5px;
  text-align: center;
  color: var(--text, #e8e8e8);
}
.upload-modal-filename {
  font-size: 0.76rem;
  color: var(--text-dim, #c8c8c8);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.75;
}
.upload-modal-bar-wrap {
  height: 5px;
  background: #1e1e1e;
  border-radius: 3px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent, #cc1020);
  border-radius: 3px;
  transition: width 0.15s ease;
}
.upload-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.upload-progress-pct {
  font-size: 0.82rem;
  color: var(--text-dim, #c8c8c8);
  letter-spacing: 2px;
}
.upload-cancel-btn {
  background: none;
  border: 1px solid #444;
  color: #777;
  font-family: "Share Tech Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 2px;
  padding: 0.28rem 0.8rem;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
  box-shadow: none;
}
.upload-cancel-btn:hover {
  border-color: var(--accent, #cc1020);
  color: var(--accent, #cc1020);
  background: none;
  box-shadow: none;
  filter: none;
}
@keyframes upload-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.stack.compact { max-width: 360px; }

label {
  display: grid;
  gap: 0.38rem;
  color: var(--text-dim);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input, select, button {
  font: inherit;
  border: 1px solid #2a2a2a;
  background: #0a0a0a;
  color: var(--text);
  border-radius: 2px;
  padding: 0.68rem 0.85rem;
  transition: border-color 200ms, box-shadow 200ms;
}

input:focus, select:focus {
  outline: none;
  border-color: rgba(200, 10, 30, 0.6);
  box-shadow: 0 0 0 2px rgba(180, 0, 20, 0.15);
}

select { min-height: 120px; }

button {
  cursor: pointer;
  background: #111;
  border: 1px solid #2e2e2e;
  color: var(--text);
  letter-spacing: 2px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  transition: border-color 180ms, box-shadow 180ms, background 180ms, transform 100ms;
}

button:hover {
  background: #1a1a1a;
  border-color: rgba(200, 10, 30, 0.55);
  box-shadow: 0 0 12px rgba(180, 0, 20, 0.25),
              inset 0 0 20px rgba(100, 0, 10, 0.08);
}

button:active { transform: translateY(1px); }

/* ── Controls ────────────────────────────────── */
.control-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.custom-control-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.45rem;
}

#seek-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0.3rem 0;
}

/* ── Video player — 16:9 responsive ─────────── */
.player-wrapper {
  margin-top: 0.8rem;
  border: 1px solid #1e1e1e;
  border-radius: 3px;
  overflow: hidden;
  background: #000;
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  /* subtle red border glow */
  box-shadow: 0 0 0 1px rgba(150, 0, 15, 0.22),
              0 0 20px rgba(0, 0, 0, 0.65);
}

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

#yt-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#yt-player iframe {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

/* Blocks audience from touching the YouTube player */
.yt-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: transparent;
  cursor: default;
}

/* ── User list ───────────────────────────────── */
.user-list {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 0.4rem;
}

.user-list li {
  padding: 0.4rem 0.7rem;
  background: rgba(255,255,255,0.02);
  border-left: 2px solid rgba(180, 10, 20, 0.5);
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ── Misc ────────────────────────────────────── */
.status {
  min-height: 1.5rem;
  padding: 0.5rem 1rem;
  color: #d3d3d3;
  font-size: 0.9rem;
}

.status.error {
  color: #ff7070;
  text-shadow: 0 0 6px rgba(220, 0, 0, 0.4);
}

.muted { color: #c2c2c2; font-size: 0.92rem; }
.hidden { display: none !important; }
#source-label { color: var(--text-dim); }

#break-requests {
  max-height: 260px;
  overflow-y: auto;
}

/* User page readability mode: hide decorative overlays/effects if present */
.player-panel {
  background: #0d0f14;
}

/* Hide any legacy/injected ambient layers on user page */
.user-page .upside-trees,
.user-page .vein-container,
.user-page .spores,
.user-page .leaf,
.user-page .leaves,
.user-page .bat,
.user-page .bats,
.user-page .vecna,
.user-page [class*="particle"],
.user-page [id*="particle"],
.user-page canvas {
  display: none !important;
}

/* ── Vein decorations ── dark, subtle ────────── */
.vein-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.vein-left, .vein-right {
  position: absolute;
  top: 0;
  height: 100%;
  width: 120px;
  opacity: 0.35;          /* subtle — just a dark red hint */
  display: none;
}

.vein-left  { left: 0; }
.vein-right { right: 0; transform: scaleX(-1); }

.vein-path {
  fill: none;
  stroke: #4a0000;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.vein-main   { stroke-width: 2.2; }
.vein-branch { stroke-width: 1.1; }
.vein-sub    { stroke-width: 0.6; opacity: 0.6; }

@keyframes vein-breathe {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.55; }
}
.vein-container { animation: vein-breathe 6s ease-in-out infinite; }

/* ── Upside-down trees — black silhouette ────── */
.upside-trees {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 110px;
  pointer-events: none;
  z-index: 150;
  display: none;
}

.upside-trees svg { width: 100%; height: 100%; }

/* ── Floating spores — very faint ───────────── */
.spores {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 998;
  display: none;
  overflow: hidden;
}

@keyframes spore-drift {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.5); }
  8%   { opacity: 0.4; }
  90%  { opacity: 0.15; }
  100% { opacity: 0; transform: translate(var(--drift-x, 20px), -100vh) scale(1); }
}

.spore {
  position: absolute;
  bottom: -6px;
  left: var(--sx);
  width: var(--ss, 2px);
  height: var(--ss, 2px);
  border-radius: 50%;
  background: rgba(180, 40, 20, 0.5);
  animation: spore-drift var(--sd, 16s) var(--delay, 0s) ease-out infinite;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 980px) {
  :root { --overlay-top: 74px; }
  .grid-admin { grid-template-columns: 1fr; }
  .control-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vein-left, .vein-right { width: 70px; opacity: 0.25; }
  .user-sidebar {
    width: min(420px, 100vw);
  }
  .chat-sidebar {
    width: min(380px, 100vw);
  }
  .sidebar-toggle {
    right: 12px;
  }
  .chat-toggle {
    left: 12px;
  }
}

@media (max-width: 600px) {
  :root { --overlay-top: 122px; }
  .topbar {
    flex-direction: column;
    text-align: center;
    padding: 0.7rem 1rem;
  }
  .topbar div { justify-content: center; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.4rem; }
  .grid-admin { padding: 0.5rem; gap: 0.5rem; }
  .player-panel { margin: 0.5rem; }
  .player-header-row {
    flex-direction: column;
    align-items: stretch;
  }
  .sidebar-toggle {
    right: 10px;
    min-width: 120px;
    padding: 0.52rem 0.7rem;
  }
  .chat-toggle {
    left: 10px;
    min-width: 110px;
    padding: 0.52rem 0.7rem;
  }
  .chat-sidebar {
    width: 100vw;
  }
  .user-sidebar {
    width: 100vw;
  }
  .upside-trees { height: 65px; }
  .vein-left, .vein-right { display: none; }
  .stack.compact { max-width: 100%; }
}
