/*
 * 이용 통계(분석) 동의 — 하단 안내·쿠키 설정 창 (마크업: fragments/analytics :: body, 동작: eds-consent.js)
 *
 * 모든 화면에 실린다: 앱 화면(Phoenix 테마)과 테마 없는 단독 화면(방침·약관·오류·결제).
 * 색·모서리·버튼·글꼴은 Phoenix 변수를 읽고(앱 화면에서 라이트/다크 그대로), 변수가 없는 단독 화면에서는
 * 같은 라이트 값으로 떨어진다. 버튼 셋(모두 허용·거부·설정)은 같은 클래스·같은 크기 — 무게가 같아야 한다.
 *
 * 하단 안내는 앱의 일부처럼 조용하게(소유자 결정 2026-10-06): 중립 바탕, 앱과 같은 글자 크기, 경고색·아이콘·굵은 경고 없음.
 * 업무 화면을 가리지 않게 페이지 아래 여백을 안내 높이만큼 늘린다(html.eds-consent-bar-open, 높이는 eds-consent.js 가 잰다).
 */

/* hidden 속성이 아래 display 규칙에 지지 않게 (규칙보다 먼저 선언해도 !important 로 이긴다) */
.eds-consent [hidden],
.eds-consent[hidden] {
    display: none !important;
}

.eds-consent {
    --eds-consent-bg: var(--phoenix-emphasis-bg, #fff);
    --eds-consent-fg: var(--phoenix-body-color, #31374a);
    --eds-consent-strong: var(--phoenix-emphasis-color, #141824);
    --eds-consent-muted: var(--phoenix-tertiary-color, #525b75);
    --eds-consent-border: var(--phoenix-border-color, #cbd0dd);
    --eds-consent-soft: var(--phoenix-body-highlight-bg, #eff2f6);
    --eds-consent-primary: var(--phoenix-primary, #3874ff);
    --eds-consent-danger: var(--phoenix-danger, #ed2000);
    --eds-consent-radius: var(--phoenix-border-radius, .375rem);
    --eds-consent-radius-lg: var(--phoenix-border-radius-lg, .5rem);
    font-family: var(--phoenix-body-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif);
    color: var(--eds-consent-fg);
    word-break: keep-all; /* 한국어는 어절 단위로 줄바꿈 */
    overflow-wrap: anywhere;
}

.eds-consent p {
    margin: 0;
}

/* ---------- 버튼 (btn-phoenix-secondary 와 같은 토큰, 테마 없는 화면은 같은 라이트 값) ---------- */
.eds-consent .eds-consent-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 38px;
    min-height: 38px;
    padding: 0 1rem;
    margin: 0;
    font-family: inherit;
    font-size: var(--phoenix-btn-font-size, .8rem);
    font-weight: var(--phoenix-btn-font-weight, 700);
    line-height: 1;
    white-space: nowrap;
    color: var(--phoenix-btn-color, #31374a);
    background-color: var(--phoenix-btn-bg, #f5f7fa);
    border: 1px solid var(--phoenix-btn-border-color, #e3e6ed);
    border-radius: var(--eds-consent-radius);
    cursor: pointer;
    transition: background-color .15s ease-in-out, border-color .15s ease-in-out, color .15s ease-in-out;
}

.eds-consent .eds-consent-btn:hover {
    color: var(--phoenix-btn-hover-color, #222834);
    background-color: var(--phoenix-btn-hover-bg, #e3e6ed);
    border-color: var(--phoenix-btn-hover-border-color, #e6e9ef);
}

.eds-consent .eds-consent-btn:active {
    background-color: var(--phoenix-btn-active-bg, #e3e6ed);
}

.eds-consent .eds-consent-btn:focus-visible,
.eds-consent .eds-consent-x:focus-visible,
.eds-consent .eds-consent-toggle:focus-visible,
.eds-consent a:focus-visible {
    outline: 2px solid var(--eds-consent-primary);
    outline-offset: 2px;
}

.eds-consent .eds-consent-btn:disabled {
    opacity: .55;
    cursor: default;
}

.eds-consent .eds-consent-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(5.5rem, 1fr));
    gap: .5rem;
}

.eds-consent .eds-consent-actions--two {
    grid-template-columns: repeat(2, minmax(5.5rem, 1fr));
}

/* 닫기(✕) — 동의가 아니다 (다음 화면에서 다시 묻는다) */
.eds-consent .eds-consent-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--eds-consent-muted);
    background: transparent;
    border: 0;
    border-radius: var(--eds-consent-radius);
    cursor: pointer;
    flex: 0 0 auto;
}

.eds-consent .eds-consent-x:hover {
    color: var(--eds-consent-strong);
    background: var(--eds-consent-soft);
}

.eds-consent .eds-consent-x svg {
    width: 14px;
    height: 14px;
}

.eds-consent a {
    white-space: nowrap; /* "자세히 보기" 가 두 줄로 갈라지지 않게 */
    color: var(--phoenix-link-color, #3874ff);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* '자세히 보기' — 조용한 링크 (본문 색, 밑줄). 방침의 이용 통계·국외 이전 절을 새 탭으로 연다 */
.eds-consent .eds-consent-more-link {
    color: var(--eds-consent-muted);
    text-decoration-color: currentColor;
}

.eds-consent .eds-consent-more-link:hover {
    color: var(--eds-consent-strong);
}

.eds-consent .eds-consent-optional {
    font-weight: 400;
    color: var(--eds-consent-muted);
}

.eds-consent .eds-consent-error {
    margin-top: .5rem;
    font-size: .8125rem;
    color: var(--eds-consent-danger);
}

/* ---------- 하단 안내 (로그인 전·후 모든 화면) ---------- */
.eds-consent .eds-consent-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* Bootstrap 오프캔버스(1045)·모달(1055) 아래 — 업무 화면의 창이 뜨면 그 창이 위에 온다 */
    z-index: 1035;
    margin: 0;
    padding: 0; /* 테마의 section 여백(3.5rem)을 받지 않는다 */
    background: var(--eds-consent-bg);
    border-top: 1px solid var(--eds-consent-border);
    box-shadow: 0 -2px 8px rgba(20, 24, 36, .06);
}

/* 앱 화면처럼 가득 차게 — 좌우 여백(1.25rem)이 업무 화면의 내용 가장자리와 같다. [안내 | 버튼 셋 | ✕] */
.eds-consent .eds-consent-bar-inner {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: .625rem 1rem;
    align-items: center;
    padding: .75rem 1.25rem;
}

.eds-consent .eds-consent-title {
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--eds-consent-strong);
}

.eds-consent .eds-consent-desc {
    margin-top: .125rem;
    font-size: .8125rem;
    line-height: 1.55;
    color: var(--eds-consent-fg);
}

.eds-consent .eds-consent-bar .eds-consent-actions {
    min-width: 18rem;
}

/* 안내가 열려 있으면 페이지 맨 아래 내용(저장·다음 버튼 등)이 안내 밑에 깔리지 않게 그만큼 아래 여백을 둔다 */
html.eds-consent-bar-open body {
    padding-bottom: var(--eds-consent-bar-h, 0px);
}

/* ---------- 쿠키 설정 창 ('설정'·'쿠키 설정'을 눌렀을 때만) ---------- */
html.eds-consent-dialog-open body {
    overflow: hidden;
}

.eds-consent .eds-consent-layer {
    position: fixed;
    inset: 0;
    /* Bootstrap 모달(1055)·배경(1050) 아래 — 다른 화면의 모달이 뜨면 그쪽이 위에 오고 키보드를 갖는다 */
    z-index: 1049;
    display: grid;
    place-items: center;
    padding: 1rem;
    overflow-y: auto;
}

.eds-consent .eds-consent-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 36, .5);
}

.eds-consent .eds-consent-dialog {
    position: relative;
    width: min(560px, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--eds-consent-bg);
    border: 1px solid var(--eds-consent-border);
    border-radius: var(--eds-consent-radius-lg);
    box-shadow: 0 12px 32px rgba(20, 24, 36, .2);
}

.eds-consent .eds-consent-dialog:focus {
    outline: none;
}

.eds-consent .eds-consent-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: 1.125rem 1rem .5rem 1.25rem;
}

.eds-consent .eds-consent-dialog-title {
    margin: 0;
    padding-top: .25rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--eds-consent-strong);
}

.eds-consent .eds-consent-dialog-body {
    padding: 0 1.25rem;
    font-size: .875rem;
    line-height: 1.6;
}

.eds-consent .eds-consent-dialog-foot {
    padding: 1rem 1.25rem 1.25rem;
}

.eds-consent .eds-consent-more {
    margin-top: .75rem;
    font-size: .8125rem;
}

/* 설정 창의 범주 — 행마다 [설명 | 조작] 두 칸 */
.eds-consent .eds-consent-status {
    margin-bottom: .25rem;
    padding: .5rem .75rem;
    font-size: .8125rem;
    background: var(--eds-consent-soft);
    border-radius: var(--eds-consent-radius);
}

.eds-consent .eds-consent-category {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4.5rem;
    gap: .25rem 1rem;
    align-items: center;
    padding: .875rem 0;
    border-bottom: 1px solid var(--eds-consent-border);
}

.eds-consent .eds-consent-category:last-of-type {
    border-bottom: 0;
}

.eds-consent .eds-consent-category-name {
    display: block;
    margin: 0;
    font-size: .875rem;
    font-weight: 600;
    color: var(--eds-consent-strong);
}

.eds-consent .eds-consent-category-desc {
    margin-top: .125rem;
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--eds-consent-muted);
}

.eds-consent .eds-consent-control {
    justify-self: end;
}

.eds-consent .eds-consent-always {
    display: inline-block;
    padding: .25rem .5rem;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--eds-consent-muted);
    background: var(--eds-consent-soft);
    border-radius: 999px;
}

/* 스위치 — 테마와 상관없이 같은 모양 (기본 꺼짐, 미리 켜 두지 않는다) */
.eds-consent .eds-consent-toggle {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
    vertical-align: middle;
    background: var(--eds-consent-border);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .15s ease-in-out;
}

.eds-consent .eds-consent-toggle::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(20, 24, 36, .3);
    transition: transform .15s ease-in-out;
}

.eds-consent .eds-consent-toggle:checked {
    background: var(--eds-consent-primary);
}

.eds-consent .eds-consent-toggle:checked::before {
    transform: translateX(20px);
}

/* ---------- 알림 (저장 결과) ---------- */
.eds-consent .eds-consent-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    z-index: 1060;
    max-width: calc(100% - 2rem);
    padding: .625rem 1rem;
    font-size: .875rem;
    line-height: 1.5;
    color: #fff;
    background: #222834;
    border-radius: var(--eds-consent-radius);
    box-shadow: 0 6px 20px rgba(20, 24, 36, .25);
    transform: translateX(-50%);
}

/* ---------- 좁은 화면 ---------- */
@media (max-width: 767.98px) {
    .eds-consent .eds-consent-bar-inner {
        grid-template-columns: minmax(0, 1fr);
        gap: .625rem;
    }

    .eds-consent .eds-consent-bar .eds-consent-x {
        position: absolute;
        top: .5rem;
        right: .5rem;
    }

    .eds-consent .eds-consent-bar .eds-consent-title {
        padding-right: 2rem;
    }

    .eds-consent .eds-consent-bar .eds-consent-actions {
        min-width: 0;
    }
}

@media (max-width: 479.98px) {
    .eds-consent .eds-consent-layer {
        padding: .5rem;
    }

    .eds-consent .eds-consent-dialog {
        max-height: calc(100vh - 1rem);
    }

    .eds-consent .eds-consent-btn {
        padding: 0 .5rem;
    }

    .eds-consent .eds-consent-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .eds-consent .eds-consent-actions--two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .eds-consent .eds-consent-btn,
    .eds-consent .eds-consent-toggle,
    .eds-consent .eds-consent-toggle::before {
        transition: none;
    }
}
