/* 부고 화면 공통 UI - fstd-tokens.css · fstd-button.css · cjb-theme.css 뒤에 싣는다.
   폭 경계는 744 하나다(@bp:744). 기존 t 991 · 480, apply 961 과 섞지 않는다. 열고 닫기 250ms 는 cjb-ui.js 의 TRANSITION_MS 와 같아야 한다. */

/* body 직계라 화면의 글꼴을 물려받지 못한다. */
.cjb-sheet,
.cjb-toast {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* 클래스 규칙의 display 가 UA 의 [hidden] 을 이긴다 - 못 박는다. */
.cjb-sheet[hidden],
.cjb-toast__box[hidden],
.cjb-toast__icon[hidden] {
    display: none !important;
}

/* 전역 CSS 가 포커스 윤곽선을 지우는 화면이 있다 - 키보드 포커스에서만 되살린다. */
.cjb-sheet :focus-visible,
.cjb-toast :focus-visible {
    outline: 2px solid var(--fstd-fg-heavy);
    outline-offset: 2px;
}

/* 시트를 열면 cjb-ui.js 가 제목(tabindex="-1", data-cjb-initial-focus)에 포커스를 준다 - 스크린리더가 제목부터 읽게 하려는 것이라 테두리는 그리지 않는다.
   조작 없이 열리는 시트(재로그인 · 작성 직후 등)는 스크립트 포커스에도 :focus-visible 이 맞아 위 윤곽선이 제목에 남는다. 제목은 누르는 곳이 아니어서 키보드로 열어도 그리지 않는다.
   버튼 · × · 입력칸의 키보드 포커스 윤곽선은 그대로다. 시트 제목 포커스 규칙은 이 한 곳에 둔다. */
.cjb-sheet__title[tabindex="-1"]:focus {
    outline: none;
}

/* ---------- 시트 - 744 미만 바텀시트(VDO-F1-I09), 이상 센터 모달(VDO-F1-I08) ---------- */

.cjb-sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10100;                    /* 레거시 최상위(10000) 위. 겹친 시트는 cjb-ui.js 가 연 순서대로 올린다 */
}

.cjb-sheet__dim {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: var(--fstd-dim-sheet);
    opacity: 0;
    transition: opacity 250ms ease-out;
}
.cjb-sheet.is-open .cjb-sheet__dim {
    opacity: 1;
}

/* 패널 기본 글꼴은 제목 글꼴(KR/Title/Semibold/1)이다 - 본문 · 버튼은 각자 덮는다. */
.cjb-sheet__panel {
    position: absolute;
    right: 0;
    bottom: var(--cjb-keyboard, 0px);  /* 키보드가 열리면 그 위에 붙는다 */
    left: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    max-height: calc(var(--cjb-vh, 100vh) * 0.9);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-radius: 20px 20px 0 0;
    background-color: var(--fstd-surface);
    color: var(--fstd-fg-heavy);
    font-size: 20px;
    font-weight: 600;
    line-height: 26px;
    letter-spacing: -0.4px;
    transform: translateY(100%);
    transition: transform 250ms ease-out;
}
.cjb-sheet.is-open .cjb-sheet__panel {
    transform: none;
}

/* 피커 시트(날짜 선택)는 가용 높이 − 24 까지, 본문 스크롤 없음. */
.cjb-sheet__panel--picker {
    max-height: calc(var(--cjb-vh, 100vh) - 24px);
}
.cjb-sheet__panel--picker .cjb-sheet__body {
    overflow: visible;
}
/* 키보드가 열리면 상한 = 화면 − 키보드 − 24(--cjb-vh 가 이미 키보드를 뺀 높이다). */
.cjb-keyboard-open .cjb-sheet__panel {
    max-height: calc(var(--cjb-vh, 100vh) - 24px);
}

/* 끌기 영역. touch-action: none 이 없으면 모바일 브라우저가 끌기를 스크롤로 가져가 닫기가 취소된다. */
.cjb-sheet__handle {
    display: flex;
    flex: none;
    justify-content: center;
    padding: 12px 0 8px;
    touch-action: none;
    cursor: grab;
}
.cjb-sheet__handle::before {
    content: '';
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background-color: var(--fstd-stroke-muted);
}

.cjb-sheet__head {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 0 16px;
}

.cjb-sheet__title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.cjb-sheet__close {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 32px;
    height: 32px;
    padding: 6px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--fstd-neutral-label);
    cursor: pointer;
}
.cjb-sheet__close svg {
    display: block;
    width: 20px;
    height: 20px;
}
/* 누르는 영역 44×44 - 보이는 X(모바일 32, PC 36)는 시안 크기 그대로 둔다. */
.cjb-sheet__close::before {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    bottom: -6px;
    left: -6px;
}

.cjb-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 16px 16px;
    color: var(--cjb-fg-subtle);
    font-size: 15px;
    font-weight: 400;
    line-height: 22px;
    letter-spacing: -0.3px;
    word-break: keep-all;
}
.cjb-sheet__body > :first-child {
    margin-top: 0;
}
.cjb-sheet__body > :last-child {
    margin-bottom: 0;
}
/* 넘칠 때만 아래 흐림(Fog 28) - 끝까지 내리면 걷는다. */
.cjb-sheet__panel.is-overflowing:not(.is-scrolled-end) .cjb-sheet__body {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}

.cjb-sheet__foot {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--cjb-stroke-subtle);
}
.cjb-sheet__foot > .fstd-button {
    width: 100%;
}

@media (min-width: 744px) { /* @bp:744 */
    .cjb-sheet__dim {
        background-color: var(--fstd-dim-modal);
    }

    .cjb-sheet__panel,
    .cjb-keyboard-open .cjb-sheet__panel {
        max-height: calc(var(--cjb-vh, 100vh) * 0.7);
    }
    .cjb-sheet__panel {
        top: 50%;
        right: auto;
        bottom: auto;
        left: 50%;
        width: 420px;
        max-width: calc(100vw - 32px);
        padding-bottom: 0;
        border: 1px solid var(--fstd-stroke-muted);
        border-radius: 16px;
        box-shadow: 0 0 2px rgba(0, 0, 0, 0.08), 0 8px 16px rgba(0, 0, 0, 0.12);
        line-height: 28px;
        opacity: 0;
        transform: translate(-50%, -50%);
        transition: opacity 250ms ease-out;
    }
    .cjb-sheet.is-open .cjb-sheet__panel {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    /* 짧은 확인(나가기 · 마감 · 저장 실패)은 336, 부고장 보내기는 488(Rationale 5027:11766). */
    .cjb-sheet__panel--modal-336 {
        width: 336px;
    }
    .cjb-sheet__panel--modal-488 {
        width: 488px;
    }

    .cjb-sheet__handle {
        display: none;
    }

    .cjb-sheet__head {
        align-items: flex-start;
        padding: 24px 20px 12px;
    }
    .cjb-sheet__close {
        width: 36px;
        height: 36px;
        color: var(--fstd-fg-muted);
    }
    .cjb-sheet__close::before {
        top: -4px;
        right: -4px;
        bottom: -4px;
        left: -4px;
    }

    .cjb-sheet__body {
        padding: 0 20px 20px;
        color: var(--fstd-neutral-label);
        font-size: 16px;
        line-height: 24px;
        letter-spacing: -0.32px;
    }

    /* 주 버튼은 오른쪽(Rationale 5199:13480) - 마크업은 모바일과 같은 순서(주 버튼 먼저)라 뒤집는다. */
    .cjb-sheet__foot {
        flex-direction: row-reverse;
        gap: 10px;
        padding: 16px 20px 20px;
        border-top-color: var(--fstd-stroke-muted);
    }
    .cjb-sheet__foot > .fstd-button {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }
}

/* ---------- 토스트 - 모바일 화면 − 32, 744 이상 본문 컨테이너(912) − 56 = 856(VDO-F1-G03) ---------- */

.cjb-toast {
    position: fixed;
    right: 0;
    bottom: calc(16px + var(--cjb-toast-offset, 0px) + env(safe-area-inset-bottom, 0px)); /* 하단 고정 바가 있는 화면은 --cjb-toast-offset 에 그 높이를 둔다 */
    left: 0;
    z-index: 10600;                    /* 열린 시트 위 */
    display: flex;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 16px;
    pointer-events: none;              /* 화면 폭 루트가 아래 버튼의 탭을 막지 않게 - 상자만 auto */
}

.cjb-toast__box {
    display: flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    width: 100%;
    max-width: 856px;
    padding: 12px 8px 12px 16px;
    border-radius: 6px;
    background-color: var(--cjb-snackbar-bg);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    color: var(--fstd-on-color);
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    letter-spacing: -0.13px;
    pointer-events: auto;
}

.cjb-toast__icon {
    display: flex;
    flex: none;
    width: 16px;
    height: 16px;
}
.cjb-toast__icon svg {
    width: 100%;
    height: 100%;
}

.cjb-toast__message {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* 누르는 영역 24px(WCAG 2.5.8) - 늘어난 6 은 위아래 margin -3 으로 되돌려 토스트 높이를 지킨다. */
.cjb-toast__close {
    flex: none;
    min-height: 24px;
    margin: -3px 0;
    padding: 0 8px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--cjb-snackbar-action);
    font: inherit;
    letter-spacing: inherit;
    white-space: nowrap;
    cursor: pointer;
}

/* CJB.toast.show 의 tone 을 준 토스트 - 모양(색 · 아이콘 배경)은 tone 을 쓰는 화면의 전용 CSS 가 [data-tone] 으로 그린다.
   cjb-ui.js 는 tone 이면 아이콘 자리를 연다 - 성공 아이콘 마크업은 숨긴다. tone 이 없으면 kind 와 관계없이 위 어두운 스낵바 그대로다. */
.cjb-toast__box[data-tone] .cjb-toast__icon svg {
    display: none;
}

@media (min-width: 744px) { /* @bp:744 */
    .cjb-toast {
        padding: 0 28px;
    }
    .cjb-toast__box {
        padding: 16px;
        -webkit-backdrop-filter: blur(6px);
        backdrop-filter: blur(6px);
    }
    .cjb-toast__icon {
        width: 18px;
        height: 18px;
    }
    .cjb-toast__close {
        font-weight: 500;
    }
}

/* ---------- 스위치 - 추모영상 사용 켬 · 끔. 레거시 .switch · .check_slider 는 쓰지 않는다 ----------
   <label class="cjb-switch"><span>추모영상 사용</span><span class="cjb-switch__control">
     <input class="cjb-switch__input" type="checkbox" role="switch"><span class="cjb-switch__track" aria-hidden="true"></span></span></label>
   입력칸은 트랙 위에 투명하게 겹쳐 둔다 - 숨기면 키보드 포커스 · 스크린리더가 스위치를 찾지 못한다. */

.cjb-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.cjb-switch__control {
    position: relative;
    display: inline-flex;
    flex: none;
    width: 48px;
    height: 24px;
}

.cjb-switch__input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: inherit;
}

.cjb-switch__track {
    position: relative;
    box-sizing: border-box;
    width: 48px;
    height: 24px;
    border-radius: 12px;
    background-color: var(--cjb-switch-off);
    pointer-events: none;
    transition: background-color 150ms ease-out;
}
.cjb-switch__track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--fstd-surface);
    transition: transform 150ms ease-out;
}

.cjb-switch__input:checked + .cjb-switch__track {
    background-color: var(--fstd-brand);
}
.cjb-switch__input:checked + .cjb-switch__track::after {
    transform: translateX(24px);
}
.cjb-switch__input:focus-visible + .cjb-switch__track {
    outline: 2px solid var(--fstd-fg-heavy);
    outline-offset: 2px;
}
/* 비활성은 FSTD 값 그대로(버튼 비활성 바탕과 같은 값). */
.cjb-switch__input:disabled {
    cursor: default;
}
.cjb-switch__input:disabled + .cjb-switch__track {
    background-color: var(--fstd-surface-muted);
}

/* ---------- 라디오 - 음악 목록 ----------
   <label class="cjb-radio"><input class="cjb-radio__input" type="radio" name="…"><span class="cjb-radio__mark" aria-hidden="true"></span><span class="cjb-radio__label">곡 이름</span></label> */

.cjb-radio {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    box-sizing: border-box;
    min-height: 28px;
    padding: 4px 3px;
    color: var(--fstd-neutral-label);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    letter-spacing: -0.21px;
    cursor: pointer;
}

.cjb-radio__input {
    position: absolute;
    top: 50%;
    left: 3px;
    width: 16px;
    height: 16px;
    margin: -8px 0 0;
    opacity: 0;
    cursor: inherit;
}

/* 고르지 않아도 테두리는 코랄(시안 Radio Button 코랄 값 덮어씀) - 고르면 가운데 점이 찬다. */
.cjb-radio__mark {
    position: relative;
    flex: none;
    box-sizing: border-box;
    width: 16px;
    height: 16px;
    border: 1.25px solid var(--fstd-brand);
    border-radius: 50%;
}
.cjb-radio__mark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--fstd-brand);
    transform: translate(-50%, -50%) scale(0);
}

.cjb-radio__label {
    flex: 1 1 auto;
    min-width: 0;
}

.cjb-radio__input:checked + .cjb-radio__mark::after {
    transform: translate(-50%, -50%) scale(1);
}
.cjb-radio__input:checked ~ .cjb-radio__label {
    color: var(--cjb-fg-default);
}
.cjb-radio__input:focus-visible + .cjb-radio__mark {
    outline: 2px solid var(--fstd-fg-heavy);
    outline-offset: 2px;
}
.cjb-radio__input:disabled {
    cursor: default;
}
.cjb-radio__input:disabled + .cjb-radio__mark {
    border-color: var(--fstd-neutral-border);
}
.cjb-radio__input:disabled + .cjb-radio__mark::after {
    background-color: var(--fstd-neutral-border);
}

/* .is-open 규칙까지 적어야 특정도에서 이긴다. */
@media (prefers-reduced-motion: reduce) {
    .cjb-sheet__dim,
    .cjb-sheet.is-open .cjb-sheet__dim,
    .cjb-sheet__panel,
    .cjb-sheet.is-open .cjb-sheet__panel,
    .cjb-switch__track,
    .cjb-switch__track::after {
        transition: none;
    }
}
