/* =============================================================
   midnight.css — scoped theme + navbar badge + page UI
   Never mutates existing :root tokens. Only activates when
   body.midnight-mode is present, or for #navMidnightLink.
   ============================================================= */

/* ---------- Navbar link (safe on all pages) ---------- */
.nav-midnight-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}
.nav-midnight-link:hover { transform: translateY(-1px); }
.nav-midnight-link.closed { opacity: 0.7; }
.nav-midnight-link.disabled {
  opacity: 0.45;
  background: rgba(255, 120, 120, 0.08);
  border-color: rgba(255, 120, 120, 0.25);
  cursor: not-allowed;
}

/* Mobile: keep the moon chip compact so the profile chip stays in frame */
@media (max-width: 600px) {
  .nav-midnight-link {
    padding: 4px 8px;
    font-size: 11px;
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
@media (max-width: 380px) {
  .nav-midnight-link {
    max-width: 38px;
    padding: 5px 7px;
    font-size: 0;        /* hide text, keep emoji via ::before */
    gap: 0;
  }
  .nav-midnight-link::before {
    content: "🌙";
    font-size: 14px;
  }
}
.nav-midnight-link.open {
  background: linear-gradient(135deg, rgba(165, 140, 255, 0.22), rgba(91, 64, 180, 0.22));
  border-color: rgba(165, 140, 255, 0.55);
  color: #e6e9ff;
  box-shadow: 0 0 18px rgba(165, 140, 255, 0.35);
  animation: navMidnightPulse 2.4s ease-in-out infinite;
}
@keyframes navMidnightPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(165, 140, 255, 0.28); }
  50%      { box-shadow: 0 0 22px rgba(165, 140, 255, 0.55); }
}

/* ---------- Moonlight theme (scoped to midnight.html only) ---------- */
body.midnight-mode {
  --bg: #05060a;
  --surface: #0e0f16;
  --surface-2: #141726;
  --text: #e6e9ff;
  --text-muted: #9aa0c0;
  --accent: #a58cff;
  --accent2: #7d6bff;
  --accent-bg: #1a1530;
  --border: rgba(165, 140, 255, 0.18);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(165, 140, 255, 0.12), transparent 50%),
    radial-gradient(ellipse at 85% 90%, rgba(70, 50, 140, 0.18), transparent 55%),
    #05060a;
  min-height: 100vh;
  color: var(--text);
}

body.midnight-mode .navbar {
  background: rgba(10, 10, 20, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

/* Starfield — pure CSS, zero image weight */
body.midnight-mode::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 67% 72%, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 15%, rgba(255, 255, 255, 0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 40% 85%, rgba(200, 200, 255, 0.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 12% 60%, rgba(255, 255, 255, 0.55) 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 42%, rgba(255, 255, 255, 0.8) 50%, transparent 51%);
  background-size: 100% 100%;
  opacity: 0.6;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle {
  from { opacity: 0.4; }
  to   { opacity: 0.75; }
}

/* ---------- Page layout ---------- */
.midnight-shell {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 18px 120px;
}

.midnight-banner {
  text-align: center;
  padding: 28px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(165, 140, 255, 0.12), rgba(70, 50, 140, 0.1));
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  margin-bottom: 24px;
}
.midnight-banner h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -0.01em; }
.midnight-banner p  { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }
.midnight-banner .midnight-countdown { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }

.midnight-banner.last-call {
  animation: lastCallPulse 1.2s ease-in-out infinite;
  border-color: #ff7a7a;
}
@keyframes lastCallPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 122, 0); }
  50%      { box-shadow: 0 0 28px 4px rgba(255, 122, 122, 0.35); }
}

/* ---------- Composer ---------- */
.midnight-composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 24px;
}
.midnight-composer textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
}
.midnight-composer textarea::placeholder { color: var(--text-muted); }
.midnight-composer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.midnight-charcount { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.midnight-charcount.warn { color: #ff9e7a; }
.midnight-charcount.bad  { color: #ff6a6a; }
.midnight-post-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.midnight-post-btn:hover:not(:disabled) { transform: translateY(-1px); }
.midnight-post-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Feed ---------- */
.midnight-feed { display: flex; flex-direction: column; gap: 12px; }

.midnight-post {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: transform 0.14s ease, box-shadow 0.2s ease;
}
.midnight-post:hover { box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }

.midnight-post .vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 36px;
  gap: 2px;
}
.midnight-post .vote-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s ease;
}
.midnight-post .vote-btn:hover { color: var(--accent); }
.midnight-post .vote-btn.voted { color: #ff8a5b; }
.midnight-post .vote-btn.voted-down { color: #7193ff; }
.midnight-post .vote-score { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 24px; text-align: center; }

.midnight-post-body { flex: 1; min-width: 0; }
.midnight-post-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.midnight-anon-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--aura, #a58cff);
  box-shadow: 0 0 6px var(--aura, #a58cff);
}
.midnight-post-text {
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.midnight-post-actions {
  margin-top: 8px;
  display: flex;
  gap: 12px;
  font-size: 12px;
}
.midnight-report-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.midnight-report-btn:hover { opacity: 1; color: #ff6a6a; }

.midnight-author {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
a.midnight-author:hover { color: var(--accent); border-bottom-color: var(--accent); }

.midnight-reply-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  opacity: 0.8;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.midnight-reply-toggle:hover { color: var(--accent); opacity: 1; }

.midnight-admin-btn {
  background: rgba(255, 80, 80, 0.08);
  border: 1px solid rgba(255, 80, 80, 0.25);
  color: #ff8a8a;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  margin-left: auto;
}
.midnight-admin-btn:hover { background: rgba(255, 80, 80, 0.18); }

.midnight-replies {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.midnight-reply-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.midnight-reply {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.midnight-reply .midnight-post-text { font-size: 14px; margin-top: 4px; }
.midnight-reply-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.midnight-reply-composer textarea {
  flex: 1;
  min-height: 44px;
  resize: vertical;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.midnight-reply-composer .midnight-post-btn { padding: 6px 14px; font-size: 13px; }

/* ---------- Empty states ---------- */
.midnight-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.midnight-empty .moon-art {
  font-size: 64px;
  margin-bottom: 16px;
  animation: moonrise 4s ease-in-out infinite alternate;
  display: inline-block;
}
@keyframes moonrise {
  from { transform: translateY(4px); filter: drop-shadow(0 0 6px rgba(165, 140, 255, 0.4)); }
  to   { transform: translateY(-4px); filter: drop-shadow(0 0 18px rgba(165, 140, 255, 0.8)); }
}

/* ---------- Closed-state landing ---------- */
.midnight-closed {
  text-align: center;
  padding: 80px 24px 40px;
}
.midnight-closed h1 { font-size: 32px; margin: 12px 0 8px; }
.midnight-closed .big-countdown {
  font-size: 56px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(165, 140, 255, 0.5);
  margin: 12px 0;
  letter-spacing: -0.02em;
}
.midnight-closed .sub { color: var(--text-muted); max-width: 420px; margin: 0 auto 28px; line-height: 1.5; }
.midnight-last-night {
  display: inline-block;
  padding: 14px 22px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 12px;
}

/* ---------- Nav back link ---------- */
.midnight-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 18px;
  font-size: 13px;
}
.midnight-back:hover { color: var(--accent); }

/* ── Random Chat CTA (inside Midnight Mode) ── */
.midnight-randomchat-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(165, 140, 255, 0.12), rgba(165, 140, 255, 0.04));
  border: 1px solid rgba(165, 140, 255, 0.28);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 14px 0;
  color: var(--text);
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.midnight-randomchat-cta:hover {
  transform: translateY(-1px);
  border-color: rgba(165, 140, 255, 0.55);
  background: linear-gradient(135deg, rgba(165, 140, 255, 0.18), rgba(165, 140, 255, 0.06));
}
.midnight-rc-icon {
  font-size: 28px;
  line-height: 1;
  position: relative;
  display: inline-block;
}
.midnight-rc-livedot {
  position: absolute;
  top: -2px;
  right: -4px;
  width: 9px;
  height: 9px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(165, 140, 255, 0.15), 0 0 8px rgba(74, 222, 128, 0.8);
  animation: midnight-rc-pulse 1.6s ease-in-out infinite;
}
@keyframes midnight-rc-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(1.25); }
}
.midnight-rc-body { flex: 1; min-width: 0; }
.midnight-rc-title { font-weight: 700; font-size: 14px; }
.midnight-rc-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.midnight-rc-arrow { margin-left: auto; font-size: 20px; color: var(--accent); }

.midnight-randomchat-cta.compact {
  justify-content: center;
  font-size: 13px;
  padding: 10px 14px;
  margin-top: 16px;
  font-weight: 600;
}
.midnight-randomchat-cta.compact .midnight-rc-arrow { margin-left: 4px; font-size: 16px; }

@media (max-width: 600px) {
  .midnight-randomchat-cta {
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
  }
  .midnight-rc-icon   { font-size: 26px; }
  .midnight-rc-title  { font-size: 13.5px; line-height: 1.3; }
  .midnight-rc-sub    { font-size: 11.5px; line-height: 1.35; margin-top: 3px; }
  .midnight-rc-arrow  { font-size: 18px; }
  .midnight-rc-livedot { width: 8px; height: 8px; top: -1px; right: -3px; }

  .midnight-randomchat-cta.compact {
    flex-wrap: wrap;
    text-align: center;
    font-size: 12.5px;
    padding: 10px 12px;
    line-height: 1.35;
  }
}

@media (max-width: 380px) {
  .midnight-randomchat-cta { padding: 11px 12px; gap: 9px; }
  .midnight-rc-icon   { font-size: 22px; }
  .midnight-rc-title  { font-size: 12.5px; }
  .midnight-rc-sub    { font-size: 11px; }
  .midnight-rc-arrow  { font-size: 16px; }
}

/* Long-press / tap feedback on touch devices — hover doesn't fire on tap */
@media (hover: none) {
  .midnight-randomchat-cta:active {
    transform: scale(0.985);
    border-color: rgba(165, 140, 255, 0.55);
  }
}
