/* Unified inline validation for the three "Свяжитесь с нами онлайн" forms. */
@layer doverie-components {
  :is(
    .design-page .footer-online-form__panel,
    .services-exact > .request form,
    .contacts-form__panel
  ) :is(input:not([type="checkbox"]), textarea).has-inline-validation-error {
    outline: 0;
  }

  :is(
    .design-page .footer-online-form__panel,
    .services-exact > .request form,
    .contacts-form__panel
  ) :is(input:not([type="checkbox"]), textarea).has-inline-validation-error::placeholder {
    color: rgba(126, 78, 63, .92);
    -webkit-text-fill-color: rgba(126, 78, 63, .92);
    opacity: 1;
    font-family: "Montserrat", sans-serif;
    font-weight: 500;
  }

  :is(
    .design-page .footer-online-form__panel,
    .services-exact > .request form,
    .contacts-form__panel
  ) [aria-invalid="true"] {
    outline: 0;
  }

  :is(
    .design-page .footer-online-form__panel > label,
    .services-exact > .request form > label,
    .contacts-form__panel .contacts-consent
  ).has-inline-validation-error .privacy-consent-link {
    color: rgba(126, 78, 63, .96);
    -webkit-text-fill-color: rgba(126, 78, 63, .96);
    font-family: "Montserrat", sans-serif;
    font-weight: 500;
  }

  /* Contacts desktop/tablet: when validation copy becomes longer, keep it on one
     line and let the checkbox follow the text naturally instead of overlapping it. */
  @media (min-width: 768px) {
    .contacts-form__panel .contacts-consent.has-inline-validation-error {
      display: inline-flex;
      align-items: center;
      width: max-content;
      gap: 12px;
    }

    .contacts-form__panel .contacts-consent.has-inline-validation-error .privacy-consent-link {
      white-space: nowrap;
    }

    .contacts-form__panel .contacts-consent.has-inline-validation-error .project-consent-checkbox {
      position: static;
      flex: 0 0 20px;
    }
  }
}


/* Mobile validation-only consent layout:
   keep the checkbox in its original position and give the validation copy
   enough room to stay on two lines. The normal consent state is unchanged. */
@layer doverie-components {
  @media (max-width: 767px) {
    :is(
      .design-page.is-footer-form-open .footer-online-form__panel > label,
      .services-exact > .request form > label,
      .contacts-form__panel .contacts-consent
    ).has-inline-validation-error .privacy-consent-link {
      display: block;
      width: 235px;
      max-width: 235px;
      transform: translateX(-42px);
    }
  }
}


/* Accessible validation copy: visible feedback stays inside the form controls,
   while this text gives assistive technology an explicit error description. */
@layer doverie-components {
  .validation-sr-error {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}



/* Canonical mobile home geometry.
   FAQ answers use reserved space; only the expandable online form changes the
   overall page height. Keeping these values in one block prevents state rules
   from fighting over the same coordinates. */
@layer doverie-components {
  @media (max-width: 767px) {
    .design-page {
      --home-statement-top: 6390px;
      --home-footer-top: 6600px;
      --home-page-height: 7748px;
      --home-open-form-height: 8370px;
    }
    .design-page .statement { top: var(--home-statement-top); }
    .design-page > .footer { top: var(--home-footer-top); }
    .design-page:not(.is-footer-form-open) { height: var(--home-page-height); }
    .design-page.is-footer-form-open { height: var(--home-open-form-height); }
    .design-page.is-footer-form-open > .footer { top: var(--home-footer-top); }
    .design-page.is-footer-form-open .footer-online-form { top: -210px; }
    .design-page.is-footer-form-open .scene--footer {
      top: 6490px;
      height: 1880px;
      background-position: center top, center bottom;
      background-size: 100% calc(100% - 298px), 100% 298px;
      background-repeat: no-repeat;
    }
  }

  :is(
    .footer-online-form__panel > label .project-consent-checkbox,
    .contacts-consent .project-consent-checkbox
  ):focus-visible {
    outline: 2px solid rgba(84, 63, 50, .72);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .48);
  }

  .contacts-submit:focus-visible,
  .contacts-form__panel input.contacts-submit:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .9);
    outline-offset: -5px;
    box-shadow: 0 4px 16px rgba(84, 63, 50, .18);
  }
}
