/*
 * Corporate site contact form (HubSpot embed, raw HTML mode).
 * HubSpot loads no CSS for this form, so everything here is ours.
 * Ported from the old .contact-form__* styles in page-contact.php.
 */

.hs-contact {
  --hs-contact-red: #ea0018;
  --hs-contact-gray: #707070;
  --hs-contact-border: #d4d4d4;
  --hs-contact-label-width: 250px;
}

.attention {
  font-size: 13px;
}

/* ---------- Reset ----------
 * Even in raw HTML mode, HubSpot injects a small per-instance layout CSS
 * (.hs-form-<id>_<instance> fieldset.form-columns-2 .hs-form-field { width: 50%; float: left } etc.),
 * and the theme hides every checkbox (form input[type="checkbox"] { display: none })
 * and puts bullets on <li>. The #id keeps these resets stronger than both.
 */
#hs-contact-form .hs-form-field {
  float: none;
  width: auto;
}

#hs-contact-form .input {
  margin-right: 0;
}

#hs-contact-form .hs-input:not([type="checkbox"]) {
  max-width: none;
  width: 100%;
}

#hs-contact-form ul {
  margin: 0;
  padding: 0;
}

/* .entry-content ul li sets a hanging indent (text-indent: -1em), which is
   inherited and pulls the consent text over its checkbox. */
#hs-contact-form li {
  list-style: none;
  margin: 0;
  padding: 0;
  text-indent: 0;
}

/* The theme sets line-height: 1.8 only on the default page template
   (body.page-template-default .entry-content *). Fix it for any template. */
.hs-contact,
.hs-contact * {
  line-height: 1.8;
}

#hs-contact-form li::before,
#hs-contact-form input[type="checkbox"] + span::before {
  content: none;
}

#hs-contact-form input[type="checkbox"] {
  -webkit-appearance: auto;
  appearance: auto;
  display: inline-block;
  height: 18px;
  margin: 0;
  width: 18px;
}

/* ---------- Layout ---------- */

.hs-contact .hs-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 20px;
}

.hs-contact .hs-form fieldset {
  border: none;
  margin: 0 auto;
  max-width: 820px;
  min-width: 0;
  padding: 0 70px;
  width: 100%;
}

/* Fieldsets that only hold hidden fields (UTM) must not take up a gap. */
.hs-contact .hs-form fieldset:not(:has(> .hs-form-field:not([style*="display: none"]))) {
  display: none;
}

/* One field per row: label on the left, input / example / errors on the right. */
.hs-contact .form-columns-1 > .hs-form-field:not(.hs-fieldtype-booleancheckbox) {
  align-items: start;
  column-gap: 10px;
  display: grid;
  grid-template-columns: var(--hs-contact-label-width) minmax(0, 1fr);
}

.hs-contact .form-columns-1 > .hs-form-field > label {
  grid-column: 1;
  grid-row: 1 / span 3;
}

.hs-contact .form-columns-1 > .hs-form-field > .input {
  grid-column: 2;
  grid-row: 1;
}

.hs-contact .form-columns-1 > .hs-form-field > .hs-field-desc {
  grid-column: 2;
  grid-row: 2;
}

.hs-contact .form-columns-1 > .hs-form-field > .hs-error-msgs {
  grid-column: 2;
  grid-row: 3;
}

/* Name row: one visual label ("お名前") and two inputs. */
.hs-contact .form-columns-2 {
  align-items: start;
  column-gap: 10px;
  display: grid;
  grid-template-columns: var(--hs-contact-label-width) minmax(0, 1fr) minmax(0, 1fr);
}

.hs-contact .form-columns-2 > .hs-form-field {
  display: flex;
  flex-direction: column;
}

.hs-contact .form-columns-2 > .hs-form-field > .input {
  order: 1;
}

.hs-contact .form-columns-2 > .hs-form-field > .hs-field-desc {
  order: 2;
}

.hs-contact .form-columns-2 > .hs-form-field > .hs-error-msgs {
  order: 3;
}

/* 姓 / 名 labels stay for screen readers; the row label is shown instead. */
.hs-contact .form-columns-2 > .hs-form-field > label {
  border: 0;
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* ---------- Labels and examples ---------- */

.hs-contact .hs-form-field > label,
.hs-contact .hs-contact__group-label {
  align-items: center;
  display: flex;
  font-size: 16px;
  font-weight: bold;
  height: 48px;
  letter-spacing: 0.48px;
  line-height: 1.8;
  white-space: nowrap;
}

.hs-contact .hs-form-required {
  color: var(--hs-contact-red);
}

.hs-contact .hs-field-desc {
  color: var(--hs-contact-gray);
  font-size: 13px;
  font-weight: 400;
  margin: 6px 0 2px;
}

/* ---------- Inputs ---------- */

.hs-contact .hs-input:not([type="checkbox"]) {
  background-color: #fff;
  background-position: right 20px top 50%;
  background-repeat: no-repeat;
  background-size: 24px;
  border: 1px solid var(--hs-contact-border);
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 15px;
  line-height: 1.8;
  padding: 12px 64px 12px 20px;
}

/* Same as the old <textarea rows="8">: 8 lines + padding + border. */
.hs-contact textarea.hs-input {
  font-size: 14px;
  height: calc(8 * 1.8em + 26px);
  min-height: 8em;
  padding-right: 20px;
  resize: vertical;
}

.hs-contact .hs-input:not([type="checkbox"]):focus {
  border-color: var(--hs-contact-gray);
  outline: none;
}

.hs-contact .hs-input.error:not([type="checkbox"]) {
  background-image: url("https://www.fabercompany.co.jp/wp-content/themes/faber-company/images/contact/icon-error.svg");
  border-color: var(--hs-contact-red);
}

/* HubSpot marks only errors, so the browser's :user-valid gives the OK icon. */
.hs-contact .hs-input:required:user-valid:not(.error):not([type="checkbox"]) {
  background-image: url("https://www.fabercompany.co.jp/wp-content/themes/faber-company/images/contact/icon-success.svg");
}

/* ---------- Errors ---------- */

.hs-contact .hs-error-msgs {
  color: var(--hs-contact-red);
  font-size: 13px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hs-contact .hs_error_rollup {
  text-align: center;
}

/* ---------- Privacy policy checkbox ---------- */

.hs-contact .hs-fieldtype-booleancheckbox {
  align-items: center;
  display: flex;
  flex-direction: column;
}

.hs-contact .hs-fieldtype-booleancheckbox .inputs-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hs-contact .hs-form-booleancheckbox-display {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  gap: 8px;
}

/* ---------- Radio buttons (e.g. M&A お問い合わせ種別) ----------
 * Same look as the old Contact Form 7 radios. The theme hides radios
 * (form input[type=radio] { display: none }); keep the input focusable but
 * visually hidden and draw the circle on the label text. The #id beats the
 * text-input styles of .hs-input above.
 */
#hs-contact-form input[type="radio"] {
  background: none;
  border: 0;
  display: block;
  height: 1px;
  margin: 0;
  opacity: 0;
  padding: 0;
  position: absolute;
  width: 1px;
}

.hs-contact .hs-fieldtype-radio .inputs-list {
  padding-top: 12px;
}

.hs-contact .hs-form-radio {
  margin: 0 0 10px;
}

.hs-contact .hs-form-radio-display {
  cursor: pointer;
  display: inline-block;
  font-size: 15px;
  position: relative;
}

#hs-contact-form input[type="radio"] + span {
  display: inline-block;
  line-height: 20px;
  margin: 0;
  padding-left: 28px;
  position: relative;
}

#hs-contact-form input[type="radio"] + span::before {
  background: #fff;
  border: 2px solid #000;
  border-radius: 100%;
  box-sizing: border-box;
  content: "";
  height: 18px;
  left: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
}

#hs-contact-form input[type="radio"]:checked + span::after {
  background: #000;
  border-radius: 100%;
  content: "";
  height: 10px;
  left: 4px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
}

#hs-contact-form input[type="radio"]:focus-visible + span::before {
  outline: 2px solid var(--hs-contact-gray);
  outline-offset: 2px;
}

/* ---------- reCAPTCHA ----------
 * HubSpot's badge is hidden and .hs-contact__recaptcha-notice says the same
 * as text (as on mieru-ca.com). Not display: none, which can stop reCAPTCHA
 * working. The site-wide badge of Contact Form 7 is left as it is.
 */
.hs-contact .hs_recaptcha {
  margin: 0;
  padding: 0;
  position: absolute;
  visibility: hidden;
}

/* .hs-contact prefix: stronger than the theme's .entry-content p margin. */
.hs-contact .hs-contact__recaptcha-notice {
  color: var(--hs-contact-gray, #707070);
  font-size: 12px;
  line-height: 1.8;
  margin: 16px auto 0;
  text-align: center;
}

.hs-contact__recaptcha-notice + .hs-contact__send-attention {
  margin-top: 8px;
}

.hs-contact__recaptcha-notice a {
  color: inherit;
  text-decoration: underline;
}

/* ---------- Submit ---------- */

/* HubSpot's own <input type="submit"> is replaced by .hs-contact__send-button. */
.hs-contact .hs_submit {
  display: none;
}

.hs-contact__actions {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.hs-contact__send-button {
  background-color: #000;
  border: none;
  border-radius: 34px;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  height: 68px;
  line-height: normal;
  margin: 0 auto;
  overflow: hidden;
  padding: 0 64px;
  position: relative;
  transition: 0.3s;
  width: fit-content;
  z-index: 0;
}

.hs-contact__send-button::before {
  background-color: var(--hs-contact-red, #ea0018);
  content: "";
  display: block;
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  transform: scale(0, 1);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.8, 0, 0.2, 1) 0s;
  width: 100%;
  z-index: -1;
}

.hs-contact__send-button:not(:disabled):hover::before {
  transform: scale(1, 1);
}

.hs-contact__send-button::after {
  background-image: url("https://www.fabercompany.co.jp/wp-content/themes/faber-company/images/contact/arrow-white.svg");
  background-position: right 24px top 50%;
  background-repeat: no-repeat;
  background-size: 13px 10px;
  content: "";
  display: block;
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  transition: all 0.3s;
  width: 100%;
  z-index: 1;
}

.hs-contact__send-button:not(:disabled):hover::after {
  background-position: right 21px top 50%;
}

.hs-contact__send-button:disabled {
  background-color: #ccc;
  color: #959595;
  cursor: not-allowed;
}

.hs-contact__send-button:disabled::after {
  background-image: url("https://www.fabercompany.co.jp/wp-content/themes/faber-company/images/contact/arrow-gray.svg");
}

.hs-contact__send-attention {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.39px;
  margin: 16px auto 0;
}

/* ---------- Mobile ---------- */

@media (max-width: 768px) {
  .hs-contact .hs-form fieldset {
    padding: 0;
  }

  .hs-contact .form-columns-1 > .hs-form-field:not(.hs-fieldtype-booleancheckbox) {
    grid-template-columns: minmax(0, 1fr);
  }

  .hs-contact .form-columns-1 > .hs-form-field > label {
    grid-row: 1;
  }

  .hs-contact .form-columns-1 > .hs-form-field > .input {
    grid-column: 1;
    grid-row: 2;
  }

  .hs-contact .form-columns-1 > .hs-form-field > .hs-field-desc {
    grid-column: 1;
    grid-row: 3;
  }

  .hs-contact .form-columns-1 > .hs-form-field > .hs-error-msgs {
    grid-column: 1;
    grid-row: 4;
  }

  .hs-contact .form-columns-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .hs-contact .hs-contact__group-label {
    grid-column: 1 / -1;
  }

  .hs-contact .hs-form-field > label,
  .hs-contact .hs-contact__group-label {
    height: auto;
    margin-bottom: 10px;
  }
}
