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

/* ------------------------------
　　カード
------------------------------ */
.card-list {
  padding: 0;
  margin: 0;
  margin-bottom: 1.25rem;
  list-style: none;
}

.card-list.-carousel {
  display: flex !important; // splideの設定を打ち消し
  flex-wrap: nowrap;
  gap: var(--theme-gap-x);

  .card-item {
    width: 16rem;
    margin-bottom: 0;
  }
}

.card-item {
  box-sizing: border-box;
  display: flex;
  margin: 0 0 2rem;
}

.card-item-inner {
  display: flex;
}

.card {
  display: flex;
  width: 100%;
}

.card-link {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  text-decoration: none;

  @include global.link-card(global.$color-text);

  @media (hover: hover) {
    &:hover {
      .card-img {
        transform: scale(1.2);
      }
    }

    &:hover {
      .card-read-more {
        &::before {
          transform: scaleX(1);
        }
      }
    }
  }
}

.card-img-wrap {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin: 0 0 1.25rem;
  overflow: hidden;
  border-radius: global.$border-radius-lg;
}

.card-img {
  width: 100%;
  transition: 0.4s 0.2s ease-out;
  will-change: transform;
}

.card-title,
.#{acms.$entry-class} .card-title {
  margin: 0 0 1rem;
  font-size: map.get(global.$font-scales, heading-ss);
  line-height: global.$line-height-base;
  color: global.$color-black;
}

.card-date {
  display: inline-block;
  margin: 0 1em 0.25rem 0;
  font-size: map.get(global.$font-scales, body-s);
  color: global.$color-gray90;
}

.card-badge-news {
  margin: 0 0 0 0.5rem;
  font-size: map.get(global.$font-scales, body-s);
  font-weight: bold;
  line-height: global.$line-height-ss;
}

.card-text,
.#{acms.$entry-class} .card-text {
  margin: 0 0 1rem;
  font-size: map.get(global.$font-scales, body-m);
  line-height: global.$line-height-lg;
}

.card-text + .card-tag {
  margin-top: -0.5rem;
}

.card-action {
  margin-top: auto;
}

.card-read-more,
.#{acms.$entry-class} .card-read-more {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  font-size: map.get(global.$font-scales, body-m);
  font-weight: bold;

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

  &::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: "";
  }
}

.card-footer {
  padding: 1rem 0;
  margin-top: 2rem;
  border-top: global.$border-width-sm solid global.$color-gray30;
}

.card-author {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: map.get(global.$font-scales, body-m);
}

.card-author-img,
.js-carousel-card .card-author-img {
  margin: 0 1rem 0 0;
  border-radius: global.$border-radius-circle;
}

@include acms.media-breakpoint-up(md) {
  .card-img-wrap {
    margin: 0 0 1rem;

    .card.is-lg & {
      margin: 0 0 2rem;
    }

    .card-read-more,
    .#{acms.$entry-class} .card-read-more {
      font-size: map.get(global.$font-scales, body-m);

      &::before {
        bottom: -0.5rem;
      }
    }
  }

  .card-title {
    margin: 0 0 1rem;
    font-size: map.get(global.$font-scales, heading-ss);

    .card.is-lg & {
      font-size: map.get(global.$font-scales, heading-ss);
    }
  }

  .card-text {
    margin: 0 0 1.5rem;
    font-size: map.get(global.$font-scales, body-m);

    .card.is-lg & {
      margin: 0 0 2rem;
    }
  }
}

@include acms.media-breakpoint-up(lg) {
  .card-list {
    margin-bottom: 2rem;
  }

  .card-list.-carousel {
    flex-wrap: wrap;

    .card-item {
      // 列数を4列にする
      flex: 0 0 calc((100% - (var(--theme-gap-x) * 3)) / 4);
      max-width: calc((100% - (var(--theme-gap-x) * 3)) / 4);
    }
  }
}

/* ボーダー付きカード */
.card-bordered-list {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 0 calc(var(--theme-gap-x) / -2);
  list-style: none;
}

.card-bordered-item {
  display: flex;
  margin: 0 0 2rem;
}

.card-bordered {
  width: 100%;
}

.card-bordered-link {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-decoration: none;
  border-radius: global.$border-radius-lg;
  box-shadow: global.$elevation02;

  @include global.link-card(global.$color-text);

  @media (hover: hover) {
    &:hover {
      box-shadow: global.$elevation10;

      .card-bordered-img {
        transform: scale(1.2);
      }

      .card-bordered-read-more {
        &::before {
          transform: scaleX(1);
        }
      }
    }
  }
}

.card-bordered-img-wrap {
  margin: 0;
  overflow: hidden;
  border-radius: global.$border-radius-lg global.$border-radius-lg 0 0;
}

.card-bordered-img {
  width: 100%;
  transition: 0.4s 0.2s ease-out;
  will-change: transform;
}

.card-bordered-title,
.#{ acms.$entry-class } .card-bordered-title {
  margin: 0 0 1rem;
  font-size: map.get(global.$font-scales, body-m);
  line-height: global.$line-height-sm;
  color: global.$color-black;
}

.card-bordered-read-more,
.#{acms.$entry-class} .card-bordered-read-more {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  font-size: map.get(global.$font-scales, body-m);
  font-weight: bold;

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

  &::after {
    margin: 0 0 0 0.5rem;
    content: "";

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

.card-bordered-text-inline {
  display: flex;
  align-items: center;
  padding: 1rem;

  .card-bordered-title,
  .#{acms.$entry-class} .card-bordered-title,
  .card-bordered-text,
  .card-bordered-read-more {
    margin: 0;
  }

  .card-bordered-read-more {
    margin-left: auto;
  }
}

@include acms.media-breakpoint-up(md) {
  .card-bordered-text-inline {
    display: flex;
    padding: 1.5rem;
  }

  .card-bordered-title,
  .#{ acms.$entry-class } .card-bordered-title {
    margin: 0;
    font-size: map.get(global.$font-scales, heading-ss);
  }

  .card-bordered-text {
    margin: 0 0 2rem;
    font-size: map.get(global.$font-scales, body-m);
  }
  .card-bordered-read-more,
  .#{acms.$entry-class} .card-bordered-read-more {
    font-size: map.get(global.$font-scales, body-m);

    &::before {
      bottom: -0.5rem;
    }
  }
}

@include acms.media-breakpoint-up(lg) {
  .card-bordered-text-inline {
    padding: 2rem;
  }
}
