/* ===================== 启智数理 · 响应式样式 ===================== */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --text: #1f2937;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --brand: #4f7df0;
  --brand-2: #6ad4d5;
  --math: #4f7df0;
  --math-soft: #eaf1ff;
  --physics: #14b8a6;
  --physics-soft: #e0f7f4;
  --line: #e5eaf3;
  --shadow: 0 2px 10px rgba(20, 30, 60, 0.06);
  --shadow-hover: 0 8px 24px rgba(20, 30, 60, 0.10);
  --radius: 14px;
  --gap: 18px;
  --container: 1200px;
  --header-h: 120px;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

/* ---------- 顶部品牌区（无小字） ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  padding: 36px 20px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--header-h);
}

.hero-inner {
  width: 100%;
  max-width: var(--container);
  text-align: center;
}

.brand {
  margin: 0;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* ---------- 主体容器 ---------- */
.container {
  max-width: var(--container);
  margin: -28px auto 0;
  padding: 0 20px 40px;
  position: relative;
  z-index: 1;
}

/* ---------- 搜索框 ---------- */
.search-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  margin-bottom: 22px;
}

#search {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  padding: 14px 16px;
  color: var(--text);
  border-radius: 10px;
}

#search::placeholder { color: var(--text-3); }

/* ---------- 学科板块 ---------- */
.section { margin-top: 8px; }

.section + .section { margin-top: 28px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 6px 4px 14px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-title .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.section[data-subject="math"] .section-title .dot { background: var(--math); }
.section[data-subject="physics"] .section-title .dot { background: var(--physics); }

.section-meta {
  font-size: 13px;
  color: var(--text-3);
}

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .15s ease, box-shadow .15s ease;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  min-height: 160px;
}

.card:hover, .card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line);
  outline: none;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
}

.section[data-subject="math"] .tag.tag-subject { background: var(--math-soft); color: #2956c8; }
.section[data-subject="physics"] .tag.tag-subject { background: var(--physics-soft); color: #0d8b7e; }

.tag-grade { background: #f3f0ff; color: #6a4ec2; }

.tag-chapter {
  background: rgba(245, 158, 11, 0.10);
  color: #b45309;
  font-weight: 600;
  border: 1px dashed rgba(245, 158, 11, 0.45);
}

.card-title {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  flex: 1;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  margin-top: auto;
}

.card-type {
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-2);
}

/* ---------- 特色工具板块 ---------- */
.featured { margin-top: 8px; }
#featured .dot { background: #f59e0b; }
#featured .tag.tag-subject { background: #fef3c7; color: #b45309; }
#featured .card { border: 1px solid #fde68a; box-shadow: 0 4px 16px rgba(245, 158, 11, 0.12); }
#featured .card:hover { box-shadow: 0 8px 24px rgba(245, 158, 11, 0.18); }
#featured .card-title { font-size: 17px; }

/* ---------- 学期分组 ---------- */
.sem-group { margin-bottom: 20px; }
.sem-group:last-child { margin-bottom: 4px; }
.sem-title {
  margin: 0 4px 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sem-title::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--brand);
  flex-shrink: 0;
}
.section[data-subject="physics"] .sem-title::before { background: var(--physics); }
.sem-title .sem-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-left: auto;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  color: var(--text-3);
  padding: 40px 0;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ===================== 响应式断点 ===================== */

/* 平板：≤ 900px */
@media (max-width: 900px) {
  :root {
    --gap: 14px;
    --header-h: 100px;
  }
  .brand { font-size: 30px; letter-spacing: 1.5px; }
  .hero { padding: 28px 18px 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .container { padding: 0 16px 32px; }
  .section-title { font-size: 18px; }
  .card { padding: 16px 16px 14px; min-height: 150px; }
  .card-title { font-size: 15px; }
}

/* 手机：≤ 640px */
@media (max-width: 640px) {
  :root {
    --header-h: 84px;
    --gap: 12px;
  }
  html, body { font-size: 14px; }
  .brand { font-size: 24px; letter-spacing: 1px; }
  .hero { padding: 22px 16px 20px; }
  .container {
    margin-top: -20px;
    padding: 0 12px 28px;
  }
  .search-wrap { margin-bottom: 18px; }
  #search { font-size: 14px; padding: 12px 14px; }
  .section + .section { margin-top: 22px; }
  .section-head { margin: 4px 2px 10px; gap: 8px; }
  .section-title { font-size: 16px; }
  .section-meta { font-size: 12px; }
  /* 手机端：1-2 列自适应 */
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card {
    padding: 14px 14px 12px;
    min-height: 0;
  }
  .card-title { font-size: 14px; }
  .card-desc { font-size: 12px; -webkit-line-clamp: 3; }
  .card-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .card-tags { font-size: 11px; gap: 4px; }
  .tag { padding: 2px 7px; }
  .card-foot { font-size: 11px; }
}

/* 极小屏：≤ 380px */
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
  .brand { font-size: 22px; }
}

/* 大屏：≥ 1400px 更宽容器 */
@media (min-width: 1400px) {
  :root { --container: 1280px; --gap: 20px; }
  .brand { font-size: 40px; }
}