/* 引入自定义字体 */
@font-face {
  font-family: "Liu Jian Mao Cao";
  src: url("/assets/LiuJianMaoCao-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* 针对使用特定标记链接的块应用手写字体 */
a[href="custom-font-marker"] {
  font-family: "Liu Jian Mao Cao", cursive;
  font-size: 2.2em;
  line-height: 1.5;
  text-align: center;
  color: inherit !important;
  text-decoration: none !important;
  background: none !important;
  background-image: none !important;
  cursor: default;
  pointer-events: none;
  display: block;
  /* margin-top: 1em; */
}

html {
  font-size: 10.5pt;
}

/* 设置段落两端对齐 */
p {
  text-align: justify;
  text-justify: inter-ideograph; /* 针对中文优化，改善标点和汉字间距 */
}

/* 增加段落行高，原为 2rem */
p,
ul,
ol,
dl {
  line-height: 2.2rem;
}

/* 标题样式调整：默认（中文）不倾斜，加粗 */
h1,
h2,
h3,
h4,
h5 {
  font-style: normal;
  font-weight: bold;
  color: #111;
}

h2 {
  font-size: 2.3rem;
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h3 {
  font-size: 2rem;
  line-height: 1.2;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
}

h4 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
}

h5 {
  font-size: 1.5rem;
  line-height: 1.2;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

/* 英文/数字部分：倾斜、加粗 */
.heading-en {
  font-style: italic;
}

/* 覆盖 Tufte CSS 的默认代码块样式 */
pre > code {
  width: 95%;
  /* 原为 52.5%，改为 100% 以适应父容器 */
  font-size: 1.2rem;
  /* 原为 0.9rem，增大字体 */
  margin-left: 0%;
  background-color: transparent;
  /* 避免代码块内重复背景 */
  padding: 0;
  border: none;
}

/* 调整行内代码大小及样式 */
code {
  font-size: 1.2rem;
  background-color: #f7f7f7;
  /* 浅灰背景 */
  padding: 0.1em 0.3em;
  /* 内边距 */
  border-radius: 3px;
  /* 圆角 */
  border: 1px solid #e7e7e7;
  /* 浅色边框 */
}

/* 代码块容器样式 */
pre {
  position: relative;
  /* 为复制按钮定位 */
  background-color: #f7f7f7;
  /* 浅灰背景 */
  border: 1px solid #e0e0e0;
  /* 边框 */
  border-radius: 5px;
  /* 圆角 */
  padding: 1em;
  /* 内边距 */
  overflow-x: auto;
  /* 横向滚动 */
  margin-bottom: 1.5em;

  /* 布局修复 */
  width: 55%;
  margin-left: 0;
  margin-right: 0;
  float: none;
  clear: none;
  box-sizing: border-box;
  /* 包含内边距和边框 */
  left: 0;
}

/* 列表中的代码块需要占满列表项宽度 */
li pre,
ul pre,
ol pre,
dl pre {
  width: 100%;
}

/* Figure 中的代码块需要占满 Figure 宽度 */
figure pre {
  width: 100%;
}

/* 修复引用块 (Quote Box) 样式 */
/* 针对 theorion 包生成的带左边框的 div */
div[style*="border-inline-start"] {
  width: 55% !important;
  /* 强制宽度为 55%，与正文一致 */
  font-size: 1.4rem;
  /* 统一字体大小，匹配正文 p 标签 */
  line-height: 2.2rem;
  /* 统一行高 */
  clear: none;
  /* 清除浮动 */
  margin: 1.5em 0;
  /* 垂直间距 */
  padding-right: 0 !important;
  /* 移除右内边距，确保侧边注与正文侧边注对齐 */
}

/* 确保内部 p 标签样式一致 */
div[style*="border-inline-start"] p {
  font-size: 1.4rem;
  /* 确保 p 标签也是 1.4rem */
  margin: 0.5em 0;
  /* 调整内部段落间距 */
  width: 100%;
  /* 内部 p 占满 div */
}

/* 修复引用块内的脚注和侧边注样式 */
div[style*="border-inline-start"] .footnote-ref,
div[style*="border-inline-start"] .marginnote,
div[style*="border-inline-start"] .footnote-ref a {
  color: #111 !important;
}

/* 复制按钮样式 */
.copy-button {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  padding: 0.3em 0.6em;
  font-size: 0.8rem;
  color: #666;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  /* 默认隐藏 */
  transition: opacity 0.2s, background-color 0.2s;
}

/* 鼠标悬停在代码块上时显示按钮 */
pre:hover .copy-button {
  opacity: 1;
}

/* 修复脚注导致的行距不一致问题 */
sup.footnote-ref {
  line-height: 0;
  position: relative;
  vertical-align: baseline;
  top: -0.5em;
}

.copy-button:hover {
  background-color: #f0f0f0;
  color: #333;
}

.copy-button.copied {
  background-color: #e6fffa;
  color: #008000;
  border-color: #008000;
}
