/* =====================================================================
 * Foliage v1.0 — base.css
 * 全局重置 + 排版 + 布局工具类 + 响应式
 * 基于 v0.9.72 base.css · 搬运 + 精简 · 2026-06-11
 * ===================================================================== */

/* =====================================================================
 * §1 全局重置
 * ===================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  min-height: 100vh;
  font-feature-settings: "tnum" 1, "kern" 1;
  transition: background var(--transition), color var(--transition);
}


/* =====================================================================
 * §2 排版
 * ===================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  color: var(--text);
  margin: 0;
}
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-md); }

p { margin: 0; }

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--text-link-hover); }

code, pre, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* 等宽数字全局 */
body {
  font-variant-numeric: tabular-nums;
}


/* =====================================================================
 * §3 布局工具类
 * ===================================================================== */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.container-wide {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* Flex 组合 */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { gap: var(--space-2); }
.stack-lg { gap: var(--space-6); }
.stack-xl { gap: var(--space-10); }

.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.cluster-end { justify-content: flex-end; }
.cluster-between { justify-content: space-between; }

/* Grid */
.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); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-auto-fit { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Flex 快捷 */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-row-sm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }

/* 主内容 */
main {
  max-width: var(--container-wide);
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--space-4);
}


/* =====================================================================
 * §4 响应式 — MOBILE-001 (断点 768px → 1024px 激进策略)
 * ===================================================================== */
@media (max-width: 1024px) {
  :root { --header-height: 56px; }
  .container, .container-wide { padding: 0 var(--space-4); }
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }

  /* 顶部 nav 折叠为汉堡菜单 (mobile-nav.js 控制) */
  .site-header .site-nav.mobile-collapsed {
    display: none !important;
  }

  main { padding: 0 var(--space-2); }
  .hide-mobile { display: none !important; }

  /* 卡片内 flex-between 在 mobile 改为纵向,避免内容挤压竖排 (MOBILE-001 Batch 4)
   * 注意: 只影响 .card-body.flex-between,不波及全局 .flex-between (admin topbar 等) */
  .card-body.flex-between {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  /* cluster 容器在 mobile 也允许换行 */
  .cluster { flex-wrap: wrap; }
  /* 卡片内边距缩小 */
  .card { padding: var(--space-4); }
  /* 操作按钮 (mobile 下保持 44px 触摸目标) */
  .btn-sm { min-height: 36px; padding: 6px 10px; }
}

@media (min-width: 1025px) {
  .show-mobile { display: none !important; }
}


/* =====================================================================
 * §5 可访问性
 * ===================================================================== */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: var(--space-4);
  z-index: 99999;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  opacity: 0;
  transition: top 0.2s, opacity 0.2s;
}
.skip-to-content:focus {
  top: var(--space-4);
  opacity: 1;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}


/* =====================================================================
 * §6 减少动效偏好
 * ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* =====================================================================
 * §7 主题切换过渡
 * ===================================================================== */
html, body, .card, .btn, .nav-item, .surface-2, .modal-overlay-full,
input, textarea, select, [class*="bg-"], [class*="text-"] {
  transition: background-color 0.3s ease, color 0.3s ease,
              border-color 0.3s ease, box-shadow 0.3s ease;
}


/* =====================================================================
 * §8 DOCS-CMS 文档页面 (about / help / privacy / tos / pricing / compliance)
 * ===================================================================== */
.doc-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 0;
  color: var(--text);
}
.doc-page h1 { font-size: 28px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.doc-page h2 { font-size: 22px; font-weight: 600; margin-top: 32px; margin-bottom: 12px; color: var(--text); }
.doc-page h3 { font-size: 18px; font-weight: 600; margin-top: 24px; margin-bottom: 8px; color: var(--text); }
.doc-page p { line-height: 1.7; margin-bottom: 12px; }
.doc-page ul, .doc-page ol { padding-left: 24px; margin-bottom: 12px; }
.doc-page li { margin-bottom: 6px; }
.doc-page a { color: var(--accent); }
.doc-page code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.doc-page .doc-meta {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}
