/* kanju 主题 · ArtPlayer 挂载区（任务 5）
   外层 .k-apt 是「舞台 + 弹幕发送行」的列容器；
   16:9 只落在 .k-apt__mount，避免发送行被 aspect-ratio/overflow 叠进画面。 */
.k-apt {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: var(--k-radius);
    background: transparent;
    min-height: 0;
    /* 勿在外层设 aspect-ratio / overflow:hidden —— 会把 .k-apt__send 挤进画面 */
}

.k-apt__mount {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 18rem;
    border-radius: var(--k-radius);
    overflow: hidden;
    background: #000;
}

/* ArtPlayer 自带样式接手后，容器铺满 */
.k-apt__mount .art-video-player {
    width: 100%;
    height: 100%;
}

.k-apt__fallback {
    margin: 0;
    padding: 2rem;
    text-align: center;
    color: var(--k-text-subtle);
    font-size: var(--k-fs-md);
}

/* 换源 badge 相对舞台定位（挂在 .k-apt 下，对齐 mount 右上） */
.k-apt > .k-player__badge,
.k-apt > .k-player__badge--btn {
    position: absolute;
    top: 14px;
    right: 22px;
    z-index: 20;
}

/* 弹幕发送行：舞台下方 */
.k-apt > .k-apt__send {
    margin-top: 10px;
    flex: 0 0 auto;
}
.k-apt > .k-apt__send-err {
    flex: 0 0 auto;
}

@media (max-width: 1023.98px) {
    .k-apt {
        margin-left: calc(-1 * var(--k-page-edge));
        margin-right: calc(-1 * var(--k-page-edge));
        width: auto;
    }
    .k-apt__mount {
        min-height: 12rem;
        border-radius: 0;
    }
    .k-apt > .k-apt__send {
        margin-left: var(--k-page-edge);
        margin-right: var(--k-page-edge);
    }
}


/* 对照源站 h-dvh + overflow-hidden：桌面播放页一屏铺满，不再用 100dvh min-height 顶出滚动 */
@media (min-width: 1024px) {
    /* 壳层锁视口：head(72) + watch 弹性填满，禁止整页滚动 */
    #k-shell:has(.k-watch),
    #k-main:has(.k-watch) {
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }
    #app-main:has(.k-watch) {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        max-height: 100dvh;
        padding-bottom: 0.5rem; /* ≈源站 grid p-2 底边 */
        overflow: hidden;
        box-sizing: border-box;
    }
    #app-main:has(.k-watch) > .k-watch__head {
        flex: 0 0 auto;
    }
    #app-main:has(.k-watch) > .k-watch {
        flex: 1 1 auto;
        min-height: 0; /* 覆盖旧 calc(100dvh-…) */
        height: auto;
        max-height: none;
        align-items: stretch;
    }
    .k-apt {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0; /* 覆盖旧 calc(100dvh-7rem) */
        border-radius: 0; /* 源站 react-player-frame rounded-none */
    }
    .k-apt__mount {
        aspect-ratio: auto;
        flex: 1 1 auto;
        /* 勿 min-height:0：htmx 软进 / flex 链未算好时会塌成一条；12rem 兜底仍可被 flex 拉高 */
        min-height: 12rem;
        height: auto;
        border-radius: 0; /* 源站 shell-page frame>div border-radius:0 */
    }
}


/* H5≤760：播区按 16:9 贴顶，禁止 onescreen/网页全屏把横片拉成竖条（短剧 .k-short 沉浸页不走 .k-apt） */
@media (max-width: 760px) {
    #k-shell:has(.k-watch),
    #k-main:has(.k-watch),
    #app-main:has(.k-watch) {
        height: auto;
        max-height: none;
        overflow: visible;
    }
    #app-main:has(.k-watch) > .k-watch {
        height: auto;
        max-height: none;
        min-height: 0;
        align-items: start;
        overflow: visible;
    }
    .k-apt {
        height: auto !important;
        min-height: 0;
        flex: 0 0 auto;
    }
    .k-apt__mount {
        aspect-ratio: 16 / 9;
        width: 100%;
        height: auto !important;
        flex: 0 0 auto !important;
        min-height: 0;
        max-height: none;
    }
    /* 若仍被点到网页全屏：锁在 16:9 mount 内，勿 fixed 铺满视口 */
    .k-apt .art-video-player.art-fullscreen-web,
    .k-apt__mount .art-video-player.art-fullscreen-web,
    .k-watch .art-video-player.art-fullscreen-web {
        position: absolute !important;
        inset: 0 !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        z-index: 20 !important;
    }
}

/* 投屏暂下：藏 ArtPlayer AirPlay / cast 类控件 */
.art-control-airplay,
.art-icon-airplay,
.art-control[data-index="airplay"],
.art-video-player [class*="airplay"],
.art-video-player [class*="cast"]:not(.art-control-pip):not([class*="fullscreen"]) {
    display: none !important;
}

@media (max-width: 760px) {
    /* H5 不展示网页全屏钮（保留原生全屏）；避免误触撑成竖条 */
    .k-apt .art-control-fullscreenWeb,
    .k-apt .art-icon-fullscreenWeb {
        display: none !important;
    }
}

@media (max-width: 760px) {
    /* ArtPlayer 网页全屏会把节点挂到 body；播放页在场时强制取消铺满 */
    body:has(.k-watch) > .art-video-player.art-fullscreen-web {
        position: fixed !important;
        /* 仍可能短暂闪一下；JS 会立刻关掉。此处至少不要 100% 高竖条：按宽算 16:9 居中 */
        top: 50% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9 !important;
        max-height: 100% !important;
        transform: translateY(-50%) !important;
        inset: auto !important;
    }
}

/* === PC播区圆角对齐源站（min-width:1024） === */
@media (min-width: 1024px) {
    .k-apt,
    .k-apt__mount {
        border-radius: 0; /* 源站 react-player-frame rounded-none */
    }
}
/* === /PC播区圆角对齐源站 === */
