/* ════════════════════════════════
   Lunaria: ギャラリーブロック
   ════════════════════════════════ */

.pb-gallery {
  box-sizing: border-box;
}

/* 見出し */
.pb-gallery__heading-wrap {
  text-align: center;
  margin-bottom: 32px;
}
.pb-gallery__heading {
  font-family: var(--pb-font-serif, serif);
  font-size: clamp(18px, 2.5vw, 26px);
  font-weight: 600;
  color: var(--pb-text, #332518);
  letter-spacing: .06em;
  display: inline-flex;
  align-items: center;
  gap: 16px;
}
.pb-gallery__heading::before,
.pb-gallery__heading::after {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: var(--pb-taupe, #C9B99A);
}

/* 共通画像 */
.pb-gallery__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s cubic-bezier(0.25,0.46,0.45,0.94),
              filter .4s ease;
}
.pb-gallery__link {
  display: block;
  overflow: hidden;
  position: relative;
  cursor: zoom-in;
}
.pb-gallery__link:hover .pb-gallery__img {
  transform: scale(1.05);
  filter: brightness(1.05);
}

/* キャプション */
.pb-gallery__caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 12px 10px;
  background: linear-gradient(to top, rgba(20,10,5,.6) 0%, transparent 100%);
  font-family: var(--pb-font-sans, sans-serif);
  font-size: 11px;
  color: #fff;
  letter-spacing: .06em;
  pointer-events: none;
}

/* ════════════════════════════════
   A. マソンリー
   ════════════════════════════════ */
.pb-gallery--masonry .pb-gallery__masonry {
  column-fill: balance;
}
.pb-gallery--masonry .pb-gallery__item--masonry {
  break-inside: avoid;
  position: relative;
  overflow: hidden;
  border-radius: 3px;
}
.pb-gallery--masonry .pb-gallery__img {
  height: auto;
  width: 100%;
  display: block;
}

/* ════════════════════════════════
   B. 均等グリッド
   ════════════════════════════════ */
.pb-gallery--grid .pb-gallery__grid {
  display: grid;
}
.pb-gallery--grid .pb-gallery__item {
  aspect-ratio: 3/2;
  overflow: hidden;
  border-radius: 3px;
  position: relative;
}

/* ════════════════════════════════
   C. フルブリード
   ════════════════════════════════ */
.pb-gallery--fullbleed .pb-gallery__fullbleed {
  display: grid;
}
.pb-gallery--fullbleed .pb-gallery__item {
  aspect-ratio: 3/2;
  overflow: hidden;
  position: relative;
}
.pb-gallery--fullbleed .pb-gallery__img {
  transition: transform .6s ease, filter .5s ease;
}

/* ════════════════════════════════
   D. 額装風（フレーム）
   ════════════════════════════════ */
.pb-gallery--frame .pb-gallery__frame-grid {
  display: grid;
}
.pb-gallery--frame .pb-gallery__frame-item {
  background: var(--pb-warm-white, #FFFEFB);
  padding: 10px 10px 36px;
  box-shadow: 0 4px 20px rgba(60,30,10,.1), 0 1px 4px rgba(60,30,10,.07);
  transition: transform .3s ease, box-shadow .3s ease;
}
.pb-gallery--frame .pb-gallery__frame-item:hover {
  transform: translateY(-4px) rotate(0.3deg);
  box-shadow: 0 10px 32px rgba(60,30,10,.16);
}
.pb-gallery--frame .pb-gallery__frame {
  aspect-ratio: 3/2;
  overflow: hidden;
}
.pb-gallery--frame .pb-gallery__link {
  cursor: zoom-in;
}
.pb-gallery--frame .pb-gallery__frame-caption {
  font-family: var(--pb-font-sans, sans-serif);
  font-size: 11px;
  color: var(--pb-text-sub, #7A6550);
  text-align: center;
  margin: 10px 0 0;
  letter-spacing: .04em;
}

/* ════════════════════════════════
   E. 大小混在（マガジン）
   ════════════════════════════════ */
.pb-gallery--magazine .pb-gallery__magazine {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 200px;
}
.pb-gallery--magazine .pb-gallery__magazine-item {
  overflow: hidden;
  position: relative;
}
.pb-gallery--magazine .pb-gallery__magazine-item.is-large {
  grid-column: span 2;
  grid-row: span 2;
}
.pb-gallery--magazine .pb-gallery__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ════════════════════════════════
   F. スクロールフェード
   ════════════════════════════════ */
.pb-gallery--fade .pb-gallery__fade-grid {
  display: grid;
}
.pb-gallery--fade .pb-gallery__fade-item {
  aspect-ratio: 3/2;
  overflow: hidden;
  border-radius: 3px;
  position: relative;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
}
.pb-gallery--fade .pb-gallery__fade-item.is-visible {
  opacity: 1;
  transform: translateY(0);
}
/* 遅延でずらす */
.pb-gallery--fade .pb-gallery__fade-item:nth-child(2) { transition-delay: .08s; }
.pb-gallery--fade .pb-gallery__fade-item:nth-child(3) { transition-delay: .16s; }
.pb-gallery--fade .pb-gallery__fade-item:nth-child(4) { transition-delay: .24s; }
.pb-gallery--fade .pb-gallery__fade-item:nth-child(5) { transition-delay: .32s; }
.pb-gallery--fade .pb-gallery__fade-item:nth-child(6) { transition-delay: .40s; }
.pb-gallery--fade .pb-gallery__fade-item:nth-child(n+7) { transition-delay: .48s; }

/* ════════════════════════════════
   ライトボックス
   ════════════════════════════════ */
.pb-gallery-lb {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}
.pb-gallery-lb.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* グラスモーフィズム背景 */
.pb-gallery-lb__bg {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 3, 0.72);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

/* メイン画像ステージ */
.pb-gallery-lb__stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(92vw, 1080px);
  max-height: 80vh;
}
.pb-gallery-lb__img {
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  border-radius: 2px;
  transition: opacity .25s ease;
}
.pb-gallery-lb__img.is-transitioning {
  opacity: 0;
}
.pb-gallery-lb__caption {
  margin-top: 12px;
  font-family: var(--pb-font-sans, sans-serif);
  font-size: 12px;
  color: rgba(255,255,255,.7);
  letter-spacing: .08em;
  text-align: center;
}

/* オートハイドUI */
.pb-gallery-lb .pb-gallery-lb__close,
.pb-gallery-lb .pb-gallery-lb__prev,
.pb-gallery-lb .pb-gallery-lb__next,
.pb-gallery-lb .pb-gallery-lb__counter,
.pb-gallery-lb .pb-gallery-lb__strip {
  transition: opacity .4s ease;
}
.pb-gallery-lb.ui-hidden .pb-gallery-lb__close,
.pb-gallery-lb.ui-hidden .pb-gallery-lb__prev,
.pb-gallery-lb.ui-hidden .pb-gallery-lb__next,
.pb-gallery-lb.ui-hidden .pb-gallery-lb__counter,
.pb-gallery-lb.ui-hidden .pb-gallery-lb__strip {
  opacity: 0;
  pointer-events: none;
}

/* 閉じるボタン */
.pb-gallery-lb__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .2s, opacity .4s;
}
.pb-gallery-lb__close:hover {
  background: rgba(255,255,255,.25);
  transform: rotate(90deg);
}

/* 前後ボタン */
.pb-gallery-lb__prev,
.pb-gallery-lb__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .2s, opacity .4s;
}
.pb-gallery-lb__prev { left: 16px; }
.pb-gallery-lb__next { right: 16px; }
.pb-gallery-lb__prev:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.08); }
.pb-gallery-lb__next:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.08); }

/* カウンター */
.pb-gallery-lb__counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--pb-font-sans, sans-serif);
  font-size: 11px;
  letter-spacing: .14em;
  color: rgba(255,255,255,.6);
  background: rgba(0,0,0,.25);
  padding: 3px 12px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* サムネイルストリップ */
.pb-gallery-lb__strip {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  max-width: 90vw;
  overflow-x: auto;
  scrollbar-width: none;
}
.pb-gallery-lb__strip::-webkit-scrollbar { display: none; }
.pb-gallery-lb__thumb {
  flex-shrink: 0;
  width: 48px;
  height: 36px;
  border-radius: 3px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  background: none;
  opacity: .6;
  transition: opacity .2s, border-color .2s, transform .2s;
}
.pb-gallery-lb__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pb-gallery-lb__thumb.is-active {
  border-color: #fff;
  opacity: 1;
  transform: scale(1.1);
}
.pb-gallery-lb__thumb:hover { opacity: .9; }

/* ズームビュー */
.pb-gallery-lb__zoom-wrap {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}
.pb-gallery-lb.is-zoomed .pb-gallery-lb__zoom-wrap {
  opacity: 1;
  pointer-events: auto;
  cursor: grab;
}
.pb-gallery-lb.is-zoomed .pb-gallery-lb__zoom-wrap:active {
  cursor: grabbing;
}
.pb-gallery-lb__zoom-img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center;
  transition: transform .1s ease;
  user-select: none;
  -webkit-user-drag: none;
}
/* ズーム中はメイン画像を隠す */
.pb-gallery-lb.is-zoomed .pb-gallery-lb__stage { opacity: 0; pointer-events: none; }

/* ════════════════════════════════
   レスポンシブ
   ════════════════════════════════ */
@media (max-width: 768px) {
  .pb-gallery--grid .pb-gallery__grid,
  .pb-gallery--fade .pb-gallery__fade-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .pb-gallery--frame .pb-gallery__frame-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .pb-gallery--magazine .pb-gallery__magazine {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 140px;
  }
  .pb-gallery-lb__prev { left: 8px; width: 40px; height: 40px; }
  .pb-gallery-lb__next { right: 8px; width: 40px; height: 40px; }
  .pb-gallery-lb__thumb { width: 40px; height: 30px; }
  .pb-gallery--masonry .pb-gallery__masonry {
    column-count: 2 !important;
  }
}
@media (max-width: 480px) {
  .pb-gallery--grid .pb-gallery__grid,
  .pb-gallery--fade .pb-gallery__fade-grid,
  .pb-gallery--frame .pb-gallery__frame-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .pb-gallery-lb__strip { display: none; }
}

/* ════════════════════════════════
   エディター
   ════════════════════════════════ */
.pb-gallery-editor { padding: 0; }
.pb-gallery-editor-wrap {
  border: 1px dashed #c4b8a8;
  border-radius: 4px;
  padding: 16px;
  background: #faf7f2;
}
.pb-gallery-editor-header {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #332518;
}
