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

/* ------------------------------
　　ボタン
------------------------------ */
.button {
  display: inline-block;
  box-sizing: border-box;
  padding: 0.75rem 2.25rem;
  color: global.$color-text-inverse;
  font-weight: bold;
  font-size: map.get(global.$font-scales, body-m);
  line-height: global.$line-height-base;
  text-align: center;
  background: global.$color-primary;
  border: 0;
  border-radius: global.$border-radius-md;
  transition: background-color 0.2s;

  &:any-link {
    color: global.$color-text-inverse;
    text-decoration: none;
  }

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

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

  &.is-block {
    width: 100%;
  }

  &.is-sm {
    padding: 0.5rem 1.5rem;
    font-size: map.get(global.$font-scales, body-s);
  }

  &.is-lg {
    display: inline-block;
    margin: auto;
    padding: 1rem 2.25rem;
  }

  &.is-xl {
    width: 18rem;
    max-width: 100%;
  }

  &.is-width-sm {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
  }

  &.is-width-lg {
    width: 18rem;
    max-width: 100%;
  }

  &.is-shadow {
    box-shadow: global.$elevation08;
  }

  &.is-shadow-shallow {
    box-shadow: global.$elevation02;

    &:hover {
      box-shadow: global.$elevation10;
    }
  }

  &.is-inverse {
    color: global.$color-text;
    background: global.$color-white;

    &:any-link {
      color: global.$color-text;
    }

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

  &.is-arrow {
    position: relative;

    &::after {
      position: absolute;
      top: 0;
      right: 16px;
      bottom: 0;
      display: inline-block;
      width: 8px;
      height: 12px;
      margin: auto;
      padding-right: 8px;
      padding-left: 8px;
      background-image: url("#{global.$root-theme-img}arrow-border-white.svg");
      background-repeat: no-repeat;
      background-position: center;
      background-size: contain;
      content: "";
    }
  }

  &.is-arrow.is-inverse {
    &::after {
      background-image: url("#{global.$root-theme-img}arrow-border-black.svg");
    }
  }

  &.is-danger {
    background: global.$color-error;
  }

  &.is-bordered {
    color: global.$color-text;
    background: transparent;
    border: global.$border-width-sm solid global.$color-gray40;

    &:any-link {
      color: global.$color-text;
    }

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

  &.is-bordered-danger {
    color: global.$color-error;
    background: none;
    border: 1px solid global.$color-error;

    &:hover {
      background: rgb(201 45 45 / 8%);
    }
  }

  &.is-rounded {
    border-radius: global.$border-radius-round;
  }
}

@media (min-width: acms.$breakpoint-md-min) {
  .button {
    &.is-send {
      min-width: 17.5rem;
    }

    &.is-xl {
      min-width: 22rem;
      padding: 1rem;
      font-size: map.get(global.$font-scales, heading-ss);
    }
  }
}

.button-read-more {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  color: currentcolor;
  font-weight: bold;
  font-size: map.get(global.$font-scales, body-m);
  text-decoration: none;

  &::before {
    position: absolute;
    right: 0;
    bottom: -0.25rem;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: global.$color-secondary;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
    content: "";
  }

  &::after {
    @include global.arrow-circle($size: ss,$color-bg:global.$color-secondary,$color-line:white);

    display: inline-block;
    margin: 0 0 0 0.5rem;
    content: "";
  }

  @media (hover: hover) {
    &:hover {
      &::before {
        transform: scaleX(1);
      }
    }
  }
}

.button-wrap {
  max-width: 17.5rem;
  margin: 2.5rem auto 0;

  .button.is-block + .button.is-block {
    margin-top: 1rem;
  }
}

.icon-button {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  padding: 0.375rem 0.75rem;
  color: global.$color-text;
  font-weight: bold;
  font-size: 1rem;
  line-height: 1.8;
  text-decoration: none;
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
  appearance: none;

  > .acms-icon {
    font-size: 20px;
  }

  @media (hover: hover) {
    &:hover {
      background: global.$color-gray10;
    }
  }

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

    @media (hover: hover) {
      &:hover {
        background-color: global.$color-primary-hover;
      }
    }
  }

  &.is-text-primary {
    color: global.$color-text-primary;
    background-color: global.$color-white;

    @media (hover: hover) {
      &:hover {
        background: global.$color-gray10;
      }
    }
  }

  &.is-column {
    flex-flow: column;
    justify-content: center;
    font-size: 0.625rem;
    line-height: 1;

    > .acms-icon {
      padding-right: 0;
      padding-bottom: 8px;
      font-size: 18px;
    }
  }
}
