/* ===================================================================
   core.css — 全局设计系统 + 全部可复用组件
   已整合 404/500 错误页面样式（冗余已清理）
   =================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  --primary-color: #2563eb;
  --secondary-color: #1e40af;
  --accent-color: #3b82f6;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  --bg-primary: #fcfbf8;
  --bg-secondary: #f8f6f2;
  --bg-tertiary: #f5f3ef;
  --bg-card: #ffffff;

  --border-color: #d1d5db;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition: 0.3s ease;

  --font-family: 'Inter', 'Helvetica Neue', Arial, 'Microsoft YaHei', sans-serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
  --font-size-base: 1rem;
  --line-height-base: 1.6;

  --content-max-width: 800px;
  --container-max-width: 1200px;

  --card-bg: #ffffff;
  --card-hover-bg: #f8f6f2;
  --tag-bg: #f1f5f9;
  --primary-color-light: rgba(37, 99, 235, 0.1);
  --primary-rgb: 37, 99, 235;

  /* ---- z-index 语义变量（方案 A：具名不改值，2026-10-21） ---- */
  --z-nav: 100;
  --z-sidebar: 100;
  --z-tooltip: 100;
  --z-drawer-overlay: 999;
  --z-drawer: 1000;
  --z-drawer-toggle: 1002;
  --z-modal: 2000;
  --z-toast-bottom: 2100;
  --z-dropdown: 9999;
  --z-overlay: 9999;
  --z-toast-top: 9999;
  --z-notification: 10000;
  --z-share-panel: 10000;
  --z-qr-modal: 10001;
}

/* 暗色主题 */
body.dark-theme {
  /* 补全缺失的深色模式变量 */
  --tag-bg: rgba(255, 255, 255, 0.05); 
  --primary-color-light: rgba(37, 99, 235, 0.15); 
  --tag-bg-dark-fixed: true;

  --primary-color: #3b82f6;
  --secondary-color: #60a5fa;
  --accent-color: #93c5fd;
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --bg-primary: #2a2c35;
  --bg-secondary: #252730;
  --bg-tertiary: #212229;
  --bg-card: #2a2c35;
  --border-color: #4a4c57;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
}
body.dark-theme header {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-tertiary));
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  background-image: url("../images/background_desktop.89e24e8a4054.webp");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  min-height: 100vh;
  padding: 20px;
}

@media (max-width: 768px) {
  body {
    background-image: url("../images/background_mobile.7160ac688acc.webp");
    background-attachment: scroll;
  }
}

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

a { color: var(--primary-color); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--secondary-color); }

/* ---------- 排版 ---------- */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; margin-bottom: 0.5em; color: var(--text-primary); }
h1 { font-size: 2.5rem; } h2 { font-size: 2rem; } h3 { font-size: 1.5rem; } h4 { font-size: 1.25rem; }

/* ---------- 工具类：无障碍隐藏 ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
p { margin-bottom: 1rem; }

/* ---------- 通用按钮（增强版，整合 404 样式）---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.85rem 1.75rem; border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 500; cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none; font-family: inherit; min-width: 140px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), #667eea);
  color: white; box-shadow: 0 4px 15px rgba(74,108,247,0.2);
}
.btn-primary:hover {
  transform: translateY(-3px); box-shadow: 0 8px 25px rgba(74,108,247,0.3);
}
.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border-color); box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.btn-secondary:hover {
  background: var(--bg-secondary); border-color: var(--primary-color);
  transform: translateY(-3px); box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; min-width: auto; }
.btn-icon { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow-sm); transition: all var(--transition);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary-color); }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; background: var(--bg-secondary); color: var(--text-secondary);
  padding: 0.2rem 0.8rem; border-radius: var(--radius-full); font-size: 0.8rem; font-weight: 500;
  transition: all var(--transition-fast); text-decoration: none;
}
.tag:hover { background: var(--primary-color); color: white; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

/* ---------- 元信息 ---------- */
.meta { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.9rem; color: var(--text-secondary); }
.meta-item {
  display: inline-flex; align-items: center; gap: 0.3rem; background: var(--bg-secondary);
  padding: 0.2rem 0.7rem; border-radius: var(--radius-full); font-size: 0.85rem;
}

/* ---------- 文章内容 ---------- */
.article-content {
  max-width: var(--content-max-width); margin: 0 auto; line-height: 1.8; font-size: 1.05rem;
}
.article-content h2 { margin: 2.5rem 0 1.2rem; padding-left: 0.8rem; border-left: 4px solid var(--primary-color); color: var(--text-primary); font-weight: 700; }
.article-content h3 { margin: 2rem 0 1rem; color: var(--secondary-color); font-weight: 600; }
.article-content p { margin-bottom: 1.5rem; line-height: 1.8; text-align: justify; color: var(--text-primary); }
.article-content section p { text-indent: 0 !important; margin-bottom: 0 !important; }
.article-content blockquote {
  border-left: 4px solid var(--primary-color); padding: 1rem 1.5rem; margin: 1.5rem 0;
  background: var(--bg-secondary); border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic; color: var(--text-secondary);
}
.article-content ul, .article-content ol { margin: 1.5rem 0; padding-left: 2rem; }
.article-content li { margin-bottom: 0.5rem; }
.article-content code { background: var(--bg-secondary); padding: 0.15rem 0.4rem; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; }
.article-content pre { background: #2d3748; color: #e2e8f0; padding: 1.5rem; border-radius: var(--radius-md); overflow-x: auto; margin: 1.5rem 0; }
.article-content pre code { background: none; padding: 0; color: inherit; }
.article-content table { width: 100%; border-collapse: collapse; margin: 2rem 0; }
.article-content .highlight-box {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary)); padding: 2rem;
  border-radius: var(--radius-md); border-left: 4px solid var(--primary-color); margin: 2rem 0;
}
.article-content .footnotes { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color); font-size: 0.9rem; }

/* 文章内图片 */
.article-content img {
  max-width: 100%; height: auto; display: block; margin: 1.5rem auto;
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
@media (max-width: 768px) {
  .article-content img { margin: 1rem auto; }
}

/* 特殊图片保护 */
.profile-avatar, .qrcode-img, .modal-qrcode-item img { max-width: none; margin: initial; border-radius: initial; box-shadow: initial; }
.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--bg-primary);
    box-shadow: var(--shadow-sm);
    display: block;
    margin: 0 auto;
}
.qrcode-img, .modal-qrcode-item img { width: 100% !important; max-width: 180px !important; height: auto !important; border-radius: var(--radius-md) !important; box-shadow: var(--shadow-sm) !important; margin: 0 auto !important; }

/* ---------- PWA 安装按钮 ---------- */
.pwa-install-btn {
  background: linear-gradient(135deg, #4f46e5, #7c3aed); color: white; border: none;
  border-radius: var(--radius-md); padding: 0.6rem 1.2rem; font-size: 0.9rem; cursor: pointer; transition: all var(--transition);
}
.pwa-install-btn:hover { background: linear-gradient(135deg, #4338ca, #6d28d9); transform: translateY(-2px); }

/* ---------- 图标尺寸 ---------- */
.icon { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; fill: currentColor; }
.icon-sm { width: 0.875em; height: 0.875em; }
.icon-lg { width: 1.25em; height: 1.25em; }
.icon-xl { width: 1.5em; height: 1.5em; }

/* ---------- 安装图标和提示 ---------- */
.install-icon { position: relative; cursor: pointer; transition: all 0.3s ease; }
.install-icon:hover { transform: scale(1.1); color: #4f46e5; }
.install-badge {
  position: absolute; top: -5px; right: -5px; background: #ff6b6b; color: white;
  font-size: 10px; width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; animation: pulse 2s infinite;
}
.install-icon.installed { color: #10b981; }
.install-icon.installed:hover { color: #059669; }

/* ---------- nav-link 悬浮提示 ---------- */
.nav-link[data-tip] { position: relative; }
.nav-link[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: -38px; left: 50%; transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.85); /* 石墨蓝/深灰 */
  color: white; 
  padding: 6px 12px; 
  border-radius: 8px;
  font-size: 0.75rem; 
  font-weight: 500; 
  white-space: nowrap; 
  z-index: var(--z-tooltip); 
  pointer-events: none; 
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeInDown 0.2s ease forwards;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translate(-50%, -4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@media (max-width: 768px) {
  .nav-link[data-tip]:hover::after { display: none; }
}

/* ---------- 加载动画 ---------- */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.95);
  display: flex; align-items: center; justify-content: center; z-index: var(--z-overlay);
  transition: opacity 0.3s ease;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--bg-tertiary);
  border-top: 4px solid var(--primary-color); border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ---------- 应用更新通知 ---------- */
.update-notification {
  position: fixed; bottom: 20px; right: 20px; background: #4f46e5; color: white;
  padding: 15px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: var(--z-notification); animation: slideIn 0.3s ease;
}
.update-content p { margin: 0 0 10px 0; font-weight: 500; }
.update-actions { display: flex; gap: 10px; }
.update-btn {
  background: white; color: #4f46e5; border: none; padding: 6px 12px;
  border-radius: 4px; cursor: pointer; font-weight: 500;
}
.update-btn.secondary { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.3); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- 动画集 ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}
@keyframes calendarFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ---------- 无障碍偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .error-image-container,
  .error-content,
  .error-content .btn {
    animation: none;
    transition: none;
  }
  .error-image-container::after { display: none; }
}
@media (prefers-contrast: high) {
  .error-content { border: 2px solid currentColor; }
  .btn-secondary { border: 2px solid currentColor; }
  .image-background { background: white; border: 1px solid currentColor; }
}



/* =========================================
   通用工具类（从 HTML 内联抽离）
   ========================================= */
.text-decoration-none { text-decoration: none; }
.mt-1 { margin-top: 1rem; }
.opacity-50 { opacity: 0.5; }
.mb-0 { margin-bottom: 0; }


/* =========================================
   通用工具类（Utility Classes）
   ========================================= */
.m-0 { margin: 0 !important; }
.d-none { display: none !important; }
.overflow-x-auto { overflow-x: auto; }
.flex-1-col { flex: 1; display: flex; flex-direction: column; }
.flex-1-col-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.flex-end-mb16 { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.svg-icon { width: 1em; height: 1em; vertical-align: -0.125em; fill: currentColor; }
