/* DSH 学习网站 —— 样式 */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2d3d;
  --text-light: #5e6d82;
  --primary: #4f2ee8;
  --primary-dark: #3a1fb5;
  --primary-light: #7a5cff;
  --accent: #00b3a4;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 12px 32px rgba(79, 46, 232, 0.10);
  --radius: 18px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #f0edff 0%, var(--bg) 45%, #eefaf8 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== 顶栏 ===== */
.topbar {
  background: var(--card);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.brand-logo {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 9px;
  letter-spacing: 0.5px;
}

/* 返回总站：跨站导航，与站内导航做视觉区分（Issue #57） */
.brand-group {
  display: flex; align-items: center; gap: 12px;
  min-width: 0; flex-wrap: wrap;
}
/* 移动端窄屏：品牌文字换成不换行省略，别再被压成一列 */
.brand { min-width: 0; }
.brand > span:last-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-home {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 5px 10px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-light);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.site-home:hover { background: rgba(79, 46, 232, 0.1); color: var(--primary); text-decoration: none; }

/* 导航：窄屏允许换行；极端窄屏（<360px）退化为横向滑动，绝不竖排挤压 */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.topbar-nav::-webkit-scrollbar { display: none; }
.nav-link { white-space: nowrap; flex: 0 0 auto; }
.nav-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  padding: 8px 12px;
  border-radius: 9px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.nav-link:hover { background: #f1f4fa; color: var(--text); }
.nav-link.active { background: rgba(79, 46, 232, 0.1); color: var(--primary); font-weight: 600; }

/* ===== 主体容器 ===== */
.container {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 20px 20px;
}

/* ===== 首页 Hero ===== */
.hero { text-align: center; margin-bottom: 36px; }
.hero .badge {
  display: inline-block;
  background: rgba(79, 46, 232, 0.1);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.hero h1 {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}
.hero p { color: var(--text-light); font-size: 15px; line-height: 1.7; }

/* ===== 阶段卡片 ===== */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}
.stage-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  gap: 18px;
  cursor: pointer;
  border: 1px solid rgba(79, 46, 232, 0.06);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.stage-card:hover { transform: translateY(-5px); box-shadow: 0 20px 40px rgba(79, 46, 232, 0.16); }
.stage-icon { font-size: 34px; line-height: 1; }
.stage-body { flex: 1; }
.stage-body h2 { font-size: 19px; margin-bottom: 8px; }
.stage-body p { color: var(--text-light); font-size: 13px; line-height: 1.6; margin-bottom: 12px; }
.stage-meta { display: flex; gap: 14px; color: var(--text-light); font-size: 12px; margin-bottom: 12px; }
.progress-bar {
  height: 8px;
  background: #eef1f6;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar.big { height: 12px; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.stage-foot { display: flex; align-items: center; justify-content: space-between; }
.stage-pct { font-size: 12px; color: var(--primary); font-weight: 600; }

/* ===== 按钮 ===== */
.btn {
  display: inline-block;
  text-align: center;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(79, 46, 232, 0.08);
  padding: 10px 16px;
  border-radius: 10px;
  text-decoration: none;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn.primary { color: #fff; background: linear-gradient(120deg, var(--primary), var(--accent)); }
.btn.done { color: #fff; background: #00b3a4; }
.back-btn {
  border: none;
  cursor: pointer;
  background: none;
  color: var(--text-light);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
}
.back-btn:hover { background: #f1f4fa; }

/* ===== 阶段页 ===== */
.stage-header { margin-bottom: 24px; }
.stage-header h1 { font-size: 26px; margin: 12px 0 8px; }
.stage-header p { color: var(--text-light); font-size: 14px; margin-bottom: 14px; }
.chapter-list { display: flex; flex-direction: column; gap: 12px; }
.chapter-item {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid rgba(79, 46, 232, 0.05);
}
.chapter-item:hover { transform: translateX(4px); box-shadow: 0 10px 24px rgba(79, 46, 232, 0.12); }
.chapter-num {
  width: 34px; height: 34px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: rgba(79, 46, 232, 0.1);
  color: var(--primary);
  font-weight: 700;
}
.chapter-body { flex: 1; }
.chapter-body h3 { font-size: 16px; margin-bottom: 3px; }
.chapter-doc { font-size: 12px; color: var(--text-light); }
.chapter-status { font-size: 12px; color: var(--text-light); flex-shrink: 0; }
.chapter-status.done { color: #00a48f; font-weight: 600; }
.quiz-entry { margin-top: 24px; text-align: center; }

/* ===== 章节页 ===== */
.chapter-top { display: flex; gap: 10px; margin-bottom: 18px; }
.content-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.content-nav { font-size: 12px; color: var(--text-light); margin-bottom: 8px; }
.content-card h2 { font-size: 24px; margin-bottom: 18px; }
.content-body { line-height: 1.9; color: var(--text); font-size: 15px; }
.content-body h3 { font-size: 18px; margin: 22px 0 10px; }
.content-body p { margin-bottom: 12px; }
.content-body ul, .content-body ol { margin: 0 0 14px 22px; }
.content-body li { margin-bottom: 6px; }
.content-body pre {
  background: #f6f7fb;
  border: 1px solid #eef1f6;
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
}
.content-body code {
  background: #f1f3f9;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--primary);
}
.content-body pre code { background: none; padding: 0; color: var(--text); }
.content-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid #eef1f6;
  flex-wrap: wrap;
}

/* ===== 测试页 ===== */
.quiz-list { display: flex; flex-direction: column; gap: 16px; }
.question {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid rgba(79, 46, 232, 0.05);
}
.q-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.q-num {
  display: inline-block;
  width: 24px; height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  margin-right: 8px;
}
.q-title em { color: var(--accent); font-style: normal; font-size: 12px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #eef1f6;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}
.option:hover { background: #f6f7fb; }
.quiz-submit { text-align: center; margin-top: 24px; }
.prev-result {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(0, 179, 164, 0.1);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
}

/* ===== 结果弹层 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}
.modal h2 { margin-bottom: 12px; font-size: 22px; }
.modal p { color: var(--text-light); font-size: 14px; line-height: 1.8; margin-bottom: 10px; }
.result-score { font-size: 44px; font-weight: 800; color: var(--primary); margin: 8px 0; }
.modal .btn { margin: 8px 6px 0; }

/* ===== 登录/注册弹窗 ===== */
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 26px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--danger); }
.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 18px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid #e5e7f0;
  border-radius: 9px;
  background: var(--card);
  color: var(--text-light);
  cursor: pointer;
  font-size: 14px;
}
.auth-tab.active {
  background: rgba(79, 46, 232, 0.1);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}
.auth-form { text-align: left; }
.auth-form label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin: 14px 0 6px;
}
.auth-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7f0;
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.auth-form input:focus { border-color: var(--primary); }
.auth-msg {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
}
.auth-submit {
  width: 100%;
  margin-top: 12px;
}

/* ===== 进度页 ===== */
.prog-list { display: flex; flex-direction: column; gap: 12px; }
.prog-row {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  border: 1px solid rgba(79, 46, 232, 0.05);
}
.prog-row:hover { transform: translateX(4px); }
.prog-icon { font-size: 26px; }
.prog-info { flex: 1; }
.prog-name { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.prog-stat { font-size: 13px; color: var(--text-light); flex-shrink: 0; }

/* ===== 底部 ===== */
.footer {
  text-align: center;
  padding: 24px 20px;
  color: var(--text-light);
  font-size: 13px;
  line-height: 1.8;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  margin-top: 24px;
}
.footer a { color: var(--primary); text-decoration: none; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  /* 顶栏改为两行：品牌行 / 导航行，导航溢出时横滑 —— 不再互挤成竖排乱码 */
  .topbar-inner {
    padding: 8px 16px;
    row-gap: 6px;
    align-items: center;
  }
  .brand-group { flex: 1 1 auto; }
  .brand { max-width: 100%; }
  .topbar-nav { order: 3; flex: 1 0 100%; }
}
@media (max-width: 640px) {
  .container { padding: 24px 14px; }
  .hero h1 { font-size: 24px; }
  .stage-card { flex-direction: column; }
  .content-card { padding: 18px; }
  .brand-group { gap: 8px; }
  .site-home { padding: 4px 8px; font-size: 12px; }
}

/* ===== 微信扫码登录（Issue #44）=====
 * 二维码固定在 200px：够手机扫，又不会把弹窗撑得过高。
 * 过期遮罩盖在二维码上，点击即刷新 —— 比让用户自己找刷新按钮更直接。
 */
.wx-qr-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 8px auto 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
}

.wx-qr {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.wx-qr-mask {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 13px;
  color: var(--text-light);
}

.wx-tip {
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.wx-follow-tip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin: 10px 0;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 13px;
}

/* 关注引导（Issue #60）：固定底部、可关掉的一行，不占位、不挡内容。
 * 用 fixed 而不是普通块：引导要在任何页面都看得到，但不能把内容挤下去。 */
.wx-follow-tip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  z-index: 900;
  max-width: min(560px, calc(100vw - 24px));
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
  background: #fff;
  border: 1px solid var(--border);
}

.wx-follow-body {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wx-follow-text {
  line-height: 1.45;
}

/* 站点在页面里放的公众号二维码（id=wxFollowGuide 的容器），小尺寸够扫即可 */
#wxFollowGuide img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  display: block;
}

.wx-follow-tip .btn {
  flex: none;
  white-space: nowrap;
}
