/* 추모영상 공용 플레이어 - cjb-player.js 가 .cjb-player 안에 마크업을 만든다. cjb-theme.css 뒤에 싣는다.
   상태는 루트의 is-* 클래스 하나로 정한다: is-loading · is-failed · is-standby · is-playing · is-paused (+ is-buffering).
   재생 중 조작이 없으면 cjb-player-autohide.js 가 is-controls-hidden 을 더한다(가운데 재생 · 일시정지 버튼만 숨김).
   장면 전환은 cjb-player-crossfade.js 가 이미지 칸에 is-current · is-entering 을 붙인다.
   루트 글꼴은 그 상태의 대표 글자(대기 · 재생 = 재생 시간 칩, 불러오는 중 · 실패 = 안내 문구) 값이다 - 자식이 물려받는다. */

.cjb-player {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    color: var(--fstd-on-color);
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: -0.06px;
}

.cjb-player :focus-visible {
    outline: 2px solid var(--fstd-fg-heavy);
    outline-offset: 2px;
}

/* 16:9, 사진 비율이 달라도 자르지 않고 검은 여백으로 담는다. aspect-ratio 를 모르는 옛 웹뷰가 있어 위 여백으로 높이를 잡는다.
   무대에는 바탕을 칠하지 않는다 - 보이는 장이 늘 무대를 덮고, 검은 여백은 이미지 칸이 칠한다(아래 .cjb-player__image). */
.cjb-player__stage {
    position: relative;
    height: 0;
    padding-top: 56.25%;
}

/* 장면 칸(cjb-player-crossfade.js) - 이미지 두 장을 겹친다. 칸이 쌓임 맥락을 만들어 떠오르는 장의 z-index 가 어둡게 · 버튼과 겨루지 않는다. */
.cjb-player__scene {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 0;
}

/* 쉬는 칸(src 를 넣기 전 포함)은 투명하다. visibility 로 숨기지 않는다 - 불러오는 중 무대의 visibility: hidden 을 자식이 되살린다.
   검은 바탕은 사진 비율이 달라 생긴 여백까지 덮는다 - 떠오르는 장 여백으로 앞 장이 비치지 않고, 두 장이 겹친 동안 화면이 어두워지지 않는다.
   검은 바탕은 둥근 윤곽에서 1px 안쪽(반지름 7px)까지만 칠한다. 윤곽에 걸친 화소는 브라우저가 바탕 · 사진을 따로 반투명하게 깎아 겹쳐서,
   바탕이 윤곽까지 깔리면 사진 가장자리로 검은 선이 비친다(흰 사진 - 휴대폰은 둥근 모서리, PC 는 확대 배율이 소수일 때 윤곽 전체).
   0.5px 로 들이면 PC 에서 남는다. 배경은 칸(사진)보다 작게 자를 수 없어 네 모서리 원과 가로 · 세로 띠 그라데이션으로 칠한다.
   이 들임은 사진 밑과 띠에서 뺀 모서리 8px 칸에만 남는다 - 사진이 없는 여백의 곧은 변(--cjb-player-bars, 아래 data-fit 규칙)은 윤곽까지 칠한다. */
.cjb-player__image {
    --cjb-player-bars: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        var(--cjb-player-bars),
        radial-gradient(circle at 100% 100%, #000 7px, transparent 7px) left 1px top 1px / 7px 7px no-repeat,
        radial-gradient(circle at 0 100%, #000 7px, transparent 7px) right 1px top 1px / 7px 7px no-repeat,
        radial-gradient(circle at 100% 0, #000 7px, transparent 7px) left 1px bottom 1px / 7px 7px no-repeat,
        radial-gradient(circle at 0 0, #000 7px, transparent 7px) right 1px bottom 1px / 7px 7px no-repeat,
        linear-gradient(#000, #000) center / calc(100% - 16px) calc(100% - 2px) no-repeat,
        linear-gradient(#000, #000) center / calc(100% - 2px) calc(100% - 16px) no-repeat;
    object-fit: contain;
    opacity: 0;
    /* 투명한 쉬는 칸이 앞 장 그림을 쥔 채 누름(PC 오른쪽 클릭 「이미지 저장」 등)을 받지 않게 */
    pointer-events: none;
}
/* 사진이 없는 여백(좌우 · 위아래 띠)은 곧은 변에서 윤곽까지 칠한다 - 사진은 윤곽까지 닿으므로, 여백을 위처럼 들이면 사진 끝이 여백 끝보다
   장치 픽셀 1~3개 밖으로 각지게 튀어나와 보이고, 아래 변은 진행 막대(흰색 40%)가 그 줄을 덮어 막대가 사진 위에서만 한 줄 더 굵어 보였다(PJT-637 2차).
   띠 밑에는 사진이 없어 윤곽에서 검은 선이 비치지 않는다. 사진 비율에 따른 띠 두께(--cjb-player-bar, 칸 폭 · 높이 대비 %)와 방향(data-fit)은
   cjb-player-crossfade.js 가 사진을 불러오면 넣는다 - 비율이 무대(16:9)와 같거나 아직 모르면 위 바탕만 칠한다.
   띠는 사진 쪽으로 0.75px 더 칠한다 - 사진 끝(장치 픽셀로 맞춘 자리)과 띠 끝 사이 화소로 페이지 색이 비치지 않게(PC 확대 80% 의 장치 픽셀 반 개까지 덮는다).
   1px 이면 Chrome PC 확대 125 · 80% 에서 사진 · 띠 경계와 아래 윤곽이 만나는 화소가 어두워졌다.
   모서리 8px 칸은 띠에서 빼고 위 모서리 원에 맡긴다 - 모서리까지 칠하면 진행 막대 흰 채움 옆 둥근 모서리에 검은 호가 비친다. */
.cjb-player__image[data-fit="pillarbox"] {
    --cjb-player-bars:
        linear-gradient(to right, #000 calc(var(--cjb-player-bar, 0%) + 0.75px), transparent 0, transparent calc(100% - var(--cjb-player-bar, 0%) - 0.75px), #000 0) center / 100% calc(100% - 16px) no-repeat,
        linear-gradient(to right, transparent 8px, #000 8px, #000 calc(var(--cjb-player-bar, 0%) + 0.75px), transparent 0, transparent calc(100% - var(--cjb-player-bar, 0%) - 0.75px), #000 0, #000 calc(100% - 8px), transparent 0);
}
.cjb-player__image[data-fit="letterbox"] {
    --cjb-player-bars:
        linear-gradient(#000 calc(var(--cjb-player-bar, 0%) + 0.75px), transparent 0, transparent calc(100% - var(--cjb-player-bar, 0%) - 0.75px), #000 0) center / calc(100% - 16px) 100% no-repeat,
        linear-gradient(transparent 8px, #000 8px, #000 calc(var(--cjb-player-bar, 0%) + 0.75px), transparent 0, transparent calc(100% - var(--cjb-player-bar, 0%) - 0.75px), #000 0, #000 calc(100% - 8px), transparent 0);
}
.cjb-player__image.is-current,
.cjb-player__image.is-entering {
    pointer-events: auto;
}
.cjb-player__image.is-current {
    opacity: 1;
}
/* 장면 전환 0.8초 - 전환 시간은 다음 장의 5.2초 안에 든다(2026-11-17 사용자 결정). 재생 중이 아니면(일시정지 · 탭 숨김 · 불러오는 중) 그 자리에서 멈췄다가 이어진다. */
.cjb-player__image.is-entering {
    z-index: 1;
    animation: cjb-player-fade-in 0.8s ease-in-out both;
}
.cjb-player:not(.is-playing) .cjb-player__image.is-entering {
    animation-play-state: paused;
}

/* 대기 · 일시정지 화면을 어둡게 - 재생 중에는 걷는다. 밝기 0.7 은 불투명한 사진 위에 scrim(--cjb-scrim 검정 30%)을 덮은 값과 같다.
   무대 전체를 scrim 층으로 덮지 않는다 - 검은 여백 바깥 1px(위 이미지 칸)이 페이지 색 위 회색 테두리로 보인다. */
.cjb-player:not(.is-playing) .cjb-player__scene {
    filter: brightness(0.7);
}

/* 소리 있는 영상이라는 표시만 한다 - 누를 수 없다(VDO-F2-G01). */
.cjb-player__speaker {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: flex;
    width: 16px;
    height: 16px;
}

.cjb-player__speaker svg,
.cjb-player__toggle-icon svg,
.cjb-player__error-icon svg,
.cjb-player__retry-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.cjb-player__toggle {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    padding: 0;
    border: 1.5px solid var(--fstd-on-color);
    border-radius: 28px;
    background-color: var(--cjb-scrim);
    color: var(--fstd-on-color);
    cursor: pointer;
}
.cjb-player__toggle:focus-visible {
    outline-color: var(--fstd-on-color);
}

.cjb-player__toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}
/* 첫 재생 버퍼링 - 일시정지 아이콘 자리에 스피너(Figma Spinner 24 안 19.5) */
.cjb-player.is-buffering .cjb-player__toggle-icon svg {
    width: 19.5px;
    height: 19.5px;
    animation: cjb-player-spin 1s linear infinite;
}

/* 대기 화면은 한 바퀴 길이, 재생 뒤에는 흐른 시간 */
.cjb-player__time {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    padding: 2px 8px;
    border-radius: 10px;
    background-color: var(--cjb-scrim);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* 진행 막대 - 보기 전용(VDO-F2-G01) */
.cjb-player__progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    display: none;
    height: 3px;
}
.cjb-player__progress::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: 2px;
    background-color: var(--fstd-on-color);
    opacity: 0.4;
}
.cjb-player__progress-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    border-radius: 2px;
    background-color: var(--fstd-on-color);
}
.cjb-player.is-playing .cjb-player__progress,
.cjb-player.is-paused .cjb-player__progress {
    display: block;
}

/* 재생 중 자동 숨김(cjb-player-autohide.js) - 가운데 버튼만 숨긴다. 재생 시간 · 진행 막대 · 스피커는 모든 화면에서 늘 보인다(2026-11-16 사용자 결정).
   visibility · display 가 아니라 투명도로 숨겨 숨은 버튼도 Tab 으로 닿는다(포커스가 오면 JS 가 다시 보인다). 숨은 동안 누름은 버튼에 닿지 않는다. */
.cjb-player__toggle {
    transition: opacity 0.2s ease;
}
.cjb-player.is-controls-hidden .cjb-player__toggle {
    opacity: 0;
    pointer-events: none;
}

/* ---------- 불러오는 중(Figma 4050:12165) · 실패(4050:12207) ---------- */

.cjb-player__loading,
.cjb-player__error,
.cjb-player__retry {
    display: none;
}

.cjb-player.is-loading,
.cjb-player.is-failed {
    background-color: var(--cjb-surface-faint);
    color: var(--fstd-neutral-label);
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    letter-spacing: -0.13px;
}

/* 크기(16:9)는 무대가 잡고 보이지만 않게 한다 - 숨은 재생 버튼에 포커스가 가지 않는다. */
.cjb-player.is-loading .cjb-player__stage {
    visibility: hidden;
}
.cjb-player.is-loading .cjb-player__loading {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.cjb-player__spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}
.cjb-player__spinner svg {
    display: block;
    width: 19.5px;
    height: 19.5px;
    animation: cjb-player-spin 1s linear infinite;
}
.cjb-player__loading-text,
.cjb-player__error-text {
    margin: 0;
    text-align: center;
    word-break: keep-all;
}

/* 실패 칸은 16:9 가 아니라 내용 높이(위아래 40). */
.cjb-player.is-failed {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 40px 0;
    border: 1px solid var(--cjb-stroke-subtle);
}
.cjb-player.is-failed .cjb-player__stage {
    display: none;
}
.cjb-player.is-failed .cjb-player__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.cjb-player__error-icon {
    display: flex;
    width: 24px;
    height: 24px;
}
.cjb-player.is-failed .cjb-player__retry {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-sizing: border-box;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--fstd-brand);
    font: inherit;
    font-weight: 600;
    letter-spacing: inherit;
    white-space: nowrap;
    cursor: pointer;
}
/* 누르는 영역 높이 44 - 보이는 버튼은 시안 높이 28 그대로. */
.cjb-player__retry::before {
    content: '';
    position: absolute;
    top: -8px;
    right: -4px;
    bottom: -8px;
    left: -4px;
}
.cjb-player__retry-icon {
    display: flex;
    width: 14px;
    height: 14px;
}

@keyframes cjb-player-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@media (prefers-reduced-motion: reduce) {
    .cjb-player__spinner svg,
    .cjb-player.is-buffering .cjb-player__toggle-icon svg {
        animation: none;
    }
    .cjb-player__toggle {
        transition: none;
    }
    /* 장면 전환도 페이드 없이 바로 바뀐다 - cjb-player-crossfade.js 가 이 미디어에서는 전환 클래스를 붙이지 않고, 이 줄은 도중에 설정이 바뀐 때를 받친다. */
    .cjb-player__image.is-entering {
        animation: none;
        opacity: 1;
    }
}
