@use "sass:map";
@use "global/acms-common" as acms;
@use "global/common" as global;

/* ------------------------------
　　お問い合わせ
------------------------------ */

/* ステップ
------------------------------ */
.form-step {
  display: flex;
  margin: 0 0 1.5rem;
  padding: 0;

  /* カウンターの設定 */
  counter-reset: mailStep;
}

.form-step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0 0.5rem;
  color: global.$color-text;
  font-weight: bold;
  font-size: map.get(global.$font-scales, body-m);
  list-style: none;

  &::before {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0 0 0.5rem;
    color: global.$color-text;
    line-height: global.$line-height-lg;
    background: global.$color-gray10;
    border-radius: 50%;
    content: counter(mailStep);

    /* カウンターの設定 */
    counter-increment: mailStep;
  }

  &.is-current {
    &::before {
      color: global.$color-text-inverse;
      background: global.$color-primary;
    }
  }

  &:not(:last-child) {
    margin: 0 1.25rem 0 0;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .form-step-item {
    flex-direction: row;
    justify-content: center;
    padding: 1rem 0;
    font-size: map.get(global.$font-scales, heading-ss);

    &::before {
      width: 2.5rem;
      height: 2.5rem;
      margin: 0 0.5rem 0 0;
      font-size: map.get(global.$font-scales, heading-ss);
    }

    &:not(:last-child) {
      margin: 0 2rem 0 0;
    }
  }
}

@media screen and (max-width: acms.$breakpoint-md-max) {
  .form-step {
    justify-content: center;
  }
}

/* フォームレイアウト
------------------------------ */
.form-group-list {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;

  &.is-confirm {
    padding: 0 0.5rem;
  }
}

.form-group-inner {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  margin: 0;
  padding: 0;
}

.form-group {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  margin: 0 0 2rem;
  padding: 0;
}

.form-label {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 0.5rem;
  font-weight: bold;
  text-align: left;
}

.form-control {
  display: block;
  box-sizing: border-box;
  width: 100%;
  line-height: global.$line-height-lg;
}

.form-button-group {
  .button {
    margin: 0;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .form-label {
    vertical-align: top;
  }
}

.form-button-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 2rem 0 0;
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .form-button-group {
    flex-direction: row;
    margin: 2.5rem 0 0;
  }

  .form-button:not(:last-child) {
    margin: 0 1.25rem 0 0;
  }
}

@media screen and (max-width: acms.$breakpoint-md-max) {
  .form-button {
    width: 100%;
    margin: 0 0 1rem;

    .button {
      width: 100%;
    }
  }

  .form-button-return {
    order: 1;
  }
}

/* ラベル
------------------------------ */
.label-required {
  margin: 0 0 0 0.25rem;
  padding: 0.25rem 0.5rem;
  color: #fff;
  font-size: map.get(global.$font-scales, body-s);
  vertical-align: middle;
  background: global.$color-error;
  border-radius: global.$border-radius-sm;

  &:first-child {
    margin: 0 0.25rem 0 0;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .label-required {
    margin: 0 0 0 0.5rem;

    &:first-child {
      margin: 0 0.5rem 0 0;
    }
  }
}

.label-optional {
  margin: 0 0 0 0.25rem;
  padding: 0.25rem 0.5rem;
  color: global.$color-text;
  font-size: map.get(global.$font-scales, body-s);
  vertical-align: middle;
  background: global.$color-gray40;
  border-radius: global.$border-radius-sm;

  &:first-child {
    margin: 0 0.25rem 0 0;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .label-optional {
    margin: 0 0 0 0.5rem;

    &:first-child {
      margin: 0 0.5rem 0 0;
    }
  }
}

/* フォーム要素
------------------------------ */
.form-group {
  display: block;
  border: 0;

  select {
    &[required]:required {
      border: global.$border-width-sm solid global.$color-error;
    }

    &.focused:invalid {
      border: global.$border-width-sm solid global.$color-error;
    }

    &[required]:valid {
      border: global.$border-width-sm solid global.$color-gray40;
    }
  }

  input[type="text"],
  input[type="password"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="week"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  textarea,
  select {
    color: global.$color-text;
    border: 1px solid rgb(0 0 0 / 20%);

    &[required]:required {
      background-color: global.$color-gray10;
    }

    &.focused:invalid,
    &.invalid {
      background-color: global.$color-gray10;
      border-color: global.$color-error;
      box-shadow: global.$box-shadow-error, acms.$acms-form-box-shadow;
    }

    &[required]:valid {
      background-color: global.$color-gray10;
    }

    &:focus {
      background-color: global.$color-gray10;
      border-color: global.$color-focus;
      box-shadow: global.$box-shadow-focus, acms.$acms-form-box-shadow;
    }
  }

  // 入力欄をスマホのサイズのままにする
  input[type="text"],
  input[type="password"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="week"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"] {
    box-sizing: border-box;
    padding: 0.75rem;
    font-size: map.get(global.$font-scales, body-m);
    line-height: global.$line-height-base;
    border: global.$border-width-sm solid rgb(0 0 0 / 20%);
    border-radius: global.$border-radius-sm;
  }

  textarea {
    box-sizing: border-box;
    padding: 0.75rem;
    font-size: map.get(global.$font-scales, body-m);
    border-radius: global.$border-radius-sm;
  }

  select {
    box-sizing: border-box;
    min-height: 3rem;
    padding: 0.75rem  3rem 0.75rem 1rem;
    font-size: map.get(global.$font-scales, body-m);
    line-height: global.$line-height-base;
    vertical-align: top;
    background-color: global.$color-gray10;
    border-radius: global.$border-radius-sm;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .form-group {
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"] {
      padding: 0.75rem;
    }

    textarea {
      padding: 0.75rem;
    }
  }
}

.form-checkbox-only {
  display: block;
  margin: 0;
  padding: 0.75rem 1rem;
  line-height: 1.5;
  background: global.$color-gray20;
  border: global.$border-width-sm solid rgb(0 0 0 / 10%);
  border-radius: global.$border-radius-sm;

  &:hover {
    background: global.$color-gray30;
  }

  &:focus-within {
    background-color: global.$color-gray10;
    border-color: global.$color-focus;
    box-shadow: global.$box-shadow-focus, acms.$acms-form-box-shadow;
  }
}

.form-checkbox-only-label {
  vertical-align: middle;

  a:link,
  a:hover,
  a:visited,
  a:active,
  a:focus {
    text-decoration: none;
    border-bottom: 1px dashed;
  }
}

/* 検索フォーム
------------------------------ */

.form-search {
  .form-search-action {
    display: flex;
    width: 100%;

    .button {
      margin-left: -1px;
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }
  }

  input.form-search-input {
    flex: 1 1 auto;
    box-sizing: border-box;
    height: 3rem;
    padding: 0.5rem;
    font-size: map.get(global.$font-scales, body-m);
    background: global.$color-gray10;
    border: global.$border-width-sm solid global.$color-gray40;
    border-radius: global.$border-radius-md;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    transition: background-color 0.25s ease;
    appearance: none;

    &:hover {
      background: global.$color-white;
      border-color: global.$color-gray50;
    }

    &:focus {
      background: global.$color-white;
      border-color: acms.$acms-form-focus-border-color;
      outline: none;
      box-shadow: global.$box-shadow-focus, acms.$acms-form-box-shadow;
    }
  }

  .form-search-side-button {
    display: flex;
    white-space: nowrap;
  }

  .form-search-button {
    padding: 0.75rem 1rem;
  }

  @media screen and (min-width: acms.$breakpoint-md-min) {
    input.form-search-input {
      height: 4rem;
      padding: 1rem 1.25rem;
      font-size: map.get(global.$font-scales, heading-ss);
    }

    .form-search-button {
      padding: 0.75rem 2rem;
    }
  }
}

/* ヘルパーテキスト
------------------------------ */
.form-helper-text {
  margin: 0.5rem 0;
  color: global.$color-text-side;
  font-size: map.get(global.$font-scales, body-s);
}

/* バリデーター
------------------------------ */
.form-group {
  .valid-mark {
    display: none;
  }

  .valid-mark.valid {
    display: inline;
    float: right;
    color: #5cb85c;
  }

  .invalid {
    border-color: global.$color-error;
    box-shadow: global.$box-shadow-error, acms.$acms-form-box-shadow;
  }
}

.form-error-text {
  margin: 0.5rem 0;
  color: global.$color-error;
  font-size: map.get(global.$font-scales, body-s);

  .form-helper-text + .validator-result-0 & {
    margin-top: 0;
  }
}

.transaction-notice-,
.v-result-,
.v-result-1,
.validator-result-,
.validator-result-1 {
  display: none;
}

/* メッセージ
------------------------------ */
.form-message {
  margin: 0 0 3rem;
}

.form-message-back {
  text-align: center;
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .form-message {
    margin: 0 0 4rem;
  }
}
