/* ============================================================================
   Auth pages (login / signup / forgot-password).
   Sits between base.css (resets + topbar) and the footer partial, so we
   only style what's specific to the auth card itself.
   Design principles:
     - Single focal point (the card) with everything else recessed.
     - Hierarchy via type weight + color, not layout density.
     - 8/12/16 spacing scale matches the rest of the site.
     - Mobile-first; the card just becomes full-width below ~480px.
   ============================================================================ */

.page-auth {
  background: #f5f6f8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Main fills the space between topbar and footer. */
.auth-main {
  flex: 1 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 64px;
}

/* Card — single column, capped width, gentle elevation. */
.auth-card {
  background: #fff;
  width: 100%;
  max-width: 400px;
  padding: 36px 32px 28px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 12px 32px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Brand wordmark — link to home, modest weight so it doesn't compete
   with the heading. */
.auth-brand {
  display: block;
  text-align: center;
  color: #0f172a;
  text-decoration: none;
  margin-bottom: 4px;
}
.auth-brand-mark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Section heading — small, neutral. The card itself is the affordance. */
.auth-heading {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  text-align: center;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}

/* Inline error banner — only visible when JS adds .is-visible. */
.auth-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.auth-error[hidden] { display: none; }

/* Form layout. */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0 0;
}

/* ── Honeypot field — visually hidden, dimensionless. Real users never
      see it; bots that auto-fill all inputs leak themselves. ───────────── */
.auth-honeypot {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Field wrapper (label + control). */
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  letter-spacing: 0.005em;
}

/* Inline field feedback — used by auth-signup.js to surface
   email-check results below the email input. Three visual states
   driven by data-status="ok|warn|error":
     ok    — green (available)
     warn  — yellow (format / typo)
     error — red   (registered / disposable / no-mx)
   Stays inside the .auth-field column so margins don't shift the
   surrounding form layout. */
.auth-field-feedback {
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
  letter-spacing: 0.005em;
}
.auth-field-feedback[data-status="ok"]    { color: #166534; }
.auth-field-feedback[data-status="warn"]  { color: #b45309; }
.auth-field-feedback[data-status="error"] { color: #b91c1c; }

/* Inputs — tall enough for mobile tap, neutral border, deep focus ring. */
.auth-input {
  width: 100%;
  height: 44px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.3;
  color: #0f172a;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  transition: border-color .15s, background .15s, box-shadow .15s;
  box-sizing: border-box;
}
.auth-input::placeholder { color: #9ca3af; }
.auth-input:hover { background: #fff; border-color: #9ca3af; }
.auth-input:focus {
  outline: none;
  background: #fff;
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.18);
}
.auth-input[type="file"] {
  height: auto;
  min-height: 44px;
  padding: 9px 12px;
}
/* Browser-native autofill leaves a pale yellow tint by default; override. */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #0f172a;
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* Password show/hide toggle. */
.auth-password-wrap { position: relative; }
.auth-password-wrap .auth-input { padding-right: 44px; }
.auth-password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #6b7280;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.auth-password-toggle:hover { color: #1d4ed8; background: #eef2ff; }
.auth-password-toggle:active { transform: translateY(-50%) scale(0.94); }
.auth-password-toggle[data-revealed="1"] { color: #1d4ed8; }

/* Turnstile widget container — Cloudflare renders its own iframe inside,
   we just give it spacing room. */
.auth-turnstile {
  margin: 4px 0 0;
  min-height: 65px;
  display: flex;
  justify-content: center;
}

/* Buttons — primary (filled), secondary (outlined). 44px tap target. */
.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .1s;
  position: relative;
}
.auth-btn:active { transform: translateY(1px); }
.auth-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.32);
}

.auth-btn-primary {
  background: #1d4ed8;
  color: #fff;
  margin-top: 4px;
}
.auth-btn-primary:hover { background: #1e40af; }
.auth-btn-primary[disabled] {
  background: #93c5fd;
  cursor: not-allowed;
}

.auth-btn-secondary {
  background: #fff;
  color: #1d4ed8;
  border-color: #1d4ed8;
}
.auth-btn-secondary:hover {
  background: #eef2ff;
}

/* Submit-in-progress spinner — visible only when .is-loading is on. */
.auth-btn-spinner {
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
  display: none;
}
.auth-btn.is-loading .auth-btn-spinner { display: inline-block; }
.auth-btn.is-loading .auth-btn-label { opacity: 0.85; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* "Stay signed in for 14 days" — opt-in checkbox sitting under the
   primary submit. Two lines (label + hint) stack vertically next to
   the checkbox so they don't end up side-by-side as flex siblings. */
.auth-remember {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.auth-remember:hover { background: #f9fafb; }
.auth-remember input[type="checkbox"] {
  accent-color: #1d4ed8;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
}
.auth-remember-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.auth-remember-text,
.auth-remember-hint {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  line-height: 1.4;
}
.auth-remember-hint {
  font-size: 11.5px;
  color: #6b7280;
}
.auth-remember:has(input:checked) .auth-remember-text { color: #1e40af; font-weight: 600; }

/* "Forgot your password?" — quiet text link below the secondary button. */
.auth-forgot {
  font-size: 12px;
  color: #6b7280;
  text-align: center;
  text-decoration: none;
  margin-top: 2px;
}
.auth-forgot:hover { color: #1d4ed8; text-decoration: underline; }

/* Divider with centered "or" text. */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
  color: #9ca3af;
  font-size: 12px;
  text-transform: lowercase;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #e5e7eb;
}

/* SNS button row — four 48×48 round buttons, centered, brand colors. */
.auth-sns-group {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 2px;
}
.auth-sns-btn {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  text-decoration: none;
  transition: transform .12s, box-shadow .15s, opacity .15s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.06);
}
.auth-sns-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15, 23, 42, 0.10); }
.auth-sns-btn:active { transform: translateY(0); }

/* Brand backgrounds — neutral or brand color depending on the provider's
   guidelines. White cards keep multicolor brands legible. */
.auth-sns-google { background: #fff; }
.auth-sns-kakao { background: #FEE500; }
.auth-sns-line { background: #06C755; }
.auth-sns-facebook { background: #1877F2; }

/* ── Mobile — card stretches edge-to-edge with a softer shadow. ─────────── */
@media (max-width: 480px) {
  .auth-main { padding: 24px 12px 48px; }
  .auth-card {
    padding: 28px 20px 24px;
    border-radius: 14px;
    box-shadow:
      0 1px 2px rgba(15, 23, 42, 0.03),
      0 6px 16px rgba(15, 23, 42, 0.05);
  }
  .auth-brand-mark { font-size: 20px; }
  .auth-heading { font-size: 17px; }
}

/* Reduced motion — disable spinner rotation + transform animations. */
@media (prefers-reduced-motion: reduce) {
  .auth-btn-spinner { animation: none; }
  .auth-btn,
  .auth-sns-btn { transition: none; }
  .auth-btn:active,
  .auth-sns-btn:hover,
  .auth-sns-btn:active { transform: none; }
}

/* ============================================================================
   SIGNUP-PAGE EXTENSIONS
   The login styles above cover most of what the signup form needs.
   Below we only add: wider card, dense form rows, checkboxes/radios,
   subheading, success banner, consent row, and the privacy modal.
   ============================================================================ */

/* Wider card variant so the 2-col rows breathe. Login keeps 400px;
   signup uses 520px. */
.auth-card--wide { max-width: 520px; }

/* Subheading directly under the H1. */
.auth-subheading {
  font-size: 13px;
  color: #6b7280;
  text-align: center;
  margin: -8px 0 8px;
  line-height: 1.4;
}

/* Inline "required" marker — small red asterisk after the field label. */
.auth-required {
  color: #dc2626;
  margin-left: 4px;
  font-weight: 700;
}

/* Inline hint under a field (e.g. password rules). */
.auth-hint {
  font-size: 11.5px;
  color: #6b7280;
  margin-top: 2px;
  line-height: 1.35;
}
.auth-hint--inline { margin-left: 6px; }

/* Success banner (sibling of .auth-error). */
.auth-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.auth-success[hidden] { display: none; }

/* Form layout — signup is denser than login. */
.auth-form--signup {
  gap: 14px;
}

/* 2-column row that collapses to 1-col on mobile. */
.auth-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 480px) {
  .auth-row--2col {
    grid-template-columns: 1fr 1fr;
  }
}

/* Native <select> styling — match auth-input so they line up visually. */
.auth-select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #6b7280 50%),
    linear-gradient(135deg, #6b7280 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}

/* Fieldsets (account type, services-of-interest). */
.auth-fieldset {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-fieldset-legend {
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  padding: 0;
  margin-bottom: 2px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

/* Radio group (Account type: Personal / Advertiser). */
.auth-radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.auth-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #f9fafb;
  cursor: pointer;
  font-size: 13.5px;
  color: #1f2937;
  transition: background .15s, border-color .15s;
}
.auth-radio:hover { background: #fff; border-color: #9ca3af; }
.auth-radio input[type="radio"] {
  accent-color: #1d4ed8;
  width: 16px;
  height: 16px;
  margin: 0;
}
.auth-radio:has(input[type="radio"]:checked) {
  background: #eef2ff;
  border-color: #1d4ed8;
  color: #1e40af;
  font-weight: 600;
}

/* Services-of-interest checkbox grid — 2 cols mobile, 4 cols desktop. */
.auth-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (min-width: 480px) {
  .auth-checkbox-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  cursor: pointer;
  font-size: 12.5px;
  color: #374151;
  line-height: 1.3;
  transition: background .15s, border-color .15s;
}
.auth-checkbox:hover { background: #fff; border-color: #9ca3af; }
.auth-checkbox input[type="checkbox"] {
  accent-color: #1d4ed8;
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}
.auth-checkbox:has(input[type="checkbox"]:checked) {
  background: #eef2ff;
  border-color: #1d4ed8;
  color: #1e40af;
}

/* Privacy-consent row — full width, slightly emphasized. */
.auth-consent {
  margin-top: 4px;
  padding: 10px 12px;
  background: #fafafa;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
}
.auth-consent-checkbox {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
}
.auth-consent-checkbox:hover { background: transparent; border: none; }

/* Inline button styled as a text link (used to open the privacy modal). */
.auth-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #1d4ed8;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-link-btn:hover { color: #1e40af; }

/* ============================================================================
   PRIVACY POLICY MODAL
   - Full-viewport overlay (backdrop + centered panel)
   - Panel max-width 720px, max-height 80vh, internal scroll
   - <pre> body preserves the .txt file's whitespace + line breaks
   - Focus is trapped inside while open (JS handles)
   ============================================================================ */
.auth-modal[hidden] { display: none; }
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.auth-modal-panel {
  position: relative;
  background: #fff;
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  border-radius: 16px;
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e5e7eb;
}
.auth-modal-title {
  font-size: 17px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}
.auth-modal-close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  line-height: 1;
}
.auth-modal-close:hover { background: #f3f4f6; color: #111827; }
.auth-modal-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 20px 24px;
  background: #fafafa;
}
.auth-policy-text {
  /* Render the .txt content as-is (preserve whitespace + line breaks).
     Wrap long lines so narrow viewports don't trigger horizontal scroll. */
  white-space: pre-wrap;
  word-break: break-word;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.65;
  color: #1f2937;
  margin: 0;
}
.auth-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
.auth-modal-agree {
  width: auto !important;
  min-width: 160px;
  height: 42px !important;
}

/* Mobile — modal goes full-bleed at narrow widths. */
@media (max-width: 480px) {
  .auth-modal { padding: 0; }
  .auth-modal-panel {
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .auth-modal-header { padding: 14px 18px; }
  .auth-modal-body { padding: 14px 18px; }
  .auth-modal-footer { padding: 12px 18px; }
}

/* Body lock when modal is open (JS toggles .modal-open on <body>). */
body.modal-open { overflow: hidden; }
