/* =============================================
   Masonry Gallery — エフェクト定義
   レイアウト（grid-template など）は HTML 側で自由に書く
   ============================================= */

.masonry-section {
  padding: 60px 40px 100px;
}

/* グリッドコンテナ：基本設定のみ。カラム構成は自分で上書きする */
.masonry-grid {
  max-width: 1200px;
  margin: 0 auto;
}

/* -------------------------------------------------
   アイテム共通
   position: relative → キャプション（absolute）の基点
   overflow: hidden  → パララックスで画像がはみ出ないよう隠す
   ------------------------------------------------- */
.masonry-item {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  /* 画像ロード前に表示するプレースホルダー背景 */
  background: linear-gradient(135deg, #2a1f3d 0%, #1a1a2e 50%, #2d1b4e 100%);

  /* ---- Stage 1: ボックスが下からスライドアップ ---- */
  transform: translateY(80px);
  opacity: 0;
  will-change: transform, opacity;
}

.masonry-item.is-visible {
  transform: translateY(0);
  opacity: 1;
  transition:
    transform 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.6s ease;
}

/* -------------------------------------------------
   画像ラッパー：Stage 2 の遅延フェード＋スライドアップ
   img とは別要素にすることでパララックスと干渉しない
   ------------------------------------------------- */
.masonry-img-wrap {
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.8s ease 0.55s,
    transform 1s cubic-bezier(0.22, 1, 0.36, 1) 0.55s;
}

.masonry-item.is-visible .masonry-img-wrap {
  opacity: 1;
  transform: translateY(0);
}

/* -------------------------------------------------
   画像
   --parallax: JS がスクロールに応じてセットする縦オフセット
   scale(1.15): オフセットで端が見えないよう少し大きくしておく
   ------------------------------------------------- */
.masonry-item img {
  --parallax: 0px;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: translateY(var(--parallax)) scale(1.3);
  /* transitionをhoverデバイス限定にしてパララックス更新と分離 */
}

/* ホバーズーム：マウスがある端末のみ */
@media (hover: hover) {
  .masonry-item img {
    transition: transform 0.75s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  .masonry-item:hover img {
    transform: translateY(var(--parallax)) scale(1.2);
    transition: transform 0.6s ease;
  }
}

/* a タグリセット */
a.masonry-item {
  display: block;
  text-decoration: none;
  color: inherit;
}

/* -------------------------------------------------
   ホバーオーバーレイ＋キャプション
   ------------------------------------------------- */
.masonry-caption {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
  background: rgba(0, 0, 0, 0);
  transition: background 0.35s ease;
  pointer-events: none;
}

.masonry-item:hover .masonry-caption {
  background: rgba(0, 0, 0, 0.52);
}

.masonry-caption__title,
.masonry-caption__sub {
  margin: 0;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.3s ease,
    transform 0.35s ease;
}

.masonry-caption__title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.masonry-caption__sub {
  font-size: 1.1rem;
  font-weight: 400;
  margin-top: 4px;
  opacity: 0;
  transition:
    opacity 0.3s ease 0.05s,
    transform 0.35s ease 0.05s;
}

.masonry-item:hover .masonry-caption__title,
.masonry-item:hover .masonry-caption__sub {
  opacity: 1;
  transform: translateY(0);
}
