/* ============================================================
   孤城 · 视觉特效层
   只用 transform / opacity / filter，全部走合成层，不触发重排。
   所有常驻动画在 prefers-reduced-motion 下自动停掉。
   ============================================================ */

/* ---------- 氛围浓度旋钮 ----------
   想更浓就把 --fx 调大，想清爽调小，0 = 完全关掉风沙与灯晕。
   在 app.css 的 :root 里或浏览器里改都行。 */
:root { --fx: 1; }

/* ---------- 层级：氛围在内容之下，闪光/转场在最上 ---------- */
body > .fx-amb { z-index: 0 !important; }
body > .fx-over { z-index: 90 !important; }
.fx-amb, .fx-over { position: fixed; inset: 0; pointer-events: none; }

/* ============ 1. 风沙 ============
   两层不同速度的颗粒做视差。整层只动 transform。 */
.fx-dust {
  position: absolute; inset: -20% -20% -20% -20%;
  will-change: transform;
  opacity: var(--fx);
}
.fx-dust.a {
  background-image:
    radial-gradient(1.7px 1.7px at 12% 18%, rgba(240,194,113,.85), transparent 62%),
    radial-gradient(1.3px 1.3px at 38% 62%, rgba(217,164,69,.72), transparent 62%),
    radial-gradient(2.1px 2.1px at 67% 27%, rgba(217,164,69,.58), transparent 62%),
    radial-gradient(1.2px 1.2px at 84% 71%, rgba(234,228,215,.52), transparent 62%),
    radial-gradient(1.5px 1.5px at 25% 88%, rgba(217,164,69,.66), transparent 62%),
    radial-gradient(1.1px 1.1px at 55% 42%, rgba(234,228,215,.46), transparent 62%),
    radial-gradient(1.9px 1.9px at 92% 12%, rgba(217,164,69,.60), transparent 62%),
    radial-gradient(1.3px 1.3px at 7% 54%,  rgba(217,164,69,.55), transparent 62%),
    radial-gradient(1.6px 1.6px at 46% 8%,  rgba(240,194,113,.62), transparent 62%),
    radial-gradient(1.1px 1.1px at 73% 91%, rgba(234,228,215,.44), transparent 62%),
    radial-gradient(2px 2px     at 31% 34%, rgba(217,164,69,.50), transparent 62%),
    radial-gradient(1.2px 1.2px at 60% 68%, rgba(217,164,69,.58), transparent 62%),
    radial-gradient(1.4px 1.4px at 18% 74%, rgba(240,194,113,.48), transparent 62%),
    radial-gradient(1px 1px     at 97% 47%, rgba(234,228,215,.40), transparent 62%);
  background-size: 300px 300px;
  animation: dustA 34s linear infinite;
}
.fx-dust.b {
  background-image:
    radial-gradient(3.4px 3.4px at 22% 44%, rgba(217,164,69,.42), transparent 60%),
    radial-gradient(4.2px 4.2px at 61% 78%, rgba(217,164,69,.34), transparent 60%),
    radial-gradient(3px 3px     at 88% 33%, rgba(234,228,215,.28), transparent 60%),
    radial-gradient(3.6px 3.6px at 44% 15%, rgba(217,164,69,.36), transparent 60%),
    radial-gradient(2.8px 2.8px at 9% 70%,  rgba(240,194,113,.30), transparent 60%),
    radial-gradient(4px 4px     at 76% 6%,  rgba(217,164,69,.26), transparent 60%);
  background-size: 470px 470px;
  animation: dustB 62s linear infinite;
  filter: blur(.7px);
}
@keyframes dustA { to { transform: translate3d(-300px, 120px, 0); } }
@keyframes dustB { to { transform: translate3d(470px, -141px, 0); } }

/* ============ 2. 灯晕呼吸 ============ */
.fx-lamp {
  position: absolute; left: 50%; top: -26vh; width: 150vw; height: 74vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(217,164,69,.34) 0%, rgba(217,164,69,.09) 38%, transparent 68%);
  animation: lampBreathe 7s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  will-change: opacity, filter;
}
@keyframes lampBreathe {
  from { opacity: .5; filter: blur(0px); transform: translateX(-50%) scale(1); }
  to   { opacity: 1;  filter: blur(7px); transform: translateX(-50%) scale(1.06); }
}
/* 底部一层朱砂余烬，和顶部灯金形成冷暖夹击 */
.fx-vig::before {
  content: ""; position: absolute; left: 50%; bottom: -22vh; width: 140vw; height: 52vh;
  transform: translateX(-50%); opacity: var(--fx);
  background: radial-gradient(ellipse at center, rgba(214,91,76,.16) 0%, transparent 66%);
  mix-blend-mode: screen; animation: emberBreathe 11s ease-in-out infinite alternate;
}
@keyframes emberBreathe { from { opacity: calc(var(--fx) * .35) } to { opacity: var(--fx) } }

/* ============ 3. 暗角 ============ */
.fx-vig {
  position: absolute; inset: 0;
  box-shadow: inset 0 0 220px 60px rgba(0,0,0,.86);
}

/* ============ 4. 胶片颗粒抖动 ============ */
body::before { animation: grainJitter .9s steps(5) infinite; will-change: transform; opacity: .13 !important; }
@keyframes grainJitter {
  0%   { transform: translate3d(0,0,0); }
  20%  { transform: translate3d(-9px,6px,0); }
  40%  { transform: translate3d(7px,-8px,0); }
  60%  { transform: translate3d(-6px,-5px,0); }
  80%  { transform: translate3d(8px,7px,0); }
  100% { transform: translate3d(0,0,0); }
}

/* ============ 5. 卡片入场 ============ */
@keyframes riseIn {
  from { opacity: 0; transform: translate3d(0,16px,0) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.fx-in > * { animation: riseIn .5s cubic-bezier(.16,.84,.44,1) both; }
.fx-in > *:nth-child(1) { animation-delay: .02s }
.fx-in > *:nth-child(2) { animation-delay: .07s }
.fx-in > *:nth-child(3) { animation-delay: .12s }
.fx-in > *:nth-child(4) { animation-delay: .17s }
.fx-in > *:nth-child(5) { animation-delay: .22s }
.fx-in > *:nth-child(6) { animation-delay: .27s }
.fx-in > *:nth-child(n+7) { animation-delay: .32s }

/* ============ 6. 页签切换 ============ */
@keyframes viewIn {
  from { opacity: 0; transform: translate3d(0,10px,0); }
  to   { opacity: 1; transform: none; }
}
.view:not([hidden]), .dv:not([hidden]) { animation: viewIn .34s cubic-bezier(.16,.84,.44,1) both; }

/* ============ 7. 章节转场 ============ */
.fx-chapter {
  position: fixed; inset: 0; z-index: 95; pointer-events: none;
  display: grid; place-content: center; text-align: center;
  background: #07090C;
  opacity: 0;
}
.fx-chapter.run { animation: chapterHold 3.4s ease both; }
@keyframes chapterHold {
  0%   { opacity: 0 }
  10%  { opacity: 1 }
  78%  { opacity: 1 }
  100% { opacity: 0 }
}
.fx-chapter .bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  opacity: .5; filter: contrast(1.15) saturate(.75);
}
.fx-chapter.run .bg { animation: kenBurns 3.4s ease-out both; }
@keyframes kenBurns {
  from { transform: scale(1.14) translate3d(2%, 1%, 0); }
  to   { transform: scale(1) translate3d(0,0,0); }
}
.fx-chapter .scrim { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 20%, #07090C 82%); }
.fx-chapter .txt { position: relative; padding: 0 30px; }
.fx-chapter .num {
  font-family: "Noto Sans SC", sans-serif; font-size: .74rem; letter-spacing: .5em;
  color: var(--lamp-dim); margin-bottom: 14px;
}
.fx-chapter .name {
  font-family: "ZCOOL XiaoWei", serif; font-size: 3.2rem; letter-spacing: .3em;
  color: var(--lamp); text-shadow: 0 0 44px rgba(217,164,69,.45);
  padding-left: .3em;
}
.fx-chapter.run .name { animation: nameIn 1.5s cubic-bezier(.16,.84,.44,1) both .25s; }
@keyframes nameIn {
  from { opacity: 0; transform: translate3d(0,20px,0); letter-spacing: .9em; filter: blur(10px); }
  to   { opacity: 1; transform: none; letter-spacing: .3em; filter: blur(0); }
}
.fx-chapter .rule {
  height: 1px; margin: 20px auto 0; width: 0;
  background: linear-gradient(90deg, transparent, var(--lamp-dim), transparent);
}
.fx-chapter.run .rule { animation: ruleGrow 1.6s ease both .5s; }
@keyframes ruleGrow { to { width: 74vw; max-width: 420px; } }

/* ============ 8. 开枪：屏震 + 血闪 ============ */
.fx-flash {
  position: fixed; inset: 0; z-index: 96; pointer-events: none; opacity: 0;
}
.fx-flash.hit  { background: radial-gradient(ellipse at center, rgba(214,91,76,.55), rgba(214,91,76,.12) 55%, transparent 78%); }
.fx-flash.block{ background: radial-gradient(ellipse at center, rgba(111,168,148,.42), transparent 68%); }
.fx-flash.run  { animation: flashOut .72s ease-out both; }
@keyframes flashOut { 0% { opacity: 0 } 8% { opacity: 1 } 100% { opacity: 0 } }
@keyframes shake {
  0%,100% { transform: translate3d(0,0,0) }
  12% { transform: translate3d(-9px,3px,0) }
  26% { transform: translate3d(8px,-4px,0) }
  40% { transform: translate3d(-6px,-3px,0) }
  56% { transform: translate3d(5px,4px,0) }
  72% { transform: translate3d(-3px,2px,0) }
  88% { transform: translate3d(2px,-1px,0) }
}
.fx-shake { animation: shake .58s cubic-bezier(.36,.07,.19,.97) both; }

/* ============ 9. 收款码：扫描线 ============ */
.bigcode { position: relative; overflow: hidden; }
.bigcode::after {
  content: ""; position: absolute; left: 0; right: 0; height: 34%;
  background: linear-gradient(180deg, transparent, rgba(217,164,69,.20), transparent);
  animation: scanSweep 2.4s ease-in-out infinite;
}
@keyframes scanSweep { 0% { top: -40% } 100% { top: 110% } }
.bigcode { animation: codePulse 2.4s ease-in-out infinite alternate; }
@keyframes codePulse {
  from { box-shadow: 0 0 0 1px rgba(217,164,69,.10) inset, 0 0 0 0 rgba(217,164,69,0); }
  to   { box-shadow: 0 0 0 1px rgba(217,164,69,.28) inset, 0 0 34px 2px rgba(217,164,69,.22); }
}

/* ============ 10. 朱印落章（命运抉择 / 已选定） ============ */
.fx-seal {
  position: absolute; right: 14px; top: 50%; width: 74px; height: 74px;
  margin-top: -37px; pointer-events: none; opacity: .9;
}
.fx-seal.run { animation: sealDrop .62s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes sealDrop {
  0%   { opacity: 0; transform: scale(2.6) rotate(-16deg); filter: blur(6px); }
  60%  { opacity: .95; transform: scale(.92) rotate(-7deg); filter: blur(0); }
  100% { opacity: .9; transform: scale(1) rotate(-7deg); }
}

/* ============ 11. 新线索 / 徽标脉冲 ============ */
@keyframes badgePop {
  0% { transform: scale(0) } 60% { transform: scale(1.35) } 100% { transform: scale(1) }
}
.badge:not([hidden]) { animation: badgePop .42s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes clueGlow {
  0%,100% { box-shadow: 0 0 0 0 rgba(217,164,69,0) }
  50%     { box-shadow: 0 0 22px 2px rgba(217,164,69,.35) }
}
.clue.fresh { animation: clueGlow 2s ease-in-out 2; }

/* ============ 12. 拍卖：中标流光 ============ */
@keyframes shimmer {
  from { background-position: -180% 0 } to { background-position: 280% 0 }
}
.lot.bidded, .lot.ring { position: relative; overflow: hidden; }
.lot.bidded::after, .lot.ring::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(217,164,69,.22) 50%, transparent 62%);
  background-size: 220% 100%;
  animation: shimmer 3.2s ease-in-out infinite;
}

/* ============ 13. 阅读层：开卷 + 引信倒计时 ============ */
@keyframes unfold {
  from { opacity: 0; transform: translate3d(0,26px,0) rotateX(9deg); }
  to   { opacity: 1; transform: none; }
}
.rd { transform-origin: top center; animation: unfold .46s cubic-bezier(.16,.84,.44,1) both; }
.rd-foot { position: relative; }
.rd-foot::before {
  content: ""; position: absolute; left: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, var(--cinnabar), var(--lamp));
  width: var(--fuse, 100%);
  transition: width 1s linear;
  box-shadow: 0 0 8px rgba(217,164,69,.6);
}

/* ============ 14. 标题烫金 ============ */
.boot-mark, .dm-mark {
  background: linear-gradient(100deg, var(--lamp-dim) 20%, var(--lamp-hi) 42%, var(--lamp) 58%, var(--lamp-dim) 80%);
  background-size: 260% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gild 6s ease-in-out infinite;
}
@keyframes gild { 0%,100% { background-position: 0% 0 } 50% { background-position: 100% 0 } }

/* ============ 15. 开场大字入场 ============ */
.boot .boot-mark { animation: gild 6s ease-in-out infinite, markIn 1.5s cubic-bezier(.16,.84,.44,1) both; }
@keyframes markIn {
  from { opacity: 0; transform: translate3d(0,26px,0) scale(.9); letter-spacing: .8em; filter: blur(14px); }
  to   { opacity: 1; transform: none; letter-spacing: .2em; filter: blur(0); }
}
.boot > *:not(.boot-mark) { animation: riseIn .7s cubic-bezier(.16,.84,.44,1) both .5s; }
.boot-hero {
  position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center 30%;
  background-image: url(/img/fx/hero.webp);
  opacity: .68; filter: contrast(1.14) saturate(.85);
  animation: heroDrift 26s ease-in-out infinite alternate;
}
@keyframes heroDrift {
  from { transform: scale(1.06) translate3d(0,0,0) }
  to   { transform: scale(1.16) translate3d(-1.5%,-2%,0) }
}

/* ============ 16. 按钮/可点元素的手感 ============ */
.btn, .lot, .clue, .dcard .who button, .tabs button {
  transition: transform .14s cubic-bezier(.2,.8,.3,1), border-color .18s, color .18s, background .18s;
}
.btn:active, .lot:active, .clue:active { transform: scale(.972); }
.tabs button.on b { text-shadow: 0 0 16px rgba(217,164,69,.55); }

/* ============ 17. 死亡状态：整页褪色 ============ */
body.fx-dead main { filter: grayscale(.72) brightness(.82); transition: filter 1.2s ease; }

/* ============ 无障碍：关掉动效 ============ */
@media (prefers-reduced-motion: reduce) {
  .fx-dust, .fx-lamp, body::before, .bigcode, .bigcode::after,
  .lot.bidded::after, .lot.ring::after, .boot-mark, .dm-mark {
    animation: none !important;
  }
  .fx-in > *, .view:not([hidden]), .dv:not([hidden]), .rd, .boot > *, .boot .boot-mark {
    animation-duration: .01ms !important;
  }
  .fx-chapter.run { animation-duration: 1.2s !important; }
  .fx-shake { animation: none !important; }
}

/* 进入正式界面后（#boot / #gate 被移除）收掉开场大图 */
body.player:has(#app:not([hidden])) .boot-hero,
body.dm:has(#app:not([hidden])) .boot-hero { opacity: 0; transition: opacity .8s ease; }

/* ============ 18. 拍品图标 ============ */
.lot-ic {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 3px;
  background-size: cover; background-position: center;
  border: 1px solid var(--line-soft);
  filter: saturate(.85) contrast(1.08);
  box-shadow: inset 0 0 18px rgba(0,0,0,.55);
}
.lot:active .lot-ic { filter: saturate(1) contrast(1.15) brightness(1.12); }
.lot.ring .lot-ic { border-color: var(--jade); }
.lot.bidded .lot-ic { border-color: var(--lamp-dim); }

.lot-ic.sm {
  display: inline-block; width: 26px; height: 26px; vertical-align: -8px; margin-right: 8px;
  flex: 0 0 auto; box-shadow: none;
}

/* ============ 19. 卡片装饰：民国海报式金角 + 纸纹 ============ */
.card {
  position: relative;
  background-image:
    var(--grain),
    linear-gradient(180deg, rgba(217,164,69,.045), transparent 110px);
  background-size: 96px 96px, auto;
  background-blend-mode: overlay, normal;
}
.card::before, .card::after {
  content: ""; position: absolute; width: 15px; height: 15px; pointer-events: none;
  opacity: .55;
}
.card::before { top: -1px; left: -1px;  border-top: 2px solid var(--lamp-dim); border-left: 2px solid var(--lamp-dim); }
.card::after  { bottom: -1px; right: -1px; border-bottom: 2px solid var(--lamp-dim); border-right: 2px solid var(--lamp-dim); }
/* 标题前的金菱与延伸线 */
.card > h2::before {
  content: ""; width: 6px; height: 6px; flex: none; align-self: center;
  background: var(--lamp); transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(217,164,69,.8);
}
.card > h2 { position: relative; }
.card > h2::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, var(--lamp-dim), transparent 45%);
}

/* 顶栏压一条暗夜城墙 + 金线 */
.topbar, .dm-top {
  position: relative;
  background-image: linear-gradient(180deg, rgba(11,13,17,.78), rgba(11,13,17,.97)), url(/img/fx/hero.webp);
  background-size: auto, cover;
  background-position: center, center 22%;
  border-bottom: 1px solid transparent;
}
.topbar::after, .dm-top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--lamp), transparent);
  box-shadow: 0 0 12px rgba(217,164,69,.6);
}

/* 玩家板卡（主持台总览）也上纸纹 */
.pc { background-image: var(--grain), none; background-size: 96px 96px; background-blend-mode: overlay; }

/* ============ 20. 开场：停留足够看清，再化开 ============ */
.boot { position: relative; z-index: 2; }
.fx-out { animation: bootOut .6s ease forwards; }
@keyframes bootOut { to { opacity: 0; transform: scale(1.04); filter: blur(6px); } }
.boot-hero.fx-out { animation: heroOut 1.1s ease forwards; }
@keyframes heroOut { to { opacity: 0; transform: scale(1.2); } }
/* 开场页正中一道横向金线，像揭幕 */
.boot::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; height: 1px; width: 0;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--lamp), transparent);
  animation: ruleGrow 1.8s ease both .3s;
  box-shadow: 0 0 14px rgba(217,164,69,.7);
}

/* ============ 21. 换头像 ============ */
.ch-col { flex: none; display: flex; flex-direction: column; align-items: center; gap: 9px; width: 92px; }
.ch-face { position: relative; transition: box-shadow .3s ease; }
.ch-face .gen-veil { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.face-btn {
  background: none; border: 1px solid var(--line); border-radius: 3px;
  color: var(--muted); font-family: "Noto Sans SC", sans-serif; font-size: .68rem;
  letter-spacing: 0; padding: 6px 4px; width: 100%; cursor: pointer; line-height: 1.45;
  min-height: 42px;
  transition: border-color .18s, color .18s, transform .14s;
}
.face-btn:active { transform: scale(.94); }
.face-btn:hover:not(:disabled) { border-color: var(--lamp); color: var(--lamp); }
.face-btn:disabled { color: var(--lamp); border-color: var(--lamp-dim); cursor: progress; }

/* 生成中：模糊 + 扫描线 + 金环脉冲 */
.ch-face.gen { box-shadow: 0 0 0 4px rgba(217,164,69,.30), 0 0 30px rgba(217,164,69,.45); }
.ch-face.gen img { filter: blur(8px) contrast(1.25) saturate(.55); transform: scale(1.08); }
.ch-face img { transition: filter .45s ease, transform .45s ease; }
.ch-face.gen .gen-veil {
  opacity: 1;
  background: linear-gradient(180deg, transparent, rgba(217,164,69,.55), transparent);
  background-size: 100% 44%; background-repeat: no-repeat;
  animation: genScan 1.05s linear infinite;
}
@keyframes genScan { from { background-position: 0 -55% } to { background-position: 0 155% } }
/* 生成完：从模糊里“显影” */
.ch-face.pop img { animation: facePop .75s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes facePop {
  0%   { filter: blur(12px) saturate(.5); transform: scale(1.14); opacity: .35 }
  60%  { filter: blur(2px) saturate(.9);  transform: scale(1.02); opacity: 1 }
  100% { filter: contrast(1.06); transform: none; opacity: 1 }
}
