/**
 * DocBook 子主题 - 页面特效样式
 *
 * 全部选择器以 doc- 前缀限定作用域，只在对应开关开启时才由
 * docbook-effects.php 入队，不影响未启用时的页面。
 *
 * 该文件由 docbook-effects.php 引入，不直接被浏览器请求。
 */

/* ============================================================
   1. 鼠标跟随光标
   ============================================================ */
.doc-cursor {
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 100000;
    visibility: hidden;
    will-change: transform;
}

.doc-cursor__inner,
.doc-cursor__outer {
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 50%;
    display: block;
    transform: translate(-100px, -100px);
    transition: width .25s ease, height .25s ease, margin .25s ease,
                background-color .25s ease, border-color .25s ease, opacity .25s ease;
}

.doc-cursor__inner {
    width: 7px;
    height: 7px;
    margin: -3.5px 0 0 -3.5px;
    background: var(--doc-fx-cursor, #5b8def);
}

.doc-cursor__outer {
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 2px solid var(--doc-fx-cursor, #5b8def);
    opacity: .45;
}

/* 悬停可点击元素时外环扩散、内点隐藏 */
.doc-cursor.is-hover .doc-cursor__outer {
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    opacity: .18;
}
.doc-cursor.is-hover .doc-cursor__inner {
    width: 0;
    height: 0;
    margin: 0;
    opacity: 0;
}

/* 触屏/无精确指针设备没有真实鼠标，隐藏自定义光标避免「点不到」的错觉。
   用 hover 能力判断而非屏幕宽度：带触控的笔记本也应保留效果。 */
@media (hover: none), (pointer: coarse) {
    .doc-cursor { display: none; }
}

/* ============================================================
   2. 点击彩带礼花 / 飘落雪花：共用全屏画布
   ============================================================ */
.doc-confetti,
.doc-snow {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99998;
}

/* 彩带画布不应长期挡住下面的悬停态，只在有粒子时由 JS 控制 */
.doc-confetti { z-index: 99999; }

/* ============================================================
   3. FPS 显示器
   ============================================================ */
.doc-fps {
    position: fixed;
    top: 6px;
    left: 10px;
    z-index: 100001;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .5px;
    background-image: linear-gradient(-90deg, #8b5cf6, #5561ec, #5b7ef1);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    pointer-events: none;
}

/* ============================================================
   4. 随机彩蛋文字
   ============================================================ */
.doc-egg {
    position: fixed;
    z-index: 100002;
    padding: 7px 13px;
    border-radius: 999px;
    background: var(--doc-fx-egg-bg, #1f2733);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .16);
    opacity: 0;
    transform: translateY(6px) scale(.94);
    animation: doc-egg-in .26s ease forwards;
}

.doc-egg.is-out {
    animation: doc-egg-out .4s ease forwards;
}

@keyframes doc-egg-in {
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes doc-egg-out {
    to { opacity: 0; transform: translateY(-14px) scale(.98); }
}

body.dark-theme .doc-egg {
    background: #f1f3f4;
    color: #1f2733;
}

/* ============================================================
   5. 元素入场动画
   ============================================================ */
.doc-reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .5s ease, transform .5s ease;
}

.doc-reveal.is-in {
    opacity: 1;
    transform: none;
}

/* 不支持动画/用户要求减少动效时，直接显示不做位移 */
@media (prefers-reduced-motion: reduce) {
    .doc-reveal { opacity: 1; transform: none; transition: none; }
}

/* ============================================================
   6. 阅读进度条
   ============================================================ */
.doc-progress {
    position: fixed;
    left: 0;
    top: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #5b8def, #7f5af0);
    z-index: 100000;
    pointer-events: none;
    transition: width .1s linear;
}

/* ============================================================
   7. 灯笼挂件
   ============================================================ */
.doc-lantern {
    position: fixed;
    top: 0;
    right: 26px;
    z-index: 9990;
    pointer-events: none;
    transform-origin: 50% 0;
    animation: doc-lantern-swing 4.6s ease-in-out infinite;
}

.doc-lantern__rope {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 46px;
    margin-left: -.5px;
    background: rgba(150, 120, 80, .55);
}

.doc-lantern__body {
    position: absolute;
    left: 50%;
    top: 44px;
    width: 52px;
    height: 40px;
    margin-left: -26px;
    border-radius: 50% / 46%;
    background:
        radial-gradient(circle at 34% 34%, #ff8a6b, #d8000f 62%, #a1000a);
    box-shadow: 0 4px 18px rgba(216, 0, 15, .35);
}

/* 上下盖 */
.doc-lantern__body::before,
.doc-lantern__body::after {
    content: '';
    position: absolute;
    left: 50%;
    width: 16px;
    height: 4px;
    margin-left: -8px;
    background: #d8a24a;
    border-radius: 2px;
}
.doc-lantern__body::before { top: -2px; }
.doc-lantern__body::after { bottom: -2px; }

/* 竖向灯骨 */
.doc-lantern__body {
    background-image:
        linear-gradient(90deg,
            transparent 30%, rgba(255, 220, 190, .35) 30%, rgba(255, 220, 190, .35) 34%,
            transparent 34%, transparent 66%,
            rgba(255, 220, 190, .35) 66%, rgba(255, 220, 190, .35) 70%, transparent 70%),
        radial-gradient(circle at 34% 34%, #ff8a6b, #d8000f 62%, #a1000a);
}

.doc-lantern__text {
    position: absolute;
    left: 50%;
    top: 44px;
    width: 52px;
    height: 40px;
    margin-left: -26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffe9c7;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

/* 灯穗 */
.doc-lantern__body::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    width: 3px;
    height: 14px;
    margin: 0 0 0 -1.5px;
    background: #d8a24a;
    border-radius: 0 0 2px 2px;
}

.doc-lantern--plain .doc-lantern__text { display: none; }

@keyframes doc-lantern-swing {
    0%, 100% { transform: rotate(-3.5deg); }
    50%      { transform: rotate(3.5deg); }
}

@media (max-width: 768px) {
    /* 移动端隐藏挂件，屏幕小容易遮挡正文 */
    .doc-lantern { display: none; }
}
