/* Premium Video Player Styles */
:root {
    --cvp-primary: #ffffff;
    --cvp-bg: #000;
    --cvp-radius: 16px;
    --cvp-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.cvp-player-container {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    background: var(--cvp-bg);
    border-radius: var(--cvp-radius);
    line-height: 0;
}

.cvp-player-container.has-shadow {
    box-shadow: var(--cvp-shadow);
}

/* ─── 핵심: plyr--video 자체에 aspect-ratio 설정 ─── */
/* 이렇게 하면 plyr 높이 = 16:9 크기만 됨 (컨트롤이 높이에 추가되지 않음) */
.cvp-player-container .plyr--video {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    overflow: hidden !important;
    border-radius: var(--cvp-radius) !important;
    background: var(--cvp-bg) !important;
}

.cvp-player-container.is-shorts .plyr--video {
    aspect-ratio: 9 / 16 !important;
    max-width: 400px !important;
    margin: 0 auto !important;
}

/* ─── video-wrapper: plyr 전체 영역을 absolute로 채움 ─── */
/* Plyr JS가 설정하는 inline aspect-ratio를 무력화 */
.cvp-player-container .plyr__video-wrapper {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    aspect-ratio: unset !important;
}

/* ─── YouTube iframe 크롭 (타이틀/추천영상 숨김) ─── */
.cvp-player-container .plyr__video-wrapper iframe {
    position: absolute !important;
    top: -8% !important;
    left: 0 !important;
    width: 100% !important;
    height: 116% !important;
    transform: scale(1.02) !important;
    pointer-events: none !important;
}

.cvp-player-container.is-playing .plyr__video-wrapper iframe {
    pointer-events: auto !important;
}

.cvp-player-container.is-shorts .plyr__video-wrapper iframe {
    top: -4% !important;
    height: 108% !important;
    transform: scale(1.01) !important;
}

/* ─── 컨트롤 바: plyr 하단 오버레이 ─── */
.cvp-player-container .plyr--video .plyr__controls {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    z-index: 30 !important;
    padding: 30px 20px 15px !important;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.5) 50%,
        rgba(0, 0, 0, 0) 100%
    ) !important;
    border-bottom-left-radius: var(--cvp-radius);
    border-bottom-right-radius: var(--cvp-radius);
    display: flex !important;
    align-items: center !important;
}

/* Plyr 기본 숨김 동작 허용 */
.cvp-player-container .plyr--hide-controls .plyr__controls {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* YouTube 보호 오버레이 (컨트롤 클릭 방해 제외) */
.cvp-youtube-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 60px);
    z-index: 20;
    cursor: pointer;
    background: transparent;
}

/* 중앙 재생 버튼 */
.cvp-player-container .plyr__control--overlaid {
    background: rgba(255, 255, 255, 0.2) !important;
    padding: 25px !important;
    z-index: 25 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.plyr__control--overlaid svg {
    width: 30px;
    height: 30px;
    fill: #fff;
}

/* Plyr CSS 변수 */
.plyr--full-ui {
    --plyr-color-main: var(--cvp-primary);
    --plyr-video-control-background-hover: rgba(255, 255, 255, 0.2);
    --plyr-control-radius: 8px;
}

.plyr__progress__container {
    margin-bottom: 5px;
}

.plyr__volume {
    max-width: 100px;
}

/* 컨트롤 버튼 스타일 */
.plyr__control,
.plyr__control--overlaid,
.plyr__controls button {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background-image: none !important;
    color: #fff !important;
}

.plyr__control svg {
    fill: #fff !important;
}

.plyr__control:focus,
.plyr__control:active,
.plyr--full-ui input[type=range]:focus {
    outline: 0 !important;
    box-shadow: none !important;
}

.plyr--full-ui input[type=range] {
    color: #fff !important;
}

/* 반응형 */
@media (max-width: 768px) {
    .cvp-player-container .plyr--video .plyr__controls {
        padding: 15px 10px 10px !important;
    }
    .cvp-youtube-overlay {
        height: calc(100% - 44px);
    }
}

/* Settings Menu */
.plyr__menu__container {
    background: rgba(30, 30, 30, 0.8) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
}

.plyr__menu__container [role="menu"] { color: #ffffff !important; }
.plyr__menu__container .plyr__control { color: #ffffff !important; }
.plyr__menu__container .plyr__control:hover { background: rgba(255, 255, 255, 0.1) !important; }
.plyr__menu__container .plyr__control[aria-checked="true"]::before { background: #ffffff !important; }
.plyr__menu__container .plyr__control--back { border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important; }
