/*
 * Account Auth Card — /my-account/ login + register redesign
 * Gerbs V2 auth card: yellow brand panel + tabbed form (Sign in / Create account).
 *
 * Loaded only when: is_account_page() + !is_user_logged_in() + gerbs_account_login_use_v2().
 * All values use gerbs-tokens.css custom properties. No hardcoded hex.
 * Classes namespaced .gerbs-auth-* to avoid WC/Divi conflicts.
 *
 * Breakpoints:
 *   Desktop: > 940px — 2-col grid (brand | form)
 *   Tablet:  ≤ 940px — 1-col (form order 1, brand order 2, glow hidden)
 *   Phone:   ≤ 720px — card padding tightens 48→24px
 */

/* ─── Outer wrapper ────────────────────────────────────────────────────────── */

.gerbs-auth-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-12) var(--container-pad);
  min-height: 480px;
  width: 100%;
  box-sizing: border-box;
}

/* ─── Card ─────────────────────────────────────────────────────────────────── */

.gerbs-auth-card {
  width: 100%;
  max-width: 960px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* ─── Tab toggles ──────────────────────────────────────────────────────────── */

.gerbs-auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--gerbs-hairline);
  background: var(--gerbs-fog);
}

.gerbs-auth-tab {
  flex: 1;
  padding: var(--space-4) var(--space-6);
  font-family: var(--ff-body);
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
  color: var(--gerbs-ink-50);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  min-height: 52px;
  text-align: center;
}

.gerbs-auth-tab:hover {
  color: var(--gerbs-ink);
}

.gerbs-auth-tab.is-active {
  color: var(--gerbs-ink);
  border-bottom-color: var(--gerbs-blue);
}

.gerbs-auth-tab:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: 2px;
}

/* ─── Card body — 2-col grid ──────────────────────────────────────────────── */

.gerbs-auth-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 520px;
}

/* ─── Brand panel (left, yellow) ───────────────────────────────────────────── */

.gerbs-auth-brand {
  background-color: var(--gerbs-yellow);
  padding: var(--space-12);
  display: flex;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

/* Decorative glow — hidden on tablet/mobile via media query */
.gerbs-auth-brand::after {
  content: '';
  position: absolute;
  bottom: -80px;
  right: -80px;
  width: 280px;
  height: 280px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  pointer-events: none;
}

.gerbs-auth-brand__inner {
  position: relative;
  z-index: 1;
}

.gerbs-auth-brand__eyebrow {
  font-family: var(--ff-body);
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--gerbs-ink);
  opacity: 0.6;
  margin: 0 0 var(--space-3);
}

.gerbs-auth-brand__headline {
  font-family: var(--ff-display);
  font-size: var(--fs-32);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--gerbs-ink);
  text-wrap: balance;
  margin: 0 0 var(--space-4);
}

.gerbs-auth-brand__lead {
  font-family: var(--ff-body);
  font-size: var(--fs-16);
  line-height: var(--lh-normal);
  color: var(--gerbs-ink);
  opacity: 0.8;
  margin: 0 0 var(--space-8);
  text-wrap: pretty;
}

.gerbs-auth-brand__trust {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.gerbs-auth-brand__trust li {
  font-family: var(--ff-body);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--gerbs-ink);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.gerbs-auth-brand__trust li::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  background-color: var(--gerbs-ink);
  border-radius: 50%;
  flex-shrink: 0;
  /* Checkmark via mask — ink circle with a white check */
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  mask-size: 70%;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  -webkit-mask-size: 70%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

/* ─── Form panel (right, white) ────────────────────────────────────────────── */

.gerbs-auth-forms {
  padding: var(--space-12);
  display: flex;
  flex-direction: column;
}

/* WC notice container — scoped into the card */
.gerbs-auth-forms .woocommerce-notices-wrapper,
.gerbs-auth-forms .woocommerce-error,
.gerbs-auth-forms .woocommerce-info,
.gerbs-auth-forms .woocommerce-message {
  margin-bottom: var(--space-6);
}

/* Collapse the empty notices wrapper WC always outputs — avoids phantom gap above panes */
.gerbs-auth-forms > .woocommerce-notices-wrapper:empty {
  margin: 0;
  padding: 0;
  min-height: 0;
  line-height: 0;
}

/* ─── Pane (one active at a time) ─────────────────────────────────────────── */

.gerbs-auth-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* JS manages hidden attr; CSS ensures invisible-but-focusable doesn't happen */
.gerbs-auth-pane[hidden] {
  display: none !important;
}

/* Without JS both panes stack; give them some separation.
   Scope to :not([hidden]) so the rule only fires when BOTH panes are in the DOM
   and visible (no-JS). DOM siblings are still siblings when one is display:none,
   so the unscoped + selector would always add margin-top to the register pane. */
.gerbs-auth-pane:not([hidden]) + .gerbs-auth-pane:not([hidden]) {
  margin-top: var(--space-10);
  padding-top: var(--space-10);
  border-top: 1px solid var(--gerbs-hairline);
}

/* When JS is active the hidden pane is gone, so the sibling combinator never fires */
.gerbs-auth-pane__header {
  margin-bottom: var(--space-8);
}

.gerbs-auth-pane__heading {
  font-family: var(--ff-display);
  font-size: var(--fs-24);
  font-weight: var(--fw-bold);
  line-height: var(--lh-snug);
  color: var(--gerbs-ink);
  text-wrap: balance;
  margin: 0 0 var(--space-2);
}

.gerbs-auth-pane__subline {
  font-family: var(--ff-body);
  font-size: var(--fs-14);
  color: var(--gerbs-ink-50);
  margin: 0;
}

/* ─── Form rows ─────────────────────────────────────────────────────────────── */

.gerbs-auth-pane .woocommerce-form-row,
.gerbs-auth-pane .form-row {
  margin-bottom: var(--space-5);
}

.gerbs-auth-pane label {
  display: block;
  font-family: var(--ff-body);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--gerbs-ink);
  margin-bottom: var(--space-2);
}

.gerbs-auth-pane .woocommerce-Input--text,
.gerbs-auth-pane input[type="text"],
.gerbs-auth-pane input[type="email"],
.gerbs-auth-pane input[type="password"] {
  width: 100%;
  padding: 12px var(--space-4);
  font-family: var(--ff-body);
  font-size: var(--fs-16);
  color: var(--gerbs-ink);
  background: #fff;
  border: 1.5px solid var(--gerbs-ink-20);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.gerbs-auth-pane .woocommerce-Input--text:focus,
.gerbs-auth-pane input[type="text"]:focus,
.gerbs-auth-pane input[type="email"]:focus,
.gerbs-auth-pane input[type="password"]:focus {
  outline: none;
  border-color: var(--gerbs-blue);
  box-shadow: 0 0 0 3px var(--gerbs-blue-tint);
}

/* ─── First name + Last name side-by-side ──────────────────────────────────── */

.gerbs-auth-name-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.gerbs-auth-name-row .woocommerce-form-row {
  margin-bottom: 0;
}

/* WC default CSS floats .form-row-first/.form-row-last at 47% width.
   Override so they fill their grid cell instead.
   !important beats WC specificity; scoped to .gerbs-auth-pane to avoid global leakage. */
.gerbs-auth-pane .gerbs-auth-name-row .form-row-first,
.gerbs-auth-pane .gerbs-auth-name-row .form-row-last {
  float: none !important;
  width: 100% !important;
  clear: none !important;
}

/* Ensure inputs inside the name grid cells also fill their container */
.gerbs-auth-pane .gerbs-auth-name-row input[type="text"] {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ─── Password reveal ──────────────────────────────────────────────────────── */

.gerbs-field-with-reveal label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.gerbs-reveal-wrap {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.gerbs-reveal-wrap .woocommerce-Input--text,
.gerbs-reveal-wrap input[type="password"],
.gerbs-reveal-wrap input[type="text"] {
  padding-right: 48px;
  width: 100%;
}

.gerbs-reveal-toggle {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--gerbs-ink-50);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.gerbs-reveal-toggle:hover {
  color: var(--gerbs-ink);
}

.gerbs-reveal-toggle:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ─── Remember me / opt-in checkboxes ─────────────────────────────────────── */

.gerbs-auth-remember-row,
.gerbs-auth-optin-row {
  margin-bottom: var(--space-5) !important;
}

.gerbs-auth-pane .woocommerce-form__label-for-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--gerbs-ink);
}

.gerbs-auth-pane .woocommerce-form__input-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--gerbs-blue);
  cursor: pointer;
}

/* ─── Submit buttons — extend .g-btn primary ───────────────────────────────── */

.gerbs-auth-pane .g-btn--primary.g-btn--full,
.gerbs-auth-pane .woocommerce-form-login__submit,
.gerbs-auth-pane .woocommerce-form-register__submit {
  width: 100%;
  display: block;
  text-align: center;
  padding: 14px var(--space-6);
  min-height: 52px;
  font-family: var(--ff-body);
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
  color: #fff;
  background: var(--gerbs-blue);
  border: none;
  border-radius: var(--radius-atc);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.gerbs-auth-pane .g-btn--primary.g-btn--full:hover,
.gerbs-auth-pane .woocommerce-form-login__submit:hover,
.gerbs-auth-pane .woocommerce-form-register__submit:hover {
  background: var(--gerbs-blue-hover);
}

.gerbs-auth-pane .g-btn--primary.g-btn--full:active,
.gerbs-auth-pane .woocommerce-form-login__submit:active,
.gerbs-auth-pane .woocommerce-form-register__submit:active {
  background: var(--gerbs-blue-press);
  transform: scale(0.99);
}

.gerbs-auth-pane .g-btn--primary.g-btn--full:focus-visible,
.gerbs-auth-pane .woocommerce-form-login__submit:focus-visible,
.gerbs-auth-pane .woocommerce-form-register__submit:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* Loading / spinner state — JS adds .is-loading */
.gerbs-auth-pane button.is-loading {
  opacity: 0.7;
  pointer-events: none;
  cursor: not-allowed;
}

/* ─── Forgot password ──────────────────────────────────────────────────────── */

.gerbs-auth-pane .woocommerce-LostPassword {
  margin-top: var(--space-4);
  text-align: center;
}

.gerbs-auth-pane .woocommerce-LostPassword a {
  font-family: var(--ff-body);
  font-size: var(--fs-14);
  color: var(--gerbs-blue);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.gerbs-auth-pane .woocommerce-LostPassword a:hover {
  text-decoration: underline;
}

/* ─── "Switch" line at bottom of each pane ────────────────────────────────── */

.gerbs-auth-switch {
  margin-top: var(--space-6);
  text-align: center;
  font-family: var(--ff-body);
  font-size: var(--fs-14);
  color: var(--gerbs-ink-70);
}

.gerbs-auth-switch-link {
  background: none;
  border: none;
  padding: 0 0 0 var(--space-1);
  font-family: var(--ff-body);
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  color: var(--gerbs-blue);
  cursor: pointer;
  min-height: 44px;
  vertical-align: baseline;
}

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

.gerbs-auth-switch-link:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: 2px;
}

/* ─── required asterisk ─────────────────────────────────────────────────────── */

.gerbs-auth-pane .required {
  color: var(--gerbs-error);
  margin-left: 2px;
}

/* ─── Reduced motion ─────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .gerbs-auth-pane {
    animation: gerbs-auth-pane-in 0.18s ease-out both;
  }
  @keyframes gerbs-auth-pane-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ─── Responsive — tablet ≤ 940px ─────────────────────────────────────────── */

@media (max-width: 940px) {
  .gerbs-auth-body {
    grid-template-columns: 1fr;
  }

  /* Form first, brand second on mobile */
  .gerbs-auth-forms {
    order: 1;
  }

  .gerbs-auth-brand {
    order: 2;
  }

  /* Hide decorative glow on small screens */
  .gerbs-auth-brand::after {
    display: none;
  }

  /* Tabs become scrollable if needed */
  .gerbs-auth-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}

/* ─── Responsive — phone ≤ 720px ──────────────────────────────────────────── */

@media (max-width: 720px) {
  .gerbs-auth-wrap {
    padding: var(--space-6) var(--container-pad);
  }

  .gerbs-auth-brand,
  .gerbs-auth-forms {
    padding: var(--space-6);
  }

  .gerbs-auth-name-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .gerbs-auth-name-row .woocommerce-form-row {
    margin-bottom: var(--space-5);
  }

  .gerbs-auth-brand__headline {
    font-size: var(--fs-24);
  }
}

/* ─── Divi page scaffolding suppression ──────────────────────────────────────── */
/*
 * /my-account/ is a Divi-built page with an et_pb_text module containing
 * <h1>Account</h1> immediately above the et_pb_code module that renders the
 * auth card. Hide that heading and collapse the section padding so the card
 * fills the viewport cleanly with no dead space.
 *
 * Uses :has() (Chrome 105+, Firefox 121+, Safari 15.4+) scoped to
 * body.gerbs-account-v2 (added by bootstrap.php body_class filter).
 */

body.gerbs-account-v2 .entry-content .et_pb_section:has(.gerbs-auth-wrap) {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

body.gerbs-account-v2 .entry-content .et_pb_row:has(.gerbs-auth-wrap) {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Hide the Divi text module containing the "Account" h1 */
body.gerbs-account-v2 .entry-content .et_pb_column:has(.gerbs-auth-wrap) .et_pb_text {
  display: none !important;
}

/* ─── Third-party plugin overrides ─────────────────────────────────────────── */

/*
 * Wordfence Login Security injects its own password-reveal button adjacent to
 * password inputs. Inside our card we already have gerbs-reveal-toggle, so the
 * Wordfence button creates a duplicate icon and shrinks the input.
 * Hide Wordfence's button and reset any width constraint it applies to the input.
 * Scoped to .gerbs-auth-wrap so this does not affect other login forms.
 */
.gerbs-auth-wrap .wfls-password-visibility-toggle,
.gerbs-auth-wrap [class*="wfls-"][type="button"],
.gerbs-auth-wrap .wfls-pwd-toggle,
.gerbs-auth-wrap .show-password-input {
  display: none !important;
}

/* Ensure the password input fills the reveal-wrap even if WFLS adds padding-right */
.gerbs-auth-wrap .gerbs-reveal-wrap input[type="password"],
.gerbs-auth-wrap .gerbs-reveal-wrap input[type="text"] {
  width: 100% !important;
  box-sizing: border-box !important;
  padding-right: 48px !important;
}

/* ─── Print ──────────────────────────────────────────────────────────────────── */

@media print {
  .gerbs-auth-pane[hidden] {
    display: block !important;
  }
  .gerbs-auth-brand::after {
    display: none;
  }
}
