/* Copyright (c) We Decide Canada
 * File: auth_modal.css
 * Purpose: Styles for login/register modals (theme-aware).
 * Requires: global_theme.css
 */

.auth_modal_overlay {
  position: fixed;
  left: 0;
  right: 0;

  /* Keep header + optional TTS bar visible (same pattern as menu overlay). */
  top: var(--site-header-offset);
  bottom: 0;

  z-index: 1300; /* above header (1200) and menu (1150) */
  display: none;

  /*
    Ensure the panel/backdrop never sits flush to viewport edges.
    We keep the overlay pinned to the viewport, and add padding so the
    panel always has equal spacing on left/right/bottom/top.
  */
  padding: 20px 16px;
  box-sizing: border-box;

  /*
    Critical mobile fix:
    - Make the overlay the scroll container so you can always reach the bottom
      of a tall modal (e.g., reCAPTCHA).
    - Keep iOS/Android scrolling smooth.
  */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  /*
    Improve scroll chaining behavior: keep scroll interactions inside the modal
    instead of "falling through" to the page behind it.
  */
  overscroll-behavior: contain;
}

.auth_modal_overlay.is-open {
  display: block;
}

.auth_modal_backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(0,0,0,0.65);
  cursor: pointer;
}

html[data-theme="light"] .auth_modal_backdrop {
  background: rgba(242, 242, 242, 0.92);
}

.auth_modal_panel {
  position: relative;

  /*
    Center horizontally, start at top (below the overlay padding).
    The overlay scrolls, so the user can reach content even when tall.
  */
  margin: 0 auto;

  /* Use full available width up to the max. */
  width: min(520px, 100%);

  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /*
    Ensure the panel never exceeds the visible overlay height.
    Overlay height is (100vh - header offset). We subtract vertical padding (40px).
  */
  max-height: calc(100vh - var(--site-header-offset) - 40px);
}

.auth_modal_header {
  display: flex;
  flex-direction: column;

  /* Slightly tighter header spacing */
  padding: 12px 14px;

  border-bottom: 1px solid var(--color-border);
}

.auth_modal_header_row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth_modal_title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-text);
}

.auth_modal_close {
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  width: 40px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;

  /* Center consistently */
  display: inline-flex;
  align-items: center;
  justify-content: center;

  /* Remove default button spacing that can shift inline content */
  padding: 0;
  line-height: 1;
}

.auth_modal_close_icon {
  /* Make the X a controlled shape instead of relying on font glyph metrics */
  position: relative;
  width: 18px;
  height: 18px;

  /* Nudge very slightly upward to look optically centered inside 36px height */
  transform: translateY(-0.5px);
}

.auth_modal_close_icon::before,
.auth_modal_close_icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;

  width: 18px;
  height: 2px;

  /* Slightly thinner and with rounded ends */
  background: var(--color-text);
  border-radius: 999px;

  transform-origin: center;
}

.auth_modal_close_icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.auth_modal_close_icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.auth_modal_close:hover,
.auth_modal_close:focus-visible {
  border-color: var(--color-primary);
  outline: none;
}

/* Optional: keep the X readable on hover/focus without changing thickness */
.auth_modal_close:hover .auth_modal_close_icon::before,
.auth_modal_close:hover .auth_modal_close_icon::after,
.auth_modal_close:focus-visible .auth_modal_close_icon::before,
.auth_modal_close:focus-visible .auth_modal_close_icon::after {
  background: var(--color-text);
}

.auth_modal_content {
  padding: 14px 14px 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}

.auth_modal_footer {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.auth_modal_footer_banners {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.auth_modal_footer_banners .auth_banner {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.auth_modal_footer_cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth_modal_footer_cols .auth_btn {
  width: 100%;
}

.auth_form {
  display: block;
}

.auth_label {
  display: block;
  color: var(--color-text);
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.auth_input {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  padding: 0 12px;
  font: inherit;
}

.auth_input:focus-visible {
  outline: none;
  border-color: var(--color-primary);
}

.auth_pw_row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.auth_pw_toggle {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.auth_pw_toggle:hover,
.auth_pw_toggle:focus-visible {
  border-color: var(--color-primary);
  outline: none;
}

.auth_btn {
  width: 100%;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}

.auth_btn:hover,
.auth_btn:focus-visible {
  border-color: var(--color-primary);
  outline: none;
}

/*
  Auth "primary" action buttons (Login / Create account):
  - Not bold.
  - Red text, matching the header "Sign in / up" button.
  - Neutral border by default; red only on hover/focus.
*/
.auth_btn--primary {
  border-color: var(--color-border);
  color: var(--color-primary);
  font-weight: 400;
}

.auth_btn--primary:hover,
.auth_btn--primary:focus-visible {
  border-color: var(--color-primary);
  outline: none;
}

.auth_banner {
  padding: 10px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--color-border);
}

.auth_banner--error {
  border-color: #b91c1c;
  color: #fecaca;
  background: rgba(185, 28, 28, 0.15);
}

html[data-theme="light"] .auth_banner--error {
  color: #7f1d1d;
}

.auth_banner--info {
  border-color: #2563eb;
  color: #bfdbfe;
  background: rgba(37, 99, 235, 0.15);
}

html[data-theme="light"] .auth_banner--info {
  color: #1e3a8a;
}

.auth_help {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.is-hidden { display: none !important; }

.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }

.auth_hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

.auth_recaptcha {
  position: relative;
  display: flex;
  justify-content: center;

  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  overflow: hidden;
}

html[data-theme="dark"] .auth_recaptcha {
  border-color: #2b2f36;
  background: #141821;
}

.auth_recaptcha::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  pointer-events: none;

  box-shadow:
    inset 0 0 0 8px var(--color-bg),
    inset -14px 0 0 0 var(--color-bg),
    inset 2px 0 0 0 var(--color-bg);
}

html[data-theme="dark"] .auth_recaptcha::before {
  box-shadow:
    inset 0 0 0 8px #141821,
    inset -14px 0 0 0 #141821,
    inset 2px 0 0 0 #141821;
}

.auth_recaptcha iframe {
  border: 0 !important;
  border-radius: 12px;
}

/* Mobile */
@media (max-width: 640px) {
  .auth_modal_overlay {
    padding: 14px 14px;
  }

  .auth_modal_panel {
    max-height: calc(100vh - var(--site-header-offset) - 28px);
  }
}

@media (max-width: 420px) {
  .auth_modal_footer_cols {
    grid-template-columns: 1fr;
  }
}
