/* ============================================================
   Sillok — Auth flow shared styles (login/signup/forgot)
   ============================================================ */

html, body {
  margin: 0;
  background: var(--paper-0); /* fills iOS standalone safe-area, kills the black bar */
  overscroll-behavior: none;
}
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
@supports (min-height: 100dvh) { body { min-height: 100dvh; } }

/* Safe-area fillers — always paint paper-0 over iOS safe-area regions.
   z-index:1 keeps it above body bg but below sticky topbar (5) and toasts (100). */
body::before, body::after {
  content: '';
  position: fixed;
  left: 0; right: 0;
  background: var(--paper-0);
  pointer-events: none;
  z-index: 1;
}
body::before { top: 0; height: env(safe-area-inset-top); }
body::after  { bottom: 0; height: env(safe-area-inset-bottom); }

/* Top bar — minimal, brand only, matches marketing topbar height */
.auth-topbar {
  height: calc(56px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line-1);
  background: rgba(251, 250, 247, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding-left: max(32px, env(safe-area-inset-left));
  padding-right: max(32px, env(safe-area-inset-right));
  position: sticky; top: 0; z-index: 5;
}
.auth-topbar a { display: inline-flex; }
.auth-topbar > a, .auth-topbar > .auth-topbar-inner {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

/* Page surface — desktop 최적화: 너비 1000px 컨테이너 안에 카드 중앙 정렬 */
.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 48px) clamp(14px, 2.5vw, 24px) clamp(28px, 5vw, 64px);
}

/* Card — desktop 에서 약간 더 넓게 (480px), wide 변형은 600px */
.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--paper-card);
  border: 1px solid var(--line-1);
  border-radius: 8px;
  padding: clamp(22px, 3vw + 12px, 40px) clamp(16px, 2.4vw + 8px, 36px) clamp(20px, 2.4vw + 8px, 32px);
  box-shadow: var(--shadow-1);
  box-sizing: border-box;
}

.auth-card.wide { max-width: 600px; }

.auth-head {
  text-align: left;
  margin-bottom: 28px;
}
.auth-head .eyebrow { margin-bottom: 8px; }
.auth-head h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(20px, 4.2vw + 6px, 28px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--ink-0);
  overflow-wrap: anywhere;
}
.auth-head p {
  font-size: clamp(13px, 0.5vw + 11px, 14px);
  color: var(--ink-2);
  margin: 0;
  line-height: 1.55;
}

/* Field */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-1);
}
.field .label .req { color: var(--seal-500); margin-left: 2px; }
.field .hint {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
}
.field .err {
  font-size: 12px;
  color: var(--seal-600);
  display: none;
}
.field.is-error .err { display: block; }
.field.is-error .input { border-color: var(--seal-500); }

.input {
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--paper-card);
  color: var(--ink-0);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
  width: 100%;
  box-sizing: border-box;
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  border-color: var(--seal-500);
  box-shadow: 0 0 0 3px rgba(184, 57, 42, 0.15);
}
.input:disabled {
  background: var(--paper-1);
  color: var(--ink-2);
  cursor: not-allowed;
}
.input.mono { font-family: var(--font-mono); letter-spacing: 0.06em; }

/* Compound: input + side button */
.input-row {
  display: flex;
  gap: 8px;
}
.input-row .input { flex: 1; }
.input-row .btn { flex-shrink: 0; }

/* Two-column rows for desktop */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) {
  .row-2 { grid-template-columns: 1fr; }
}

/* Buttons (mirrors marketing) */
.btn {
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  transition: background 120ms cubic-bezier(.22,1,.36,1), color 120ms;
  text-decoration: none;
}
.btn.primary { background: var(--seal-500); color: var(--paper-0); }
.btn.primary:hover { background: var(--seal-600); }
.btn.primary:disabled { background: var(--ink-3); cursor: not-allowed; }
.btn.secondary { background: var(--paper-card); color: var(--ink-0); border-color: var(--line-2); }
.btn.secondary:hover { background: var(--paper-2); }
.btn.secondary:disabled { color: var(--ink-3); cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-1); }
.btn.ghost:hover { background: var(--paper-1); }
.btn.block { width: 100%; }
.btn.lg { padding: 12px 18px; font-size: 15px; }

/* Card footer (가입/비번찾기 등) */
.auth-foot {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.auth-foot a { color: var(--seal-600); text-decoration: none; font-weight: 500; }
.auth-foot a:hover { text-decoration: underline; }

/* Inline note (e.g., "인증코드 발송됨") */
.inline-note {
  background: var(--success-50);
  border-left: 3px solid var(--success-500);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink-1);
  border-radius: 0 4px 4px 0;
  margin-bottom: 16px;
}
.inline-note.warn {
  background: var(--warning-50);
  border-left-color: var(--warning-500);
}
.inline-note .mono { font-family: var(--font-mono); font-weight: 500; }

/* Terms list */
.terms {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 8px;
}
.terms .item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-1);
}
.terms .item:last-child { border-bottom: 0; }
.terms .item .check {
  margin-top: 2px;
  flex-shrink: 0;
}
.terms .item .body { flex: 1; }
.terms .item .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-0);
  display: flex;
  align-items: center;
  gap: 6px;
}
.terms .item .name .pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--seal-500);
  color: var(--paper-0);
  text-transform: uppercase;
}
.terms .item .desc {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
  line-height: 1.5;
}
.terms .item .view {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-1);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  align-self: center;
  text-decoration: none;
}
.terms .item .view:hover { background: var(--paper-1); color: var(--ink-0); }

/* Custom checkbox — square, document-feel */
.cbx {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--paper-card);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 120ms, border-color 120ms;
}
.cbx:checked {
  background: var(--seal-500);
  border-color: var(--seal-500);
}
.cbx:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--paper-0);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.cbx:focus-visible {
  outline: 2px solid var(--seal-500);
  outline-offset: 2px;
}

/* Step indicator */
.steps-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.steps-bar .seg {
  flex: 1;
  height: 3px;
  background: var(--line-1);
  border-radius: 2px;
}
.steps-bar .seg.active { background: var(--seal-500); }
.steps-bar .seg.done { background: var(--ink-2); }

.step-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Section divider within form */
.form-section {
  margin: 24px 0 8px;
  padding-top: 20px;
  border-top: 1px solid var(--line-1);
}
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section h2 {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-0);
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.form-section.locked { opacity: 0.5; pointer-events: none; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink-0);
  color: var(--paper-0);
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: var(--shadow-3);
  transition: transform 220ms cubic-bezier(.22,1,.36,1);
  z-index: 100;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* Mock disclaimer — present on every auth page so reviewers know nothing is real */
.mock-banner {
  background: var(--paper-1);
  border-bottom: 1px solid var(--line-1);
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  text-align: center;
}
.mock-banner strong { color: var(--seal-600); font-weight: 600; }

/* Mobile — sizes interpolate via clamp() at base; this block handles layout-only changes */
@media (max-width: 520px) {
  .auth-topbar {
    height: calc(52px + env(safe-area-inset-top));
    padding: 0 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .auth-page { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
  /* iOS no-zoom: input must be ≥ 16px */
  .input { font-size: 16px; padding: 11px 12px; }
  .btn { padding: 11px 16px; }
  .btn.lg { padding: 13px 18px; font-size: 15px; }
  .auth-foot {
    flex-direction: column; align-items: flex-start;
    gap: 6px; padding-top: 16px; margin-top: 16px;
  }
  .terms .item { padding: 12px 0; gap: 10px; }
  .terms .item .name { font-size: 13px; flex-wrap: wrap; }
  .terms .item .desc { font-size: 11px; }
  .mock-banner { font-size: 10px; padding: 6px 10px; letter-spacing: 0.04em; }
}

/* Width-overflow safety */
.auth-card, .auth-head, .auth-foot, .terms, .terms .item, .field, .input-row, .row-2 {
  min-width: 0; max-width: 100%; box-sizing: border-box;
}
.auth-head h1, .auth-head p, .terms .item .name, .terms .item .desc { overflow-wrap: anywhere; }

/* Extra-narrow viewports (folded phones, very small PWAs) */
@media (max-width: 360px) {
  .auth-card { padding: 18px 14px 16px; }
  .auth-foot { font-size: 12px; }
  .input-row { flex-direction: column; gap: 6px; }
  .input-row .btn { width: 100%; justify-content: center; }
  .terms .item .view { padding: 4px 6px; font-size: 11px; }
}

/* iOS — kill double-tap zoom on action targets */
.btn, .cbx, .terms .item .view, .input-row .btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* iOS — prevent automatic zoom on small inputs */
@supports (-webkit-touch-callout: none) {
  input, textarea, select { font-size: 16px; }
}
