/* VibeStream — Modern Cinema & Media Hub Styles
 * Semantic Design Token Architecture · Day/Light & Night/Dark Themes · Fluid Scale · Mobile-First
 */

:root {
  /* Day / Light Mode Semantic Design Tokens */
  --color-bg-base: #f8fafc;
  --color-bg-surface: #ffffff;
  --color-bg-surface-raised: #f1f5f9;
  --color-bg-surface-elevated: #e2e8f0;
  --color-bg-overlay: rgba(255, 255, 255, 0.92);
  
  --color-text-primary: #0f172a;
  --color-text-secondary: #334155;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  
  --color-border-subtle: rgba(15, 23, 42, 0.08);
  --color-border-strong: rgba(15, 23, 42, 0.16);
  --color-border-hover: rgba(15, 23, 42, 0.28);
  
  --color-primary: #ff0033;
  --color-primary-hover: #e6002e;
  --color-primary-glow: rgba(255, 0, 51, 0.25);
  
  --color-scrollbar-thumb: rgba(15, 23, 42, 0.22);
  --color-scrollbar-thumb-hover: rgba(255, 0, 51, 0.6);
  
  --backdrop-filter-color: rgba(15, 23, 42, 0.45);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-raised: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  --shadow-cinema: 0 20px 50px -10px rgba(15, 23, 42, 0.25);

  /* Fluid Typography Scale Tokens */
  --text-display: clamp(1.5rem, 3.5vw + 0.5rem, 2.25rem);
  --text-h1: clamp(1.125rem, 2vw + 0.5rem, 1.5rem);
  --text-h2: clamp(0.95rem, 1.5vw + 0.4rem, 1.25rem);
  --text-h3: clamp(0.85rem, 1.2vw + 0.4rem, 1.05rem);
  --text-body: clamp(0.8125rem, 1vw + 0.35rem, 0.875rem);
  --text-caption: clamp(0.6875rem, 0.8vw + 0.3rem, 0.75rem);
}

html.dark {
  /* Night / Dark Mode Semantic Design Tokens */
  --color-bg-base: #09090b;
  --color-bg-surface: #18181b;
  --color-bg-surface-raised: #27272a;
  --color-bg-surface-elevated: #3f3f46;
  --color-bg-overlay: rgba(9, 9, 11, 0.94);
  
  --color-text-primary: #f4f4f5;
  --color-text-secondary: #a1a1aa;
  --color-text-muted: #71717a;
  --color-text-subtle: #52525b;
  
  --color-border-subtle: rgba(255, 255, 255, 0.08);
  --color-border-strong: rgba(255, 255, 255, 0.16);
  --color-border-hover: rgba(255, 255, 255, 0.28);
  
  --color-primary: #ff0033;
  --color-primary-hover: #ff2654;
  --color-primary-glow: rgba(255, 0, 51, 0.35);
  
  --color-scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --color-scrollbar-thumb-hover: rgba(255, 0, 51, 0.6);
  
  --backdrop-filter-color: rgba(0, 0, 0, 0.82);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.6);
  --shadow-raised: 0 10px 30px -10px rgba(0, 0, 0, 0.8);
  --shadow-cinema: 0 20px 50px -10px rgba(0, 0, 0, 0.95);
}

@layer base {
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  html, body {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
  }

  body {
    background-color: var(--color-bg-base);
    color: var(--color-text-primary);
    transition: background-color 200ms ease, color 200ms ease;
  }
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-scrollbar-thumb); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-scrollbar-thumb-hover); }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Safe Area Inset Support (Optimized for Android Gesture Bar & Notches) */
.safe-top { padding-top: env(safe-area-inset-top, 0px); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
.safe-left { padding-left: env(safe-area-inset-left, 0px); }
.safe-right { padding-right: env(safe-area-inset-right, 0px); }
.safe-pb-floating { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem); }

/* YouTube-Style Timestamp & Latency Badges */
.yt-badge {
  background-color: rgba(0, 0, 0, 0.78);
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 1.5px 5px;
  border-radius: 4px;
  letter-spacing: -0.01em;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* 120Hz Fast Touch Momentum Scrolling for Chips & Carousels */
.chip-scroll {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  will-change: scroll-position;
}
.chip-scroll::-webkit-scrollbar {
  display: none;
}

/* Ergonomic Touch Target (44x44px minimum hit area without layout expansion) */
.touch-target {
  position: relative;
}
.touch-target::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* iOS Safari 16px Font Auto-Zoom Prevention on Mobile */
@media screen and (max-width: 640px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Micro Animations */
@keyframes spinFast { to { transform: rotate(360deg); } }
.animate-spin-fast { animation: spinFast 0.7s linear infinite; }

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 15px var(--color-primary-glow); }
  50% { box-shadow: 0 0 25px rgba(255, 0, 51, 0.6); }
}
.animate-glow { animation: pulseGlow 2s ease-in-out infinite; }

@keyframes eqWave {
  0%, 100% { height: 3px; }
  50% { height: 11px; }
}
.animate-eq-1 { animation: eqWave 0.65s ease-in-out infinite; }
.animate-eq-2 { animation: eqWave 0.65s ease-in-out 0.2s infinite; }
.animate-eq-3 { animation: eqWave 0.65s ease-in-out 0.4s infinite; }

/* Hero Cinema Player */
.hero-player {
  transition: box-shadow 260ms cubic-bezier(0.16, 1, 0.3, 1), border-color 260ms ease, border-radius 260ms ease;
  will-change: transform;
}

/* Mobile Top-Snap Hero Player (YouTube-Style Native Experience) */
.hero-snap-mobile {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  width: 100vw;
  z-index: 50;
  background-color: #000;
  border-bottom: 2px solid var(--color-primary);
  box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.98);
  border-radius: 0 !important;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 220ms ease;
}

/* Desktop Floating Cinema PiP Card */
.hero-floating-pip {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  right: 1.5rem;
  width: min(25rem, calc(100vw - 3rem));
  z-index: 45;
  box-shadow: var(--shadow-cinema), 0 0 30px var(--color-primary-glow);
  border: 1.5px solid var(--color-primary);
  border-radius: 1.25rem;
  overflow: hidden;
  backdrop-filter: blur(24px);
  background-color: var(--color-bg-overlay);
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-media {
  max-height: 480px;
  transition: max-height 240ms ease;
}

/* Native Dialogs & Popovers */
dialog {
  border: none;
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  transition: opacity 240ms cubic-bezier(0.16, 1, 0.3, 1), transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
dialog[open] {
  animation: modalPop 240ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
dialog::backdrop {
  background: var(--backdrop-filter-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: backdropFade 240ms ease forwards;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes backdropFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(44rem, calc(100% - 1.5rem));
  max-height: calc(100vh - 2.5rem);
  overflow: hidden;
  z-index: 100;
}
.settings-dialog form {
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Grids: Mobile-First Responsive Media Feeds */
.gallery-grid-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.875rem;
}
@media (min-width: 640px) {
  .gallery-grid-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
}
@media (min-width: 1024px) {
  .gallery-grid-1 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
}
@media (min-width: 1400px) {
  .gallery-grid-1 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.5rem; }
}

/* 2-Column Compact Grid (Optimized for Mobile Information Density on Infinix Note 30 5G) */
.gallery-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .gallery-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
}

/* Hardware-Accelerated Zero-Stutter Virtualization */
.gallery-grid-1 > article,
.gallery-grid-2 > article,
.gallery-stack > article {
  content-visibility: auto;
  contain-intrinsic-size: auto 240px;
  contain: layout style paint;
}
@media (min-width: 768px) {
  .gallery-grid-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
}
@media (min-width: 1100px) {
  .gallery-grid-2 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.125rem; }
}
@media (min-width: 1400px) {
  .gallery-grid-2 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1.25rem; }
}

.gallery-stack {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* Mobile Dialog Optimizations */
@media (max-width: 640px) {
  dialog, #crawlerModal, #mediaModal, .settings-dialog {
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
    max-height: calc(100vh - 2rem) !important;
    border-radius: 1.25rem !important;
    margin: auto !important;
    overflow: hidden !important;
  }

  #crawlerModal > div, #mediaModal > form, .settings-dialog > form {
    max-height: calc(100vh - 3.5rem) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1rem !important;
  }

  button, select, a {
    min-height: 38px;
  }

  .touch-target-sm {
    min-height: 32px;
  }
}

/* Glassmorphic Surfaces */
.glass-panel {
  background: var(--color-bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-border-subtle);
}

.glass-card {
  background: var(--color-bg-surface-raised);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-subtle);
}