/* ==========================================================================
   CINEWAVE ARCHIVE — MASTER LUXURY CINEMA STYLING
   Optimized for Mobile (390px), iPad/Tablet (768-1024px) & Desktop (1280px+)
   Follows /human_web_design and /web_ui_polish specifications
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Chonburi&family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&display=swap');

:root {
  --color-canvas: #060913;
  --color-surface: #0c1220;
  --color-surface-elevated: #141c30;
  --color-surface-hover: #1c2742;
  --color-line: rgba(255, 255, 255, 0.08);
  --color-line-focus: rgba(245, 158, 11, 0.5);

  --brand-indigo: #3231c3;
  --brand-indigo-glow: rgba(50, 49, 195, 0.4);
  --accent-gold: #f59e0b;
  --accent-gold-hover: #d97706;
  --accent-coral: #f43f5e;
  --accent-emerald: #10b981;

  --color-ink: #f8fafc;
  --color-ink-dim: #94a3b8;
  --color-ink-muted: #64748b;

  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --radius-card: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--color-canvas);
  color: var(--color-ink);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

.font-editorial {
  font-family: 'Chonburi', cursive;
}

.font-mono-num {
  font-family: 'IBM Plex Mono', monospace;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--color-canvas);
}
::-webkit-scrollbar-thumb {
  background: #1e273b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Glassmorphism Navigation */
.glass-nav {
  background: rgba(6, 9, 19, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-line);
}

.glass-card {
  background: rgba(12, 18, 32, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--color-line);
}

/* 60fps Micro-Interactions */
button, .clickable-pill, .series-card {
  transition: transform 180ms var(--ease-spring), opacity 180ms var(--ease-spring), border-color 180ms var(--ease-spring), box-shadow 180ms var(--ease-spring);
}

button:active, .clickable-pill:active {
  transform: scale(0.97) !important;
}

/* Badges */
.badge-dub {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  font-weight: 600;
}

.badge-sub {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #fff;
  font-weight: 600;
}

.badge-cinema {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-weight: 600;
}

.badge-source-m2f {
  background: linear-gradient(135deg, #dc2626, #f43f5e);
  color: #fff;
}

.badge-source-short {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #000;
  font-weight: 700;
}

/* Source Filter Chips */
.source-chip {
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  color: var(--color-ink-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  white-space: nowrap;
}

.source-chip:hover {
  background: var(--color-surface-elevated);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fff;
}

.source-chip.active {
  background: linear-gradient(135deg, #3231c3, #4338ca);
  color: #fff;
  border-color: #6366f1;
  box-shadow: 0 0 20px rgba(50, 49, 195, 0.4);
}

/* Platform Carousel */
.platform-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
}
.platform-carousel::-webkit-scrollbar {
  display: none;
}

.platform-pill {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 9999px;
  padding: 6px 14px 6px 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.75rem;
  min-height: 40px;
}

.platform-pill:hover {
  background: var(--color-surface-elevated);
  border-color: rgba(245, 158, 11, 0.4);
  transform: translateY(-2px);
}

.platform-pill.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.08));
  border-color: var(--accent-gold);
  color: #fff;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.3);
}

.platform-pill img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  background: #1e293b;
}

/* Series Cards */
.series-card {
  position: relative;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  overflow: hidden;
  border: 1px solid var(--color-line);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  content-visibility: auto;
  contain-intrinsic-size: 200px 320px;
  will-change: transform;
}

.series-card:hover {
  transform: translateY(-5px);
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 16px 32px -10px rgba(0, 0, 0, 0.8), 0 0 20px rgba(245, 158, 11, 0.15);
}

.series-poster-box {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #101626;
}

.series-poster-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 450ms var(--ease-spring);
}

.series-card:hover .series-poster-box img {
  transform: scale(1.06);
}

.series-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6, 9, 19, 0.95) 0%, rgba(6, 9, 19, 0.15) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  pointer-events: none;
}

.play-hover-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-hover));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  opacity: 0;
  transition: all 250ms var(--ease-spring);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.6);
}

.series-card:hover .play-hover-btn {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Catalog Responsive Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (min-width: 768px) {
  .catalog-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }
}

@media (min-width: 1024px) {
  .catalog-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
  }
}

@media (min-width: 1280px) {
  .catalog-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 22px;
  }
}

/* Episode Buttons in Drawer */
.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
}

.episode-btn {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-ink-dim);
  cursor: pointer;
  user-select: none;
}

.episode-btn:hover {
  background: var(--color-surface-elevated);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fff;
}

.episode-btn.active {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-hover));
  color: #000;
  border-color: var(--accent-gold);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

/* Theater Overlay */
.theater-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 5, 12, 0.98);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms var(--ease-spring);
}

.theater-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Bottom Navigation Bar */
.mobile-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: rgba(6, 9, 19, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-line);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
}

@media (min-width: 768px) {
  .mobile-nav-bar {
    display: none;
  }
}

/* Shimmer Loading */
.skeleton {
  background: linear-gradient(90deg, #0c1220 25%, #141c30 50%, #0c1220 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
