/* ===================================================================
   Bilibili 追番展示墙样式 (anime.css)
=================================================================== */

/* --- 1. 网格与卡片布局 --- */
.bili-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
    margin-top: 20px;
}

/* 外层容器：消除移动端点击时的长方形描边和高亮阴影 */
.bili-card-wrapper {
    display: block;
    text-decoration: none;
    height: 100%;
    cursor: pointer;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
}

.bili-card-wrapper:focus,
.bili-card-wrapper:active {
    outline: none !important;
}

/* 内层卡片：负责显示UI和动画位移 */
.bili-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    border-radius: 14px;
    padding: 10px;
    height: 100%;
    box-sizing: border-box;
    background: linear-gradient(180deg, rgba(150, 150, 150, 0.06), rgba(150, 150, 150, 0.02));
    border: 1px solid rgba(150, 150, 150, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* 悬停外层容器时，让内层卡片上浮并加深阴影 */
.bili-card-wrapper:hover .bili-card {
    transform: translateY(-4px);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.15);
    border-color: rgba(150, 150, 150, 0.3);
}

/* 封面包装器 */
.cover-wrapper {
    position: relative;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
}

/* 番剧封面图 */
.bili-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
}

/* 番剧标题 */
.bili-card h3 {
    width: 100%;
    font-size: 1.15rem;
    margin: 12px 0 0 0;
    padding: 0;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: none;
}

/* --- 2. 徽章与悬停特效 --- */

.watched-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(255, 107, 107, 0.9);
    color: white;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 5;
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    border-radius: inherit;
    /* 随容器自动变更圆角 */
    z-index: 10;
}

.bili-card-wrapper:hover .play-overlay {
    opacity: 1;
}

.play-text {
    color: #ffffff;
    background-color: var(--accent-color, #ff6b6b);
    font-size: 1.1rem;
    font-weight: bold;
    padding: 8px 18px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bili-card-wrapper:hover .play-text {
    transform: scale(1);
}

/* --- 3. 模态播放器窗口 --- */
.anime-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.anime-modal.active {
    display: flex;
}

.anime-modal-content {
    background: var(--card-background-color, #ffffff);
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    margin-top: 3vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
}

.anime-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color, #e5e5e5);
    position: relative;
    z-index: 100;
}

.anime-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anime-modal-tools {
    display: flex;
    align-items: center;
    gap: 15px;
}

.anime-tool-btn {
    background: var(--background-color, #f0f0f0);
    border: 1px solid var(--border-color, #ddd);
    color: var(--text-color, #333);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.anime-tool-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.anime-modal-close {
    background: transparent;
    border: none;
    color: var(--text-color, #333);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.anime-modal-close:hover {
    color: var(--accent-color, #ff6b6b);
}

.anime-modal-body {
    flex: 1;
    background: #000;
    position: relative;
    overflow: hidden;
}

.anime-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* --- 4. 选集侧边栏 --- */
.anime-episode-sidebar {
    position: absolute;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100%;
    background: rgba(25, 25, 25, 0.98);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    z-index: 2147483647;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.anime-episode-sidebar.show {
    right: 0;
}

.sidebar-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

#sidebar-close-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

#sidebar-close-btn:hover {
    color: #fff;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 80px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.episode-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ddd;
    padding: 12px 15px;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.episode-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.episode-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
    font-weight: bold;
}


/* --- 5. 右键角色菜单 --- */
.anime-context-menu {
    position: fixed;
    display: none;
    width: 320px;
    background: var(--card-background-color, #ffffff);
    border: 1px solid var(--border-color, #e5e5e5);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    overflow: hidden;
    flex-direction: column;
}

.anime-context-menu.show {
    display: flex;
}

.context-menu-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #e5e5e5);
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    color: var(--text-color, #333);
}

.loading-text {
    font-size: 0.85rem;
    color: var(--accent-color, #ff6b6b);
}

.context-menu-body {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-height: 320px;
    overflow-y: auto;
}

.character-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.character-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color, #eee);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.character-name {
    font-size: 0.8rem;
    color: var(--text-color, #333);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.context-menu-body::-webkit-scrollbar {
    width: 6px;
}

.context-menu-body::-webkit-scrollbar-track {
    background: transparent;
}

.context-menu-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* --- 6. 响应式布局 --- */
@media (max-width: 1200px) {
    .bili-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .bili-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ★ 移动端重新设计：圆形布局 */
@media (max-width: 768px) {
    .bili-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }

    .bili-card-wrapper {
        max-width: 100%;
        position: relative;
    }

    .bili-card {
        border-radius: 50%;
        padding: 4px;
        /* 外层发光感/边距 */
        aspect-ratio: 1 / 1;
        height: auto;
        background: transparent;
        /* 取消原本的方形背景 */
        border: 2px solid rgba(150, 150, 150, 0.2);
    }

    .cover-wrapper {
        border-radius: 50%;
        width: 100%;
        height: auto;
        /* ★ 改为 auto */
    }

    .bili-card img {
        width: 100%;
        /* ★ 补充宽度100% */
        height: auto;
        /* ★ 覆盖掉之前的 height: 100% */
        aspect-ratio: 1 / 1;
        border-radius: 50%;
        object-fit: cover;
        display: block;
        /* ★ 防止底部留白 */
    }

    .bili-card h3 {
        position: absolute;
        bottom: -28px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.9rem;
        width: 120%;
        text-align: center;
        background: transparent;
        color: var(--text-color);
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        margin: 0;
    }

    /* 使模态框适应手机 */
    .anime-modal {
        padding: 0;
    }

    .anime-modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin-top: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .anime-modal-body {
        flex: none;
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        min-height: 30vh;
    }

    .anime-episode-sidebar {
        width: 240px !important;
        right: -240px !important;
    }

    .anime-episode-sidebar.show {
        right: 0 !important;
    }

    #anime-episode-btn,
    #sidebar-close-btn {
        display: flex !important;
    }
}

/* 手机端更小屏幕 */
@media (max-width: 480px) {
    .bili-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
        margin-bottom: 20px;
    }
}

/* --- 7. 暗色模式 (Dark Mode) 适配 --- */
html.dark-mode .bili-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    html.dark-mode .bili-card {
        background: transparent;
    }
}

html.dark-mode .anime-modal-content {
    background: #1e1e1e;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

html.dark-mode .anime-modal-header {
    border-color: #333;
}

html.dark-mode .anime-modal-header h2,
html.dark-mode .anime-modal-close {
    color: #eee;
}

html.dark-mode .anime-tool-btn {
    background: #2a2a2a;
    border-color: #444;
    color: #ddd;
}

html.dark-mode .anime-tool-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* 暗色模式 - 右键菜单 */
html.dark-mode .anime-context-menu {
    background: #262626;
    border-color: #333;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html.dark-mode .context-menu-header {
    border-color: #333;
    color: #eee;
}

html.dark-mode .character-name {
    color: #eee;
}

html.dark-mode .character-avatar {
    border-color: #444;
}

html.dark-mode .context-menu-body::-webkit-scrollbar-thumb {
    background: #555;
}

/* --- 换源下拉框样式 --- */
#anime-source-select {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    margin-right: 10px;
}

#anime-source-select option {
    background: #222;
    color: #fff;
}

/* --- artplayer播放器 --- */
.artplayer-app {
    background: #000;
}

/* ===================================================================
   ★ 新增：全屏与网页全屏专用的层级和定位修复 
=================================================================== */
.anime-episode-sidebar.fixed-fullscreen {
    position: fixed !important;
    top: 0 !important;
    height: 100vh !important;
    z-index: 2147483647 !important;
}