/* ============================================================
   resume.css —— 简历纸张与选择器样式

   从「AI优化简历」的 globals.css 简历段 + Tailwind 类内联样式合并重写。
   纸张内部一律用 --r-* 变量（由 resume-render.js 注入），与站点 theme.css 的
   --primary 等 token 隔离：纸张配色是用户选的，不该跟着站点主题走。
   ============================================================ */

/* ===== 纸张容器：手机上缩放适屏 ===== */
/* 纸张固定 210mm≈794px，手机屏约 390px。整体等比缩放（scale）而不是改版心宽度 ——
   改宽度等于换了一套版面，用户在手机上看到的就不是打印出来的样子，
   六套版式的差异也就无从判断。缩放后字小，但可双指放大。 */
.paper-stage {
  overflow: hidden;
  border-radius: 14px;
  background: #eef0f7;
  border: 1px solid var(--line);
  padding: 10px;
}
/* transform-origin 必须是 top left，且不能 margin:auto。
   原因：scaler 宽 794px 而容器只有约 370px，overflow 之前它是「溢出到右边」的状态；
   用 top center + margin auto 会让缩放围绕那个溢出后的中心点发生，结果纸张被推到右侧并切掉左半边。
   改成 top left 后缩放从容器左上角开始，缩完再由 JS 算左边距居中（宽度已知，算得准）。 */
.paper-scaler {
  transform-origin: top left;
  width: 210mm;
}
.paper-hint {
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
}

/* ===== 纸张本体 ===== */
.resume-paper {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  color: #1f2937;
  box-shadow: 0 2px 12px rgba(30, 41, 89, .1);
  /* 纸张内部不继承站点行高，交给 --r-lh */
  --r-text: #1f2937;
  --r-muted: #6b7280;
}
.resume-paper .r-pad { padding: 32px; }
.resume-paper h1, .resume-paper h2 { font-weight: 700; letter-spacing: 0; }

/* 占位符高亮：AI 提示用户补真实数据的地方 */
.resume-paper .r-ph {
  background: #fef3c7;
  color: #92400e;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: .85em;
  font-weight: 500;
}

/* ---- 页头 ---- */
.r-header-center { text-align: center; margin-bottom: 16px; }
.r-header-left { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--r-primary); }
.r-name { font-size: 1.8em; color: var(--r-primary); line-height: 1.25; }
.r-header-left .r-name { font-size: 1.75em; }
.r-joblarge { margin-top: 4px; font-size: .95em; font-weight: 600; color: var(--r-text); }
.r-contact { margin-top: 4px; font-size: .9em; color: var(--r-muted); }
.r-sep { color: var(--r-muted); }

/* ---- 段落 ---- */
.r-section { margin-bottom: calc(var(--r-gap) * 1.3); }
.r-sec-bar > h2 {
  font-size: 1.05em; color: var(--r-primary);
  border-bottom: 2px solid var(--r-primary);
  padding-bottom: 4px; margin-bottom: 8px;
}
.r-sec-tight { margin-bottom: calc(var(--r-gap) * 1.05); }
.r-sec-tight > h2 {
  font-size: .95em; color: var(--r-primary);
  border-bottom: 1px solid var(--r-primary);
  padding-bottom: 2px; margin-bottom: 4px;
}
.r-sec-soft { margin-bottom: calc(var(--r-gap) * 1.4); }
.r-sec-soft > h2 {
  font-size: .85em; color: var(--r-primary);
  letter-spacing: .15em; margin-bottom: 8px;
}
/* 强调块：技能优先型的技能栏、学术型的教育栏 */
.r-tintbox {
  background: var(--r-tint);
  border-left: 3px solid var(--r-primary);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.r-tintbox > h2 { font-size: 1em; color: var(--r-primary); margin-bottom: 6px; }

/* ---- 经历条目 ---- */
.r-block { margin-bottom: var(--r-gap); }
.r-block-dense { margin-bottom: calc(var(--r-gap) * .55); }
.r-blockhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.r-blocktitle { font-weight: 600; color: var(--r-text); }
.r-blockperiod {
  flex-shrink: 0; font-size: .85em; color: var(--r-muted);
  display: inline-flex; align-items: center; gap: 4px;
}
.r-bullets { margin-top: 4px; padding-left: 20px; list-style: disc; }
.r-bullets > li { margin-bottom: 2px; }
.r-bullets-dense { margin-top: 2px; line-height: calc(var(--r-lh) * .92); }
.r-bullets-dense > li { margin-bottom: 0; }
.r-nobullet { list-style: none; }

/* ---- 技能 ---- */
.r-skills { padding-left: 20px; list-style: disc; }
.r-skills > li { margin-bottom: 2px; }
.r-skills-plain { padding-left: 0; list-style: none; }
.r-skills-cols { column-gap: 1.6em; }
.r-skills-cols > li { break-inside: avoid; }

/* ---- 侧栏双列 ---- */
.r-twocol { display: flex; min-height: 297mm; }
.r-sidebar {
  width: 32%; flex-shrink: 0; padding: 20px;
  background: var(--r-sidebar-bg); color: var(--r-sidebar-fg);
}
.r-main { flex: 1; padding: 20px; }
.r-sname { font-size: 1.5em; line-height: 1.2; color: inherit; }
.r-sjob { margin-top: 4px; font-size: .9em; opacity: .9; }
.r-scontact { margin-top: 16px; font-size: .82em; opacity: .9; }
.r-scontact > div { margin-bottom: 3px; }
.r-break { word-break: break-all; }
.r-sgroup { margin-top: 20px; }
.r-shead { font-size: .95em; letter-spacing: .06em; opacity: .8; margin-bottom: 8px; }
.r-sbody { font-size: .84em; opacity: .92; }
.r-sdim { margin-top: 2px; opacity: .72; }
.r-sidebar .r-sep { color: inherit; opacity: .7; }

/* ===== 就地编辑态 ===== */
.r-f { display: inline; }
.resume-editmode .r-editable {
  cursor: text; border-radius: 3px;
  outline: 1px dashed transparent;
  outline-offset: 2px;
  transition: background .12s, outline-color .12s;
}
.resume-editmode .r-editable:hover { background: rgba(79, 107, 255, .07); outline-color: rgba(79, 107, 255, .35); }
.resume-editmode .r-editable:focus-visible { outline: 2px solid var(--r-primary); }
.r-editing {
  background: #fff !important;
  outline: 2px solid var(--r-primary) !important;
  outline-offset: 2px;
  white-space: pre-wrap;
}
.r-empty { color: #b6bcca; font-style: italic; }
.resume-paper .r-sidebar .r-empty { color: rgba(255, 255, 255, .55); }
.resume-editmode .r-sidebar .r-editable:hover { background: rgba(255, 255, 255, .12); }

.r-iconbtn {
  display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; margin-left: 4px;
  border-radius: 4px; border: none;
  background: #fee2e2; color: #b91c1c;
  font-size: 13px; line-height: 1; font-weight: 700;
  cursor: pointer; vertical-align: middle;
}
.r-iconbtn:hover { background: #fecaca; }
.resume-editmode .r-bullet:hover .r-iconbtn,
.resume-editmode .r-block:hover .r-iconbtn { display: inline-flex; }
.r-addbtn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; margin-top: 4px;
  font-size: 12px; font-weight: 600;
  color: var(--r-muted); background: transparent;
  border: 1px dashed #cbd5e1; border-radius: 8px; cursor: pointer;
}
.r-addbtn:hover { color: var(--r-primary); border-color: var(--r-primary); }
.r-sidebar .r-addbtn { color: rgba(255, 255, 255, .7); border-color: rgba(255, 255, 255, .35); }
.r-sidebar .r-addbtn:hover { color: #fff; border-color: #fff; }

/* ===== 版式选择器 ===== */
.lp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .lp-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

.lp-card {
  position: relative; text-align: left; padding: 0; overflow: hidden;
  background: var(--card); border: 2px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.lp-card:hover { border-color: var(--primary); }
.lp-card.active { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.lp-thumbwrap { position: relative; padding: 8px; background: var(--bg); }
.lp-thumb {
  width: 100%; aspect-ratio: 210 / 297;
  background: #fff; border: 1px solid var(--line); border-radius: 3px;
  overflow: hidden; display: flex; flex-direction: column; padding: 8px; gap: 5px;
}
.lp-badge {
  position: absolute; right: 12px; top: 12px;
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 20px;
}
.lp-check {
  position: absolute; left: 12px; top: 12px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.lp-meta { padding: 4px 10px 10px; }
.lp-name { font-size: 13px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.lp-card.active .lp-name { color: var(--primary); }
.lp-line { font-size: 11px; line-height: 1.45; color: var(--ink-soft); margin-bottom: 2px; }
.lp-line.dim { color: var(--ink-faint); }
.lp-line b { font-weight: 700; }

/* 缩略图骨架条 */
.lp-bar { border-radius: 1px; background: #e2e8f0; flex-shrink: 0; }
.lp-bar.t { background: var(--primary); }
.lp-bar.b { background: #cbd5e1; }
.lp-blk { display: flex; flex-direction: column; gap: 2px; }
.lp-side { display: flex; height: 100%; }
.lp-sidecol { width: 34%; display: flex; flex-direction: column; gap: 5px; padding: 5px; background: #2b3a67; }
.lp-sidecol .lp-bar { background: rgba(255, 255, 255, .38); }
.lp-sidecol .lp-bar.t { background: rgba(255, 255, 255, .85); }
.lp-sidemain { flex: 1; display: flex; flex-direction: column; gap: 7px; padding: 6px; }
.lp-tint { background: var(--primary-soft); border-left: 2px solid var(--primary); border-radius: 2px; padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.lp-row { display: flex; gap: 5px; }
.lp-row > .lp-blk { flex: 1; }
.lp-center { align-items: center; }

/* 收起态摘要行 */
.lp-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; font-family: inherit; font-size: 13px; transition: border-color .15s;
}
.lp-summary:hover { border-color: var(--primary); }
.lp-summary .s-main { min-width: 0; }
.lp-summary .s-name { font-weight: 700; color: var(--ink); }
.lp-summary .s-why { color: var(--ink-faint); font-size: 12px; }
.lp-summary .s-act { flex-shrink: 0; color: var(--primary); font-weight: 700; font-size: 12px; }
.lp-reason {
  display: flex; gap: 6px; font-size: 12px; line-height: 1.6;
  color: var(--ink-soft); margin-bottom: 12px;
}
.lp-reason b { color: var(--ink); }

/* ===== 打印：只留简历纸张，A4 版心 =====
   纸张由 JS 额外渲染一份到 body 直接子级 #print-root，这样能用 display:none
   隐藏其它兄弟节点 —— 用 visibility:hidden 的话元素仍占文档高度，会打出大量空白页。 */
@media print {
  body > *:not(#print-root) { display: none !important; }
  /* #print-root 在屏幕上用行内 style 推到 left:-99999px 藏起来，行内样式优先级高于
     普通规则，必须用 !important 复位，否则打印出来是整页空白。踩过一次。 */
  #print-root {
    display: block !important;
    position: static !important;
    left: auto !important; top: auto !important;
    width: auto !important;
  }
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  /* 缩放只为屏幕小视口服务，打印必须还原成 1:1，否则纸上是缩小的一小块。
     height/margin-left 是 JS 为缩放态写的行内值，也要一并清掉 */
  .paper-scaler {
    transform: none !important; width: auto !important;
    height: auto !important; margin-left: 0 !important;
  }
  .resume-paper {
    width: 210mm !important; max-width: 210mm !important;
    margin: 0 !important; box-shadow: none !important;
    /* 让侧栏深色底、主色标题线真的打印出来，而不是被浏览器省掉墨 */
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .resume-paper * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  /* 左栏双列布局：侧栏深色底延伸满整页高 */
  .resume-paper .r-sidebar { min-height: 297mm; }
  /* 一条经历、一个段落标题不被硬切到下一页 */
  .resume-paper .r-block,
  .resume-paper .r-bullet { break-inside: avoid; page-break-inside: avoid; }
  .resume-paper .r-section > h2 { break-after: avoid; page-break-after: avoid; }
  /* 编辑态的所有装饰与增删按钮一律不印 */
  .r-edit-ui { display: none !important; }
  .resume-paper .r-editable,
  .resume-paper .r-editing { outline: none !important; background: transparent !important; }
  .resume-paper .r-empty { display: none !important; }
  .tabbar { display: none !important; }
  @page { size: A4; margin: 0; }
}
