/* 笼卡：按 99.1 × 67.7 mm 标签纸排版（A4 上 2 列 × 4 行，一张 8 枚）。
 *
 * 几何是量好的，不要凭感觉改：
 *   A4  210 × 297 mm
 *   卡   99.1 × 67.7 mm
 *   左右边距 4.65 mm  →  4.65 + 99.1 + 2.5 + 99.1 + 4.65 = 210 ✓
 *   上下边距 13.1 mm  →  13.1 + 67.7 × 4 + 13.1        = 297 ✓
 *   列间距 2.5 mm，行间距 0
 *
 * 打印时必须把缩放设成「实际大小 / 100%」，并关掉页眉页脚，
 * 否则浏览器会按「适应页面」缩一点，位置就全错了。屏幕上的提示写了这句。
 *
 * 全部走 class，不用行内 style —— CSP 是 style-src 'self'，
 * 行内样式会被静默丢掉，看不出任何报错。
 */

/* ---------- 屏幕上的预览 ---------- */

.cardhint {
  margin: 0 0 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--dim);
  font-size: 13.5px;
  line-height: 1.7;
}
.cardhint b { color: var(--ink); }

.cardbar { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }

.cardwrapper {
  /* 一张 A4 在手机上放不下，整体缩小预览；打印时这条不生效 */
  overflow-x: auto;
  padding-bottom: 8px;
}

.cardsheet {
  width: 210mm;
  height: 297mm;
  box-sizing: border-box;
  padding: 13.1mm 4.65mm;
  display: grid;
  grid-template-columns: 99.1mm 99.1mm;
  grid-template-rows: repeat(4, 67.7mm);
  column-gap: 2.5mm;
  row-gap: 0;
  background: #fff;
  color: #111;
  margin: 0 auto 18px;
  box-shadow: 0 2px 18px rgb(0 0 0 / 14%);
}

.cardone {
  box-sizing: border-box;
  width: 99.1mm;
  height: 67.7mm;
  padding: 4mm 4.6mm;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.2mm;
  font-family: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  color: #111;
}

/* 名单区：能压就压，压不下就裁掉，**绝不把卡撑变形**。
   裁掉多少由「另有 N 只」如实说出来。 */
.cardlist { flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* 空位也要占格：8 枚一张，第 5 张卡必须落在第二页的第一枚上 */
.cardgap { width: 99.1mm; height: 67.7mm; }

/* 屏幕上画出裁切参考线；打印时去掉，免得印在标签上 */
.cardsheet.guides .cardone { outline: 0.2mm dashed #c9d2d4; outline-offset: -0.1mm; }

.cardhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 3mm;
  border-bottom: 0.4mm solid #111;
  padding-bottom: 0.9mm;
}
.cardlabel { font-size: 6.2mm; font-weight: 800; letter-spacing: 0.2mm; line-height: 1.1; }
.cardcount { font-size: 3.2mm; font-weight: 700; white-space: nowrap; }

.cardmeta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8mm 4mm;
  font-size: 2.9mm;
  line-height: 1.35;
}
.cardmeta span { white-space: nowrap; }
.cardmeta i { font-style: normal; color: #555; }

.cardgeno {
  font-size: 2.9mm;
  line-height: 1.3;
  /* 基因型可能很长。截断比换行挤掉下面的名单好 —— 名单才是笼卡的正事。 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cardgeno i { font-style: normal; color: #555; }

.cardtable { width: 100%; border-collapse: collapse; font-size: 2.6mm; line-height: 1.15; }
.cardtable th, .cardtable td {
  text-align: left;
  padding: 0.35mm 1.2mm 0.35mm 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cardtable th { font-weight: 700; color: #555; border-bottom: 0.2mm solid #bbb; }
.cardtable tbody tr + tr td { border-top: 0.15mm solid #e2e6e7; }
/* td.tag 撞了 styles.css 里列表标签的 .tag 胶囊样式（灰底、圆角、12px、灰字），
   在 2.6mm 的笼卡表格里会变成一排灰色药丸。这里它只是「编号列加粗」，
   把被误带的属性压回继承值。 */
.cardtable td.tag { font-weight: 700; font-size: inherit; background: none;
  border-radius: 0; color: inherit; }

.cardmore { font-size: 2.5mm; color: #555; flex: none; }

.cardfoot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 3mm;
  font-size: 2.6mm;
  color: #666;
  border-top: 0.2mm solid #ddd;
  padding-top: 1mm;
}

/* ---------- 打印 ---------- */

@media print {
  @page { size: A4; margin: 0; }

  html, body { margin: 0; padding: 0; background: #fff; }
  /* 除了内容区，什么都不印：顶栏、底栏、公告、浮动按钮 */
  body > *:not(#main) { display: none !important; }
  #main {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    max-width: none !important;
  }
  #main > .view:not(#v-tracker) { display: none !important; }
  /* 笼位页里除了纸，别的都不印（返回按钮、说明、工具条） */
  #trackerBody > *:not(.cardwrapper) { display: none !important; }
  .cardwrapper { overflow: visible !important; padding: 0 !important; }

  .cardsheet {
    margin: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }
  .cardsheet:last-child { break-after: auto; page-break-after: auto; }
  .cardsheet.guides .cardone { outline: 0 !important; }

  /* 一枚卡不许被拆到两页 */
  .cardone, .cardgap { break-inside: avoid; page-break-inside: avoid; }
}
