/* ============================================================
   中国妖怪大全 · 神鬼妖异录
   东方水墨 × 古籍风  |  移动端优先响应式
   ============================================================ */

:root {
  --paper: #f4ecdc;
  --paper-deep: #ece0c8;
  --paper-light: #faf5e9;
  --ink: #2b2722;
  --ink-soft: #55483a;
  --ink-faint: #8a7a66;
  --cinnabar: #a83c2c;
  --cinnabar-dark: #8c2f22;
  --gold: #b48a3c;
  --jade: #3d5a52;
  --line: rgba(43, 39, 34, .18);
  --shadow: 0 2px 10px rgba(60, 45, 25, .10);
  --shadow-lift: 0 8px 28px rgba(60, 45, 25, .18);
  --radius: 12px;
  --font-title: "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif SC", "Songti SC", serif;
  --font-body: "Noto Serif SC", "Songti SC", "SimSun", "Microsoft YaHei", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(180, 138, 60, .08), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(168, 60, 44, .06), transparent 50%),
    var(--paper);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.main, .site-header, .bottom-nav, .search-panel { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
img { display: block; max-width: 100%; }

/* ============ 顶部栏 ============ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244,236,220,.97);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
}
.btn-back {
  font-size: 30px; line-height: 1; color: var(--ink-soft);
  padding: 2px 10px 6px; border-radius: 8px;
  display: none;
}
.btn-back:hover { background: rgba(43,39,34,.06); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-seal {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--cinnabar); color: var(--paper-light);
  font-family: var(--font-title); font-size: 22px;
  border-radius: 8px 8px 8px 2px;
  box-shadow: inset 0 0 0 2px rgba(250,245,233,.35);
  transform: rotate(-3deg);
}
.brand-text h1 {
  font-family: var(--font-title); font-size: 20px; font-weight: 700;
  letter-spacing: 2px; line-height: 1.3;
}
.brand-text p { font-size: 11px; color: var(--ink-faint); letter-spacing: 1px; }
.btn-search-toggle {
  margin-left: auto;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 18px; color: var(--paper-light);
  background: var(--cinnabar);
  font-family: var(--font-title);
  display: grid; place-items: center;
}
.btn-search-toggle:hover { background: var(--cinnabar-dark); }

/* ============ 搜索面板 ============ */
.search-panel {
  max-width: 1200px; margin: 0 auto;
  padding: 12px 16px 14px;
  border-bottom: 1px dashed var(--line);
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
}
.search-box:focus-within { border-color: var(--cinnabar); }
.search-icon { font-size: 15px; opacity: .7; }
.search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
}
.search-box input::placeholder { color: var(--ink-faint); }
.search-clear { font-size: 20px; color: var(--ink-faint); padding: 0 4px; }
.search-clear:hover { color: var(--cinnabar); }
.hot-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.hot-tags .hot {
  font-size: 12px; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 12px; background: var(--paper-light);
}
.hot-tags .hot:hover { color: var(--cinnabar); border-color: var(--cinnabar); }

/* ============ 主内容 ============ */
.main {
  max-width: 1200px; margin: 0 auto;
  padding: 20px 16px 90px;
  min-height: 70vh;
}

/* 视图切换动画 */
.view { animation: viewIn .35s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ============ 首页 ============ */
.hero {
  text-align: center;
  padding: 34px 10px 26px;
  position: relative;
}
.hero::after {
  content: "";
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  width: 120px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cinnabar), transparent);
}
.hero .hero-mark {
  display: inline-block;
  font-family: var(--font-title); font-size: 52px; font-weight: 700;
  letter-spacing: 10px; color: var(--ink);
  text-shadow: 0 1px 0 rgba(250,245,233,.6);
  position: relative;
}
.hero .hero-mark::before,
.hero .hero-mark::after {
  content: "❖"; font-size: 16px; color: var(--gold);
  position: absolute; top: 20px;
}
.hero .hero-mark::before { left: -28px; }
.hero .hero-mark::after { right: -28px; }
.hero .hero-sub {
  margin-top: 10px; font-size: 13px; color: var(--ink-faint);
  letter-spacing: 3px;
}
.hero .hero-quote {
  margin: 18px auto 0; max-width: 560px;
  font-size: 13px; color: var(--ink-soft);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 10px 6px;
}

/* 四卷入口 */
.volume-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-top: 22px;
}
.volume-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper-light);
  box-shadow: var(--shadow);
  padding: 16px 8px 14px;
  text-align: center;
  transition: transform .2s, box-shadow .2s;
  cursor: pointer;
}
.volume-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.volume-card .v-char {
  font-family: var(--font-title); font-size: 44px; font-weight: 700;
  line-height: 1.2;
}
.volume-card .v-count {
  display: inline-block; margin-top: 6px;
  font-size: 11px; color: var(--ink-faint);
  background: rgba(43,39,34,.05);
  border-radius: 999px; padding: 1px 10px;
}
.volume-card .v-sub {
  margin-top: 4px; font-size: 12px; color: var(--ink-soft); letter-spacing: 1px;
}
.v-神 { color: #7a5a1e; }
.v-怪 { color: #3d5a52; }
.v-鬼 { color: #4a3b63; }
.v-妖 { color: #a83c2c; }
.volume-card .v-seal {
  position: absolute; top: 8px; right: 8px;
  font-family: var(--font-title); font-size: 11px;
  border: 1.5px solid currentColor; border-radius: 4px;
  padding: 0 6px; opacity: .65; letter-spacing: 2px;
}

/* 分类章节 */
.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 30px 0 14px;
}
.section-title .st-seal {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 1.5px solid var(--cinnabar); color: var(--cinnabar);
  border-radius: 6px; font-family: var(--font-title); font-size: 15px;
  transform: rotate(-3deg);
}
.section-title h2 { font-family: var(--font-title); font-size: 20px; letter-spacing: 2px; }
.section-title .st-line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.section-title .st-more { font-size: 12px; color: var(--ink-faint); }
.section-title .st-more:hover { color: var(--cinnabar); }

.category-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.category-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-light); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px;
  font-size: 13px; color: var(--ink-soft);
  box-shadow: var(--shadow);
  transition: transform .15s;
  cursor: pointer;
}
.category-chip:hover { transform: translateY(-2px); color: var(--cinnabar); border-color: var(--cinnabar); }
.category-chip .cc-char {
  font-family: var(--font-title); font-size: 18px; color: var(--cinnabar);
  border: 1px solid var(--cinnabar); border-radius: 6px; padding: 0 5px;
}
.category-chip .cc-num { font-size: 11px; color: var(--ink-faint); }

/* 首页精选 */
.feature-strip {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-top: 14px;
}

/* ============ 妖怪卡片 ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.yaoguai-card {
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  animation: cardIn .4s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.yaoguai-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.card-media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(ellipse at center, #efe6d2 0%, #e4d7ba 100%);
}
.card-media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s ease;
}
.yaoguai-card:hover .card-media img { transform: scale(1.06); }
.card-cat {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; color: var(--paper-light);
  background: rgba(43,39,34,.72);
  border-radius: 4px; padding: 1px 8px;
  letter-spacing: 2px; backdrop-filter: blur(2px);
}
.card-body { padding: 9px 12px 11px; }
.card-body .c-name {
  font-family: var(--font-title); font-size: 17px; font-weight: 700;
  letter-spacing: 1px; line-height: 1.4;
}
.card-body .c-src {
  font-size: 11px; color: var(--ink-faint);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 无图占位卡 */
.card-media.placeholder {
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(168,60,44,.10), transparent 50%),
    linear-gradient(160deg, #efe6d2, #e2d4b6);
}
.placeholder .ph-char {
  font-family: var(--font-title);
  font-size: 64px; font-weight: 700;
  color: rgba(43,39,34,.75);
  text-shadow: 0 2px 6px rgba(90,70,40,.2);
  line-height: 1;
}
.placeholder .ph-ring {
  position: absolute; inset: 12px;
  border: 1px solid rgba(168,60,44,.28);
  border-radius: 50%;
}
.placeholder .ph-ring::after {
  content: ""; position: absolute; inset: 8px;
  border: 1px dashed rgba(180,138,60,.4);
  border-radius: 50%;
}
.placeholder .ph-seal {
  position: absolute; bottom: 10px; right: 12px;
  font-family: var(--font-title); font-size: 11px;
  color: var(--cinnabar);
  border: 1.5px solid var(--cinnabar);
  border-radius: 4px; padding: 0 6px; opacity: .8;
}

/* ============ 列表页头部 ============ */
.list-head { margin-bottom: 16px; }
.list-head h2 {
  font-family: var(--font-title); font-size: 26px; letter-spacing: 3px;
  display: flex; align-items: center; gap: 10px;
}
.list-head h2 .lh-seal {
  border: 2px solid var(--cinnabar); color: var(--cinnabar);
  border-radius: 8px; padding: 0 8px;
  font-size: 16px; transform: rotate(-3deg);
}
.list-head p { color: var(--ink-faint); font-size: 13px; margin-top: 6px; letter-spacing: 1px; }
.list-head .count-badge {
  display: inline-block; margin-left: 8px;
  background: var(--cinnabar); color: var(--paper-light);
  border-radius: 999px; font-size: 12px; padding: 1px 12px;
  vertical-align: middle;
}

/* 分类标签栏（横向滚动） */
.cat-scroll {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-width: none;
}
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-scroll .cs-tab {
  flex: none;
  font-size: 13px; color: var(--ink-soft);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 16px;
  white-space: nowrap;
  cursor: pointer;
}
.cat-scroll .cs-tab.active {
  background: var(--ink); color: var(--paper-light); border-color: var(--ink);
}

/* ============ 详情页 ============ */
.detail-wrap { max-width: 760px; margin: 0 auto; }
.detail-top {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.detail-top .dt-back {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 12px; font-size: 13px; color: var(--ink-soft);
  background: var(--paper-light);
}
.detail-top .dt-back:hover { color: var(--cinnabar); border-color: var(--cinnabar); }
.detail-top .dt-cat {
  font-size: 12px; color: var(--cinnabar);
  border: 1px solid var(--cinnabar); border-radius: 4px;
  padding: 2px 10px; font-family: var(--font-title); letter-spacing: 2px;
}
.detail-top .dt-index { margin-left: auto; font-size: 12px; color: var(--ink-faint); }

.detail-hero {
  text-align: center;
  background: linear-gradient(180deg, rgba(250,245,233,.7), transparent);
  padding: 10px 0 18px;
  position: relative;
}
.detail-hero h1 {
  font-family: var(--font-title);
  font-size: 40px; font-weight: 700; letter-spacing: 6px;
  text-indent: 6px;
}
.detail-hero .dh-seal {
  display: inline-block; margin-top: 10px;
  border: 2px solid var(--cinnabar); color: var(--cinnabar);
  border-radius: 6px; padding: 1px 12px;
  font-family: var(--font-title); font-size: 13px; letter-spacing: 3px;
  transform: rotate(-2deg);
}

/* 裱框主图 */
.frame {
  background: linear-gradient(135deg, #f8f2e2, #efe4ca);
  border: 1px solid var(--line);
  padding: 12px;
  box-shadow: var(--shadow);
  border-radius: 4px;
  position: relative;
}
.frame::before {
  content: ""; position: absolute; inset: 6px;
  border: 1px solid rgba(180,138,60,.5);
  pointer-events: none;
}
.frame img {
  width: 100%; max-height: 60vh; object-fit: contain;
  margin: 0 auto;
}
.frame .frame-caption {
  text-align: center; font-size: 11px; color: var(--ink-faint);
  padding-top: 8px; letter-spacing: 2px;
}
/* 无图时的详情占位 */
.frame.placeholder { min-height: 320px; display: grid; place-items: center; }
.frame.placeholder .ph-char { font-size: 120px; color: rgba(43,39,34,.7); }
.frame.placeholder .ph-note {
  text-align: center; font-size: 12px; color: var(--ink-faint);
  margin-top: 8px; letter-spacing: 2px;
}

/* 详情正文 */
.detail-body { margin-top: 22px; }
.detail-body .summary {
  font-size: 15.5px; color: var(--ink);
  text-align: justify;
}
.detail-body .summary p + p { margin-top: 10px; }

.sec-block { margin-top: 26px; }
.sec-block .sec-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-title);
  font-size: 19px; font-weight: 700; letter-spacing: 3px;
  margin-bottom: 10px;
}
.sec-block .sec-title::before {
  content: ""; width: 4px; height: 20px;
  background: var(--cinnabar);
  border-radius: 2px;
}
.sec-block .sec-content {
  font-size: 15px; color: var(--ink-soft);
  text-align: justify;
  background: rgba(250,245,233,.5);
  border-left: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
}
.sec-block .sec-content p + p { margin-top: 8px; }

/* 出处引文 */
.source-block {
  margin-top: 30px;
  background:
    linear-gradient(135deg, rgba(168,60,44,.05), rgba(180,138,60,.05)),
    var(--paper-light);
  border: 1px solid rgba(168,60,44,.25);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.source-block .src-title {
  font-family: var(--font-title); font-size: 15px; font-weight: 700;
  color: var(--cinnabar);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.source-block .src-title::before {
  content: "❖"; font-size: 12px;
}
.source-block .src-text {
  font-size: 14px; color: var(--ink-soft);
  text-align: justify; line-height: 2;
}

/* 上下篇导航 */
.detail-nav {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 34px; padding-top: 18px;
  border-top: 1px dashed var(--line);
}
.detail-nav .dn-btn {
  flex: 1; max-width: 48%;
  background: var(--paper-light); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; color: var(--ink-soft);
  text-align: center;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  transition: border-color .15s, color .15s;
  cursor: pointer;
}
.detail-nav .dn-btn:hover { color: var(--cinnabar); border-color: var(--cinnabar); }
.detail-nav .dn-btn.disabled { opacity: .35; pointer-events: none; }
.detail-nav .dn-label { font-size: 11px; color: var(--ink-faint); display: block; margin-bottom: 2px; }

/* ============ 搜索结果 / 空状态 ============ */
.empty-state {
  text-align: center; padding: 70px 20px;
  color: var(--ink-faint);
}
.empty-state .es-char {
  font-family: var(--font-title); font-size: 60px; opacity: .4;
}
.empty-state p { margin-top: 10px; font-size: 14px; letter-spacing: 2px; }
.result-info { font-size: 13px; color: var(--ink-faint); margin-bottom: 14px; letter-spacing: 1px; }
.result-info b { color: var(--cinnabar); }

/* ============ 摸签弹层 ============ */
/* hidden 属性必须真正隐藏（否则遮罩常驻拦截点击） */
.modal-mask[hidden] { display: none !important; }
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(30, 24, 16, .62);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lottery-card {
  width: 100%; max-width: 360px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(180,138,60,.12), transparent 60%),
    var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(20,14,8,.4);
  overflow: hidden;
  animation: popIn .45s cubic-bezier(.2, 1.4, .4, 1);
  text-align: center;
  position: relative;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.75) rotate(-4deg); }
  to { opacity: 1; transform: none; }
}
.lottery-card .lot-head {
  background: var(--cinnabar); color: var(--paper-light);
  font-family: var(--font-title); letter-spacing: 6px;
  font-size: 14px; padding: 9px 0;
  text-indent: 6px;
}
.lottery-card .lot-media { position: relative; }
.lottery-card .lot-media img {
  width: 100%; height: 200px; object-fit: cover;
}
.lottery-card .lot-media .lot-ph {
  height: 200px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #efe6d2, #e0d1b0);
  font-family: var(--font-title); font-size: 96px;
  color: rgba(43,39,34,.72);
}
.lottery-card .lot-body { padding: 16px 20px 20px; }
.lottery-card .lot-name {
  font-family: var(--font-title); font-size: 28px; font-weight: 700;
  letter-spacing: 4px; text-indent: 4px;
}
.lottery-card .lot-cat {
  display: inline-block; margin-top: 6px;
  font-size: 11px; color: var(--cinnabar);
  border: 1px solid var(--cinnabar); border-radius: 4px;
  padding: 0 10px; letter-spacing: 2px;
}
.lottery-card .lot-quote {
  margin-top: 10px; font-size: 13px; color: var(--ink-soft);
  text-align: justify;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.lottery-card .lot-btns { display: flex; gap: 10px; margin-top: 16px; }
.lottery-card .lot-btn {
  flex: 1; padding: 10px 0;
  border-radius: 10px; font-size: 14px; letter-spacing: 2px;
  font-family: var(--font-title);
}
.lot-btn-primary { background: var(--cinnabar); color: var(--paper-light); }
.lot-btn-primary:hover { background: var(--cinnabar-dark); }
.lot-btn-ghost { border: 1px solid var(--line); color: var(--ink-soft); }
.lot-btn-ghost:hover { border-color: var(--cinnabar); color: var(--cinnabar); }
.lottery-card .lot-close {
  position: absolute; top: 42px; right: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(30,24,16,.5); color: var(--paper-light);
  font-size: 16px; display: grid; place-items: center;
  z-index: 2;
}

/* ============ 底部导航 ============ */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex;
  background: rgba(250,245,233,.97);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px;
  color: var(--ink-faint);
  font-size: 11px; letter-spacing: 1px;
  font-family: var(--font-body);
}
.nav-item.active { color: var(--cinnabar); }
.nav-ico {
  font-family: var(--font-title); font-size: 19px; line-height: 1.2;
  border: 1.5px solid currentColor; border-radius: 6px;
  padding: 0 7px;
}
.nav-item.active .nav-ico { background: var(--cinnabar); color: var(--paper-light); border-color: var(--cinnabar); }

/* 滚动进度条 */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 2px; z-index: 70;
  width: 0;
  background: linear-gradient(90deg, var(--cinnabar), var(--gold));
  transition: width .1s linear;
}

/* ============ 响应式 ============ */
@media (min-width: 700px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .volume-grid { grid-template-columns: repeat(4, 1fr); }
  .feature-strip { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .main { padding: 28px 28px 60px; }
  .brand-text h1 { font-size: 23px; }
}
@media (min-width: 1000px) {
  .card-grid { grid-template-columns: repeat(4, 1fr); }
  .volume-card { padding: 22px 8px 18px; }
  .volume-card .v-char { font-size: 54px; }
  .bottom-nav { display: none; }
  .btn-back { display: inline-block; }
  .main { padding-top: 34px; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
