/* 云学资料库 · 展示端样式
   色值只允许出现在下面这段令牌块里，其余一律 var(--*)。与小程序主色同源（#9e211e）。 */

:root {
  --brand: #9e211e;
  --brand-dark: #771d1c;
  --brand-soft: rgba(158, 33, 30, 0.08);
  --brand-line: rgba(158, 33, 30, 0.22);

  --ink-1: #241413;
  --ink-2: #5b4a48;
  --ink-3: #8d7d7a;
  --ink-4: #b3a6a3;

  --bg-page: #fbf9f7;
  --bg-card: #ffffff;
  --bg-soft: #f5f1ed;
  --line: rgba(60, 30, 28, 0.10);
  --line-strong: rgba(60, 30, 28, 0.18);

  --ok: #2f7a4f;
  --warn: #b4642f;

  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 18px;
  --shadow-s: 0 1px 2px rgba(60, 30, 28, 0.06);
  --shadow-m: 0 6px 24px rgba(60, 30, 28, 0.08);
  --wrap: 1180px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* 必须放在所有布局规则之前：.btn 的 display:inline-flex 会盖掉 hidden 的默认 display:none，
   导致「已登录」和「扫码登录」同时出现这类问题。用 !important 一次性兜住。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--ink-1);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  /* 让页脚始终贴底：内容不足一屏时也不会浮在页面中间 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main#app { flex: 1 0 auto; }

img { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 28px;
}

.muted { color: var(--ink-3); font-size: 14px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled {
  background: var(--ink-4);
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand-line);
}
.btn-ghost:hover { background: var(--brand-soft); }

.btn-lg {
  height: 48px;
  padding: 0 32px;
  font-size: 15px;
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.link-btn:hover { color: var(--brand); }

.text-link {
  font-size: 14px;
  color: var(--brand);
}

/* ---------- 页头 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(251, 249, 247, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  flex: none;
}
/* 租户上传了 logo 就整块换成图片：去掉品牌底色，圆形成徽章（logo 本身是方形带底色） */
.brand-mark.has-logo {
  background: transparent;
  border-radius: 50%;
}
.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.brand-text strong { font-size: 16px; font-weight: 600; }
.brand-text small { font-size: 11px; color: var(--ink-3); letter-spacing: 0.04em; }

.site-nav {
  display: flex;
  gap: 26px;
  margin-right: auto;
  font-size: 14px;
}
.site-nav a { color: var(--ink-2); padding: 4px 0; border-bottom: 1px solid transparent; }
.site-nav a:hover { color: var(--ink-1); }
.site-nav a.active { color: var(--brand); border-bottom-color: var(--brand); }

.header-actions { display: flex; align-items: center; gap: 12px; }

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  font-size: 14px;
}
.account-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}
.account-chip .link-btn { font-size: 13px; color: var(--brand); }

/* ---------- 课件信息流（首页） ---------- */

.feed { padding: 22px 0 56px; }

.feed-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.inline-search { display: flex; gap: 8px; }
.inline-search input {
  flex: 1;
  height: 38px;
  min-width: 220px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-1);
  outline: none;
}
.inline-search input:focus { border-color: var(--brand); }

.feed-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 16px;
  min-height: 18px;
}

.feed-more {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}
.feed-more .btn { min-width: 180px; height: 42px; }

/* ---------- 通用区块 ---------- */

.section { padding: 24px 0 56px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.section-head h2 { font-size: 22px; }

/* ---------- 资料卡片 ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: var(--brand-line);
  transform: translateY(-3px);
  box-shadow: var(--shadow-m);
}

.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  overflow: hidden;
}
/* 封面原图口径是 16:9，容器同比例 + contain ⇒ 整图不裁；非 16:9 的老图留底色，不切边 */
.card-cover img { width: 100%; height: 100%; object-fit: contain; }
.cover-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--ink-4);
}
.card-cover .badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(36, 20, 19, 0.72);
  color: #fff;
  font-size: 11px;
}

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
/* 标题悬浮气泡：标题两行截断，鼠标放上去出全名（只在真截断时出现，见 app.js）。
   必须 pointer-events:none —— 气泡一旦盖住标题，hover 会自己中断，表现为不停闪烁。 */
.card-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 70;
  /* min() 兜住 320px 这类极窄屏，别让气泡横向溢出 */
  max-width: min(340px, calc(100vw - 16px));
  padding: 8px 11px;
  border-radius: var(--radius-s);
  background: var(--ink-1);
  color: #fff;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: var(--shadow-m);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.card-tip.show { opacity: 1; }
.card-tags span {
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  line-height: 1.5;
}

/* 搜索关键词高亮。默认的黄底黑字太跳，压成主题色系。
   底色用 --brand-line（0.22 透明度）：比 brand-soft 的 0.08 明显，又不至于糊成一片。 */
mark {
  background: var(--brand-line);
  color: var(--brand);
  font-weight: 600;
  padding: 0 1px;
  border-radius: 2px;
}
/* 分类标签本身已是浅色底，标签内再叠同色底看不出来，改用更实的边线色 */
.card-tags mark { background: var(--brand); color: #fff; }

.card-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: auto;
  /* 单行截断：窄屏宁可截掉末位的浏览数，也不要换行留下悬空的分隔点 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-block {
  grid-column: 1 / -1;
  padding: 56px 20px;
  text-align: center;
  color: var(--ink-3);
  background: var(--bg-card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-m);
  font-size: 14px;
}

/* ---------- 分类筛选 ---------- */

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ---------- 详情 ---------- */

.detail-wrap {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}
/* 侧栏无可见内容时收成单列，避免右侧留白 */
.detail-wrap.no-side { grid-template-columns: 1fr; }

.back-btn { margin-bottom: 18px; color: var(--ink-3); }

.detail-card {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 30px;
  /* 封面与信息列等高对齐，避免顶部对齐后左下方留一大块白 */
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 28px;
}

.detail-cover {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--bg-soft);
}
.detail-cover img { width: 100%; height: 100%; object-fit: contain; }

.detail-info h1 { font-size: 24px; line-height: 1.4; margin-bottom: 14px; }

.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.meta-row span {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--ink-2);
}

.detail-desc {
  font-size: 14px;
  color: var(--ink-2);
  margin: 0 0 24px;
  white-space: pre-wrap;
}

.download-box {
  padding: 18px 20px;
  border-radius: var(--radius-m);
  background: var(--bg-soft);
}
.download-hint { margin: 12px 0 0; font-size: 13px; color: var(--ink-3); }
.download-hint.warn { color: var(--warn); }
.download-hint.ok { color: var(--ok); }

.side-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 20px;
  margin-bottom: 16px;
}
.side-card h3 { font-size: 15px; margin-bottom: 12px; }

.bullet { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.bullet li { margin-bottom: 8px; }

.qr-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--bg-soft);
  margin-bottom: 10px;
}
.qr-box img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- 会员权益 / 帮助 / 账号 ---------- */

.vip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.vip-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 24px;
}
.vip-card h3 { font-size: 16px; margin-bottom: 10px; }
.vip-card p { margin: 0; font-size: 14px; color: var(--ink-2); }

.notice-panel {
  margin-top: 24px;
  padding: 28px;
  border-radius: var(--radius-l);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
}
.notice-panel h3 { font-size: 16px; margin-bottom: 8px; }
.notice-panel p { margin: 0 0 18px; font-size: 14px; color: var(--ink-2); }

.faq { max-width: 720px; }
.faq details {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 16px 20px;
  margin-bottom: 12px;
}
.faq summary { cursor: pointer; font-size: 15px; font-weight: 500; }
.faq p { margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }

.account-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 22px;
}
.stat-card small { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.stat-card strong { font-size: 20px; font-weight: 600; }
.stat-card .sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------- 页脚 ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 36px 0;
  margin-top: 32px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 14px;
}
.footer-inner strong { font-size: 15px; }
.footer-inner p { margin: 8px 0 0; max-width: 34em; }
.footer-links { display: flex; gap: 22px; align-items: flex-start; }
.footer-links a:hover, .footer-links .link-btn:hover { color: var(--brand); }

/* ---------- 扫码登录浮层 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(36, 20, 19, 0.5);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border-radius: var(--radius-l);
  padding: 32px 28px 24px;
  box-shadow: 0 24px 70px rgba(36, 20, 19, 0.28);
  text-align: center;
}
.modal-card h2 { font-size: 19px; }
.modal-card .muted { margin: 8px 0 20px; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
}
.modal-close:hover { color: var(--ink-1); }

.login-qr {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  border-radius: var(--radius-m);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.login-qr img { width: 100%; height: 100%; object-fit: contain; }
.qr-placeholder { font-size: 13px; color: var(--ink-3); }

.login-status {
  min-height: 22px;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.login-status.error { color: var(--warn); }

.legal {
  margin: 16px 0 0;
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-4);
  text-align: left;
}

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: 88vw;
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(36, 20, 19, 0.92);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-m);
}
.toast[hidden] { display: none; }

/* ---------- 内容预览 ---------- */

.preview-block {
  margin-top: 20px;
  padding: 22px 28px 26px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
}
.preview-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.preview-head h2 { font-size: 17px; margin: 0; }
.preview-head .muted { font-size: 12px; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.preview-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--bg-soft);
  overflow: hidden;
  cursor: zoom-in;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.preview-item:hover,
.preview-item:focus-visible {
  border-color: var(--brand-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow-s);
  outline: none;
}
/* 页码角标：缩略图很小，必须让它能看出这是第几页 */
.preview-idx {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 20px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(36, 20, 19, 0.68);
  color: #fff;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}
.preview-note {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------- 预览大图 ---------- */

body.no-scroll { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px 68px;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 8, 8, 0.9);
}
.lightbox-img {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  /* 图片加载完成前先给个深底，避免闪一下白 */
  background: rgba(0, 0, 0, 0.35);
}
.lightbox-btn {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.24); }
.lightbox-btn:disabled { opacity: 0.28; cursor: default; }
.lightbox-prev { margin-right: 12px; }
.lightbox-next { margin-left: 12px; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.24); }
.lightbox-count {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 960px) {
  .preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-wrap { grid-template-columns: 1fr; }
  .detail-card { grid-template-columns: 1fr; }
  .site-nav { display: none; }
}

@media (max-width: 640px) {
  .preview-block { margin-top: 14px; padding: 16px 14px 18px; }
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  /* 手机上左右箭头太占地方，挪到底部一行，图左右滑动翻页 */
  .lightbox { padding: 60px 12px 72px; }
  .lightbox-btn {
    position: absolute;
    bottom: 18px;
    width: 42px;
    height: 42px;
  }
  .lightbox-prev { left: calc(50% - 92px); margin-right: 0; }
  .lightbox-next { left: calc(50% + 50px); margin-left: 0; }
  .lightbox-count { bottom: 30px; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 18px; }
  .header-inner { height: 60px; gap: 12px; }
  .brand-text small { display: none; }
  .feed { padding: 16px 0 40px; }
  /* min-width:0 是关键：横向滚动的 chip 栏不设它会把整页撑宽，右侧卡片被推出屏幕 */
  .feed-bar { flex-direction: column; align-items: stretch; gap: 12px; min-width: 0; }
  .chip-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; min-width: 0; }
  .chip { flex: 0 0 auto; }
  .inline-search { min-width: 0; }
  .inline-search input { min-width: 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-body { padding: 10px 12px 12px; }
  .card-views { display: none; }
  .detail-card { padding: 18px; }
  .download-box { padding: 16px; }
  .btn-lg { width: 100%; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
