/* ============================================================
   绯月画廊 · Scarlet Moon Gallery
   暗黑哥特风单页图集 — 纯前端，无任何依赖
   ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  /* 底色：近黑的冷紫黑 */
  --bg:            #0a070b;
  --bg-soft:       #0d0a0e;
  --panel:         #131016;
  --panel-2:       #1a151c;
  --line:          #2a2028;
  --line-soft:     #1f181f;

  /* 暗红主调 */
  --blood:         #8b1a2b;
  --blood-deep:    #5c0f1d;
  --blood-glow:    rgba(139, 26, 43, .45);

  /* 灰白文字，刻意压低亮度 */
  --ink:           #b9b2b7;
  --ink-dim:       #8c8489;
  --ink-faint:     #655d64;
  --ink-strong:    #ddd6da;

  /* 社交平台配色（按要求区分） */
  --c-bili:        #e78fb3;
  --c-dy:          #35d6d0;
  --c-xhs:         #d94a52;

  --gap:           16px;
  --head-h:        58px;
  --img-max-h:     400px;

  --ease:          cubic-bezier(.22, .61, .36, 1);
  --font-goth:     "Cinzel Decorative", "Cinzel", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-body:     "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", "Microsoft YaHei", system-ui, serif;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html {
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: .02em;
  background-color: var(--bg);
  /* 极淡的哥特暗纹 + 两侧暗角 */
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, rgba(92, 15, 29, .18), transparent 62%),
    radial-gradient(ellipse 90% 60% at 50% 110%, rgba(60, 12, 24, .14), transparent 60%),
    linear-gradient(180deg, #0a070b 0%, #0b080c 45%, #08060a 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* 全屏暗角 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse 100% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, .55) 100%);
}

img { display: block; border: 0; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--blood-deep); color: var(--ink-strong); }

/* 细哥特滚动条 */
* { scrollbar-width: thin; scrollbar-color: #3a2530 var(--bg); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: #0a070b; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3a2530, #23161d);
  border-radius: 6px;
  border: 2px solid #0a070b;
}
*::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #55293a, #33191f); }

:focus-visible {
  outline: 1px solid var(--blood);
  outline-offset: 2px;
}

/* ---------- 顶部绯色进度线 ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  z-index: 60;
  background: linear-gradient(90deg, var(--blood-deep), var(--blood), #c02a3f);
  box-shadow: 0 0 10px var(--blood-glow);
  transition: width .12s linear;
}

/* ---------- 顶栏 ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, rgba(10, 7, 11, .97) 0%, rgba(10, 7, 11, .88) 70%, rgba(10, 7, 11, .70) 100%);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border-bottom: 1px solid var(--line-soft);
}

.head-inner {
  max-width: 2000px;
  margin: 0 auto;
  padding: 9px 18px 0;
}

/* 品牌标题 */
.brand { display: flex; align-items: baseline; gap: 9px; }

.brand-mark {
  color: var(--blood);
  font-size: 13px;
  text-shadow: 0 0 12px var(--blood-glow);
  align-self: center;
}

.brand-title {
  margin: 0;
  font-family: var(--font-goth);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: .22em;
  color: var(--ink-strong);
  text-shadow: 0 0 18px rgba(139, 26, 43, .35), 0 1px 0 #000;
}
.brand-title em {
  font-family: var(--font-goth);
  font-style: normal;
  font-size: 10px;
  letter-spacing: .3em;
  color: var(--ink-faint);
  margin-left: 12px;
  text-transform: uppercase;
}

/* 分类标签：顺序由 JS 按固定数组生成 */
.tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin-top: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: 0 0 auto;
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 13.5px;
  letter-spacing: .07em;
  padding: 9px 15px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease);
}

.tab .tab-n {
  font-family: var(--font-goth);
  font-size: 10px;
  letter-spacing: .06em;
  color: var(--ink-faint);
  margin-left: 7px;
  transition: color .25s var(--ease);
}

.tab::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -2px;
  width: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--blood), #b3243a, var(--blood), transparent);
  transform: translateX(-50%);
  transition: width .35s var(--ease);
}

.tab:hover { color: var(--ink-strong); background: rgba(139, 26, 43, .07); }
.tab:hover .tab-n { color: var(--ink-dim); }

.tab.is-active {
  color: var(--ink-strong);
  background: linear-gradient(180deg, transparent, rgba(139, 26, 43, .12));
}
.tab.is-active::after { width: 100%; }
.tab.is-active .tab-n { color: var(--blood); }

/* NSFW 标签的警示色 */
.tab[data-cat="NSFW区"] { color: #9c7a7e; }
.tab[data-cat="NSFW区"]::before {
  content: "18+";
  font-family: var(--font-goth);
  font-size: 8px;
  letter-spacing: .08em;
  color: #c05a63;
  border: 1px solid #5c2a30;
  border-radius: 3px;
  padding: 0 3px;
  margin-right: 6px;
  vertical-align: 1px;
}

/* 顶栏右侧信息 */
.head-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 2px 9px;
  border-top: 1px solid var(--line-soft);
  margin-top: 2px;
  flex-wrap: wrap;
}

.meta-count {
  font-family: var(--font-goth);
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--ink-faint);
}
.meta-count b { color: var(--blood); font-weight: 600; }

.meta-btn {
  appearance: none;
  background: linear-gradient(180deg, var(--panel-2), #120e14);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 11.5px;
  letter-spacing: .1em;
  padding: 3px 11px 4px;
  cursor: pointer;
  transition: all .25s var(--ease);
}
.meta-btn:hover {
  color: var(--ink-strong);
  border-color: var(--blood);
  box-shadow: 0 0 14px -2px var(--blood-glow), inset 0 0 12px -6px var(--blood);
  transform: translateY(-1px);
}
.meta-btn:active { transform: translateY(0); }
.meta-btn.danger { color: #b07a80; border-color: #43222a; }
.meta-btn.danger:hover { color: #e9b6bb; border-color: #7d2634; }

/* ---------- 瀑布流舞台 ---------- */
.stage {
  position: relative;
  z-index: 10;
  max-width: 2000px;
  margin: 0 auto;
  padding: 18px 18px 0;
}

.masonry { position: relative; width: 100%; }

.card {
  position: absolute;
  top: 0; left: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: #0b080d;
  cursor: zoom-in;
  /* 只有 transform / box-shadow / border-color 参与动画，绝不影响邻居布局 */
  transition:
    transform .38s var(--ease),
    box-shadow .38s var(--ease),
    border-color .38s var(--ease);
  will-change: transform;
}

/* 卡片尺寸由 JS 按原图比例精确计算（含 max-height 限制），
   object-fit: contain 保证任何极端长宽比都完整显示、绝不拉伸裁剪。
   注意：默认可见，仅当 JS 挂上懒加载观察器后才淡入 —— 
   即使观察器因故不触发，图片也一定会显示，不会留下空框。 */
.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #080608;
  transition: opacity .5s var(--ease), filter .38s var(--ease);
}
.card img.is-lazy { opacity: 0; }
.card img.is-loaded { opacity: 1; }
.card img.is-error { opacity: .25; filter: grayscale(1); }

/* 悬停：自身位置轻微放大 + 阴影，不影响周围 */
.card:hover,
.card:focus-visible {
  transform: scale(1.02);
  z-index: 8;
  border-color: #4a2531;
  box-shadow:
    0 18px 42px -12px rgba(0, 0, 0, .85),
    0 0 0 1px rgba(139, 26, 43, .35),
    0 0 28px -6px var(--blood-glow);
}
.card:hover img { filter: brightness(1.06) saturate(1.04); }

/* 卡片序号（哥特小字，悬停浮现） */
.card-idx {
  position: absolute;
  right: 6px; bottom: 5px;
  font-family: var(--font-goth);
  font-size: 9.5px;
  letter-spacing: .12em;
  color: rgba(220, 210, 215, .72);
  text-shadow: 0 1px 4px #000, 0 0 8px #000;
  opacity: 0;
  transition: opacity .3s var(--ease);
  pointer-events: none;
}
.card:hover .card-idx { opacity: 1; }

/* 卡片入场 */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card.is-new { animation: cardIn .5s var(--ease) both; }

/* 第一轮之外（无限滚动追加的轮次）左上角细标记 */
.round-tag {
  position: absolute;
  left: 0; top: 0;
  padding: 1px 6px 2px;
  font-family: var(--font-goth);
  font-size: 9px;
  letter-spacing: .14em;
  color: rgba(214, 160, 168, .8);
  background: linear-gradient(90deg, rgba(60, 8, 20, .82), rgba(60, 8, 20, 0));
  opacity: 0;
  transition: opacity .3s var(--ease);
  pointer-events: none;
}
.card:hover .round-tag { opacity: 1; }

/* ---------- 无限滚动哨兵 ---------- */
.sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 34px 0 46px;
  color: var(--ink-faint);
  font-size: 12.5px;
  letter-spacing: .14em;
  min-height: 96px;
}

.sentinel-spin {
  width: 15px; height: 15px;
  border: 1px solid #3a2530;
  border-top-color: var(--blood);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 出错提示 ---------- */
.fatal {
  max-width: 620px;
  margin: 60px auto;
  padding: 26px 28px;
  border: 1px solid #43222a;
  border-radius: 3px;
  background: linear-gradient(180deg, #150d11, #0c080b);
  text-align: center;
}
.fatal h2 {
  margin: 0 0 10px;
  font-family: var(--font-goth);
  font-size: 17px;
  letter-spacing: .14em;
  color: #c4757f;
}
.fatal p { margin: 0; color: var(--ink-dim); font-size: 13.5px; line-height: 1.9; }
.fatal code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  color: #d9a7ae;
  background: #1c1216;
  border: 1px solid #33202a;
  border-radius: 2px;
  padding: 1px 5px;
}

/* ---------- 页脚 / 关于导言 ---------- */
.site-foot {
  position: relative;
  z-index: 10;
  margin-top: 30px;
  padding: 40px 18px 34px;
  border-top: 1px solid var(--line-soft);
  background:
    radial-gradient(ellipse 80% 100% at 50% 0%, rgba(92, 15, 29, .16), transparent 65%),
    linear-gradient(180deg, #0b080c, #070509);
  text-align: center;
}

.foot-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 26px;
  color: var(--blood);
  font-size: 13px;
  text-shadow: 0 0 14px var(--blood-glow);
}
.foot-rule::before,
.foot-rule::after {
  content: "";
  height: 1px;
  width: min(150px, 22vw);
  background: linear-gradient(90deg, transparent, #3a2530, transparent);
}

.about { max-width: 860px; margin: 0 auto; }

.about-title {
  margin: 0 0 16px;
  font-family: var(--font-goth);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .26em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.about-title::after {
  content: "";
  display: block;
  width: 46px; height: 1px;
  margin: 12px auto 0;
  background: linear-gradient(90deg, transparent, var(--blood), transparent);
}

/* 导言正文：暗灰白，低调 */
.about-text {
  margin: 0 auto 16px;
  max-width: 780px;
  color: #a49ca2;
  font-size: 14.5px;
  line-height: 2.15;
  /* 手机上自动换行，绝不溢出 */
  overflow-wrap: break-word;
  word-break: break-word;
}

/* 社交账号：可点击 · 悬停高亮 · 小红心 */
.sns {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 2px;
  margin: 2px 1px;
  border: 1px solid transparent;
  border-radius: 3px;
  white-space: nowrap;
  font-weight: 500;
  color: var(--ink-dim);
  transition: color .28s var(--ease), border-color .28s var(--ease),
              background .28s var(--ease), text-shadow .28s var(--ease),
              transform .28s var(--ease);
}

.sns-ico {
  font-size: 10px;
  line-height: 1;
  opacity: .55;
  transform: translateY(-1px);
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}

.sns:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, .025);
}
.sns:hover .sns-ico { opacity: 1; animation: heart .9s ease-in-out infinite; }

@keyframes heart {
  0%, 100% { transform: translateY(-1px) scale(1); }
  45%      { transform: translateY(-2px) scale(1.28); }
}

/* B站 → 粉 */
.sns-bili { color: #b98ea0; }
.sns-bili:hover {
  color: var(--c-bili);
  border-color: rgba(231, 143, 179, .45);
  text-shadow: 0 0 14px rgba(231, 143, 179, .5);
  background: rgba(231, 143, 179, .07);
}

/* 抖音 → 青 */
.sns-dy { color: #85a8a7; }
.sns-dy:hover {
  color: var(--c-dy);
  border-color: rgba(53, 214, 208, .45);
  text-shadow: 0 0 14px rgba(53, 214, 208, .5);
  background: rgba(53, 214, 208, .07);
}

/* 小红书 → 红 */
.sns-xhs { color: #b38285; }
.sns-xhs:hover {
  color: var(--c-xhs);
  border-color: rgba(217, 74, 82, .45);
  text-shadow: 0 0 14px rgba(217, 74, 82, .5);
  background: rgba(217, 74, 82, .07);
}

.about-note {
  max-width: 720px;
  margin: 18px auto 0;
  padding-top: 16px;
  border-top: 1px dashed #241a20;
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 2;
  overflow-wrap: break-word;
}

.foot-sig {
  margin: 30px auto 0;
  font-family: var(--font-goth);
  font-size: 10.5px;
  letter-spacing: .18em;
  color: #4e464c;
}

/* ============================================================
   灯箱
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lbIn .28s var(--ease) both;
}
.lightbox[hidden] { display: none; }

@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }

.lb-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 70% at 50% 50%, rgba(20, 4, 10, .88), rgba(3, 2, 4, .97) 80%);
  backdrop-filter: blur(9px) brightness(.55);
  -webkit-backdrop-filter: blur(9px) brightness(.55);
  cursor: zoom-out;
}

.lb-stage {
  position: relative;
  z-index: 2;
  margin: 0;
  max-width: min(94vw, 1900px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: lbZoom .34s var(--ease) both;
}
@keyframes lbZoom {
  from { opacity: 0; transform: scale(.965); }
  to   { opacity: 1; transform: scale(1); }
}

.lb-img {
  max-width: 94vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid #33202a;
  border-radius: 2px;
  box-shadow:
    0 40px 90px -20px rgba(0, 0, 0, .95),
    0 0 0 1px rgba(139, 26, 43, .2),
    0 0 70px -18px var(--blood-glow);
  background: #080608;
  transition: opacity .3s var(--ease);
}
.lb-img.is-loading { opacity: .35; }

.lb-spinner {
  position: absolute;
  top: 50%; left: 50%;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(120, 80, 92, .35);
  border-top-color: var(--blood);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.lb-spinner.is-on { opacity: 1; }

.lb-cap {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 8px;
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--ink-dim);
  text-shadow: 0 1px 6px #000;
}
.lb-idx { font-family: var(--font-goth); color: #c08b93; letter-spacing: .12em; }
.lb-sep { color: #40383e; }
.lb-name {
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-faint);
}
.lb-size { font-family: var(--font-goth); color: var(--ink-faint); }

.lb-orig {
  color: #a8757e;
  border: 1px solid #33202a;
  border-radius: 3px;
  padding: 1px 8px 2px;
  transition: all .25s var(--ease);
}
.lb-orig:hover {
  color: var(--ink-strong);
  border-color: var(--blood);
  box-shadow: 0 0 14px -3px var(--blood-glow);
}

/* 灯箱按钮 */
.lb-btn {
  position: absolute;
  z-index: 3;
  appearance: none;
  background: rgba(14, 10, 14, .72);
  border: 1px solid #33202a;
  color: var(--ink-dim);
  border-radius: 50%;
  width: 46px; height: 46px;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .25s var(--ease);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.lb-btn:hover {
  color: var(--ink-strong);
  border-color: var(--blood);
  background: rgba(48, 10, 20, .8);
  box-shadow: 0 0 26px -4px var(--blood-glow);
  transform: scale(1.07);
}
.lb-btn:active { transform: scale(.97); }

.lb-close { top: 18px; right: 18px; font-size: 17px; }
.lb-prev  { left: 20px;  top: 50%; margin-top: -23px; font-size: 30px; padding-bottom: 4px; }
.lb-next  { right: 20px; top: 50%; margin-top: -23px; font-size: 30px; padding-bottom: 4px; }

/* 滚动锁定 */
body.lb-open { overflow: hidden; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1200px) {
  .brand-title { font-size: 17px; letter-spacing: .18em; }
}

@media (max-width: 860px) {
  :root { --gap: 12px; --img-max-h: 360px; }

  .head-inner { padding: 8px 12px 0; }
  .stage { padding: 14px 12px 0; }

  .brand-title { font-size: 15px; letter-spacing: .14em; }
  .brand-title em { display: none; }

  .tab { font-size: 12.5px; padding: 8px 12px 9px; }

  .about-text { font-size: 13.5px; line-height: 2.05; }

  .lb-btn { width: 40px; height: 40px; }
  .lb-close { top: 12px; right: 12px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lb-img { max-width: 96vw; max-height: 74vh; }
  .lb-name { max-width: 60vw; }
}

@media (max-width: 520px) {
  :root { --gap: 10px; --img-max-h: 320px; }

  .head-inner { padding: 7px 9px 0; }
  .stage { padding: 12px 9px 0; }

  .brand { justify-content: center; }
  .tabs { justify-content: flex-start; }
  .head-meta { justify-content: center; }

  .about-text { font-size: 13px; padding: 0 4px; }
  .sns { margin: 3px 2px; }

  .lb-img { max-width: 97vw; max-height: 70vh; }
  .lb-name { display: none; }
  .lb-cap { gap: 6px; font-size: 11px; }
}

/* 尊重系统的减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
