/* ============================================================
   pages.css
   各页面布局 + 响应式（覆盖 Mac / Windows / iPad / 安卓平板 / 手机）
   ============================================================ */

/* ============================================================
   登录页
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-6) + var(--safe-b));
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--c-card);
  border-radius: var(--r-card);
  padding: var(--sp-6) var(--sp-5);
  box-shadow: 0 6px 24px rgba(31, 42, 51, .10);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--sp-5);
}

.login-emoji {
  font-size: 58px;
  line-height: 1;
  display: block;
  margin-bottom: var(--sp-2);
}

.login-title {
  font-size: var(--fs-title);
  font-weight: 700;
  text-align: center;
}

.login-sub {
  text-align: center;
  color: var(--c-text-light);
  font-size: var(--fs-small);
  margin-top: 4px;
}

/* ============================================================
   主页
   ============================================================ */
.home-page { padding-bottom: calc(var(--sp-6) + var(--safe-b)); }

.home-header {
  text-align: center;
  padding: var(--sp-5) 0 var(--sp-3);
}

.home-logo {
  font-size: 34px;
  margin-right: 6px;
  vertical-align: -4px;
}

.home-title {
  font-size: var(--fs-title);
  font-weight: 700;
  display: inline;
}

/* 信息卡：等级 + 进度 + 四项统计 */
.info-card {
  background: var(--c-card);
  border-radius: var(--r-card);
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  box-shadow: 0 2px 12px rgba(31, 42, 51, .07);
}

.info-level {
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.info-card .stat-value {
  /* v2 主页这里用的是 21pt 的英文数字，比全局 28px 小 */
  font-size: 22px;
}

.info-progress-text {
  text-align: center;
  font-size: var(--fs-tiny);
  color: var(--c-text-light);
  margin-top: 4px;
}

/* ---------- 学习年级（v2 同款紧凑一行）---------- */
.grade-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin: var(--sp-4) 0 var(--sp-2);
}

.grade-row-label {
  font-size: var(--fs-small);
  color: var(--c-text-light);
}

.grade-select {
  width: auto;
  min-width: 110px;
  height: 40px;
  padding: 0 34px 0 12px;
  font-size: var(--fs-small);
}

.grade-row-hint {
  font-size: var(--fs-small);
  color: var(--c-text-light);
}

/* ---------- 三档按钮区（对齐 v2 的 hero / normal / small）---------- */
.btn-tier {
  display: flex;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* 第一档：三个主按钮，天蓝，均分一行 */
.btn-tier-hero {
  margin-top: var(--sp-3);
  gap: var(--sp-3);
}

.btn-tier-hero .btn {
  flex: 1 1 0;
  min-width: 150px;
  max-width: 260px;
}

/* 第二档：五个常用按钮，浅天蓝 */
.btn-tier-normal {
  margin-top: var(--sp-3);
}

.btn-tier-normal .btn {
  flex: 0 1 auto;
  min-width: 112px;
  padding: 0 18px;
}

/* 第三档：家长模式，刻意低调 */
.btn-tier-small {
  margin-top: var(--sp-2);
}

/* 底部鼓励语 */
.home-msg {
  text-align: center;
  color: var(--c-text-light);
  font-size: var(--fs-small);
  /* v2 是 pady=(10, 0)，紧贴家长模式按钮 */
  margin-top: 10px;
}

/* ============================================================
   答题页（学习 / 复习 / 测验共用）
   ============================================================ */
.study-page {
  /* ⚠️ 不能再用 100vh：顶栏是 sticky 的，本身占 56px，
     100vh 会让整页永远多出顶栏那么高，哪怕内容装得下也会出现滚动条。
     实测：1280x900 下 scrollHeight 825 / clientHeight 769（多 56px）。 */
  min-height: calc(100vh - var(--topbar-h) - var(--safe-t));
  display: flex;
  flex-direction: column;
}

.study-progress {
  /* 与题目卡片同宽居中，否则桌面端进度文字会贴在左上角，看着像漏了样式 */
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 var(--sp-4) var(--sp-2);
  font-size: var(--fs-small);
  color: var(--c-text-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

.study-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* 内容整体垂直居中，而不是把卡片拉到满屏 */
  justify-content: center;
  align-items: stretch;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + var(--safe-b));
  overflow-y: auto;
}

/* 题目卡、作答区、确认条统一宽度，视觉上是一条竖列 */
.question-card,
.answer-area,
.confirm-bar {
  width: 100%;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.question-card {
  background: var(--c-card);
  border-radius: var(--r-card);
  padding: var(--sp-5) var(--sp-4);
  box-shadow: 0 2px 12px rgba(31, 42, 51, .07);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* 不再 flex: 1 铺满；给个舒服的高度区间 */
  flex: 0 1 auto;
  min-height: 190px;
  max-height: 46vh;
  overflow-y: auto;
}

.question-prompt {
  font-size: var(--fs-hero);
  font-weight: 700;
  text-align: center;
  line-height: 1.45;
  word-break: break-word;
  margin-bottom: var(--sp-2);
}

/* 英文单词展示（write_cn / en_to_cn 的题面） */
.question-word {
  font-family: var(--font-en);
  font-size: var(--fs-word);
  font-weight: 700;
  text-align: center;
  word-break: break-word;
}

.question-hint {
  font-size: var(--fs-small);
  color: var(--c-text-light);
  text-align: center;
  min-height: 22px;
  margin-bottom: var(--sp-3);
}

.question-phonetic {
  font-size: var(--fs-normal);
  color: var(--c-text-light);
  text-align: center;
  margin-bottom: var(--sp-2);
}

/* 字母模式提示（write_en） */
.letter-pattern {
  font-family: var(--font-en);
  font-size: var(--fs-big);
  letter-spacing: 3px;
  color: var(--c-text-light);
  text-align: center;
  margin-top: var(--sp-2);
  word-break: break-word;
}

.options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
  margin: 0 auto;
}

.options .btn { width: 100%; }

/* 键盘输入区 */
.text-answer {
  width: 100%;
  margin: 0 auto;
}

.text-answer input {
  text-align: center;
  font-size: var(--fs-big);
  font-family: var(--font-en);
  font-weight: 700;
  height: 58px;
}

.text-answer-row {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.text-answer-row .btn { flex: 1; }

/* 反馈区 */
.feedback {
  text-align: center;
  font-size: var(--fs-normal);
  font-weight: 700;
  min-height: 30px;
  margin-top: var(--sp-3);
  padding: 0 var(--sp-2);
  line-height: 1.4;
}

.feedback.is-correct { color: var(--c-green); }
.feedback.is-wrong   { color: var(--c-red); }

/* 答错后的确认按钮 */
.confirm-bar {
  padding: 0;
}
.confirm-bar .btn { width: 100%; }

/* 结算页 */
.summary-card {
  background: var(--c-card);
  border-radius: var(--r-card);
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
  box-shadow: 0 2px 12px rgba(31, 42, 51, .07);
}

.summary-big {
  font-size: 40px;
  font-weight: 700;
  color: var(--c-hero);
  line-height: 1.2;
}

.summary-breakdown {
  margin: var(--sp-4) auto 0;
  max-width: 360px;
  text-align: left;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: var(--fs-small);
  border-bottom: 1px dashed var(--c-border);
}
.summary-line:last-child { border-bottom: none; }

/* ============================================================
   单词本
   ============================================================ */
.words-page { padding-bottom: calc(var(--sp-6) + var(--safe-b)); }

.filter-bar {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

.filter-bar input { flex: 1 1 180px; min-width: 0; }
.filter-bar select { flex: 0 0 auto; width: auto; min-width: 110px; }

/* ============================================================
   家长模式
   ============================================================ */
.parent-page { padding-bottom: calc(var(--sp-6) + var(--safe-b)); }

.parent-body { padding-top: var(--sp-3); }

/* 概览的数字格子 */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

.overview-tile {
  background: var(--c-card);
  border-radius: 14px;
  padding: var(--sp-4);
  text-align: center;
}

.overview-tile .v {
  font-size: var(--fs-big);
  font-weight: 700;
  line-height: 1.2;
}
.overview-tile .k {
  font-size: var(--fs-small);
  color: var(--c-text-light);
  margin-top: 2px;
}

/* 7 日柱状图（纯 CSS，不引图表库） */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 130px;
  padding: var(--sp-2) 0 0;
  /* 底部基线，与 v2 的 canvas 画线一致 */
  border-bottom: 1px solid rgba(74, 90, 102, .35);
  margin-bottom: 2px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.chart-bar {
  width: 70%;
  max-width: 34px;
  background: var(--c-secondary);
  border-radius: 6px 6px 0 0;
  min-height: 3px;
  transition: height .3s ease;
}

.chart-bar.has-value { background: var(--c-hero); }

/* 数值为 0 的那天不画柱子（与 v2 一致：只看柱子的有无就知道哪天没学） */
.chart-bar.is-zero { background: transparent; }

.chart-label {
  font-size: 10px;
  color: var(--c-text-light);
  margin-top: 4px;
  white-space: nowrap;
}

/* 两个图并排（家长概览 / 统计页）—— 与 v2 统计页一致 */
.chart-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.chart-pane { min-width: 0; padding: 0 var(--sp-4); }

/* 两图之间加分隔线，避免标题连在一起看不清 */
.chart-pane + .chart-pane {
  border-left: 1px solid rgba(140, 194, 224, .5);
}

/* v2 的标题是在图正上方居中的 */
.chart-pane-title {
  text-align: center;
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.chart-pane-title .sub {
  display: block;
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--c-text-light);
  margin-top: 2px;
}

/* 柱子上方的数值标注 */
.chart-bar.has-label {
  position: relative;
}

.chart-bar-value {
  font-size: 10px;
  color: var(--c-text-light);
  margin-bottom: 2px;
  white-space: nowrap;
}

/* 图下方的日期标签行（正确率图用） */
.chart-labels-row {
  display: flex;
  gap: 6px;
  padding: 0 0 var(--sp-1);
}
.chart-labels-row span {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--c-text-light);
  min-width: 0;
  overflow: hidden;
}

/* 词表卡片 */
.wordbook-card {
  background: var(--c-card);
  border-radius: 14px;
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}

.wb-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.wb-name { font-weight: 700; flex: 1; word-break: break-word; }

.wb-meta {
  font-size: var(--fs-small);
  color: var(--c-text-light);
  margin-bottom: var(--sp-2);
}

.wb-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* 设置项行 */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid rgba(140, 194, 224, .35);
}
.setting-row:last-child { border-bottom: none; }

.setting-row .label { font-weight: 700; }
.setting-row .desc  { font-size: var(--fs-small); color: var(--c-text-light); }
.setting-row .ctl   { flex: 0 0 auto; display: flex; align-items: center; gap: var(--sp-2); }

.setting-row .ctl input[type="number"] { width: 90px; }
.setting-row .ctl select { width: auto; min-width: 110px; }

/* 开关 */
.switch {
  position: relative;
  width: 54px; height: 30px;
  background: var(--c-disabled);
  border-radius: var(--r-pill);
  border: none;
  cursor: pointer;
  transition: background .18s;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.is-on { background: var(--c-hero); }
.switch.is-on::after { transform: translateX(24px); }

/* 危险区 */
.danger-zone {
  border: 2px solid var(--c-danger);
  border-radius: 14px;
  padding: var(--sp-4);
  background: #FFF8F7;
}

/* ============================================================
   响应式
   ============================================================ */

/* 手机竖屏：单列 */
@media (max-width: 599px) {
  /* 主按钮一列排开，拇指更好点 */
  .btn-tier-hero { flex-direction: column; }
  /* ⚠️ 必须重置 flex-basis：
     基础规则里是 flex: 1 1 0，在 row 方向下 0 指宽度（靠 flex-grow 撑满）；
     但改成 column 后 0 变成了「高度基准」，会把原本 66px 的按钮压成 30px。
     这里改成 0 0 auto，让 height: var(--btn-hero-h) 生效。 */
  .btn-tier-hero .btn { flex: 0 0 auto; max-width: none; width: 100%; }
  /* 常用按钮两列 */
  .btn-tier-normal .btn { flex: 1 1 calc(50% - var(--sp-2)); min-width: 0; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
  .question-prompt { font-size: 26px; }
  .question-word { font-size: 30px; }
  /* 触屏上选项用 hero 高度，手指更容易点中 */
  .btn-option { height: var(--btn-hero-h); font-size: var(--fs-normal); }
  .wrap { padding: 0 var(--sp-3); }
  /* 窄屏卡片内边距收一档，避免内容被挤得太窄 */
  .card { padding: var(--sp-4); }
  .question-card { padding: var(--sp-4) var(--sp-3); min-height: 170px; }
  .login-card { padding: var(--sp-5) var(--sp-4); }
  .modal { padding: var(--sp-4); }
}

/* 图在窄屏上改为上下堆叠 */
@media (max-width: 899px) {
  .chart-pair { grid-template-columns: 1fr; gap: var(--sp-4); }

  /* 上下堆叠后左右分隔线没意义了，改成上边框 + 上下留白，
     否则两张图的标题会连在一起分不清 */
  .chart-pane { padding: 0; }
  .chart-pane + .chart-pane {
    border-left: none;
    border-top: 1px solid rgba(140, 194, 224, .5);
    padding-top: var(--sp-4);
  }
}

/* 手机上词条右侧的「编辑 / 更多」把正文挤成省略号了，
   改为正文占满一行、按钮换到第二行 */
@media (max-width: 599px) {
  .words-page .list-item { flex-wrap: wrap; row-gap: 8px; }
  .words-page .list-item .li-main { flex: 1 1 100%; }
  .words-page .word-actions {
    width: 100%;
    flex-direction: row;
    justify-content: flex-end;   /* 徽标和按钮一起靠右，别分居两端 */
    align-items: center;
    gap: 8px;
  }
}

/* 平板竖屏 */
@media (min-width: 600px) and (max-width: 1023px) {
  .overview-grid { grid-template-columns: repeat(3, 1fr); }
  .btn-tier-hero .btn { min-width: 130px; }
  .btn-tier-normal .btn { min-width: 100px; }
}

/* 桌面 / 平板横屏 */
@media (min-width: 1024px) {
  .overview-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 横屏且高度小（手机横屏、iPad 横屏答题）→ 左右分栏 */
@media (orientation: landscape) and (max-height: 560px) {
  /* 手机横屏时改为左右分栏：题面在左，作答在右 */
  .study-body {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: var(--sp-3);
  }
  .question-card {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    max-height: none;
    min-height: 0;
  }
  .answer-area {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .confirm-bar { max-width: none; flex: 0 0 100%; }
  .question-prompt { font-size: 24px; }
  .question-word { font-size: 28px; }
  .topbar { height: 46px; }
}

/* ============================================================
   打印（家长可能想打词表）
   ============================================================ */
@media print {
  body { background: #fff; }
  .topbar, .tabs, .btn, .filter-bar, .home-actions { display: none !important; }
  .card, .list-item, .wordbook-card { box-shadow: none; border: 1px solid #ddd; }
}
