/* ============================================================
   漫蛙漫画 - 全局样式表
   设计理念: 现代、清新、沉浸式阅读体验
   版本: 1.0.0
   ============================================================ */

/* ---------- CSS变量与重置 ---------- */
:root {
  --primary: #3b82f6;
  --primary-dark: #1e3a8a;
  --primary-light: #60a5fa;
  --primary-bg: #dbeafe;
  --primary-tag-text: #1e40af;
  --bg: #f9fafb;
  --bg-secondary: #f1f5f9;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --card-bg: #ffffff;
  --card-shadow: rgba(0, 0, 0, 0.05);
  --card-shadow-hover: rgba(0, 0, 0, 0.1);
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --footer-bg: #0f172a;
  --footer-text: #cbd5e1;
  --footer-link: #94a3b8;
  --footer-link-hover: #60a5fa;
  --footer-border: #1e293b;
  --nav-bg: rgba(255, 255, 255, 0.85);
  --nav-border: rgba(229, 231, 235, 1);
  --search-bg: #f3f4f6;
  --howto-bg: #f8fafc;
  --faq-text: #4b5563;
  --banner-gradient: linear-gradient(145deg, #1e3a8a, #3b82f6);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.6s ease;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.15);
  --blur: blur(12px);
  --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 暗黑模式变量 */
body.dark {
  --bg: #111827;
  --bg-secondary: #1e293b;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --text-light: #6b7280;
  --card-bg: #1f2937;
  --card-shadow: rgba(0, 0, 0, 0.3);
  --card-shadow-hover: rgba(0, 0, 0, 0.4);
  --border: #374151;
  --border-strong: #4b5563;
  --nav-bg: rgba(17, 24, 39, 0.9);
  --nav-border: rgba(55, 65, 81, 1);
  --search-bg: #1f2937;
  --howto-bg: #1e293b;
  --faq-text: #d1d5db;
  --primary-bg: #1e3a8a;
  --primary-tag-text: #93c5fd;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  transition: background var(--transition-medium), color var(--transition-medium);
  min-height: 100vh;
  overflow-x: hidden;
}

body.dark {
  background: #111827;
  color: #e5e7eb;
}

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

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

ul, ol {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input {
  font-family: inherit;
}

/* ---------- 容器 ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }
}

/* ---------- 工具类 ---------- */
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.mt-20 {
  margin-top: 20px;
}

.text-center {
  text-align: center;
}

/* ---------- 导航栏 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--nav-border);
  transition: background var(--transition-medium), border-color var(--transition-medium);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

body.dark .navbar {
  background: rgba(17, 24, 39, 0.9);
  border-bottom-color: #374151;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 20px;
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-fill-color: transparent;
  flex-shrink: 0;
}

.menu {
  display: flex;
  gap: 24px;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.menu a {
  text-decoration: none;
  color: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
  position: relative;
  padding: 4px 0;
}

.menu a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width var(--transition-fast);
  border-radius: 2px;
}

.menu a:hover {
  color: var(--primary);
}

.menu a:hover::after {
  width: 100%;
}

/* 搜索框 */
.search-box {
  display: flex;
  background: var(--search-bg);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  align-items: center;
  border: 1px solid var(--border);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  flex-shrink: 0;
}

body.dark .search-box {
  background: #1f2937;
  border-color: #374151;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-box input {
  border: none;
  background: transparent;
  padding: 8px;
  width: 140px;
  outline: none;
  color: inherit;
  font-size: 0.9rem;
}

.search-box input::placeholder {
  color: var(--text-light);
}

.search-box button {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
  padding: 4px;
}

.search-box button:hover {
  color: var(--primary);
}

/* 图标按钮 */
.icon-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: inherit;
  margin-left: 8px;
  transition: transform var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  padding: 4px;
  border-radius: 50%;
}

.icon-btn:hover {
  transform: scale(1.1);
  color: var(--primary);
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: inherit;
  padding: 4px 8px;
  transition: color var(--transition-fast);
}

.mobile-menu-btn:hover {
  color: var(--primary);
}

/* 移动导航 */
.mobile-nav {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px 20px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.3s ease;
}

body.dark .mobile-nav {
  background: #111827;
  border-color: #374151;
}

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

.mobile-nav a {
  text-decoration: none;
  color: inherit;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  transition: color var(--transition-fast), padding-left var(--transition-fast);
  border-radius: var(--radius-sm);
}

.mobile-nav a:last-child {
  border-bottom: none;
}

.mobile-nav a:hover {
  color: var(--primary);
  padding-left: 16px;
  background: var(--bg-secondary);
}

/* ---------- 轮播Banner ---------- */
.banner {
  background: var(--banner-gradient);
  color: white;
  padding: 48px 0;
  border-radius: 0 0 40px 40px;
  position: relative;
  overflow: hidden;
}

.banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 32px;
  position: relative;
  z-index: 1;
}

.banner-text h1 {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.2;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.banner-text p {
  font-size: 1.2rem;
  opacity: 0.9;
  max-width: 600px;
  line-height: 1.8;
}

.banner-slider {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 24px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}

.banner-slider::-webkit-scrollbar {
  display: none;
}

.banner-card {
  min-width: 260px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  transition: transform var(--transition-fast), background var(--transition-fast);
  scroll-snap-align: start;
}

.banner-card:hover {
  transform: translateY(-4px);
  background: rgba(255,255,255,0.25);
}

.banner-card h3 {
  font-size: 1.3rem;
  margin-bottom: 6px;
  font-weight: 700;
}

.banner-card span {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ---------- 区块通用 ---------- */
.section {
  padding: 48px 0;
}

.section-title {
  text-align: center;
  margin-bottom: 40px;
}

.section-title h2 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary-dark);
  position: relative;
  display: inline-block;
  padding-bottom: 12px;
}

body.dark .section-title h2 {
  color: #93c5fd;
}

.section-title h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: var(--primary);
  border-radius: 3px;
}

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

/* ---------- 卡片 ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-medium);
  border: 1px solid transparent;
}

body.dark .card {
  background: #1f2937;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

.card h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

.card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

body.dark .card p {
  color: #9ca3af;
}

/* 标签 */
.tag {
  background: var(--primary-bg);
  color: var(--primary-tag-text);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  display: inline-block;
  margin-bottom: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* 元信息 */
.meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 12px;
}

/* ---------- 文章列表 ---------- */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.article-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 16px 8px;
  transition: background var(--transition-fast), padding-left var(--transition-fast);
  border-radius: var(--radius-sm);
}

.article-row:hover {
  background: var(--bg-secondary);
  padding-left: 16px;
}

.article-row a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
  flex: 1;
  margin-right: 16px;
}

.article-row a:hover {
  color: var(--primary);
}

.article-row span {
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ---------- FAQ ---------- */
.faq-list {
  max-width: 800px;
  margin: 0 auto;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.faq-item:first-child {
  border-top: 1px solid var(--border);
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 8px 0;
  transition: color var(--transition-fast);
  gap: 16px;
}

.faq-question span {
  font-size: 1.5rem;
  color: var(--primary);
  transition: transform var(--transition-medium);
  flex-shrink: 0;
  font-weight: 400;
}

.faq-item:hover .faq-question {
  color: var(--primary);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-medium) ease;
  padding-top: 0;
  color: var(--faq-text);
  line-height: 1.8;
  font-size: 0.95rem;
}

body.dark .faq-answer {
  color: #d1d5db;
}

.faq-item.active .faq-answer {
  max-height: 500px;
  padding-top: 8px;
}

.faq-item.active .faq-question span {
  transform: rotate(45deg);
}

.faq-item.active .faq-question {
  color: var(--primary);
}

/* ---------- HowTo教程 ---------- */
.howto-step {
  background: var(--howto-bg);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

body.dark .howto-step {
  background: #1e293b;
}

.howto-step:hover {
  border-left-width: 6px;
}

.howto-step strong {
  color: var(--primary);
  margin-right: 8px;
}

/* ---------- 页脚 ---------- */
.footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 48px 0 24px;
  margin-top: 48px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.footer h4 {
  color: white;
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 600;
}

.footer a {
  color: var(--footer-link);
  text-decoration: none;
  display: block;
  margin: 6px 0;
  transition: color var(--transition-fast), padding-left var(--transition-fast);
  font-size: 0.9rem;
}

.footer a:hover {
  color: var(--footer-link-hover);
  padding-left: 4px;
}

.copyright {
  text-align: center;
  border-top: 1px solid var(--footer-border);
  padding-top: 24px;
  font-size: 0.85rem;
  color: var(--footer-link);
}

/* ---------- 返回顶部 ---------- */
#backToTop {
  position: fixed;
  bottom: 40px;
  right: 30px;
  background: var(--primary);
  color: white;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: none;
  z-index: 99;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

#backToTop:hover {
  transform: translateY(-4px) scale(1.05);
  background: var(--primary-dark);
  box-shadow: var(--shadow-xl);
}

/* ---------- 滚动动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* 延迟动画 */
.reveal:nth-child(2) { transition-delay: 0.1s; }
.reveal:nth-child(3) { transition-delay: 0.2s; }
.reveal:nth-child(4) { transition-delay: 0.3s; }

/* ---------- SVG图标 ---------- */
.svg-icon {
  width: 48px;
  height: 48px;
  color: var(--primary);
  transition: transform var(--transition-fast);
}

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

/* ---------- 媒体查询 ---------- */
@media (max-width: 1024px) {
  .menu {
    gap: 16px;
  }

  .search-box input {
    width: 120px;
  }

  .banner-text h1 {
    font-size: 2.2rem;
  }
}

@media (max-width: 768px) {
  .nav-inner {
    height: 56px;
  }

  .logo {
    font-size: 1.4rem;
  }

  .menu {
    display: none;
  }

  .mobile-menu-btn {
    display: block;
  }

  .search-box {
    display: none;
  }

  .icon-btn {
    margin-left: 4px;
    font-size: 1.2rem;
  }

  .banner {
    padding: 32px 0;
    border-radius: 0 0 24px 24px;
  }

  .banner-text h1 {
    font-size: 1.8rem;
  }

  .banner-text p {
    font-size: 1rem;
  }

  .banner-card {
    min-width: 220px;
    padding: 16px;
  }

  .section {
    padding: 32px 0;
  }

  .section-title h2 {
    font-size: 1.6rem;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card {
    padding: 20px;
  }

  .article-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 8px;
  }

  .article-row a {
    margin-right: 0;
    font-size: 0.95rem;
  }

  .article-row span {
    font-size: 0.8rem;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  #backToTop {
    bottom: 24px;
    right: 20px;
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .faq-question {
    font-size: 0.95rem;
  }

  .howto-step {
    font-size: 0.9rem;
  }

  .banner-content {
    gap: 16px;
  }
}

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

  .logo {
    font-size: 1.2rem;
  }

  .icon-btn {
    font-size: 1.1rem;
  }

  .banner-text h1 {
    font-size: 1.5rem;
  }

  .banner-text p {
    font-size: 0.9rem;
  }

  .banner-card {
    min-width: 180px;
    padding: 14px;
  }

  .banner-card h3 {
    font-size: 1.1rem;
  }

  .section-title h2 {
    font-size: 1.4rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer {
    padding: 32px 0 16px;
  }
}

/* ---------- 暗黑模式适配 ---------- */
body.dark .banner {
  background: linear-gradient(145deg, #1e3a8a, #3b82f6);
}

body.dark .banner-card {
  background: rgba(255,255,255,0.1);
}

body.dark .banner-card:hover {
  background: rgba(255,255,255,0.2);
}

body.dark .faq-item {
  border-color: #374151;
}

body.dark .article-row {
  border-color: #374151;
}

body.dark .article-row:hover {
  background: #1e293b;
}

body.dark .article-row a {
  color: #e5e7eb;
}

body.dark .article-row a:hover {
  color: var(--primary-light);
}

body.dark .article-row span {
  color: #9ca3af;
}

body.dark .card:hover {
  border-color: #374151;
}

body.dark .tag {
  background: #1e3a8a;
  color: #93c5fd;
}

body.dark .mobile-nav a {
  border-color: #374151;
}

body.dark .mobile-nav a:hover {
  background: #1e293b;
}

body.dark .search-box button {
  color: #9ca3af;
}

body.dark .search-box button:hover {
  color: var(--primary-light);
}

body.dark .howto-step strong {
  color: var(--primary-light);
}

/* ---------- 动画关键帧 ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* 卡片悬浮效果增强 */
.card {
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  transition: left 0.5s ease;
  pointer-events: none;
}

.card:hover::before {
  left: 100%;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

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

body.dark ::-webkit-scrollbar-track {
  background: #111827;
}

body.dark ::-webkit-scrollbar-thumb {
  background: #374151;
}

body.dark ::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* 选中文本颜色 */
::selection {
  background: var(--primary);
  color: white;
}

/* 焦点可见性 */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 减少动画偏好 */
@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;
  }
}