/**
 * MLT MACHINERY
 * TOPページ専用スライダー
 *
 * 表示仕様：
 * ・4:3画像
 * ・中央スライドを強調
 * ・左右のスライドを一部表示
 * ・画像下部へグラデーション
 * ・Gutenbergで保存した配置を公開画面へ反映
 * ・文字色、文字縁取り、グラデーション色を個別設定
 */

/* ================================================================
   全体
================================================================ */

.mlt-top-slider-section {
  width: 100%;
  margin: 0 0 48px;
  overflow: hidden;
}

.mlt-top-slider {
  position: relative;
  width: 100%;
  padding: 0 0 44px;
  overflow: hidden;
  background: #fff;
}

.mlt-top-slider .swiper-wrapper {
  align-items: flex-start;
}

.mlt-top-slider__slide {
  align-self: flex-start;
  height: auto !important;
  opacity: 0.58;
  transform: scale(0.9);
  transition:
    opacity 0.45s ease,
    transform 0.45s ease;
}

.mlt-top-slider__slide.swiper-slide-active {
  z-index: 2;
  opacity: 1;
  transform: scale(1);
}

.mlt-top-slider__content {
  width: 100%;
  height: auto;
}


/* ================================================================
   Gutenbergブロック共通調整
================================================================ */

.mlt-top-slider__content > * {
  margin-top: 0;
  margin-bottom: 0;
}

.mlt-top-slider__content .wp-block-cover {
  position: relative;
  display: block;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 4 / 3 !important;
  max-width: none !important;
  margin-right: 0 !important;
  margin-left: 0 !important;

  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #222;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
}

/*
 * 投稿本文用のalignfullを
 * TOPスライダー内では無効化する。
 */
.mlt-top-slider__content
  .wp-block-cover.alignfull {
  left: auto !important;
  width: 100% !important;
  max-width: none !important;
  margin-right: 0 !important;
  margin-left: 0 !important;
  transform: none !important;
}

.mlt-top-slider__content .wp-block-cover__image-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/*
 * Gutenberg標準の単色オーバーレイは使用せず、
 * 独自グラデーションへ統一する。
 */
.mlt-top-slider__content .wp-block-cover__background {
  opacity: 0 !important;
}


/* ================================================================
   下部グラデーション
================================================================ */

.mlt-top-slider__content .wp-block-cover::after {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  left: 0;
  height: 72%;
  background:
    linear-gradient(
      to bottom,
      rgba(
        var(--mlt-slide-gradient-rgb, 0, 0, 0),
        0
      ) 0%,
      rgba(
        var(--mlt-slide-gradient-rgb, 0, 0, 0),
        calc(
          var(--mlt-slide-gradient-opacity, 0.7) * 0.15
        )
      ) 25%,
      rgba(
        var(--mlt-slide-gradient-rgb, 0, 0, 0),
        calc(
          var(--mlt-slide-gradient-opacity, 0.7) * 0.75
        )
      ) 72%,
      rgba(
        var(--mlt-slide-gradient-rgb, 0, 0, 0),
        var(--mlt-slide-gradient-opacity, 0.7)
      ) 100%
    );
  content: "";
  pointer-events: none;
}


/* ================================================================
   カバー内レイアウト
================================================================ */

.mlt-top-slider__content .wp-block-cover__inner-container {
  position: absolute;
  z-index: 2;
  inset: 0;

  display: flex;
  width: auto;
  height: auto;
  margin: 0;

  padding:
    clamp(20px, 3vw, 42px)
    clamp(18px, 3.3vw, 46px)
    clamp(22px, 3.5vw, 48px);

  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mlt-top-slider__content .mlt-top-slide-content {
  width: 100%;
  max-width: 760px;
  margin-right: auto;
  margin-left: auto;
}


/* ================================================================
   見出し
================================================================ */

.mlt-top-slider__content h1,
.mlt-top-slider__content h2,
.mlt-top-slider__content h3 {
  margin-top: 0;
  margin-bottom: clamp(10px, 1.2vw, 14px);
  color: var(--mlt-slide-text-color, #ffffff);
  font-weight: 700;
  line-height: 1.35;

  /*
   * 文字縁取り
   */
  -webkit-text-stroke:
    var(--mlt-slide-text-stroke-width, 0px)
    var(--mlt-slide-text-stroke-color, #000000);

  paint-order: stroke fill;

  /*
   * 縁取りとは別に、ごく軽い影を残す。
   */
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.45);
}

.mlt-top-slider__content h2 {
  width: 100%;
  font-size: clamp(1.15rem, 2.3vw, 2.15rem);
}


/* ================================================================
   左右線付き見出し
================================================================ */

/*
 * 中央：
 * 見出しの左右へ線を表示
 */
.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
}

.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-center::before,
.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-center::after {
  display: block;
  flex: 1 1 auto;
  height: 1px;
  margin: 0;
  border: 0;
  background: currentColor;
  content: "";
  opacity: 0.85;
}

/*
 * 左：
 * 右側の線だけを表示
 */
.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(12px, 2vw, 24px);
}

.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-left::before {
  display: none;
}

.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-left::after {
  display: block;
  flex: 1 1 auto;
  height: 1px;
  margin: 0;
  border: 0;
  background: currentColor;
  content: "";
  opacity: 0.85;
}

/*
 * 右：
 * 左側の線だけを表示
 */
.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(12px, 2vw, 24px);
}

.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-right::before {
  display: block;
  flex: 1 1 auto;
  height: 1px;
  margin: 0;
  border: 0;
  background: currentColor;
  content: "";
  opacity: 0.85;
}

.mlt-top-slider__content
  .is-style-vk-heading-both_ends.has-text-align-right::after {
  display: none;
}


/* ================================================================
   説明文
================================================================ */

.mlt-top-slider__content p {
  max-width: 680px;
  margin-top: 0;
  margin-bottom: clamp(14px, 1.5vw, 18px);
  color: var(--mlt-slide-text-color, #ffffff);
  font-size: clamp(0.82rem, 1vw, 1rem);
  line-height: 1.7;

  /*
   * 文字縁取り
   */
  -webkit-text-stroke:
    var(--mlt-slide-text-stroke-width, 0px)
    var(--mlt-slide-text-stroke-color, #000000);

  paint-order: stroke fill;

  text-shadow:
    0 1px 6px rgba(0, 0, 0, 0.42);
}

/*
 * Gutenbergの配置設定に合わせて、
 * 最大幅680pxの段落自体も移動させる。
 */
.mlt-top-slider__content p.has-text-align-center {
  margin-right: auto;
  margin-left: auto;
}

.mlt-top-slider__content p.has-text-align-left {
  margin-right: auto;
  margin-left: 0;
}

.mlt-top-slider__content p.has-text-align-right {
  margin-right: 0;
  margin-left: auto;
}


/* ================================================================
   ボタン
================================================================ */

.mlt-top-slider__content .wp-block-buttons {
  width: 100%;
  margin-top: clamp(14px, 1.5vw, 20px);
}

.mlt-top-slider__content
  .wp-block-buttons.is-content-justification-left {
  justify-content: flex-start !important;
}

.mlt-top-slider__content
  .wp-block-buttons.is-content-justification-center {
  justify-content: center !important;
}

.mlt-top-slider__content
  .wp-block-buttons.is-content-justification-right {
  justify-content: flex-end !important;
}

.mlt-top-slider__content .wp-block-button {
  width: auto;
}

.mlt-top-slider__content .wp-block-button__link {
  display: inline-flex;
  width: auto;
  min-width: clamp(124px, 14vw, 180px);
  padding:
    clamp(8px, 1vw, 11px)
    clamp(14px, 1.8vw, 24px);

  border: 2px solid #f78008;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  background: #f78008;
  color: #fff;
  font-size: clamp(0.84rem, 1vw, 1rem);
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease,
    transform 0.25s ease;
}

.mlt-top-slider__content .wp-block-button__link:hover,
.mlt-top-slider__content .wp-block-button__link:focus {
  border-color: #fff;
  background: #fff;
  color: #222;
  transform: translateY(-2px);
}


/* ================================================================
   左右の非アクティブスライド
================================================================ */

.mlt-top-slider__slide:not(.swiper-slide-active)
  .wp-block-cover::before {
  position: absolute;
  z-index: 3;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  content: "";
  pointer-events: none;
}

.mlt-top-slider__slide:not(.swiper-slide-active)
  .wp-block-cover__inner-container {
  opacity: 0.7;
}


/* ================================================================
   ナビゲーション矢印
================================================================ */

.mlt-top-slider__prev,
.mlt-top-slider__next {
  top: calc(50% - 22px);
  width: 46px;
  height: 46px;
  margin-top: -23px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.24);
  transition:
    background-color 0.2s ease,
    opacity 0.2s ease,
    transform 0.2s ease;
}

.mlt-top-slider__prev {
  left: 18px;
}

.mlt-top-slider__next {
  right: 18px;
}

.mlt-top-slider__prev::after,
.mlt-top-slider__next::after {
  font-size: 18px;
  font-weight: 700;
}

.mlt-top-slider__prev:hover,
.mlt-top-slider__next:hover,
.mlt-top-slider__prev:focus,
.mlt-top-slider__next:focus {
  background: #f78008;
  transform: scale(1.06);
}

.mlt-top-slider__prev:focus-visible,
.mlt-top-slider__next:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}


/* ================================================================
   ページネーション
================================================================ */

.mlt-top-slider__pagination {
  bottom: 8px !important;
}

.mlt-top-slider__pagination .swiper-pagination-bullet {
  width: 9px;
  height: 9px;
  background: #999;
  opacity: 0.55;
}

.mlt-top-slider__pagination
  .swiper-pagination-bullet-active {
  width: 24px;
  border-radius: 8px;
  background: #f78008;
  opacity: 1;
}


/* ================================================================
   初期表示のちらつき防止
================================================================ */

.mlt-top-slider:not(.mlt-top-slider--ready) {
  visibility: hidden;
}

.mlt-top-slider.mlt-top-slider--ready {
  visibility: visible;
}


/* ================================================================
   スライド1件時
================================================================ */

.mlt-top-slider--single {
  max-width: 900px;
  margin-right: auto;
  margin-left: auto;
}

.mlt-top-slider--single .mlt-top-slider__slide {
  opacity: 1;
  transform: none;
}

.mlt-top-slider--single .mlt-top-slider__prev,
.mlt-top-slider--single .mlt-top-slider__next,
.mlt-top-slider--single .mlt-top-slider__pagination {
  display: none !important;
}


/* ================================================================
   タブレット
================================================================ */

@media (max-width: 991px) {
  .mlt-top-slider-section {
    margin-bottom: 38px;
  }

  .mlt-top-slider {
    padding-bottom: 40px;
  }

  .mlt-top-slider__prev {
    left: 10px;
  }

  .mlt-top-slider__next {
    right: 10px;
  }
}


/* ================================================================
   スマートフォン
================================================================ */

@media (max-width: 767px) {
  .mlt-top-slider-section {
    margin-bottom: 32px;
  }

  .mlt-top-slider {
    padding-bottom: 36px;
  }

  .mlt-top-slider__slide {
    opacity: 0.65;
    transform: scale(0.94);
  }

  .mlt-top-slider__slide.swiper-slide-active {
    opacity: 1;
    transform: scale(1);
  }

  .mlt-top-slider__content .wp-block-cover {
    border-radius: 6px;
  }

  .mlt-top-slider__content .wp-block-cover::after {
    height: 78%;
  }

  /*
   * スマホのみ説明文を最大2行に制限
   */
  .mlt-top-slider__content p {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .mlt-top-slider__prev,
  .mlt-top-slider__next {
    top: calc(50% - 18px);
    width: 36px;
    height: 36px;
    margin-top: -18px;
  }

  .mlt-top-slider__prev {
    left: 5px;
  }

  .mlt-top-slider__next {
    right: 5px;
  }

  .mlt-top-slider__prev::after,
  .mlt-top-slider__next::after {
    font-size: 14px;
  }

  .mlt-top-slider__pagination {
    bottom: 5px !important;
  }
}


/* ================================================================
   動きを抑える設定
================================================================ */

@media (prefers-reduced-motion: reduce) {
  .mlt-top-slider__slide,
  .mlt-top-slider__content .wp-block-button__link,
  .mlt-top-slider__prev,
  .mlt-top-slider__next {
    transition: none;
  }
}