/* =========================================================
   EVRIZ Auth – 공통 스타일 (login / signup)
   tokens.json 기반 CSS 변수
   ========================================================= */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;500;600;700&family=Noto+Sans+KR:wght@400;500;700&display=swap');

/* ---------- Design Tokens (from tokens.json) ---------- */
:root {
  /* brand */
  --color-accent: #a78bfa;
  --color-accent-strong: #8b5cf6;
  --color-accent-hover: #9670f7;
  --color-page: #181b2b;

  /* neutral */
  --color-bg: #050505;
  --color-surface-1: #0f0f12;
  --color-surface-2: #15151c;
  --color-surface-3: #1b1b22;
  --color-rim: #27272a;
  --color-text: #ffffff;
  --color-text-muted: #a1a1aa;

  /* slate scale */
  --color-slate-50: #fafafa;
  --color-slate-100: #f4f4f5;
  --color-slate-200: #e4e4e7;
  --color-slate-300: #d4d4d8;
  --color-slate-400: #a1a1aa;
  --color-slate-500: #71717a;
  --color-slate-600: #52525b;
  --color-slate-700: #3f3f46;
  --color-slate-800: #27272a;
  --color-slate-900: #18181b;
  --color-slate-950: #09090b;

  /* radius */
  --radius-1: 6px;
  --radius-2: 10px;
  --radius-3: 14px;

  /* shadow */
  --shadow-rim-top: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --shadow-rim-edge: 0 0 0 1px var(--color-rim);
  --shadow-hard: 0 12px 30px rgba(0, 0, 0, 0.7);
  --shadow-inset: inset 0 2px 6px rgba(0, 0, 0, 0.7);

  /* typography */
  --font-display: 'Work Sans', 'Noto Sans KR', sans-serif;
  --font-body: 'Work Sans', 'Noto Sans KR', sans-serif;

  /* spacing scale (보충) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;

  /* semantic */
  --color-error: #f87171;
  --color-error-bg: rgba(248, 113, 113, 0.08);
  --color-success: #34d399;
  --color-success-bg: rgba(52, 211, 153, 0.08);
  --color-info: #60a5fa;
  --color-info-bg: rgba(96, 165, 250, 0.08);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-page);
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-page);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--space-4) + env(safe-area-inset-top))
    calc(var(--space-4) + env(safe-area-inset-right))
    calc(var(--space-4) + env(safe-area-inset-bottom))
    calc(var(--space-4) + env(safe-area-inset-left));
  line-height: 1.5;
}

/* ---------- Animations ---------- */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Auth Container ---------- */
.auth-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  animation: fade-in-up 0.9s ease-out forwards;
}

/* ---------- Logo ---------- */
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-5);
}

.auth-logo img {
  height: 32px;
  width: auto;
  object-fit: contain;
}

/* ---------- Card ---------- */
.auth-card {
  background: var(--color-surface-1);
  border: 1px solid var(--color-rim);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-hard), var(--shadow-rim-top);
  padding: var(--space-8) var(--space-7);
  animation: fade-in 0.6s ease-out forwards;
}

.auth-card-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-card-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.auth-card-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.auth-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.auth-copy p {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.auth-card-main {
  display: flex;
  flex-direction: column;
}

.auth-card-bottom {
  margin-top: var(--space-6);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ---------- Form ---------- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ---------- Field Group ---------- */
.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.field-wrapper input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-rim);
  border-radius: var(--radius-2);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-wrapper input::placeholder {
  color: var(--color-slate-600);
}

.field-wrapper input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

/* password 토글 있는 input 오른쪽 패딩 */
.field-wrapper input[type="password"],
.field-wrapper input.has-toggle {
  padding-right: var(--space-10);
}

/* 에러 상태 */
.field-group.has-error .field-wrapper input {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1);
}

.field-error {
  font-size: 0.75rem;
  color: var(--color-error);
  min-height: 1rem;
  display: none;
}

.field-group.has-error .field-error {
  display: block;
}

/* ---------- Password Toggle ---------- */
.btn-toggle-pw {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-1);
  transition: color 0.15s ease;
}

.btn-toggle-pw:hover {
  color: var(--color-text);
}

.btn-toggle-pw:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-toggle-pw svg {
  width: 18px;
  height: 18px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius-2);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* primary */
.btn-primary {
  width: 100%;
  padding: var(--space-3) var(--space-6);
  min-height: 44px;
  color: #fff;
  background: linear-gradient(135deg, var(--color-accent-strong), var(--color-accent));
  box-shadow: var(--shadow-rim-top);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-strong));
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-inset);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* secondary / outline */
.btn-secondary {
  width: 100%;
  padding: var(--space-3) var(--space-6);
  min-height: 44px;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-rim);
}

.btn-secondary:hover {
  background: var(--color-surface-3);
  border-color: var(--color-slate-600);
}

/* text / ghost */
.btn-ghost {
  padding: var(--space-2) var(--space-3);
  color: var(--color-accent);
  background: transparent;
}

.btn-ghost:hover {
  color: var(--color-accent-strong);
  background: rgba(167, 139, 250, 0.06);
}

/* ---------- Alert / Toast ---------- */
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-2);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: var(--space-5);
  animation: fade-in 0.4s ease-out forwards;
}

.auth-alert[hidden] {
  display: none;
}

.auth-alert-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.auth-alert-icon svg {
  width: 16px;
  height: 16px;
}

.auth-alert--error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(248, 113, 113, 0.15);
}

.auth-alert--success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(52, 211, 153, 0.15);
}

.auth-alert--info {
  background: var(--color-info-bg);
  color: var(--color-info);
  border: 1px solid rgba(96, 165, 250, 0.15);
}

/* ---------- Divider ---------- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  margin: var(--space-2) 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-rim);
}

/* ---------- Footer links ---------- */
.auth-footer {
  text-align: center;
  margin-top: var(--space-4);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.auth-footer a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.auth-footer a:hover {
  color: var(--color-accent-strong);
  text-decoration: underline;
}

.auth-footer a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-1);
}

.auth-legal {
  margin-top: var(--space-4);
  display: flex;
  justify-content: center;
}

.auth-legal-link {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.15s ease;
}

.auth-legal-link:hover {
  color: var(--color-accent);
}

.auth-legal-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- Stepper (signup) ---------- */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.stepper-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-slate-700);
  transition: all 0.3s ease;
}

.stepper-dot.active {
  background: var(--color-accent);
  width: 24px;
  border-radius: 4px;
}

.stepper-dot.done {
  background: var(--color-accent-strong);
}

.stepper-line {
  width: 24px;
  height: 2px;
  background: var(--color-slate-700);
  border-radius: 1px;
}

/* ---------- Step containers (signup) ---------- */
.step {
  display: none;
  animation: fade-in-up 0.5s ease-out forwards;
}

.step.active {
  display: block;
}

/* ---------- OTP input ---------- */
.otp-group {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
}

.otp-group input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-rim);
  border-radius: var(--radius-2);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  caret-color: var(--color-accent);
}

.otp-group input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.otp-group input.filled {
  border-color: var(--color-accent-strong);
}

/* ---------- Timer ---------- */
.resend-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.resend-timer {
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
  font-weight: 500;
}

.btn-resend {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-accent);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-1);
  transition: all 0.15s ease;
}

.btn-resend:hover:not(:disabled) {
  color: var(--color-accent-strong);
  background: rgba(167, 139, 250, 0.06);
}

.btn-resend:disabled {
  color: var(--color-slate-600);
  cursor: not-allowed;
}

.btn-resend:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- Success state ---------- */
.success-icon {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-5);
}

.success-icon .circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.15), rgba(52, 211, 153, 0.05));
  border: 2px solid var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in-up 0.5s ease-out forwards;
}

.success-icon .circle svg {
  width: 28px;
  height: 28px;
  color: var(--color-success);
}

/* ---------- Misc / Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  html,
  body {
    background: var(--color-surface-1);
  }

  body {
    display: block;
    padding: 0;
  }

  .auth-container {
    max-width: none;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--color-surface-1);
  }

  .auth-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding:
      calc(var(--space-8) + env(safe-area-inset-top))
      calc(var(--space-5) + env(safe-area-inset-right))
      calc(var(--space-6) + env(safe-area-inset-bottom))
      calc(var(--space-5) + env(safe-area-inset-left));
  }

  .auth-card-main {
    flex: 1;
    justify-content: center;
    padding-block: var(--space-6);
  }

  .auth-card-header {
    margin-bottom: var(--space-5);
  }

  .auth-logo {
    margin-bottom: var(--space-4);
  }

  .auth-card-title {
    font-size: 1.25rem;
  }

  .auth-footer {
    margin-top: var(--space-4);
    padding-top: 0;
  }

  .auth-card-bottom {
    margin-top: 0;
    padding-top: var(--space-5);
  }

  .auth-legal-link {
    width: auto;
  }

  .otp-group input {
    width: 40px;
    height: 48px;
    font-size: 1.125rem;
  }
}

@media (min-width: 641px) and (max-width: 768px) {
  body {
    padding:
      calc(var(--space-5) + env(safe-area-inset-top))
      calc(var(--space-5) + env(safe-area-inset-right))
      calc(var(--space-5) + env(safe-area-inset-bottom))
      calc(var(--space-5) + env(safe-area-inset-left));
  }
}

/* ---------- Prefers reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
