/* xloudread/static/style/materials.css
   学生科协物料管理 —— 与资料库 / 题库同一套蓝紫（indigo）令牌、同一张冷灰纸面。 */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 作者样式里的 display:flex 会盖过默认 [hidden]{display:none}，显式兜住 */
[hidden] { display: none !important; }

:root {
  --paper: #f4f5f9;
  --card: #ffffff;
  --ink: #1f2430;
  --ink-soft: #6b7280;
  --ink-faint: #9aa1ae;
  --line: #e6e8ef;
  --indigo: #6366f1;
  --indigo-deep: #4f46e5;
  --indigo-soft: #eef0fe;
  --green: #2f9e6e;
  --green-soft: #e9f7f0;
  --bar-h: 56px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶部条 ---------------- */
.mt-top {
  position: sticky; top: 0; z-index: 50; height: var(--bar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 22px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mt-logo { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.mt-logo-mark {
  width: 26px; height: 26px; flex: 0 0 26px; color: var(--indigo);
  display: flex; align-items: center; justify-content: center;
}
.mt-logo-mark svg { width: 23px; height: 23px; display: block; }
.mt-logo-text {
  font-family: "Songti SC", "SimSun", serif; letter-spacing: 1px; font-size: 16px;
  white-space: nowrap;
}
.mt-nav { display: flex; gap: 4px; margin-left: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mt-nav::-webkit-scrollbar { display: none; }
.mt-nav a {
  color: var(--ink-soft); text-decoration: none; font-size: 13px;
  padding: 6px 13px; border-radius: 18px; transition: background .2s, color .2s;
  white-space: nowrap; flex: 0 0 auto;
}
.mt-nav a:hover { background: var(--indigo-soft); color: var(--indigo-deep); }

/* ---------------- 主体 ---------------- */
.mt-wrap { max-width: 1080px; margin: 0 auto; padding: 30px 22px 70px; }

.mt-hero h1 {
  font-size: 26px; font-weight: 700; letter-spacing: .5px;
  display: flex; align-items: center; gap: 10px;
}
.mt-hero h1 iconify-icon { color: var(--indigo); }
.mt-sub { margin-top: 8px; font-size: 13.5px; line-height: 1.7; color: var(--ink-soft); }
.mt-sub b { color: var(--indigo-deep); font-weight: 600; }
#mtMeta { color: var(--ink-faint); }

/* 搜索条 */
.mt-bar { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.mt-search {
  position: relative; display: flex; align-items: center; gap: 8px;
  flex: 1 1 320px; max-width: 520px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 0 12px; height: 44px;
  transition: border-color .2s, box-shadow .2s;
}
.mt-search:focus-within { border-color: #c3c8f6; box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
.mt-search iconify-icon { color: var(--ink-faint); flex: 0 0 auto; }
.mt-search input {
  flex: 1 1 auto; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font-family: inherit; font-size: 14px; color: var(--ink);
}
.mt-search input::placeholder { color: #b3b9c4; }
.mt-search input::-webkit-search-cancel-button { display: none; }
.mt-clear {
  flex: 0 0 auto; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: #eceff5; color: var(--ink-soft);
  cursor: pointer; transition: background .18s, color .18s;
}
.mt-clear:hover { background: #e2e6f0; color: var(--ink); }
.mt-hint { font-size: 13px; color: var(--ink-faint); white-space: nowrap; }
.mt-hint b { color: var(--indigo-deep); font-weight: 600; }

/* 类别筛选 */
.mt-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mt-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; transition: background .18s, border-color .18s, color .18s;
}
.mt-chip:hover { background: var(--indigo-soft); border-color: #d6dbfa; color: var(--indigo-deep); }
.mt-chip.is-active { background: var(--indigo-soft); border-color: #c7cef9; color: var(--indigo-deep); }
.mt-chip:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.mt-chip-n {
  font-size: 11.5px; font-weight: 700; line-height: 1;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(99, 102, 241, .12); color: var(--indigo-deep);
}
.mt-chip.is-active .mt-chip-n { background: #fff; }

/* ---------------- 分组卡片 ---------------- */
.mt-group {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px 6px; margin-top: 18px;
  box-shadow: 0 4px 14px rgba(17, 24, 39, .04);
}
.mt-group-hd { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; }
.mt-group-badge {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
  font-size: 13px; font-weight: 700; font-family: var(--mono);
}
.mt-group-hd h2 { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.mt-group-n { margin-left: auto; font-size: 12.5px; color: var(--ink-faint); white-space: nowrap; }
.mt-group-num { color: var(--indigo-deep); font-weight: 700; }

/* 宽屏一行放两组「值 + 封装」（39 条也不用一路滚），窄屏退回单列堆叠。
   每条记录内部仍是 值 | 封装 两列，值用等宽字体，纵向扫读时不跳动。 */
.mt-list { display: grid; grid-template-columns: 1fr; }
.mt-row {
  display: grid; grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid #f2f3f8;
  transition: background .15s;
}
.mt-row:hover { background: #fafbff; }
/* 仪表组每条前面都有 30px 实物缩略图，值列加宽一点，长名称（逻辑分析仪测试夹）才不折行。
   只在宽屏生效：手机上值列固定 74px，不能跟着放大。 */
@media (min-width: 601px) {
  .mt-group[data-group="instrument"] .mt-row { grid-template-columns: 176px minmax(0, 1fr); }
}
.mt-row-val { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mt-val { font-family: var(--mono); font-size: 14.5px; font-weight: 600; letter-spacing: .2px; }
.mt-thumb {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 6px;
  object-fit: cover; background: #f1f3f9; border: 1px solid var(--line);
}
/* 样品本封面是竖版实拍：拉成竖向比例并用 contain，别把标签裁掉 */
.mt-thumb--book {
  width: 32px; height: 44px; flex: 0 0 32px;
  object-fit: cover; object-position: center 40%;
  background: #f1f3f9; border-color: #d9dcec;
}
.mt-row-pkgs { display: flex; flex-wrap: wrap; gap: 6px; }
/* 搜索结果末尾的样品本封面卡片：只在检索电容/电感/样品本/0603 时出现。 */
.mt-book-strip {
  margin: 18px 0 6px; padding: 14px 16px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.mt-book-strip-hd {
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
  letter-spacing: .3px; margin-bottom: 12px;
}
.mt-book-strip-list { display: flex; flex-wrap: wrap; gap: 16px; }
.mt-book-card {
  display: flex; align-items: center; gap: 12px; min-width: 280px;
  padding: 8px 14px 8px 8px; text-align: left; cursor: pointer;
  background: #fafbff; border: 1px solid #e7e9f4; border-radius: 10px;
  font-family: inherit; color: var(--ink); transition: border-color .15s, background .15s;
}
.mt-book-card:hover { border-color: #c7cef9; background: var(--indigo-soft); }
.mt-book-card:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.mt-book-card img {
  width: 46px; height: 62px; flex: 0 0 46px; border-radius: 6px;
  object-fit: cover; object-position: center 42%;
  background: #f1f3f9; border: 1px solid var(--line);
}
.mt-book-card-tx { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mt-book-card-tx b { font-size: 14px; font-weight: 600; }
.mt-book-card-tx small { font-size: 12px; color: var(--ink-soft); line-height: 1.4; }

/* 芯片行内使用说明（materials.js 从 pkg_meta.json 的 itemInfo 注入）：
   跨满两列、小字浅色，跟在条目下方；不算「值/封装」，不参与点击。 */
.mt-item-info {
  grid-column: 1 / -1;
  margin: 2px 0 1px;
  padding: 5px 9px;
  font-size: 12.5px; line-height: 1.6; color: #636b7d;
  background: #f7f8fc; border-left: 3px solid #c7cef9; border-radius: 0 6px 6px 0;
}
.mt-pkg {
  font-size: 12px; line-height: 1.5; color: #4b5263;
  background: #f3f4fa; border: 1px solid #e7e9f4; border-radius: 7px;
  padding: 0 8px; white-space: nowrap;
}
/* 暂无配图的封装（例如刚上架的电感）：只给提示，不做成按钮样式，
   免得用户以为点了会有图却没反应 */
.mt-pkg--noimg { cursor: help; border-style: dashed; color: #6b7280; }
/* 纯文字标注（数量 ×N / 精度 1% / 线长）：不是封装，不可点，也不提示缺图 */
.mt-pkg--tag { color: #666e80; background: #f7f8fc; border-color: #eceef8; }
/* 带图的封装胶囊：JS 从 pkg_meta.json 拿到匹配后升级，可点击看大图 */
.mt-pkg--img {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; padding: 0 9px 0 4px; min-height: 26px;
  transition: border-color .18s, background .18s, color .18s, box-shadow .18s;
}
.mt-pkg--img:hover, .mt-pkg--img:focus-visible {
  background: var(--indigo-soft); border-color: #c7cef9; color: var(--indigo-deep);
  box-shadow: 0 1px 4px rgba(79, 70, 229, .14);
}
.mt-pkg--img:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.mt-pkg-ico {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 4px;
  object-fit: cover; background: #fff; border: 1px solid #e7e9f4;
}

/* ---------------- 封装图片 lightbox ---------------- */
.mt-lightbox { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.mt-lb-backdrop {
  position: absolute; inset: 0;
  background: rgba(31, 36, 48, .58); backdrop-filter: blur(3px);
}
.mt-lb-card {
  position: relative; max-width: min(92vw, 560px); width: 100%;
  max-height: 88vh; overflow: auto;
  background: var(--card); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, .3);
  animation: mtLbIn .18s ease-out;
}
@keyframes mtLbIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .mt-lb-card { animation: none; } }
.mt-lb-img {
  display: block; width: 100%; max-height: 52vh; object-fit: contain;
  background: #f6f7fb; border-radius: 16px 16px 0 0;
}
.mt-lb-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .92); color: var(--ink);
  cursor: pointer; box-shadow: 0 1px 6px rgba(17, 24, 39, .18);
  transition: background .18s;
}
/* 视觉 34px，命中区扩到 48px（触控 ≥44px 且不撑大圆钮） */
.mt-lb-close::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; }
.mt-lb-close:hover { background: #fff; }
.mt-lb-close:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.mt-lb-cap { padding: 14px 18px 16px; }
.mt-lb-cap h3 { font-size: 15.5px; font-weight: 700; letter-spacing: .3px; }
.mt-lb-desc { margin-top: 6px; font-size: 13px; line-height: 1.75; color: #4b5563; }
.mt-lb-vals {
  margin-top: 10px; font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: var(--indigo-deep); background: var(--indigo-soft);
  border-radius: 8px; padding: 6px 10px;
}
/* 商品页链接：按当前值现拼（封装 + 阻值/容值） */
.mt-lb-buy { margin-top: 12px; }
.mt-lb-buy[hidden] { display: none !important; }
.mt-lb-buy a {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 13px;
  font-size: 12.5px; font-weight: 600; line-height: 1;
  color: var(--indigo-deep); background: var(--indigo-soft);
  border: 1px solid rgba(99, 102, 241, .32); border-radius: 999px;
  text-decoration: none;
  transition: background .18s, border-color .18s;
}
.mt-lb-buy a::after { content: '↗'; font-size: 12px; opacity: .7; }
.mt-lb-buy a:hover { background: #e7e9ff; border-color: rgba(99, 102, 241, .55); }
.mt-lb-buy a:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.mt-lb-src { margin-top: 10px; font-size: 11px; color: var(--ink-faint); }
.mt-lb-src a {
  color: var(--indigo-deep); text-decoration: none;
  border-bottom: 1px dashed rgba(99, 102, 241, .45);
}
.mt-lb-src a:hover { border-bottom-style: solid; }
.mt-lb-src a:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; border-radius: 2px; }
@media (min-width: 760px) {
  .mt-list { grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .mt-row { padding: 7px 8px; }
}

/* 空态 */
.mt-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-top: 18px; padding: 46px 20px;
  background: var(--card); border: 1px dashed #dcdfea; border-radius: 14px;
  color: var(--ink-faint); font-size: 14px;
}
.mt-empty iconify-icon { color: #c8ccd8; }
.mt-empty-btn {
  margin-top: 2px; min-height: 36px; padding: 0 16px;
  background: var(--indigo-soft); border: 1px solid #d6dbfa; border-radius: 9px;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--indigo-deep);
  cursor: pointer;
}
.mt-empty-btn:hover { background: #e5e9fe; }

/* ---------------- 说明 / 数量级 ---------------- */
.mt-notes {
  margin-top: 22px; padding: 18px 20px;
  background: #fbfcff; border: 1px solid #e3e7f7; border-left: 3px solid var(--indigo);
  border-radius: 14px;
}
.mt-notes-hd { display: flex; align-items: center; gap: 8px; color: var(--indigo-deep); }
.mt-notes-hd h2 { font-size: 15px; font-weight: 700; }
.mt-note-list { margin: 10px 0 0 18px; font-size: 13.5px; line-height: 1.85; color: #4b5563; }
.mt-note-list li { list-style: disc; }
.mt-scale { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #dde2f3; }
.mt-scale-hd { font-size: 13px; font-weight: 600; color: var(--indigo-deep); margin-bottom: 10px; }
.mt-scale-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.mt-scale-item {
  display: flex; align-items: baseline; gap: 6px;
  background: #fff; border: 1px solid #e7eaf6; border-radius: 9px;
  padding: 7px 10px; font-size: 13px; color: #4b5563;
}
.mt-scale-sym { font-family: var(--mono); font-weight: 700; color: var(--indigo-deep); }
.mt-scale-eq { font-family: var(--mono); }
.mt-scale-eq sup { font-size: 9.5px; }
.mt-scale-mean { margin-left: auto; font-size: 11.5px; color: var(--ink-faint); }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 600px) {
  .mt-top { padding: 0 14px; gap: 10px; }
  .mt-wrap { padding: 22px 14px 56px; }
  .mt-hero h1 { font-size: 22px; }
  .mt-search { flex: 1 0 100%; max-width: none; }
  .mt-hint { flex: 1 0 100%; }
  .mt-group { padding: 16px 14px 4px; }
  /* 手机端不要堆成两行（39 条会拉到 3000px）：值靠左固定宽度，封装胶囊右侧换行排列 */
  .mt-row { grid-template-columns: 74px minmax(0, 1fr); gap: 6px 10px; padding: 9px 8px; }
  /* 仪表组的值前面还有 30px 缩略图，74px 会让「数字万用表」一个字一行 */
  .mt-group[data-group="instrument"] .mt-row { grid-template-columns: 122px minmax(0, 1fr); }
  .mt-row-pkgs { padding-left: 0; }
  .mt-chip { min-height: 36px; }
  /* 手机上胶囊要能点到（图标同步放大，命中高度 34px） */
  .mt-pkg { font-size: 12.5px; }
  .mt-pkg--img { min-height: 34px; padding: 0 10px 0 5px; }
  .mt-pkg-ico { width: 24px; height: 24px; flex-basis: 24px; }
}

@media (max-width: 430px) {
  .mt-nav { gap: 0; margin-left: 0; }
  .mt-nav a { padding: 6px 7px; font-size: 12.5px; }
}

@media (max-width: 360px) {
  .mt-logo-text { display: none; }
  .mt-scale-grid { grid-template-columns: 1fr 1fr; }
}
