/* ============================================================
   ui.css — 滚动指示器、返回顶部、魔法投影、响应式、打印
   梦初雪 (Yume Hatsuyuki) 角色档案卷轴
   ============================================================ */

/* ── 滚动指示器 ───────────────────────────────────────────── */
.scroll-indicator {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 998;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.scroll-indicator:hover { opacity: 0.8; }

.scroll-rune {
    font-family: var(--font-illuminated);
    font-size: 1.2rem;
    color: var(--ink-gold);
    animation: pulseRune 2s ease-in-out infinite;
    text-shadow: 0 0 5px rgba(184, 134, 11, 0.5);
}

.scroll-line {
    width: 2px;
    height: 100px;
    background: linear-gradient(to bottom,
        transparent,
        var(--ink-gold) 20%,
        var(--ink-gold) 80%,
        transparent);
    position: relative;
}

.scroll-line::before,
.scroll-line::after {
    content: "";
    position: absolute;
    left: -3px;
    width: 8px;
    height: 8px;
    background: var(--ink-gold);
    border-radius: 50%;
    animation: floatRune 3s ease-in-out infinite;
}

.scroll-line::before { top: 0;    animation-delay: 0s; }
.scroll-line::after  { bottom: 0; animation-delay: 1.5s; }

@keyframes pulseRune {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50%       { opacity: 1;   transform: scale(1.2); }
}

@keyframes floatRune {
    0%, 100% { transform: translateY(0);   opacity: 0.5; }
    50%       { transform: translateY(-5px); opacity: 1; }
}

/* ── 返回顶部按钮 ─────────────────────────────────────────── */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 42px;
    height: 42px;
    background: var(--parchment-old);
    color: var(--ink-blood);
    border: 2px solid var(--ink-blood);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.4rem;
    box-shadow:
        0 3px 8px var(--shadow-heavy),
        inset 0 0 5px rgba(139, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 999;
    user-select: none;
    line-height: 1;
    padding: 0;
    margin: 0;
    overflow: hidden;
    transform: translateY(10px) scale(0.9);
}

.scroll-to-top::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(184, 134, 11, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.scroll-to-top::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px; right: 2px; bottom: 2px;
    border: 1px solid rgba(139, 0, 0, 0.2);
    border-radius: 50%;
    pointer-events: none;
}

.scroll-to-top.show {
    opacity: 0.9;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scroll-to-top:hover {
    background: var(--ink-blood);
    color: var(--parchment-old);
    transform: translateY(-5px) scale(1.05);
    box-shadow:
        0 6px 15px var(--glow-blood),
        0 0 10px rgba(139, 0, 0, 0.3);
    opacity: 1;
}

.scroll-to-top:hover::before { opacity: 1; }

.scroll-to-top .arrow {
    display: block;
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 34px;
    font-size: 1.5rem;
    margin-top: -1px;
}

/* ── 全屏魔法投影 ─────────────────────────────────────────── */
.scrying-pool {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 8, 5, 0.97);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    cursor: zoom-out;
    padding: 2rem;
}

.scrying-pool.active {
    display: flex;
    animation: scryFadeIn 0.3s ease;
}

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

.scrying-pool img {
    max-width: 90%;
    max-height: 90%;
    border: 6px solid var(--ink-gold);
    border-image:
        linear-gradient(45deg,
            var(--ink-gold) 25%,
            var(--ink-blood) 50%,
            var(--ink-gold) 75%) 1;
    box-shadow:
        0 0 40px rgba(184, 134, 11, 0.6),
        0 0 80px rgba(139, 0, 0, 0.4);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px)   rotate(0deg); }
    50%       { transform: translateY(-10px) rotate(0.2deg); }
}

/* ── 响应式断点 ───────────────────────────────────────────── */
@media (max-width: 768px) {
    body { padding: 0.5rem; }

    .grimoire-container {
        padding: 1rem;
        border-width: 4px;
    }

    .main-title { font-size: 2rem; }

    .grimoire-layout { grid-template-columns: 1fr; }

    .profile-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .spell-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .character-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    .tapestry-frame img { height: 160px; }

    .codex-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .spell-scroll {
        padding: 1rem;
        min-height: 160px;
    }

    .spell-description { padding-left: 0.8rem; font-size: 0.95rem; }

    .scroll-indicator { right: 15px; opacity: 0.3; }
    .scroll-line      { height: 80px; }

    .scroll-to-top {
        width: 40px;
        height: 40px;
        bottom: 20px;
        right: 20px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .main-title    { font-size: 1.8rem; }
    .section-title { font-size: 1.3rem; }

    .character-gallery { grid-template-columns: 1fr; }
    .tapestry-frame img { height: 200px; }

    .persona-poem  { padding: 1rem; }
    .poem-verse  { font-size: 1rem; }

    .spell-scroll { min-height: 150px; }

    .scroll-indicator { display: none; }
}

@media (max-width: 768px) {
    .scroll-to-top { width: 36px; height: 36px; font-size: 1.1rem; }
    .scroll-to-top .arrow { line-height: 36px; font-size: 1rem; }
}

/* ── 打印优化 ─────────────────────────────────────────────── */
@media print {
    body {
        background: white;
        color: black;
    }

    .grimoire-container {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .expand-btn,
    .ritual-button,
    .tapestry-frame:hover,
    .scroll-to-top,
    .scroll-indicator {
        display: none !important;
    }

    .spell-description { max-height: none !important; }
}
