/* 全局样式 */
:root {
  --primary: #165dff;
  --primary-red: #dc2626;
  --primary-gray: #111827;
  --secondary-gray: #1f2937;
  --accent-gold: #fbbf24;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  background-color: var(--primary-gray);
  color: #ffffff;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  transition: color 0.3s ease;
}

/* 导航栏滚动效果 */
#navbar.scroll {
  background-color: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  padding-top: 1rem;
  padding-bottom: 1rem;
}

nav {
  transition: all 0.3s ease-in-out;
}

nav.bg-opacity-90 {
  backdrop-filter: blur(10px);
}

nav.bg-opacity-95 {
  backdrop-filter: blur(15px);
}

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

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

/* 漫画卡片悬停效果 */
.comic-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* 分类卡片悬停效果 */
.category-card:hover .category-image {
  transform: scale(1.05);
}

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

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

::-webkit-scrollbar-track {
  background: var(--secondary-gray);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-red);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #b91c1c;
}

/* 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%);
  }
}

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

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

/* 自定义圆角 */
.rounded-4xl {
  border-radius: 2rem;
}

.rounded-5xl {
  border-radius: 2.5rem;
}

/* 自定义边框 */
.border-3 {
  border-width: 3px;
}

/* 移动端菜单动画 */
.mobile-menu {
  transition: all 0.3s ease-in-out;
  transform: translateY(-10px);
  opacity: 0;
}

.mobile-menu:not(.hidden) {
  transform: translateY(0);
  opacity: 1;
}

/* 视频卡片样式 */
.group {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.group:hover {
  transform: translateY(-4px) scale(1.02);
}

/* 播放按钮动画 */
.group svg {
  transition: all 0.3s ease;
}

.group:hover svg {
  transform: scale(1.1);
}

/* 渐变背景动画 */
.bg-gradient-to-br {
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 排行榜项目动画 */
.bg-gray-700 {
  transition: all 0.2s ease;
  cursor: pointer;
}

.bg-gray-700:hover {
  background-color: #374151;
  transform: translateX(4px);
}

.bg-gray-700:active {
  transform: translateX(2px) scale(0.98);
}

/* 按钮动画效果 */
button {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

button:active {
  transform: translateY(0);
}

/* 搜索框动画 */
input[type="text"] {
  transition: all 0.3s ease;
}

input[type="text"]:focus {
  transform: scale(1.02);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* 加载动画 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 弹跳动画 */
@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

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

/* 滑入动画 */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slideInRight {
  animation: slideInRight 0.5s ease-out;
}

/* 淡入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* 响应式设计 */
@media (max-width: 768px) {
  /* 移动端优化 */
  .grid {
    gap: 1rem;
  }
  
  /* 移动端文字调整 */
  h1 {
    font-size: 1.5rem !important;
  }
  
  h2 {
    font-size: 1.25rem !important;
  }
  
  .text-3xl {
    font-size: 1.5rem !important;
  }
  
  .text-4xl {
    font-size: 1.75rem !important;
  }
  
  .text-5xl {
    font-size: 2rem !important;
  }
  
  /* 移动端按钮调整 */
  button {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 移动端卡片调整 */
  .group {
    margin-bottom: 1rem;
  }
  
  /* 移动端导航调整 */
  nav {
    padding: 0.5rem 1rem;
  }
  
  /* 移动端容器调整 */
  .max-w-7xl {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* 移动端内间距调整 */
  .py-12 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
  }
  
  .py-16 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
  }
  
  .py-20 {
    padding-top: 4rem !important;
    padding-bottom: 4rem !important;
  }
  
  /* 移动端网格调整 */
  .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  
  .grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
  
  /* 移动端文本大小 */
  .text-xl {
    font-size: 1rem !important;
  }
  
  .text-lg {
    font-size: 0.95rem !important;
  }
  
  /* 移动端排行榜优化 */
  .bg-gray-800 {
    padding: 1rem !important;
  }
  
  /* 移动端搜索框调整 */
  input[type="text"] {
    font-size: 16px; /* 防止iOS缩放 */
  }
}

@media (max-width: 640px) {
  /* 小屏幕优化 */
  .text-3xl {
    font-size: 1.3rem !important;
  }
  
  .text-5xl {
    font-size: 1.8rem !important;
  }
  
  .text-4xl {
    font-size: 1.6rem !important;
  }
  
  .py-12 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }
  
  .py-16 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
  }
  
  .py-20 {
    padding-top: 2.5rem !important;
    padding-bottom: 2.5rem !important;
  }
  
  /* 小屏幕间距调整 */
  .gap-8 {
    gap: 0.75rem !important;
  }
  
  .gap-6 {
    gap: 0.5rem !important;
  }
  
  .gap-4 {
    gap: 0.5rem !important;
  }
  
  /* 小屏幕导航高度调整 */
  .h-16 {
    height: 3.5rem !important;
  }
  
  /* 小屏幕按钮调整 */
  .px-8 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  .px-6 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  
  /* 小屏幕卡片内容调整 */
  .aspect-video {
    aspect-ratio: 16/9 !important;
  }
  
  /* 移动端横向按钮布局 */
  .flex-col.sm\\:flex-row {
    flex-direction: column !important;
  }
  
  /* 小屏幕搜索框 */
  .w-64 {
    width: 100% !important;
  }
  
  /* 移动端排行榜调整 */
  .lg\\:grid-cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
  
  /* 移动端热播推荐调整 */
  .lg\\:grid-cols-3 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
  
  .md\\:grid-cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
  
  /* 移动端footer调整 */
  .md\\:grid-cols-4 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .group:hover {
    transform: none;
  }
  
  button:hover {
    transform: none;
  }
  
  /* 为触摸设备增加点击区域 */
  button, .group {
    min-height: 44px;
  }
}

/* 性能优化 */
.aspect-video,
.aspect-\[3\/4\] {
  will-change: transform;
}

/* 无障碍功能 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  body {
    background-color: #000000;
    color: #ffffff;
  }
  
  .bg-gray-800 {
    background-color: #000000;
    border: 1px solid #ffffff;
  }
  
  button {
    border: 2px solid currentColor;
  }
}

/* 文字选择样式 */
::selection {
  background-color: var(--primary-red);
  color: white;
}

::-moz-selection {
  background-color: var(--primary-red);
  color: white;
}

/* 焦点样式 */
button:focus,
input:focus,
a:focus {
  outline: 2px solid var(--primary-red);
  outline-offset: 2px;
}

/* 防止内容位移 */
.layout-shift-guard {
  contain: layout style paint;
}

/* 图像优化 */
img {
  max-width: 100%;
  height: auto;
  loading: lazy;
}

/* 链接悬停效果 */
a:hover {
  color: var(--primary-red);
}

/* 表单元素统一样式 */
input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* 隐藏元素的无障碍样式 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 移动端设备特定样式 */
.mobile-device {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 移动端视口高度修复 */
:root {
  --vh: 1vh;
}

.min-h-screen {
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
}

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

/* 移动端菜单动画优化 */
.mobile-menu {
  transform: translateY(-10px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu:not(.hidden) {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* 移动端触摸反馈 */
.mobile-device button:active,
.mobile-device .cursor-pointer:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

/* 移动端滚动条隐藏 */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    display: none;
  }
  
  body {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* 移动端横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
  .py-12 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
  
  .py-16 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }
  
  nav .h-16 {
    height: 3rem !important;
  }
}

/* 移动端加载状态 */
.mobile-loading {
  pointer-events: none;
  opacity: 0.6;
}

/* 移动端文本选择优化 */
.mobile-device .no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}