/* Keep both submit buttons inside their illustrated form panels.
   The artwork scales with the viewport, while inputs have minimum heights. */
@media (min-width: 1024px) and (max-width: 1439px) {
  #form_top {
    top: 34.5%;
  }

  #form_top .space-20 {
    margin-bottom: clamp(2px, calc(2px + 12 * (100vw - 768px) / 672), 14px);
  }

  #form_bottom .space-20-2 {
    margin-bottom: clamp(10px, calc(10px + 15 * (100vw - 768px) / 512), 25px);
  }
}

.hero-artwork { position: relative; }
#form_top { z-index: 1; }
.restoration-mask { position: absolute; }
.service-background-restore { display: none; }

@media (max-width: 767px) {
  .service-background-restore {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: #fff;
    clip-path: url(#service-background-restore);
  }
}

/* On phones and small tablets, let the form determine its own height. Only the illustrated
   heading is shown above it; the bitmap's empty form area is clipped. */
@media (max-width: 1023px) {
  .hero, #form_bottom {
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
  }

  .hero { background: #faf6eb; }
  #form_bottom { background: #fff; }

  .hero-artwork, .form-bottom-artwork {
    display: block;
    order: 0;
    overflow: hidden;
    width: 100%;
    flex: none;
  }

  .hero-artwork { aspect-ratio: 1280 / 2144; }
  .form-bottom-artwork { aspect-ratio: 1280 / 976; }

  .hero-artwork > picture:not(.hero-background-restore) img,
  .form-bottom-artwork img {
    display: block;
    width: 100%;
    height: auto;
  }

  .hero-artwork .hero-background-restore {
    bottom: auto;
    height: auto;
    aspect-ratio: 1280 / 3800;
    clip-path: polygon(
      0 46%, 4.84375% 46%, 4.84375% 98.736842%,
      95.15625% 98.736842%, 95.15625% 46%,
      100% 46%, 100% 100%, 0 100%
    );
  }

  #form_top, #form_bottom form {
    position: relative;
    order: 1;
    inset: auto;
    transform: none;
    width: 90%;
    margin: -1px auto 0;
    padding: 20px 16px 22px;
    border: 2px solid #45a175;
    border-top: 0;
    background: #fff;
  }

  #form_top dl > div, #form_bottom form dl > div {
    display: block;
    margin: 0 0 18px;
  }

  #form_top dt, #form_bottom form dt {
    width: 100%;
    margin-bottom: 6px;
  }

  #form_top dt p, #form_bottom form dt p {
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: .02em;
  }

  #form_top dt br, #form_bottom form dt br { display: none; }
  #form_top dd, #form_bottom form dd { width: 100%; }

  #form_top :is(input:not([type="radio"]), select, textarea),
  #form_bottom form :is(input:not([type="radio"]), select, textarea) {
    min-height: 44px;
    padding: 8px 10px;
    border: 2px solid #dfe7e2;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: normal;
  }

  #form_top textarea, #form_bottom form textarea {
    min-height: 104px;
    resize: vertical;
  }

  #form_top fieldset, #form_bottom form fieldset {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 0;
    border: 0;
  }

  #form_top fieldset label, #form_bottom form fieldset label {
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    border: 1px solid #dfe7e2;
    border-radius: 6px;
  }

  #form_top fieldset span, #form_bottom form fieldset span {
    font-size: 14px;
    letter-spacing: normal;
    line-height: 1.5;
    white-space: nowrap;
  }

  #form_top input[type="radio"], #form_bottom form input[type="radio"] {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
  }

  #form_top .phone-note, #form_bottom form .phone-note {
    margin-top: 6px !important;
    line-height: 1.5 !important;
  }

  .phone-note small { display: block; }
  #form_top .phone-note span, #form_bottom form .phone-note span {
    font-size: 11px !important;
  }

  #form_top :is(input,select,textarea,fieldset).blank,
  #form_bottom form :is(input,select,textarea,fieldset).blank {
    outline: 2px solid #e9534b;
    outline-offset: 1px;
    animation: mobile-blank-blink 1s ease-in-out infinite;
  }

  #form_top button[type="submit"], #form_bottom form button[type="submit"] {
    position: relative;
    inset: auto;
    display: block;
    width: 100%;
    max-width: 360px;
    min-height: 44px;
    margin: 20px auto 0;
    border-width: 3px;
  }
}

@keyframes mobile-blank-blink {
  0%, 100% { outline-color: transparent; }
  50% { outline-color: #e9534b; }
}

/* Keep the current field clearly marked for visitors who reduce motion. */
@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
  #form_top :is(input,select,textarea,fieldset).blank,
  #form_bottom form :is(input,select,textarea,fieldset).blank {
    animation: none;
    outline-color: #e9534b;
  }
}
