/* ==========================================================================
   教学资源栏目 · /resource/
   与 site.css 共用变量。原则：正文优先可读 —— 大纲和教案是给人长时间读的，
   行宽控制在 34em 左右，行高 1.9，不用灰底卡片切碎内容。
   ========================================================================== */

/* ---------------------------------------------------------------- 列表页 */
.res-hero {
  padding: 8px 0 4px;
}

.res-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3.6vw, 34px);
  letter-spacing: -.01em;
}

.res-hero .hero-sub {
  margin: 0 0 0;
  color: var(--c-text-2);
  max-width: 42em;
}

/* 统计条沿用首页 .hero-stats 的居中卡片样式（site.css 里已定义），
   这里不再覆盖布局，只保留外边距 —— 两页的视觉语言要一致，
   用户在首页见过的样子在资源页应该还是那个样子。 */
.res-hero .hero-stats { margin-bottom: 28px; }

/* ---- 课程卡片 ---- */
.rsc-grid {
  display: grid;
  gap: 18px;
  margin: 0 0 36px;
  padding: 0;
  list-style: none;
}

.rsc {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.rsc:hover { border-color: #c3cdf5; box-shadow: var(--shadow-2); }

.rsc-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
}

.rsc-cover {
  width: 72px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-1);
  background: var(--c-bg);
}

.rsc-cover img { width: 72px; height: 101px; object-fit: cover; }

.rsc-cover-empty {
  display: grid;
  place-items: center;
  width: 72px; height: 101px;
  color: var(--c-text-3);
  font-size: 22px;
  border: 1px dashed var(--c-border-strong);
  box-shadow: none;
}

.rsc-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.rsc-name {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--c-text);
}

.rsc:hover .rsc-name { color: var(--c-primary); }

.rsc-author { font-size: 13px; color: var(--c-text-2); }

.rsc-res {
  font-size: 12px;
  color: var(--c-primary);
  background: var(--c-primary-soft);
  border-radius: 999px;
  padding: 2px 10px;
  align-self: flex-start;
}

.rsc-go {
  margin-left: auto;
  color: var(--c-text-3);
  font-size: 18px;
  transition: transform var(--t-fast), color var(--t-fast);
}

.rsc:hover .rsc-go { transform: translateX(3px); color: var(--c-primary); }

.rsc-items {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--c-border);
  background: var(--c-border);
}

.rsc-items li { background: var(--c-surface); }

.rsc-items a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 14px;
  color: var(--c-text-2);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}

.rsc-items a:hover { background: var(--c-primary-soft); color: var(--c-primary-dark); }

.rsi-kind {
  flex-shrink: 0;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: #eef2ff;
  color: #3730a3;
}

.rsi-kind-les { background: #ecfdf5; color: #065f46; }
.rsi-kind-intro { background: #f1f5f9; color: #475569; }

.res-help {
  margin: 0 0 40px;
  padding: 22px 24px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}

.res-help h2 { margin: 0 0 8px; font-size: 18px; }
.res-help p { margin: 0 0 14px; color: var(--c-text-2); max-width: 46em; }
.res-help-act { margin: 0; }

/* ---------------------------------------------------------------- 课程页 */
.res-title { padding: 6px 0 2px; }

.res-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-primary);
  font-weight: 600;
}

.res-title h1 {
  margin: 0 0 10px;
  font-size: clamp(23px, 3.4vw, 32px);
  letter-spacing: -.01em;
}

.res-lead {
  margin: 0 0 24px;
  color: var(--c-text-2);
  max-width: 44em;
}

/* ---- 顶部教材卡 ---- */
.rs-book {
  margin: 0 0 30px;
  padding: 20px 22px 18px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.rs-book-tag {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--c-text-3);
}

.rs-book-inner { display: flex; gap: 18px; align-items: flex-start; }

.rsb-cover { flex-shrink: 0; box-shadow: var(--shadow-2); border-radius: 6px; overflow: hidden; }
.rsb-cover img { width: 120px; height: 169px; object-fit: cover; }

.rs-book-main { min-width: 0; }

.rs-book-title { margin: 0 0 4px; font-size: 19px; line-height: 1.4; }
.rs-book-title a { color: var(--c-text); text-decoration: none; }
.rs-book-title a:hover { color: var(--c-primary); }

.rs-book-sub { margin: 0 0 10px; font-size: 13px; color: var(--c-text-3); }

.rs-book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--c-text-2);
}

.rs-book-meta span { color: var(--c-text-3); margin-right: 5px; }

.rs-book-acts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }

/* .apply-btn 在学科页卡片里是 width:100%（撑满卡片宽度），
   搬到教材卡这一行里会把同行按钮挤到下一行。这里收回宽度。
   同时把它的绿色小按钮外观拉齐到 .btn 的尺寸 —— 教材卡上的三个
   按钮是同级主行动，不该一个像正文按钮一个像角标。 */
.rsb-btn {
  width: auto;
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
}

.rsb-btn.apply-btn {
  border-color: var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text-2);
}

.rsb-btn.apply-btn:hover {
  border-color: var(--c-text-3);
  background: var(--c-surface);
  color: var(--c-text);
}

.rs-book-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--c-text-3);
  line-height: 1.6;
}

/* ---- 双栏：左目录 右正文 ---- */
.res-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.res-side {
  position: sticky;
  top: calc(var(--head-h) + 14px);
  max-height: calc(100vh - var(--head-h) - 40px);
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 13px;
}

.res-side-h {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--c-text-3);
}

.res-nav { margin: 0; padding: 0; list-style: none; }

.res-nav-g {
  margin: 14px 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c-text-3);
  letter-spacing: .06em;
}

.res-nav-g:first-child { margin-top: 0; }

.res-nav a {
  display: block;
  padding: 5px 8px;
  margin: 0 -8px;
  border-radius: 6px;
  color: var(--c-text-2);
  text-decoration: none;
  line-height: 1.45;
}

.res-nav a:hover { background: var(--c-primary-soft); color: var(--c-primary-dark); }

/* ---- 正文 ---- */
.res-body { min-width: 0; }

.rs-doc {
  margin: 0 0 34px;
  padding: 26px 28px 8px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.rs-doc-lesson { border-left: 3px solid #a7f3d0; }
.rs-doc-intro { background: #fbfcfe; }

.rs-h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--c-border);
  font-size: 21px;
  line-height: 1.35;
}

.rs-h2-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #ecfdf5;
  color: #065f46;
  letter-spacing: .04em;
}

/* 元信息表 */
.rs-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1px;
  margin: 0 0 22px;
  background: var(--c-border);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.rs-meta-row {
  display: flex;
  gap: 10px;
  padding: 9px 13px;
  background: #fcfcfd;
  font-size: 13.5px;
  line-height: 1.6;
}

.rs-meta-row dt {
  flex-shrink: 0;
  width: 5em;
  color: var(--c-text-3);
}

.rs-meta-row dd { margin: 0; color: var(--c-text); min-width: 0; }

/* 教案基本信息：纵向清单，每行「键 —— 值」。
   不用 auto-fit 网格 —— 「教材来源」这类值很长，被压进 1/3 列会变成
   一条细高的文字柱，读起来是断的。 */
.rs-info {
  margin: 0 0 22px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.rs-li-row {
  display: flex;
  gap: 14px;
  padding: 9px 14px;
  background: #fcfcfd;
  font-size: 13.5px;
  line-height: 1.7;
}

.rs-li-row + .rs-li-row { border-top: 1px solid var(--c-border); }

.rs-li-row dt {
  flex-shrink: 0;
  width: 7em;
  color: var(--c-text-3);
}

.rs-li-row dd { margin: 0; color: var(--c-text); min-width: 0; }

/* 一级小节 */
.rs-sec { margin: 0 0 24px; }

.rs-sec:last-child { margin-bottom: 12px; }

.rs-h3 {
  display: flex;
  gap: 2px;
  margin: 0 0 12px;
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--c-text);
}

.rs-sec-no { color: var(--c-primary); font-weight: 700; flex-shrink: 0; }

.rs-h4 {
  display: flex;
  gap: 6px;
  margin: 16px 0 8px;
  font-size: 14.5px;
  color: var(--c-text);
}

.rs-no { color: var(--c-text-3); flex-shrink: 0; }

/* 正文段落：行宽限制在 36em，长文不横跨整屏 */
.rs-sec > p,
.rs-list,
.rs-pre {
  max-width: 38em;
}

.rs-sec > p {
  margin: 0 0 10px;
  color: var(--c-text-2);
  line-height: 1.9;
  /* 不做 text-align: justify。中文两端对齐遇到「Python 与第三方库」
     这类中英混排时，会在词间塞进大段空白，出现像"段落断了"的空隙。
     左对齐、允许右侧参差，读起来反而稳。 */
  text-align: left;
}

.rs-list {
  margin: 0 0 12px;
  padding-left: 1.5em;
  color: var(--c-text-2);
  line-height: 1.85;
  /* site.css 全局把 ul 的 list-style 清零了，这里必须显式恢复 ——
     大纲说明里的「1. 以学习全部内容为目标」原文是有序列表，
     序号是内容的一部分（不同教学目标的第 1/2/3 种），丢了就读不通。 */
  list-style: decimal;
}

.rs-list li { margin: 0 0 6px; }

/* 键值行（课程名称：… / 思政主线：…） */
.rs-kv { display: flex; gap: 10px; }

.rs-k {
  flex-shrink: 0;
  color: var(--c-text-3);
  min-width: 5em;
}

.rs-v { color: var(--c-text); }

.rs-dot {
  position: relative;
  padding-left: 1.1em;
}

.rs-dot::before {
  content: "·";
  position: absolute;
  left: .25em;
  color: var(--c-text-3);
  font-weight: 700;
}

/* 章节行：（一）绪论 …… 1学时 */
.rs-chap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 20px 0 8px;
  padding: 7px 0 7px 12px;
  border-left: 2px solid var(--c-primary-soft);
  font-size: 15.5px;
  color: var(--c-text);
}

.rs-chap:first-of-type { margin-top: 6px; }

.rs-chap-no { color: var(--c-primary); font-weight: 700; flex-shrink: 0; }
.rs-chap-t { flex: 1; min-width: 0; font-weight: 600; }

.rs-hours {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
}

/* 【内容】【重点】【难点】 */
.rs-field {
  display: flex;
  gap: 8px;
  margin: 0 0 7px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--c-text-2);
}

.rs-field-k {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1.9;
  color: var(--c-text-3);
  min-width: 3.2em;
}

.rs-field-重点 .rs-field-k { color: #b45309; }
.rs-field-难点 .rs-field-k { color: #b91c1c; }

.rs-field-v { min-width: 0; }

/* 表格 */
.rs-table-wrap {
  margin: 6px 0 18px;
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  -webkit-overflow-scrolling: touch;
}

.rs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.7;
  min-width: 620px;
}

.rs-table th,
.rs-table td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--c-border);
}

.rs-table th {
  background: #f4f6fa;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  /* 不做 position: sticky。表格外层是 overflow-x:auto 的容器，
     sticky 会以容器为参照，表头始终贴在容器顶部 —— 而容器本身会随页面
     滚动，结果表头飘在页头下方盖住内容行。滚动查看表头在这里不重要，
     6 列名字一眼能记住。 */
}

.rs-table tbody tr:last-child td { border-bottom: 0; }
.rs-table tbody tr:nth-child(even) td { background: #fcfcfd; }
.rs-table td:first-child { font-weight: 600; color: var(--c-text); white-space: nowrap; }

/* 第 2 列是「时长」，内容是「8分钟」「26分钟」这类短词。
   默认列宽会把它压到只能放两个字，变成「8分/钟」两行 ——
   时长是一眼要扫的信息，必须横排。 */
.rs-table td:nth-child(2),
.rs-table th:nth-child(2) { white-space: nowrap; }

/* 6 列的教案表里，末尾「课件页」也是短词，同理 */
.rs-table-wrap[data-cols="6"] td:last-child,
.rs-table-wrap[data-cols="6"] th:last-child { white-space: nowrap; }

/* 板书设计：原文靠空格与空行排版，必须原样保留。
   用等宽字体 + 浅底块，不做虚线框（虚线会被误认成"待填内容"）。
   注意 font-variant-east-asian: 让中文也按等宽渲染，否则中英混排时
   「有标签　　　　　无标签」这类靠全角空格对齐的行会歪。 */
.rs-pre {
  margin: 0 0 16px;
  padding: 16px 18px;
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas,
               "Cascadia Mono", "Microsoft YaHei Mono", monospace;
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--c-text-2);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-width: 100%;
  tab-size: 4;
  font-variant-east-asian: full-width;
}

/* 板书按行拆分后，每行是 display:block 的 span（pre 里不加块元素，
   保持文本节点的空格语义）；结构行加粗，空行撑出原稿的段落间距。 */
.rs-pre .bl {
  display: block;
  min-height: 1lh;
}

.rs-pre .bl-h {
  font-weight: 700;
  color: var(--c-text);
  margin-top: .35em;
}

.rs-pre .bl-hour {
  font-weight: 700;
  color: var(--c-primary);
  letter-spacing: .02em;
}

.rs-pre .bl-sep {
  color: var(--c-border-strong);
  overflow: hidden;
  white-space: nowrap;
}

.rs-pre .bl-gap { min-height: .55em; }

/* 空节说明 */
.rs-sec-empty .rs-empty {
  margin: 0 0 10px;
  padding: 10px 13px;
  background: var(--c-warn-bg);
  border: 1px solid var(--c-warn-border);
  border-radius: var(--r-sm);
  color: var(--c-warn-text);
  font-size: 13.5px;
  line-height: 1.7;
  max-width: 40em;
}

/* 页尾 CTA */
.res-cta {
  margin: 10px 0 44px;
  padding: 24px 26px;
  background: linear-gradient(135deg, #f8faff, #eef3ff);
  border: 1px solid #dbe4fb;
  border-radius: var(--r-md);
}

.res-cta h2 { margin: 0 0 8px; font-size: 18px; }
.res-cta p { margin: 0 0 14px; color: var(--c-text-2); max-width: 46em; }
.res-cta-act { margin: 0; }

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 900px) {
  .res-layout { grid-template-columns: 1fr; gap: 20px; }
  .res-side {
    position: static;
    max-height: none;
    order: -1;
  }
  .res-nav { columns: 2; column-gap: 18px; }
  .res-nav-g { break-after: avoid; }
}

@media (max-width: 620px) {
  .rs-doc { padding: 20px 16px 6px; }
  .rs-book { padding: 16px 16px 14px; }
  .rs-book-inner { gap: 12px; }
  .rsb-cover img { width: 84px; height: 118px; }
  .rsb-cover img { }
  .rs-book-title { font-size: 16.5px; }
  .rs-book-meta { gap: 4px 14px; font-size: 12.5px; }
  .rs-book-acts { gap: 8px; }
  .rsb-btn { font-size: 13px; padding: 8px 12px; }
  .res-hero .hero-stats { gap: 20px; }
  .res-nav { columns: 1; }
  .rs-h2 { font-size: 18px; }
  .rs-h3 { font-size: 15.5px; }
  .rsc-head { padding: 14px 16px; gap: 12px; }
  .rsc-items a { padding: 9px 16px; }
  .rs-field { flex-direction: column; gap: 1px; }
  .rs-field-k { min-width: 0; }
  .rs-kv { flex-direction: column; gap: 0; }
  .rs-k { min-width: 0; }
  .rs-pre { font-size: 12px; padding: 12px; }
  .res-cta { padding: 20px 18px; }
}

/* 打印：教案常常要打出来带去上课。
   去掉导航、侧栏、教材卡与 CTA，正文占满，字号放大到可读。 */
@media print {
  .site-header,
  .breadcrumb,
  .page-back,
  .res-side,
  .rs-book,
  .res-cta,
  .site-footer,
  .skip-link,
  .fab-wrap,
  #apply-fab {
    display: none !important;
  }

  .res-layout { display: block; }
  .rs-doc {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0 0 24px;
    break-inside: auto;
  }
  .rs-h2 { break-after: avoid; font-size: 15pt; }
  .rs-h3 { break-after: avoid; font-size: 12.5pt; }
  .rs-chap { break-after: avoid; }
  .rs-sec { break-inside: auto; }
  .rs-table-wrap { overflow: visible; }
  .rs-table { min-width: 0; font-size: 8.5pt; }
  .rs-table th { position: static; }
  .rs-pre { background: none; border: 0; padding: 0; }
  body { background: #fff; }
}