/**
 * SPA Router 樣式
 * 頂部進度條 + 頁面切換轉場動畫
 */

/* 頂部進度條（類似 YouTube / GitHub） */
#spa-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--ui-primary-color, #0d6efd);
    z-index: 9999;
    transition: width 0.3s ease;
    pointer-events: none;
    box-shadow: 0 0 8px var(--ui-primary-color, #0d6efd);
}

#spa-progress.active {
    animation: spa-progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes spa-progress-indeterminate {
    0% { width: 0; left: 0; }
    50% { width: 60%; left: 20%; }
    100% { width: 0; left: 100%; }
}

#spa-progress.finishing {
    animation: none;
    width: 100% !important;
    left: 0 !important;
    transition: width 0.2s ease;
}

/* ============================
 * 頁面轉場動畫
 * ============================ */

/* 內容區基礎：啟用硬體加速 + 平滑過渡 */
.main-content-wrapper {
    will-change: opacity, transform;
}

/* 淡入 + 上滑（預設，適用大部分導航） */
.spa-fade-in {
    animation: spa-slide-up 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes spa-slide-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡出（切換前的舊內容） */
.spa-fade-out {
    animation: spa-fade-out 0.15s ease-in forwards;
    pointer-events: none;
}

@keyframes spa-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-6px);
    }
}

/* ============================
 * 骨架屏（Skeleton Loading）
 * ============================ */

.spa-skeleton {
    pointer-events: none;
    user-select: none;
}

/* 骨架線條（通用佔位元素） */
.spa-sk-line {
    background: var(--ems-dark-bg-tertiary, #e9ecef);
    border-radius: 6px;
    animation: spa-skeleton-pulse 1.5s ease-in-out infinite;
}

/* 骨架卡片 */
.spa-sk-card {
    height: 80px;
    background: var(--ems-dark-bg-tertiary, #e9ecef);
    border-radius: 8px;
    animation: spa-skeleton-pulse 1.5s ease-in-out infinite;
}

/* 骨架表格區 */
.spa-sk-table {
    border-radius: 8px;
    overflow: hidden;
}

/* 脈搏動畫 */
@keyframes spa-skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.15; }
}

/* 深色模式適配 */
body.dark-mode .spa-sk-line,
body.dark-mode .spa-sk-card {
    background: var(--ems-dark-bg-tertiary, #303134);
}

/* 減少動態效果偏好（無障礙） */
@media (prefers-reduced-motion: reduce) {
    .spa-fade-in,
    .spa-fade-out {
        animation: none !important;
    }

    #spa-progress {
        transition: none !important;
    }

    #spa-progress.active {
        animation: none !important;
        width: 30% !important;
    }
}
