/* ============================================
   YouTube Discovery Randomizer - Styles
   Mobile-first, dark/light themes
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Light theme (default) */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-muted: #868e96;
  --border-color: #dee2e6;
  --accent: #e63946;
  --accent-hover: #c1121f;
  --accent-glow: rgba(230, 57, 70, 0.3);
  --chip-bg: #e9ecef;
  --chip-active-bg: #e63946;
  --chip-active-text: #ffffff;
  --chip-dimmed: #ced4da;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --text-primary: #e8e8e8;
  --text-secondary: #b8b8b8;
  --text-muted: #888888;
  --border-color: #2a2a4a;
  --accent: #e63946;
  --accent-hover: #ff6b6b;
  --accent-glow: rgba(230, 57, 70, 0.4);
  --chip-bg: #2a2a4a;
  --chip-active-bg: #e63946;
  --chip-active-text: #ffffff;
  --chip-dimmed: #1a1a3a;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Header --- */
.site-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1rem 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  overflow: hidden;
}

[data-theme="dark"] .site-header {
  background: rgba(22, 33, 62, 0.85);
}

.header-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #ff6b6b, #ffa502, var(--accent));
  background-size: 200% 100%;
  animation: accent-shimmer 6s ease-in-out infinite;
}

@keyframes accent-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .header-accent {
    animation: none;
  }
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--accent), #ff6b6b, #ffa502);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.site-tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* --- Dark Mode Toggle --- */
.dark-mode-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  min-width: 44px;
  min-height: 44px;
}

.dark-mode-toggle:hover {
  border-color: var(--accent);
}

.dark-mode-toggle svg {
  color: var(--text-secondary);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* --- Main Content --- */
.main-content {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  gap: 1.5rem;
}

.content-wrapper {
  flex: 1;
  max-width: 800px;
  min-width: 0;
}

/* --- Filter Panel --- */
.filter-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  overflow: hidden;
}

.filter-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.filter-toggle:hover {
  background: var(--bg-tertiary);
}

.filter-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.filter-toggle[aria-expanded="true"] .filter-arrow {
  transform: rotate(180deg);
}

.filter-content {
  padding: 0 1rem 1rem;
}

.filter-group {
  margin-bottom: 0.75rem;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

/* --- Chip Toggles --- */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.95rem;
  background: var(--chip-bg);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.15s ease;
  user-select: none;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.chip.active {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  border-color: var(--chip-active-bg);
}

.chip.dimmed {
  opacity: 0.45;
  cursor: default;
}

.chip.dimmed:hover {
  border-color: transparent;
  color: var(--text-secondary);
}

/* --- Discover Button --- */
.discover-section {
  text-align: center;
  margin: 1.5rem 0;
}

.discover-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2.5rem;
  background: linear-gradient(to bottom, #ef4444, #c1121f);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.discover-btn:hover {
  background: linear-gradient(to bottom, #f87171, #e63946);
  box-shadow: 0 4px 20px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.discover-btn:active {
  transform: translateY(0);
}

/* Subtle pulse animation */
@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow-lg); }
  50% { box-shadow: 0 4px 24px var(--accent-glow); }
}

.discover-btn:not(:hover) {
  animation: pulse 3s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .discover-btn:not(:hover) {
    animation: none;
  }
}

/* --- Video Player --- */
.player-section {
  margin-bottom: 1rem;
  scroll-margin-top: 5rem;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* Padding fallback for browsers without aspect-ratio */
@supports not (aspect-ratio: 16 / 9) {
  .video-container {
    height: 0;
    padding-bottom: 56.25%;
  }
  .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

.video-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.video-info {
  padding: 0 0 0.75rem;
}

.video-info .video-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.video-info .video-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.video-info .category-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

/* --- Message Area --- */
.message-area {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* --- Ad Slots --- */
.ad-slot {
  display: none;  /* Hidden until AdSense is configured */
  align-items: center;
  justify-content: center;
  min-height: 90px;
}

.ad-slot.has-ad {
  display: flex;
}

.ad-slot-bottom.has-ad {
  margin-top: 1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.ad-slot-sidebar {
  display: none;
}

/* --- Footer --- */
.site-footer {
  background: var(--bg-secondary);
  text-align: center;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: auto;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-bottom: 0.25rem;
}

.footer-credit {
  margin: 0;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Tablet (768px+) */
@media (min-width: 768px) {
  .site-title {
    font-size: 1.7rem;
  }

  .site-tagline {
    font-size: 1rem;
  }

  .main-content {
    padding: 1.5rem;
  }

  .discover-btn {
    font-size: 1.3rem;
    padding: 1.1rem 3rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .ad-slot-sidebar.has-ad {
    display: flex;
    width: 300px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
    padding-left: 1.5rem;
    align-self: flex-start;
    position: sticky;
    top: 1rem;
  }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
  .main-content {
    max-width: 1400px;
  }
}
