/* =========================================
   1. レイアウトと背景色の設定
========================================= */
/* 左右の余白を固定するための外枠 */
.carousel-wrapper {
  width: 100%;
  background-color: #fff6ed;
  /* 左右の余白の色 */
  display: flex;
  justify-content: center;
  /* カルーセルを中央に配置 */
}

/* カルーセル全体のコンテナ（ここがスライドが見える範囲＝画像範囲になります） */
.carousel-container {
  position: relative;
  width: 100%;

  /* PC用画像の比率（3:1）を厳密に指定 */
  aspect-ratio: 3 / 1;

  /* 高さが700pxでストップするため、幅も 700px × 3 = 2100px で完全にストップさせる */
  max-width: 2100px;
  max-height: 700px;

  overflow: hidden;
  /* この枠の外にはみ出たスライドを隠す */
  background-color: transparent;
  touch-action: pan-y;
}

/* スマホ表示（640px以下） */
@media screen and (max-width: 640px) {
  .carousel-container {
    /* スマホ用画像の比率 */
    aspect-ratio: 800 / 700;
    max-height: none;
    /* スマホでは高さいっぱいに広げる */
    max-width: 100%;
  }
}

/* =========================================
   2. スライドとアニメーションの制御 (フェード＆スライド混用版)
========================================= */
.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.carousel-track:active {
  cursor: grabbing;
}

.carousel-track.is-animating {
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.carousel-slide {
  min-width: 100%;
  height: 100%;
  background-color: transparent;
}

/* 1スライド内の2枚の画像を重ねるためのコンテナ */
.slide-layers {
  position: relative;
  width: 100%;
  height: 100%;
}

/* 各画像ラッパー（絶対配置でピッタリ重ねる） */
.img-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #e60012;
}

/* 1枚目は常に下敷き（z-index: 1） */
.layer-1 {
  z-index: 1;
}

/* 2枚目（z-index: 2 で上に被さり、デフォルトは透明） */
.layer-2 {
  opacity: 0;
  transition: opacity 0.8s ease;
  /* 1枚目→2枚目のフェード速度 */
  z-index: 2;
}

/* JSによってクラスが付与されたら2枚目がフェードイン */
.carousel-slide.show-layer-2 .layer-2 {
  opacity: 1;
}

/* 
  スライド遷移時（横滑り時）に赤色(#e60012)を出すためのフィルター
  ※重ねた画像全体(slide-layers)に対して1つだけかけます
*/
.slide-layers::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #e60012;
  opacity: 0.8;
  pointer-events: none;
  z-index: 5;
}

.carousel-track.is-animating .slide-layers::after {
  transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.carousel-slide.is-active .slide-layers::after {
  opacity: 0;
}

/* =========================================
   3. 画像の表示設定
========================================= */
.img-pc,
.img-sp {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 枠にピッタリ合わせる */
  vertical-align: bottom;
  transition: opacity 0.5s ease;
  -webkit-user-drag: none;
  user-select: none;
}

/* デフォルト（PC表示） */
.img-pc {
  position: relative;
  opacity: 1;
}

.img-sp {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
}

/* スマホ表示（640px以下） */
@media screen and (max-width: 640px) {
  .img-pc {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
  }

  .img-sp {
    position: relative;
    opacity: 1;
    pointer-events: auto;
  }
}

/* =========================================
   4. ページネーション（ドット）
========================================= */
.carousel-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  /* PCでのドット同士の間隔（少し広め） */
  z-index: 10;
  pointer-events: none;
  /* コンテナ側のフリックを邪魔しないように */
}

/* PC用のドットサイズ（少し大きめ） */
.dot {
  width: 16px;
  height: 16px;
  background-color: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  pointer-events: auto;
}

.dot:hover {
  background-color: rgba(255, 255, 255, 0.8);
}

.dot.is-active {
  background-color: #ffffff;
  transform: scale(1.2);
}

/* スマホ表示（640px以下）のページネーション調整 */
@media screen and (max-width: 640px) {
  .carousel-dots {
    bottom: 12px;
    /* SPでは画像の下端に少し近づける */
    gap: 10px;
    /* SPではドット同士の間隔を少し狭める */
  }

  /* SP用のドットサイズ（少し小さめ） */
  .dot {
    width: 10px;
    height: 10px;
  }
}