/* ============================================================
   实验学习库页 · 大学物理实验室风格
   参考视觉：现代科研实验室软件（白/浅灰/低饱和深蓝）
   ============================================================ */
:root {
  --ink: #17233b;      /* 主文字 */
  --muted: #68758a;    /* 次要文字 */
  --line: #dfe5ed;     /* 边框 */
  --soft: #f6f8fb;     /* 浅灰底 */
  --blue: #285eea;     /* 主强调色（低饱和深蓝） */
  --green: #168254;    /* 已提交 */
  --amber: #a66708;    /* 逾期提交 */
  --red: #c53c4b;      /* 未提交 */
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: #fbfcfe;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  height: 64px;
  padding: 0 max(24px, calc((100% - 1200px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; color: #183c83; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.mark { position: relative; width: 24px; height: 24px; border: 2px solid var(--blue); border-radius: 50%; }
.mark::before, .mark::after { content: ""; position: absolute; inset: 4px -4px; border: 2px solid var(--blue); border-radius: 50%; transform: rotate(60deg); }
.mark::after { transform: rotate(-60deg); }
.mark span { position: absolute; width: 5px; height: 5px; top: 7px; left: 7px; background: var(--blue); border-radius: 50%; z-index: 1; }

nav { display: flex; height: 100%; align-items: center; gap: 26px; }
nav a { height: 100%; display: flex; align-items: center; gap: 7px; text-decoration: none; color: #404b5b; font-size: 14.5px; border-bottom: 2px solid transparent; }
nav a.active { color: var(--blue); border-color: var(--blue); font-weight: 600; }
.navicon { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ---------- 页面主体 ---------- */
/* ⚠️ 这条是全局元素选择器：category.css 经 styles.css 被 /public 与教师端所有页面 import，
   教师端首页/admin 的 1200px 版心就靠它，不要改成 main#library 之类的限定写法（实测会让教师页拉满全屏）。
   实验详情页（main 里含左侧学习目录）在 experiment.html 自己的 <style> 里就地中和水平约束。 */
main { max-width: 1200px; margin: 0 auto; padding: 40px 24px 64px; }
.heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.heading h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.5px; }
.summary { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- 筛选条（分类下拉多选 + 提交状态下拉单选） ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 26px;
  margin: 0 0 20px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
/* .filters 自带 display:flex，会盖过 UA 的 [hidden]{display:none}，必须显式兜住 */
.filters[hidden] { display: none; }
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-label { flex: none; color: var(--muted); font-size: 13px; font-weight: 600; }

/* 下拉框：触发器 + 绝对定位面板（面板不能被 .filters 裁掉，故各级都不设 overflow） */
.dropdown { position: relative; }
.dd-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 172px;
  padding: 7px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #46546b;
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.dd-trigger:hover { border-color: #b9c9ee; }
.dd-trigger.active { border-color: var(--blue); color: var(--blue); font-weight: 600; }
.dd-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-caret { flex: none; width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; transition: transform .15s; }
.dd-trigger[aria-expanded="true"] .dd-caret { transform: rotate(180deg); }

.dd-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(340px, calc(100vw - 48px));
  max-height: 288px;
  overflow: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(31, 56, 105, .12);
}
.dd-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 4px;
  color: #46546b;
  font-size: 13.5px;
  cursor: pointer;
}
.dd-opt:hover { background: #f2f6ff; }
.dd-opt input { flex: none; width: 14px; height: 14px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.dd-opt .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-opt .n { flex: none; color: var(--muted); font-size: 12px; }
.dd-opt.on { background: #eef3ff; color: var(--blue); font-weight: 600; }
.dd-opt.on .n { color: var(--blue); }
.dd-empty { padding: 8px 9px; color: var(--muted); font-size: 13px; }
.dd-foot { display: flex; justify-content: flex-end; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); }
.dd-clear { padding: 2px 6px; background: none; border: 0; color: var(--muted); font-family: inherit; font-size: 12.5px; cursor: pointer; }
.dd-clear:hover { color: var(--blue); }

.filter-reset {
  margin-left: auto;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.filter-reset:hover { border-color: #b9c9ee; color: var(--blue); }

/* ---------- 实验卡片网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card {
  position: relative;
  min-height: 210px;
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: border-color .18s, box-shadow .18s;
}
.card:hover { border-color: #b9c9ee; box-shadow: 0 6px 18px rgba(31, 56, 105, .07); }

/* ---------- 卡片封面图（教师端「1. 实验基础信息 → 编辑封面图」的第一张） ---------- */
/* 有封面的卡片：顶到卡片上边缘的通栏图片，底部用渐变淡出到白底，
   让图片"溶"进卡片而不是硬边一块图；悬停时图片轻微放大。 */
.card.has-cover { padding-top: 0; overflow: hidden; }
.card-cover {
  position: relative;
  height: 132px;
  margin: 0 -22px 14px;              /* 抵消 .card 的左右内边距，做通栏 */
  overflow: hidden;
  background: linear-gradient(135deg, #e9efff 0%, #d9e5ff 55%, #eef3ff 100%);  /* 图片加载失败/缺失时的兜底渐变 */
}
.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s ease;
}
.card:hover .card-cover img { transform: scale(1.045); }
/* 渐变遮罩：顶部一层淡蓝（呼应主色），底部渐白（接住下方的标题与徽章） */
.card-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(40, 94, 234, .12) 0%,
    rgba(40, 94, 234, 0) 40%,
    rgba(255, 255, 255, .68) 82%,
    #ffffff 100%);
}

.cardhead { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.cardhead h2 { margin: 0; font-size: 18px; line-height: 1.45; font-weight: 650; color: var(--ink); }

/* 截止/状态徽章：小圆角淡色底（按个人提交状态） */
.deadline {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 3px;
  white-space: nowrap;
}
.deadline svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }
.dl-unsubmitted { color: var(--red); background: #fff3f3; }      /* 未提交 */
.dl-late { color: var(--amber); background: #fff7ed; }           /* 逾期提交 */
.dl-on-time { color: var(--green); background: #edf9f2; }        /* 已按时提交 */
.dl-none { color: var(--muted); background: var(--soft); }       /* 未设截止 */

.meta { margin: 12px 0 0; color: var(--muted); font-size: 13.5px; }
.meta strong { color: #46546b; font-weight: 500; }

.open { margin-top: 18px; color: var(--blue); font-size: 14px; text-decoration: none; font-weight: 600; align-self: flex-start; }
.open::after { content: "→"; padding-left: 7px; font-size: 17px; vertical-align: -1px; }

.footer { margin-top: auto; padding-top: 18px; }
.progress-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.progress-row .value { color: var(--blue); }
.bar { height: 5px; margin-top: 9px; overflow: hidden; background: #e9edf3; border-radius: 1px; }
.fill { height: 100%; background: var(--blue); border-radius: 1px; }
.fill.green { background: var(--green); }
.unset { color: #98a2b3 !important; }

/* 空状态 / 加载中 */
.grid-tip { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 920px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .brand { font-size: 14px; }
  nav { gap: 14px; }
  nav a { font-size: 0; }
  nav a .navicon { width: 19px; height: 19px; }
  main { padding: 28px 16px 48px; }
  .heading { flex-direction: column; align-items: flex-start; gap: 8px; }
  .filters { padding: 12px; gap: 10px 0; }
  .filter-row { width: 100%; gap: 8px; }
  .filter-label { width: 100%; }
  .dropdown { flex: 1; min-width: 0; }
  .dd-trigger { width: 100%; min-width: 0; }
  .dd-panel { width: 100%; max-width: calc(100vw - 64px); }
  .filter-reset { margin-left: 0; }
  .grid { grid-template-columns: 1fr; }
  /* 单列时卡片更宽，封面稍高一些更耐看 */
  .card-cover { height: 146px; }
  /* 触摸目标：下拉触发按钮、卡片内「进入学习」在手机上都不能太矮（实测原为 33px / 22px） */
  .dd-trigger { min-height: 42px; }
  .dd-opt { min-height: 40px; }
  .open { display: inline-flex; align-items: center; min-height: 42px; margin-top: 10px; }
}
