/**
 * Joyn Player Pro - Main Stylesheet
 * @version 1.0.0
 */

/* ==================== 기본 스타일 ==================== */

.joyn-player-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.joyn-player-wrapper * {
    box-sizing: border-box;
}

/* 반응형 래퍼 - joyn-tv-live: 검정 빈공간 제거 (line-height/font-size 0, overflow hidden) */
.joyn-player-responsive .joyn-player-aspect {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 기본값 */
    overflow: hidden;
    line-height: 0;
    font-size: 0;
}

.joyn-player-responsive .joyn-player-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.joyn-player-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
}

/* 비디오 요소 - joyn-tv-live와 동일 (object-fit 미사용, 검정 빈공간 방지) */
.joyn-player-container video,
.joyn-player-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* 플랫폼 컨테이너 */
.joyn-player-youtube-container,
.joyn-player-vimeo-container,
.joyn-player-bunny-container,
.joyn-player-gumlet-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ==================== 오버레이 ==================== */

.joyn-player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
}

/* ==================== 큰 재생 버튼 ==================== */

.joyn-player-big-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.joyn-player-playing .joyn-player-big-play {
    opacity: 0;
    pointer-events: none;
}

.joyn-player-big-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
}

.joyn-player-big-play-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.joyn-player-big-play-btn svg {
    width: 40px;
    height: 40px;
    fill: #fff;
}

/* ==================== 생방송 배지 ==================== */

.joyn-player-live-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 0, 0, 0.9);
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 30;
}

.joyn-live-dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: joyn-live-pulse 1.5s ease-in-out infinite;
}

@keyframes joyn-live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== 로딩 스피너 ==================== */

.joyn-player-loading {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
}

.joyn-player-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: joyn-spin 0.8s linear infinite;
}

@keyframes joyn-spin {
    to { transform: rotate(360deg); }
}

/* ==================== 에러 메시지 ==================== */

.joyn-player-error {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 30;
}

.joyn-player-error-icon svg {
    width: 60px;
    height: 60px;
    fill: #ff4444;
    margin-bottom: 15px;
}

.joyn-player-error-message {
    color: #fff;
    font-size: 14px;
    text-align: center;
    max-width: 80%;
}

/* ==================== 컨트롤 바 ==================== */

.joyn-player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 30px 15px 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.joyn-player-wrapper:hover .joyn-player-controls,
.joyn-player-paused .joyn-player-controls {
    opacity: 1;
}

.joyn-player-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.joyn-player-controls-left,
.joyn-player-controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 컨트롤 버튼 */
.joyn-player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.joyn-player-btn:hover {
    transform: scale(1.1);
}

.joyn-player-btn svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

/* ==================== 진행 바 ==================== */

.joyn-player-progress-container {
    position: relative;
    width: 100%;
    padding: 10px 0;
    margin-bottom: 5px;
    cursor: pointer;
}

.joyn-player-progress {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: visible;
}

.joyn-player-progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    transition: width 0.1s ease;
}

.joyn-player-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #ff0000;
    border-radius: 2px;
    transition: width 0.1s ease;
}

.joyn-player-progress-handle {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    margin-top: -7px;
    background: #ff0000;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.joyn-player-progress-container:hover .joyn-player-progress {
    height: 6px;
}

.joyn-player-progress-container:hover .joyn-player-progress-handle {
    opacity: 1;
}

/* 시간 툴팁 */
.joyn-player-time-tooltip {
    display: none;
    position: absolute;
    bottom: 20px;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
}

/* ==================== 볼륨 ==================== */

.joyn-player-volume-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.joyn-player-volume-slider {
    width: 0;
    overflow: hidden;
    transition: width 0.2s ease;
}

.joyn-player-volume-container:hover .joyn-player-volume-slider {
    width: 80px;
}

.joyn-player-volume-track {
    position: relative;
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
}

.joyn-player-volume-level {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #fff;
    border-radius: 2px;
}

.joyn-player-volume-handle {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    margin-left: -6px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.joyn-player-volume-slider:hover .joyn-player-volume-handle {
    opacity: 1;
}

/* ==================== 시간 표시 ==================== */

.joyn-player-time {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.joyn-player-time-separator {
    opacity: 0.7;
}

/* ==================== 재생 속도 ==================== */

.joyn-player-speed-container {
    position: relative;
}

.joyn-player-speed-btn {
    width: auto;
    padding: 0 8px;
}

.joyn-player-speed-value {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}

.joyn-player-speed-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    padding: 5px 0;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 4px;
    min-width: 80px;
}

.joyn-player-speed-menu.active {
    display: block;
}

.joyn-player-speed-option {
    display: block;
    width: 100%;
    padding: 8px 15px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.joyn-player-speed-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.joyn-player-speed-option.active {
    color: #ff0000;
}

/* ==================== 플레이리스트 (전체영상) ==================== */

.joyn-player-playlist {
    background: #111;
    border-top: 1px solid #333;
    pointer-events: auto;
    touch-action: manipulation;
}

.joyn-player-playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.joyn-player-playlist-items {
    max-height: 300px;
    overflow-y: auto;
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
}

.joyn-player-playlist-title {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.joyn-player-playlist-count {
    color: #999;
    font-size: 13px;
}

.joyn-player-playlist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.joyn-player-playlist-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.joyn-player-playlist-item.active {
    background: rgba(255, 0, 0, 0.1);
}

.joyn-player-playlist-item-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 45px;
    background: #222;
    border-radius: 4px;
    overflow: hidden;
}

.joyn-player-playlist-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.joyn-player-playlist-item-info {
    flex: 1;
    min-width: 0;
}

.joyn-player-playlist-item-title {
    display: block;
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.joyn-player-playlist-item-duration {
    display: block;
    color: #999;
    font-size: 12px;
    margin-top: 4px;
}

.joyn-player-playlist-item.active .joyn-player-playlist-item-title {
    color: #ff0000;
}

/* ==================== 제목 ==================== */

.joyn-player-title {
    padding: 12px 15px;
    background: #111;
}

.joyn-player-title h4 {
    margin: 0;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
}

/* ==================== 전체화면 ==================== */

.joyn-player-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    z-index: 999999 !important;
}

.joyn-player-fullscreen .joyn-player-aspect {
    padding-bottom: 0 !important;
    height: 100vh !important;
}

.joyn-player-fullscreen .joyn-player-playlist {
    position: absolute;
    right: 0;
    top: 0;
    width: 300px;
    height: 100%;
    border-top: none;
    border-left: 1px solid #333;
}

/* ==================== 생방송 모드 ==================== */

.joyn-player-live-mode .joyn-player-progress-container {
    display: none;
}

.joyn-player-live-mode .joyn-player-time {
    display: none;
}

.joyn-player-no-pause .joyn-player-play-btn,
.joyn-player-no-pause .joyn-player-big-play {
    display: none;
}

.joyn-player-no-seek .joyn-player-progress-container {
    pointer-events: none;
}

/* ==================== Video.js 오버라이드 ==================== */

.video-js.vjs-joyn-player {
    background: transparent;
}

.vjs-joyn-player .vjs-control-bar,
.vjs-joyn-player .vjs-big-play-button,
.vjs-joyn-player .vjs-loading-spinner {
    display: none !important;
}

/* ==================== 반응형 ==================== */

/* ==================== 숏츠 모드 - 반응형 (미디어쿼리 없이 clamp 등으로 해결) ==================== */

:root {
    --joyn-shorts-max-width: clamp(280px, 100%, 400px);
}

/* 숏츠 모드 래퍼 - 반응형 */
.joyn-player-wrapper.joyn-player-shorts-mode,
.joyn-player-wrapper[data-shorts-mode="true"] {
    max-width: var(--joyn-shorts-max-width) !important;
    margin: 0 auto !important;
    margin-bottom: 0 !important;
    width: 100% !important;
    display: block !important;
}

/* 숏츠 aspect - 반응형, aspect-ratio만 사용 (padding-bottom 제거로 창/영상 크기 일치) */
.joyn-player-shorts-mode .joyn-player-aspect,
[data-shorts-mode="true"] .joyn-player-aspect {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding-bottom: 0 !important;
    height: auto !important;
    aspect-ratio: 9 / 16 !important;
    overflow: hidden !important;
    line-height: 0 !important;
    font-size: 0 !important;
}

@supports not (aspect-ratio: 9 / 16) {
    .joyn-player-shorts-mode .joyn-player-aspect,
    [data-shorts-mode="true"] .joyn-player-aspect {
        aspect-ratio: unset !important;
        height: 0 !important;
        padding-bottom: 177.78% !important; /* 9:16 fallback */
    }
}

/* 숏츠 모드 컨테이너 */
.joyn-player-container.joyn-player-shorts-mode,
.joyn-player-container[data-shorts-mode="true"],
.joyn-player-responsive.joyn-player-shorts-mode,
.joyn-player-responsive[data-shorts-mode="true"] {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

/* 숏츠 iframe/video - 반응형 (영상 꽉 차게) */
.joyn-player-shorts-mode iframe,
.joyn-player-shorts-mode video,
[data-shorts-mode="true"] iframe,
[data-shorts-mode="true"] video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
    object-fit: cover !important;
}

/* 숏츠 모드 - 모든 구간 가로 100% 유지 */

/* body 클래스로 전역 제어 */
body.joyn-shorts-mode-active .site-footer,
body.joyn-shorts-mode-active footer {
    margin-top: 0 !important;
}

/* ==================== 1:1 정사각형 모드 ==================== */

.joyn-player-wrapper.joyn-player-square-mode,
.joyn-player-wrapper[data-aspect-ratio="1:1"] {
    display: flex;
    justify-content: center;
}

.joyn-player-square-mode .joyn-player-aspect,
[data-aspect-ratio="1:1"] .joyn-player-aspect {
    padding-bottom: 100% !important; /* 1:1 비율 */
    max-width: 500px;
    margin: 0 auto;
}

@supports (aspect-ratio: 1 / 1) {
    .joyn-player-square-mode .joyn-player-aspect,
    [data-aspect-ratio="1:1"] .joyn-player-aspect {
        padding-bottom: 0 !important;
        aspect-ratio: 1 / 1;
        height: auto !important;
    }
}

/* ==================== 기타 화면 비율 ==================== */

/* 4:3 */
[data-aspect-ratio="4:3"] .joyn-player-aspect {
    padding-bottom: 75% !important;
}

@supports (aspect-ratio: 4 / 3) {
    [data-aspect-ratio="4:3"] .joyn-player-aspect {
        padding-bottom: 0 !important;
        aspect-ratio: 4 / 3;
    }
}

/* 21:9 (울트라와이드) */
[data-aspect-ratio="21:9"] .joyn-player-aspect {
    padding-bottom: 42.86% !important;
}

@supports (aspect-ratio: 21 / 9) {
    [data-aspect-ratio="21:9"] .joyn-player-aspect {
        padding-bottom: 0 !important;
        aspect-ratio: 21 / 9;
    }
}

@media (max-width: 768px) {
    .joyn-player-big-play-btn {
        width: 60px;
        height: 60px;
    }
    
    .joyn-player-big-play-btn svg {
        width: 30px;
        height: 30px;
    }
    
    .joyn-player-controls {
        padding: 20px 10px 10px;
    }
    
    .joyn-player-btn {
        width: 32px;
        height: 32px;
    }
    
    .joyn-player-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .joyn-player-volume-container:hover .joyn-player-volume-slider {
        width: 60px;
    }
    
    .joyn-player-time {
        font-size: 12px;
    }
    
    .joyn-player-live-badge {
        top: 10px;
        left: 10px;
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .joyn-player-fullscreen .joyn-player-playlist {
        width: 100%;
        height: auto;
        max-height: 40%;
        position: absolute;
        bottom: 0;
        right: 0;
    }
}

@media (max-width: 480px) {
    .joyn-player-controls-row {
        gap: 8px;
    }
    
    .joyn-player-controls-left,
    .joyn-player-controls-right {
        gap: 5px;
    }
    
    .joyn-player-volume-slider {
        display: none;
    }
    
    .joyn-player-speed-container {
        display: none;
    }
    
    .joyn-player-pip-btn {
        display: none;
    }
}

/* ==================== YouTube 네이티브 컨트롤 모드 ==================== */

/* YouTube 플레이어에서 네이티브 컨트롤 사용 시 커스텀 UI 완전히 숨김 */
.joyn-player-youtube.joyn-player-native-controls .joyn-player-overlay,
.joyn-player-youtube-live.joyn-player-native-controls .joyn-player-overlay {
    display: none !important;
    pointer-events: none !important;
}

/* YouTube 네이티브 컨트롤이 보이도록 z-index 조정 */
.joyn-player-youtube.joyn-player-native-controls iframe,
.joyn-player-youtube-live.joyn-player-native-controls iframe {
    z-index: 1;
}

/* YouTube 네이티브 컨트롤 컨테이너 클릭 가능하도록 */
.joyn-player-youtube.joyn-player-native-controls .joyn-player-youtube-container,
.joyn-player-youtube-live.joyn-player-native-controls .joyn-player-youtube-container {
    pointer-events: auto !important;
    z-index: 1;
}

.joyn-player-youtube.joyn-player-native-controls .joyn-player-container,
.joyn-player-youtube-live.joyn-player-native-controls .joyn-player-container {
    pointer-events: none;
}

/* 로딩 스피너와 에러는 표시 */
.joyn-player-youtube.joyn-player-native-controls .joyn-player-loading,
.joyn-player-youtube-live.joyn-player-native-controls .joyn-player-loading,
.joyn-player-youtube.joyn-player-native-controls .joyn-player-error,
.joyn-player-youtube-live.joyn-player-native-controls .joyn-player-error {
    display: flex !important;
    z-index: 2;
}


