/* styles/global.css */

:root {

  /* =========================
     Typography System (DESIGN.md driven)
     ========================= */

  --fs-xxs: 12px;
  --fs-xs: 14px;
  --fs-sm: 18px;
  --fs-md: 24px;
  --fs-lg: 32px;
  --fs-xl: 40px;
  --fs-xxl: 56px;
  --fs-display: 72px;

  /* Chinese teaching emphasis sizes */
  --cn-base: 32px;
  --cn-emphasis: 36px;
  --cn-scale: 1.15;  /* ✅ 修复1：添加分号 */

  /* Legacy alias (to avoid breaking existing pages immediately) */
  --title-size: var(--fs-display);
  --section-size: var(--fs-lg);
  --en-size: var(--fs-xl);
  --expr-en-size: var(--fs-lg);
  --expr-cn-size: var(--cn-base);
  --adj-word-size: var(--fs-xl);
  --adj-cn-size: var(--cn-base);

  /* =========================
     Spacing System
     ========================= */

  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;

  /* =========================
     Radius System
     ========================= */

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* =========================
     Shadow System
     ========================= */

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.10);
  --shadow-hover: 0 12px 32px rgba(0,0,0,0.12);

  /* =========================
     Colors
     ========================= */

  --primary: #6366f1;
  --primary-hover: #4F46E5;  /* ✅ 移动到这里 */
  --success: #10b981;
  --error: #ef4444;

  --text-primary: #111827;
  --text-secondary: #6b7280;
  --neutral: #9ca3af;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.08);

  /* =========================
     Line Height
     ========================= */

  --line-height-tight: 1.4;
  --line-height-normal: 1.75;
  --line-height-loose: 2;

  /* =========================
     Button System
     ========================= */

  --radius-btn: 6px;
  --transition-base: 200ms ease;

  /* =========================
     Font System
     ========================= */

  --font-display: 'General Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: 'DM Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  /* =========================
     Layout
     ========================= */

  --header-height: 72px;
}

/* =========================
   Base Reset
   ========================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: var(--cn-base);
  line-height: var(--line-height-normal);
  background: var(--bg);
  color: var(--text-primary);
  padding-top: var(--header-height);
}

/* =========================
   Container & Layout
   ========================= */

.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
  min-height: calc(100vh - var(--header-height));
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* =========================
   Typography Primitives
   ========================= */

.page-title {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

.section-title,
.section-heading {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

.column-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.page-subtitle,
.column-desc {
  font-size: var(--fs-xs);
  line-height: var(--line-height-normal);
  color: var(--text-secondary);
}

p {
  font-size: var(--cn-base);
  line-height: var(--line-height-normal);
  color: var(--text-secondary);
}

.main-content li,
.content li,
.article li,
.word-list li,
.example-list li {
  font-size: var(--cn-base);
  line-height: var(--line-height-normal);
  color: var(--text-secondary);
}

.card-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

/* 标题层级 */
h1 {
  font-size: var(--fs-display);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

h3 {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

h4 {
  font-size: var(--fs-md);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

/* =========================
   Link Styles
   ========================= */

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

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* =========================
   Card Component
   ========================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* =========================
   Button Component
   ========================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-btn);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  top: 0;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

/* =========================
   Navigation (统一内联版 · 取代 fetch 加载的 navbar.html
   ========================= */

.global-navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.global-navbar .nav-container {
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.03em;
}
.nav-logo span { color: var(--primary); }

.nav-search-bar {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 36px;
  width: 220px;
  cursor: pointer;
  transition: border-color var(--transition-base);
}
.nav-search-bar:hover { border-color: var(--primary); }
.nav-search-bar input {
  border: none;
  background: transparent;
  width: 100%;
  margin-left: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}
.search-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}
.search-icon { flex-shrink: 0; color: var(--neutral); }

.global-navbar .nav-links {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  list-style: none;
  gap: 4px;
  margin: 0;
  padding: 0;
}
.nav-item {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all var(--transition-base);
}
.nav-item:hover,
.nav-item.active {
  color: var(--text-primary);
  background-color: var(--bg);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--primary);
}
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.mobile-menu-toggle span {
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition-base);
}
.mobile-drawer { display: none; }

@media (max-width: 768px) {
  .global-navbar .nav-links,
  .nav-search-bar { display: none; }
  .mobile-menu-toggle { display: flex; }
  .global-navbar .nav-container { padding: 0 16px; }
  .mobile-drawer.open {
    display: block;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    z-index: 999;
  }
  .mobile-drawer ul { list-style: none; margin: 0; padding: 0; }
  .drawer-item {
    display: block;
    padding: 12px 0;
    font-size: 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--bg);
  }
  .drawer-item.active { color: var(--primary); font-weight: 600; }
}

/* =========================
   Footer
   ========================= */

.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--space-6) var(--space-4);
  margin-top: var(--space-7);
  text-align: center;
  font-size: var(--fs-xxs);
  color: var(--text-secondary);
}

/* =========================
   Grid & Layout Utilities
   ========================= */

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* 两栏布局 */
.two-column {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
}

.two-column > * {
  flex: 1;
  min-width: 0;
}

/* 响应式 */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .two-column {
    flex-direction: column;
  }
  
  .main-content {
    padding: var(--space-4) var(--space-3);
  }
  
  .page-title {
    font-size: var(--fs-xl);
  }
  
  h1 {
    font-size: var(--fs-xl);
  }
  
  h2 {
    font-size: var(--fs-lg);
  }
  
  .nav-links {
    gap: var(--space-2);
  }
  
  .nav-links a {
    font-size: var(--fs-xs);
  }
}

/* =========================
   Utility Classes
   ========================= */

/* Text alignment */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Text colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-neutral { color: var(--neutral); }

/* Background colors */
.bg-white { background: var(--surface); }
.bg-gray { background: var(--bg); }

/* Spacing utilities */
.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-2); }
.mt-md { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }
.mt-xl { margin-top: var(--space-7); }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-2); }
.mb-md { margin-bottom: var(--space-4); }
.mb-lg { margin-bottom: var(--space-6); }
.mb-xl { margin-bottom: var(--space-7); }

.ml-sm { margin-left: var(--space-2); }
.mr-sm { margin-right: var(--space-2); }

.p-sm { padding: var(--space-2); }
.p-md { padding: var(--space-4); }
.p-lg { padding: var(--space-6); }

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-4); }

/* Border radius */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-pill); }

/* Shadow */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-hover { box-shadow: var(--shadow-hover); }

/* =========================
   Dark Mode Support
   ========================= */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --neutral: #64748b;
  }
}

/* =========================
   Print Styles
   ========================= */

@media print {
  .navbar,
  .footer,
  .no-print {
    display: none;
  }
  
  body {
    padding-top: 0;
    background: white;
  }
  
  .main-content {
    padding: 0;
    max-width: 100%;
  }
  
  a {
    text-decoration: underline;
    color: black;
  }
}
