/* ===== Root Variables ===== */
:root {
  --primary: #FFD700;
  --accent: #FFD700;
  --text-primary: #E0E0E0;
  --text-secondary: #B0B0B0;
  --bg-dark: #0A0A0A;
  --bg-lighter: #1A1A1A;
  --border-color: #2A2A2A;
  --transition: all 0.3s ease;
}

html[data-theme="light"] {
  --primary: #B8860B;
  --accent: #D4A017;
  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --bg-dark: #FAFAFA;
  --bg-lighter: #FFFFFF;
  --border-color: #E5E5E5;
}

/* ===== Global Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Serif SC', 'Inter', sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-dark);
  line-height: 1.6;
  transition: var(--transition);
}

/* ===== Navbar ===== */
.navbar {
  background-color: var(--bg-lighter);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: transform 0.3s ease-in-out;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  margin: 0.8rem auto 0 auto;
  border-radius: 0 0 12px 12px;
  backdrop-filter: blur(10px);
  width: fit-content;
  transform: translateY(0);
  padding: 0 1.5rem;
}

/* Hide navbar when scrolling down */
.navbar.hide {
  transform: translateY(-150%);
}

.navbar.scrolled {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  margin: 0.8rem auto 0 auto;
}

html[data-theme="light"] .navbar.scrolled {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .nav-link {
  color: #1a1a1a;
}

html[data-theme="light"] .nav-link:hover {
  color: #D4A017;
  background-color: rgba(212, 160, 23, 0.08);
}

html[data-theme="light"] .nav-link.active {
  color: #D4A017;
  border-bottom-color: #D4A017;
}

html[data-theme="light"] .logo {
  color: #D4A017;
}

html[data-theme="light"] .logo:hover {
  color: #B8860B;
}

html[data-theme="light"] .theme-btn {
  color: #1a1a1a;
  border-color: transparent;
}

html[data-theme="light"] .theme-btn:hover {
  background-color: rgba(212, 160, 23, 0.08);
  color: #D4A017;
  border-color: transparent;
}

/* Nav Inner Container - Flexbox Layout */
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 2rem;
}

/* Nav Links Lists */
.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
  align-items: center;
}

.nav-links.nav-left {
  flex: 0 0 auto;
  order: 1;
}

.nav-links.nav-right {
  flex: 0 0 auto;
  order: 3;
}

/* Logo - Center ===== */
.logo {
  order: 2;
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.5rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo:hover {
  color: var(--primary);
  transform: scale(1.05);
}

.font-art {
  font-family: 'Ma Shan Zheng', cursive;
  letter-spacing: 0.1em;
}

/* Nav Link Styles */
.nav-link {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: var(--transition);
  position: relative;
}

.nav-link:hover {
  color: var(--accent);
  background-color: rgba(255, 215, 0, 0.1);
}

.nav-link.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* Theme Button */
.theme-btn {
  order: 4;
  background: none;
  border: 1px solid transparent;
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);

  margin-left: 1rem;
}

.theme-btn:hover {
  background-color: rgba(255, 215, 0, 0.1);
  color: var(--accent);
  border-color: transparent;
}

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ===== Hero Section ===== */
.hero {
  padding: 120px 0 80px;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-lighter) 100%);
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

/* Watermark for hero - placed on container */
.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  position: relative;
  z-index: 1;
}

.hero-content::before {
  content: '道';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24rem;
  font-weight: 700;
  font-family: 'Ma Shan Zheng', cursive;
  opacity: 0.08;
  color: var(--accent);
  white-space: nowrap;
  z-index: -1;
  pointer-events: none;
  letter-spacing: 0.2em;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  line-height: 1.8;
}

/* ===== Buttons ===== */
.btn-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.8rem 2rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.95rem;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background-color: var(--accent);
  color: #000;
}

.btn-primary:hover {
  background-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.btn-outline {
  background-color: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn-outline:hover {
  background-color: rgba(255, 215, 0, 0.1);
  transform: translateY(-2px);
}

/* ===== Book Content ===== */
.book-content {
  color: var(--text-primary);
  line-height: 1.8;
  max-width: 210mm;
  margin: 0 auto;
}

.book-content section {
  margin-bottom: 3rem;
}

.book-content h2 {
  font-size: 1.8rem;
  margin: 2rem 0 1rem;
  color: var(--accent);
}

.book-content h3 {
  font-size: 1.3rem;
  margin: 1.5rem 0 0.8rem;
  color: var(--text-primary);
}

.book-content p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  text-align: justify;
}

.book-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--text-primary);
}

.book-content ul {
  margin: 1rem 0 1rem 2rem;
}

.book-content li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.book-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 3rem 0;
}

/* ===== Learning Path ===== */
.learning-path {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.path-item {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: var(--transition);
}

.path-item:hover {
  border-color: var(--accent);
  background-color: rgba(255, 215, 0, 0.05);
}

.path-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--accent);
  margin-top: 0.3rem;
  flex-shrink: 0;
}

.path-content h3 {
  color: var(--accent);
}

.path-step {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== Author Section ===== */
.author-section {
  background-color: var(--bg-lighter);
}

.author-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.author-img-wrapper {
  margin-bottom: 2rem;
}

.author-img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  overflow: hidden;
}

.author-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.author-role {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* ===== Contact Bar ===== */
.contact-bar {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.contact-item span {
  font-size: 1.2rem;
}

/* ===== Site Statistics ===== */
.site-stats {
  margin: 30px 0 20px;
  padding: 15px 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  opacity: 0.6;
  font-size: 12px;
  color: var(--text-primary);
}

.site-stats h4 {
  display: none;
}

.stats-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  opacity: 0.7;
}

.stat-value {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Arial', sans-serif;
}

.stat-separator {
  opacity: 0.4;
  margin: 0 4px;
}

/* ===== Footer ===== */
footer {
  background-color: var(--bg-lighter);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

.footer-content {
  padding: 0 2rem;
}

/* ===== TOC (Table of Contents) Styles ===== */
.toc-float-btn {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-lighter);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 15px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
  z-index: 998;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toc-float-btn:hover {
  background: var(--accent);
  color: var(--bg-dark);
  box-shadow: 0 6px 16px rgba(212, 175, 55, 0.3);
}

.toc-text {
  opacity: 0.7;
  letter-spacing: 4px;
}

.toc {
  position: fixed;
  left: -300px;
  top: 0;
  width: 280px;
  height: 100vh;
  background: var(--bg-lighter);
  border-right: 1px solid var(--border-color);
  padding: 80px 20px 20px;
  overflow-y: auto;
  transition: left 0.3s ease;
  z-index: 999;
}

.toc.active {
  left: 0;
}

.toc h3 {
  color: var(--accent);
  margin-bottom: 20px;
  font-size: 20px;
}

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

.toc li {
  margin: 10px 0;
}

.toc a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.6;
  display: block;
  padding: 5px 10px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toc a:hover {
  background: var(--accent);
  color: var(--bg-dark);
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--accent);
  color: var(--bg-dark);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  opacity: 0;
  visibility: hidden;
  z-index: 997;
}

.back-to-top:hover {
  transform: translateY(-5px);
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
}

/* ===== Mobile Menu (Hamburger) ===== */
/* 汉堡菜单按钮 */
.hamburger-btn {
  display: none; /* 默认隐藏，仅在移动端显示 */
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1002;
  transition: var(--transition);
}

.hamburger-btn:hover {
  opacity: 0.8;
}

/* 汉堡图标（三条横线） */
.hamburger-icon {
  width: 24px;
  height: 20px;
  position: relative;
  transform: rotate(0deg);
  transition: 0.3s ease-in-out;
  cursor: pointer;
}

.hamburger-icon span {
  display: block;
  position: absolute;
  height: 3px;
  width: 100%;
  background: var(--text-primary);
  border-radius: 3px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: 0.25s ease-in-out;
}

.hamburger-icon span:nth-child(1) {
  top: 0;
}

.hamburger-icon span:nth-child(2) {
  top: 8px;
}

.hamburger-icon span:nth-child(3) {
  top: 16px;
}

/* 汉堡图标动画 - 变成X */
.hamburger-btn.active .hamburger-icon span:nth-child(1) {
  top: 8px;
  transform: rotate(135deg);
}

.hamburger-btn.active .hamburger-icon span:nth-child(2) {
  opacity: 0;
  left: -60px;
}

.hamburger-btn.active .hamburger-icon span:nth-child(3) {
  top: 8px;
  transform: rotate(-135deg);
}

/* 移动端菜单 */
.mobile-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: 50%;
  max-width: 250px;
  height: 100vh;
  background: var(--bg-lighter);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
  padding: 80px 0 20px;
  overflow-y: auto;
  z-index: 1001;
  transition: right 0.3s ease-in-out;
}

.mobile-menu.active {
  right: 0;
}

.mobile-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-menu li {
  border-bottom: 1px solid var(--border-color);
}

.mobile-menu .nav-link {
  display: block;
  padding: 1rem 1.5rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 1rem;
  border-radius: 0;
  transition: var(--transition);
}

.mobile-menu .nav-link:hover {
  background: rgba(255, 215, 0, 0.1);
  color: var(--accent);
  padding-left: 2rem;
}

.mobile-menu .nav-link.active {
  color: var(--accent);
  border-bottom: none;
  border-left: 3px solid var(--accent);
}

/* 移动端菜单背景遮罩 */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.mobile-overlay.active {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .toc {
    width: 250px;
  }
}

/* ===== Light Theme - Additional Styles ===== */
html[data-theme="light"] body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
}

html[data-theme="light"] .hero-title {
  color: #1a1a1a;
}

html[data-theme="light"] .hero-content::before {
  color: #D4A017;
  opacity: 0.06;
}

html[data-theme="light"] .hero-subtitle {
  color: #555;
}

html[data-theme="light"] .hero-desc {
  color: #555;
}

html[data-theme="light"] .btn-primary {
  background-color: #D4A017;
  color: #fff;
}

html[data-theme="light"] .btn-primary:hover {
  background-color: #B8860B;
}

html[data-theme="light"] .btn-outline {
  color: #D4A017;
  border-color: #D4A017;
}

html[data-theme="light"] .btn-outline:hover {
  background-color: rgba(212, 160, 23, 0.08);
}

html[data-theme="light"] .section {
  border-top-color: #D0D0D0;
}

html[data-theme="light"] .section-tag {
  color: #D4A017;
}

html[data-theme="light"] .section-title {
  color: #1a1a1a;
}

html[data-theme="light"] #ontology .section-title::before {
  color: #D4A017;
  opacity: 0.06;
}

html[data-theme="light"] .book-content {
  color: #1a1a1a;
}

html[data-theme="light"] .book-content h2 {
  color: #D4A017;
}

html[data-theme="light"] .book-content h3 {
  color: #1a1a1a;
}

html[data-theme="light"] .book-content p {
  color: #555;
}

html[data-theme="light"] .book-content blockquote {
  border-left-color: #D4A017;
  color: #1a1a1a;
}

html[data-theme="light"] .book-content li {
  color: #555;
}

html[data-theme="light"] .book-content hr {
  border-top-color: #D0D0D0;
}

html[data-theme="light"] .path-item {
  border-color: #D0D0D0;
}

html[data-theme="light"] .path-item:hover {
  border-color: #D4A017;
  background-color: rgba(212, 160, 23, 0.03);
}

html[data-theme="light"] .path-dot {
  background-color: #D4A017;
}

html[data-theme="light"] .path-content h3 {
  color: #D4A017;
}

html[data-theme="light"] .path-step {
  color: #888;
}

html[data-theme="light"] .author-section {
  background-color: var(--bg-lighter);
}

html[data-theme="light"] .author-img {
  border-color: #D4A017;
}

html[data-theme="light"] .author-name {
  color: #D4A017;
}

html[data-theme="light"] .author-role {
  color: #555;
}

html[data-theme="light"] .contact-bar {
  border-top-color: #D0D0D0;
}

html[data-theme="light"] .contact-item {
  color: #555;
}

html[data-theme="light"] footer {
  background-color: var(--bg-lighter);
  border-top-color: #D0D0D0;
  color: #555;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  /* 导航栏移动端布局：左(主题) 中(Logo) 右(汉堡) */
  .navbar {
    width: 90%;
    max-width: 500px;
    padding: 0 1rem;
  }

  .nav-inner {
    padding: 0.8rem 0;
    gap: 0.5rem;
    justify-content: space-between;
  }

  /* 隐藏桌面端菜单链接 */
  .nav-links {
    display: none !important;
  }

  /* 主题按钮：左侧 */
  .theme-btn {
    order: 1;
    margin-left: 0;
    padding: 0.5rem;
  }

  /* Logo：居中 */
  .logo {
    order: 2;
    flex: 1;
    font-size: 1.3rem;
  }

  /* 汉堡按钮：右侧，显示 */
  .hamburger-btn {
    display: block;
    order: 3;
  }

  .hero-title {
    font-size: 2rem;
  }

  .section-title {
    font-size: 1.8rem;
  }

  .learning-path {
    grid-template-columns: 1fr;
  }

  .contact-bar {
    flex-direction: column;
    gap: 1rem;
  }

  .site-stats {
    font-size: 11px;
    padding: 12px 0;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-value {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  /* 导航栏：保持刘海样式 */
  .navbar {
    width: 95%;
    padding: 0 0.8rem;
  }

  .nav-inner {
    padding: 0.7rem 0;
  }

  .logo {
    font-size: 1.2rem;
  }

  .theme-btn {
    font-size: 1.1rem;
    padding: 0.4rem;
  }

  .hero {
    padding: 60px 0 40px;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .section {
    padding: 40px 0;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .toc {
    width: 220px;
  }
}

/* ===== Utility Classes ===== */
.text-center {
  text-align: center;
}

.mt-2 {
  margin-top: 2rem;
}

.mb-2 {
  margin-bottom: 2rem;
}