/* =================================================
 * HubSpot新フォーム調整
 * ================================================= */
:root {
  /* ===== HubSpot form CSS variables (global) ===== */
  --hsf-global__font-family: "IBM Plex Sans JP", "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Osaka, Meiryo, YuGothic, "Yu Gothic medium", "Hiragino Sans", Meiryo, sans-serif;
  --hsf-global__font-size: 16px;
  --hsf-global__color: var(--black);
  --hsf-global-error__color: var(--form-error-color);
  /* Spacing */
  --hsf-row__vertical-spacing: 0;
  --hsf-module__vertical-spacing: 7px;
  /* Buttons */
  --hsf-button__background-color: var(--rbusinesscard-primary);
  --hsf-button__border-radius: 5px;
  --hsf-button__padding: 22px 0;
  --hsf-button__box-shadow: none;
  --hsf-button__width: 187px;
  --hsf-button__height: 63px;
  /* Background */
  --hsf-background__background-color: none;
  --hsf-background__padding: 0 0 20px;
  /* Alerts */
  --hsf-erroralert__font-size: 12px;
  --hsf-infoalert__font-size: 14px;
  --hsf-infoalert__color: var(--form-error-color);
  /* Field common */
  --hsf-heading__color: var(--rbusinesscard-primary);
  --hsf-field-label__font-size: 16px;
  --hsf-field-label__color: var(--black);
  --hsf-field-label-requiredindicator__color: var(--white);
  --hsf-field-description__color: var(--black);
  --hsf-field-input__background-color: var(--white);
  --hsf-field-input__placeholder-color: var(--gray-04);
  --hsf-field-input__border-color: var(--gray-08);
  --hsf-field-input__border-width: 1px;
  --hsf-field-input__border-style: solid;
  --hsf-field-input__border-radius: 3px;
  /* Field textarea */
  --hsf-field-textarea__background-color: var(--gray-09);
  --hsf-field-textarea__placeholder-color: var(--gray-08);
  --hsf-field-textarea__border-color: var(--gray-08);
  --hsf-field-textarea__border-width: 1px;
  --hsf-field-textarea__border-style: solid;
  --hsf-field-textarea__border-radius: 5px;
  --hsf-field-textarea__padding: 20px;
  /* Field checkbox / radio */
  --hsf-field-checkbox__padding: ;
  --hsf-field-checkbox__background-color: var(--white);
  --hsf-field-checkbox__color: var(--white);
  --hsf-field-checkbox__border-color: var(--main-gray-bg01);
  --hsf-field-checkbox__border-width: 1px;
  --hsf-field-checkbox__border-style: solid;
  /* Field radio */
  --hsf-field-radio__border-color: var(--main-gray-bg01);
  --hsf-default-field-radio__border-color: var(--main-gray-bg01);
  /* Progress bar */
  --hsf-progressbar-progressLine__background-color: var(--rbusinesscard-primary) /* padding */ --hsf-default-background__padding: 0;
}

/* ===== Checkbox & Radio ===== */

input[type="radio"],
input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  -o-appearance: none;
  appearance: none;
  cursor: pointer;
  position: relative;
  display: block;
  float: left;
}

@media all and (-ms-high-contrast: none) {
  input[type="radio"],
  input[type="checkbox"] {
    position: relative;
    top: 3px;
    float: left;
  }
}

/* ===== Container ===== */
.m-form-hs {
  width: 100%;
  position: relative;
  @media screen and (max-width: 840px) {
    width: 100%;
  }
}

.m-form-hs__wrapper {
  @media screen and (max-width: 840px) {
    width: 100%;
  }
}

/* Title pill */
.m-form-hs .m-form-hs__h2 {
  position: relative;
  display: inline-block;
  font-size: 18px;
  padding: 12px 60px;
  border-radius: 30px;
  line-height: 1.4;
  background: var(--rbusinesscard-primary);
  color: var(--white);
  left: 50%;
  transform: translateX(-50%);
  top: 24px;
  @media screen and (max-width: 840px) {
    font-size: 16px;
    padding: 10px 30px;
    top: 19px;
  }
  &::before {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    left: 50%;
    bottom: -10px;
    transform: translateX(-50%);
    border: 11px solid transparent;
    border-bottom-width: 0;
    border-top: 15px solid var(--rbusinesscard-primary);
  }
}

/* ===== HubSpot form HTML (inside iframe host container) ===== */

.m-form-hs .hs-form-html .hsfc-FieldLabel {
  position: relative;
  font-weight: bold;
  font-size: 16px;
  color: var(--rbusinesscard-primary) !important;
  cursor: default;
  display: flex;
  font-weight: 700;
  justify-content: flex-start;
  line-height: 1.3;
  margin-bottom: 5px;
  padding-top: 8px;
  position: relative;
  text-align: left;
  width: 100%;
}
/* 必須マークの並び替え */
.m-form-hs .hs-form-html [data-hsfc-id="Renderer"] .hsfc-FieldLabel > span {
  align-items: center;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
}

/* 必須マークの見た目 */
.m-form-hs .hs-form-html .hsfc-FieldLabel__RequiredIndicator {
  align-items: center;
  background-color: var(--rbusinesscard-primary);
  border-radius: 3px;
  color: transparent;
  font-size: 73%;
  margin: -2px 4px 0 0;
  padding: 0 12px 3px;
  position: relative;
  &:after {
    color: var(--white);
    content: "必須";
    display: block;
    font-size: 11px;
    text-align: center;
    position: absolute;
    top: 3px;
    left: 3px;
    width: 25px;
  }
}

/* リッチテキスト */
.m-form-hs .hs-form-html .hsfc-RichText p {
  color: var(--black);
  font-size: 16px;
  @media screen and (max-width: 840px) {
    font-size: 14px;
  }
}
.m-form-hs .hs-form-html .hsfc-RichText a {
  text-decoration: underline;
  &:hover {
    text-decoration: none;
  }
}
.m-form-hs .hs-form-html .hsfc-DataPrivacyField p {
  color: var(--black);
  font-size: 11px;
}

/* ステップ枠 */
.m-form-hs .hs-form-html .hsfc-Step .hsfc-Step__Content {
  position: relative;
  z-index: 10;
  & > .hsfc-Row {
    margin-bottom: 5px;
  }
}

/* ラジオ */
.m-form-hs .hs-form-html .hsfc-RadioFieldGroup__Options {
  display: flex;
  flex-direction: column;
  @media screen and (max-width: 840px) {
    flex-direction: column;
    gap: 4px;
  }
}

/* セレクトボックス */
.m-form-hs .hs-form-html .hsfc-DropdownInput {
  /* max-width: 240px; */
}

.m-form-hs .hs-form-html .hsfc-DropdownInput__Caret {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  & > span {
    position: relative;
    border-top: unset;
    width: unset;
    height: unset;
    display: unset;
    vertical-align: unset;
    border-left: unset;
    border-right: unset;
    &::after {
      border-right: 1px solid var(--gray-04);
      border-top: 1px solid var(--gray-04);
      content: "";
      display: block;
      height: 6px;
      position: absolute;
      right: 0px;
      top: -4px;
      transform: rotate(135deg);
      width: 6px;
    }
  }
}

/* チェック/ラジオのラベル */
.m-form-hs .hs-form-html .hsfc-RadioFieldGroup__Options label,
.m-form-hs .hs-form-html .hsfc-CheckboxFieldGroup__Options label {
  font-weight: 500 !important;
  color: var(--black) !important;
}

/* プレースホルダー */
.m-form-hs .hs-form-html .hsfc-DateInput.hsfc-DateInput--placeholder {
  font-weight: 400;
}

/* プログレスバー（テキスト非表示） */
.m-form-hs .hs-form-html .hsfc-ProgressBar__Text {
  display: none;
}

/* エラーメッセージ */
.m-form-hs .hs-form-html .hsfc-ErrorAlert {
  position: relative;
  color: var(--hsf-global-error__color);
}

/* 次/前ボタンの行高微調整 */
.m-form-hs .hs-form-html .button-item--previous,
.m-form-hs .hs-form-html .button-item--next {
  line-height: 1;
}

/* 入力フォーカス/状態 */
.m-form-hs .hs-form-html .hsfc-RadioInput:checked:after {
  background-color: var(--rbusinesscard-primary) !important;
}

.m-form-hs .hs-form-html input:focus {
  border-color: var(--gray-bg-01) !important;
  box-shadow: 0 0 3px var(--hsf-field-radio__border-color, var(--hsf-field-input__border-color, var(--hsf-default-field-radio__border-color)));
}

.m-form-hs .hs-form-html input[aria-required="true"][aria-invalid="true"] {
  background: var(--form-error-bg);
  border-color: var(--form-error-border);
  box-shadow: 0 0 3px var(--form-error-shadow);
}

/* バリッド時のチェック演出 */
.m-form-hs .hs-form-html input[aria-required="true"][aria-invalid="false"].hsfc-TextInput.valid-input {
  position: relative !important;
  &::after {
    content: "";
    position: absolute;
    top: 25px;
    right: 27px;
    width: 9px;
    height: 7px;
    border-left: 2px solid var(--white);
    border-bottom: 2px solid var(--white);
    transform: rotate(-45deg);
    z-index: 999;
    display: block;
  }
}

/* ===== Buttons ===== */
.m-form-hs .hs-form-html button[type="submit"] {
  background: var(--rbusinesscard-cta) !important;
  border: 3px solid var(--white);
  border-radius: 4px;
  border-radius: 1000px;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
  color: var(--white);
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  margin: 20px auto 0;
  max-width: 500px;
  outline: 0;
  padding: 22px 20px;
  position: relative;
  text-align: center;
  text-decoration: none;
  transition: all 0.3s ease;
  width: 100%;
  @media screen and (max-width: 840px) {
    font-size: 18px;
    padding: 14px 20px;
  }
  &:hover {
    background-color: var(--white) !important;
    border: 3px solid var(--rbusinesscard-cta);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.2);
    color: var(--rbusinesscard-cta);
    transform: scale(1.03);
  }
}

@media screen and (max-width: 840px) {
  .m-form-hs .hs-form-html button[type="submit"] {
    font-size: 18px;
    padding: 14px 20px;
  }
  .m-form-hs .hs-form-html .hsfc-NavigationRow__Buttons {
    flex-direction: column;
  }
  .m-form-hs .hs-form-html .hsfc-TextareaInput {
    padding: 10px;
    line-height: 1.2;
    min-height: 6em;
  }
  .m-form-hs .hs-form-html button.hsfc-Button.button-item--previous {
    width: 100%;
    max-width: 280px;
  }
}
/* Checkboxes */
.m-form-hs .hs-form-html .hsfc-CheckboxInput {
  border: 1px solid var(--form-placeholder);
  border-radius: 0;
  border-radius: 3px;
  height: 20px;
  width: 20px;
}

[data-hsfc-id="Renderer"] .hsfc-CheckboxInput:checked {
  background-color: var(--form-radio) !important;
}

/* Progress bar */
.m-form-hs .hs-form-html .hsfc-ProgressBar__Progress {
  background-color: var(--main-gray-bg02);
  border: 1px solid var(--main-gray-bg01);
}

/* ベース：ラベルにポップアップ用の疑似要素を仕込む（普段は非表示） */
[data-hsfc-id$="Field"] > .hsfc-FieldLabel {
  position: relative;
  &::after,
  &::before {
    position: absolute;
    right: 0;
    opacity: 0;
    visibility: hidden;
    /* displayではなくvisibilityで管理 */
    pointer-events: none;
    content: "";
    z-index: 100;
  }
  /* 吹き出し本体 */
  &::after {
    top: -15px;
    padding: 14px 15px;
    font-size: 12px;
    line-height: 1;
    color: var(--black);
    background: var(--rbusinesscard-accent);
    border-radius: 4px;
    left: 0;
    right: unset;
  }
  /* 三角 */
  &::before {
    bottom: -12px;
    left: 11px;
    width: 0;
    height: 0;
    border: 9px solid transparent;
    border-top-color: var(--rbusinesscard-accent);
  }
}

/* --- ここから対象別：末尾一致で安全に狙う --- */
/* Eメール */
[data-hsfc-id$="Field"]:has(> input[name$="0-1/email"], > input[name="email"]):focus-within > .hsfc-FieldLabel::after {
  content: "メールアドレスを入力してください";
  animation: popupStayFade 5s ease-out forwards;
}

[data-hsfc-id$="Field"]:has(> input[name$="0-1/email"], > input[name="email"]):focus-within > .hsfc-FieldLabel::before {
  animation: popupStayFade 5s ease-out forwards;
}

/* 電話 */
[data-hsfc-id$="Field"]:has(> input[name$="0-1/rcard_tell"], > input[name="0-1/rcard_tell"]):focus-within > .hsfc-FieldLabel::after {
  content: "日中繋がりやすい電話番号を記入してください";
  animation: popupStayFade 5s ease-out forwards;
}

[data-hsfc-id$="Field"]:has(> input[name$="0-1/rcard_tell"], > input[name="0-1/rcard_tell"]):focus-within > .hsfc-FieldLabel::before {
  animation: popupStayFade 5s ease-out forwards;
}

/* 会社名 */
[data-hsfc-id$="Field"]:has(> input[name$="0-1/rcard_company"], > input[name="0-1/rcard_company"]):focus-within > .hsfc-FieldLabel::after {
  content: "お勤め先の会社名を記入してください";
  animation: popupStayFade 5s ease-out forwards;
}

[data-hsfc-id$="Field"]:has(> input[name$="0-1/rcard_company"], > input[name="0-1/rcard_company"]):focus-within > .hsfc-FieldLabel::before {
  animation: popupStayFade 5s ease-out forwards;
}

/* 5秒表示→フェードアウト */
@keyframes popupStayFade {
  0% {
    opacity: 0;
    visibility: visible;
    transform: translateY(-4px);
  }
  10% {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  70% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}
