/* ========== 英雄区域布局 ========== */
.bg-hero {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 4px 32px 0 rgba(99,102,241,0.10);
  padding-top: 4rem;
  margin-top: 0 !important;
}

/* Light mode hero area */
[data-theme="light"] .bg-hero {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%) !important;
  color: #fff !important;
}

/* Dark mode hero area */
[data-theme="dark"] .bg-hero {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
  color: #f1f5f9 !important;
}

/* ========== 现代英雄头部 ========== */
.modern-hero-header {
  position: relative;
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 2rem;
}

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.hero-gradient {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.9) 0%, 
    rgba(139, 92, 246, 0.9) 50%, 
    rgba(124, 58, 237, 0.9) 100%
  );
  background-size: 200% 200%;
  animation: gradientShift 8s ease-in-out infinite;
}

.hero-particles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 1px, transparent 1px),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.05) 1px, transparent 1px),
    radial-gradient(circle at 40% 40%, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 100px 100px, 80px 80px, 120px 120px;
  animation: particleFloat 20s linear infinite;
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 4rem 0;
}

.hero-title-container {
  margin-bottom: 2rem;
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 6rem);
  font-weight: 900;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.02em;
  text-shadow: 
    0 2px 4px rgba(0,0,0,0.1),
    0 8px 16px rgba(0,0,0,0.1);
  background: linear-gradient(135deg, #ffffff 0%, #e0e7ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

.hero-title-underline {
  width: 120px;
  height: 4px;
  background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
  margin: 1.5rem auto;
  border-radius: 2px;
  animation: underlineExpand 2s ease-out;
}

.hero-subtitle {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.hero-scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.scroll-arrow {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255,255,255,0.6);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
  animation: scrollBounce 2s ease-in-out infinite;
}

/* Dark theme hero support */
[data-theme="dark"] .hero-gradient {
  background: linear-gradient(135deg, 
    rgba(30, 41, 59, 0.95) 0%, 
    rgba(51, 65, 85, 0.95) 50%, 
    rgba(71, 85, 105, 0.95) 100%
  );
}

[data-theme="dark"] .hero-title {
  background: linear-gradient(135deg, #f1f5f9 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .hero-subtitle {
  color: rgba(241, 245, 249, 0.9);
}

[data-theme="dark"] .scroll-arrow {
  border-color: rgba(241, 245, 249, 0.6);
}

/* ========== 主要内容布局 ========== */
.text-content {
  margin-left: 0 !important;
  margin-right: 0 !important;
  align-items: flex-start !important;
  /* ensure there is space below main content before the footer */
  padding-bottom: 2.5rem;
}

.content-section {
  width: 100%;
  background-color: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin-top: 20px;
  /* add bottom margin so footer doesn't sit flush against content */
  margin-bottom: 2.5rem;
  min-height: 600px;
}

[data-theme="dark"] .container {
  color: var(--text-primary);
}

[data-theme="dark"] .text-content {
  color: var(--text-primary);
}

[data-theme="dark"] .content-section {
  background-color: var(--card-bg) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
  border: 1px solid var(--border-color);
}

.content-section h2,
.content-section h3 {
  scroll-margin-top: 130px;
  color: #2c3e50;
  margin-top: 40px;
  margin-bottom: 20px;
}

.content-section h1 {
  scroll-margin-top: 130px;
  color: #1f2937; /* slate-800 */
  font-size: clamp(2rem, 3.5vw, 2.4rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  margin-top: 50px;
  margin-bottom: 24px;
}

.content-section h2 {
  font-size: 1.8em;
  border-bottom: 2px solid #4a90e2;
  padding-bottom: 10px;
}

.content-section h3 {
  font-size: 1.4em;
  color: #34495e;
}

.content-section p {
  line-height: 1.7;
  margin-bottom: 20px;
  /* color: #555; */
}

.content-section ul,
.content-section ol {
  margin-bottom: 20px;
  padding-left: 30px;
}

.content-section li {
  margin-bottom: 8px;
}

/* ========== Wiki 图片样式 ========== */
.wiki-figure {
  margin: 1.5rem auto;
  text-align: center;
}

.wiki-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  margin: 1rem auto;
}

.wiki-figcaption {
  font-size: 0.9rem;
  color: #6b7280; /* slate-500 */
  margin-top: 0.5rem;
}

.wiki-img--border {
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.wiki-img--shadow {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.wiki-img--minimal-margin {
  margin: 0.1rem auto;
  width: 100%;
  max-width: min(100%, 1300px) !important;
}

[data-theme="dark"] .wiki-img {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .wiki-figcaption {
  color: var(--text-secondary);
}

/* 并排图片容器 */
.wiki-img-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
  margin: 1rem 0;
}

.wiki-img-row .wiki-img {
  flex: 1 1 0;
  width: 100%;
  max-width: none;
}

@media (max-width: 768px) {
  .wiki-img-row {
    flex-direction: column;
  }
}

/* ========== TOC 悬浮目录样式 ========== */
.toc-index {
  position: relative;
  flex-shrink: 0;
  padding-right: 1rem;
}

.toc-container {
  position: -webkit-sticky;
  position: sticky;
  top: 100px;
  width: 100%;
  max-width: 350px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.08);
  padding: 1.5rem;
  opacity: 1;
  pointer-events: auto;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  max-height: 75vh;
  overflow: hidden;
  align-self: flex-start;
  margin-top: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toc-container:hover {
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
}


/* 滚动区域 */
.toc-container #toc-content {
  max-height: calc(75vh - 2rem);
  overflow-y: auto;
  padding-right: 8px;
  margin-right: -8px;
}

/* 自定义滚动条 */
.toc-container #toc-content::-webkit-scrollbar {
  width: 4px;
}

.toc-container #toc-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
}

.toc-container #toc-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 2px;
}

.toc-container #toc-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.toc-container ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-container li {
  margin: 0;
  list-style: none;
  position: relative;
}

.toc-container a {
  display: block;
  padding: 12px 16px;
  color: #4b5563;
  text-decoration: none;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  margin-bottom: 4px;
  overflow: hidden;
}

.toc-container a:hover {
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.08) 0%, 
    rgba(139, 92, 246, 0.08) 100%);
  color: #1f2937;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.toc-container a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  transform: scaleY(0);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0 2px 2px 0;
}

.toc-container .active > a,
.toc-container li.active > a {
  color: #1f2937;
  font-weight: 600;
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.12) 0%, 
    rgba(139, 92, 246, 0.12) 100%);
  box-shadow: 
    0 4px 12px rgba(59, 130, 246, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.toc-container .active > a::before,
.toc-container li.active > a::before {
  transform: scaleY(1);
}

.toc-container ul ul {
  margin-left: 20px;
  padding-left: 16px;
  border-left: 2px solid rgba(59, 130, 246, 0.15);
  margin-top: 8px;
  margin-bottom: 8px;
  display: none;
  position: relative;
}

.toc-container ul ul::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, 
    rgba(59, 130, 246, 0.3) 0%, 
    rgba(139, 92, 246, 0.3) 100%);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.toc-container li.active > ul {
  display: block;
  animation: slideDown 0.3s ease-out;
}

.toc-container li.active > ul::before {
  transform: scaleY(1);
}

.toc-container li ul li {
  margin-bottom: 2px;
}

.toc-container li ul a {
  font-size: 0.8125rem;
  padding: 8px 12px;
  color: #6b7280;
  font-weight: 400;
}

.toc-container li ul a:hover {
  color: #374151;
  background: rgba(59, 130, 246, 0.06);
}

.toc-container li ul .active > a {
  color: #3b82f6;
  font-weight: 500;
}

.toc-loading {
  color: #9ca3af;
  font-size: 0.875rem;
  text-align: center;
  padding: 2rem 0;
  font-style: italic;
}

/* 展开动画 */
@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    max-height: 200px;
    transform: translateY(0);
  }
}

/* Dark theme TOC */
[data-theme="dark"] .toc-container {
  background: rgba(15, 23, 42, 0.95) !important;
  border: 1px solid rgba(59, 130, 246, 0.15);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] .toc-container:hover {
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .toc-container #toc-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .toc-container a {
  color: #d1d5db !important;
}

[data-theme="dark"] .toc-container a:hover {
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.15) 0%, 
    rgba(139, 92, 246, 0.15) 100%) !important;
  color: #f9fafb !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .toc-container .active > a,
[data-theme="dark"] .toc-container li.active > a {
  color: #f9fafb !important;
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.2) 0%, 
    rgba(139, 92, 246, 0.2) 100%) !important;
  box-shadow: 
    0 4px 12px rgba(59, 130, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .toc-container ul ul {
  border-left-color: rgba(59, 130, 246, 0.25) !important;
}

[data-theme="dark"] .toc-container ul ul::before {
  background: linear-gradient(180deg, 
    rgba(59, 130, 246, 0.4) 0%, 
    rgba(139, 92, 246, 0.4) 100%);
}

[data-theme="dark"] .toc-container li ul a {
  color: #9ca3af !important;
}

[data-theme="dark"] .toc-container li ul a:hover {
  color: #e5e7eb !important;
  background: rgba(59, 130, 246, 0.1) !important;
}

[data-theme="dark"] .toc-container li ul .active > a {
  color: #60a5fa !important;
}

[data-theme="dark"] .toc-loading {
  color: #6b7280 !important;
}

/* ========== 页脚样式 ========== */
footer.bg-dark {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%) !important;
  background-color: transparent !important; /* 覆盖Bootstrap的bg-dark */
  color: #fff !important;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  --bs-bg-opacity: 0 !important; /* 禁用Bootstrap的背景透明度 */
}

footer a {
  color: #e0e7ff !important;
  font-weight: bold;
  text-decoration: none !important;
  transition: color 0.2s;
}

footer a:hover {
  color: #3b82f6 !important;
  text-decoration: underline !important;
}

footer .text-light {
  color: #e0e7ff !important;
}

footer .text-white {
  color: #fff !important;
}

/* 确保footer的Bootstrap类正确应用 */
footer.footer {
  margin-top: 3rem !important;
  padding-top: 3rem !important;
  padding-bottom: 3rem !important;
}

footer .container {
  max-width: 1200px;
}

footer .row {
  align-items: flex-start;
}

footer h2 {
  color: #fff !important;
  font-weight: 600;
  margin-bottom: 1rem;
}

footer hr {
  border-color: rgba(255, 255, 255, 0.2) !important;
  margin: 2rem 0 1rem 0;
}

footer .subfoot {
  color: #3b82f6 !important;
  text-decoration: underline !important;
}

footer .subfoot:hover {
  color: #2563eb !important;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
  .modern-hero-header {
    min-height: 50vh;
  }
  
  .hero-content {
    padding: 2rem 0;
  }
  
  .hero-title {
    font-size: clamp(2rem, 10vw, 3.5rem);
  }
  
  .hero-subtitle {
    font-size: clamp(1rem, 4vw, 1.2rem);
    padding: 0 1rem;
  }
  
  .hero-scroll-indicator {
    bottom: 1rem;
  }
}

@media (max-width: 1200px) {
  .toc-container {
    max-width: 300px;
    padding: 1.25rem;
  }
  
  .toc-container a {
    padding: 10px 14px;
    font-size: 0.8125rem;
  }
  
  .toc-container li ul a {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
}

@media (max-width: 992px) {
  .toc-index {
    display: none;
  }

  .text-content {
    margin-left: 20px;
  }

  .content-section {
    padding: 20px;
    margin-top: 10px;
    margin-left: 5px;
    margin-right: 15px;
  }
}

@media (max-width: 768px) {
  .toc-index {
    display: none;
  }

  .text-content {
    margin-left: 0;
  }

  .content-section {
    padding: 15px;
    margin-left: 0;
    margin-right: 0;
  }

  .content-section h2 {
    font-size: 1.5em;
  }

  .content-section h3 {
    font-size: 1.2em;
  }
}

@media (max-width: 576px) {
  .content-section {
    padding: 15px;
  }

  .content-section h2 {
    font-size: 1.3em;
  }

  .content-section h3 {
    font-size: 1.1em;
  }
}

/* ========== Footer Animated Logo ========== */
.footer-logo-container {
  display: inline-block;
  position: relative;
}

.footer-logo-title {
  font-family: 'Montserrat', 'Merriweather', system-ui, sans-serif;
  color: #f1c83c;
  text-transform: uppercase;
  font-size: 40px;
  line-height: 1;
  letter-spacing: 1px;
  margin: 0;
  transform: translateX(-50%) rotate(-10deg);
  left: 50%;
  position: relative;
  white-space: nowrap;
}

.footer-logo-title span {
  display: inline-block;
  transform: skew(-10deg) scaleX(0.9);
  position: relative;
  min-width: 10px;
  min-height: 10px;
  opacity: 0;
  bottom: -18px;
  text-shadow:
    #533d4a 1px 1px,
    #533d4a 2px 2px,
    #533d4a 3px 3px,
    #533d4a 4px 4px,
    #533d4a 5px 5px,
    #533d4a 6px 6px;
  animation-name: footerLogoRise;
  animation-duration: 1s;
  animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

@keyframes footerLogoRise {
  to {
    opacity: 1;
    bottom: 0;
  }
}