/* ==========================================================================
   BAPPHIM — AURORA CINEMA DESIGN SYSTEM v2
   Brand Tagline: "Thế giới phim trong một chạm."
   NOTE: Legacy token names are preserved for backward compatibility
   (admin views reference them via inline styles).
   ========================================================================== */

:root {
  /* ---------- Surfaces ---------- */
  --bg-primary: #05060B;
  --bg-secondary: #090B14;
  --bg-surface: #0E1120;
  --bg-card: #131729;
  --bg-card-hover: #1A1F36;
  --bg-input: #0B0E1A;
  --bg-elevated: #171B2F;
  --bg-glass: rgba(17, 20, 36, 0.55);
  --bg-glass-strong: rgba(12, 14, 26, 0.82);

  /* ---------- Brand Accent (Amber → Rose → Violet) ---------- */
  --color-accent: #FFB020;
  --color-accent-hover: #FF9500;
  --color-accent-light: #FFD98A;
  --color-accent-glow: rgba(255, 176, 32, 0.35);
  --color-rose: #FF4D6D;
  --color-violet: #8B5CF6;
  --color-cyan: #22D3EE;
  --color-accent-gradient: linear-gradient(135deg, #FFD166 0%, #FFB020 35%, #FF6B4A 75%, #FF4D6D 100%);
  --color-hero-gradient: linear-gradient(135deg, #FFB020 0%, #FF4D6D 55%, #8B5CF6 100%);
  --gradient-aurora: linear-gradient(120deg, #FFB020, #FF4D6D, #8B5CF6, #22D3EE, #FFB020);
  --gradient-border: linear-gradient(135deg, rgba(255, 176, 32, 0.8), rgba(255, 77, 109, 0.6), rgba(139, 92, 246, 0.7));

  /* ---------- Text ---------- */
  --text-white: #FFFFFF;
  --text-primary: #F4F5FA;
  --text-secondary: #A3A9C2;
  --text-muted: #6B7290;
  --text-dark: #343A55;

  /* ---------- Borders ---------- */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(255, 176, 32, 0.45);

  /* ---------- Status ---------- */
  --status-success: #22C55E;
  --status-warning: #FFB020;
  --status-danger: #FF4D6D;
  --status-info: #60A5FA;

  /* ---------- Typography ---------- */
  --font-main: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-heading: 'Lexend', 'Be Vietnam Pro', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* ---------- Radii ---------- */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;

  /* ---------- Shadows ---------- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 34px -8px rgba(0, 0, 0, 0.7), 0 4px 10px -4px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 30px 60px -12px rgba(0, 0, 0, 0.85);
  --shadow-glow: 0 0 0 1px rgba(255, 176, 32, 0.25), 0 10px 40px -6px rgba(255, 140, 50, 0.55);
  --shadow-gold: 0 10px 30px -8px rgba(255, 140, 50, 0.55);
  --shadow-hover: 0 24px 50px -12px rgba(0, 0, 0, 0.9), 0 0 40px -10px rgba(255, 120, 60, 0.45);

  /* ---------- Motion ---------- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 520ms cubic-bezier(0.16, 1, 0.3, 1);

  /* ---------- Layout ---------- */
  --header-height: 76px;
  --bottom-nav-height: 68px;
  --max-content-width: 1480px;
}

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

html {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: var(--bg-primary);
  position: relative;
}

/* Strict media and element boundaries to prevent screen blowout */
img, picture, video, canvas, svg {
  max-width: 100%;
}

iframe {
  max-width: 100%;
}

input, button, select, textarea {
  max-width: 100%;
}

h1, h2, h3, h4, h5, h6, p, a, span {
  overflow-wrap: break-word;
}

::selection {
  background: rgba(255, 176, 32, 0.35);
  color: #fff;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
  line-height: 1.2;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: transparent;
  outline: none;
}

button { cursor: pointer; }

select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ==========================================================================
   Typography utilities
   ========================================================================== */
.heading-hero {
  font-family: var(--font-heading);
  font-size: clamp(2.1rem, 4.2vw + 1rem, 4rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.03em;
}

.heading-section {
  font-family: var(--font-heading);
  font-size: clamp(1.25rem, 1.6vw + 0.7rem, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-white);
}

.text-gold { color: var(--color-accent); }

.text-gradient {
  background: var(--color-accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-aurora {
  background: var(--gradient-aurora);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: auroraShift 8s linear infinite;
}

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* ==========================================================================
   Container
   ========================================================================== */
.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(14px, 3.2vw, 40px);
  padding-right: clamp(14px, 3.2vw, 40px);
  min-width: 0;
  box-sizing: border-box;
}

@media (max-width: 480px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (max-width: 360px) {
  .container {
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  --btn-bg: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1.2;
  padding: 11px 22px;
  border-radius: var(--radius-full);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  isolation: isolate;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal),
              background var(--transition-normal), border-color var(--transition-normal), color var(--transition-fast);
}

.btn:active { transform: scale(0.96); }

/* Shine sweep */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 700ms var(--ease-out);
  z-index: -1;
  pointer-events: none;
}

.btn:hover::after { transform: translateX(120%); }

.btn-primary {
  background: var(--color-accent-gradient);
  background-size: 160% 160%;
  background-position: 0% 50%;
  color: #170B02;
  box-shadow: var(--shadow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background-position: 100% 50%;
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  color: #0B0500;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text-white);
  transform: translateY(-2px);
}

.btn-secondary.active {
  border-color: rgba(255, 77, 109, 0.55);
  background: rgba(255, 77, 109, 0.12);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.06);
}

.btn-danger {
  background: rgba(255, 77, 109, 0.12);
  color: #FF8DA1;
  border: 1px solid rgba(255, 77, 109, 0.35);
}

.btn-danger:hover {
  background: rgba(255, 77, 109, 0.22);
  color: #fff;
  transform: translateY(-2px);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.btn-lg {
  padding: 15px 32px;
  font-size: 1.04rem;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
}

/* Ripple (injected by effects.js) */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255, 255, 255, 0.45);
  animation: rippleOut 650ms ease-out forwards;
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-gold {
  background: rgba(255, 176, 32, 0.16);
  color: var(--color-accent-light);
  border: 1px solid rgba(255, 176, 32, 0.42);
}

.badge-quality {
  background: linear-gradient(135deg, #FF4D6D, #FF6B4A);
  color: #FFFFFF;
  box-shadow: 0 4px 14px -4px rgba(255, 77, 109, 0.7);
}

.badge-lang {
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #FFFFFF;
  box-shadow: 0 4px 14px -4px rgba(139, 92, 246, 0.7);
}

.badge-rating {
  background: rgba(9, 11, 20, 0.85);
  color: #FFD166;
  border: 1px solid rgba(255, 209, 102, 0.35);
}

.badge-glass {
  background: rgba(14, 17, 32, 0.82);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* ==========================================================================
   Glass panel primitive
   ========================================================================== */
.glass-panel {
  position: relative;
  background: linear-gradient(160deg, rgba(23, 27, 47, 0.72), rgba(12, 14, 26, 0.72));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Animated gradient border (use on any element) */
.gradient-border {
  position: relative;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: var(--gradient-aurora);
  background-size: 300% 300%;
  animation: auroraShift 6s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.85;
}

/* ==========================================================================
   Card Grid System
   ========================================================================== */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (max-width: 360px) {
  .movie-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

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

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

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

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

@media (min-width: 1600px) {
  .movie-grid { grid-template-columns: repeat(7, 1fr); gap: 24px; }
}

@media (min-width: 2000px) {
  .movie-grid { grid-template-columns: repeat(8, 1fr); gap: 26px; }
}

@media (min-width: 1800px) {
  :root { --max-content-width: 1720px; }
}

@media (min-width: 2200px) {
  :root { --max-content-width: 2040px; }
}

/* Touch & Tap optimization */
button, a, input, select, textarea {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   Scroll reveal primitives (driven by effects.js)
   ========================================================================== */
.reveal {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2A2F4A, #1C2036);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #FFB020, #FF4D6D);
}

/* ==========================================================================
   Keyframes
   ========================================================================== */
@keyframes auroraShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

@keyframes rippleOut {
  to { transform: scale(4); opacity: 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 176, 32, 0.55); }
  50% { box-shadow: 0 0 0 14px rgba(255, 176, 32, 0); }
}

@keyframes heartPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.45); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes particleBurst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}
