/* 详情页 Hero：背景大图 + 预告片 + 三层渐变遮罩 + 底部对齐内容。
   结构参考 cineby.at 的做法：背景图始终在底层不移除，预告片就绪后淡入覆盖，
   预告片一播就把标题缩小、元信息与简介折叠，把画面让给视频。 */

.tvb-hero {
    position: relative;
    width: 100%;
    /* 对齐 cineby 的 80vh：详情页要有整屏观感，太矮会变成横幅 */
    height: 80vh;
    min-height: 460px;
    max-height: 820px;
    overflow: hidden;
    background: #09090b;
    flex-shrink: 0;
}

/* ① 背景大图 */
.tvb-hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 20%;
    background-repeat: no-repeat;
}

/* 没有横版背景时只能用竖版海报硬撑：放大 + 模糊，避免拉伸变形太扎眼。
   模糊别下手太重 —— 糊成一团色块就完全看不出是哪部片了，
   靠遮罩层压暗保证左侧文字可读即可。 */
.tvb-hero-bg-poster {
    filter: blur(18px) saturate(1.2) brightness(0.9);
    transform: scale(1.15);
}

/* ② 背景视频层：默认透明，真正出画面才淡入 */
.tvb-hero-video {
    position: absolute;
    inset: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    pointer-events: none;
    border: 0;
}
.tvb-hero-video.tvb-hero-video-on {
    opacity: 1;
}
/* 片源流：直接铺满并裁切，本来就是正片画面，不需要放大去黑边 */
.tvb-hero-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ③ 遮罩：横向压暗左侧、纵向收到页面底色、右上角氛围光 */
.tvb-hero-scrim-x,
.tvb-hero-scrim-y,
.tvb-hero-glow {
    position: absolute;
    pointer-events: none;
}
.tvb-hero-scrim-x {
    inset: 0;
    background: linear-gradient(90deg, rgba(9, 9, 11, 0.88) 0%, rgba(9, 9, 11, 0.5) 45%, rgba(9, 9, 11, 0) 72%);
}
.tvb-hero-scrim-y {
    inset: 0;
    background: linear-gradient(to bottom, rgba(9, 9, 11, 0.6) 0%, rgba(9, 9, 11, 0) 25%, rgba(9, 9, 11, 0) 60%, #09090b 100%);
}
.tvb-hero-glow {
    top: -10%;
    right: -8%;
    width: 55%;
    height: 45%;
    background: radial-gradient(rgba(99, 102, 241, 0.18) 0%, rgba(99, 102, 241, 0.06) 32%, rgba(0, 0, 0, 0) 62%);
}

/* 预览静音开关：压在氛围光之上、内容层之外的右上角 */
.tvb-hero-mute {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #e4e4e7;
    background: rgba(9, 9, 11, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.2s, transform 0.12s, border-color 0.2s;
}
.tvb-hero-mute:hover {
    background: rgba(9, 9, 11, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}
.tvb-hero-mute:active {
    transform: scale(0.92);
}
.tvb-hero-mute:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}
@media (min-width: 768px) {
    .tvb-hero-mute {
        top: 1.5rem;
        right: 1.5rem;
    }
}

/* ④ 内容层 */
.tvb-hero-content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.875rem;
    padding: 0 1.5rem 2.5rem;
    max-width: 52rem;
}
/* 文字衬底：背景是会动的正片画面，光靠外层横向遮罩压不住，
   这里再给信息区兜一层由下而上的柔性暗场，保证任何一帧下都可读 */
.tvb-hero-content::before {
    content: '';
    position: absolute;
    left: 0;
    right: -6rem;
    bottom: 0;
    top: -2rem;
    background: linear-gradient(to top, rgba(9, 9, 11, 0.92) 0%, rgba(9, 9, 11, 0.72) 45%, rgba(9, 9, 11, 0) 100%);
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 62%, transparent 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 62%, transparent 100%);
    pointer-events: none;
    z-index: -1;
}
@media (min-width: 768px) {
    .tvb-hero-content {
        padding: 0 3rem 3rem;
    }
}
@media (min-width: 1280px) {
    .tvb-hero-content {
        padding: 0 5rem 3.5rem;
    }
}

.tvb-hero-title-wrap {
    transform-origin: left bottom;
    transition: transform 0.5s cubic-bezier(0, 0, 0.2, 1);
}
.tvb-hero-logo {
    max-width: min(26rem, 70%);
    max-height: 8rem;
    object-fit: contain;
    object-position: left bottom;
    filter: drop-shadow(0 2px 14px rgba(0, 0, 0, 0.7));
}
.tvb-hero-title {
    font-size: clamp(2rem, 4.6vw, 3.5rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.1;
    color: #fafafa;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
}

/* 演职人员：单行截断，信息密度高但不抢版面 */
.tvb-hero-credits {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.62);
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0, 0, 0.2, 1), opacity 0.5s cubic-bezier(0, 0, 0.2, 1);
    max-height: 4rem;
    opacity: 1;
}
.tvb-hero-credits span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tvb-hero-credits b {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    margin-right: 0.5rem;
}

/* 预告片在放且鼠标静止：只收起简介 / 演职人员，标题与元信息保持不变。
   0.5s ease-out，鼠标一动就恢复。 */
.tvb-hero-playing .tvb-hero-overview,
.tvb-hero-playing .tvb-hero-credits {
    max-height: 0;
    opacity: 0;
}

.tvb-hero-overview {
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0, 0, 0.2, 1), opacity 0.5s cubic-bezier(0, 0, 0.2, 1);
    max-height: 8rem;
    opacity: 1;
}
.tvb-hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 0.625rem;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.82);
}
.tvb-hero-rating {
    color: #fbbf24;
    font-weight: 600;
}
.tvb-hero-votes {
    color: rgba(255, 255, 255, 0.66);
    font-weight: 400;
}
.tvb-hero-genre,
.tvb-hero-remarks {
    padding: 0.0625rem 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.75rem;
}
.tvb-hero-remarks {
    border-color: rgba(99, 102, 241, 0.45);
    background: rgba(99, 102, 241, 0.16);
    color: #c7d2fe;
}
.tvb-hero-overview {
    font-size: 0.875rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.8);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* 精选剧照：最多 10 张，保持单行横向滑动；图片本身使用 loading=lazy。 */
.tvb-stills {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding-bottom: 0.375rem;
    touch-action: pan-x pan-y;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.tvb-stills:active {
    cursor: grabbing;
}
.tvb-still {
    flex: 0 0 clamp(17rem, 42vw, 28rem);
    aspect-ratio: 16 / 9;
    padding: 0;
    overflow: hidden;
    border-radius: 0.75rem;
    background: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    scroll-snap-align: start;
    cursor: zoom-in;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.tvb-still img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.25s ease, opacity 0.2s ease;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}
.tvb-still:hover img {
    transform: scale(1.025);
}
.tvb-still:focus,
.tvb-still:focus-visible,
.tvb-still:active {
    outline: none;
    box-shadow: none;
}

/* 点击剧照后的大图灯箱。 */
.tvb-still-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.tvb-still-lightbox > img {
    display: block;
    max-width: min(96vw, 80rem);
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}
.tvb-still-lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fafafa;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(24, 24, 27, 0.78);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.tvb-still-lightbox-close:hover {
    background: rgba(63, 63, 70, 0.92);
}
/* 剧照切换过渡：下一张从右滑入、上一张从左滑入（out-in，先出后进各 130ms） */
.tvb-still-next-enter-active, .tvb-still-next-leave-active,
.tvb-still-prev-enter-active, .tvb-still-prev-leave-active {
    transition: opacity 0.13s ease, transform 0.13s ease;
}
.tvb-still-next-enter-from { opacity: 0; transform: translateX(48px); }
.tvb-still-next-leave-to   { opacity: 0; transform: translateX(-48px); }
.tvb-still-prev-enter-from { opacity: 0; transform: translateX(-48px); }
.tvb-still-prev-leave-to   { opacity: 0; transform: translateX(48px); }
/* 索引指示（如 3 / 10） */
.tvb-still-lightbox-count {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: rgba(24, 24, 27, 0.72);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
    pointer-events: none;
}


.tvb-hero-play {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: #6366f1;
    border: 1px solid rgba(255, 255, 255, 0.14);
    transition: background 0.2s, transform 0.12s;
}
.tvb-hero-play:hover:not(:disabled) {
    background: #4f46e5;
}
.tvb-hero-play:active:not(:disabled) {
    transform: scale(0.96);
}
.tvb-hero-play:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.tvb-hero-play:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: 2px;
}


/* 数据来源切换 */
.tvb-hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.tvb-hero-badge {
    padding: 0.1875rem 0.625rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    color: #a1a1aa;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.35);
}
.tvb-hero-badge-on {
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.16);
}
/* 匹配资料中的加载徽标：小转圈 + 呼吸，让「正在匹配」肉眼可见 */
.tvb-hero-badge-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.16);
    animation: tvb-badge-pulse 1.6s ease-in-out infinite;
}
.tvb-hero-badge-loading::before {
    content: '';
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    border: 2px solid rgba(199, 210, 254, 0.35);
    border-top-color: #c7d2fe;
    animation: tvb-badge-spin 0.8s linear infinite;
}
@keyframes tvb-badge-spin {
    to { transform: rotate(360deg); }
}
@keyframes tvb-badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}
.tvb-hero-switch {
    padding: 0.1875rem 0.75rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    color: #e4e4e7;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    transition: background 0.2s, border-color 0.2s;
}
.tvb-hero-switch:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.28);
}
.tvb-hero-switch:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* 窄屏收敛 */
@media (max-width: 640px) {
    .tvb-hero {
        /* 移动端背景视频/图要有足够展示面积：折叠后信息区很矮，56vh 才不显得只剩横条 */
        height: 56vh;
        min-height: 320px;
    }
    .tvb-hero-content {
        max-width: none;
        padding: 0 1rem 1.25rem;
        gap: 0.5rem;
    }
    .tvb-hero-logo {
        max-width: 70%;
        max-height: 4rem;
    }
    .tvb-hero-overview {
        -webkit-line-clamp: 2;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tvb-hero-video,
    .tvb-hero-title-wrap,
    .tvb-hero-meta,
    .tvb-hero-overview {
        transition: none;
    }
}

/* ===== 选集：aether 风格横向卡片（左 16:9 剧照 + 右剧集名与剧情） ===== */
.tvb-ep-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    /* 长剧集会有几十上百集，容器内滚动，别把页面撑成无限长 */
    max-height: 32rem;
    overflow-y: auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
@media (min-width: 768px) {
    .tvb-ep-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.tvb-ep-list::-webkit-scrollbar {
    width: 6px;
}
.tvb-ep-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

.tvb-ep {
    display: flex;
    width: 100%;
    text-align: left;
    border-radius: 0.5rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.tvb-ep:hover {
    background: rgba(255, 255, 255, 0.08);
}
.tvb-ep:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}
/* 当前正在播的那一集 */
.tvb-ep-on {
    background: rgba(99, 102, 241, 0.16);
    border-color: rgba(99, 102, 241, 0.55);
}

.tvb-ep-thumb {
    position: relative;
    flex-shrink: 0;
    width: 33.333%;
    max-width: 11rem;
    aspect-ratio: 16 / 9;
    max-height: 110px;
    background: rgba(255, 255, 255, 0.06);
}
.tvb-ep-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.tvb-ep-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.0625rem 0.375rem;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.7);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.6875rem;
    line-height: 1.4;
    white-space: nowrap;
}

.tvb-ep-body {
    flex: 1;
    min-width: 0;
    padding: 0.625rem 0.75rem;
}
.tvb-ep-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* 单集评分（TMDB episode vote_average，票数够才显示） */
.tvb-ep-rating {
    margin-left: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #fbbf24;
}
.tvb-ep-overview {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.65);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== 相关推荐：竖版海报网格 ===== */
.tvb-reco-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}
@media (min-width: 640px) {
    .tvb-reco-list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (min-width: 1024px) {
    .tvb-reco-list {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}
.tvb-reco {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    cursor: pointer;
}
.tvb-reco-poster {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 0.5rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}
.tvb-reco:hover .tvb-reco-poster {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.tvb-reco-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.tvb-reco-rating {
    position: absolute;
    top: 0.375rem;
    left: 0.375rem;
    padding: 0.0625rem 0.3125rem;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.72);
    color: #fbbf24;
    font-size: 0.6875rem;
    font-weight: 600;
}
.tvb-reco-title {
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.88);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tvb-reco-year {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.45);
}
