/* ===== 全局样式与变量 ===== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.08);
  --bg-glass-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-primary: #6366f1;
  --accent-secondary: #ec4899;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 4px 20px rgba(99, 102, 241, 0.3);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.6s ease;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --container-max: 1400px;
}

/* 暗色模式 */
[data-theme="dark"] {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
}

/* 亮色模式（自动检测） */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --bg-glass: rgba(0, 0, 0, 0.05);
    --bg-glass-hover: rgba(0, 0, 0, 0.1);
  }
}

/* ===== 重置与基础 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition-normal), color var(--transition-normal);
}

/* 背景渐变装饰 */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
  z-index: -1;
  animation: bgFloat 20s ease-in-out infinite alternate;
}

@keyframes bgFloat {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-2%, -2%) rotate(2deg); }
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

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

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

ul {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 700;
  margin-bottom: 0.5em;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-gradient);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ===== 滚动动画 ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

/* ===== 头部导航 ===== */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

nav {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: var(--shadow-accent);
  letter-spacing: -0.5px;
  margin: 0;
  animation: slideDown 0.6s ease;
}

nav ul {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

nav ul li a {
  display: block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

nav ul li a::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--accent-gradient);
  transition: width var(--transition-normal);
}

nav ul li a:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

nav ul li a:hover::before {
  width: 100%;
}

/* ===== 主内容区 ===== */
main {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
}

main > section {
  min-width: 0;
}

/* ===== 区块通用样式 ===== */
section {
  margin-bottom: 3rem;
}

section h2 {
  font-size: 2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1.5rem;
  position: relative;
  display: inline-block;
  animation: fadeInUp 0.6s ease;
}

section h2::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 60px;
  height: 3px;
  background: var(--accent-gradient);
  border-radius: 2px;
}

/* ===== 网格布局 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

/* ===== 卡片样式 ===== */
.grid article {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.6s ease both;
  position: relative;
  overflow: hidden;
}

.grid article::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-normal);
}

.grid article:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
  background: var(--bg-glass-hover);
}

.grid article:hover::before {
  transform: scaleX(1);
}

.grid article img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.grid article:hover img {
  transform: scale(1.03);
  box-shadow: var(--shadow-md);
}

.grid article h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  transition: color var(--transition-fast);
}

.grid article:hover h3 {
  color: var(--accent-primary);
}

.grid article p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.grid article p:first-of-type {
  color: var(--text-muted);
  font-weight: 500;
}

/* 精品推荐卡片特殊样式 */
#recommend .grid article p:first-of-type {
  font-style: italic;
  color: var(--text-secondary);
  border-left: 3px solid var(--accent-primary);
  padding-left: 0.75rem;
  margin-bottom: 0.75rem;
}

/* ===== 漫画介绍区块 ===== */
#intro article {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  animation: fadeInUp 0.6s ease;
}

#intro h3 {
  font-size: 1.3rem;
  color: var(--accent-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  position: relative;
  padding-left: 1rem;
}

#intro h3::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1.2em;
  background: var(--accent-gradient);
  border-radius: 2px;
}

#intro p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 1rem;
}

/* ===== 角色介绍 ===== */
#characters .grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

#characters .grid article {
  text-align: center;
  padding: 1.5rem 1rem;
}

#characters .grid article img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  border: 3px solid transparent;
  background: var(--accent-gradient) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

#characters .grid article:hover img {
  transform: scale(1.05) rotate(3deg);
  box-shadow: var(--shadow-accent);
}

#characters .grid article h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

#characters .grid article p {
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

#characters .grid article p:first-of-type {
  color: var(--accent-primary);
  font-weight: 600;
}

/* ===== 平台介绍 ===== */
#platform article {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  animation: fadeInUp 0.6s ease;
}

#platform h3 {
  font-size: 1.3rem;
  color: var(--accent-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-left: 1rem;
  position: relative;
}

#platform h3::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1.2em;
  background: var(--accent-gradient);
  border-radius: 2px;
}

#platform p {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 1rem;
}

/* ===== APP下载 ===== */
#app article {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  animation: fadeInUp 0.6s ease;
}

#app h3 {
  font-size: 1.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
}

#app p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

#app div {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

#app a {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent-gradient);
  color: #fff;
  border-radius: 50px;
  font-weight: 600;
  font-size: 1rem;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-accent);
  position: relative;
  overflow: hidden;
}

#app a::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left var(--transition-slow);
}

#app a:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

#app a:hover::before {
  left: 100%;
}

/* ===== 用户评论 ===== */
#comments > div {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

#comments article {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.6s ease both;
}

#comments article:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

#comments article p:first-child {
  font-style: italic;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  position: relative;
  padding-left: 1.5rem;
}

#comments article p:first-child::before {
  content: '"';
  position: absolute;
  left: 0;
  top: -0.5rem;
  font-size: 2rem;
  color: var(--accent-primary);
  font-family: Georgia, serif;
}

#comments article p:not(:first-child) {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== 侧边栏 ===== */
aside {
  position: sticky;
  top: 80px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

aside::-webkit-scrollbar {
  width: 4px;
}

aside > h2 {
  font-size: 1.5rem;
  margin-bottom: 0;
}

aside section {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all var(--transition-normal);
}

aside section:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

aside h3 {
  font-size: 1.1rem;
  color: var(--accent-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

aside ul li {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  border-left: 3px solid transparent;
}

aside ul li:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-left-color: var(--accent-primary);
  padding-left: 1rem;
}

aside p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border-color);
}

aside p:last-child {
  border-bottom: none;
}

aside p::after {
  content: '📊';
  margin-left: 0.5rem;
  opacity: 0.7;
}

/* ===== 页脚 ===== */
footer {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  padding: 3rem 2rem 2rem;
  margin-top: 3rem;
  text-align: center;
}

footer h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

footer ul {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

footer ul li a {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition-normal);
}

footer ul li a:hover {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent);
}

footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

/* ===== 响应式布局 ===== */
@media (max-width: 1200px) {
  main {
    grid-template-columns: 1fr 260px;
    gap: 1.5rem;
    padding: 1.5rem;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 992px) {
  main {
    grid-template-columns: 1fr;
  }
  
  aside {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    padding: 0;
  }
  
  aside > h2 {
    grid-column: 1 / -1;
  }
  
  nav {
    padding: 0.75rem 1rem;
  }
  
  nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
  }
  
  nav ul.show {
    display: flex;
  }
  
  nav ul li a {
    padding: 0.75rem 1rem;
  }
  
  /* 移动端汉堡菜单（通过JS控制） */
  .logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
  
  .logo::after {
    content: '☰';
    font-size: 1.5rem;
    cursor: pointer;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: transform var(--transition-normal);
  }
  
  .logo:hover::after {
    transform: rotate(90deg);
  }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  main {
    padding: 1rem;
  }
  
  section {
    margin-bottom: 2rem;
  }
  
  section h2 {
    font-size: 1.5rem;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }
  
  .grid article img {
    height: 200px;
  }
  
  #characters .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  
  #characters .grid article img {
    width: 120px;
    height: 120px;
  }
  
  #intro article,
  #platform article,
  #app article {
    padding: 1.5rem;
  }
  
  #app div {
    flex-direction: column;
    align-items: center;
  }
  
  #app a {
    width: 100%;
    max-width: 300px;
    text-align: center;
  }
  
  footer {
    padding: 2rem 1rem 1.5rem;
  }
  
  footer ul {
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  
  .grid article img {
    height: 180px;
  }
  
  #comments > div {
    grid-template-columns: 1fr;
  }
  
  #characters .grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  
  #characters .grid article img {
    width: 100px;
    height: 100px;
  }
  
  aside {
    grid-template-columns: 1fr;
  }
}

/* ===== 动画延迟工具类 ===== */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* ===== 无障碍与可访问性 ===== */
@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;
  }
}

/* ===== 焦点样式 ===== */
:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ===== 打印样式 ===== */
@media print {
  header, aside, footer, #app, #comments {
    display: none;
  }
  
  main {
    display: block;
  }
  
  body {
    background: #fff;
    color: #000;
  }
  
  section {
    break-inside: avoid;
  }
  
  .grid {
    display: block;
  }
  
  .grid article {
    break-inside: avoid;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
  }
}