/* ============================================================
   短视频沉浸式信息流（TikTok 式）
   仅在 shorts.php 加载（body.shorts-page）
   ============================================================ */

/* ── 接管全屏：隐藏全站外壳，进入沉浸模式 ── */
body.shorts-page {
    overflow: hidden;
    background: #000;
    height: 100dvh;
}
body.shorts-page .navbar,
body.shorts-page .footer,
body.shorts-page .back-to-top,
body.shorts-page .announcement-bar,
body.shorts-page .mobile-menu,
body.shorts-page .mobile-menu-overlay {
    display: none !important;
}
body.shorts-page main.container {
    max-width: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

/* ── 应用容器：固定全屏 ── */
.shorts-app {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: #050507;
    color: #fff;
    overflow: hidden;
    z-index: 1;
    --rail-fg: rgba(255, 255, 255, 0.95);
}

/* ── 顶栏（悬浮在视频上方） ── */
.shorts-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: max(10px, env(safe-area-inset-top)) 14px 26px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
}
.shorts-bar > * { pointer-events: auto; }
.shorts-bar-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.2s, transform 0.15s;
    text-decoration: none;
}
.shorts-bar-btn:active { transform: scale(0.9); }
.shorts-bar-btn:hover { background: rgba(255, 255, 255, 0.2); }
.shorts-sound.on { background: var(--shorts-accent); }
.shorts-bar-title {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.02rem;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.shorts-bar-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.shorts-bar-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.shorts-vip-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f7c948, #f0932b);
    color: #1a1300;
    font-weight: 800;
    font-size: 0.85rem;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(240, 147, 43, 0.4);
    transition: transform 0.15s;
}
.shorts-vip-btn:active { transform: scale(0.94); }

/* ── 滑动舞台 ── */
.shorts-stage {
    position: absolute;
    inset: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}
.shorts-stage::-webkit-scrollbar { display: none; }

/* ── 单屏 ── */
.shorts-slide {
    position: relative;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 模糊背景填充信箱区 */
.shorts-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(44px) brightness(0.42) saturate(1.2);
    transform: scale(1.25);
    z-index: 0;
}

/* 媒体层（视频/封面，contain 不裁切） */
.shorts-media {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.shorts-poster {
    position: absolute;
    inset: 0;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}
.shorts-video {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
}

/* 播放/暂停指示 */
.shorts-playicon {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: 50%;
    width: 78px;
    height: 78px;
    transform: translate(-50%, -50%) scale(0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 1.8rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    backdrop-filter: blur(4px);
}
.shorts-slide.paused .shorts-playicon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* 缓冲转圈 */
.shorts-buffering {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.shorts-buffering.show { opacity: 1; }
.shorts-spinner {
    display: block;
    width: 42px;
    height: 42px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--shorts-accent, #fff);
    border-radius: 50%;
    animation: shortsSpin 0.8s linear infinite;
}
@keyframes shortsSpin { to { transform: rotate(360deg); } }

/* 无源 / 错误 */
.shorts-nosrc {
    position: absolute;
    z-index: 4;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.shorts-nosrc i { font-size: 2rem; opacity: 0.7; }
.shorts-nosrc p { margin: 0; font-size: 0.95rem; }

/* ── 锁定（付费引导） ── */
.shorts-media.locked .shorts-poster {
    filter: blur(26px) brightness(0.5) saturate(1.1);
    transform: scale(1.12);
}
.shorts-lock {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 28px;
    gap: 12px;
    background: radial-gradient(120% 80% at 50% 50%, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.55));
}
.shorts-lock-badge {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    color: #1a1300;
    background: linear-gradient(135deg, #f7c948, #f0932b);
    box-shadow: 0 8px 30px rgba(240, 147, 43, 0.45);
    margin-bottom: 4px;
}
.shorts-lock-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    max-width: 90%;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.shorts-lock-sub {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.72);
    max-width: 280px;
    line-height: 1.5;
}
.shorts-lock-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}
.shorts-unlock-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 34px;
    border-radius: 30px;
    background: linear-gradient(135deg, #f7c948, #f0932b);
    color: #1a1300;
    font-weight: 800;
    font-size: 1rem;
    text-decoration: none;
    box-shadow: 0 8px 26px rgba(240, 147, 43, 0.45);
    animation: shortsPulse 2.4s ease-in-out infinite;
}
@keyframes shortsPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
.shorts-unlock-btn:active { transform: scale(0.96); }
.shorts-login-link {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* ── 底部渐变遮罩 ── */
.shorts-shade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 42%;
    z-index: 6;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.28) 45%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
}

/* ── 底部信息 ── */
.shorts-meta {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 8;
    width: calc(100% - 86px);
    padding: 0 16px max(20px, env(safe-area-inset-bottom)) 16px;
    pointer-events: none;
}
.shorts-meta a, .shorts-meta button { pointer-events: auto; }
.shorts-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 0;
}
.shorts-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 700;
    backdrop-filter: blur(4px);
}
.shorts-tag.free { background: rgba(76, 217, 168, 0.92); color: #04241a; }
.shorts-tag.vip { background: linear-gradient(135deg, #f7c948, #f0932b); color: #1a1300; }
.shorts-tag.lock { background: rgba(255, 255, 255, 0.16); color: #fff; }
.shorts-name {
    margin: 0 0 6px;
    font-size: 1.06rem;
    font-weight: 700;
    line-height: 1.35;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.shorts-subline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.78);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.shorts-subline .dot { opacity: 0.5; }

/* ── 右侧操作轨 ── */
.shorts-rail {
    position: absolute;
    right: 8px;
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 9;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}
.shorts-rail-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--rail-fg);
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
/* 图标直接是按钮的 <i> 子元素（不加包裹 span，以兼容 app.js Favorite.toggle 的 DOM 假设） */
.shorts-rail-btn > i {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-size: 1.3rem;
    transition: transform 0.15s, background 0.2s;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}
.shorts-rail-btn:active > i { transform: scale(0.88); }
.shorts-rail-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.shorts-rail-btn.btn-favorite.favorited > i {
    background: rgba(255, 77, 109, 0.22);
    color: #ff4d6d;
}

/* ── 进度条 ── */
.shorts-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    z-index: 12;
    background: rgba(255, 255, 255, 0.16);
}
.shorts-progress > i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--shorts-accent, #fff);
    border-radius: 0 2px 2px 0;
    transition: width 0.18s linear;
}

/* ── 到底页 / 空状态 / 重试 ── */
.shorts-end .shorts-end-inner,
.shorts-retry .shorts-end-inner {
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.shorts-end .shorts-end-inner i,
.shorts-retry .shorts-end-inner i { font-size: 2.4rem; color: var(--shorts-accent); }
.shorts-end .shorts-end-inner p,
.shorts-retry .shorts-end-inner p { margin: 0; font-size: 1rem; }
.shorts-mini-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 9px 22px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}
.shorts-mini-btn:hover { background: rgba(255, 255, 255, 0.22); }

/* ── 初始加载 ── */
.shorts-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ── 首次滑动提示 ── */
.shorts-hint {
    position: absolute;
    left: 50%;
    bottom: 16%;
    z-index: 15;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.85rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    animation: shortsUp 1.5s ease-in-out infinite;
}
.shorts-hint i { font-size: 1.5rem; }
@keyframes shortsUp {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.6; }
    50% { transform: translateX(-50%) translateY(-8px); opacity: 1; }
}

/* ── 桌面端：把竖向信息流约束成手机比例居中，两侧留白 ── */
@media (min-width: 768px) {
    .shorts-app {
        background: #0a0a0f;
    }
    .shorts-stage {
        width: 440px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        box-shadow: 0 0 80px rgba(0, 0, 0, 0.6);
    }
    .shorts-bar {
        width: 440px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    .shorts-hint { bottom: 12%; }
}

/* ── 双击点赞飘心 ── */
.shorts-heart-pop {
    position: absolute;
    z-index: 14;
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
    color: #ff4d6d;
    font-size: 5rem;
    pointer-events: none;
    filter: drop-shadow(0 4px 12px rgba(255, 77, 109, 0.5));
    animation: shortsHeartPop 0.9s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
    will-change: transform, opacity;
}
@keyframes shortsHeartPop {
    0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(0.2); }
    15% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.15); }
    30% { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(0.95); }
    100% { opacity: 0; transform: translate(-50%, -90%) rotate(var(--rot, 0deg)) scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
    .shorts-heart-pop { animation-duration: 0.4s; }
    .shorts-unlock-btn { animation: none; }
    .shorts-hint { animation: none; }
}
