/* =============================================================================
 * TotalMed — California Consumer Privacy form (CCPA "do not sell my info").
 *
 * Loaded ONLY on the page that renders [totalmed_ca_privacy_form] (see
 * inc/forms-ca-privacy.php). Everything is namespaced `.tm-caform` and built from
 * the --tm-* tokens in foundations.css, so it inherits the brand automatically and
 * can't leak onto MetForm or Elementor forms elsewhere.
 *
 * This form is hand-built HTML rather than a MetForm form (it POSTs straight to the
 * Jobs backend), so it gets its own field styling here instead of riding the `.mf-*`
 * rules in components.css. Values are intentionally the same ones those rules use —
 * a visitor should not be able to tell this form apart from the rest of the site.
 * ========================================================================== */

.tm-caform {
  font-family: var(--tm-font-sans);
  color: var(--tm-color-text);
  background-color: white;
  display: flex;
  flex-direction: column;
  gap: var(--tm-space-4);
  padding: 4rem;
  max-width: 40rem;
  border-radius: 1rem;
  box-shadow: 0 3px 20px 0 rgba(0, 0, 0, 0.12);
}

/* `display: flex` above outranks the UA's [hidden] rule, so the hidden confirmation
   panel — and the form once ca-privacy-form.js swaps them — would stay visible without
   this. Both states of that swap depend on it. */
.tm-caform[hidden] {
  display: none;
}

/* --- Legal copy (verbatim strings; see the PHP) ---------------------------- */
.tm-caform__pretext,
.tm-caform__posttext {
  margin: 0;
  font-size: var(--tm-text-small);
}

.tm-caform__pretext {
  font-weight: 600;
}

.tm-caform__posttext {
  color: var(--tm-color-text-muted);
  text-align: center;
}

/* --- Fields ---------------------------------------------------------------- */
/* Two-up on desktop, stacked on narrow screens — auto-fit rather than a media
   query so it also collapses correctly inside a narrow Elementor column. */
.tm-caform__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
  gap: var(--tm-space-4);
}

.tm-caform__field {
  display: flex;
  flex-direction: column;
  gap: var(--tm-space-2);
}

.tm-caform__label {
  font-weight: 600;
  font-size: var(--tm-text-small);
  color: var(--tm-color-navy);
}

.tm-caform__required {
  color: var(--tm-color-coral);
}

.tm-caform__input {
  width: 100%;
  font-family: inherit;
  font-size: var(--tm-text-body);
  color: var(--tm-color-navy);
  background: var(--tm-color-white);
  border: 1px solid var(--tm-color-border);
  border-radius: var(--tm-radius);
  padding: var(--tm-space-3) var(--tm-space-4);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tm-caform__input:focus {
  outline: none;
  border-color: var(--tm-form-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tm-form-accent) 22%, transparent);
}

/* :user-invalid, NOT :invalid — the latter paints every empty required field red the
   moment the page loads. This only fires after the visitor has typed in the field or
   tried to submit. On a browser without :user-invalid the field simply isn't tinted;
   native validation still blocks the submit either way. */
.tm-caform__input:user-invalid {
  border-color: var(--tm-color-danger);
}

/* --- Consent checkbox (the actual CCPA opt-in) ----------------------------- */
.tm-caform__consent {
  display: flex;
  align-items: center;
  gap: var(--tm-space-3);
  font-size: var(--tm-text-body);
}

.tm-caform__checkbox {
  /* 1.15em, not a fixed px: the box tracks the label's type size. margin-top
     optically centers it on the first line rather than the line box. */
  width: 1.15em;
  height: 1.15em;
  margin: 0.15em 0 0;
  flex: 0 0 auto;
  accent-color: var(--tm-form-accent);
}

.tm-caform__consent label {
  cursor: pointer;
}

/* --- Errors, submit --------------------------------------------------------- */
.tm-caform__error {
  margin: 0;
  color: var(--tm-color-danger);
  font-size: var(--tm-text-small);
  font-weight: 600;
}

.tm-caform__actions {
  margin-top: var(--tm-space-2);
}

/* Button color/shape comes from .tm-btn--form in components.css (blue — forms never
   use the coral marketing CTA). Only the width behavior is form-specific. */
.tm-caform__submit {
  min-width: 10rem;
  width: 100%;
}

/* The card's 4rem inset is a desktop measure. Left alone on a narrow phone it eats
   most of the usable width: at 390px the card is 350px wide, so 64px each side leaves
   the fields 222px — measured on dev, where the inputs started at x=84 on a 390px
   screen. Reducing the inset to 1.75rem gives them 294px and keeps the card reading as
   a card. Only the padding changes; radius, shadow and background are untouched.

   (The `.tm-caform__submit { width: 100% }` rule that used to live here was a no-op —
   the same declaration already applies unconditionally above.) */
@media (max-width: 480px) {
  .tm-caform {
    padding: 1.75rem;
  }
}

/* --- Confirmation panel ----------------------------------------------------
 * Replaces the form after a successful hand-off (?tm_caform=sent). Reuses the
 * .tm-caform card itself so the page doesn't visibly change shape underneath the
 * visitor — only the contents swap. */
.tm-caform--sent {
  gap: var(--tm-space-3);
}

.tm-caform__sent-title {
  margin: 0;
  font-family: var(--tm-font-serif);
  font-size: var(--tm-text-h3);
  line-height: 1.2;
  color: var(--tm-color-navy);
}

.tm-caform__sent-body {
  margin: 0;
  color: var(--tm-color-text-muted);
}
