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

/* 클래스 규칙의 display(.share-toast__box 는 flex)가 UA 의 [hidden] 을 이기므로 못 박는다. */
.share-sheet[hidden],
.share-toast__box[hidden] {
    display: none !important;
}

/* base.css 가 모든 요소의 포커스 윤곽선을 지운다 - 키보드 포커스에서만 되살린다. */
.share-sheet :focus-visible,
.share-toast :focus-visible {
    outline: revert;
}

.share-sheet {
    position: fixed;
    inset: 0;
    z-index: 1000;                     /* 상담 폼 .csf 와 같은 층(한 번에 하나만 열린다), 알림 .mdl 1100 아래 */
}

.share-sheet__dim {
    position: absolute;
    inset: 0;
    background-color: var(--fstd-dim-sheet);
    opacity: 0;
    transition: opacity 250ms ease-in;
}

.share-sheet__panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    box-sizing: border-box;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background-color: var(--fstd-surface);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 250ms ease-in;
}

.share-sheet.is-open .share-sheet__dim {
    opacity: 1;
    transition: opacity 300ms ease-out;
}
.share-sheet.is-open .share-sheet__panel {
    transform: none;
    transition: transform 300ms ease-out;
}

/* 보이지 않는 끌기 영역. touch-action: none 이 없으면 모바일 브라우저가 끌기를 스크롤로 가져가 닫기가 취소된다. */
.share-sheet__handle {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 64px;
    touch-action: none;
}

.share-sheet__close {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    border: 0;
    background: none;
    color: var(--fstd-fg-muted);
    cursor: pointer;
    position: relative;                /* 앞서 그려지는 손잡이(absolute) 위에 와야 눌린다 */
    grid-row: 1;
    grid-column: 2;
    align-self: start;
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

.share-sheet__title {
    grid-row: 1;
    grid-column: 1;
    align-self: start;
    margin: 0;
    color: var(--fstd-fg-heavy);
    font-size: var(--ds-text-xl, 20px);
    font-weight: var(--ds-weight-medium, 500);
    line-height: 28px;
    letter-spacing: -0.4px;
}

.share-sheet__desc {
    grid-column: 1 / -1;
    margin: 28px 0 0;
    color: var(--fstd-fg-muted);
    font-size: var(--ds-text-sm, 12px);
    font-weight: var(--ds-weight-medium, 500);
    line-height: 18px;
    letter-spacing: -0.12px;
    word-break: keep-all;
}

.share-sheet__options {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
    color: var(--fstd-fg-muted);
    font-size: var(--ds-text-sm, 12px);
    font-weight: var(--ds-weight-medium, 500);
    line-height: 18px;
    letter-spacing: -0.12px;
    text-align: center;
    white-space: nowrap;
}
.share-sheet__options [data-share-copy],
.share-sheet__options [data-share-kakao] {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}
.share-sheet__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 48px;
    height: 48px;
    margin: 0 auto 8px;
    border-radius: 999px;
    background-color: var(--fstd-surface-muted);
}
.share-sheet__options [data-share-kakao] .share-sheet__icon {
    background-color: var(--fstd-kakao);
}

.share-sheet__dismiss {
    grid-column: 1 / -1;
    margin-top: 36px;
}

@media (min-width: 961px) { /* @bp:961 */
    .share-sheet__dim {
        background-color: var(--fstd-dim-modal);
        transition: opacity 200ms ease-in;
    }
    .share-sheet.is-open .share-sheet__dim {
        transition: opacity 200ms ease-out;
    }

    .share-sheet__panel {
        top: 50%;
        right: auto;
        bottom: auto;
        left: 50%;
        width: 460px;
        padding: 24px 24px 16px;
        border-radius: 16px;
        opacity: 0;
        transition: opacity 200ms ease-in;
    }
    .share-sheet__panel,
    .share-sheet.is-open .share-sheet__panel {
        transform: translate(-50%, -50%);
    }
    .share-sheet.is-open .share-sheet__panel {
        opacity: 1;
        transition: opacity 200ms ease-out;
    }

    .share-sheet__handle {
        display: none;
    }
    .share-sheet__dismiss {
        margin-right: -4px;
        margin-left: -4px;
    }

    /* PC 블록 안에 둔다 - 밖이면 모바일 시트에도 420 이 걸린다. 바깥 961 이 744 로 바뀌면 이 구간도 744~1151 이 된다. */
    @media (max-width: 1151px) { /* @bp:1151 */
        .share-sheet__panel {
            width: 420px;
        }
    }
}

.share-toast {
    position: fixed;
    right: 0;
    bottom: 68px;
    left: 0;
    z-index: 1050;                     /* 열린 공유 시트(1000) 위, 알림 .mdl 1100 아래 */
    display: flex;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 max(28px, env(safe-area-inset-right, 0px)) 0 max(28px, env(safe-area-inset-left, 0px));
    pointer-events: none;              /* 화면 폭 루트가 아래 바의 탭을 막지 않게 - 상자만 auto */
}

.share-toast__box {
    display: flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    width: 319px;
    max-width: 100%;
    padding: 12px 16px;
    border-radius: 6px;
    background-color: var(--fstd-snackbar-bg);
    color: var(--fstd-on-color);
    font-size: var(--ds-text-md, 13px);
    font-weight: var(--ds-weight-regular, 400);
    line-height: 18px;
    letter-spacing: -0.13px;
    pointer-events: auto;
}
.share-toast__icon {
    display: flex;
    flex: none;
    width: 16px;
    height: 16px;
}
/* 클래스 규칙의 display 가 UA 의 [hidden] 을 이겨서 못 박는다. */
.share-toast__icon[hidden] {
    display: none;
}
.share-toast__icon svg {
    width: 100%;
    height: 100%;
}
.share-toast__box [data-share-toast-msg] {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
/* 누르는 영역 24px(WCAG 2.5.8) - 늘어난 6 은 위아래 margin -3 으로 되돌려 토스트 높이를 지킨다. */
.share-toast__box [data-share-toast-close] {
    flex: none;
    min-height: 24px;
    margin: -3px 0;
    padding: 0 8px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--fstd-brand);
    font: inherit;
    letter-spacing: inherit;
    white-space: nowrap;
    cursor: pointer;
}

@media (min-width: 961px) { /* @bp:961 */
    .share-toast {
        bottom: calc(var(--bottom-cta-bar-h) + 40px);
    }
    .share-toast__box {
        width: 568px;
        padding: 16px 8px 16px 16px;
        border-radius: 8px;
        font-size: var(--ds-text-base, 14px);
        font-weight: var(--ds-weight-medium, 500);
        line-height: var(--ds-lh-body2, 20px);
        letter-spacing: -0.21px;
    }
    .share-toast__icon {
        width: 18px;
        height: 18px;
    }
    .share-toast__box [data-share-toast-close] {
        font-size: var(--ds-text-md, 13px);
        line-height: 18px;
        letter-spacing: -0.13px;
    }
}

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