/* =============================================================================
   Asya — Contact Form 7 bridge

   Contact Form 7 wraps every control in <span class="wpcf7-form-control-wrap">
   and injects its own response/validation elements. This file dissolves those
   wrappers so the site's existing form rules (.row, .field, input, select,
   textarea, .consent, .sent in home.css / contact.css) style the CF7 markup
   exactly as they styled the original hand-written forms — no visual change.

   It also styles CF7's validation messages, response output and spinner in the
   brand palette, reading the same custom properties as the rest of the site.
   ========================================================================== */

/* --- dissolve CF7's wrappers so grid layout is unaffected ---------------- */
.wpcf7 .wpcf7-form-control-wrap {
  display: contents;
}

/* Older browsers without display:contents still get a sane block wrapper. */
@supports not (display: contents) {
  .wpcf7 .wpcf7-form-control-wrap {
    display: block;
  }
}

.wpcf7 form {
  display: grid;
  gap: 18px;
}

.wpcf7 form > p {
  margin: 0;
}

/* CF7 adds <br> and stray paragraphs when the mail template is edited in the
   visual tab; the theme's forms are laid out with .row/.field instead. */
.wpcf7 form .row > br,
.wpcf7 form .field > br {
  display: none;
}

/* --- stop CF7's size/cols/rows attributes from blowing out the grid ----- */
/* CF7 always renders text/email/tel inputs with size="40" and textareas
   with cols="40" rows="10" — attributes the original hand-written <input>
   elements never had. .row's columns are plain "1fr 1fr" with no floor, so
   without this, that size/cols/rows-driven intrinsic width becomes each
   field's automatic minimum contribution to the grid track: at narrower
   desktop widths the row (and the whole card around it) is forced wider
   than its column and the right-hand fields spill past the edge of the
   page, instead of shrinking to fit the way the original always did. */
.wpcf7 .row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.wpcf7 .field,
.wpcf7 input,
.wpcf7 select,
.wpcf7 textarea {
  min-width: 0;
}

/* min-width:0 alone stops the *track* from blowing out, but a grid item's
   default stretch alignment does not override an <input>'s own size="40" /
   textarea's cols="40" — Chrome still renders the control at its
   attribute-driven ~380px intrinsic width even inside a narrower track (it
   just overflows the field instead). The original inputs had no size
   attribute, so they always filled whatever width .field gave them; this
   restores that explicitly rather than relying on stretch to do it. */
.wpcf7 input,
.wpcf7 select,
.wpcf7 textarea {
  width: 100%;
}

/* --- submit button ------------------------------------------------------ */
/* [submit class:btn class:btn-solid "…"] already puts the page's own .btn
   and .btn-solid classes on the rendered <input type="submit">, so the
   page's own stylesheet (home.css's pill-shaped, flat-teal button; contact
   .css's larger, rounded, dark-gradient button; etc.) styles it exactly like
   the original markup's <a>/<button> elements — each page keeps its own
   shape and size. This only resets the browser's native submit-button
   chrome and adds the states CF7 introduces that the static site never had;
   it must NOT set its own color/padding/radius, or it would override every
   page's button with one hardcoded look (this used to hardcode the home
   page's button onto the Contact page too — see the theme README §9). */
.wpcf7 input[type="submit"],
.wpcf7 .wpcf7-submit {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  cursor: pointer;
}

.wpcf7 input[type="submit"]:disabled,
.wpcf7 .wpcf7-submit:disabled {
  cursor: not-allowed;
  transform: none;
}

/* --- consent checkbox --------------------------------------------------- */
/* [acceptance consent] renders a span chain wrapping its own <label>; flatten
   the whole chain so the checkbox and its text become direct children of the
   theme's flex .consent row. */
.wpcf7 .consent .wpcf7-acceptance,
.wpcf7 .consent .wpcf7-list-item,
.wpcf7 .consent .wpcf7-list-item > label {
  display: contents;
  margin: 0;
}

.wpcf7 .consent .wpcf7-list-item-label {
  font-size: 0.82rem;
  color: rgba(var(--pearl-rgb), 0.58);
  line-height: 1.5;
  letter-spacing: normal;
  text-transform: none;
}

.wpcf7 .consent input[type="checkbox"] {
  appearance: auto;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  padding: 0;
  flex: none;
  border: 0;
  background: none;
  accent-color: var(--azure);
}

/* --- validation ---------------------------------------------------------- */
.wpcf7 .wpcf7-not-valid {
  border-color: var(--brass);
}

.wpcf7 .wpcf7-not-valid-tip {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--brass);
}

.wpcf7 .wpcf7-response-output {
  margin: 0;
  padding: 14px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: rgba(var(--pearl-rgb), 0.75);
  background: rgba(var(--ink-rgb), 0.6);
}

.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.payment-required .wpcf7-response-output {
  border-color: rgba(217, 80, 46, 0.55);
}

.wpcf7 form.sent .wpcf7-response-output {
  border-color: var(--sky);
}

.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output {
  border-color: var(--brass);
}

/* The theme reveals its own ".sent" panel on success, so CF7's duplicate
   confirmation message is redundant. */
.wpcf7 form.sent .wpcf7-response-output {
  display: none;
}

/* --- spinner ------------------------------------------------------------- */
.wpcf7 .wpcf7-spinner {
  margin: 0 0 0 12px;
  background-color: var(--sky);
}

[dir="rtl"] .wpcf7 .wpcf7-spinner {
  margin: 0 12px 0 0;
}

/* --- honeypot / hidden helper fields ------------------------------------- */
.wpcf7 .asya-hp,
.wpcf7 input[type="hidden"] + br {
  display: none !important;
}

/* --- reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .wpcf7 input[type="submit"],
  .wpcf7 .wpcf7-submit {
    transition: none;
  }
  .wpcf7 input[type="submit"]:hover,
  .wpcf7 .wpcf7-submit:hover {
    transform: none;
  }
}
