/* public/theme-customization.css
 * 主题定制 —— 参考 new-api 的 theme-customization 设计: 把「主题」拆成**相互独立可组合**的轴,
 * 而不是只能整包切换几个固定配色。
 *
 *   配色预设  data-theme-accent          在任意基础主题上叠加强调色 (不改变明暗基调)
 *   圆角      data-theme-radius          无 / 小 / 中 / 大 / 特大
 *   字体      data-theme-font            跟随主题 / 无衬线 / 衬线 / 几何
 *   内容宽度  data-theme-layout          撑满 / 居中限宽
 *
 * 级联顺序很重要: 基础主题 (console.css 的 [data-theme=...]) 先定义整套变量, 本文件的轴块
 * **在后面**覆盖对应变量, 因此用户显式选择总能赢过主题内置默认值 —— 与 new-api 把
 * radius/scale 块放在 preset 块之后的理由相同。
 *
 * 未做任何定制时不写属性, 所有二阶参数取原值, 视觉零变化。
 */

/* ============ 圆角 ============ */
/* 只覆盖源码里实际用到的四档 (md/lg/xl/2xl) 以及自绘控件的圆角变量;
 * rounded-full (胶囊) 不参与缩放, 否则头像/开关会变成方块。 */
:root {
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --ui-radius-sm: 6px;
}
html[data-theme-radius='none'] {
  --radius-md: 0; --radius-lg: 0; --radius-xl: 0; --radius-2xl: 0; --ui-radius-sm: 0;
}
html[data-theme-radius='sm'] {
  --radius-md: 0.2rem; --radius-lg: 0.25rem; --radius-xl: 0.35rem; --radius-2xl: 0.5rem; --ui-radius-sm: 3px;
}
html[data-theme-radius='md'] {
  --radius-md: 0.375rem; --radius-lg: 0.5rem; --radius-xl: 0.75rem; --radius-2xl: 1rem; --ui-radius-sm: 6px;
}
html[data-theme-radius='lg'] {
  --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem; --radius-2xl: 1.35rem; --ui-radius-sm: 9px;
}
html[data-theme-radius='xl'] {
  --radius-md: 0.75rem; --radius-lg: 1rem; --radius-xl: 1.35rem; --radius-2xl: 1.75rem; --ui-radius-sm: 13px;
}

/* ============ 配色预设 ============ */
/* 只改强调色系 (accent / accent-2 / logo 渐变 / 光晕), 不动明暗基调与文本对比度 ——
 * 因此可安全叠加在 obsidian(深) / graphite-amber(深) / pine-green(浅) 任意基础主题上,
 * 也能叠加会员主题。取值参考 new-api 的 preset 色板 (oklch 转 sRGB 近似)。 */
html:not([data-member-theme])[data-theme-accent='anthropic'] {
  --th-accent: #d97757; --th-accent-2: #e8a087;
  --th-logo-grad: linear-gradient(135deg, #2a1f1a 0%, #d97757 68%, #f0c3ad 100%);
  --th-hero-glow-1: rgba(217, 119, 87, 0.16); --th-hero-glow-2: rgba(232, 160, 135, 0.08);
}
html:not([data-member-theme])[data-theme-accent='underground'] {
  --th-accent: #3f9a72; --th-accent-2: #b46fa8;
  --th-logo-grad: linear-gradient(135deg, #101a15 0%, #3f9a72 68%, #b46fa8 100%);
  --th-hero-glow-1: rgba(63, 154, 114, 0.16); --th-hero-glow-2: rgba(180, 111, 168, 0.08);
}
html:not([data-member-theme])[data-theme-accent='rose-garden'] {
  --th-accent: #e0446a; --th-accent-2: #f0a0b4;
  --th-logo-grad: linear-gradient(135deg, #2a1219 0%, #e0446a 68%, #f0a0b4 100%);
  --th-hero-glow-1: rgba(224, 68, 106, 0.16); --th-hero-glow-2: rgba(240, 160, 180, 0.08);
}
html:not([data-member-theme])[data-theme-accent='lake-view'] {
  --th-accent: #2fa88a; --th-accent-2: #4fb8cc;
  --th-logo-grad: linear-gradient(135deg, #0d1f1c 0%, #2fa88a 68%, #4fb8cc 100%);
  --th-hero-glow-1: rgba(47, 168, 138, 0.16); --th-hero-glow-2: rgba(79, 184, 204, 0.08);
}
html:not([data-member-theme])[data-theme-accent='sunset-glow'] {
  --th-accent: #e8734a; --th-accent-2: #f0b45c;
  --th-logo-grad: linear-gradient(135deg, #2a1a12 0%, #e8734a 68%, #f0b45c 100%);
  --th-hero-glow-1: rgba(232, 115, 74, 0.16); --th-hero-glow-2: rgba(240, 180, 92, 0.08);
}
html:not([data-member-theme])[data-theme-accent='forest-whisper'] {
  --th-accent: #2f9c9c; --th-accent-2: #7f93c4;
  --th-logo-grad: linear-gradient(135deg, #0d1e1e 0%, #2f9c9c 68%, #7f93c4 100%);
  --th-hero-glow-1: rgba(47, 156, 156, 0.16); --th-hero-glow-2: rgba(127, 147, 196, 0.08);
}
html:not([data-member-theme])[data-theme-accent='ocean-breeze'] {
  --th-accent: #3b6fe0; --th-accent-2: #7a6ff0;
  --th-logo-grad: linear-gradient(135deg, #101a2e 0%, #3b6fe0 68%, #7a6ff0 100%);
  --th-hero-glow-1: rgba(59, 111, 224, 0.16); --th-hero-glow-2: rgba(122, 111, 240, 0.08);
}
html:not([data-member-theme])[data-theme-accent='lavender-dream'] {
  --th-accent: #8b5cf6; --th-accent-2: #67b8d6;
  --th-logo-grad: linear-gradient(135deg, #1a1526 0%, #8b5cf6 68%, #67b8d6 100%);
  --th-hero-glow-1: rgba(139, 92, 246, 0.16); --th-hero-glow-2: rgba(103, 184, 214, 0.08);
}

/* ============ 字体 ============ */
/* 只改正文族; 代码/等宽 (.font-mono) 与数字指标保持 DM Mono, 否则数字列会错位。 */
html[data-theme-font='sans'] {
  --ui-font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
html[data-theme-font='serif'] {
  /* 系统衬线 + CJK 衬线回退, 不新增字体资源 */
  --ui-font-body: Georgia, 'Times New Roman', 'Songti SC', 'Noto Serif CJK SC', 'Source Han Serif SC', serif;
}
html[data-theme-font='grotesk'] {
  --ui-font-body: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
html[data-theme-font] body,
html[data-theme-font] .font-sans {
  font-family: var(--ui-font-body);
}
/* 等宽域显式还原, 避免被上面的 body 规则继承覆盖 */
html[data-theme-font] .font-mono,
html[data-theme-font] code,
html[data-theme-font] pre,
html[data-theme-font] kbd {
  font-family: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ============ 内容宽度 ============ */
/* 撑满: 默认行为 (不写属性即撑满)。居中: 给主内容区限宽并水平居中, 大屏阅读更舒适。 */
html[data-theme-layout='centered'] .page-container {
  max-width: var(--ui-content-max-width, 1280px);
  margin-inline: auto;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme-layout='centered'] .page-container { transition: none; }
}

/* ============ 自绘组件的圆角轴接入 ============ */
/* Tailwind 的 569 处 rounded-* 已由 --radius-* 驱动; 这里再覆盖圆角较大、视觉最明显的
 * 自绘组件 (面板/输入/卡片/弹窗), 让圆角轴在自定义组件上同样可见。
 * 值取自各自原本的圆角, 乘同一套档位, 未启用定制时与原来一致。 */
:root { --ui-radius-lg: 12px; --ui-radius-xl: 16px; --ui-radius-2xl: 24px; }
html[data-theme-radius='none'] { --ui-radius-lg: 0; --ui-radius-xl: 0; --ui-radius-2xl: 0; }
html[data-theme-radius='sm']   { --ui-radius-lg: 5px; --ui-radius-xl: 7px; --ui-radius-2xl: 10px; }
html[data-theme-radius='md']   { --ui-radius-lg: 12px; --ui-radius-xl: 16px; --ui-radius-2xl: 24px; }
html[data-theme-radius='lg']   { --ui-radius-lg: 16px; --ui-radius-xl: 22px; --ui-radius-2xl: 32px; }
html[data-theme-radius='xl']   { --ui-radius-lg: 22px; --ui-radius-xl: 30px; --ui-radius-2xl: 44px; }

html[data-theme-radius] .glass-panel,
html[data-theme-radius] .bento-card,
html[data-theme-radius] .landing-feature-card,
html[data-theme-radius] .gateway-console { border-radius: var(--ui-radius-xl); }
html[data-theme-radius] .input-apple { border-radius: var(--ui-radius-sm); }
html[data-theme-radius] .badge-apple,
html[data-theme-radius] .console-page-heading-actions { border-radius: var(--ui-radius-sm); }

/* ============ 定制面板 ============ */
.theme-custom-dialog {
  /* 与其他弹窗一致 (after-sales.css / api-tokens.css): 原生 <dialog> 居中依赖
   * position:fixed + inset:0 + margin:auto; 只给宽高会让它贴在左上角。 */
  position: fixed; inset: 0; margin: auto;
  width: min(680px, calc(100vw - 2rem));
  max-height: min(84vh, 760px);
  padding: 0;
  border: 1px solid var(--th-border);
  border-radius: var(--ui-radius-xl);
  background: var(--th-bg-2, var(--th-bg));
  color: var(--th-text);
  overflow: hidden;
}
.theme-custom-dialog::backdrop { background: var(--th-overlay, rgba(0, 0, 0, 0.68)); backdrop-filter: blur(4px); }
.theme-custom-dialog > header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--th-border);
}
.theme-custom-dialog > header h2 { color: var(--th-text); font-size: 15px; font-weight: 700; }
.theme-custom-dialog > header p { margin-top: 4px; color: var(--th-text-2); font-size: 11px; line-height: 1.5; }
.theme-custom-dialog > header button {
  flex-shrink: 0; padding: 6px 12px; border: 1px solid var(--th-border); border-radius: var(--ui-radius-sm);
  background: var(--th-surface-subtle); color: var(--th-text-2); font-size: 11px;
}
.theme-custom-dialog > header button:hover { color: var(--th-text); border-color: var(--th-accent); }
.theme-custom-body { max-height: 58vh; overflow-y: auto; padding: 16px 20px; display: grid; gap: 18px; }
.theme-custom-section { display: grid; gap: 9px; }
.theme-custom-heading h3 { color: var(--th-text); font-size: 12px; font-weight: 600; }
.theme-custom-heading p { margin-top: 2px; color: var(--th-text-2); font-size: 10.5px; }
.theme-custom-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.theme-custom-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 9px 8px; border: 1px solid var(--th-border); border-radius: var(--ui-radius-lg);
  background: var(--th-surface-subtle); color: var(--th-text-2); font-size: 11px;
  transition: border-color .15s, color .15s, background .15s;
}
.theme-custom-option:hover { color: var(--th-text); background: var(--th-surface-muted); }
.theme-custom-option.active { color: var(--th-text); border-color: var(--th-accent); box-shadow: inset 0 0 0 1px var(--th-accent); }
.theme-custom-swatch { width: 100%; height: 20px; border-radius: 5px; border: 1px solid var(--th-border); }

/* 文字与布局 (原「显示设置」并入): 分组标题 + 选项网格 + 阅读预览 */
.theme-custom-display { border-top: 1px solid var(--th-border); padding-top: 16px; }
.theme-custom-display-group { display: grid; gap: 7px; }
.theme-custom-display-group h4 { color: var(--th-text-2); font-size: 11px; font-weight: 600; }
.theme-custom-display .theme-custom-options { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
.theme-custom-reading-preview {
  display: grid; gap: 6px; padding: 12px 14px;
  border: 1px solid var(--th-border); border-radius: var(--ui-radius-lg);
  background: var(--th-surface-subtle);
}
.theme-custom-reading-title { color: var(--th-text-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.theme-custom-reading-preview p { color: var(--th-text); font-size: var(--ui-body, 13px); }
.theme-custom-reading-preview strong { color: var(--th-accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; }
.theme-custom-display-status { color: var(--th-text-2); font-size: 10.5px; }
.theme-custom-dialog > footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 20px; border-top: 1px solid var(--th-border);
  /* console.css 有一条**裸 `footer { background:#020204; padding:60px 32px }`** (面向着陆页),
   * 它会漏进所有弹窗 —— after-sales.css 同样需要显式重置。这里显式复位, 否则浅色主题下
   * 面板底部会出现一条深色横带。 */
  background: transparent; color: var(--th-text-2);
  width: auto; min-height: 0; margin: 0;
}
.theme-custom-dialog > header { background: transparent; }
.theme-custom-dialog > footer button { padding: 7px 14px; border-radius: var(--ui-radius-sm); font-size: 11px; border: 1px solid var(--th-border); background: var(--th-surface-subtle); color: var(--th-text-2); }
.theme-custom-dialog > footer button:hover { color: var(--th-text); }
.theme-custom-dialog > footer [data-reset] { margin-right: auto; }
@media (max-width: 700px) {
  .theme-custom-options { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .theme-custom-body { max-height: 52vh; padding: 14px; }
}
