/* 全局样式 */
:root {
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --secondary: #ec4899;
  --secondary-dark: #db2777;
  --vh: 1vh;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #ffffff;
  background: linear-gradient(135deg, #1f2937 0%, #6b46c1 50%, #1e40af 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 防止水平滚动 */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* 导航栏滚动效果 */
#navbar.scroll {
  background-color: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* 轮播图样式 */
.carousel-item.active {
  opacity: 1;
  z-index: 1;
}

.carousel-slide {
  opacity: 0;
  transition: opacity 1s ease-in-out;
}

.carousel-slide.active {
  opacity: 1;
}

.carousel-dot.active {
  background-color: rgba(255, 255, 255, 0.9);
  transform: scale(1.2);
}

/* 移动端菜单 */
#mobileMenu.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* 电影卡片悬停效果 */
.movie-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.movie-card .favorite-btn.favorited {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.2);
}

/* 分类筛选按钮 */
.category-filter.active {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: white;
  transform: scale(1.05);
}

/* 平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #7c3aed, #db2777);
}

/* Line clamp 样式 */
.line-clamp-1 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.line-clamp-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* 动画效果 */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -10px, 0);
  }
  70% {
    transform: translate3d(0, -5px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

.animate-shimmer {
  animation: shimmer 2s linear infinite;
}

.animate-fadeIn {
  animation: fadeIn 0.6s ease-out forwards;
}

.animate-slideInUp {
  animation: slideInUp 0.8s ease-out forwards;
}

.animate-pulse {
  animation: pulse 2s infinite;
}

.animate-bounce {
  animation: bounce 2s infinite;
}

/* 懒加载图片效果 */
img.lazy {
  opacity: 0;
  transition: opacity 0.3s;
}

img.lazy.loaded {
  opacity: 1;
}

/* 响应式阴影 */
.shadow-3xl {
  box-shadow: 0 35px 60px -12px rgba(0, 0, 0, 0.4);
}

/* 毛玻璃效果 */
.backdrop-blur-md {
  backdrop-filter: blur(12px);
}

.backdrop-blur-sm {
  backdrop-filter: blur(4px);
}

/* 移动端优化 */
@media (max-width: 768px) {
  /* 移动端字体调整 */
  .text-5xl, .text-6xl, .text-7xl {
    font-size: 2.5rem !important;
    line-height: 1.2;
  }
  
  .text-xl, .text-2xl, .text-3xl {
    font-size: 1.25rem !important;
  }
  
  /* 移动端间距调整 */
  .py-20 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
  }
  
  .mb-16 {
    margin-bottom: 2rem !important;
  }
  
  .mb-12 {
    margin-bottom: 1.5rem !important;
  }
  
  /* 移动端网格调整 */
  .grid-cols-2 {
    gap: 1rem !important;
  }
  
  /* 移动端卡片优化 */
  .movie-card {
    margin-bottom: 1rem;
  }
  
  .movie-card:hover {
    transform: none;
  }
  
  /* 移动端按钮调整 */
  .px-8 {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }
  
  .py-4 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
  
  /* 移动端导航优化 */
  .nav-link {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
  }
  
  .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
}

@media (max-width: 640px) {
  /* 超小屏幕优化 */
  .hero-carousel {
    min-height: calc(var(--vh, 1vh) * 100);
  }
  
  .text-5xl {
    font-size: 2rem !important;
  }
  
  .px-4 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  .gap-6 {
    gap: 0.75rem !important;
  }
  
  /* 移动端页脚优化 */
  .lg\\:col-span-1 {
    grid-column: span 1;
  }
  
  .grid-cols-1 {
    gap: 2rem !important;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .movie-card:hover {
    transform: none;
    box-shadow: none;
  }
  
  .group:hover .group-hover\\:opacity-100 {
    opacity: 0;
  }
  
  .hover\\:scale-105:hover {
    transform: none;
  }
  
  .transform:hover {
    transform: none;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .bg-white\\/10 {
    background-color: rgba(255, 255, 255, 0.3);
  }
  
  .border-white\\/20 {
    border-color: rgba(255, 255, 255, 0.5);
  }
  
  .text-gray-400 {
    color: #d1d5db;
  }
}

/* 减少动画模式 */
@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;
  }
  
  .animate-bounce,
  .animate-pulse,
  .animate-fadeIn,
  .animate-slideInUp {
    animation: none;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  /* 已经是深色主题，无需额外调整 */
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
  .hero-carousel {
    min-height: 100vh;
  }
  
  .pt-16 {
    padding-top: 4rem;
  }
}

/* Focus 可见性改进 */
button:focus,
a:focus,
input:focus {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

/* 加载状态 */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

/* 优化文本选择 */
::selection {
  background-color: rgba(139, 92, 246, 0.3);
  color: white;
}

/* iOS Safari 修复 */
input, textarea, select {
  -webkit-appearance: none;
  border-radius: 0;
}

/* 防止双击缩放 */
* {
  touch-action: manipulation;
}

/* 安全区域适配 */
@supports (padding: max(0px)) {
  .safe-area-top {
    padding-top: max(1rem, env(safe-area-inset-top));
  }
  
  .safe-area-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  
  .safe-area-left {
    padding-left: max(1rem, env(safe-area-inset-left));
  }
  
  .safe-area-right {
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}