/* ==================== A4 简历画布：无极变量驱动骨架 ====================
   本文件不再为「5 套模板」写死样式，而是把所有可调维度收敛为 CSS 变量。
   变量由 js/app.js 依据 state.resume.style.layout 连续计算并写入 :root，
   因此任意两个档位之间的取值都能被真实渲染 —— 这就是「无极调节」。
   ========================================================================= */

:root {
  /* —— 结构比例 —— */
  --lay-pad-x: 36px;
  --lay-pad-y: 28px;
  --lay-col-gap: 18px;
  --lay-col-bg: transparent;
  /* —— 版式骨架 —— */
  --lay-top-rule: 0px;
  --lay-header-pad-y: 0px;
  --lay-header-bg: transparent;
  --lay-header-border: 0px;
  --lay-header-border-color: transparent;
  --lay-header-rule-w: 1.5px;
  --lay-header-rule-style: solid;
  --lay-rule-w: 1.5px;
  --lay-rule-style: solid;
  --lay-rule-color: #e2e8f0;
  --lay-accent-bar-w: 68px;
  --lay-accent-bar-h: 2px;
  --lay-section-bar-w: 0px;
  --lay-section-bar-gap: 0px;
  --lay-backing-bg: transparent;
  --lay-backing-pad-y: 3px;
  --lay-backing-pad-x: 0px;
  --lay-title-color: var(--resume-accent);
  /* —— 视觉质感 —— */
  --lay-card-bg: transparent;
  --lay-card-border-color: transparent;
  --lay-card-border-w: 0px;
  --lay-card-pad-y: 0px;
  --lay-card-pad-x: 0px;
  --lay-round: 0px;
  --lay-avatar-scale: 1;
  /* —— 字号排版 —— */
  --lay-item-gap: 8px;
  /* —— 标题前缀（由 titlePrefix 参数切换，无需重绘 DOM）—— */
  --title-prefix: "";
  --title-prefix-w: 4px;
  --title-prefix-h: 13px;
  --title-prefix-bg: var(--resume-accent);
  --title-prefix-radius: 2px;
  --title-prefix-font: inherit;
  --title-prefix-weight: 800;
  --title-prefix-gap: 6px;
}

.resume-sheet {
  width: var(--resume-page-w, 794px);
  min-height: var(--resume-page-h, 1123px);
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1), 0 1px 3px rgba(15, 23, 42, 0.06);
  border-radius: 2px;
  font-family: var(--resume-font-family);
  font-size: var(--resume-font-size);
  line-height: var(--resume-line-height);
  padding: var(--lay-pad-y) var(--lay-pad-x);
  border-top: var(--lay-top-rule) solid var(--resume-accent);
  position: relative;
  overflow-wrap: break-word;
}

.resume-sheet.page-free {
  min-height: 0;
}

.resume-sheet[contenteditable="true"] {
  outline: 2px dashed rgba(37, 99, 235, 0.45);
  outline-offset: 4px;
}

/* ==================== 版式骨架：通栏页眉 + 主栏 / 侧栏 ====================
   布局模型对齐市面共识：模板决定有没有侧栏、侧栏在哪边；区块只归属主栏或侧栏。
   侧栏宽度由 --lay-side-w 连续控制（10%–50%）。 */
.r-body {
  display: block;
}

.r-columns {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: var(--lay-col-gap);
  align-items: start;
}

.resume-sheet.has-side .r-columns {
  grid-template-columns: 1fr var(--lay-side-w, 34%);
}

.resume-sheet.has-side.side-left .r-columns {
  grid-template-columns: var(--lay-side-w, 34%) 1fr;
}

.r-main {
  position: relative;
  min-width: 0;
}

.r-side {
  position: relative;
  min-width: 0;
  align-self: stretch;
  padding: 14px 16px;
  background: var(--lay-col-bg);
  border-radius: var(--lay-round);
}

.resume-sheet.side-left .r-side {
  border-right: var(--lay-side-border, 0px) solid var(--lay-rule-color);
}

.resume-sheet.side-right .r-side {
  border-left: var(--lay-side-border, 0px) solid var(--lay-rule-color);
}

/* 区块内多列：短条目列表（技能 / 证书 / 语言等）可以并排成 2–3 列 */
.r-section[data-cols="2"] > .r-bullets,
.r-section[data-cols="2"] > .r-skills-grid {
  display: block;
  column-count: 2;
  column-gap: 22px;
}

.r-section[data-cols="3"] > .r-bullets,
.r-section[data-cols="3"] > .r-skills-grid {
  display: block;
  column-count: 3;
  column-gap: 18px;
}

.r-section[data-cols] > .r-bullets > li,
.r-section[data-cols] > .r-skills-grid > * {
  break-inside: avoid;
  margin-bottom: 3px;
}

/* 窄栏自动降级排版：容器查询，不写死任何「侧栏宽度」 */
.r-main,
.r-side {
  container-type: inline-size;
}

@container (max-width: 260px) {
  .r-skill-line {
    flex-direction: column;
    gap: 1px;
  }

  .r-skill-cat {
    min-width: 0;
  }

  .r-item-meta {
    white-space: normal;
  }

  .r-contact-list {
    flex-direction: column;
    align-items: flex-start;
  }

  .r-item-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
  }
}

/* ==================== 顶部个人信息区 ==================== */
.r-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: var(--resume-section-gap);
  padding: var(--lay-header-pad-y) calc(var(--lay-header-pad-y) * 1.4);
  background: var(--lay-header-bg);
  border: var(--lay-header-border) solid var(--lay-header-border-color);
  border-bottom-width: var(--lay-header-rule-w);
  border-bottom-style: var(--lay-header-rule-style);
  border-bottom-color: var(--lay-rule-color);
  border-radius: var(--lay-round);
}

.resume-sheet.align-center .r-header {
  text-align: center;
}

.resume-sheet.align-center .r-header-main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.resume-sheet.align-center .r-name-row,
.resume-sheet.align-center .r-contact-list {
  justify-content: center;
}

.resume-sheet.align-right .r-header {
  flex-direction: row-reverse;
  text-align: right;
}

.resume-sheet.align-right .r-name-row,
.resume-sheet.align-right .r-contact-list {
  justify-content: flex-end;
}

.r-header-main {
  flex: 1;
  min-width: 0;
}

.r-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.r-name {
  font-size: calc(var(--resume-font-size) * 1.84);
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.r-role-badge {
  font-size: calc(var(--resume-font-size) * 1.08);
  font-weight: 700;
  color: var(--resume-accent);
  background: var(--lay-badge-bg, rgba(37, 99, 235, 0.07));
  border: 1px solid var(--lay-badge-border, rgba(37, 99, 235, 0.18));
  padding: 2px 9px;
  border-radius: calc(6px + var(--lay-round) * 0.6);
  line-height: 1.35;
}

.r-contact-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: calc(var(--resume-font-size) * 0.96);
  color: #475569;
  line-height: 1.45;
}

.r-contact-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.r-contact-sep {
  color: #cbd5e1;
  font-size: 11px;
}

.r-avatar {
  width: calc(68px * var(--lay-avatar-scale));
  height: calc(84px * var(--lay-avatar-scale));
  object-fit: cover;
  border-radius: calc(6px + var(--lay-round) * 0.5);
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
  background: #f8fafc;
}

.r-avatar.circle {
  width: calc(74px * var(--lay-avatar-scale));
  height: calc(74px * var(--lay-avatar-scale));
  border-radius: 50%;
}

/* ==================== 模块通用结构 ==================== */
.r-section {
  position: relative;
  margin-bottom: var(--resume-section-gap);
}

.r-section:last-child {
  margin-bottom: 0;
}

.r-section-header {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 7px;
  padding: var(--lay-backing-pad-y) var(--lay-backing-pad-x);
  padding-left: calc(var(--lay-backing-pad-x) + var(--lay-section-bar-w) + var(--lay-section-bar-gap));
  background: var(--lay-backing-bg);
  border-left: var(--lay-section-bar-w) solid var(--resume-accent);
  border-bottom-width: var(--lay-rule-w);
  border-bottom-style: var(--lay-rule-style);
  border-bottom-color: var(--lay-rule-color);
  border-radius: var(--lay-round);
}

/* 标题下强调条：长度与粗细均为连续变量 */
.r-section-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: calc(var(--lay-rule-w) * -1);
  width: var(--lay-accent-bar-w);
  height: var(--lay-accent-bar-h);
  border-radius: 2px;
  background: var(--resume-accent);
}

.r-section-title {
  font-size: calc(var(--resume-font-size) * 1.1);
  font-weight: 700;
  color: var(--lay-title-color);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
}

/* 标题前缀：# 号 / 竖条 / 无 —— 三种形态共用同一个伪元素，切换零重绘 */
.r-section-title::before {
  content: var(--title-prefix);
  display: inline-block;
  width: var(--title-prefix-w);
  height: var(--title-prefix-h);
  background: var(--title-prefix-bg);
  border-radius: var(--title-prefix-radius);
  font-family: var(--title-prefix-font);
  font-weight: var(--title-prefix-weight);
  line-height: 1;
  flex-shrink: 0;
  margin-right: var(--title-prefix-gap);
}

.r-item {
  margin-bottom: var(--lay-item-gap);
  padding: var(--lay-card-pad-y) var(--lay-card-pad-x);
  background: var(--lay-card-bg);
  border: var(--lay-card-border-w) solid var(--lay-card-border-color);
  border-radius: var(--lay-round);
}

.r-item:last-child {
  margin-bottom: 0;
}

.r-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 2px;
}

.r-item-left {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}

.r-item-title {
  font-weight: 700;
  font-size: calc(var(--resume-font-size) * 1.08);
  color: #0f172a;
}

.r-item-subtitle {
  font-weight: 600;
  color: var(--resume-accent);
  font-size: var(--resume-font-size);
}

.r-item-dept {
  font-weight: 500;
  color: #475569;
  font-size: calc(var(--resume-font-size) * 0.96);
}

.r-item-meta {
  font-size: calc(var(--resume-font-size) * 0.96);
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.r-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 4px;
}

.r-tag {
  font-size: calc(var(--resume-font-size) * 0.84);
  line-height: 1.3;
  padding: 1px 6px;
  border-radius: calc(4px + var(--lay-round) * 0.4);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-weight: 500;
}

.r-bullets {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 2.5px;
  color: #334155;
}

.r-bullets li {
  position: relative;
  padding-left: 12px;
  text-align: justify;
}

.r-bullets li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--resume-accent);
  transform: translateY(-50%);
}

/* 量化数字自动高亮样式 */
.r-metric-bold {
  font-weight: 700;
  color: #0f172a;
}

.r-skills-grid {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
}

.r-skill-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.r-skill-cat {
  font-weight: 700;
  color: #0f172a;
  min-width: 82px;
  flex-shrink: 0;
  position: relative;
  padding-left: 10px;
}

.r-skill-cat::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.62em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--resume-accent);
  transform: translateY(-50%);
}

/* ==================== 高清打印与 PDF 导出媒体查询 ==================== */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    background: #ffffff !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .no-print {
    display: none !important;
  }

  .dm-handle,
  .dm-badge,
  .dm-drop-line {
    display: none !important;
  }

  .workspace-main {
    display: block !important;
    overflow: visible !important;
  }

  .preview-pane,
  .preview-scroll-wrap {
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    background-image: none !important;
    overflow: visible !important;
    display: block !important;
  }

  .a4-sheet-wrapper {
    transform: none !important;
    width: 100% !important;
  }

  .resume-sheet {
    width: 210mm !important;
    min-height: 297mm !important;
    box-shadow: none !important;
    margin: 0 auto !important;
  }
}

/* ==================== 形态系统：让模板真正长得不一样 ====================
   模板之间不只靠「滑杆数值不同」，而是靠 4 个正交形态维度：
   页眉形态 · 区块标题形态 · 条目形态 · 头像形态，外加侧栏色调。 */

/* ---------- 页眉形态 ---------- */
.resume-sheet.hs-band .r-header,
.resume-sheet.hs-banner .r-header {
  margin: calc(var(--lay-pad-y) * -1) calc(var(--lay-pad-x) * -1) var(--resume-section-gap);
  padding: calc(var(--lay-pad-y) + 8px) var(--lay-pad-x);
  border-radius: 0;
}

.resume-sheet.hs-band .r-header {
  background: var(--lay-band-bg);
  border-bottom: 2px solid var(--resume-accent);
}

.resume-sheet.hs-banner .r-header {
  background: var(--resume-accent);
  border: none;
}

.resume-sheet.hs-banner .r-name,
.resume-sheet.hs-banner .r-contact-list,
.resume-sheet.hs-banner .r-contact-item {
  color: #ffffff;
}

.resume-sheet.hs-banner .r-role-badge {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.38);
}

.resume-sheet.hs-banner .r-contact-sep {
  color: rgba(255, 255, 255, 0.45);
}

.resume-sheet.hs-banner .r-avatar {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.15);
}

/* ---------- 区块标题形态 ---------- */
.resume-sheet.ts-solid .r-section-header {
  padding: 3px 10px;
  background: var(--resume-accent);
  border-radius: 5px;
  border-bottom-width: 0;
}

.resume-sheet.ts-solid .r-section-header::after,
.resume-sheet.ts-pill .r-section-header::after,
.resume-sheet.ts-leftblock .r-section-header::after,
.resume-sheet.ts-center .r-section-header::after {
  display: none;
}

.resume-sheet.ts-solid .r-section-title {
  color: #ffffff;
}

.resume-sheet.ts-pill .r-section-header {
  padding: 3px 12px;
  background: var(--lay-pill-bg);
  border-left: 3px solid var(--resume-accent);
  border-radius: 999px;
  border-bottom-width: 0;
}

.resume-sheet.ts-leftblock .r-section-header {
  padding-left: calc(var(--lay-block-w) + 8px);
  background: none;
  border-left: var(--lay-block-w) solid var(--resume-accent);
  border-bottom-width: 0;
  border-radius: 0;
}

.resume-sheet.ts-center .r-section-header {
  justify-content: center;
  padding: 3px 0;
  border-top: 1px solid var(--lay-rule-color);
  border-bottom: 1px solid var(--lay-rule-color);
  border-left-width: 0;
}

/* ---------- 条目形态 ---------- */
.resume-sheet.es-rail .r-item {
  position: relative;
  margin-left: 5px;
  padding-left: 20px;
  border-left: 1.5px solid var(--lay-rail-line);
}

.resume-sheet.es-rail .r-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 0.45em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--resume-accent);
}

.resume-sheet.es-divider .r-item {
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--lay-rule-color);
}

.resume-sheet.es-divider .r-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

/* ---------- 头像形态 ---------- */
.resume-sheet.as-block .r-avatar {
  border-radius: 10px;
  border: 3px solid var(--resume-accent);
  background: #ffffff;
}

/* ---------- 深色侧栏：整体反白 ---------- */
.resume-sheet.side-dark .r-side {
  color: rgba(255, 255, 255, 0.92);
}

.resume-sheet.side-dark .r-side .r-name,
.resume-sheet.side-dark .r-side .r-section-title,
.resume-sheet.side-dark .r-side .r-item-title,
.resume-sheet.side-dark .r-side .r-item-subtitle,
.resume-sheet.side-dark .r-side .r-item-dept,
.resume-sheet.side-dark .r-side .r-skill-cat,
.resume-sheet.side-dark .r-side .r-contact-list,
.resume-sheet.side-dark .r-side .r-contact-item,
.resume-sheet.side-dark .r-side .r-bullets li {
  color: rgba(255, 255, 255, 0.94);
}

.resume-sheet.side-dark .r-side .r-item-meta {
  color: rgba(255, 255, 255, 0.7);
}

.resume-sheet.side-dark .r-side .r-bullets li::before,
.resume-sheet.side-dark .r-side .r-skill-cat::before {
  background: rgba(255, 255, 255, 0.8);
}

.resume-sheet.side-dark .r-side .r-section-header {
  border-bottom-color: rgba(255, 255, 255, 0.4);
  border-left-color: rgba(255, 255, 255, 0.75);
}

.resume-sheet.side-dark .r-side .r-role-badge {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
}

.resume-sheet.side-dark .r-side .r-avatar {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.12);
}

.resume-sheet.side-dark .r-side .r-tag {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.resume-sheet.side-dark.ts-solid .r-side .r-section-header {
  background: rgba(255, 255, 255, 0.2);
}

.resume-sheet.side-dark.ts-pill .r-side .r-section-header {
  background: rgba(255, 255, 255, 0.16);
}

.resume-sheet.side-dark.es-rail .r-side .r-item::before {
  background: var(--lay-col-bg);
}
