/* ============================================================
 *  style.css — 公式大全 · 科技风（高对比度）
 *  三主题：tech 科技深（默认）/ light 明亮 / eye 护眼
 *  设计要点：深色底 + 霓虹青蓝强调色；公式与正文对比度均达 WCAG AA；
 *  护眼模式采用暖色低蓝光底，缓解长时间阅读疲劳。
 * ============================================================ */

/* ---------- 主题变量 ---------- */
:root,
[data-theme="tech"] {
  --bg: #070b16;
  --bg-grid: rgba(56, 189, 248, .07);
  --surface: #0e1726;
  --surface-2: #0b1320;
  --text: #eaf2fb;
  --text-soft: #aebbcd;
  --text-faint: #6f8095;
  --border: #1d2c45;
  --accent: #22d3ee;          /* 霓虹青 */
  --accent-2: #38bdf8;        /* 天蓝 */
  --accent-soft: rgba(34, 211, 238, .12);
  --glow: rgba(34, 211, 238, .35);
  --math-color: #7dd3fc;      /* 公式主色（高对比） */
  --math: #7dd3fc;
  --physics: #fbbf24;
  --chemistry: #34d399;
  --primary: #c084fc;
  --middle: #22d3ee;
  --high: #f472b6;
  --header-bg: linear-gradient(120deg, #0b2440, #06122a);
  --header-text: #eaf2fb;
  --shadow: 0 2px 10px rgba(0, 0, 0, .5);
  --radius: 12px;
}

[data-theme="light"] {
  --bg: #eef3f9;
  --bg-grid: rgba(37, 99, 235, .05);
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --text: #0c1a2e;
  --text-soft: #34465c;
  --text-faint: #647689;
  --border: #d4deec;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, .1);
  --glow: rgba(37, 99, 235, .22);
  --math-color: #1d4ed8;
  --math: #1d4ed8;
  --physics: #b45309;
  --chemistry: #047857;
  --primary: #7c3aed;
  --middle: #0891b2;
  --high: #be185d;
  --header-bg: linear-gradient(120deg, #2563eb, #1e3a8a);
  --header-text: #ffffff;
  --shadow: 0 2px 10px rgba(15, 23, 42, .1);
}

[data-theme="eye"] {
  --bg: #e9e2cc;             /* 暖纸色（低蓝光） */
  --bg-grid: rgba(120, 90, 40, .04);
  --surface: #f3ecd8;
  --surface-2: #e7ddc1;
  --text: #38311f;           /* 深褐，对比度高且柔和 */
  --text-soft: #5b5236;
  --text-faint: #8a7d5c;
  --border: #d6caa6;
  --accent: #2f7d5b;         /* 护眼绿 */
  --accent-2: #3f8f6a;
  --accent-soft: rgba(47, 125, 91, .14);
  --glow: rgba(47, 125, 91, .22);
  --math-color: #1f6f4e;
  --math: #1f6f4e;
  --physics: #a9621a;
  --chemistry: #2f7d5b;
  --primary: #7a5aa0;
  --middle: #2f7d5b;
  --high: #a23b6a;
  --header-bg: linear-gradient(120deg, #4a7a5c, #2f5d44);
  --header-text: #f3ecd8;
  --shadow: 0 2px 10px rgba(90, 70, 30, .14);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 34px 34px;
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}
/* 科技风：深空霓虹辉光底 */
[data-theme="tech"] body {
  background-image:
    radial-gradient(1200px 620px at 82% -12%, rgba(34, 211, 238, .12), transparent 60%),
    radial-gradient(900px 520px at -8% 102%, rgba(129, 140, 248, .10), transparent 60%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
}
@media (prefers-reduced-motion: reduce) {
  [data-theme="tech"] .site-header::after { animation: none; }
  .card, .chip, .icon-btn, .cat-item { transition: none; }
}

/* ---------- Header ---------- */
.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 18px 0;
  box-shadow: var(--shadow);
  border-bottom: 1px solid var(--accent);
}
[data-theme="tech"] .site-header {
  box-shadow: 0 0 28px var(--glow), var(--shadow);
  position: relative;
}
/* 科技风：顶栏流动辉光描边 */
[data-theme="tech"] .site-header::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  background-size: 200% 100%;
  animation: tech-sweep 3.2s linear infinite;
}
@keyframes tech-sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.header-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  font-size: 38px; font-weight: 700; line-height: 1;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 12px;
  width: 56px; height: 56px; display: grid; place-items: center;
  box-shadow: 0 0 16px var(--glow);
}
.brand-text h1 { margin: 0; font-size: 24px; letter-spacing: 2px; }
/* 科技风：霓虹渐变标题 */
[data-theme="tech"] .brand-text h1 {
  background: linear-gradient(90deg, #a5f3fc, #22d3ee, #818cf8);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  text-shadow: 0 0 22px rgba(34, 211, 238, .35);
  font-weight: 800;
}
.brand-text p { margin: 2px 0 0; font-size: 13px; opacity: .85; letter-spacing: .5px; }
.icon-btn {
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25);
  color: var(--header-text);
  width: 42px; height: 42px; border-radius: 10px; cursor: pointer; font-size: 20px;
  transition: background .2s, box-shadow .2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .28); box-shadow: 0 0 14px var(--glow); }

/* ---------- Toolbar ---------- */
.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.toolbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 13px; color: var(--text-faint); font-weight: 600; letter-spacing: .5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-soft); padding: 6px 14px; border-radius: 999px;
  cursor: pointer; font-size: 13px; transition: all .18s; letter-spacing: .5px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent); border-color: var(--accent);
  color: #04121f; font-weight: 700;
  box-shadow: 0 0 12px var(--glow);
}
[data-theme="eye"] .chip.active,
[data-theme="light"] .chip.active { color: #fff; }

.search-box { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-box input {
  width: 260px; max-width: 50vw; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 14px; outline: none; transition: border .18s, box-shadow .18s;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-count { font-size: 13px; color: var(--text-faint); white-space: nowrap; }

/* ---------- Layout ---------- */
.content {
  max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px;
  display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start;
}
.sidebar {
  position: sticky; top: 78px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  max-height: calc(100vh - 100px); overflow-y: auto;
}
[data-theme="tech"] .sidebar { box-shadow: 0 0 18px rgba(34, 211, 238, .12), var(--shadow); }
.sidebar-title { margin: 2px 4px 10px; font-size: 14px; color: var(--text-faint); letter-spacing: 1px; }
.category-list { list-style: none; margin: 0; padding: 0; }
.cat-group {
  font-size: 12px; color: var(--text-faint); font-weight: 700;
  margin: 12px 4px 4px; letter-spacing: .5px;
}
.cat-item {
  width: 100%; text-align: left; border: none; background: transparent;
  color: var(--text-soft); padding: 7px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13px; display: flex; justify-content: space-between;
  align-items: center; transition: background .15s, color .15s;
}
.cat-item:hover { background: var(--surface-2); color: var(--text); }
.cat-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cat-num {
  font-size: 11px; background: var(--surface-2); color: var(--text-faint);
  border-radius: 999px; padding: 1px 7px;
}
.cat-item.active .cat-num { background: var(--accent); color: #04121f; }

/* ---------- Results ---------- */
.group-title {
  grid-column: 1 / -1; font-size: 16px; margin: 18px 2px 4px;
  color: var(--text); border-left: 4px solid var(--accent); padding-left: 10px;
  letter-spacing: .5px;
}
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px; margin-bottom: 8px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 16px 14px;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s;
}
[data-theme="tech"] .card { border-color: #1a2c47; }
.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 0 26px var(--glow), var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { margin: 0; font-size: 16px; line-height: 1.4; color: var(--text); }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; flex-shrink: 0; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--surface-2); color: var(--text-soft);
}
.tag-level-primary { background: rgba(124, 58, 237, .16); color: var(--primary); }
.tag-level-middle { background: rgba(8, 145, 178, .16); color: var(--middle); }
.tag-level-high { background: rgba(219, 39, 119, .16); color: var(--high); }
.tag-subj-math { background: rgba(37, 99, 235, .16); color: var(--math); }
.tag-subj-physics { background: rgba(217, 119, 6, .18); color: var(--physics); }
.tag-subj-chemistry { background: rgba(5, 150, 105, .18); color: var(--chemistry); }

.formula-box {
  margin: 12px 0; padding: 14px 16px; background: var(--surface-2);
  border-radius: 10px; border-left: 3px solid var(--accent);
  border-top: 1px solid var(--border); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  overflow-x: auto; font-size: 16px; text-align: center;
  color: var(--math-color);
}
[data-theme="tech"] .formula-box { box-shadow: inset 0 0 22px rgba(34, 211, 238, .06); }
.katex { color: var(--math-color); }
.katex-display { margin: 2px 0; }

.meta { font-size: 13px; color: var(--text-soft); margin-top: 8px; }
.meta-label {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 5px; padding: 1px 7px; margin-right: 6px;
}
.meta.example .meta-label { color: var(--chemistry); background: rgba(5, 150, 105, .16); }
.meta.note .meta-label { color: var(--physics); background: rgba(217, 119, 6, .18); }

/* 推导折叠 */
.deriv { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.deriv summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent);
  list-style: none; user-select: none;
}
.deriv summary::-webkit-details-marker { display: none; }
.deriv summary::before { content: "▸ "; }
.deriv[open] summary::before { content: "▾ "; }
.deriv-steps { margin: 10px 0 0; padding-left: 4px; list-style: none; }
.deriv-steps li { display: flex; gap: 10px; margin-bottom: 8px; align-items: flex-start; }
.step-no {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 12px;
  display: grid; place-items: center; font-weight: 700; margin-top: 1px;
}
.step-body { font-size: 13.5px; color: var(--text-soft); overflow-x: auto; }

.empty {
  grid-column: 1 / -1; text-align: center; color: var(--text-faint);
  padding: 60px 20px; font-size: 15px;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center; color: var(--text-faint); font-size: 12.5px;
  padding: 24px 20px 36px; border-top: 1px solid var(--border);
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .content { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .search-box { margin-left: 0; width: 100%; }
  .search-box input { width: 100%; max-width: none; }
}
