/* Shared auth modals — login + checkout (LAZI: quiet, sleek, minimal) */

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

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--color-overlay);
  backdrop-filter: blur(12px) saturate(0.9);
  -webkit-backdrop-filter: blur(12px) saturate(0.9);
}

.auth-modal.is-open {
  display: flex;
  animation: auth-fade-in 0.28s var(--ease-out, ease);
}

.auth-modal[hidden] {
  display: none !important;
}

/* #login hash fallback for gated redirects */
.auth-modal#login:target {
  display: flex;
}

.auth-modal__panel {
  width: 100%;
  max-width: 22.5rem;
  background: var(--color-bg, var(--grey-50));
  color: var(--color-text, var(--ink-900));
  border: 1px solid var(--color-border, var(--grey-300));
  border-radius: var(--radius);
  box-shadow:
    var(--shadow-sm),
    var(--shadow-lg);
  overflow: hidden;
  animation: auth-panel-in 0.32s var(--ease-out, ease);
}

.auth-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.5rem 0.35rem;
  border-bottom: 0;
  min-height: 0;
}

.auth-modal__header h2 {
  margin: 0;
  font-family: var(--font-body, "Nunito", sans-serif);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: var(--tracking-display, -0.03em);
  line-height: 1.15;
  color: var(--color-text, var(--ink-900));
}

.auth-modal__close {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--color-bg-soft, var(--grey-100));
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
  color: var(--color-muted, var(--color-muted));
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.auth-modal__close:hover {
  background: var(--color-bg-muted, var(--grey-200));
  color: var(--color-text, var(--ink-900));
}

.auth-modal__body {
  padding: 1.1rem 1.5rem 1.5rem;
}

.auth-modal__footer {
  padding: 0 1.5rem 1.4rem;
  text-align: center;
  color: var(--color-muted, var(--color-muted));
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.auth-modal__footer p {
  margin: 0;
}

.auth-field {
  margin-bottom: 1.1rem;
}

.auth-field label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted, var(--color-muted));
}

.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="text"] {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--color-border, var(--grey-300));
  border-radius: var(--radius-sm);
  background: var(--color-bg-soft, var(--grey-100));
  color: var(--color-text, var(--ink-900));
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.auth-field input::placeholder {
  color: var(--color-muted-2, var(--color-muted-2));
}

.auth-field input:hover {
  border-color: var(--grey-300);
}

.auth-field input:focus {
  outline: none;
  background: var(--color-bg, var(--grey-50));
  border-color: var(--color-accent, var(--color-accent));
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.auth-lead {
  margin: 0 0 1.1rem;
  font-weight: 500;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-muted, var(--color-muted));
}

.auth-muted {
  margin: 0 0 1rem;
  color: var(--color-muted, var(--color-muted));
  font-size: 0.85rem;
  word-break: break-all;
}

.auth-back {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 0;
  padding: 0;
  margin: 0 0 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--color-muted, var(--color-muted));
  cursor: pointer;
  transition: color 0.2s ease;
}

.auth-back:hover {
  color: var(--color-text, var(--ink-900));
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.35rem;
}

.auth-actions .button {
  margin: 0;
}

.auth-text-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  color: var(--color-muted, var(--color-muted));
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.auth-text-btn:hover {
  color: var(--color-text, var(--ink-900));
  text-decoration: underline;
}

.auth-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.35rem 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted-2, var(--color-muted-2));
}

.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border, var(--grey-300));
}

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-muted, var(--color-muted));
  line-height: 1.4;
}

.auth-check input {
  margin-top: 0.2rem;
  width: auto;
  accent-color: var(--color-text, var(--ink-900));
}

.auth-alert {
  padding: 0.75rem 0.9rem;
  margin: 0.75rem 0 0;
  border: 1px solid var(--color-border, var(--grey-300));
  border-radius: var(--radius-sm);
  background: var(--color-bg-soft, var(--grey-100));
  color: var(--color-text, var(--ink-900));
  font-size: 0.85rem;
  line-height: 1.4;
}

.auth-alert--error {
  border-color: var(--color-border-strong);
}

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

.auth-btn {
  position: relative;
  width: 100%;
  margin-top: 0.15rem;
  border-radius: var(--radius-sm) !important;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 0.78rem !important;
  padding: 0.85rem 1.1rem !important;
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.button.primary.auth-btn {
  background: var(--color-accent, var(--color-accent)) !important;
  color: var(--color-accent-text, var(--ink-900)) !important;
  border-color: var(--color-accent, var(--color-accent)) !important;
}

.button.primary.auth-btn:hover {
  background: var(--color-accent-hover, var(--color-accent-hover)) !important;
  color: var(--color-accent-text, var(--ink-900)) !important;
  border-color: var(--color-accent-hover, var(--color-accent-hover)) !important;
}

.auth-actions .auth-btn {
  width: auto;
  min-width: 7.5rem;
}

.button-link.auth-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 0.25rem;
  padding: 0.65rem 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--color-text, var(--ink-900)) !important;
  font-size: 0.82rem !important;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.button-link.auth-btn:hover {
  opacity: 0.7;
}

.auth-btn--ghost {
  background: transparent !important;
  color: var(--color-text, var(--ink-900)) !important;
  border: 1px solid var(--color-border-strong, var(--ink-900)) !important;
}

.auth-btn--ghost:hover {
  background: var(--color-text, var(--ink-900)) !important;
  color: var(--color-bg, var(--grey-50)) !important;
}

.auth-btn .loader {
  display: none;
  width: 18px;
  height: 18px;
  aspect-ratio: 1;
  --_c: no-repeat radial-gradient(farthest-side, var(--ink-900) 92%, #0000);
  background:
    var(--_c) top,
    var(--_c) left,
    var(--_c) right,
    var(--_c) bottom;
  background-size: 7px 7px;
  margin: 0 auto;
}

.button.primary.auth-btn .loader {
  --_c: no-repeat radial-gradient(farthest-side, var(--color-accent-text, var(--ink-900)) 92%, #0000);
}

.auth-btn.loading {
  pointer-events: none;
}

.auth-btn.loading .button-text {
  opacity: 0;
}

.auth-btn.loading .loader {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  animation: auth-spin 1s infinite;
}

@keyframes auth-spin {
  to {
    transform: translate(-50%, -50%) rotate(0.5turn);
  }
}

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

@keyframes auth-panel-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-modal.is-open,
  .auth-modal__panel {
    animation: none;
  }
}
