/* ===== animations.css ===== */
/* 用途：所有 @keyframes 定义以及入场动画类 */

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 var(--accent-dim);
    }

    50% {
        box-shadow: 0 0 12px 2px var(--accent-dim);
    }

    100% {
        box-shadow: 0 0 0 0 var(--accent-dim);
    }
}

@keyframes star-drift {
    0% {
        background-position: 0 0, 0 0, 0 0;
    }

    100% {
        background-position: 200px 200px, -150px 150px, 180px -180px;
    }
}

@keyframes resultFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 可直接使用的动画类 */
.animate-fade-up {
    animation: fade-in-up 0.6s ease forwards;
}

/* ===== 新增丰富动画效果 ===== */

/* 按钮点击涟漪 */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.4);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.btn-ripple:active::after {
    animation: ripple 0.4s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }

    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

/* 卡片入场交错动画 */
@keyframes card-stagger {
    0% {
        opacity: 0;
        transform: translateY(24px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-event {
    animation: card-stagger 0.4s ease forwards;
    opacity: 0;
}

.timeline-event:nth-child(1) {
    animation-delay: 0.05s;
}

.timeline-event:nth-child(2) {
    animation-delay: 0.1s;
}

.timeline-event:nth-child(3) {
    animation-delay: 0.15s;
}

.timeline-event:nth-child(4) {
    animation-delay: 0.2s;
}

.timeline-event:nth-child(5) {
    animation-delay: 0.25s;
}

.timeline-event:nth-child(n+6) {
    animation-delay: 0.3s;
}

/* 模态框弹性入场 */
@keyframes modal-pop {
    0% {
        opacity: 0;
        transform: scale(0.92);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.history-modal:not(.hidden) .modal-container {
    animation: modal-pop 0.25s cubic-bezier(0.2, 0.9, 0.4, 1) forwards;
}

/* 悬停发光脉冲 */
@keyframes glow-pulse {

    0%,
    100% {
        box-shadow: 0 0 5px var(--accent-dim);
    }

    50% {
        box-shadow: 0 0 20px var(--accent-glow);
    }
}

.extra-btn.active {
    animation: glow-pulse 2s infinite;
}

/* 结果项渐显（已移至 search.css） */

/* 背景光晕移动 */
@keyframes bg-shimmer {
    0% {
        background-position: 0% 0%;
    }

    100% {
        background-position: 200% 0%;
    }
}

.hero h1 {
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 50%, var(--accent) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: bg-shimmer 4s linear infinite;
}

/* ===== 模态框退出动画 ===== */
.history-modal.closing .modal-container {
    animation: modal-pop-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes modal-pop-out {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.92);
    }
}

/* 登录模态框同样支持退出动画（使用相同效果） */
.auth-modal.closing .auth-modal-content {
    animation: modal-pop-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* 密码错误抖动 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.auth-modal-content.shake {
    animation: shake 0.4s ease-in-out;
}

/* ===== UX 增强动画 ===== */

/* 按钮按压缩放反馈 */
@keyframes btn-press {
    0% { transform: scale(1); }
    50% { transform: scale(0.96); }
    100% { transform: scale(1); }
}

.btn-press:active {
    animation: btn-press 0.2s ease;
}

/* 视图切换淡入 */
@keyframes view-enter {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chronicle-grid.view-enter,
.stats-container.view-enter {
    animation: view-enter 0.35s ease forwards;
}

/* 欢迎消息滑入 */
@keyframes welcome-slide {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.welcome-message {
    animation: welcome-slide 0.4s cubic-bezier(0.2, 0.9, 0.4, 1) forwards;
}

/* 人物卡片交错入场 */
.character-card {
    opacity: 0;
    transform: translateY(20px);
    animation: card-stagger 0.35s ease forwards;
}

.characters-grid .character-card:nth-child(1) { animation-delay: 0.03s; }
.characters-grid .character-card:nth-child(2) { animation-delay: 0.06s; }
.characters-grid .character-card:nth-child(3) { animation-delay: 0.09s; }
.characters-grid .character-card:nth-child(4) { animation-delay: 0.12s; }
.characters-grid .character-card:nth-child(5) { animation-delay: 0.15s; }
.characters-grid .character-card:nth-child(6) { animation-delay: 0.18s; }
.characters-grid .character-card:nth-child(7) { animation-delay: 0.21s; }
.characters-grid .character-card:nth-child(8) { animation-delay: 0.24s; }
.characters-grid .character-card:nth-child(9) { animation-delay: 0.27s; }
.characters-grid .character-card:nth-child(10) { animation-delay: 0.3s; }
.characters-grid .character-card:nth-child(n+11) { animation-delay: 0.33s; }

/* 模态框遮罩淡入 */
.history-modal:not(.hidden) .modal-overlay {
    animation: fade-in 0.2s ease forwards;
}

.history-modal.closing .modal-overlay {
    animation: fade-out 0.15s ease forwards;
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* 排序控件切换动画 */
.record-sort-container,
.character-sort-container {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.record-sort-container.hidden,
.character-sort-container.hidden {
    display: none !important;
}

/* 页脚淡入 */
@keyframes footer-fade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

footer {
    animation: footer-fade 0.6s ease 0.3s both;
}

/* 类别导航切换 */
.extra-categories .extra-btn {
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.4, 1);
}

.extra-categories .extra-btn:not(.active):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 169, 89, 0.15);
}

.extra-categories .extra-btn.active {
    animation: glow-pulse 2s infinite;
}

/* 年级按钮点击弹跳 */
.grade-btn:active {
    transform: scale(0.94);
    transition: transform 0.1s;
}

/* 搜索触发框悬停增强 */
.search-trigger-box {
    transition: all 0.25s cubic-bezier(0.2, 0.9, 0.4, 1);
}

.search-trigger-box:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(201, 169, 89, 0.12);
}

/* 随机按钮悬停增强 */
#randomBtn {
    transition: all 0.25s cubic-bezier(0.2, 0.9, 0.4, 1);
}

#randomBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 169, 89, 0.25);
}

#randomBtn:active {
    transform: scale(0.96);
}

/* 导航按钮悬停增强 */
.nav-btn {
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.4, 1);
}

.nav-btn:hover {
    transform: translateY(-1px);
}

.nav-btn:active {
    transform: scale(0.96);
}

/* 返回顶部按钮出场 */
.back-to-top {
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1) !important;
}

.back-to-top:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(201, 169, 89, 0.3);
}

.back-to-top:active {
    transform: scale(0.92);
}

/* 时间轴卡片悬停强化 */
.timeline-event-copy {
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1) !important;
}

.timeline-event-copy:hover {
    transform: translateX(6px) translateY(-2px) !important;
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent-dim), 0 8px 30px rgba(201, 169, 89, 0.08) !important;
}

/* 人物卡片悬停强化 */
.character-card {
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1);
}

.character-card:hover {
    transform: translateY(-6px) !important;
    box-shadow: var(--shadow-md), 0 0 0 1px var(--accent-dim) !important;
}

.character-card:active {
    transform: scale(0.97) !important;
}

/* 模态框内容滚动条美化 */
.modal-container::-webkit-scrollbar {
    width: 4px;
}

.modal-container::-webkit-scrollbar-thumb {
    background: var(--accent-dim);
    border-radius: 4px;
}

/* 输入框聚焦光晕 */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-dim), 0 0 12px rgba(201, 169, 89, 0.1);
    transition: all 0.2s ease;
}

/* 搜索模态框输入框聚焦 */
.inner-search-input:focus {
    box-shadow: 0 0 0 3px var(--accent-dim), 0 0 16px rgba(201, 169, 89, 0.08);
}

/* 加载骨架屏优化 */
.skeleton-card {
    animation: skeleton-loading 1.2s ease-in-out infinite;
}

/* 相关人物卡片点击过渡 */
.related-record-item {
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.4, 1);
}

.related-record-item:hover {
    transform: translateX(8px);
}