/* ================================================================
 * hm_modal.css  v1.2
 * 모바일 통합 모달 시스템 — hmAlert / hmConfirm / hmToast
 * 기준 디자인: hm_read_login_dialog 스타일 통일
 * 다크모드: html[data-hm-theme="dark"] 선택자 기반
 * ================================================================ */

/* ── 공통 변수 ─────────────────────────────────────────────────── */
:root {
  --hm-modal-bg:           #ffffff;
  --hm-modal-border:       transparent;
  --hm-modal-overlay:      rgba(17, 24, 39, 0.48);
  --hm-modal-radius:       16px;
  --hm-modal-shadow:       0 8px 32px rgba(0, 0, 0, 0.15);
  --hm-modal-title-clr:    #111827;
  --hm-modal-sub-clr:      #6b7280;
  /* 버튼 */
  --hm-modal-btn-ok-bg:    #101c84;
  --hm-modal-btn-ok-bd:    #101c84;
  --hm-modal-btn-ok-clr:   #ffffff;
  --hm-modal-btn-cancel-bg:#ffffff;
  --hm-modal-btn-cancel-bd:#d1d5db;
  --hm-modal-btn-cancel-clr:#374151;
  --hm-modal-btn-danger-bg: #dc2626;
  --hm-modal-btn-danger-bd: #dc2626;
  --hm-modal-btn-danger-clr:#ffffff;
  /* 토스트 */
  --hm-toast-bg:           #1e2330;
  --hm-toast-clr:          #f1f5f9;
}

html[data-hm-theme="dark"] {
  --hm-modal-bg:           #252525;
  --hm-modal-border:       rgba(255, 255, 255, 0.12);
  --hm-modal-overlay:      rgba(0, 0, 0, 0.68);
  --hm-modal-shadow:       0 8px 32px rgba(0, 0, 0, 0.5);
  --hm-modal-title-clr:    #f3f4f6;
  --hm-modal-sub-clr:      #9ca3af;
  --hm-modal-btn-ok-bg:    #1e3a8a;
  --hm-modal-btn-ok-bd:    #1e3a8a;
  --hm-modal-btn-cancel-bg:#3a3a3c;
  --hm-modal-btn-cancel-bd:rgba(255, 255, 255, 0.15);
  --hm-modal-btn-cancel-clr:#d1d5db;
  --hm-toast-bg:           #2c2c2e;
  --hm-toast-clr:          #f1f5f9;
}

/* ── 오버레이 ───────────────────────────────────────────────────── */
.hm-modal-overlay {
  position: fixed;
  inset: 0;
  /* 모든 시트/레이어 (hm-my-push-modal: 2147483003) 위에 표시 */
  z-index: 2147483640;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  box-sizing: border-box;
  /* 뒷 화면 클릭 완전 차단 */
  pointer-events: all;
  touch-action: none;
  animation: hmOverlayIn 0.18s ease both;
}
/* 배경 레이어 (단색, 성능 우선) */
.hm-modal-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hm-modal-overlay);
}
.hm-modal-overlay.hm-modal-leaving {
  animation: hmOverlayOut 0.16s ease both;
}

@keyframes hmOverlayIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes hmOverlayOut { from { opacity: 1; } to { opacity: 0; } }

/* ── 모달 카드 ──────────────────────────────────────────────────── */
.hm-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 320px;
  padding: 24px 20px 20px;
  background: var(--hm-modal-bg);
  border: 1px solid var(--hm-modal-border);
  border-radius: var(--hm-modal-radius);
  box-shadow: var(--hm-modal-shadow);
  box-sizing: border-box;
  text-align: center;
  animation: hmCardIn 0.22s cubic-bezier(0.34, 1.15, 0.64, 1) both;
}
.hm-modal-overlay.hm-modal-leaving .hm-modal-card {
  animation: hmCardOut 0.14s ease both;
}

@keyframes hmCardIn {
  from { opacity: 0; transform: scale(0.9) translateY(6px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}
@keyframes hmCardOut {
  from { opacity: 1; transform: scale(1);    }
  to   { opacity: 0; transform: scale(0.94); }
}

/* ── 타이틀 ─────────────────────────────────────────────────────── */
.hm-modal-title {
  margin: 0;
  color: var(--hm-modal-title-clr);
  font-size: 1.0625rem;   /* 17px */
  font-weight: 700;
  line-height: 1.5;
  word-break: keep-all;
}
.hm-modal-title:empty { display: none; }

/* ── 서브 메시지 ────────────────────────────────────────────────── */
.hm-modal-sub {
  margin: 10px 0 0;
  color: var(--hm-modal-sub-clr);
  font-size: 0.875rem;    /* 14px */
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.hm-modal-sub:empty { display: none; }

/* 타이틀 없을 때 서브가 메인 텍스트처럼 */
.hm-modal-title:empty + .hm-modal-sub {
  color: var(--hm-modal-title-clr);
  font-size: 1.0625rem;
  font-weight: 700;
  margin-top: 0;
}

/* ── 버튼 영역 ──────────────────────────────────────────────────── */
.hm-modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.hm-modal-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 10px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9375rem;   /* 15px */
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s;
}
.hm-modal-btn:active { opacity: 0.82; }

.hm-modal-btn--ok {
  border: 1px solid var(--hm-modal-btn-ok-bd);
  background: var(--hm-modal-btn-ok-bg);
  color: var(--hm-modal-btn-ok-clr);
}
.hm-modal-btn--cancel {
  border: 1px solid var(--hm-modal-btn-cancel-bd);
  background: var(--hm-modal-btn-cancel-bg);
  color: var(--hm-modal-btn-cancel-clr);
}
.hm-modal-btn--danger {
  border: 1px solid var(--hm-modal-btn-danger-bd);
  background: var(--hm-modal-btn-danger-bg);
  color: var(--hm-modal-btn-danger-clr);
}

/* ── 토스트 알림 ────────────────────────────────────────────────── */
.hm-toast-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 99500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.hm-toast {
  padding: 10px 18px;
  background: var(--hm-toast-bg);
  color: var(--hm-toast-clr);
  font-size: 0.8125rem;   /* 13px */
  font-weight: 500;
  line-height: 1.5;
  border-radius: 100px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
  white-space: nowrap;
  animation: hmToastIn 0.2s cubic-bezier(0.34, 1.15, 0.64, 1) both;
}
.hm-toast.hm-toast-leaving {
  animation: hmToastOut 0.18s ease both;
}

@keyframes hmToastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes hmToastOut {
  from { opacity: 1; transform: translateY(0)   scale(1); }
  to   { opacity: 0; transform: translateY(6px) scale(0.96); }
}
