/* ============================================
   Supabase Auth Gate — Shared Styles
   Peptide Commons
   ============================================ */

/* --- Gate: Blur + Overlay --- */
.auth-gate-container {
  position: relative;
}

.auth-gate-blur {
  filter: blur(6px);
  max-height: 480px;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.auth-gate-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    180deg,
    rgba(248, 250, 252, 0) 0%,
    rgba(248, 250, 252, 0.6) 30%,
    rgba(248, 250, 252, 0.95) 55%,
    #F8FAFC 75%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 10;
}

.auth-gate-overlay.hidden {
  display: none;
}

/* --- Gate CTA Card --- */
.auth-gate-cta {
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 16px;
  padding: 2.5rem 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 8px 32px rgba(37, 99, 235, 0.06);
  position: relative;
  margin-top: 6rem;
}

.auth-gate-cta .gate-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.auth-gate-cta .gate-icon svg {
  color: #2563EB;
  width: 22px;
  height: 22px;
}

.auth-gate-cta h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0F172A;
  margin-bottom: 0.5rem;
}

.auth-gate-cta .gate-desc {
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.auth-gate-cta .gate-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.auth-gate-cta .gate-input {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-gate-cta .gate-input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-gate-cta .gate-input::placeholder {
  color: #94A3B8;
}

.auth-gate-cta .gate-btn {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 0.7rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: #2563EB;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.auth-gate-cta .gate-btn:hover {
  background: #1D4ED8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.auth-gate-cta .gate-btn:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}

.auth-gate-cta .gate-btn:active {
  transform: scale(0.98);
}

.auth-gate-cta .gate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-gate-cta .gate-note {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: #94A3B8;
  letter-spacing: 0.02em;
}

.auth-gate-cta .gate-password {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  outline: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-gate-cta .gate-password:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-gate-cta .gate-password::placeholder {
  color: #94A3B8;
}

.auth-gate-cta .gate-status {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 0.5rem;
  min-height: 1.5em;
}

.auth-gate-cta .gate-status.success {
  color: #16A34A;
}

.auth-gate-cta .gate-status.error {
  color: #DC2626;
}

/* --- Auth Modal --- */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.auth-modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.auth-modal {
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 16px 48px rgba(0, 0, 0, 0.1);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-modal-backdrop.open .auth-modal {
  transform: translateY(0) scale(1);
}

.auth-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #94A3B8;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-modal-close:hover {
  background: #F1F5F9;
  color: #475569;
}

.auth-modal-close svg {
  width: 18px;
  height: 18px;
}

.auth-modal h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0F172A;
  margin-bottom: 0.4rem;
}

.auth-modal .modal-desc {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.auth-modal .modal-input {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  outline: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-modal .modal-input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-modal .modal-input::placeholder {
  color: #94A3B8;
}

.auth-modal .modal-password {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  outline: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-modal .modal-password:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-modal .modal-password::placeholder {
  color: #94A3B8;
}

.auth-modal .modal-btn {
  width: 100%;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: #2563EB;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.auth-modal .modal-btn:hover {
  background: #1D4ED8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.auth-modal .modal-btn:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}

.auth-modal .modal-btn:active {
  transform: scale(0.98);
}

.auth-modal .modal-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-modal .modal-note {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: #94A3B8;
  letter-spacing: 0.02em;
  text-align: center;
  margin-top: 0.75rem;
}

.auth-modal .modal-status {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
  margin-top: 0.5rem;
  min-height: 1.5em;
}

.auth-modal .modal-status.success {
  color: #16A34A;
}

.auth-modal .modal-status.error {
  color: #DC2626;
}

/* --- Nav Auth Elements --- */
.nav-auth-link {
  font-family: 'DM Mono', monospace !important;
  font-size: 0.7rem !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: #2563EB !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: color 0.2s ease !important;
  background: none;
  border: none;
  padding: 0;
}

.nav-auth-link:hover {
  color: #1D4ED8 !important;
}

.nav-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-user-email {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem;
  color: #94A3B8;
  letter-spacing: 0.02em;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-signout {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: #94A3B8;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color 0.2s ease;
}

.nav-signout:hover {
  color: #475569;
}

/* Mobile auth in mobile menu */
.mobile-auth-link {
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #2563EB;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.mobile-auth-link:hover {
  color: #1D4ED8;
}

.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-user-email {
  font-size: 0.75rem;
  color: #94A3B8;
}

.mobile-signout {
  font-size: 0.75rem;
  color: #94A3B8;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.mobile-signout:hover {
  color: #475569;
}

/* --- Password Toggle --- */
.auth-password-wrap {
  position: relative;
  margin-bottom: 0.5rem;
}

.auth-password-wrap input {
  width: 100%;
  padding-right: 3rem !important;
}

.auth-password-toggle {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #94A3B8;
  /* 44×44 px minimum touch target */
  min-width: 44px;
  min-height: 44px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  /* Ensure no overlay blocks taps */
  outline: none;
}

.auth-password-toggle:hover {
  color: #475569;
}

.auth-password-toggle svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.auth-password-toggle * {
  pointer-events: none;
}

/* --- Form Rows --- */
.auth-name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.auth-field {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-field:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-field::placeholder {
  color: #94A3B8;
}

.auth-select {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  outline: none;
  width: 100%;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-select:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-optional-fields {
  margin-bottom: 0.5rem;
}

.auth-optional-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.auth-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.auth-checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: #2563EB;
  flex-shrink: 0;
  cursor: pointer;
}

.auth-checkbox-row label {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.4;
  cursor: pointer;
}

.auth-checkbox-row label span {
  color: #94A3B8;
  font-size: 0.72rem;
}

.auth-expandable {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
  margin-bottom: 0;
}

.auth-expandable.open {
  max-height: 300px;
  opacity: 1;
  margin-bottom: 0.5rem;
}

/* --- Shared Auth UI --- */
.auth-toggle-link {
  color: #2563EB;
  text-decoration: none;
  font-weight: 500;
}

.auth-toggle-link:hover {
  text-decoration: underline;
}

.auth-mode-toggle {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: #64748B;
  margin-top: 0.75rem;
}

.auth-magic-link {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  color: #64748B;
  letter-spacing: 0.02em;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
}

.auth-magic-link:hover {
  color: #2563EB;
}

.auth-forgot {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: #64748B;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: right;
  display: block;
  margin-bottom: 0.75rem;
  transition: color 0.2s ease;
}

.auth-forgot:hover {
  color: #2563EB;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.auth-divider span {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem;
  color: #94A3B8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}

/* --- Recovery Modal --- */
.recovery-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.recovery-modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.recovery-modal {
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 16px 48px rgba(0, 0, 0, 0.1);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.recovery-modal-backdrop.open .recovery-modal {
  transform: translateY(0) scale(1);
}

.recovery-modal h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0F172A;
  margin-bottom: 0.4rem;
}

.recovery-modal p {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.recovery-modal .recovery-input {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: #F8FAFC;
  color: #0F172A;
  outline: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.recovery-modal .recovery-input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.recovery-modal .recovery-input::placeholder {
  color: #94A3B8;
}

.recovery-modal .recovery-btn {
  width: 100%;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: #2563EB;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.recovery-modal .recovery-btn:hover {
  background: #1D4ED8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.recovery-modal .recovery-btn:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}

.recovery-modal .recovery-btn:active {
  transform: scale(0.98);
}

.recovery-modal .recovery-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.recovery-modal .recovery-status {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  text-align: center;
  margin-top: 0.75rem;
  min-height: 1.5em;
}

.recovery-modal .recovery-status.success { color: #16A34A; }
.recovery-modal .recovery-status.error { color: #DC2626; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .auth-gate-cta {
    padding: 1.75rem 1.25rem 1.5rem;
    margin-top: 3rem;
  }

  .auth-gate-cta .gate-form {
    flex-direction: column;
  }

  .auth-gate-cta .gate-btn {
    width: 100%;
    padding: 0.75rem;
  }

  .auth-name-row,
  .auth-optional-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .auth-modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .auth-modal {
    padding: 1.75rem 1.25rem;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    overflow-y: auto;
  }

  .recovery-modal {
    padding: 1.75rem 1.25rem;
    margin: 0 0.5rem;
  }
}
