/* 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;
    }
}

/* ═══ ArtPlayer 底栏与弹幕发送：竖屏 H5 无输入框，横屏/桌面显示（对照源站）═══ */
/* 网页全屏会把 .art-video-player 挂到 body，须与 .k-apt__mount 共用一套 flex */
.k-apt__mount .art-bottom,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-bottom {
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgb(0 0 0 / 82%) 0%, rgb(0 0 0 / 28%) 55%, transparent 100%);
    box-sizing: border-box;
}

.k-apt__mount .art-controls,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.k-apt__mount .art-controls-left,
.k-apt__mount .art-controls-center,
.k-apt__mount .art-controls-right,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-left,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-center,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

.k-apt__mount .art-controls-left,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-left {
    flex: 0 0 auto;
    gap: 2px;
}

.k-apt__mount .art-controls-center,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-center {
    flex: 1 1 auto;
    overflow: hidden;
    justify-content: flex-end;
}

.k-apt__mount .art-controls-right,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-right {
    flex: 0 1 auto;
    gap: 2px;
    max-width: min(48%, 220px);
    justify-content: flex-end;
}

.k-apt__mount .art-control-time,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-control-time {
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0 2px;
}

.k-apt__mount .apd-emitter,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-emitter {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.k-apt__mount .apd-input,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-input {
    flex: 1 1 auto;
    min-width: 0 !important;
    width: 0 !important;
    max-width: 100%;
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid rgb(255 255 255 / 20%);
    background: rgb(0 0 0 / 48%);
    color: #fff;
    font-size: 12px;
    box-sizing: border-box;
}

.k-apt__mount .apd-input::placeholder,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-input::placeholder {
    color: rgb(255 255 255 / 52%);
}

.k-apt__mount .apd-send,
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-send {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    min-height: 32px;
    margin: 0;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    box-sizing: border-box;
    vertical-align: middle;
}

@media (max-width: 1023.98px) {
    .k-apt__mount .apd-style,
    .k-apt__mount .apd-config,
    :is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-style,
    :is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-config {
        display: none !important;
    }
    .k-apt__mount .art-controls-right,
    :is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-right {
        max-width: min(58%, 260px);
    }
}

@media (max-width: 760px) {
    .k-apt__mount .apd-toggle,
    :is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-toggle {
        display: none !important;
    }
    .k-apt__mount .art-control-time,
    :is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-control-time {
        font-size: 10px;
    }
}

/* 网页全屏 / 原生全屏：黑底 contain，底栏满宽+安全区（参照源站横屏播控） */
body > .art-video-player.art-fullscreen-web,
body > .art-video-player.art-fullscreen,
.k-apt__mount .art-video-player.art-fullscreen-web,
.k-apt__mount .art-video-player.art-fullscreen {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: stretch !important;
    background: #000 !important;
}

body > .art-video-player.art-fullscreen-web,
body > .art-video-player.art-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 99990 !important;
    margin: 0 !important;
    transform: none !important;
}

.art-video-player.art-fullscreen-web .art-video,
.art-video-player.art-fullscreen .art-video,
.art-video-player.art-fullscreen-web video,
.art-video-player.art-fullscreen video {
    object-fit: contain !important;
}

.art-video-player.art-fullscreen-web .art-bottom,
.art-video-player.art-fullscreen .art-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 8px max(10px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-right));
}

/* 全屏横屏：底栏放宽，弹幕输入与 PiP/全屏同排或折行 */
:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 6px;
}

:is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .art-controls-right {
    max-width: none;
    flex-wrap: wrap;
    row-gap: 6px;
}

@media (orientation: landscape) {
    :is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-emitter {
        flex: 1 1 100%;
        width: 100%;
        order: -1;
    }
}

/* 竖屏 H5：对照源站——控制条不露出弹幕输入 */
@media (orientation: portrait) and (max-width: 1023.98px) {
    .k-apt__mount .apd-emitter,
    :is(.art-video-player.art-fullscreen-web, .art-video-player.art-fullscreen) .apd-emitter {
        display: none !important;
    }
}

/* 播放器已移走：舞台旁换源 badge 不参与全屏层 */
html[data-k-art-fullscreen] .k-apt > .k-player__badge,
html[data-k-art-fullscreen] .k-apt > .k-player__badge--btn {
    visibility: hidden;
    pointer-events: none;
}

/* 全屏竖屏横屏引导（对照 kanju18 顶栏黑条 + 关闭） */
.art-video-player .k-player__rotate-hint {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100002;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 40px 10px 12px;
    box-sizing: border-box;
    background: rgb(0 0 0 / 78%);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    pointer-events: auto;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.art-video-player .k-player__rotate-hint[hidden] {
    display: none !important;
}
.k-player__rotate-hint-t {
    margin: 0;
    flex: 1 1 auto;
    font-weight: 500;
}
.k-player__rotate-hint-close {
    position: absolute;
    top: calc(6px + env(safe-area-inset-top, 0px));
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgb(255 255 255 / 10%);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.k-player__rotate-hint-close:hover {
    background: rgb(255 255 255 / 18%);
}
.k-player__rotate-hint-close:focus-visible {
    outline: 2px solid rgb(var(--k-primary-rgb) / 55%);
    outline-offset: 2px;
}

/* 移动端全屏退出按钮：ArtPlayer 原生全屏按钮在触屏上只有小图标 + tooltip，
   补一个固定角标大按钮，点按即退出（对照反馈目标站 ⛶ 按钮）。 */
.art-video-player .k-player__exit-fs {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    z-index: 100003;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid rgb(255 255 255 / 22%);
    border-radius: 22px;
    background: rgb(0 0 0 / 62%);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    -webkit-tap-highlight-color: transparent;
}
.art-video-player .k-player__exit-fs[hidden] {
    display: none !important;
}
.art-video-player .k-player__exit-fs:active {
    background: rgb(0 0 0 / 82%);
}
.art-video-player .k-player__exit-fs:focus-visible {
    outline: 2px solid rgb(var(--k-primary-rgb) / 70%);
    outline-offset: 2px;
}
/* 竖屏横屏引导出现时下移退出按钮，避免重叠 */
.art-video-player .k-player__rotate-hint:not([hidden]) ~ .k-player__exit-fs {
    top: calc(52px + env(safe-area-inset-top, 0px));
}

@media (max-width: 760px) {
    /* H5 禁网页全屏；若闪现在 body 上也用 contain+底栏，勿竖条拉满 */
    body:has(.k-watch) > .art-video-player.art-fullscreen-web {
        position: fixed !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;
        aspect-ratio: auto !important;
        transform: none !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        background: #000 !important;
    }
}

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