/* ==========================================================================
   Component Styles - 通用组件样式 (v5.4 - 添加 Splash Screen & 骨架屏优化)
   --------------------------------------------------------------------------
   ========================================================================== */

/* --- 核心辅助类 --- */
.is-hidden {
    display: none !important;
}

/* --- 组件: 全屏启动页 (Splash Screen) --- */
.app-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color); /* 与主背景一致，防止闪烁 */
    z-index: 10000; /* 最高层级，遮盖一切 */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out; /* 平滑淡出 */
}

/* 隐藏状态 */
.app-splash-screen.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 2rem;
    max-width: 400px;
}

/* Logo 容器与动画 */
.splash-logo-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
}

.splash-logo {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
    animation: splash-logo-pop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Logo 背后的波纹动画 */
.splash-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background-color: var(--theme-color-default);
    opacity: 0.2;
    border-radius: 50%;
    z-index: 1;
    animation: splash-ripple-effect 2s infinite ease-out;
}

/* 标题与副标题 */
.splash-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-highlight);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
    opacity: 0;
    animation: fadeInUp 0.5s ease-out 0.3s forwards; /* 延迟出现 */
}

.splash-subtitle {
    font-size: 1rem;
    color: var(--text-sub);
    font-weight: 500;
    margin-bottom: 3rem;
    opacity: 0;
    animation: fadeInUp 0.5s ease-out 0.5s forwards;
}

/* 加载区域 */
.splash-loading-area {
    width: 100%;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 0.8s forwards;
}

.splash-status-text {
    font-size: 0.9rem;
    color: var(--text-sub);
    margin-bottom: 0.8rem;
    font-variant-numeric: tabular-nums; /* 防止数字跳动 */
}

/* 进度条轨道 */
.splash-progress-track {
    width: 100%;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

/* 进度条填充 */
.splash-progress-fill {
    height: 100%;
    width: 0%; /* JS 控制 */
    background-color: var(--theme-color-default);
    border-radius: 2px;
    transition: width 0.3s linear;
    /* 添加流光效果 */
    background-image: linear-gradient(
            90deg,
            rgba(255,255,255,0) 0,
            rgba(255,255,255,0.4) 50%,
            rgba(255,255,255,0) 100%
    );
    background-size: 50px 100%;
    background-repeat: no-repeat;
    animation: shimmer 1.5s infinite linear;
}

/* 底部语录 */
.splash-quote {
    position: absolute;
    bottom: 3rem;
    font-size: 0.9rem;
    color: var(--text-sub);
    font-style: italic;
    opacity: 0;
    animation: fadeIn 1s ease-out 1.5s forwards;
}

/* 动画关键帧 */
@keyframes splash-logo-pop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes splash-ripple-effect {
    0% { width: 80%; height: 80%; opacity: 0.4; }
    100% { width: 200%; height: 200%; opacity: 0; }
}

@keyframes shimmer {
    0% { background-position: -50px 0; }
    100% { background-position: 200px 0; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* --- 组件: 年级筛选器按钮 --- */
.grade-filter-btn {
    padding: 10px 24px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary-color);
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.2s ease;
    color: var(--text-sub);

    /* 移动端水平滚动关键：防止文字换行撑开高度 */
    white-space: nowrap;
    flex-shrink: 0; /* 防止被压缩 */
}
.grade-filter-btn:hover {
    border-color: var(--border-color-hover);
    color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.grade-filter-btn.active {
    background: var(--theme-color-default);
    color: var(--text-inverse);
    border-color: var(--theme-color-default);
    box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}
body.dark-mode .grade-filter-btn.active {
    background-color: #4b5563;
    border-color: #4b5563;
}


/* --- 组件: 类别筛选器与控制按钮 --- */
.filter-btn {
    padding: 8px 20px;
    border: 2px solid var(--border-color);
    border-radius: 50px;
    background: var(--bg-secondary-color);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    color: var(--text-sub);

    /* 移动端水平滚动关键 */
    white-space: nowrap;
    flex-shrink: 0;
}
.filter-btn.active {
    background: var(--theme-color-default);
    color: var(--text-inverse);
    border-color: var(--theme-color-default);
}
.filter-btn[data-filter="learned"].active {
    background: var(--color-learned);
    border-color: var(--color-learned);
}
.filter-btn[data-filter-type="user-wordbook"].active {
    background: #0891b2;
    border-color: #0891b2;
}
body.dark-mode .filter-btn[data-filter-type="user-wordbook"].active {
    background: #0e7490;
    border-color: #0e7490;
}
.filter-btn:not(.active):hover {
    border-color: var(--border-color-hover);
    color: var(--text-main);
}


/* --- 组件: 工具栏图标按钮 (通用 / PC端) --- */
.icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-secondary-color);
    cursor: pointer;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.icon-btn:hover {
    border-color: var(--border-color-hover);
    color: var(--text-main);
    background: var(--bg-color);
    transform: translateY(-1px);
}
.icon-btn:active {
    transform: translateY(1px);
}
.icon-btn svg {
    width: 38px; /* 并非比例问题，因为外层button为38 */
    height: 24px;
    transition: transform 0.3s ease;
}
.icon-btn.active {
    background-color: var(--theme-color);
    border-color: var(--theme-color);
    color: var(--text-inverse);
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
}
.shuffle-btn:active svg {
    transform: rotate(45deg);
}

/* --- 组件: 沉浸模式悬浮按钮 (Floating Action Button) --- */
.floating-action-btn {
    display: none; /* 默认在 PC 端隐藏 */
}

@media screen and (max-width: 768px) {
    .floating-action-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        /* 固定在左上角 */
        top: 0.2rem;
        right: 0.2rem;
        /* 高层级，确保在所有卡片之上 */
        z-index: 1100;
        width: 44px;
        height: 44px;

        border-radius: 50%;
        border: none;
        background-color: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(5px);
        color: white;
        cursor: pointer;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        transition: all 0.3s ease;

        /* 避免选中时的点击高亮背景 */
        -webkit-tap-highlight-color: transparent;
    }

    .floating-action-btn:active {
        transform: scale(0.95);
        background-color: rgba(0, 0, 0, 0.6);
    }

    .floating-action-btn svg {
        width: 22px;
        height: 22px;
    }

    /* 深色模式下的微调 */
    body.dark-mode .floating-action-btn {
        background-color: rgba(255, 255, 255, 0.2);
    }
}


/* --- 组件: 移动端底部固定导航栏 (Mobile Bottom Bar) --- */
.mobile-bottom-bar {
    display: none; /* PC端隐藏 */
}

@media screen and (max-width: 768px) {
    .mobile-bottom-bar {
        display: flex;
        /* 移除 justify-content: space-around，改用 flex: 1 让子元素自适应 */
        align-items: center;

        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px; /* 固定高度 */

        background-color: var(--bg-secondary-color);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        z-index: 1000;

        /* 适配 iPhone X 等底部安全区域 */
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(60px + env(safe-area-inset-bottom));

        /* 过渡动画 */
        transition: background-color 0.3s ease, border-color 0.3s ease;
    }

    /* 沉浸模式下，底部栏变半透明 */
    body.mode-immersive .mobile-bottom-bar {
        background-color: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(10px);
        border-top-color: transparent;
        box-shadow: none;
    }
    body.dark-mode.mode-immersive .mobile-bottom-bar {
        background-color: rgba(31, 41, 55, 0.85);
    }

    /*
     * 移动端导航项样式覆盖
     * 适用于 .icon-btn 和 .options-menu-container (通过 mobile-nav-item 类)
     */
    .mobile-bottom-bar .icon-btn,
    .mobile-bottom-bar .options-menu-container {
        flex: 1;              /* 核心：平分宽度 */
        width: 0;             /* 核心：允许收缩，防止溢出 */
        min-width: 0;
        height: 100%;         /* 填满高度，增加点击热区 */

        border: none;         /* 去除边框 */
        border-radius: 0;     /* 去除圆角 */
        background: transparent;
        box-shadow: none;

        /* 内容居中 */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 2px;

        /* 移除 PC 端的 margin/padding 干扰 */
        margin: 0;
        padding: 0;
    }

    /* 针对更多菜单容器内的按钮，需要特殊处理 */
    .mobile-bottom-bar .options-menu-container .icon-btn {
        width: 100%;
        height: 100%;
        flex: 1;
        /* 重置边框等样式，因为容器已经处理了布局 */
        border: none;
        border-radius: 0;
        background: transparent;
    }

    /* 交互反馈：简单的背景色变深 */
    .mobile-bottom-bar .icon-btn:hover,
    .mobile-bottom-bar .icon-btn:active {
        transform: none;
        background-color: rgba(0,0,0,0.03);
    }
    body.dark-mode .mobile-bottom-bar .icon-btn:hover {
        background-color: rgba(255,255,255,0.05);
    }

    .mobile-bottom-bar .icon-btn svg {
        width: 24px;
        height: 24px;
        color: var(--text-sub);
    }

    /* 激活状态下的图标颜色 */
    .mobile-bottom-bar .icon-btn.active svg {
        color: var(--theme-color);
    }

    /* 更多菜单的位置调整：向上弹出 */
    .mobile-bottom-bar .options-menu-container .options-dropdown-menu {
        bottom: 100%;
        top: auto;
        right: 0;
        /* 让菜单相对于按钮右对齐或稍微偏移，根据实际需求调整 */
        transform-origin: bottom right;
        margin-bottom: 0;
        width: 180px;
    }
}


/* --- 组件: 加载/空状态提示 --- */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-sub);

    /* 移动端适配 */
    width: 100%;
    margin-top: 2rem;
}

/* --- 组件: 加载动画 Spinner --- */
.spinner {
    animation: rotate 2s linear infinite;
    width: 40px;
    height: 40px;
}
.spinner .path {
    stroke: var(--text-sub);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}


/* --- 组件: 更多操作下拉菜单 --- */
.options-menu-container {
    position: relative;
    display: flex;
}
.options-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 200px;
    background-color: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0;
    z-index: 100;
    list-style: none;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    pointer-events: none;
    transform-origin: top right;
}
.options-dropdown-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.menu-item:hover {
    background-color: var(--bg-color);
}
.menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: currentColor;
}
.menu-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}


/* --- 全局状态与动画 --- */
/* 洗牌动画 */
.card-grid.is-shuffling .card {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* 无图自测模式 */
body.mode-no-visual .card-front .visual-area svg {
    opacity: 0;
    transition: opacity 0.3s ease;
}
body.mode-no-visual .card-front .visual-area {
    position: relative;
}
body.mode-no-visual .card-front .visual-area::after {
    content: "?";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    font-weight: 800;
    color: var(--border-color);
    opacity: 0.5;
    font-family: 'Courier New', monospace;
    pointer-events: none;
}


/* --- 通用美化: 滚动条 --- */
.sentence-section::-webkit-scrollbar {
    width: 6px;
}
.sentence-section::-webkit-scrollbar-track {
    background: transparent;
}
.sentence-section::-webkit-scrollbar-thumb {
    background-color: var(--border-color-hover);
    border-radius: 10px;
}
.sentence-section::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-sub);
}