/* ============================================================================
 * JanDigital Registration — front-end stylesheet.
 * Layout/structure ported from DESING_Samples/Registration.html (form pane
 * only). All visual tokens (--jd-ma-*) re-declared here from the My Account
 * stylesheet so the registration page matches the rest of the product —
 * Sofia Sans, light grey/white palette, dark filled primary button.
 *
 * Every selector scoped under #jd-ma-reg / .jd-ma-reg-* so it cannot leak
 * into Bricks elements that wrap the shortcode.
 * ============================================================================ */

#jd-ma-reg {
  --jd-ma-bg-page: #f4f5f7;
  --jd-ma-bg-card: #ffffff;
  --jd-ma-bg-soft: #fafafb;
  --jd-ma-bg-hover: #eef0f3;
  --jd-ma-fg-primary: #0f1013;
  --jd-ma-fg-secondary: #4a4d55;
  --jd-ma-fg-muted: #8b8e96;
  --jd-ma-fg-dim: #b8bac0;
  --jd-ma-border: #dfe1e6;
  --jd-ma-border-soft: #e9eaee;
  --jd-ma-border-strong: #c8cbd2;
  --jd-ma-st-red: #b91c1c; --jd-ma-st-red-bg: #fae6e6;

  --jd-ma-radius-lg: 6px;
  --jd-ma-radius: 5px;
  --jd-ma-radius-sm: 4px;
  --jd-ma-t: 220ms cubic-bezier(.2,.7,.2,1);

  font-family: 'Sofia Sans', system-ui, sans-serif;
  color: var(--jd-ma-fg-primary);
  -webkit-font-smoothing: antialiased;
  display: block;
}

#jd-ma-reg *, #jd-ma-reg *::before, #jd-ma-reg *::after { box-sizing: border-box; }

.jd-ma-reg-card {
  max-width: 600px;
  margin: 0 auto;
  background: var(--jd-ma-bg-card);
  border: 1px solid var(--jd-ma-border-soft);
  border-radius: var(--jd-ma-radius-lg);
  padding: 36px 36px 32px;
  box-shadow: 0 1px 2px rgba(15,16,19,0.04), 0 8px 24px rgba(15,16,19,0.04);
}

/* ===== Site logo ===== */
.jd-ma-reg-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.jd-ma-reg-logo a,
.jd-ma-reg-logo span { display: inline-flex; align-items: center; }
.jd-ma-reg-logo img {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: var(--jd-ma-radius);
  object-fit: contain;
}
.jd-ma-reg-logo-text {
  font: 700 18px 'Sofia Sans', sans-serif;
  letter-spacing: -0.01em;
  color: var(--jd-ma-fg-primary);
  text-decoration: none;
}

/* ===== Header ===== */
.jd-ma-reg-head { margin-bottom: 24px; text-align: center; }
.jd-ma-reg-head h1 {
  margin: 0 0 6px;
  font: 700 26px 'Sofia Sans', sans-serif;
  letter-spacing: -0.02em;
  color: var(--jd-ma-fg-primary);
}
.jd-ma-reg-lede {
  margin: 0;
  font-size: 13.5px;
  color: var(--jd-ma-fg-secondary);
  line-height: 1.5;
}

/* ===== Form ===== */
.jd-ma-reg-form { display: flex; flex-direction: column; gap: 14px; }

.jd-ma-reg-row { display: grid; gap: 12px; }
.jd-ma-reg-row-2 { grid-template-columns: 1fr 1fr; }
.jd-ma-reg-row-2-1 { grid-template-columns: 2fr 1fr; }

.jd-ma-reg-field { display: flex; flex-direction: column; gap: 5px; }

/* Label is a single-line flex row with two children:
 *   .jd-ma-reg-field-label-text  (always present — field name + asterisk)
 *   .jd-ma-reg-field-label-msg   (created by register.js when the field
 *                                  fails validation; cleared when valid)
 * Both shrink with ellipsis. Fixed line-height + nowrap = zero layout shift
 * when the message appears (the row's height is identical empty vs filled). */
.jd-ma-reg-field > label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font: 500 11px 'Sofia Sans', sans-serif;
  line-height: 14px;
  min-height: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.jd-ma-reg-field-label-text {
  /* Never shrink — the field name must remain fully visible so the user
     always knows which field they're looking at. The error message
     ellipsizes first if the row is tight. */
  flex: 0 0 auto;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--jd-ma-fg-secondary);
}
.jd-ma-reg-field-label-text .req {
  color: var(--jd-ma-st-red);
  margin-left: 3px;
}
.jd-ma-reg-field-label-msg {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--jd-ma-st-red);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  text-align: right;
}

.jd-ma-reg-input,
.jd-ma-reg-select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--jd-ma-border);
  border-radius: var(--jd-ma-radius);
  background: var(--jd-ma-bg-soft);
  color: var(--jd-ma-fg-primary);
  font: 400 14px 'Sofia Sans', sans-serif;
  outline: none;
  transition: border-color var(--jd-ma-t), box-shadow var(--jd-ma-t), background var(--jd-ma-t);
}
.jd-ma-reg-input::placeholder { color: var(--jd-ma-fg-dim); }
.jd-ma-reg-input:hover,
.jd-ma-reg-select:hover { border-color: var(--jd-ma-border-strong); }
.jd-ma-reg-input:focus,
.jd-ma-reg-select:focus {
  border-color: var(--jd-ma-fg-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15,16,19,0.06);
}
.jd-ma-reg-input.is-invalid,
.jd-ma-reg-select.is-invalid {
  border-color: var(--jd-ma-st-red);
  background: var(--jd-ma-st-red-bg);
}


.jd-ma-reg-select-wrap { position: relative; }
.jd-ma-reg-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
}
.jd-ma-reg-select:disabled {
  background: var(--jd-ma-bg-hover);
  color: var(--jd-ma-fg-secondary);
  cursor: not-allowed;
}
.jd-ma-reg-select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--jd-ma-fg-secondary);
  border-bottom: 1.5px solid var(--jd-ma-fg-secondary);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* ===== Password show/hide ===== */
.jd-ma-reg-pw-wrap { position: relative; }
.jd-ma-reg-pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  padding: 6px;
  cursor: pointer;
  color: var(--jd-ma-fg-muted);
  border-radius: var(--jd-ma-radius-sm);
  transition: color var(--jd-ma-t), background var(--jd-ma-t);
}
.jd-ma-reg-pw-toggle:hover {
  color: var(--jd-ma-fg-primary);
  background: var(--jd-ma-bg-hover);
}
.jd-ma-reg-pw-toggle svg { display: block; width: 16px; height: 16px; }

/* ===== Checkboxes ===== */
.jd-ma-reg-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  position: relative;
}
.jd-ma-reg-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px; height: 1px;
}
.jd-ma-reg-box {
  flex: 0 0 18px;
  width: 18px; height: 18px;
  border: 1.5px solid var(--jd-ma-border-strong);
  border-radius: var(--jd-ma-radius-sm);
  background: #fff;
  margin-top: 1px;
  display: grid;
  place-items: center;
  transition: background var(--jd-ma-t), border-color var(--jd-ma-t);
}
.jd-ma-reg-check:hover .jd-ma-reg-box { border-color: var(--jd-ma-fg-primary); }
.jd-ma-reg-check input:checked + .jd-ma-reg-box {
  background: var(--jd-ma-fg-primary);
  border-color: var(--jd-ma-fg-primary);
  color: #fff;
}
.jd-ma-reg-check.is-invalid .jd-ma-reg-box {
  border-color: var(--jd-ma-st-red);
  background: var(--jd-ma-st-red-bg);
}
.jd-ma-reg-check.is-invalid .jd-ma-reg-check-text {
  color: var(--jd-ma-st-red);
}
.jd-ma-reg-check input:focus-visible + .jd-ma-reg-box {
  box-shadow: 0 0 0 3px rgba(15,16,19,0.12);
}
.jd-ma-reg-box svg {
  width: 11px; height: 11px;
  opacity: 0;
  transition: opacity .12s ease;
}
.jd-ma-reg-check input:checked + .jd-ma-reg-box svg { opacity: 1; }
.jd-ma-reg-check-text {
  font-size: 13px;
  color: var(--jd-ma-fg-secondary);
  line-height: 1.5;
}
.jd-ma-reg-check-text a {
  color: var(--jd-ma-fg-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.jd-ma-reg-check-text .req { color: var(--jd-ma-st-red); margin-left: 2px; }

/* ===== Turnstile =====
   `data-size="flexible"` on the .cf-turnstile div tells Cloudflare's api.js
   to render the widget responsive within its container (min 300px, max
   container width). The wrapper + widget + injected iframe all need to be
   100% width so the box visually aligns with the inputs above it on the
   600px card. Cloudflare sets inline `width:300px` on its iframe by default;
   the !important here is the only way to override that without rewriting
   the script's inline style at runtime. */
.jd-ma-reg-turnstile {
  margin-top: 4px;
  min-height: 65px; /* reserve space so the form doesn't jump on widget load */
  width: 100%;
}
.jd-ma-reg-turnstile .cf-turnstile,
.jd-ma-reg-turnstile .cf-turnstile > div,
.jd-ma-reg-turnstile iframe {
  width: 100% !important;
  max-width: 100% !important;
}

/* ===== Submitting state =====
   Applied while the registration request is in flight (set by register.js
   via setFormLocked). The form fields are already `disabled` so they're
   visually unresponsive — this also fades them so the user can clearly
   tell the form isn't broken, it's working. The submit button + error
   banner are exempt from the fade so the spinner is visible at full
   contrast and any retry messaging stays readable.

   Why per-field fades instead of `opacity` on the form: `opacity` cascades
   onto every descendant and can't be undone in children — so a faded form
   would force a faded spinner. Targeting the field rows directly leaves
   the submit button at full opacity. */
.jd-ma-reg-form.is-submitting > :is(
  .jd-ma-reg-row,
  .jd-ma-reg-field,
  .jd-ma-reg-check,
  .jd-ma-reg-turnstile,
  .jd-ma-reg-login-link
) {
  opacity: 0.55;
  transition: opacity 0.18s ease;
}
.jd-ma-reg-form.is-submitting {
  pointer-events: none;       /* blocks clicks on labels / Turnstile iframe overlay (button is already disabled) */
  cursor: progress;
}
.jd-ma-reg-form.is-submitting .jd-ma-reg-submit {
  cursor: progress;
}

/* Spinner / arrow swap on the submit button. Default state shows the arrow;
   while submitting, the arrow hides and the spinner shows + rotates. */
.jd-ma-reg-submit-spinner { display: none; }
.jd-ma-reg-form.is-submitting .jd-ma-reg-submit-arrow { display: none; }
.jd-ma-reg-form.is-submitting .jd-ma-reg-submit-spinner {
  display: inline-block;
  animation: jd-ma-reg-spin 0.7s linear infinite;
  transform-origin: 50% 50%;
}
@keyframes jd-ma-reg-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  /* Still swap the icon so users see the state change, but don't rotate. */
  .jd-ma-reg-form.is-submitting .jd-ma-reg-submit-spinner {
    animation: none;
  }
}

/* ===== Error banner ===== */
.jd-ma-reg-error {
  background: var(--jd-ma-st-red-bg);
  color: var(--jd-ma-st-red);
  border: 1px solid rgba(185,28,28,0.18);
  border-radius: var(--jd-ma-radius);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}
.jd-ma-reg-error a { color: inherit; text-decoration: underline; }

/* ===== Submit ===== */
.jd-ma-reg-submit {
  margin-top: 6px;
  height: 46px;
  border-radius: var(--jd-ma-radius);
  background: var(--jd-ma-fg-primary);
  color: #fff;
  border: 0;
  font: 700 12px 'Sofia Sans', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--jd-ma-t), transform .05s ease, opacity var(--jd-ma-t);
}
.jd-ma-reg-submit:hover { background: #000; }
.jd-ma-reg-submit:active { transform: translateY(1px); }
.jd-ma-reg-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--jd-ma-fg-primary);
}
.jd-ma-reg-submit svg { width: 14px; height: 14px; transition: transform var(--jd-ma-t); }
.jd-ma-reg-submit:hover:not(:disabled) svg { transform: translateX(2px); }

/* ===== Footer link ===== */
.jd-ma-reg-login-link {
  text-align: center;
  font-size: 13px;
  color: var(--jd-ma-fg-muted);
  margin: 14px 0 0;
}
.jd-ma-reg-login-link a {
  color: var(--jd-ma-fg-primary);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--jd-ma-fg-primary);
  padding-bottom: 1px;
}

/* ===== Honeypot — hidden from humans, visible to naive bots ===== */
.jd-ma-reg-hp {
  position: absolute !important;
  left: -10000px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

/* ===== Admin-only configuration notice ===== */
.jd-ma-reg-admin-notice {
  background: var(--jd-ma-st-amber-bg, #fbefd9);
  color: var(--jd-ma-st-amber, #a06508);
  border: 1px solid rgba(160,101,8,0.2);
  border-radius: var(--jd-ma-radius);
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.jd-ma-reg-admin-notice code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font: 500 11.5px 'JetBrains Mono', ui-monospace, monospace;
}

/* ===== Mobile ===== */
@media (max-width: 560px) {
  .jd-ma-reg-card { padding: 26px 22px 24px; }
  .jd-ma-reg-head h1 { font-size: 22px; }
  .jd-ma-reg-row-2 { grid-template-columns: 1fr; }
  .jd-ma-reg-row-2-1 { grid-template-columns: 1fr 1fr; }
}
