/* ============================================================================
 * common.css — yingming006.cn 全站统一基础样式（基础规范）
 *
 * 风格：极简 · 纯扁平化
 *   - 纯色背景，无渐变、无光晕、无暗黑特效
 *   - 用 1px 极细边框分隔区域（参考 Stripe 的干净实用风格）
 *   - 无悬浮卡片：hover 只改变边框/背景色，不做位移与阴影
 *   - 强调色为中性墨色（Stripe ink 色系），拒绝紫蓝渐变
 *
 * 使用约定：
 *   - 所有页面（含后续新增子应用）必须引用本文件：
 *       <link rel="stylesheet" href="/common/common.css">
 *   - 页面只允许使用本文件定义的设计令牌（--bg/--surface/--text/--border/...），
 *     不得自行定义一套新配色；
 *   - 通用组件（site-header / btn / input / select / card / theme-toggle）
 *     已在此定义，页面直接复用类名；页面特有样式写在页面内并按需微调。
 * ========================================================================== */

/* ---------------- 设计令牌 ---------------- */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  /* 背景与表面 */
  --bg: #ffffff;            /* 页面背景 */
  --surface: #ffffff;       /* 卡片 / 面板 / 输入框背景 */
  --surface-2: #f6f7f9;     /* 次级背景：悬浮、工具栏、代码块 */
  --surface-3: #eef0f3;     /* 更深的次级背景 */

  /* 文字 */
  --text: #1a1f26;          /* 主文字 */
  --text-dim: #5f6b76;      /* 次要文字 */
  --text-faint: #8a94a0;    /* 弱化文字 / 占位符 */

  /* 边框 */
  --border: #e5e8ec;        /* 极细分隔线 */
  --border-strong: #c9d0d8; /* 强调边框（hover / 聚焦） */

  /* 强调色：中性墨色（Stripe ink） */
  --accent: #0a2540;
  --accent-hover: #1c3a5e;
  --accent-contrast: #ffffff;

  /* 语义色（低饱和） */
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --success: #067647;
  --warning: #b54708;

  /* 圆角（偏小，扁平） */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "SF Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1115;
  --surface: #16191f;
  --surface-2: #1c2027;
  --surface-3: #242932;

  --text: #e8eaed;
  --text-dim: #9aa3af;
  --text-faint: #6b7480;

  --border: #262b33;
  --border-strong: #3a4150;

  /* 深色下主按钮反转为浅色实底（Stripe 深色主题做法） */
  --accent: #e8eaed;
  --accent-hover: #ffffff;
  --accent-contrast: #0f1115;

  --danger: #f0705f;
  --danger-soft: #3a2320;
  --success: #4cc38a;
  --warning: #e8a13c;
}

/* ---------------- 基础 ---------------- */

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

html {
  scrollbar-gutter: stable;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* 滚动条（细、低调） */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------- 通用组件：顶部导航 ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.site-brand:hover {
  color: var(--text);
}

.site-divider {
  color: var(--text-faint);
  font-size: 13px;
  user-select: none;
}

.site-page-name {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------------- 通用组件：按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  border-color: var(--text-dim);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--accent-contrast);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

/* ---------------- 通用组件：主题切换按钮 ---------------- */

.theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------- 通用组件：输入控件 ---------------- */

.input,
.select,
textarea.input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input:focus,
.select:focus,
textarea.input:focus {
  border-color: var(--accent);
}

.input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

.select {
  cursor: pointer;
}

/* ---------------- 通用组件：卡片 ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 640px) {
  .site-header-inner {
    padding: 0 14px;
  }

  .site-page-name {
    max-width: 40vw;
  }
}
