/* ============================================================
   playlist.css – For Geombok 재생목록 페이지 전용
   ============================================================ */

/* ── 변수 — 변수 전체·@font-face·리셋·.video-bg 는 main.css 사용 ──
   여기엔 playlist 전용 오버라이드/추가만 둔다 */
:root {
    /* main.css 기본값(0.5)보다 옅게 — 재생목록 행 hover 용 */
    --card-hover: rgba(255, 255, 255, 0.20);

    /* 행 높이 고정 → 10행 = 400px */
    --pl-row-h: 40px;
}

/* ── Body — 배경/플렉스/overflow 는 main.css body 상속 ── */
html, body {
    height: 100%;
}
body {
    font-family: var(--font-main);   /* main.css 의 system-ui 대신 페이지 폰트 */
}

/* 헤더 · 푸터 · 배경 영상 스타일은 main.css 사용 */

/* ============================================================
   Main layout
   ============================================================ */
.pl-main {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

.pl-layout {
    display: flex;
    align-items: stretch;   /* 두 패널 높이를 동일하게 */
    gap: 2rem;
    width: 100%;
    max-width: 1100px;
}

/* ============================================================
   LEFT – 플레이어 패널
   ============================================================ */
.pl-player-panel {
    width: 38%;
    min-width: 260px;
    max-width: 440px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* "Playlist" 라벨 — wiki-header-title 과 동일 크기/굵기 */
.pl-panel-label {
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    padding-top: 0.65rem;
}

/* 16 : 9 비율 영상 영역 */
.pl-video-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;   /* 16:9 */
    background: transparent;
    border: 2px solid var(--border);
    overflow: hidden;
}

.pl-yt-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* 선택 전 안내 문구 */
.pl-thumb-msg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.95rem;
    text-align: center;
    padding: 1rem;
    pointer-events: none;
}

/* YouTube iframe 래퍼 */
.pl-yt-wrapper { background: #000; }
.pl-yt-wrapper iframe,
#ytPlayerDiv   { width: 100%; height: 100%; border: none; display: block; }

/* 곡 정보 블록 */
.pl-song-info {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.pl-song-title {
    font-size: 1.55rem;
    line-height: 1.25;   /* 폰트 스왑 시 높이 변동(레이아웃 시프트) 방지 */
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-song-artist {
    font-size: 0.9rem;
    line-height: 1.2;    /* 폰트 스왑 시 높이 변동(레이아웃 시프트) 방지 */
    color: rgba(255, 255, 255, 0.8);
}

/* ── 재생바 ── */
.pl-progress-row { width: 100%; }

.pl-progress {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);   /* JS가 filled 색상을 inline style로 업데이트 */
    outline: none;
    cursor: pointer;
    border-radius: 2px;
}
.pl-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--secondary);
    cursor: pointer;
    box-shadow: 0 0 4px rgba(119, 185, 252, 0.7);
}
.pl-progress::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--secondary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 4px rgba(119, 185, 252, 0.7);
}

/* ── 컨트롤 행 ── */
.pl-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.pl-time {
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    min-width: 38px;
    color: rgba(255, 255, 255, 0.85);
}

.pl-btns {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.pl-btn {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.pl-btn:hover { color: var(--secondary); }

/* SVG 아이콘 — 기호 대신 사용 (모바일 렌더링 일관성) */
.pl-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}
.pl-btn-play svg { width: 26px; height: 26px; }

/* 재생/일시정지 토글: 기본은 재생(▶) 아이콘 표시 */
.pl-btn-play .pl-icon-pause      { display: none; }
.pl-btn-play.is-playing .pl-icon-play  { display: none; }
.pl-btn-play.is-playing .pl-icon-pause { display: block; }

/* ── 자동재생 체크박스 ── */
.pl-autoplay-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    user-select: none;
}
.pl-autoplay-chk {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.pl-autoplay-box {
    display: inline-block;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border);
    background: transparent;
    position: relative;
}
.pl-autoplay-chk:checked + .pl-autoplay-box {
    background: var(--secondary);
    border-color: var(--secondary);
}
.pl-autoplay-chk:checked + .pl-autoplay-box::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 7px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: translate(-50%, -65%) rotate(45deg);
}

/* ── 원본 영상 링크 ── */
.pl-video-link-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.pl-yt-icon { display: flex; align-items: center; flex-shrink: 0; }

.pl-video-link-text {
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s;
}
.pl-video-link-text:hover { color: var(--secondary); }

/* ============================================================
   RIGHT – 재생목록 패널
   ============================================================ */
.pl-list-panel {
    flex: 1;
    gap: 0.65rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* 헤더 행 */
.pl-list-header {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.pl-col-title  { flex: 1; text-align: left; }
.pl-col-artist { width: 130px; text-align: right; flex-shrink: 0; }

/* 목록 본문: 10행 고정 높이 */
.pl-list-body {
    height: calc(var(--pl-row-h) * 10);
    overflow-y: auto;
}

/* 항목 행 */
.pl-row {
    display: flex;
    align-items: center;
    height: var(--pl-row-h);
    padding: 0 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    transition: background 0.15s;
    user-select: none;
}
.pl-row:last-child   { border-bottom: none; }
.pl-row:hover        { background: var(--card-hover); }
.pl-row.is-active    {
    font-weight: bold;
    background: rgba(255, 255, 255, 0.3);
    color: var(--fgb-dark);
}

.pl-row-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    padding-right: 0.5rem;
}

.pl-row-title-text {
    flex: 0 1 auto;   /* 자연 너비만큼 차지 → 버튼이 텍스트 바로 우측에 붙음 */
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ── 펼치기 버튼 (다중 클립) ── */
.pl-expand-btn {
    flex-shrink: 0;
    background: var(--primary);
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    padding: 1px 2px;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: filter 0.15s, transform 0.2s;
}
.pl-expand-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    display: block;
}
.pl-expand-btn:hover { filter: brightness(1.15); }
.pl-expand-btn.is-open { transform: rotate(180deg); }
.pl-expand-btn.is-open svg { transform: translateY(1px); }

/* ── 클립 서브 목록 ── */
.pl-clips {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.pl-clips:last-child { border-bottom: none; }

.pl-clip-row {
    display: flex;
    align-items: center;
    height: calc(var(--pl-row-h) * 0.875);
    padding: 0 1rem 0 1.75rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    transition: background 0.15s;
    user-select: none;
    background: rgba(255, 255, 255, 0.04);
}
.pl-clip-row:last-child { border-bottom: none; }
.pl-clip-row:hover      { background: var(--card-hover); }
.pl-clip-row.is-active  {
    font-weight: bold;
    background: rgba(255, 255, 255, 0.18);
}

.pl-clip-title {
    flex: 1;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 0.5rem;
    min-width: 0;
}
.pl-clip-time {
    flex-shrink: 0;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.65);
}

.pl-row-artist {
    width: 200px;
    text-align: right;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* ── 목록 하단: 노래 추가 신청 버튼 ── */
.pl-list-footer {
    display: flex;
    justify-content: flex-end;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.pl-add-btn {
    display: flex;
    font-family: var(--font-main);
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--text);
    background: var(--card-bg);
    border: 2px solid var(--border);
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.pl-add-btn:hover {
    border-color: var(--fgb-dark);
    color: var(--fgb-dark);
}

/* 빈 목록 메시지 */
.pl-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ── 스크롤바 ── */
.pl-list-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(119, 185, 252, 0.7) rgba(255, 255, 255, 0.08);
}
.pl-list-body::-webkit-scrollbar       { width: 6px; }
.pl-list-body::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.06); }
.pl-list-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--secondary), var(--primary));
    border-radius: 100px;
}
.pl-list-body::-webkit-scrollbar-thumb:hover { background: var(--secondary); }

/* ============================================================
   반응형 – 화면 너비 800px 이하: 위아래 정렬
   ============================================================ */
@media (max-width: 800px) {
    /* 모바일: body 고정 높이 해제 → 자연스러운 문서 스크롤로 전환
       (body overflow: auto 는 iOS Safari 에서 스크롤 컨테이너를 body 로 잡아
        레이아웃이 뒤틀리므로 height: auto + 브라우저 기본 스크롤 사용) */
    html, body {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
    }
    body { overflow-y: visible; }

    .pl-main {
        flex: none;               /* height: 100% 채우기 시도 안 함 */
        width: 100%;
        align-items: flex-start;
        padding: 1rem 0.75rem;
        overflow: visible;
    }

    .pl-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
        max-width: 100%;
    }

    /* 플레이어 패널: 전체 너비 사용 */
    .pl-player-panel {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    /* 곡 제목 폰트 축소 */
    .pl-song-title { font-size: 1.2rem; }

    /* 아티스트 컬럼 너비 축소 */
    .pl-col-artist { width: 90px; }
    .pl-row-artist { width: 90px; }

    /* 클립 시간 너비 확보 */
    .pl-clip-time { font-size: 0.72rem; }
}
