/* ==========================================================================
   Before-After Slider
   ========================================================================== */

/* ------------------------------------------------------------------
   コンテナ
   ------------------------------------------------------------------ */
.hd-ba-slider {
  position: relative;
  overflow: hidden;
  width: 100%;
  /* 01 と 02 で画像のアスペクト比が違ってもスライダー本体のサイズが揃うよう
     コンテナ側でアスペクト比を固定し、画像は object-fit: cover で表示する */
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ------------------------------------------------------------------
   Before 画像（背景レイヤー・全面表示）
   ------------------------------------------------------------------ */
.hd-ba-slider__before {
  display: block;
  width: 100%;
  height: 100%;
}

.hd-ba-slider__before img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none; /* ドラッグ中の img drag を無効化 */
}

/* ------------------------------------------------------------------
   After 画像（前景レイヤー・左からクリップ）
   --hd-ba-clip カスタムプロパティを JS で書き換えてクリップ幅を制御
   ------------------------------------------------------------------ */
.hd-ba-slider__after {
  position: absolute;
  inset: 0;
  /* clip-path で右端を --hd-ba-clip に合わせてトリム */
  clip-path: inset(0 calc(100% - var(--hd-ba-clip, 50%)) 0 0);
  overflow: hidden; /* Safari clip-path + overflow のフォールバック */
}

.hd-ba-slider__after img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   ラベル（Before / After）
   ------------------------------------------------------------------ */
.hd-ba-slider__label {
  position: absolute;
  bottom: 12px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-radius: 4px;
  pointer-events: none;
}

.hd-ba-slider__label--before {
  right: 12px;
}

.hd-ba-slider__label--after {
  left: 12px;
}

/* ------------------------------------------------------------------
   ハンドル（縦線 + ボタン）
   ------------------------------------------------------------------ */
.hd-ba-slider__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%; /* JS 上書き前の初期位置 */
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  /* タッチターゲットを広げてタップしやすくする */
  width: 44px;
}

/* 縦線 */
.hd-ba-slider__line {
  position: absolute;
  inset: 0 auto;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}

/* ドラッグボタン */
.hd-ba-slider__btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: ew-resize;
  padding: 0;
  /* ボタン自体はポインタキャプチャを親ハンドルが担うため */
  pointer-events: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hd-ba-slider__handle:focus-visible .hd-ba-slider__btn,
.hd-ba-slider__handle:active .hd-ba-slider__btn {
  transform: scale(1.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  outline: 3px solid #4a90d9;
  outline-offset: 2px;
}

/* SVGアイコン */
.hd-ba-slider__btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #333;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------
   複数スライダーを並べるグリッド（single-works.php 内）
   ------------------------------------------------------------------ */
.hd-ba-slider-group {
  display: grid;
  gap: 32px;
}

@media (min-width: 768px) {
  .hd-ba-slider-group {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  }
}

/* ------------------------------------------------------------------
   スライダーアイテム（グループ内の個別ラッパー）
   ------------------------------------------------------------------ */
.hd-ba-slider-item {
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------
   キャプション
   ------------------------------------------------------------------ */
.hd-ba-slider-item__caption {
  margin-top: 8px;
  font-size: 0.875rem;
  color: #555;
  text-align: center;
}

/* ==========================================================================
   トップページ Before/After セクション専用
   front-page.php の hd-front-ba* ラッパーから使用
   ========================================================================== */
.hd-front-ba {
  padding: 5rem 0;
  background: var(--hd-white, #ffffff);
}

@media (min-width: 768px) {
  .hd-front-ba {
    padding: 6rem 0;
  }
}

.hd-front-ba__note {
  margin: 1rem 0 2.5rem;
  font-size: 0.85rem;
  color: rgba(47, 52, 64, 0.65);
  text-align: center;
}

.hd-front-ba__item {
  max-width: 880px;
  margin: 0 auto 2.5rem;
}

.hd-front-ba__item:last-child {
  margin-bottom: 0;
}

.hd-front-ba__num {
  display: inline-block;
  margin-right: 0.6em;
  font-family: var(--hd-font-en, serif);
  font-weight: 700;
  color: var(--hd-warm, #c19a6b);
  letter-spacing: 0.05em;
}
