/* ============================================================
   中文拼音学习站 - 样式（原创主题：中国红 × 米白纸感）
   ============================================================ */
:root {
  --red: #c8102e;
  --red-dark: #9e0c24;
  --gold: #d9a441;
  --ink: #32302d;
  --muted: #8a8378;
  --paper: #faf6ef;
  --card: #ffffff;
  --line: #eadfce;
  --green: #2e8b57;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(50, 48, 45, 0.08);
}

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

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 2px solid var(--red);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-name small { display: block; font-weight: 400; color: var(--muted); font-size: 0.72rem; }

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.main-nav a {
  text-decoration: none;
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.main-nav a:hover { background: #f3e9d8; }
.main-nav a.on { background: var(--red); color: #fff; font-weight: 500; }

.progress-chip {
  background: #fdf1dc;
  border: 1px solid var(--gold);
  color: #7a5a14;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.progress-chip strong { color: var(--red); font-size: 1rem; }

/* ---------- 主体 ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }

.hero {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 24px;
  margin-bottom: 26px;
}
.hero h1 { font-size: 1.5rem; letter-spacing: 1px; }
.hero p { opacity: 0.92; font-size: 0.95rem; margin-top: 4px; }

.section { margin-bottom: 34px; }
.section-title {
  font-size: 1.2rem;
  padding-left: 12px;
  border-left: 5px solid var(--red);
  margin-bottom: 6px;
}
.section-sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 14px; }

/* ---------- 拼音卡片 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}
.group-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 6px;
  letter-spacing: 1px;
}
.py-card {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 6px 10px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
}
.py-card:hover { transform: translateY(-2px); border-color: var(--red); box-shadow: var(--shadow); }
.py-card:active { transform: scale(0.96); }
.py-card .py-text { display: block; font-size: 1.45rem; font-weight: 600; color: var(--red-dark); line-height: 1.3; }
.py-card .py-zh { display: block; font-size: 0.8rem; color: var(--muted); }
.py-card.active { border-color: var(--gold); background: #fffaf0; }
.py-card.learned::after {
  content: "✓";
  position: absolute;
  top: 5px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}
.py-card.learned .py-text { color: var(--green); }

/* ---------- 读声调 ---------- */
.tone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
}
.tone-row {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.tone-row-head { margin-bottom: 8px; }
.tone-row-head .py-text { font-size: 1.3rem; font-weight: 600; color: var(--red-dark); }
.tone-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tone-cell {
  font-family: inherit;
  font-size: 1.25rem;
  padding: 9px 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
  position: relative;
}
.tone-cell:hover { border-color: var(--red); transform: translateY(-1px); }
.tone-cell:active { transform: scale(0.94); }
.tone-cell.active { background: #fff3d6; border-color: var(--gold); }
.tone-cell.learned { border-color: var(--green); background: #f0f9f3; }
.tone-cell.learned::after {
  content: "✓";
  position: absolute;
  top: 2px;
  right: 5px;
  font-size: 10px;
  color: var(--green);
}

/* ---------- 音节表（矩阵表格：行=韵母，列=声母） ---------- */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chart-toolbar label { font-size: 0.92rem; font-weight: 600; color: var(--ink); }
.chart-select {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 7px 14px;
  border: 1.5px solid var(--gold);
  border-radius: 999px;
  background: #fdf1dc;
  color: #7a5a14;
  cursor: pointer;
}
.chart-select:hover { border-color: var(--red); }
.chart-hint { color: var(--muted); font-size: 0.85rem; }
/* 打印 / PDF 按钮 */
.chart-btn {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--gold);
  background: #fdf1dc;
  color: #7a5a14;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chart-btn:hover { border-color: var(--red); color: var(--red-dark); }
.chart-btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.chart-btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.chart-btn:disabled { opacity: 0.6; cursor: wait; }

/* 打印/PDF 专用标题（屏幕上隐藏） */
.print-head { display: none; }

/* ---------- 关于作者页：故事 + 学习路径 ---------- */
.story-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-left: 5px solid var(--red);
  border-radius: var(--radius);
  padding: 28px 30px;
  box-shadow: var(--shadow);
}
.story-card p { margin-bottom: 14px; font-size: 1.02rem; line-height: 1.9; }
.story-card p:last-child { margin-bottom: 0; }
.story-lead {
  font-size: 1.15rem !important;
  font-weight: 700;
  color: var(--red-dark);
}
.story-card strong { color: var(--red-dark); }
.story-sign {
  text-align: right;
  font-weight: 600;
  color: var(--muted);
  margin-top: 18px !important;
}

/* 学习路径时间线 */
.path-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  counter-reset: step;
}
.path-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.path-item:hover { transform: translateX(4px); border-color: var(--gold); box-shadow: var(--shadow); }
.path-num {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.path-item:nth-child(even) .path-num { background: var(--gold); }
.path-body h3 { font-size: 1.02rem; color: var(--red-dark); margin-bottom: 3px; }
.path-body p { font-size: 0.9rem; color: var(--muted); line-height: 1.7; }

/* CTA 行动区 */
.cta-box {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 32px 26px;
  text-align: center;
}
.cta-box h2 { font-size: 1.35rem; margin-bottom: 6px; }
.cta-box p { opacity: 0.92; margin-bottom: 20px; }
.cta-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.cta-btns .btn { text-decoration: none; display: inline-block; }
.cta-btns .btn-play {
  width: auto;
  background: #fff;
  color: var(--red-dark);
  border: none;
  padding: 11px 26px;
  margin: 0;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.cta-btns .btn-play:hover { transform: translateY(-2px); background: #fff; }
.cta-btns .btn-restart {
  width: auto;
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.75);
  padding: 9px 24px;
  margin: 0;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
}
.cta-btns .btn-restart:hover { background: rgba(255, 255, 255, 0.15); }

@media (max-width: 640px) {
  .story-card { padding: 20px 18px; }
  .story-card p { font-size: 0.95rem; }
  .path-item { padding: 13px 14px; gap: 12px; }
  .path-num { flex-basis: 32px; width: 32px; height: 32px; font-size: 0.98rem; }
}

/* ---------- FAQ（静态可抓取内容） ---------- */
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0 18px;
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
  color: var(--red-dark);
  font-size: 1rem;
  list-style: none;
  position: relative;
  padding-right: 28px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--gold);
  font-weight: 400;
}
.faq-item[open] summary::after { content: "−"; }
.faq-item[open] summary { border-bottom: 1px solid var(--line); }
.faq-item p {
  padding: 12px 0 16px;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.85;
  margin: 0;
}

/* 无 JS / 爬虫可见的静态音节表格 */
.pinyin-table td.pt-val:not(:has(.pt-cell-btn)) {
  padding: 8px 2px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--ink);
}

.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.pinyin-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 940px;
  font-size: 0.95rem;
}
.pinyin-table th,
.pinyin-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  padding: 0;
  white-space: nowrap;
}
/* 表头声母行（纵向滚动时吸顶） */
.pinyin-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--red);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom: 2px solid var(--red-dark);
}
.pt-corner {
  position: sticky;
  left: 0;
  z-index: 6;
  min-width: 120px;
  background: var(--red-dark);
  font-size: 0.72rem;
  line-height: 1.35;
  font-weight: 500;
}
/* 行首韵母列（横向滚动时吸左，可点击听发音） */
.pt-final {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 58px;
  background: #fdf1dc;
  color: var(--red-dark);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 8px 6px;
  cursor: pointer;
  border-right: 2px solid var(--gold);
  transition: background 0.12s, color 0.12s;
}
.pt-final:hover { background: var(--gold); color: #fff; }
.pt-final.active { background: var(--red); color: #fff; }
/* 分组标题行 */
.pt-group {
  background: #f7ecd9;
  color: #7a5a14;
  font-weight: 600;
  text-align: left;
  padding: 7px 14px;
  font-size: 0.88rem;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--gold);
}
/* 音节单元格 */
.pt-val { background: #fff; }
.pt-cell-btn {
  width: 100%;
  min-height: 40px;
  font-family: inherit;
  font-size: 0.98rem;
  color: var(--ink);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 9px 2px;
  transition: background 0.1s, color 0.1s, transform 0.1s;
}
.pt-cell-btn:hover { background: var(--red); color: #fff; font-weight: 600; }
.pt-cell-btn:active { transform: scale(0.92); }
.pt-cell-btn.active { background: var(--gold); color: #fff; }
/* 不存在的拼合：空格 */
.pt-empty {
  background: #faf7f1;
  color: #e0d6c4;
  font-size: 0.85rem;
}
.pt-empty::before { content: "·"; }

/* 音节表页：放宽整页容器并紧凑表格，桌面端 24 列无需横向滚动 */
body[data-page="yinjiebiao"] .header-inner,
body[data-page="yinjiebiao"] main,
body[data-page="yinjiebiao"] .footer-inner { max-width: 1480px; }
body[data-page="yinjiebiao"] main { padding-left: 20px; padding-right: 20px; }
body[data-page="yinjiebiao"] .pinyin-table {
  min-width: 0;            /* 取消 940px 最小宽，让表格随容器铺满 */
  width: 100%;
  font-size: 0.86rem;
}
body[data-page="yinjiebiao"] .pinyin-table thead th { font-size: 0.92rem; padding: 9px 2px; }
body[data-page="yinjiebiao"] .pt-corner { min-width: 84px; }
body[data-page="yinjiebiao"] .pt-final { min-width: 50px; font-size: 0.96rem; padding: 7px 3px; }
body[data-page="yinjiebiao"] .pt-cell-btn {
  font-size: 0.88rem;
  padding: 8px 1px;
  min-height: 38px;
}
body[data-page="yinjiebiao"] .pt-group { padding: 6px 12px; font-size: 0.84rem; }
/* 屏幕偏窄（平板横屏/小笔记本）时再略压缩，尽量不出现横向滚动 */
@media (max-width: 1366px) {
  body[data-page="yinjiebiao"] .header-inner,
  body[data-page="yinjiebiao"] main,
  body[data-page="yinjiebiao"] .footer-inner { max-width: 100%; }
  body[data-page="yinjiebiao"] .pinyin-table { font-size: 0.8rem; }
  body[data-page="yinjiebiao"] .pt-cell-btn { font-size: 0.82rem; padding: 7px 0; min-height: 34px; }
  body[data-page="yinjiebiao"] .pt-final { font-size: 0.9rem; min-width: 44px; }
  body[data-page="yinjiebiao"] .pinyin-table thead th { font-size: 0.85rem; }
}

/* ---------- 下载 PDF：离屏导出容器（html2canvas 截图用） ---------- */
.pdf-export {
  position: absolute;
  left: -20000px;
  top: 0;
  width: 1400px;
  padding: 28px 24px;
  background: #fff;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}
.pdf-export h2 { text-align: center; font-size: 26px; margin-bottom: 4px; color: var(--red-dark); }
.pdf-export p { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.pdf-export .pinyin-table {
  width: 100% !important;
  min-width: 0 !important;
  font-size: 13px;
  box-shadow: none;
}
.pdf-export .pinyin-table thead th,
.pdf-export .pt-corner,
.pdf-export .pt-final { position: static !important; }
.pdf-export .pinyin-table thead th { padding: 8px 2px; font-size: 14px; }
.pdf-export .pt-final { min-width: 44px; font-size: 14px; padding: 7px 2px; }
.pdf-export .pt-cell-btn {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
  padding: 7px 1px;
  min-height: 0;
}
.pdf-export .pt-group { font-size: 12px; padding: 6px 10px; }

/* ---------- 打印：A4 横向，仅输出标题 + 表格 ---------- */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; }
  .site-header, .hero, .chart-toolbar, .site-footer, .section-title, .section-sub { display: none !important; }
  body[data-page="yinjiebiao"] main { max-width: none !important; padding: 0 !important; }
  .section { margin-bottom: 0; }
  .print-head { display: block; text-align: center; margin-bottom: 8px; }
  .print-head h1 { font-size: 20px; color: #000; }
  .print-head p { font-size: 12px; color: #333; margin-top: 2px; }
  .chart-scroll { overflow: visible !important; border: none !important; box-shadow: none !important; border-radius: 0; }
  body[data-page="yinjiebiao"] .pinyin-table { min-width: 0 !important; width: 100% !important; font-size: 8px !important; }
  .pinyin-table thead th, .pt-corner, .pt-final { position: static !important; }
  .pinyin-table thead th {
    padding: 4px 1px !important;
    font-size: 9px !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .pt-corner { min-width: 60px !important; font-size: 7px !important; }
  .pt-final {
    min-width: 32px !important;
    font-size: 9px !important;
    padding: 3px 1px !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .pt-group {
    padding: 3px 6px !important;
    font-size: 8px !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .pt-cell-btn {
    border: none;
    background: transparent;
    color: #000;
    font-size: 8px !important;
    font-weight: 400;
    padding: 3px 0 !important;
    min-height: 0 !important;
  }
  .pt-cell-btn:hover { background: transparent; color: #000; }
  .pt-empty::before { color: #999; }
}

/* ---------- 测验 ---------- */
.quiz-wrap { max-width: 560px; margin: 0 auto; }
.quiz-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.btn {
  font-family: inherit;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-play {
  width: 100%;
  background: var(--red);
  color: #fff;
  font-size: 1.15rem;
  padding: 16px;
  margin-bottom: 16px;
}
.btn-restart { background: var(--red); color: #fff; padding: 10px 22px; font-size: 1rem; margin-top: 10px; }
.quiz-hint { text-align: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 14px; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quiz-opt {
  font-family: inherit;
  font-size: 1.3rem;
  padding: 18px 8px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.quiz-opt:hover { border-color: var(--gold); }
.quiz-opt.right { border-color: var(--green); background: #f0f9f3; color: var(--green); font-weight: 600; }
.quiz-opt.wrong { border-color: var(--red); background: #fdeeee; color: var(--red); }
.quiz-result { text-align: center; padding: 30px 0; }
.quiz-score { font-size: 2.4rem; font-weight: 700; color: var(--red-dark); }

/* ---------- 信息小节 ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.info-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.info-card h3 { color: var(--red-dark); font-size: 1.02rem; margin-bottom: 8px; }
.info-card ul { padding-left: 18px; font-size: 0.92rem; }
.info-card li { margin-bottom: 6px; }
.info-card p { font-size: 0.92rem; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  margin-top: 30px;
}
.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}
.btn-reset {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}
.btn-reset:hover { border-color: var(--red); color: var(--red); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .tone-grid { grid-template-columns: 1fr 1fr; }
  body[data-page="yinjiebiao"] .pinyin-table { min-width: 720px; font-size: 0.78rem; }
  body[data-page="yinjiebiao"] .pt-cell-btn { min-height: 32px; padding: 6px 0; font-size: 0.8rem; }
  body[data-page="yinjiebiao"] .pt-final { min-width: 42px; font-size: 0.88rem; }
  body[data-page="yinjiebiao"] .pt-corner { min-width: 76px; font-size: 0.66rem; }
  .main-nav { width: 100%; margin-left: 0; }
  .hero h1 { font-size: 1.25rem; }
}
