/* ===== 视频详情页样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #121212; color: #fff; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* 顶部导航 */
.detail-header {
    position: fixed; top: 0; left: 0; right: 0; max-width: 750px; margin: 0 auto;
    height: clamp(44px, 6.67vw, 56px); background: #1e1e1e;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 0.75rem; padding-top: env(safe-area-inset-top);
    z-index: 100; border-bottom: 1px solid #2a2a2a;
}
.back-btn {
    width: 32px; height: 32px; background: #2a2a2a; border: none; border-radius: 50%;
    color: #e0e0e0; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.back-btn:active { background: #3a3a3a; }
.back-icon { font-weight: bold; line-height: 1; }
.detail-title {
    flex: 1; text-align: center; font-size: clamp(14px, 3.2vw, 16px);
    font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; padding: 0 10px;
}
.header-placeholder { width: 32px; flex-shrink: 0; }

/* 主内容区 */
.detail-main {
    width: 100%; max-width: 750px; margin: 0 auto;
    padding-top: calc(clamp(44px, 6.67vw, 56px) + min(56.25vw, 421.875px));
    padding-bottom: 3.5rem; min-height: 100vh; background: #121212;
}

/* 播放器区域 */
.player-section {
    position: fixed; top: clamp(44px, 6.67vw, 56px); left: 0; right: 0;
    width: 100%; max-width: 750px; margin: 0 auto; background: #000; z-index: 99;
}
.player-container {
    position: relative; width: 100%; padding-top: 56.25%;
    background: #000; margin: 0; overflow: hidden;
}

/* 视频元素 - 藏到屏幕外，安卓浏览器看不到就不会劫持 */
#detailVideo {
    position: absolute; left: -9999px; top: -9999px;
    width: 1px; height: 1px;
    opacity: 0; pointer-events: none;
}

/* Canvas画布 - 替代video显示画面 */
#detailCanvas {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

/* Poster封面图 - 视频加载前显示 */
#detailPoster {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 2;
}

/* 加载转圈 */
.player-loading {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    pointer-events: none; z-index: 10;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    color: #00c896; font-size: 0.875rem;
}
.player-loading.hidden { display: none; }
.loading-spinner {
    width: 36px; height: 36px; border: 3px solid rgba(0, 200, 150, 0.2);
    border-top-color: #00c896; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 控制栏 - 最上层 */
.detail-controls {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
    background: linear-gradient(transparent, rgba(0,0,0,0.75));
    z-index: 20; transition: opacity 0.3s;
}
.detail-controls-hidden { opacity: 0; pointer-events: none; }
.detail-controls-row {
    display: flex; align-items: center; gap: 10px;
}
.detail-ctrl-btn {
    color: #fff; font-size: 22px; cursor: pointer;
    user-select: none; -webkit-user-select: none;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; touch-action: manipulation;
    border-radius: 50%;
}
.detail-ctrl-btn:active { opacity: 0.6; background: rgba(255,255,255,0.15); }
.detail-time {
    color: #fff; font-size: 12px; font-family: monospace;
    flex-shrink: 0; min-width: 40px; text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.detail-ctrl-progress {
    flex: 1; height: 28px; position: relative; cursor: pointer;
    display: flex; align-items: center; touch-action: none;
}
.detail-ctrl-progress::before {
    content: ''; position: absolute; top: 50%; left: 0; right: 0;
    height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px;
    transform: translateY(-50%); pointer-events: none;
}
.detail-ctrl-buffered {
    position: absolute; top: 50%; left: 0; height: 4px;
    background: rgba(255,255,255,0.3); border-radius: 2px;
    transform: translateY(-50%); pointer-events: none;
}
.detail-ctrl-played {
    position: absolute; top: 50%; left: 0; height: 4px;
    background: #00c896; border-radius: 2px;
    transform: translateY(-50%); pointer-events: none;
}
.detail-ctrl-handle {
    position: absolute; top: 50%; width: 16px; height: 16px;
    background: #fff; border-radius: 50%;
    transform: translate(-50%, -50%); pointer-events: none;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* 排序tab栏 */
.tabs-section { background: #1e1e1e; border-bottom: 1px solid #2a2a2a; position: sticky; top: 0; z-index: 50; }
.tabs-bar {
    display: flex; align-items: center; padding: 0 0.5rem;
    height: clamp(38px, 5.6vw, 44px);
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab-item {
    flex-shrink: 0; padding: 0 0.75rem; height: 28px; line-height: 28px;
    font-size: 0.875rem; color: #888; cursor: pointer; border-radius: 14px;
    margin-right: 0.25rem; transition: all 0.2s; white-space: nowrap;
}
.tab-item:active { opacity: 0.7; }
.tab-item.active { color: #fff; background: #2a2a2a; font-weight: 500; }
.view-toggle {
    flex-shrink: 0; margin-left: auto; padding-left: 0.5rem;
    width: 36px; height: 28px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #888; font-size: 18px; background: #1e1e1e;
}
.view-toggle:active { color: #00c896; }
.view-icon { line-height: 1; }

/* 视频列表 */
.video-list-section {
    padding: 0.75rem;
    margin: 0.5rem;
    background: #1a1a1a;
    border-radius: 12px;
    border: 1px solid #333;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.video-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.video-grid.list-view { grid-template-columns: 1fr; }
.loading-text { grid-column: 1 / -1; text-align: center; color: #666; padding: 1.25rem; font-size: 0.875rem; }
.video-card {
    background: #000; border-radius: 8px; overflow: hidden; cursor: pointer;
    transition: transform 0.15s; border: 1px solid #1a1a1a;
}
.video-card:active { transform: scale(0.97); }
.video-cover {
    position: relative; width: 100%; padding-top: 56.25%;
    background: #000; overflow: hidden;
}
.video-cover img {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.video-duration {
    position: absolute; right: 6px; bottom: 6px;
    background: rgba(0, 0, 0, 0.75); color: #fff;
    font-size: 0.6875rem; padding: 2px 6px; border-radius: 4px;
}
.video-info { padding: 0.5rem 0.625rem 0.625rem; }
.video-card-title {
    font-size: 0.8125rem; font-weight: 500; color: #fff; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; height: 2.1em;
}
.video-card-meta {
    margin-top: 4px; font-size: 0.6875rem; color: #999;
    display: flex; align-items: center; gap: 6px;
}
.video-card-category { color: #00c896; }

/* 列表视图 */
.video-grid.list-view .video-card { display: flex; flex-direction: row; }
.video-grid.list-view .video-cover { width: 160px; min-width: 160px; padding-top: 90px; }
.video-grid.list-view .video-info {
    flex: 1; padding: 0.625rem 0.75rem;
    display: flex; flex-direction: column; justify-content: center;
}
.video-grid.list-view .video-card-title { height: auto; -webkit-line-clamp: 2; }

/* 底部导航 */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    padding-bottom: env(safe-area-inset-bottom); max-width: 750px; margin: 0 auto;
}

/* 错误提示 */
.error-msg { text-align: center; color: #ff6b6b; padding: 2rem 1rem; font-size: 0.875rem; }
.error-msg button {
    margin-top: 0.75rem; padding: 8px 20px;
    background: #00c896; color: #fff; border: none;
    border-radius: 6px; font-size: 0.875rem; cursor: pointer;
}

/* 全屏模式保障 */
.player-container:-webkit-full-screen {
    width: 100% !important; height: 100% !important;
    padding-top: 0 !important; max-width: none !important;
    background: #000;
}
.player-container:fullscreen {
    width: 100% !important; height: 100% !important;
    padding-top: 0 !important; max-width: none !important;
    background: #000;
}
.player-container:fullscreen #detailCanvas {
    width: 100% !important; height: 100% !important;
}

@keyframes randomShake { 0% { transform: translateX(0); } 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } 100% { transform: translateX(0); } }
.tab-item[data-sort='random'].shake { animation: randomShake 0.3s ease; }
