/* ==========================================================================
   拾卷 · 四大名著阅读空间
   style.css — 基础设计系统：变量、重置、排版、按钮、表单、通用组件
   ========================================================================== */

:root {
  /* 色彩 */
  --paper: #f6f3ec;
  --paper-2: #efe9dd;
  --paper-3: #e9e2d4;
  --card: #ffffff;
  --ink: #292720;
  --ink-2: #423e35;
  --muted: #777268;
  --muted-2: #968f81;
  --accent: #947650;
  --accent-2: #7c6040;
  --accent-soft: #c9b392;
  --line: #e6e0d5;
  --line-strong: #d8cfbf;
  --dark: #302e28;
  --dark-2: #3b3830;
  --red: #9e3b33;
  --green: #3f5a4e;
  --amber: #a06b2a;

  /* 圆角与阴影 */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(41, 39, 32, 0.04);
  --shadow-sm: 0 6px 18px -10px rgba(41, 39, 32, 0.18);
  --shadow-md: 0 24px 50px -28px rgba(41, 39, 32, 0.35);
  --shadow-lg: 0 40px 80px -40px rgba(41, 39, 32, 0.45);

  /* 尺寸与动效 */
  --header-h: 78px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-en: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
}

/* ---------- 重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.032'/%3E%3C/svg%3E");
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.8;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.is-locked {
  overflow: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.25s var(--ease);
}

img,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

input,
select,
textarea {
  border-radius: 0;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

::selection {
  background: rgba(148, 118, 80, 0.22);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* ---------- 滚动条 ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid var(--paper);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-soft);
}

/* ---------- 布局工具 ---------- */
.container {
  width: min(1180px, calc(100% - 64px));
  margin-inline: auto;
}

.container--narrow {
  width: min(940px, calc(100% - 64px));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 500;
  padding: 10px 18px;
  background: var(--dark);
  color: var(--paper);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transform: translateY(-160%);
  transition: transform 0.25s var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- 排版 ---------- */
.display {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.04em;
}

.lead {
  font-size: 17px;
  line-height: 1.9;
  color: var(--muted);
}

.text-accent {
  color: var(--accent-2);
}

.text-muted {
  color: var(--muted);
}

.serif {
  font-family: var(--font-serif);
}

.en {
  font-family: var(--font-en);
  letter-spacing: 0.04em;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 26px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease),
    color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--dark);
  border-color: var(--dark);
  color: var(--paper);
  box-shadow: 0 10px 24px -16px rgba(41, 39, 32, 0.8);
}

.btn--primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  box-shadow: 0 16px 30px -18px rgba(124, 96, 64, 0.8);
}

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--accent:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.35);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn--ghost:hover {
  background: #fff;
  border-color: var(--accent-soft);
  color: var(--accent-2);
}

.btn--light {
  background: var(--paper);
  border-color: var(--paper);
  color: var(--dark);
}

.btn--light:hover {
  background: #fff;
  border-color: #fff;
}

.btn--sm {
  min-height: 38px;
  padding: 0 16px;
  font-size: 13px;
  gap: 7px;
}

.btn--sm svg {
  width: 14px;
  height: 14px;
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* 文字链接 */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--accent-2);
}

.link-arrow svg {
  width: 15px;
  height: 15px;
  transition: transform 0.35s var(--ease);
}

.link-arrow:hover {
  color: var(--ink);
}

.link-arrow:hover svg {
  transform: translateX(4px);
}

/* ---------- 标签与徽标 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  font-size: 11.5px;
  line-height: 1.6;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.tag--accent {
  border-color: rgba(148, 118, 80, 0.28);
  background: rgba(148, 118, 80, 0.07);
  color: var(--accent-2);
}

.tag--dark {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(246, 243, 236, 0.72);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(246, 243, 236, 0.92);
  border: 1px solid rgba(230, 224, 213, 0.9);
  font-size: 11.5px;
  line-height: 1.6;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  backdrop-filter: blur(6px);
}

.status-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge[data-status="已读"] {
  color: var(--green);
}

.status-badge[data-status="在读"] {
  color: var(--amber);
}

.status-badge[data-status="计划阅读"] {
  color: var(--muted-2);
}

/* ---------- 表单 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field > label,
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-2);
}

.field .required {
  color: var(--red);
  margin-left: 2px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.7;
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--accent-soft);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(148, 118, 80, 0.13);
}

.textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.9;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.select-wrap .select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  padding: 0 40px 0 16px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 13.5px;
  cursor: pointer;
}

.select-wrap .select-icon {
  position: absolute;
  right: 14px;
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.field--full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.form-hint {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted-2);
}

.form-error {
  min-height: 20px;
  margin: 0;
  font-size: 12.5px;
  color: var(--red);
}

/* 搜索框 */
.search-box {
  position: relative;
  flex: 1 1 260px;
  min-width: 220px;
}

.search-box > .search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}

.search-box .input {
  min-height: 46px;
  padding-left: 43px;
  padding-right: 42px;
  background: #fff;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  transform: translateY(-50%);
  border-radius: 50%;
  color: var(--muted);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.search-clear svg {
  width: 14px;
  height: 14px;
}

.search-clear:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.search-box.has-value .search-clear {
  display: grid;
}

/* 筛选 chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease),
    color 0.25s var(--ease);
}

.chip:hover {
  border-color: var(--accent-soft);
  color: var(--accent-2);
  background: #fff;
}

.chip.is-active {
  background: var(--dark);
  border-color: var(--dark);
  color: var(--paper);
}

.chip-count {
  font-size: 10.5px;
  opacity: 0.62;
}

/* ---------- 加载与状态 ---------- */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(105deg, var(--paper-2) 12%, #fbf8f1 28%, var(--paper-2) 44%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

.skeleton-card {
  min-height: 360px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.skeleton-card .skeleton-cover {
  aspect-ratio: 3 / 4;
  margin-bottom: 20px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 10px;
}

.skeleton-line.is-title {
  width: 56%;
  height: 20px;
  margin-bottom: 14px;
}

.skeleton-line.is-short {
  width: 38%;
}

.skeleton-line.is-medium {
  width: 78%;
}

.empty-state {
  padding: 72px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.38);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--accent);
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty-state h3 {
  font-size: 24px;
  letter-spacing: 0.03em;
}

.empty-state p {
  max-width: 46ch;
  margin: 10px auto 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.data-error {
  max-width: 760px;
  margin: 32px auto;
  padding: 36px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.data-error h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

.data-error p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
  margin-bottom: 10px;
}

.data-error code {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--paper-2);
  color: var(--accent-2);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
}

.data-error .btn {
  margin-top: 18px;
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 40px);
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--dark);
  color: var(--paper);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  letter-spacing: 0.03em;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 16px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), visibility 0.3s;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--accent-soft);
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s;
}

.modal.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 30, 26, 0.62);
  backdrop-filter: blur(5px);
}

.modal-panel {
  position: relative;
  width: min(960px, 100%);
  max-height: min(88vh, 960px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  transform: translateY(18px) scale(0.985);
  transition: transform 0.45s var(--ease);
}

.modal.is-open .modal-panel {
  transform: none;
}

.modal-panel--narrow {
  width: min(720px, 100%);
}

.modal-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 16px 0;
  background: linear-gradient(180deg, var(--paper) 62%, rgba(246, 243, 236, 0) 100%);
  pointer-events: none;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink-2);
  pointer-events: auto;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.modal-close:hover {
  background: var(--dark);
  border-color: var(--dark);
  color: var(--paper);
  transform: rotate(90deg);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

/* ---------- 返回顶部 ---------- */
.to-top {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 90;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: var(--dark);
  color: var(--paper);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease),
    visibility 0.3s, background-color 0.25s var(--ease);
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.to-top:hover {
  background: var(--accent-2);
}

.to-top svg {
  width: 17px;
  height: 17px;
}

/* ---------- 入场动画 ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
  transition-delay: var(--delay, 0ms);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- 打印 ---------- */
@media print {
  .site-header,
  .site-footer,
  .to-top,
  .toast,
  .modal,
  .hero-actions,
  .hero-visual {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 本地文件提示 / 导航锁定 ---------- */
body.is-nav-open {
  overflow: hidden;
}

.file-notice {
  padding: 10px 20px;
  border-bottom: 1px solid rgba(158, 59, 51, 0.18);
  background: rgba(158, 59, 51, 0.07);
  color: var(--red);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.file-notice code {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.65);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11.5px;
}

.book-grid > .data-error,
.note-grid > .data-error,
.quote-grid > .data-error,
.quote-grid--home > .data-error {
  grid-column: 1 / -1;
}


.noscript-notice {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(148, 118, 80, 0.25);
  background: #fff8e8;
  color: #7c6040;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}
