/* ==========================================================================
   KAX Site Popups (메인 페이지 레이어 팝업 공지)
   - 메인 페이지(templates/core/partials/_site_popups.html)와
     관리자 팝업 빌더 미리보기(templates/admin/core/sitepopup/change_form.html)가 공유합니다.
   - 본문 HTML 블록용 유틸 클래스는 `kp-` 접두사를 사용합니다 (Tailwind 비의존).
   ========================================================================== */

.kax-popup-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 70;
}

.kax-popup {
    --kp-width: 380px;
    --kp-accent: #b8862f;
    --kp-accent-dark: #8d6f3e;
    --kp-accent-soft: #fdf6e7;
    --kp-accent-line: #eee4d2;

    position: absolute;
    top: 0;
    left: 0;
    width: var(--kp-width);
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 110px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 18px;
    overflow: hidden;
    pointer-events: auto;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
    color: #334155;
    box-shadow:
        0 28px 60px -18px rgba(15, 23, 42, 0.45),
        0 10px 24px -12px rgba(15, 23, 42, 0.25),
        0 0 0 1px rgba(15, 23, 42, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.96);
    transition: opacity 0.38s ease, transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.25), visibility 0s linear 0.45s;
}

.kax-popup.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.38s ease, transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.25), visibility 0s;
}

.kax-popup.is-closing {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
}

.kax-popup.is-dragging {
    transition: none;
    box-shadow: 0 36px 70px -18px rgba(15, 23, 42, 0.55), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

/* Preview mode (관리자 빌더 미리보기) - 고정 배치 */
.kax-popup.is-preview {
    position: relative;
    margin: 0 auto;
    max-height: none;
}

/* ----- Accent Themes ----- */
.kp-accent-amber   { --kp-accent: #b8862f; --kp-accent-dark: #8d6f3e; --kp-accent-soft: #fdf6e7; --kp-accent-line: #eee4d2; }
.kp-accent-navy    { --kp-accent: #1e40af; --kp-accent-dark: #172554; --kp-accent-soft: #eff4ff; --kp-accent-line: #dbe4ff; }
.kp-accent-emerald { --kp-accent: #059669; --kp-accent-dark: #065f46; --kp-accent-soft: #ecfdf5; --kp-accent-line: #c9f0de; }
.kp-accent-rose    { --kp-accent: #e11d48; --kp-accent-dark: #9f1239; --kp-accent-soft: #fff1f2; --kp-accent-line: #fecdd3; }
.kp-accent-slate   { --kp-accent: #334155; --kp-accent-dark: #0f172a; --kp-accent-soft: #f1f5f9; --kp-accent-line: #e2e8f0; }

/* ----- Header ----- */
.kax-popup__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    background: linear-gradient(135deg, var(--kp-accent) 0%, var(--kp-accent-dark) 100%);
    color: #ffffff;
    cursor: move;
    user-select: none;
    touch-action: none;
}

.kax-popup__icon {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.18);
    font-size: 13px;
}

.kax-popup__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kax-popup__x {
    flex: none;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.kax-popup__x:hover { background: rgba(255, 255, 255, 0.28); }

/* ----- Body ----- */
.kax-popup__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    overscroll-behavior: contain;
}
.kax-popup__body img { max-width: 100%; height: auto; border-radius: 12px; display: block; }
.kax-popup__body p { margin: 0 0 8px; }
.kax-popup__body a { color: var(--kp-accent-dark); }

/* ----- Footer ----- */
.kax-popup__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 14px;
    background: #0f172a;
    font-size: 12px;
}
.kax-popup__foot button {
    border: 0;
    background: transparent;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 2px;
    font-family: inherit;
}
.kax-popup__foot button:hover { color: #ffffff; }
.kax-popup__foot [data-popup-close] { color: #ffffff; font-weight: 800; }

/* ==========================================================================
   Content Blocks (kp-*) — 관리자 빌더의 블록 템플릿이 사용하는 클래스
   ========================================================================== */

.kp-hero {
    position: relative;
    padding: 18px 16px;
    border-radius: 14px;
    background:
        radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.9) 0, transparent 55%),
        linear-gradient(135deg, var(--kp-accent-soft) 0%, #ffffff 100%);
    border: 1px solid var(--kp-accent-line);
    margin-bottom: 12px;
    overflow: hidden;
}
.kp-hero__emoji { position: absolute; right: 12px; top: 10px; font-size: 38px; opacity: 0.9; }

.kp-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--kp-accent);
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.kp-title {
    margin: 8px 0 4px;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #0f172a;
}
.kp-title em { font-style: normal; color: var(--kp-accent-dark); }

.kp-text { margin: 0; font-size: 13px; color: #64748b; }

.kp-divider { border: 0; border-top: 1px dashed #e2e8f0; margin: 14px 0; }

/* Info list (주소/전화/영업시간 등) */
.kp-info-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.kp-info-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #334155; }
.kp-info-list i {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--kp-accent-soft);
    color: var(--kp-accent-dark);
    font-size: 12px;
}
.kp-info-list b { display: block; font-size: 11px; color: #94a3b8; font-weight: 700; }

/* Big phone */
.kp-phone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 12px;
    margin-bottom: 12px;
    border-radius: 14px;
    background: var(--kp-accent-soft);
    border: 1px solid var(--kp-accent-line);
    text-decoration: none !important;
    color: var(--kp-accent-dark) !important;
    transition: transform 0.15s;
}
.kp-phone:hover { transform: translateY(-1px); }
.kp-phone i { font-size: 18px; }
.kp-phone span { font-size: 26px; font-weight: 900; letter-spacing: 0.02em; }
.kp-phone small { display: block; font-size: 11px; color: #64748b; font-weight: 600; text-align: center; }

/* Buttons */
.kp-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.kp-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 120px;
    padding: 10px 12px;
    border-radius: 11px;
    background: var(--kp-accent-dark);
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none !important;
    transition: filter 0.15s;
}
.kp-btn:hover { filter: brightness(1.12); }
.kp-btn--ghost { background: #ffffff; color: var(--kp-accent-dark) !important; border: 1px solid var(--kp-accent-line); }
.kp-btn--kakao { background: #fee500; color: #191919 !important; }

/* Kakao Map Block */
.kax-kakao-map {
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: 14px;
    overflow: hidden;
    background: #eef2f7;
    border: 1px solid #e2e8f0;
    margin-bottom: 8px;
}
.kax-kakao-map .kp-map-label {
    padding: 5px 10px;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.3);
    transform: translateY(-46px);
}

.kp-map-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    text-align: center;
    background:
        linear-gradient(rgba(238, 242, 247, 0.86), rgba(238, 242, 247, 0.86)),
        repeating-linear-gradient(0deg, #dbe3ee 0 1px, transparent 1px 28px),
        repeating-linear-gradient(90deg, #dbe3ee 0 1px, transparent 1px 28px);
    color: #475569;
    font-size: 12px;
}
.kp-map-fallback i { font-size: 30px; color: var(--kp-accent); filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15)); }
.kp-map-fallback strong { font-size: 13px; color: #0f172a; }
.kp-map-fallback a {
    margin-top: 4px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #fee500;
    color: #191919 !important;
    font-weight: 800;
    text-decoration: none !important;
}

/* ==========================================================================
   Mobile: 카드 덱처럼 겹쳐서 표시 (위에서부터 닫으면 다음 팝업 노출)
   ========================================================================== */
@media (max-width: 639px) {
    .kax-popup:not(.is-preview) {
        width: auto;
        max-height: calc(100vh - 140px);
        border-radius: 16px;
    }
    .kax-popup__head { cursor: default; }
    .kp-phone span { font-size: 22px; }
}
