/* 로그인 팝업 (auth-modal.js)
 * 근거: W3C APG Dialog(Modal) 패턴, NN/G 모달·바텀시트 가이드, WCAG 2.5.8 타깃 크기(최소 24px, 권장 44px)
 * 시각: 사이트 기존 .alert-box 와 같은 계열 — #1a1a1a 패널, #333 테두리, 강조 #FFA178
 * 메인은 ds.css 를 불러오지 않으므로 이 파일만으로 완결 (토큰은 --am-*)
 */
.auth-modal {
  --am-bg: #1a1a1a;
  --am-surface: #232326;
  --am-surface-2: #2b2b2e;
  --am-border: #333336;
  --am-text: #f2f2f2;
  --am-text-dim: #a8a8ad;
  --am-text-faint: #77777c;
  --am-accent: #FFA178;
  --am-accent-strong: #e8906a;
  --am-on-accent: #1a1a1a;
  --am-danger: #e5484d;
  --am-radius: 0;
  --am-radius-sm: 2px;

  position: fixed;
  inset: 0;
  z-index: 2500; /* 드로어(1600)·PWA 시트(2100) 위, 토스트(1100)·알럿(1000)보다 위 */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: 'Pretendard-Regular', Arial, sans-serif;
  text-align: left;
  word-break: keep-all; /* 한글은 어절 단위로 줄바꿈 */
}
.auth-modal[hidden] { display: none; }

.auth-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  animation: amFade 0.2s ease-out;
}

.auth-modal__panel {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 37.5rem; /* base.css 의 페이지 최대폭과 같음 */
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--am-bg);
  border: 1px solid var(--am-border);
  border-bottom: none;
  border-radius: var(--am-radius);
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  color: var(--am-text);
  animation: amSlideUp 0.24s ease-out;
}
.auth-modal__panel:focus { outline: none; }
.auth-modal *,
.auth-modal *::before,
.auth-modal *::after { box-sizing: border-box; }

/* 데스크톱: 가운데 다이얼로그 */
@media (min-width: 640px) {
  .auth-modal { align-items: center; padding: 24px; }
  .auth-modal__panel {
    width: 400px;
    border-bottom: 1px solid var(--am-border);
    padding: 24px 24px 28px;
    animation: amScaleIn 0.2s ease;
  }
}

.auth-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.auth-modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--am-text);
}
.auth-modal__desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--am-text-dim);
  line-height: 1.5;
}

.auth-modal__close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--am-radius-sm);
  color: var(--am-text-dim);
  cursor: pointer;
  padding: 0;
}
.auth-modal__close:hover { background: var(--am-surface-2); color: var(--am-text); }
.auth-modal__close:focus-visible,
.auth-modal__submit:focus-visible,
.auth-modal__social a:focus-visible,
.auth-modal__social button:focus-visible,
.auth-modal__link:focus-visible,
.auth-modal__switch a:focus-visible,
.auth-modal__eye:focus-visible {
  outline: 2px solid var(--am-accent);
  outline-offset: 2px;
}

.auth-modal__field { margin-bottom: 14px; }
.auth-modal__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--am-text-dim);
}
.auth-modal__input {
  width: 100%;
  padding: 13px 14px;
  background: var(--am-surface);
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius-sm);
  color: var(--am-text);
  font-size: 16px; /* iOS: 16px 미만이면 입력 시 화면이 확대됨 */
  font-family: inherit;
}
.auth-modal__input::placeholder { color: var(--am-text-faint); }
.auth-modal__input:focus { outline: none; border-color: var(--am-accent); }
.auth-modal__input[aria-invalid="true"] { border-color: var(--am-danger); }

.auth-modal__pw { position: relative; }
.auth-modal__pw .auth-modal__input { padding-right: 50px; }
.auth-modal__eye {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--am-radius-sm);
  color: var(--am-text-dim);
  cursor: pointer;
  padding: 0;
}
.auth-modal__eye:hover { color: var(--am-text); }
.auth-modal__eye svg { width: 20px; height: 20px; }
.auth-modal__eye .off { display: none; }
.auth-modal__eye[aria-pressed="true"] .on { display: none; }
.auth-modal__eye[aria-pressed="true"] .off { display: block; }

/* 안내·오류: 색만으로 구분하지 않고 아이콘+문장 */
.auth-modal__message {
  display: none;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--am-danger);
  border-radius: var(--am-radius-sm);
  color: #ffb3b5;
  font-size: 13px;
  line-height: 1.5;
}
.auth-modal__message.is-visible { display: flex; }
.auth-modal__message.is-info { border-color: var(--am-border); color: var(--am-text-dim); }
.auth-modal__message svg { flex: none; width: 16px; height: 16px; margin-top: 2px; }

.auth-modal__submit {
  width: 100%;
  padding: 15px;
  background: var(--am-accent);
  color: var(--am-on-accent);
  border: none;
  border-radius: var(--am-radius-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.auth-modal__submit:hover { background: var(--am-accent-strong); }
.auth-modal__submit:disabled { opacity: 0.55; cursor: progress; }

.auth-modal__links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 14px 0 22px;
  font-size: 13px;
  color: var(--am-text-faint);
}
.auth-modal__link { color: var(--am-text-dim); text-decoration: none; padding: 4px 2px; }
.auth-modal__link:hover { color: var(--am-text); }

.auth-modal__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--am-text-faint);
}
.auth-modal__divider::before,
.auth-modal__divider::after { content: ""; flex: 1; height: 1px; background: var(--am-border); }

.auth-modal__social {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.auth-modal__social a,
.auth-modal__social button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0;
  border-radius: var(--am-radius-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}
.auth-modal__social .google { background: #ffffff; color: #1f1f1f; border-color: #dadce0; }
.auth-modal__social .google img { width: 18px; height: 18px; }
.auth-modal__social .kakao { background: #FEE500; color: #191600; }
.auth-modal__social .naver { background: #03C75A; color: #ffffff; }

.auth-modal__switch {
  margin: 22px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--am-text-dim);
}
.auth-modal__switch a {
  padding: 4px;
  color: var(--am-accent);
  font-weight: 700;
  text-decoration: none;
}

.auth-modal__legal {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--am-text-dim);
}
.auth-modal__legal a { color: inherit; text-decoration: underline; }

body.auth-modal-open { overflow: hidden; }

@keyframes amFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes amSlideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes amScaleIn { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }



/* 로그인 유지 체크박스 */
.auth-modal__remember { display: flex; align-items: center; gap: 6px; margin: 2px 0 12px; font-size: 13px; color: var(--am-text, #333); cursor: pointer; }
.auth-modal__remember input { width: 16px; height: 16px; margin: 0; }
.auth-modal__remember-hint { color: var(--am-muted, #888); font-size: 12px; }

/* 2026-09-30: 모바일도 화면 가운데 작은 카드로 + 톡 튀어나오는 등장 애니메이션 */
.auth-modal { align-items: center; padding: 16px; }
.auth-modal__panel {
  width: min(340px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--am-border);
  border-radius: 14px;
  padding: 18px 18px 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: amPopIn 0.28s cubic-bezier(.2, .9, .3, 1.2);
}
@media (min-width: 640px) {
  .auth-modal__panel { width: 360px; padding: 20px 20px 22px; animation: amPopIn 0.28s cubic-bezier(.2, .9, .3, 1.2); }
}
.auth-modal__head { margin-bottom: 14px; }
.auth-modal__title { font-size: 17px; }
.auth-modal__input { padding: 11px 12px; }
.auth-modal__submit { padding: 12px; }
@keyframes amPopIn { 0% { transform: translateY(12px) scale(0.92); opacity: 0; } 100% { transform: none; opacity: 1; } }
/* 등장 애니메이션은 동작 줄이기 설정과 관계없이 항상 (사용자 지시, 모바일 기준) */
