/* ============================================================
   公用样式 - 全局重置、变量、基础布局、Header、Footer、响应式
   ============================================================ */

/* ===== 防闪烁：背景色先行 ===== */
html {
  background: #f5f0e8;
  transition: background 0s !important;
}
html.dark {
  background: #0d0b09;
}
body {
  background: transparent !important;
  transition: none !important;
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 明亮模式 (默认) */
:root {
  --primary: #8a7050;
  --primary-light: #d4c4a8;
  --accent: #a08040;
  --dark: #f5f0e8;
  --dark-light: #ebe4d8;
  --dark-card: #ffffff;
  --text: #5a5045;
  --text-light: #8a7e70;
  --text-bright: #2a221a;
  --border: #d8cfc0;
  --border-light: #c8bfb0;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --transition: all 0.3s ease;
}

/* 暗色模式 */
html.dark {
  --primary: #b8a080;
  --primary-light: #d4c4a8;
  --accent: #c9a961;
  --dark: #0d0b09;
  --dark-light: #1a1612;
  --dark-card: #161210;
  --text: #b0a898;
  --text-light: #8a7e70;
  --text-bright: #e8ddd0;
  --border: #2a221a;
  --border-light: #3a322a;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.6);
}

body {
  font-family: 'Noto Serif SC', 'Source Han Serif SC', 'PingFang SC', 'Microsoft YaHei', serif;
  color: var(--text);
  background: var(--dark);
  line-height: 1.8;
  overflow-x: hidden;
  min-height: 100vh;
}

html {
  scroll-behavior: smooth;
}

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

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.section {
  padding: 100px 0;
}

/* ===== Header ===== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(245, 240, 232, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

html.dark .site-header {
  background: rgba(13, 11, 9, 0.95);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dark);
  font-size: 18px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
}

.logo-sub {
  font-size: 12px;
  color: var(--text-light);
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.main-nav {
  display: flex;
  gap: 30px;
}

.main-nav a {
  color: var(--text);
  font-size: 15px;
  position: relative;
  padding: 5px 0;
}

.main-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.3s;
}

.main-nav a:hover::after,
.main-nav a.active::after {
  width: 100%;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text-bright);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== Theme Toggle ===== */
.theme-btn {
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  color: var(--primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.theme-btn:hover {
  background: rgba(138, 112, 80, 0.15);
  border-color: var(--primary);
}

html.dark .theme-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: #b8a080;
}
html.dark .theme-btn:hover {
  background: rgba(184, 160, 128, 0.15);
  border-color: var(--primary);
}

/* ===== Language Selector ===== */
.language-selector {
  position: relative;
  z-index: 100;
}

.language-current {
  display: flex;
  align-items: center;
  padding: 6px 12px 6px 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  gap: 6px;
  position: relative;
  z-index: 101;
}

.language-current:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: var(--border);
}

html.dark .language-current {
  background: rgba(255, 255, 255, 0.05);
}
html.dark .language-current:hover {
  background: rgba(255, 255, 255, 0.08);
}
html.dark .language-name {
  color: #b0a898;
}

.language-flag {
  width: 20px;
  height: 14px;
  background-size: cover;
  background-position: center;
  border-radius: 2px;
}

.language-name {
  font-size: 13px;
  color: var(--text);
}

.language-current .fa-chevron-down {
  font-size: 10px;
  color: var(--text-light);
}

.language-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 420px;
  background: var(--dark-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: var(--transition);
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.language-selector.active .language-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

html.dark .language-dropdown {
  background: #161210;
  border-color: #2a221a;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

.language-regions-container {
  overflow-y: auto;
  flex: 1;
}

.language-region {
  margin-bottom: 16px;
}

.region-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.region-languages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 4px;
}

.language-option {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
  transition: var(--transition);
  gap: 6px;
}

.language-option:hover {
  background: rgba(0, 0, 0, 0.05);
}

.language-option.active {
  background: rgba(138, 112, 80, 0.12);
  color: var(--text-bright);
}

.language-option .language-flag {
  width: 16px;
  height: 12px;
}

html.dark .language-option:hover {
  background: rgba(255, 255, 255, 0.05);
}
html.dark .language-option.active {
  background: rgba(184, 160, 128, 0.12);
  color: #e8ddd0;
}

/* ===== 移动端语言切换按钮 ===== */
.mobile-language-toggle {
  display: none;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.mobile-language-toggle:hover {
  background: rgba(138, 112, 80, 0.15);
  border-color: var(--primary);
  color: var(--text-bright);
}

html.dark .mobile-language-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: #2a221a;
  color: #b0a898;
}
html.dark .mobile-language-toggle:hover {
  background: rgba(184, 160, 128, 0.15);
  border-color: #b8a080;
  color: #e8ddd0;
}

.mobile-language-modal {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.mobile-language-modal.active {
  display: flex !important;
}

.mobile-language-content {
  background: var(--dark-card);
  width: 92%;
  max-width: 380px;
  max-height: 70vh;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mobile-language-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-language-header h3 {
  color: var(--text-bright);
  font-size: 16px;
  margin: 0;
}

.mobile-language-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.mobile-language-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.mobile-language-option {
  display: flex;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 10px;
}

.mobile-language-option:hover {
  background: rgba(0, 0, 0, 0.03);
}

.mobile-language-option.active {
  background: rgba(138, 112, 80, 0.08);
}

.mobile-language-flag {
  width: 22px;
  height: 16px;
  background-size: cover;
  border-radius: 2px;
}

.mobile-language-name {
  font-size: 15px;
  color: var(--text);
}

html.dark .mobile-language-option:hover {
  background: rgba(255, 255, 255, 0.03);
}
html.dark .mobile-language-option.active {
  background: rgba(184, 160, 128, 0.08);
}
html.dark .mobile-language-name {
  color: #b0a898;
}

/* ===== Mobile Menu ===== */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
}

/* ===== Footer ===== */
.site-footer {
  background: #ede5db;
  padding: 60px 0 20px;
  border-top: 1px solid var(--border);
}

html.dark .site-footer {
  background: #0d0b09;
  border-top-color: #2a221a;
}

.footer-content {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-section h4 {
  font-size: 16px;
  color: var(--text-bright);
  margin-bottom: 20px;
}

.footer-section h4 i {
  margin-right: 8px;
  color: var(--primary);
}

.footer-section p {
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 15px;
}

.footer-section ul li {
  margin-bottom: 10px;
}

.footer-section ul li a {
  color: var(--text-light);
  font-size: 14px;
}

.footer-section ul li a:hover {
  color: var(--primary);
}

.footer-section ul li a i {
  margin-right: 8px;
  font-size: 10px;
}

.footer-social {
  display: flex;
  gap: 15px;
}

.footer-social a {
  width: 36px;
  height: 36px;
  background: rgba(138, 112, 80, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  transition: var(--transition);
}

.footer-social a:hover {
  background: var(--primary);
  color: var(--dark);
}

html.dark .footer-social a {
  background: rgba(184, 160, 128, 0.1);
}
html.dark .footer-social a:hover {
  background: #b8a080;
  color: #0d0b09;
}

.footer-bottom {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.footer-bottom p {
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 5px;
}

/* ============================================================
   响应式 - 移动端完整优化
   ============================================================ */
@media (max-width: 1024px) {
  .footer-content {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .header-right {
    position: relative;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  
  .header-right .theme-btn,
  .header-right .mobile-language-toggle,
  .header-right .mobile-menu-btn {
    position: relative;
    z-index: 1002;
    background: rgba(245, 240, 232, 0.9);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    touch-action: manipulation;
    pointer-events: auto;
  }
  
  html.dark .header-right .theme-btn,
  html.dark .header-right .mobile-language-toggle,
  html.dark .header-right .mobile-menu-btn {
    background: rgba(13, 11, 9, 0.8);
    backdrop-filter: blur(4px);
  }
  
  .header-right .theme-btn:hover,
  .header-right .mobile-language-toggle:hover,
  .header-right .mobile-menu-btn:hover {
    background: rgba(138, 112, 80, 0.2);
    border-color: var(--primary);
  }
  
  html.dark .header-right .theme-btn:hover,
  html.dark .header-right .mobile-language-toggle:hover,
  html.dark .header-right .mobile-menu-btn:hover {
    background: rgba(184, 160, 128, 0.2);
  }
  
  .mobile-language-toggle {
    display: flex !important;
  }
  
  .language-selector {
    display: none;
  }
  
  .main-nav {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--dark-card);
    flex-direction: column;
    padding: 20px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
    z-index: 998;
    pointer-events: none;
  }
  
  html.dark .main-nav {
    background: #161210;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
  
  .main-nav.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  
  .main-nav a {
    font-size: 15px;
    padding: 10px 16px;
    border-radius: 8px;
    text-align: center;
    letter-spacing: 1px;
    display: block;
    pointer-events: auto;
  }
  
  .main-nav a::after {
    display: none;
  }
  
  .main-nav a:hover,
  .main-nav a.active {
    background: rgba(138, 112, 80, 0.1);
    color: var(--text-bright);
  }
  
  html.dark .main-nav a:hover,
  html.dark .main-nav a.active {
    background: rgba(184, 160, 128, 0.1);
  }
  
  .mobile-menu-btn {
    display: block;
  }
  
  .logo-sub {
    display: none;
  }
  
  .logo-text {
    font-size: 16px;
  }
  
  .logo-icon {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }
  
  .section {
    padding: 50px 0;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}