﻿/* ============================================================
   之寒的小站 · 外观与交互增强（由插件注入）
   参考：绘梨衣站（门扉/光标/转场/显现/灯箱）+ 八奈见站（明暗主题/快捷键/表情反馈）
   全部可开关；不改主题文件。
   ============================================================ */

:root {
  --fx-c1: #ff7eb6;
  --fx-c2: #9d7bff;
  --fx-c3: #63e6ff;
  --fx-radius: 14px;
  --fx-line: rgba(120, 100, 140, .18);
}

/* ------------------------------------------------------------
   1. 开场门扉
   ⚠️ 主题里最高用到 z-index:9999999，所以这里必须用接近顶格的层级
   ---------------------------------------------------------- */
.fx-gate {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 60% at 50% 42%, rgba(255, 126, 182, .18), transparent 70%),
    #120e18;
  transition: opacity .7s cubic-bezier(.22, .61, .36, 1), visibility .7s;
}
.fx-gate.out { opacity: 0; visibility: hidden; }
.fx-gate-in { text-align: center; padding: 26px; }
.fx-gate-seal {
  width: 78px; height: 78px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  font-family: var(--f-serif, serif);
  font-size: 38px;
  color: #fff;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--fx-c1), var(--fx-c2));
  box-shadow: 0 0 40px rgba(255, 126, 182, .45);
  animation: fxSeal 1s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes fxSeal {
  0% { transform: scale(1.7) rotate(-12deg); opacity: 0; filter: blur(8px); }
  60% { opacity: 1; filter: blur(0); }
  100% { transform: none; opacity: 1; }
}
.fx-gate-name {
  margin: 0 0 6px;
  font-size: clamp(22px, 4vw, 34px);
  letter-spacing: 8px;
  background: linear-gradient(100deg, #fff, #ffd9ec 45%, var(--fx-c1));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.fx-gate-sub { margin: 0 0 22px; font-size: 12.5px; letter-spacing: 3px; color: #a89fbb; }
.fx-gate-bar { width: min(360px, 68vw); height: 2px; margin: 0 auto 18px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.fx-gate-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--fx-c1), var(--fx-c2)); transition: width .3s linear; }
.fx-gate-skip { font-size: 12px; color: #8b83a0; cursor: pointer; background: none; border: none; letter-spacing: 2px; }
.fx-gate-skip:hover { color: #fff; }

/* ------------------------------------------------------------
   2. 自定义光标 + 花瓣轨迹
   ⚠️ 原来用了 mix-blend-mode:screen，在浅色站上等于隐形；改成实心描边 + 白色包边
   ---------------------------------------------------------- */
.fx-cursor {
  position: fixed; left: 0; top: 0;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid #ff4d94;
  border-radius: 50%;
  z-index: 2147483001;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .9), 0 0 14px rgba(255, 77, 148, .55);
  transition: width .22s ease, height .22s ease, margin .22s ease, background .22s ease, opacity .3s;
}
.fx-cursor::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #ff4d94;
}
.fx-cursor.hot { width: 46px; height: 46px; margin: -23px 0 0 -23px; background: rgba(255, 126, 182, .18); }
.fx-cursor.gone { opacity: 0; }
/* 只在增强层确认启动后才隐藏系统光标（避免 JS 挂了没光标） */
html.fx-hide-cursor body,
html.fx-hide-cursor body * { cursor: none !important; }
.fx-trail {
  position: fixed;
  z-index: 2147482999;
  pointer-events: none;
  font-size: 13px;
  animation: fxTrail 1.1s ease-out forwards;
}
@keyframes fxTrail {
  0% { opacity: .95; transform: translate(-50%, -50%) scale(.6) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1.15) rotate(70deg); }
}
@media (hover: none), (pointer: coarse) {
  .fx-cursor, .fx-trail { display: none !important; }
}

/* ------------------------------------------------------------
   3. 背景粒子层
   ⚠️ 原来用 z-index:-1，会被主题的白色 #page/article 背景盖住；
      改成浮在内容之上（和主题自带的樱花特效一样的做法），并降低不透明度
   ---------------------------------------------------------- */
.fx-bg {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: .6;
}
body.fx-bg-off .fx-bg { display: none; }

/* ------------------------------------------------------------
   4. 页面转场
   ---------------------------------------------------------- */
.fx-warp { position: fixed; inset: 0; z-index: 2147482990; pointer-events: none; display: none; }
.fx-warp.play { display: block; }
.fx-warp-mask { position: absolute; inset: 0; background: #120e18; opacity: 0; }
.fx-warp-mark {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.4);
  font-family: var(--f-serif, serif);
  font-size: 30vmin;
  color: var(--fx-c1);
  opacity: 0;
}
.fx-warp-strip { position: absolute; left: 0; right: 0; height: 11.2%; background: #120e18; transform: scaleX(0); }
.fx-warp-petal {
  position: absolute; top: -10vh;
  width: 18px; height: 12px;
  border-radius: 50% 0 50% 50%;
  background: linear-gradient(120deg, #ffd0e0, var(--fx-c1));
  opacity: 0;
}
.fx-warp[data-v="seal"].play .fx-warp-mark { animation: fxWSeal .78s cubic-bezier(.22,.61,.36,1) forwards; }
@keyframes fxWSeal {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.3) rotate(-12deg); }
  45% { opacity: 1; transform: translate(-50%,-50%) scale(1.05); }
  100% { opacity: 1; transform: translate(-50%,-50%) scale(1.4); }
}
.fx-warp[data-v="blind"].play .fx-warp-strip { animation: fxWBlind .7s cubic-bezier(.22,.61,.36,1) forwards; }
@keyframes fxWBlind { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.fx-warp[data-v="petal"].play .fx-warp-petal { animation: fxWPetal .8s ease-in forwards; }
@keyframes fxWPetal {
  0% { opacity: 0; transform: translateY(0) rotate(0); }
  20% { opacity: 1; }
  100% { opacity: 1; transform: translateY(115vh) rotate(260deg); }
}

/* ------------------------------------------------------------
   5. 块级滚动显现
   ---------------------------------------------------------- */
.fx-rv { opacity: 0; transform: translateY(20px); }
.fx-rv.in { opacity: 1; transform: none; transition: opacity .65s cubic-bezier(.22,.61,.36,1), transform .65s cubic-bezier(.22,.61,.36,1); }

/* ------------------------------------------------------------
   6. 阅读进度 / 回到顶部 / 目录
   ---------------------------------------------------------- */
.fx-progress {
  position: fixed; left: 0; top: 0;
  height: 3px; width: 0;
  z-index: 2147482000;
  background: linear-gradient(90deg, var(--fx-c1), var(--fx-c2));
  box-shadow: 0 0 10px rgba(255, 126, 182, .6);
  transition: width .1s linear;
}
.fx-top {
  position: fixed; right: 20px; bottom: 24px;
  z-index: 2147482001;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 17px; color: #fff;
  border: none; border-radius: 50%;
  background: linear-gradient(140deg, var(--fx-c1), var(--fx-c2));
  box-shadow: 0 10px 26px rgba(255, 126, 182, .4);
  cursor: pointer;
  opacity: 0; transform: translateY(14px) scale(.9);
  pointer-events: none;
  transition: all .28s cubic-bezier(.22,.61,.36,1);
}
.fx-top.show { opacity: 1; transform: none; pointer-events: auto; }
.fx-top:hover { transform: translateY(-3px) scale(1.06); }

.fx-toc-btn {
  position: fixed; right: 20px; bottom: 78px;
  z-index: 2147482001;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 16px; color: #fff;
  border: none; border-radius: 50%;
  background: linear-gradient(140deg, #7f8fa6, #5b6478);
  box-shadow: 0 8px 20px rgba(40, 30, 60, .3);
  cursor: pointer;
  opacity: 0; transform: translateY(14px) scale(.9);
  pointer-events: none;
  transition: all .28s cubic-bezier(.22,.61,.36,1);
}
.fx-toc-btn.show { opacity: 1; transform: none; pointer-events: auto; }
.fx-toc {
  position: fixed; right: 20px; bottom: 130px;
  z-index: 2147482002;
  width: min(280px, 74vw);
  max-height: 56vh;
  overflow-y: auto;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .97);
  border: 1px solid var(--fx-line);
  box-shadow: 0 20px 50px rgba(40, 30, 60, .28);
  font-size: 13px;
  transform: translateY(10px) scale(.97);
  opacity: 0; pointer-events: none;
  transition: all .24s cubic-bezier(.22,.61,.36,1);
}
.fx-toc.show { opacity: 1; transform: none; pointer-events: auto; }
.fx-toc h4 { margin: 0 0 8px; font-size: 12.5px; letter-spacing: 1px; color: #8a7f9c; }
.fx-toc a {
  display: block;
  padding: 5px 8px;
  border-radius: 8px;
  color: #4a4358;
  text-decoration: none;
  line-height: 1.5;
  border-left: 2px solid transparent;
}
.fx-toc a:hover { background: rgba(255, 126, 182, .1); border-left-color: var(--fx-c1); }
.fx-toc a.lv3 { padding-left: 20px; font-size: 12.5px; color: #6d6480; }

/* ------------------------------------------------------------
   7. 图片灯箱（增强）
   ---------------------------------------------------------- */
.fx-lb {
  position: fixed; inset: 0;
  z-index: 2147482995;
  display: none;
  place-items: center;
  background: rgba(10, 7, 14, .93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.fx-lb.show { display: grid; }
.fx-lb img {
  max-width: min(92vw, 1100px);
  max-height: 80vh;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .7);
  animation: fxLb 0.32s cubic-bezier(.22,.61,.36,1);
}
@keyframes fxLb { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.fx-lb-bar { position: absolute; bottom: 26px; display: flex; gap: 10px; align-items: center; }
.fx-lb-bar button, .fx-lb-bar a {
  padding: 9px 18px;
  font-size: 13px;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 99px;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.fx-lb-bar button:hover, .fx-lb-bar a:hover { background: rgba(255, 255, 255, .28); }
.fx-lb-cap { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: #d9d2e6; font-size: 12.5px; }

/* ------------------------------------------------------------
   8. 文章特色图模糊背景
   ---------------------------------------------------------- */
.fx-postbg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  filter: blur(38px) saturate(120%) brightness(.9);
  opacity: .38;
  transform: scale(1.1);
  pointer-events: none;
}

/* ------------------------------------------------------------
   9. 明暗主题（给 body 加 .fx-night，不动主题变量）
   ---------------------------------------------------------- */
body.fx-night {
  background: #14111c;
}
body.fx-night #page, body.fx-night .site-content, body.fx-night article,
body.fx-night .entry-content, body.fx-night .post-content {
  color: #ddd8ea;
}
body.fx-night article, body.fx-night .post-card, body.fx-night .comment-body {
  background: #1d1926 !important;
  border-color: rgba(255, 255, 255, .08) !important;
}
body.fx-night .entry-title, body.fx-night h1, body.fx-night h2, body.fx-night h3 { color: #f0ecfa; }
body.fx-night a { color: #ffb3d1; }
body.fx-night .fx-toc { background: rgba(29, 25, 38, .97); border-color: rgba(255,255,255,.1); }
body.fx-night .fx-toc a { color: #cfc7de; }

.fx-theme-btn {
  position: fixed; right: 20px; bottom: 132px;
  z-index: 2147482001;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 16px;
  border: none; border-radius: 50%;
  color: #fff;
  background: linear-gradient(140deg, #4a4358, #2b2636);
  box-shadow: 0 8px 20px rgba(40, 30, 60, .3);
  cursor: pointer;
  transition: transform .2s ease;
}
.fx-theme-btn:hover { transform: translateY(-3px) rotate(-12deg); }

/* ------------------------------------------------------------
   10. 悬浮表情反馈（来自八奈见站的做法）
   ---------------------------------------------------------- */
.fx-float {
  position: fixed;
  z-index: 2147482992;
  pointer-events: none;
  font-size: 22px;
  animation: fxFloat 1.15s cubic-bezier(.22,.61,.36,1) forwards;
}
@keyframes fxFloat {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  25% { opacity: 1; transform: translate(-50%, -90%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -320%) scale(1.3); }
}

/* 提示条 */
.fx-toast-wrap {
  position: fixed; left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 2147482993;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.fx-toast {
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 13px;
  color: #fff;
  background: rgba(30, 24, 40, .92);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .4);
  animation: fxToast .3s cubic-bezier(.22,.61,.36,1);
  white-space: nowrap;
}
@keyframes fxToast { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.fx-toast.out { animation: fxToastOut .3s ease forwards; }
@keyframes fxToastOut { to { opacity: 0; transform: translateY(-8px); } }

/* 手机端收敛 */
@media (max-width: 640px) {
  .fx-top { right: 12px; bottom: 16px; width: 40px; height: 40px; }
  .fx-toc-btn { right: 12px; bottom: 64px; width: 40px; height: 40px; }
  .fx-theme-btn { right: 12px; bottom: 112px; width: 40px; height: 40px; }
  .fx-toc { right: 12px; bottom: 160px; }
}

/* 尊重「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
  .fx-rv { opacity: 1; transform: none; }
  .fx-gate, .fx-warp, .fx-trail, .fx-float { display: none !important; }
  .fx-cursor { display: none !important; }
}
