/* ═══════════════════════════════════════════════════════════════════
   TweetVault — Global Stylesheet
   Premium dark glassmorphism design
═══════════════════════════════════════════════════════════════════ */

/* Fonts now loaded non-blocking via HTML <link> tags */

/* ── Design Tokens ──────────────────────────────────────────────── */
:root {
  --bg-base:        #08080f;
  --bg-card:        rgba(18, 18, 32, 0.75);
  --bg-card-hover:  rgba(26, 26, 46, 0.90);
  --border:         rgba(139, 92, 246, 0.18);
  --border-hover:   rgba(139, 92, 246, 0.45);

  --accent:         #8b5cf6;        /* purple */
  --accent-glow:    rgba(139, 92, 246, 0.35);
  --accent2:        #06b6d4;        /* cyan */
  --accent2-glow:   rgba(6, 182, 212, 0.25);
  --danger:         #ef4444;

  --text-primary:   #f1f0ff;
  --text-secondary: #9ca3b8;
  --text-muted:     #4b5680;

  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;

  --shadow-card:    0 4px 24px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
  --shadow-hover:   0 8px 40px rgba(0,0,0,0.65), 0 0 0 1px var(--border-hover), 0 0 24px var(--accent-glow);
  --shadow-glow:    0 0 32px var(--accent-glow);

  --transition:     all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  /* Subtle animated radial gradient background */
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(139,92,246,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(6,182,212,0.08) 0%, transparent 55%);
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { display: block; }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.35); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Glassmorphism card ─────────────────────────────────────────── */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}
.glass:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px) scale(1.012);
}

/* ── Header ─────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 15, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(16px, 4vw, 48px);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.logo-text { background: linear-gradient(90deg, #e0d7ff, var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* ── Search & Resolve bar ───────────────────────────────────────── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 680px;
  margin: 0 auto;
}

.input-wrap {
  position: relative;
  flex: 1;
}
.input-icon {
  position: absolute;
  left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 15px;
}
.tv-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 10px 14px 10px 38px;
  outline: none;
  transition: var(--transition);
}
.tv-input::placeholder { color: var(--text-muted); }
.tv-input:focus {
  border-color: var(--accent);
  background: rgba(139,92,246,0.07);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { background: linear-gradient(135deg, #a78bfa, var(--accent)); box-shadow: 0 4px 20px var(--accent-glow); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255,255,255,0.07);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); border-color: var(--border-hover); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ── Nav tabs ────────────────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 0 clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.nav-tab {
  padding: 14px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
  white-space: nowrap;
}
.nav-tab:hover { color: var(--text-secondary); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Sort controls ───────────────────────────────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sort-label { font-size: 0.8rem; color: var(--text-muted); }
.sort-pill, .period-pill {
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.sort-pill:hover, .sort-pill.active,
.period-pill:hover, .period-pill.active {
  background: rgba(139,92,246,0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.duration-filter {
  display: flex;
  align-items: center;
  gap: 6px;
}
.duration-filter input {
  width: 60px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  outline: none;
  transition: var(--transition);
}
.duration-filter input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ── Main layout ─────────────────────────────────────────────────── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  max-width: 1600px;
  margin: 0 auto;
}
@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ── Video grid ──────────────────────────────────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

/* ── Video card ──────────────────────────────────────────────────── */
.video-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.card-thumb-wrap {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: #12121f;
}
.card-thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.video-card:hover .card-thumb-wrap img { transform: scale(1.06); }

.card-play-btn {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: var(--transition);
}
.card-play-btn svg { width: 52px; height: 52px; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6)); }
.video-card:hover .card-play-btn { opacity: 1; }

.card-duration {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 7px;
  border-radius: 5px;
  backdrop-filter: blur(4px);
}
.card-status-badge {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.5px;
}
.badge-expired { background: rgba(239,68,68,0.8); color: #fff; }
.badge-error   { background: rgba(100,100,100,0.8); color: #fff; }

.card-body {
  padding: 12px 14px 14px;
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: var(--transition);
}
.video-card:hover .card-body {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.card-author {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 6px;
}
.author-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.author-name { font-size: 0.78rem; color: var(--accent2); font-weight: 500; }

.card-title {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.card-stats {
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.stat { display: flex; align-items: center; gap: 4px; }
.stat svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.sidebar-section {
  padding: 16px;
}
.sidebar-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Leaderboard entry ───────────────────────────────────────────── */
.lb-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}
.lb-entry:hover { background: rgba(255,255,255,0.05); }
.lb-rank {
  width: 24px; text-align: center;
  font-size: 0.75rem; font-weight: 700;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}
.lb-rank.top3 { color: var(--accent); }
.lb-thumb {
  width: 52px; height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #12121f;
}
.lb-meta { flex: 1; min-width: 0; }
.lb-author { font-size: 0.7rem; color: var(--accent2); }
.lb-title {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-score { font-size: 0.7rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* ── System status panel ─────────────────────────────────────────── */
.status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.78rem;
}
.status-row:last-child { border-bottom: none; }
.status-key { color: var(--text-muted); }
.status-val { color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot-green { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.dot-yellow { background: #eab308; box-shadow: 0 0 6px #eab308; }
.dot-red { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* ── Resolve modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box {
  width: 100%; max-width: 520px;
  padding: 28px 32px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal-input-group { display: flex; flex-direction: column; gap: 10px; }
.modal-hint { font-size: 0.78rem; color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.spinner { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 340px;
  box-shadow: var(--shadow-hover);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast-success { background: rgba(34,197,94,0.2); border: 1px solid rgba(34,197,94,0.4); color: #86efac; }
.toast-error   { background: rgba(239,68,68,0.2); border: 1px solid rgba(239,68,68,0.4); color: #fca5a5; }
.toast-info    { background: rgba(139,92,246,0.2); border: 1px solid rgba(139,92,246,0.4); color: #c4b5fd; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.empty-sub { font-size: 0.875rem; }

/* ── Load more ───────────────────────────────────────────────────── */
.load-more-wrap { text-align: center; padding: 32px 0 0; }

/* ── Section header row ──────────────────────────────────────────── */
.section-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

/* ─────────────────────────────────────────────────────────────────
   AD PLACEHOLDERS
   These divs are styled solely to be easy for ad SDKs to target.
   Replace inner content with your ad network's embed snippet.
   ───────────────────────────────────────────────────────────────── */
.ad-slot {
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.015),
    rgba(255,255,255,0.015) 4px,
    transparent 4px,
    transparent 12px
  );
  border: 1px dashed rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  overflow: hidden;
}
.ad-slot--banner     { width: 100%; height: 90px; margin: 0 0 20px; }
.ad-slot--banner-bot { width: 100%; height: 90px; margin: 24px 0 0; }
.ad-slot--sidebar    { width: 100%; height: 250px; }
.ad-slot--interstitial {
  position: fixed; inset: 0;
  z-index: 500;
  border-radius: 0;
  background: rgba(0,0,0,0.8);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
}
.ad-slot--interstitial .close-ad {
  position: absolute; top: 16px; right: 16px;
}

/* ── Video player page ───────────────────────────────────────────── */
.player-layout {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 clamp(16px, 4vw, 48px);
}
.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,0.7), 0 0 0 1px var(--border);
}
.player-wrap .play-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  background: #0a0a14;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}
.player-wrap .play-overlay:hover {
  background: #0e0e1a;
}
.play-btn-lg svg {
  width: 80px; height: 80px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.8));
  transition: transform 0.3s ease;
}
.play-overlay:hover .play-btn-lg svg {
  transform: scale(1.15);
}
.play-hint {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}
.player-caption { margin-top: 20px; }
.player-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.player-author { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.player-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.player-author-name { font-weight: 600; }
.player-author-handle { font-size: 0.82rem; color: var(--text-muted); }
.player-title { font-size: 1.05rem; line-height: 1.5; margin-bottom: 14px; color: var(--text-primary); }
.player-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.player-stat { display: flex; align-items: center; gap: 6px; font-size: 0.875rem; color: var(--text-secondary); }
.player-stat svg { width: 16px; height: 16px; color: var(--accent2); }
.player-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; transition: var(--transition); }
.back-link:hover { color: var(--accent); }

/* ── Expired / error overlay ─────────────────────────────────────── */
.video-error-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  border-radius: var(--radius-lg);
  display: none;
}
.video-error-overlay.visible { display: flex; }
.video-error-icon { font-size: 40px; }
.video-error-msg { font-size: 0.9rem; color: var(--text-secondary); text-align: center; }

/* ── Pagination / infinite scroll sentinel ───────────────────────── */
.scroll-sentinel { height: 1px; }

/* ── Responsive tweaks ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-controls { max-width: 100%; }
  .site-header { height: 56px; }
  .video-grid { grid-template-columns: 1fr; }
  .logo-text { display: none; }
}
