/* ═══════════════════════════════════════════════════════════
   Running Man Fandom – Custom CSS
   Primary: #3968b0 | Accent: #f1e926
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary: #3968b0;
  --primary-dark: #2d549a;
  --primary-light: #4a79c4;
  --accent: #f1e926;
  --dark-bg: #0d1b2a;
  --card-bg: #162236;
  --card-border: #253a54;
  --muted: #8ba3c1;
}

/* ── Scrollbar ─────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) rgba(37, 58, 84, 0.5);
}
*::-webkit-scrollbar { width: 5px; height: 5px; }
*::-webkit-scrollbar-track { background: var(--card-bg); }
*::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

/* ── Base ──────────────────────────────────────────────── */
body {
  background: var(--dark-bg);
  color: #e8f0fa;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Desktop Nav Links ─────────────────────────────────── */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s ease;
}
.nav-link:hover {
  color: #fff;
  background: rgba(57, 104, 176, 0.15);
}
.nav-link.active {
  color: var(--accent);
  background: rgba(241, 233, 38, 0.08);
}
.nav-link svg { flex-shrink: 0; }

/* ── Mobile Bottom Nav ─────────────────────────────────── */
.bottom-nav {
  background: rgba(22, 34, 54, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
  padding: 0.4rem 0;
  position: relative;
}
.bottom-nav-item.active {
  color: var(--accent);
}
.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.875rem;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(57, 104, 176, 0.2);
}

.info-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.875rem;
  padding: 1rem 1.125rem;
}

/* ── Episode Cards ─────────────────────────────────────── */
.episode-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.875rem;
  padding: 1rem 1.125rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.episode-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(57, 104, 176, 0.2);
  transform: translateX(3px);
}
.episode-card.latest {
  border-color: rgba(241, 233, 38, 0.5);
  background: linear-gradient(135deg, rgba(241, 233, 38, 0.04) 0%, var(--card-bg) 60%);
}
.episode-card.latest:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(241, 233, 38, 0.15);
}

/* ── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-primary {
  background: rgba(57, 104, 176, 0.18);
  color: #7faadf;
  border: 1px solid rgba(57, 104, 176, 0.35);
}
.badge-accent {
  background: rgba(241, 233, 38, 0.12);
  color: var(--accent);
  border: 1px solid rgba(241, 233, 38, 0.3);
}
.badge-green {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.badge-red {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.badge-latest {
  background: rgba(241, 233, 38, 0.15);
  color: var(--accent);
  border: 1px solid rgba(241, 233, 38, 0.4);
  animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(241, 233, 38, 0.3); }
  50% { box-shadow: 0 0 0 4px rgba(241, 233, 38, 0); }
}

/* ── Year Tabs ─────────────────────────────────────────── */
.year-tab {
  padding: 0.5rem 1.25rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
}
.year-tab:hover {
  color: #fff;
  border-color: var(--primary);
}
.year-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(57, 104, 176, 0.4);
}

/* ── Year Dropdown ─────────────────────────────────────── */
.year-dropdown {
  padding: 0.5rem 2rem 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  border: 1px solid var(--primary);
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 0.65rem center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(57, 104, 176, 0.4);
  transition: all 0.2s ease;
}
.year-dropdown:hover,
.year-dropdown:focus {
  outline: none;
  box-shadow: 0 4px 20px rgba(57, 104, 176, 0.6);
}
.year-dropdown option {
  background: var(--card-bg, #1a1f2e);
  color: #fff;
}


.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--card-bg);
  color: var(--muted);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.2s ease;
}
.sort-btn:hover {
  color: #fff;
  border-color: var(--primary);
}

/* ── Trend Chips ───────────────────────────────────────── */
.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4375rem 0.875rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: #b8cde8;
  transition: all 0.2s ease;
  cursor: default;
}
.trend-chip:hover {
  border-color: var(--primary);
  color: #fff;
  background: rgba(57, 104, 176, 0.1);
}

/* ── News Cards ────────────────────────────────────────── */
.news-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.875rem;
  overflow: hidden;
  transition: all 0.25s ease;
  text-decoration: none;
  display: flex;
  flex-direction: column;
}
.news-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(57, 104, 176, 0.2);
}

/* ── Section Title ─────────────────────────────────────── */
.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1.125rem;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Hero ──────────────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, #0f2035 0%, #1a2c42 60%, #1e3452 100%);
  border: 1px solid var(--card-border);
  border-radius: 1.25rem;
  overflow: hidden;
  position: relative;
}
.hero-section::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(57, 104, 176, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Horizontal Scroll ─────────────────────────────────── */
.scroll-x {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.scroll-x > * {
  flex-shrink: 0;
  scroll-snap-align: start;
}

/* ── Popup / Modal ─────────────────────────────────────── */
#popup-overlay {
  animation: fadeIn 0.18s ease forwards;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.popup-inner {
  animation: slideUp 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.popup-field {
  background: rgba(37, 58, 84, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 0.625rem;
  padding: 0.75rem;
}
.popup-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.popup-value {
  font-size: 0.875rem;
  color: #e8f0fa;
  line-height: 1.5;
}

/* ── Ratings Table ─────────────────────────────────────── */
.rating-table { width: 100%; border-collapse: collapse; }
.rating-table th {
  background: rgba(57, 104, 176, 0.15);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--card-border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.rating-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(37, 58, 84, 0.4);
  cursor: pointer;
  transition: background 0.15s ease;
}
.rating-table tr:last-child td { border-bottom: none; }
.rating-table tbody tr:hover td {
  background: rgba(57, 104, 176, 0.08);
}
.rating-table tr.row-highest td {
  background: rgba(57, 104, 176, 0.12);
}
.rating-table tr.row-highest .rating-val {
  color: #7faadf;
  font-weight: 700;
}
.rating-table tr.row-lowest td {
  background: rgba(239, 68, 68, 0.07);
}
.rating-table tr.row-lowest .rating-val {
  color: #f87171;
  font-weight: 700;
}
.rating-table tr.row-latest td {
  background: rgba(241, 233, 38, 0.05);
}
.rating-table tr.row-latest {
  border-left: 2px solid rgba(241, 233, 38, 0.6);
}
.badge-latest-row {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.125rem 0.4rem;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 700;
  background: rgba(241, 233, 38, 0.15);
  color: var(--accent);
  border: 1px solid rgba(241, 233, 38, 0.4);
  vertical-align: middle;
  margin-left: 0.35rem;
  letter-spacing: 0.03em;
}

/* ── Stat Summary Cards ────────────────────────────────── */
.stats-grid {
  /* mobile: 2-row horizontal scroll, 2 cards visible per view */
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  grid-auto-columns: calc((100vw - 2.625rem) / 2);
  gap: 0.625rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stats-grid::-webkit-scrollbar { display: none; }
@media (min-width: 640px) {
  .stats-grid {
    grid-template-rows: unset;
    grid-auto-flow: unset;
    grid-auto-columns: unset;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
    padding-bottom: 0;
  }
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.875rem;
  padding: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  scroll-snap-align: start;
}
@media (min-width: 640px) {
  .stat-card { padding: 1rem; gap: 0.75rem; }
}
.stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(57, 104, 176, 0.15);
}
.stat-card-latest {
  border-color: rgba(241, 233, 38, 0.35);
  background: linear-gradient(135deg, rgba(241,233,38,0.04) 0%, var(--card-bg) 70%);
}
.stat-card-latest:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(241, 233, 38, 0.12);
}
.stat-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-body { flex: 1; min-width: 0; }
.stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
  line-height: 1.3;
}
.stat-value {
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.stat-sub {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ── Trend Arrows ──────────────────────────────────────── */
.trend-arrow {
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  flex-shrink: 0;
}
.trend-up   { color: #4ade80; }
.trend-down { color: #f87171; }
.trend-flat { color: var(--muted); }

/* ── Diff Chip (Seoul − NW) ────────────────────────────── */
.diff-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.diff-pos  { background: rgba(167,139,250,0.12); color: #a78bfa; border: 1px solid rgba(167,139,250,0.3); }
.diff-neg  { background: rgba(248,113,113,0.1);  color: #f87171; border: 1px solid rgba(248,113,113,0.25); }
.diff-zero { background: rgba(139,163,193,0.1);  color: var(--muted); border: 1px solid rgba(139,163,193,0.2); }

/* ── Chart Wrapper ─────────────────────────────────────── */
.chart-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  padding: 1.5rem;
  position: relative;
}

/* ── Poster ────────────────────────────────────────────── */
.poster-card {
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--card-border);
  transition: border-color 0.2s ease;
}
.poster-card:hover {
  border-color: var(--primary);
}

/* ── Upcoming Episode Style ────────────────────────────── */
.episode-card.upcoming {
  opacity: 0.6;
  border-style: dashed;
}

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
  animation: fadeInUp 0.35s ease forwards;
}

/* ── Utility ───────────────────────────────────────────── */
.text-muted-custom { color: var(--muted); }
.border-primary-custom { border-color: var(--primary); }
.bg-card { background: var(--card-bg); }
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Trakteer Support Card ─────────────────────────────── */
.trakteer-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1a1a 0%, #1e2a1e 40%, #1a2010 100%);
  border: 1px solid rgba(233, 66, 53, 0.35);
  border-radius: 1.125rem;
  padding: 1.75rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.trakteer-card:hover {
  border-color: rgba(233, 66, 53, 0.65);
  box-shadow: 0 8px 32px rgba(233, 66, 53, 0.15);
}
.trakteer-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(60px);
}
.trakteer-glow-1 {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(233,66,53,0.18) 0%, transparent 70%);
  top: -60px;
  right: -40px;
}
.trakteer-glow-2 {
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(241,233,38,0.07) 0%, transparent 70%);
  bottom: -40px;
  left: 20px;
}
.trakteer-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.trakteer-brand-name {
  font-size: 0.8125rem;
  font-weight: 800;
  color: #E94235;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.trakteer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 800;
  color: #fff;
  background: #E94235;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 16px rgba(233,66,53,0.35);
  letter-spacing: 0.01em;
}
.trakteer-btn:hover {
  background: #c73528;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(233,66,53,0.45);
}
.trakteer-btn:active {
  transform: translateY(0);
}
.trakteer-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Trakteer Floating Action Button ───────────────────── */
#trakteer-fab {
  position: fixed;
  bottom: 5.5rem;   /* above mobile bottom nav */
  right: 1rem;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: #E94235;
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 20px rgba(233,66,53,0.45), 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  /* Entry animation */
  animation: fabEntrance 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.8s both;
}
@keyframes fabEntrance {
  from { opacity: 0; transform: scale(0.6) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
#trakteer-fab:hover {
  background: #c73528;
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 8px 28px rgba(233,66,53,0.55), 0 2px 8px rgba(0,0,0,0.4);
}
#trakteer-fab:active {
  transform: scale(0.97);
}
/* On desktop: higher position (no mobile nav) */
@media (min-width: 768px) {
  #trakteer-fab {
    bottom: 2rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
  }
}
/* Label hidden on very small screens to keep it compact */
@media (max-width: 380px) {
  #trakteer-fab .fab-label { display: none; }
  #trakteer-fab { padding: 0.75rem; border-radius: 50%; }
}
/* Pulse ring */
#trakteer-fab::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(233,66,53,0.5);
  animation: fabPulse 2.5s ease-out 1.5s infinite;
}
@keyframes fabPulse {
  0%   { box-shadow: 0 0 0 0 rgba(233,66,53,0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(233,66,53,0); }
  100% { box-shadow: 0 0 0 0 rgba(233,66,53,0); }
}
