/* 自定义CSS - 补充参考模板CSS中缺少的样式 */

/* 字体定义 */
@font-face {
  font-family: 'ShangTuDongGuan';
  src: url('../fonts/上图东观体-常规.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* 章节分段渲染 — 浏览器跳过不可见章节，大幅减少首屏解析量 */
/* iOS Safari 15.4+ / Chrome 85+ / Firefox 125+ 均支持 */
.chapter-section {
  content-visibility: auto;
  contain-intrinsic-size: auto 800px;
}

/* 确保中文显示正确 */
body {
  font-family: 'ShangTuDongGuan', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #111 !important;
}

/* 立绘样式 — 强制居中 */
figure.sprite {
  display: block !important;
  margin: 1rem auto !important;
  margin-inline: auto !important;
  width: fit-content !important;
  max-width: 100% !important;
  overflow: visible !important;
  float: none !important;
  text-align: center;
}

.sprite img {
  height: 22.5rem;
  width: auto;
  display: block;
  margin: 0 auto;
}

.sprite figcaption {
  text-align: center;
  margin-top: 0.25rem;
}

/* 背景图片样式 - 全宽展示，紧凑间距 */
.bg {
  margin-left: calc(-50vw + 50%);
  width: 100vw;
  text-align: center;
}

.bg img {
  width: 100%;
  height: auto;
  display: block;
}

.bg figcaption {
  text-align: center;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

/* 使用高优先级选择器彻底覆盖 prose figure 的默认间距 */
/* specificity: (0,1,3) + !important，确保覆盖 .prose :where(figure) 和 py-6/mt-2 等工具类 */
article.prose figure.bg {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  margin-block-start: 0 !important;
  margin-block-end: 0 !important;
  padding-top: 0.25rem !important;
  padding-bottom: 0.25rem !important;
  padding-block-start: 0.25rem !important;
  padding-block-end: 0.25rem !important;
}

/* ========== 音频指示器 — 毛玻璃胶囊 ========== */
.audio-cue-container {
  display: block;
  width: fit-content;
  margin-left: auto !important;
  margin-right: auto !important;
  margin-inline: auto !important;
  margin-top: 0.375rem;
  margin-bottom: 0.375rem;
}

.audio-cue {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.8125rem;
  color: var(--color-fg, #e7e5e4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0.45;
  transition: all 0.25s ease;
  user-select: none;
  cursor: default;
}

.audio-cue:hover {
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

/* 音乐 — 暖色左竖线，更明显 */
.audio-cue-music {
  border-left: 3px solid rgba(210, 165, 120, 0.7);
  opacity: 0.65;
}

.audio-cue-music:hover {
  opacity: 0.95;
  border-left-color: rgba(210, 165, 120, 0.9);
}

/* 音效 — 冷色左竖线 */
.audio-cue-sfx {
  border-left: 2px solid rgba(140, 170, 195, 0.5);
}

/* 停止 — 中性色 */
.audio-cue-stop {
  border-left: 2px solid rgba(165, 155, 145, 0.35);
}

.audio-cue-icon {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  opacity: 0.55;
}

.audio-cue-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  line-height: 1.3;
  white-space: nowrap;
}

.audio-cue-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

/* 播放中状态 */
.audio-cue-btn.is-playing {
  opacity: 1;
}

/* 音乐播放中 — 金色 */
.audio-cue-music .audio-cue-btn.is-playing {
  color: #e8c67a;
}

/* 音效播放中 — 浅蓝 */
.audio-cue-sfx .audio-cue-btn.is-playing {
  color: #8cc4e8;
}

/* 旁白文本 — 无边框段落 */
/* 全屏文字叠加 — 信号阻塞 / 致谢等（居中大字，无框） */
/* 全屏文字叠加 — 诗歌/信号阻塞/致谢（强制居中） */

/* ========== 时间表 / 居中文字块 — 居中容器，文字左对齐，左边框 ========== */
.schedule-block {
  width: 100%;
  margin: 1.25rem 0;
}

.schedule-block-inner {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  text-align: left;
  padding: 0.5rem 1rem 0.5rem 1.25rem;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.015);
  font-family: 'Georgia', 'Times New Roman', 'ShangTuDongGuan', 'Microsoft YaHei', 'PingFang SC', serif;
  font-size: 1rem;
  line-height: 1.85;
  letter-spacing: 0.03em;
  color: var(--color-fg, #e7e5e4);
  opacity: 0.8;
}
/* ========== 制作人员名单 — 衬线字体，居中引用块 ========== */
.credits-block {
  width: 100%;
  margin: 1.5rem 0;
}

.credits-block-inner {
  display: block;
  max-width: 520px;
  margin: 0 auto;
  text-align: left;
  padding: 1rem 1.5rem;
  border-left: 3px solid rgba(232, 198, 122, 0.5);
  background: rgba(255, 255, 255, 0.015);
  font-family: 'Georgia', 'Times New Roman', 'Noto Serif SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'ShangTuDongGuan', serif;
  font-size: 1.05rem;
  line-height: 2;
  letter-spacing: 0.04em;
  color: var(--color-fg, #e7e5e4);
  opacity: 0.85;
}

.text-overlay {
  padding: 1.5rem 0;
  margin: 1rem 0;
}

.text-overlay p {
  text-align: center !important;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-fg, #e7e5e4);
  opacity: 0.8;
  line-height: 2;
  margin: 0;
}

/* 章节标题样式 */
.chapter-heading {
  font-size: 2.25rem;
  font-weight: bold;
  border-bottom: 1px solid var(--border, #44403c);
  margin: 2rem auto;
  padding-bottom: 0.5rem;
  text-align: start;
}

/* ========== 横幅 Logo ========== */
.banner-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: auto;
  opacity: 0.9;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
  pointer-events: none;
  z-index: 1;
}

/* ========== 字体大小调节 ========== */
.font-size-control {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 0.9rem;
}

.font-size-control label {
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

.font-size-control select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.3rem;
  color: #e8c67a;
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.font-size-control select:focus {
  border-color: rgba(232, 198, 122, 0.5);
  box-shadow: 0 0 6px rgba(232, 198, 122, 0.15);
}

.font-size-control select option {
  background: #1a1a1a;
  color: #e7e5e4;
}

/* 字体大小档位 — 修改根字号，所有 rem 单位自动缩放 */
html.font-sm { font-size: 14px; }
html.font-md { font-size: 16px; }
html.font-lg { font-size: 18px; }
html.font-xl { font-size: 20px; }

/* ========== 项目介绍区域 ========== */
.intro {
  margin-bottom: 2rem;
  padding: 1rem 0;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--color-fg, #e7e5e4);
  opacity: 0.8;
}

.intro p {
  margin: 0.5rem 0;
}

.intro hr {
  margin: 1rem 0;
  border-color: rgba(255, 255, 255, 0.08);
}

.intro a {
  color: #c9a96e;
}

.intro a:hover {
  color: #e0c78a;
}

/* 响应式设计 */
/* ========== 阅读进度条 ========== */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  z-index: 9999;
  cursor: pointer;
  background: transparent;
  /* 上方留透明点击区域，下方为轨道 */
}

.progress-track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  transition: height 0.2s;
}

.progress-container:hover .progress-track {
  height: 5px;
}

.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background: #e8c67a;
  box-shadow: 0 0 8px rgba(232, 198, 122, 0.5), 0 0 16px rgba(232, 198, 122, 0.2);
  transition: width 0.15s ease-out;
  pointer-events: none;
}

/* 章节节点 */
.progress-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
}

.progress-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 1.5px solid rgba(232, 198, 122, 0.4);
  transition: all 0.2s;
}

.progress-container:hover .progress-marker {
  width: 9px;
  height: 9px;
  background: rgba(232, 198, 122, 0.8);
  border-color: rgba(232, 198, 122, 1);
  box-shadow: 0 0 6px rgba(232, 198, 122, 0.6);
}

.progress-marker.reached {
  background: #e8c67a;
  border-color: #e8c67a;
}

/* 章节提示 */
.progress-tooltip {
  position: fixed;
  top: 24px;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 0.75rem;
  color: #e8c67a;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(232, 198, 122, 0.3);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10000;
}

.progress-container:hover .progress-tooltip,
.progress-tooltip.visible {
  opacity: 1;
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
  /* 基础排版 */
  body {
    font-size: 0.95rem;
  }

  /* 横幅 */
  .banner {
    margin-bottom: 1rem !important;
  }
  .banner header {
    font-size: 0.75rem;
    padding: 0.5rem 1rem 2rem !important;
  }
  .banner-logo {
    width: 200px;
  }

  /* 主标题 */
  article h1 {
    font-size: 1.5rem !important;
    margin-top: 1.5rem !important;
  }

  /* 章节标题 */
  .chapter-heading {
    font-size: 1.35rem;
    margin: 1.25rem auto;
  }
  article h2 {
    font-size: 1.35rem !important;
    margin-top: 1.25rem !important;
    margin-bottom: 1.25rem !important;
  }

  /* 对话框 — 移动端容纳标签(1.5rem) + 头像(110px+边距) = ~10rem */
  article .min-h-36 {
    min-height: 10rem !important;
  }
  /* 标签改为自然流布局后，还原顶部内边距 */
  article .pt-8 {
    padding-top: 0.75rem !important;
  }
  article .p-4 {
    padding: 0.75rem !important;
  }
  /* 角色标签 — 移动端改为自然流布局，作为文字上方标题，彻底消除重叠 */
  article .-top-2 {
    position: static !important;
    display: block;
    margin: 0 0.5rem 0.25rem 0.5rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: calc(100% - 1rem);
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent !important;
    color: #c9a96e;
  }

  /* 立绘 — 增大尺寸 */
  .sprite img {
    height: 16rem;
  }

  /* 对话框内嵌头像 — 增大尺寸 + 防止溢出 */
  .size-30 {
    width: 110px !important;
    height: 110px !important;
  }

  /* 背景图 — 全视口宽度 */
  figure.bg {
    margin-left: calc(-50vw + 50%) !important;
    width: 100vw !important;
  }
  figure.bg img {
    width: 100%;
    height: auto;
  }

  /* 旁白内边距 */
  article .px-4 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  article .py-1 {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
  }

  /* 背景图 — 修正 calc 偏移 */
  figure.bg {
    margin-left: -1rem !important;
    width: calc(100% + 2rem) !important;
  }

  /* 视频容器 */
  .video-container video {
    width: 100%;
    height: auto;
  }

  /* 全屏文字叠加 */
  .text-overlay,
  article .font-bold[style*="font-size:1.25rem"] {
    font-size: 1.05rem !important;
    padding: 0.75rem 0.5rem !important;
  }

  /* 时间表代码块 */
  .schedule-block-inner {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem 0.5rem 1rem;
    line-height: 1.7;
  }

  /* 制作人员名单 */
  .credits-block-inner {
    font-size: 0.9rem;
    padding: 1rem 1.25rem;
    max-width: 95%;
    line-height: 1.8;
  }

  /* 音频按钮 — 增大点击区域 */
  .audio-cue {
    font-size: 0.875rem;
    padding: 0.35rem 0.85rem;
  }
  .audio-cue-icon {
    width: 1rem;
    height: 1rem;
  }

  /* 进度条 — 增大触摸区域 */
  .progress-container {
    height: 24px;
  }
  .progress-track {
    height: 3px;
  }
  .progress-container:hover .progress-track {
    height: 6px;
  }
  .progress-marker {
    width: 8px;
    height: 8px;
  }
  .progress-tooltip {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  /* 项目介绍 */
  .intro {
    font-size: 0.9rem;
    line-height: 1.65;
  }

  /* 目录 */
  details {
    font-size: 0.9rem;
  }

  /* 水平线 */
  article hr {
    margin: 1rem 0;
  }
}

/* 小屏手机 */
@media (max-width: 480px) {
  body {
    font-size: 0.9rem;
  }

  article h1 {
    font-size: 1.25rem !important;
  }

  article h2 {
    font-size: 1.15rem !important;
  }

  .sprite img {
    height: 14rem;
  }

  .size-30 {
    width: 90px !important;
    height: 90px !important;
  }

  /* 对话框 — 小屏容纳标签 + 头像(90px+边距) */
  article .min-h-36 {
    min-height: 8.5rem !important;
  }
  /* 标签改为自然流布局后，还原顶部内边距 */
  article .pt-8 {
    padding-top: 0.6rem !important;
  }
  article .p-4 {
    padding: 0.6rem !important;
  }
  /* 角色标签 — 小屏自然流布局，作为文字上方标题 */
  article .-top-2 {
    position: static !important;
    display: block;
    margin: 0 0.5rem 0.2rem 0.5rem;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: calc(100% - 1rem);
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent !important;
    color: #c9a96e;
  }

  /* 内嵌立绘 — 小屏不浮动，居中显示 */
  article .float-right.size-30 {
    float: none !important;
    display: block !important;
    margin: 0.5rem auto !important;
    width: 90px !important;
    height: 90px !important;
  }

  /* 背景图 — 全视口宽度 */
  figure.bg {
    margin-left: calc(-50vw + 50%) !important;
    width: 100vw !important;
  }
  figure.bg img {
    width: 100%;
    height: auto;
  }

  .schedule-block-inner {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem 0.4rem 0.75rem;
  }

  .credits-block-inner {
    font-size: 0.8rem;
    padding: 0.75rem 1rem;
    max-width: 98%;
  }

  .intro {
    font-size: 0.85rem;
  }

  .progress-container {
    height: 28px;
  }

  .banner-logo {
    width: 150px;
  }
}
