/* ============================================================
   鸡国图书馆 · 纯白极简风样式
   想改颜色就改下面 :root 里的几个变量，全站会一起变
   ============================================================ */

/* 引入网站专属字体：汇文明朝体（fonts/huiwen-mincho.woff2） */
@font-face {
  font-family: "Huiwen";
  src: url("../fonts/huiwen-mincho.woff2") format("woff2");
  font-display: swap; /* 字体加载时先用系统字体显示，加载完自动替换 */
}

:root {
  --bg: #ffffff;           /* 背景：纯白 */
  --card: #ffffff;         /* 卡片：白色 */
  --ink: #1a1a1a;          /* 正文：近黑 */
  --ink-light: #9a9a9a;    /* 次要文字：灰 */
  --line: #ececec;         /* 细线/边框：浅灰 */
  --hover-line: #1a1a1a;   /* 鼠标悬停时的强调线 */
}

/* ---------- 全局 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 全站图片：禁止鼠标拖动保存（配合 js/protect.js） */
img {
  -webkit-user-drag: none;
  user-select: none;
}

body {
  /* 全站统一使用汇文明朝体，加载失败时用系统宋体类字体兜底 */
  font-family: "Huiwen", "Songti SC", "SimSun", "宋体", serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* 标题同样使用汇文明朝体 */
h1, h2, .back-link {
  font-family: "Huiwen", "Songti SC", "SimSun", "宋体", serif;
}

/* 细分隔线 */
.dashed-line {
  border: none;
  border-top: 1px solid var(--line);
  margin: 28px auto;
  max-width: 640px;
}

/* ---------- 首页：头部 ---------- */
.site-header {
  text-align: center;
  padding: 72px 20px 8px;
}

.header-tape {
  font-size: 13px;
  color: var(--ink-light);
  letter-spacing: 4px;
}

.site-title {
  font-size: 44px;
  font-weight: normal; /* 自定义字体只有一种粗细，避免浏览器生成假粗体 */
  letter-spacing: 12px;
  margin: 14px 0 4px;
}

/* ---------- 密码门（index.html） ---------- */
.gate-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.gate {
  text-align: center;
  padding: 24px;
}

.gate-title {
  font-size: 40px;
  letter-spacing: 6px;
  margin-bottom: 22px;
}

.gate-subtitle {
  font-size: 15px;
  color: var(--ink-light);
  line-height: 2;
  margin-bottom: 26px;
}

/* 密码输入框：细长的小矩形 */
.gate-form {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.gate-input {
  width: 200px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px;
  letter-spacing: 4px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.gate-input:focus {
  border-color: var(--ink);
}

.gate-btn {
  height: 40px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s ease;
}

.gate-btn:hover {
  opacity: 0.85;
}

.gate-error {
  margin-top: 14px;
  font-size: 13px;
  color: #c0392b;
  min-height: 20px; /* 没错误时也占位，避免页面跳动 */
}

/* 密码错误时输入框抖动一下 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.gate-input.shake {
  animation: shake 0.25s ease;
  border-color: #c0392b;
}

/* 密码门下方的提示小字 */
.gate-note {
  margin-top: 26px;
  font-size: 12px;
  color: var(--ink-light);
  line-height: 1.9;
}

/* 密码门的跳舞皮啵：固定位置，不遮文字、不挡点击 */
.gate-dance {
  position: fixed;
  width: 280px;
  pointer-events: none;
}

/* 左上角一只 */
.gate-dance-tl {
  left: 6%;
  top: 8%;
}

/* 右下角一只 */
.gate-dance-br {
  right: 7%;
  bottom: 10%;
}

/* 屏幕不够宽时缩小或藏起来，避免压住文字 */
@media (max-width: 1100px) {
  .gate-dance {
    width: 170px;
  }

  .gate-dance-tl {
    left: 3%;
  }

  .gate-dance-br {
    right: 3%;
  }
}

@media (max-width: 760px) {
  .gate-dance {
    display: none;
  }
}

/* ---------- 规则页（rules.html） ---------- */
.rules {
  max-width: 560px;
}

.rules-title {
  font-size: 34px;
  letter-spacing: 3px;
  line-height: 1.8;
  margin-bottom: 28px;
}

/* 规则条目：在居中的页面里靠左排，方便阅读 */
.rules-list {
  text-align: left;
  line-height: 2.1;
  font-size: 19px;
  padding-left: 28px;
  margin-bottom: 20px;
}

.rules-warning {
  font-size: 17px;
  color: #c0392b;
  margin-bottom: 32px;
}

/* 按钮和旁边的保证小字 */
.rules-agree {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.rules-promise {
  font-size: 14px;
  color: var(--ink-light);
  line-height: 1.8;
  text-align: left;
}

/* 手机上按钮和保证书上下排 */
@media (max-width: 600px) {
  .rules-title {
    font-size: 26px;
  }

  .rules-list {
    font-size: 17px;
  }

  .rules-agree {
    flex-direction: column;
  }

  .rules-promise {
    text-align: center;
  }
}

/* ---------- 欢迎页（welcome.html） ---------- */
.welcome-note {
  font-size: 16px;
  line-height: 2.1;
  margin-bottom: 30px;
}

/* 规则页/欢迎页右侧的装饰图：不遮文字、不挡点击 */
.page-deco {
  position: fixed;
  pointer-events: none;
}

.page-deco-right {
  right: 5%;
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
}

/* 屏幕不够宽时缩小或藏起来，避免压住文字 */
@media (max-width: 1100px) {
  .page-deco-right {
    width: 160px;
    right: 3%;
  }
}

@media (max-width: 860px) {
  .page-deco-right {
    display: none;
  }
}

/* ---------- 首页：轮播图（仿 B 站推荐位） ---------- */
.carousel {
  position: relative;
  max-width: 640px;
  margin: 8px auto 36px; /* 底部留白，把书架自然推到下方 */
  padding: 0 24px;
  overflow: hidden; /* 关键：只露出一张图的"窗口"，其余藏起来 */
}

/* 装着所有图的"长条"，通过左右平移来切换显示哪一张 */
.carousel-track {
  display: flex;
  transition: transform 0.5s ease; /* 滑动切换动画 */
}

.carousel-slide {
  min-width: 100%;
  border: 1px solid var(--line);
  overflow: hidden;
}

.carousel-slide img {
  width: 100%;
  height: auto; /* 按图片原始比例完整显示，不裁剪 */
  display: block;
}

/* 左右箭头：平时半透明，鼠标悬停整个轮播时变清晰 */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s ease, background 0.25s ease;
  z-index: 2;
}

.carousel:hover .carousel-btn {
  opacity: 1;
}

.carousel-btn:hover {
  background: rgba(255, 255, 255, 0.95);
}

.carousel-btn.prev {
  left: 36px;
}

.carousel-btn.next {
  right: 36px;
}

/* 底部小圆点 */
.carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 2;
}

.carousel-dot {
  width: 18px;
  height: 4px;
  border-radius: 2px;
  border: none;
  background: rgba(26, 26, 26, 0.25);
  cursor: pointer;
  padding: 0;
  transition: background 0.25s ease, width 0.25s ease;
}

.carousel-dot.active {
  width: 28px;
  background: var(--ink);
}

/* ---------- 首页：书架 ---------- */
.shelf {
  max-width: 1080px;
  margin: 24px auto 80px;
  padding: 0 24px;
}

/* 书架名：居中，和馆名一样的字体 */
.shelf-name {
  text-align: center;
  font-size: 26px;
  letter-spacing: 6px;
  margin: 36px 0 28px;
}

/* 第一个书架名不用太大的上间距 */
.shelf-section:first-child .shelf-name {
  margin-top: 8px;
}

/* 书架之间的分隔横线 */
.shelf-divider {
  max-width: 100%;
  margin: 48px auto 8px;
}

/* 一个书架里的书，网格排列 */
.shelf-grid {
  display: grid;
  /* 自动排版：卡片最小 260px 宽，空间够就多放几列 */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 48px 32px;
}

.empty-tip {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-light);
  padding: 40px 0;
}

/* ---------- 首页：书卡 ---------- */
.book-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease;
}

/* 鼠标放上去：微微上浮 */
.book-card:hover {
  transform: translateY(-4px);
}

.cover-wrap {
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color 0.25s ease;
}

.book-card:hover .cover-wrap {
  border-color: var(--hover-line);
}

.cover-wrap img {
  width: 100%;
  height: auto; /* 按封面图片原始比例完整显示，不裁剪 */
  display: block;
}

.card-text {
  padding: 14px 2px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 19px;
  font-weight: normal; /* 自定义字体只有一种粗细，避免浏览器生成假粗体 */
}

.card-date {
  font-size: 13px;
  color: var(--ink-light);
  white-space: nowrap;
}

/* ---------- 阅读页 ---------- */
.reader-body {
  display: flex;
  flex-direction: column;
}

.reader-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
}

.back-link {
  text-decoration: none;
  color: var(--ink);
  font-size: 15px;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.back-link:hover {
  border-bottom-color: var(--ink);
}

.reader-title {
  flex: 1;
  text-align: center;
  font-size: 22px;
  font-weight: normal; /* 自定义字体只有一种粗细，避免浏览器生成假粗体 */
  letter-spacing: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-indicator {
  font-size: 13px;
  color: var(--ink-light);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.reader-main {
  flex: 1;
  position: relative; /* 让水印可以贴在书页两侧 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px 24px 20px;
}

/* 防盗水印：横排、每行两个字，浮在书页两侧的空白处，不遮书页 */
.watermark {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Huiwen", "Songti SC", "SimSun", "宋体", serif;
  font-size: 58px;
  line-height: 1.35; /* 两行之间的间距 */
  letter-spacing: 0.15em;
  text-align: center;
  color: var(--ink);
  opacity: 0; /* 平时隐藏 */
  transition: opacity 0.8s ease;
  pointer-events: none; /* 不挡翻页按钮的点击 */
  user-select: none;
  z-index: 1;
}

.watermark.show {
  opacity: 0.14; /* 浮现时也只是淡淡的一层 */
}

.wm-left {
  left: 84px; /* 贴在左箭头旁边 */
}

.wm-right {
  right: 84px; /* 贴在右箭头旁边 */
}

/* 书页：白底 + 细边框，没有多余装饰 */
.page-frame {
  position: relative; /* 让章节提示标签可以浮在它上方 */
  border: 1px solid var(--line);
  padding: 16px;
  max-width: min(860px, 100%);
}

/* 章节小提示：浮在书页上方的空白处，不遮挡书页，1.5 秒后消失 */
.chapter-toast {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 3px 14px;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--ink-light);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none; /* 不挡鼠标点击 */
  z-index: 2;
}

.chapter-toast.show {
  opacity: 1;
}

/* 页名：书页上方的一行小字（可选，没设置就不显示） */
.page-name {
  text-align: center;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--ink-light);
  padding-bottom: 10px;
}

.page-frame img {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  display: block;
  background: #fff;
}

.page-caption {
  text-align: center;
  font-size: 12px;
  color: var(--ink-light);
  padding-top: 12px;
  letter-spacing: 1px;
}

/* 翻页按钮：白底细线圆钮，悬停变黑 */
.flip-btn {
  position: relative; /* 保证按钮画在水印上层，不被压住 */
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.flip-btn:hover:not(:disabled) {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.flip-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

/* ---------- 手机上的小屏适配 ---------- */
@media (max-width: 600px) {
  .site-header {
    padding: 56px 20px 4px;
  }

  .site-title {
    font-size: 32px;
    letter-spacing: 8px;
  }

  .reader-header {
    flex-wrap: wrap;
    justify-content: center;
    padding: 16px 20px;
  }

  .reader-title {
    order: 3;
    flex-basis: 100%;
    font-size: 18px;
    margin-top: 6px;
  }

  .reader-main {
    gap: 10px;
    padding: 20px 12px 12px;
  }

  .flip-btn {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  /* 手机上两侧空间小，水印字号跟着缩小 */
  .watermark {
    font-size: 30px;
  }
}
