/* BGM 스킨: leaf */

@font-face {
    font-family: 'TerrarumSansBitmap';
    src: url('https://cdn.jsdelivr.net/gh/fontbee/font@main/Terrarum/TerrarumSansBitmap.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

.leaf-player {
    --lp-w: 300px;
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    width: min(var(--lp-w), calc(100vw - 2 * var(--spacing-lg)));
    z-index: 9999;
    font-family: 'TerrarumSansBitmap';
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-base);
    pointer-events: auto;
}

.leaf-player button,
.leaf-player input {
    font-family: inherit;
}

.leaf-player.show {
    transform: translateY(0);
    opacity: 1;
}

/* 최소화 상태 */
.leaf-player.minimized {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--primary-color) 35%, #fff);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaf-player.minimized .player-content {
    display: none;
}

.leaf-player.minimized::before {
    content: '♪';
    font-size: 1.1rem;
    color: var(--primary-color);
}

.minimized-overlay {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    display: none;
}

.leaf-player.minimized .minimized-overlay {
    display: block;
}

.player-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* ---- 위젯 연동 배지 ---- */
.lpp-return-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    width: 100%;
    box-sizing: border-box;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: #fff;
    border: 1px solid var(--primary-color);
    border-radius: var(--btn-primary-radius, 10px);
    color: var(--primary-color);
    font-size: 10px;
    cursor: pointer;
}

.lpp-return-badge span {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lpp-return-badge:hover {
    background: var(--primary-color);
    color: #fff;
}

/* ---- 메인 스테이지 ---- */
.lp-stage {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8.805%;
    width: 100%;
    aspect-ratio: 363 / 211;
    padding: 4.683% 7.713% 4.132% 4.683%;
    box-sizing: border-box;
    background: linear-gradient(160deg, #ffffff 0%, color-mix(in srgb, var(--primary-color) 12%, #fff) 55%, color-mix(in srgb, var(--primary-color) 24%, #fff) 100%);
    border: 1px solid color-mix(in srgb, var(--primary-color) 28%, #fff);
    border-radius: 5.51% 29.06% 29.06% 5.51% / 9.48% 50% 50% 9.48%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 10px 24px rgba(0, 0, 0, .18);
    overflow: hidden;
}

.lp-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .6) 46%, transparent 62%);
    pointer-events: none;
}

/* ---- 화면 베젤 ---- */
.lp-card {
    position: relative;
    flex: 0 0 46.86%;
    height: 100%;
    box-sizing: border-box;
    border-radius: 10.74% / 8.94%;
    background: #202020;
    border: 1px solid #050505;
    box-shadow: inset 0 0 0 2px #3a3a3a, inset 0 2px 5px rgba(0, 0, 0, .8);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lp-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(125deg, rgba(255, 255, 255, .08) 0%, transparent 40%);
    pointer-events: none;
}

.lp-card::after {
    content: '';
    position: absolute;
    top: 5%;
    right: 6%;
    width: 5%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: .3;
    transition: opacity .3s;
    z-index: 3;
}

.leaf-player.playing .lp-card::after {
    opacity: 1;
    animation: leaf-led-pulse 1.6s ease-in-out infinite;
}

@keyframes leaf-led-pulse {
    50% { opacity: .5; }
}

.lp-card-art {
    position: relative;
    width: 81.2%;
    height: 81%;
    box-sizing: border-box;
    border-radius: 4.96% / 4.14%;
    background: linear-gradient(160deg, #2b2c29 0%, color-mix(in srgb, var(--primary-color) 50%, black) 100%);;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, .3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
}

.lp-card-art::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(125deg, rgba(255, 255, 255, .3) 0%, transparent 45%);
    pointer-events: none;
    z-index: 1;
}

/* 진행 바 */
.lp-progress {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    height: 3px;
    border-radius: 1.5px;
    background: rgba(0, 0, 0, .2);
    z-index: 2;
}

.lp-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    width: 66%;
    height: 100%;
    border-radius: 1.5px;
    background: var(--primary-color);
}

.lp-progress-handle {
    position: absolute;
    left: 66%;
    top: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-color);
    transform: translate(-50%, -50%);
}

/* 재생 시간 */
.lp-time {
    position: relative;
    flex: 0 0 auto;
    z-index: 2;
    color: #e2e2e2;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
}

/* 트랙 정보 */
.lp-track-info {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    z-index: 2;
    color: #e0e0e0;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* 동심원 뱃지 */
.lp-badge-mark {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transform-origin: 50% 96.3%;
}

@keyframes leaf-badge-rotate {
    to { transform: rotate(360deg); }
}

.leaf-player.playing .lp-badge-mark {
    animation: leaf-badge-rotate 8s linear infinite;
}

.lp-badge-ring {
    position: absolute;
    left: 50%;
    top: 96.3%;
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.lp-badge-ring--outer {
    width: 140.2%;
    background: #181916;
}

.lp-badge-ring--mid {
    width: 57.6%;
    background: #d9e8c2;
}

/* 썸네일 */
.lp-badge-ring--halo {
    width: 90.4%;
    background: #d9e8c2;
    overflow: hidden;
}

.lp-badge-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.lp-badge-thumb-img[src] {
    opacity: 1;
}

.lp-badge-ring--core {
    width: 16.5%;
    background: #181916;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .2);
}

/* ---- 재생목록 ---- */
.playlist-container {
    position: absolute;
    inset: 0;
    z-index: 5;
    overflow-y: auto;
    background: rgba(16, 22, 9, .94);
    box-sizing: border-box;
    padding: 6px;
}

.playlist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.playlist li {
    padding: 6px var(--spacing-sm);
    border-radius: 4px;
    font-size: 11px;
    color: #cfe3ab;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.playlist li:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.playlist li.current {
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
}

.playlist-container::-webkit-scrollbar {
    width: 4px;
}

.playlist-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

/* ---- 원형 다이얼 ---- */
.lp-dial {
    position: relative;
    flex: 0 0 auto;
    height: 78.77%;
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: 25.5% 49% 25.5%;
    grid-template-rows: 25.5% 49% 25.5%;
    grid-template-areas:
        ".    top    ."
        "left center right"
        ".    bottom .";
    place-items: center;
}

.lp-ring-outer {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(160deg, #ffffff 0%, color-mix(in srgb, var(--primary-color) 16%, #fff) 100%);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, .9), 0 4px 10px rgba(0, 0, 0, .15);
    overflow: hidden;
}

/* 조이스틱 노브 */
.lp-ring-inner {
    grid-area: center;
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(160deg, color-mix(in srgb, var(--primary-color) 80%, white) 0%, var(--primary-color) 100%);
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, .5), 0 3px 8px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.lp-ring-inner:active {
    cursor: grabbing;
}

.lp-play {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.lp-play:hover {
    transform: scale(1.06);
}

/* 다이얼 위의 작은 버튼들 (공통) */
.lp-dial-btn {
    position: relative;
    width: 26px;
    height: 26px;
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--primary-color) 35%, #fff);
    border-radius: 50%;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.lp-dial-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.lp-dial-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.lp-dial-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

@keyframes lp-dial-pulse {
    45% { background: var(--primary-color); color: #fff; transform: scale(1.2); }
}

.lp-dial-btn.lp-dial-pulse {
    animation: lp-dial-pulse .3s ease;
}

.lp-arrow-prev { grid-area: left; }
.lp-arrow-next { grid-area: right; }
.lp-leaf-top { grid-area: top; font-size: 12px; }
.lp-leaf-bottom { grid-area: bottom; font-size: 12px; }

.lp-tri {
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

.lp-tri-left {
    border-right: 8px solid currentColor;
}

.lp-tri-right {
    border-left: 8px solid currentColor;
}

.lp-bar {
    width: 2px;
    height: 9px;
    border-radius: 1px;
    background: currentColor;
    margin: 0 1px;
}

.repeat-one-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 8px;
    line-height: 11px;
    text-align: center;
}

/* ---- 유틸리티 바 ---- */
.lp-utility {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-xs);
}

.list-toggle-btn,
.volume-btn,
.minimize-btn {
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--primary-color) 35%, #fff);
    color: var(--primary-color);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    transition: all var(--transition-fast);
}

.list-toggle-btn:hover,
.list-toggle-btn.active,
.volume-btn:hover,
.minimize-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* ---- 볼륨 ---- */
.volume-control {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-popup {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-sm);
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--primary-color) 28%, #fff);
    border-radius: var(--card-border-radius, 10px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    display: none;
}

.volume-popup.show {
    display: block;
}

.volume-slider {
    width: 4px;
    height: 70px;
    background: color-mix(in srgb, var(--primary-color) 25%, #fff);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    cursor: pointer;
    writing-mode: vertical-lr;
    direction: rtl;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
}

/* ---- 접근성 ---- */
.lp-dial-btn:focus,
.lp-play:focus,
.list-toggle-btn:focus,
.volume-btn:focus,
.minimize-btn:focus,
.volume-slider:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .leaf-player,
    .lp-dial-btn,
    .lp-play,
    .lp-ring-inner,
    .lp-badge-thumb-img,
    .list-toggle-btn,
    .volume-btn,
    .minimize-btn {
        transition: none;
    }
    .leaf-player.playing .lp-badge-mark,
    .leaf-player.playing .lp-card::after,
    .lp-dial-btn.lp-dial-pulse {
        animation: none;
    }
}
