/* ============================================================
   心晴驿站 · 心理健康关爱平台
   移动优先的响应式样式
   ============================================================ */

:root {
  --c-bg: #f4f7f6;
  --c-surface: #ffffff;
  --c-primary: #7fb09a;
  --c-primary-dark: #5e9480;
  --c-primary-soft: #e7f1ec;
  --c-accent: #c48ea8;
  --c-text: #2f3a3a;
  --c-text-soft: #6b7878;
  --c-text-faint: #9aa6a4;
  --c-border: #e3eae7;
  --c-warn-bg: #fff6e9;
  --c-warn-border: #f0d6a8;
  --c-danger: #d97b6c;
  --c-danger-bg: #fdeeeb;

  --shadow-sm: 0 2px 8px rgba(95, 148, 128, 0.08);
  --shadow-md: 0 6px 20px rgba(95, 148, 128, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 880px;
  --appbar-h: 60px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Helvetica Neue", Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ---------------- 顶部导航 ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
}
.appbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--appbar-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; }
.brand-logo { font-size: 1.5rem; }
.brand-name { color: var(--c-primary-dark); letter-spacing: 0.5px; }

.nav { display: flex; gap: 6px; }
.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--c-text-soft);
  font-size: 0.95rem;
  transition: all 0.2s;
}
.nav a:hover { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.nav a.active { background: var(--c-primary); color: #fff; }

.nav-toggle { display: none; flex-direction: column; gap: 5px; padding: 8px; }
.nav-toggle span {
  width: 22px; height: 2px; background: var(--c-text); border-radius: 2px;
  transition: 0.3s;
}

/* ---------------- 主区域 ---------------- */
.app {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 18px 40px;
}

/* ---------------- 通用组件 ---------------- */
.section-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.section-sub { color: var(--c-text-soft); margin-bottom: 20px; font-size: 0.95rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--c-primary-dark); box-shadow: var(--shadow-md); }
.btn:active { transform: scale(0.97); }
.btn-ghost { background: var(--c-surface); color: var(--c-primary-dark); border: 1.5px solid var(--c-border); box-shadow: none; }
.btn-ghost:hover { background: var(--c-primary-soft); }
.btn-block { width: 100%; }

.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

/* ---------------- 首页 Hero ---------------- */
.hero {
  background: linear-gradient(135deg, #7fb09a 0%, #6aa8b0 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 38px 28px;
  text-align: center;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "🌿";
  position: absolute;
  right: -10px; bottom: -20px;
  font-size: 8rem;
  opacity: 0.12;
}
.hero h1 { font-size: 1.8rem; margin-bottom: 10px; }
.hero p { font-size: 1.02rem; opacity: 0.95; max-width: 520px; margin: 0 auto 22px; }
.hero .btn { background: #fff; color: var(--c-primary-dark); }
.hero .btn:hover { background: #f0f7f4; }

.quote-bar {
  margin-top: 22px;
  text-align: center;
  color: var(--c-text-soft);
  font-style: italic;
  font-size: 0.98rem;
}

/* ---------------- 量表卡片网格 ---------------- */
.scale-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 22px;
}
.scale-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border);
  transition: transform 0.18s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.scale-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.scale-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.scale-ico {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.scale-card h3 { font-size: 1.1rem; }
.scale-tag {
  display: inline-block;
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--c-primary-soft);
  color: var(--c-primary-dark);
  margin-top: 3px;
}
.scale-card p { color: var(--c-text-soft); font-size: 0.9rem; flex: 1; margin-bottom: 14px; }
.scale-meta { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; color: var(--c-text-faint); }

/* ---------------- 测评介绍页 ---------------- */
.intro-box { text-align: center; }
.intro-ico {
  width: 80px; height: 80px; margin: 0 auto 16px;
  border-radius: 22px; display: grid; place-items: center; font-size: 2.6rem;
}
.intro-meta {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin: 18px 0;
}
.intro-chip {
  background: var(--c-primary-soft); color: var(--c-primary-dark);
  padding: 6px 14px; border-radius: 999px; font-size: 0.88rem;
}

/* ---------------- 答题页 ---------------- */
.quiz-head { margin-bottom: 18px; }
.progress {
  height: 8px; background: var(--c-border); border-radius: 999px; overflow: hidden;
  margin: 12px 0 6px;
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--c-primary), var(--c-accent));
  border-radius: 999px; transition: width 0.35s ease;
}
.progress-text { font-size: 0.85rem; color: var(--c-text-soft); text-align: right; }

.question-card { animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
.question-num { color: var(--c-primary); font-weight: 700; font-size: 0.9rem; }
.question-text { font-size: 1.25rem; font-weight: 600; margin: 8px 0 22px; line-height: 1.5; }

.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: 1.02rem;
  transition: all 0.16s;
  text-align: left;
}
.option:hover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.option.selected { border-color: var(--c-primary); background: var(--c-primary-soft); }
.option-radio {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--c-text-faint); flex-shrink: 0;
  display: grid; place-items: center; transition: all 0.16s;
}
.option.selected .option-radio { border-color: var(--c-primary); }
.option.selected .option-radio::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c-primary);
}

.quiz-nav { display: flex; gap: 12px; margin-top: 26px; }
.quiz-nav .btn { flex: 1; }

/* ---------------- 结果页 ---------------- */
.result-hero {
  text-align: center; border-radius: var(--radius);
  padding: 32px 24px; color: #fff; box-shadow: var(--shadow-md);
}
.result-score { font-size: 3.4rem; font-weight: 800; line-height: 1; margin: 8px 0; }
.result-level { font-size: 1.3rem; font-weight: 600; }
.result-gauge {
  margin: 22px auto 0; max-width: 360px;
  height: 10px; border-radius: 999px; background: rgba(255,255,255,0.3); overflow: hidden;
}
.result-gauge-fill { height: 100%; background: #fff; border-radius: 999px; transition: width 0.6s; }

.advice-card { margin-top: 20px; border-left: 4px solid var(--c-primary); }
.advice-card h4 { margin-bottom: 8px; color: var(--c-primary-dark); }

.crisis-alert {
  margin-top: 20px;
  background: var(--c-danger-bg);
  border: 1.5px solid var(--c-danger);
  border-radius: var(--radius);
  padding: 20px;
}
.crisis-alert h4 { color: var(--c-danger); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.crisis-alert p { color: var(--c-text); font-size: 0.95rem; margin-bottom: 12px; }
.crisis-phones { display: flex; flex-direction: column; gap: 8px; }
.crisis-phone {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-radius: var(--radius-sm); padding: 12px 16px;
}
.crisis-phone strong { color: var(--c-danger); font-size: 1.05rem; }

/* ---------------- 历史记录 ---------------- */
.history-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--c-surface); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
}
.history-ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0; }
.history-info { flex: 1; min-width: 0; }
.history-info h4 { font-size: 1rem; }
.history-info span { font-size: 0.82rem; color: var(--c-text-faint); }
.history-badge { padding: 5px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; color: #fff; white-space: nowrap; }

.empty {
  text-align: center; padding: 50px 20px; color: var(--c-text-faint);
}
.empty-ico { font-size: 3.4rem; margin-bottom: 12px; }

/* ---------------- 求助资源 ---------------- */
.resource-card { margin-bottom: 14px; display: flex; align-items: center; gap: 16px; }
.resource-card .res-ico { font-size: 1.8rem; }
.resource-card .res-info { flex: 1; }
.resource-card .res-info h4 { font-size: 1.05rem; }
.resource-card .res-info p { color: var(--c-text-soft); font-size: 0.88rem; }
.resource-call {
  background: var(--c-primary); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 600; font-size: 1.05rem; white-space: nowrap;
}

.notice {
  background: var(--c-warn-bg); border: 1px solid var(--c-warn-border);
  border-radius: var(--radius); padding: 16px 18px; font-size: 0.9rem;
  color: #8a6d3b; margin-bottom: 20px;
}

/* ---------------- 底部 ---------------- */
.footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 24px 18px;
  text-align: center;
}
.footer-disclaimer {
  max-width: var(--maxw); margin: 0 auto 8px;
  font-size: 0.82rem; color: var(--c-text-soft); line-height: 1.7;
}
.footer-copy { font-size: 0.8rem; color: var(--c-text-faint); }

/* ---------------- 移动端底部 Tab 栏 ---------------- */
.tabbar { display: none; }

/* ============================================================
   响应式：移动端 (≤ 720px)
   ============================================================ */
@media (max-width: 720px) {
  .nav { display: none; }
  .nav-toggle { display: flex; }

  /* 抽屉式菜单 */
  .nav.open {
    display: flex;
    position: fixed;
    top: var(--appbar-h); left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--c-surface);
    padding: 8px;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid var(--c-border);
    z-index: 49;
  }
  .nav.open a { padding: 14px 16px; border-radius: var(--radius-sm); }

  .app { padding: 18px 14px 90px; } /* 给底部 tabbar 留空间 */

  .hero { padding: 30px 20px; }
  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: 0.95rem; }

  .section-title { font-size: 1.25rem; }
  .question-text { font-size: 1.12rem; }
  .result-score { font-size: 2.8rem; }

  .scale-grid { grid-template-columns: 1fr; }

  /* 移动端底部导航栏 */
  .tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--c-border);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 0 6px; font-size: 0.72rem; color: var(--c-text-faint);
    transition: color 0.2s;
  }
  .tabbar a .tab-ico { font-size: 1.3rem; }
  .tabbar a.active { color: var(--c-primary-dark); }

  .resource-card { flex-wrap: wrap; }
  .crisis-phone { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* 大屏微调 */
@media (min-width: 721px) {
  .hero h1 { font-size: 2.1rem; }
}

/* 尊重减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
