/* ===========================================================================
   Magic-link auth modal — canonical styles.

   Loaded by every page that includes partials/auth-modal.ejs (via page-head).
   Variables (--ink, --coral, --gold, --hair, --display, --body, etc.) come
   from theme.css, which page-head loads first.

   Visibility contract:
     • Hidden by default (display:none) so raw HTML never leaks onto the page.
     • auth-modal.js toggles `.flex-display` on the overlay to show.
     • Inner `.auth-step.hidden` swaps the email step ↔ code step.
   =========================================================================== */

.auth-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43, 34, 71, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-modal-overlay.flex-display {
  display: flex;
}

/* ---------- Card ---------- */

.auth-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 10px 0 var(--ink), 0 30px 60px rgba(43, 34, 71, 0.35);
  padding: 3.25rem 1.75rem 2.25rem;     /* extra top padding for the medallion */
  font-family: var(--body);
  overflow: visible;
  animation: authModalRise 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@media (min-width: 640px) {
  .auth-modal { padding: 3.5rem 2.25rem 2.5rem; }
}

@keyframes authModalRise {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Floating gold medallion above the card */
.auth-modal::before {
  content: "";
  position: absolute;
  top: -36px;
  left: 50%;
  width: 72px;
  height: 72px;
  background: var(--gold);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 5px 0 var(--ink), 0 0 0 8px rgba(255, 245, 230, 0.6);
  transform: translateX(-50%);
  z-index: 2;
}

/* CSS-only five-point star inside the medallion */
.auth-modal::after {
  content: "";
  position: absolute;
  top: -22px;
  left: 50%;
  width: 36px;
  height: 36px;
  background: #fff;
  transform: translateX(-50%);
  z-index: 3;
  clip-path: polygon(
    50%  0%, 61% 35%, 98% 35%, 68% 57%,
    79% 91%, 50% 70%, 21% 91%, 32% 57%,
     2% 35%, 39% 35%
  );
  filter: drop-shadow(0 1px 0 rgba(194, 135, 26, 0.4));
}

/* ---------- Close button ---------- */

.auth-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  border: 2px solid var(--hair-strong);
  border-radius: 50%;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.auth-modal-close:hover {
  background: #fff;
  border-color: var(--ink);
  color: var(--ink);
}

/* ---------- Steps ---------- */

.auth-step { display: block; }
.auth-step.hidden { display: none; }

/* Legacy celebration emoji — suppressed in favor of the medallion */
.auth-celebration { display: none; }

/* ---------- Typography ---------- */

.auth-modal h2 {
  margin: 0 0 0.4rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-align: center;
}

.auth-subtitle {
  margin: 0 0 1.5rem;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Form ---------- */

.auth-form-group { margin-bottom: 1.1rem; }

.auth-form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.auth-form-group input {
  width: 100%;
  padding: 0.75rem 0.95rem;
  font-family: var(--body);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--hair-strong);
  border-radius: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  box-sizing: border-box;
}

.auth-form-group input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 124, 90, 0.18);
}

.auth-code-input {
  font-family: var(--display) !important;
  font-weight: 800 !important;
  font-size: 1.6rem !important;
  letter-spacing: 0.4em;
  text-align: center;
  text-indent: 0.4em;
}

/* ---------- CTA ---------- */

.auth-button {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.auth-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 0 var(--ink);
}

.auth-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.auth-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.auth-hint {
  margin: 0.85rem 0 0;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-mute);
  text-align: center;
}

/* ---------- Back link ---------- */

.auth-back-link {
  margin-top: 1rem;
  text-align: center;
}

.auth-back-link a {
  color: var(--coral-shade);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}

.auth-back-link a:hover {
  color: var(--coral);
  text-decoration: underline;
}

/* ---------- Feedback messages ---------- */

.auth-error,
.auth-success {
  display: none;
  margin: 0 0 0.85rem;
  padding: 0.6rem 0.8rem;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  border-radius: 12px;
}

.auth-error {
  background: rgba(232, 90, 90, 0.10);
  color: var(--danger-shade);
  border: 2px solid var(--danger);
}

.auth-success {
  background: rgba(78, 199, 127, 0.14);
  color: var(--done-shade);
  border: 2px solid var(--done);
}

.auth-error.show,
.auth-success.show { display: block; }

.auth-error:empty,
.auth-success:empty { display: none; }
