/* ============================================================
   GLightbox ボタン（× · 矢印）をギャラリーデザインに統一
   ============================================================ */

.glightbox-container .gbtn {
  width: 44px !important;
  height: 44px !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border-radius: 50% !important;
  border: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  box-shadow: none !important;
  transition: background 0.2s !important;
}
.glightbox-container .gbtn:hover {
  background: rgba(255, 255, 255, 0.28) !important;
}

/* 閉じるボタン位置をギャラリーモーダルに合わせる */
.glightbox-container .gclose {
  top: 20px !important;
  right: 24px !important;
}

/* 矢印位置 */
.glightbox-container .gprev { left: 20px !important; }
.glightbox-container .gnext { right: 20px !important; left: auto !important; }

/* SVG アイコンを白く・サイズ調整 */
.glightbox-container .gbtn svg {
  width: 20px !important;
  height: 20px !important;
  display: block;
}
.glightbox-container .gbtn svg path {
  fill: #fff !important;
}

@media (max-width: 599px) {
  .glightbox-container .gclose  { top: 20px !important; right: 12px !important; }
  .glightbox-container .gprev   { left: 8px !important; }
  .glightbox-container .gnext   { right: 8px !important; }
}

/* ============================================================
   Gallery Modal（全画面 CSS Grid レイアウト）
   ============================================================ */

.gallery-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9000;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

/* ぼかしサムネ背景（position:fixedでスクロールに追従しない・z-index:-1で最背面） */
.gallery-modal__bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.8); /* 先に拡大→blurのエッジが画面外に出る */
  filter: blur(40px) brightness(0.45);
  z-index: -1;
  pointer-events: none;
}
.gallery-modal::-webkit-scrollbar {
  display: none;
}
.gallery-modal.is-open {
  opacity: 1;
  visibility: visible;
}

/* 閉じるボタン */
.gallery-modal__close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  z-index: 9001;
  transition: background 0.2s;
}
.gallery-modal__close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* タイトル */
.gallery-modal__title {
  position: fixed;
  top: 20px;
  left: 0;
  right: 72px;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 24px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  letter-spacing: 0.05em;
  z-index: 9001;
  pointer-events: none;
}

/* ============================================================
   グリッド全体：CSS Grid（動画2カラム＋画像が回り込む）
   ============================================================ */

.gallery-modal__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  padding: 80px 20px;
  align-items: start;
}

/* 動画セクション（3列中の2列 × 3行分を占有） */
.gallery-modal__video-section {
  grid-column: span 2;
  grid-row: span 2;
  background: #000;
  border-radius: 2px;
}

/* 動画あり：右列の画像1・2をflex縦並びで gap 20px */
.gallery-modal__video-side {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.gallery-modal__video-side .gallery-modal__item {
  display: block;
}

@media (max-width: 599px) {
  .gallery-modal__video-side {
    grid-row: auto;
    grid-column: 1 / -1;
    gap: 10px;
  }
}

/* 16:9 固定 */
.gallery-modal__video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 2px;
  overflow: hidden;
}
.gallery-modal__video-wrap iframe,
.gallery-modal__video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ============================================================
   画像のみ（動画なし）：CSS columns 真のmasonry
   ============================================================ */

.gallery-modal__images {
  grid-column: 1 / -1;
  columns: 3;
  column-gap: 40px;
}

.gallery-modal__images .gallery-modal__item {
  break-inside: avoid;
  margin-bottom: 40px;
}

/* 1枚目が横長：2カラム×2行、JSで高さ設定 */
.gallery-modal__item--wide {
  grid-column: span 2;
  grid-row: span 2;
}

/* 2・3枚目：自然な高さ（行の高さを決める側） */
.gallery-modal__item--side img {
  height: auto;
}

/* 画像2が縦長のとき：右列2行分を占有して高さいっぱいに表示 */
.gallery-modal__item--side-full {
  grid-row: span 2;
  align-self: stretch;
}
.gallery-modal__item--side-full img {
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   フェードイン
   ============================================================ */

@keyframes galleryFadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ============================================================
   画像タイル（グリッドの直接子 → 動画の右・下に自動配置）
   ============================================================ */

.gallery-modal__item {
  display: block;
  overflow: hidden;
  cursor: zoom-in;
  line-height: 0;
  border-radius: 2px;
  opacity: 0;
  animation: galleryFadeIn 0.5s ease forwards;
}
.gallery-modal__item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.45s ease;
}
.gallery-modal__item:hover img {
  transform: scale(1.07);
}

/* ===== レスポンシブ ===== */
/* ============================================================
   クレジット（最後のマス）
   ============================================================ */

.gallery-modal__credit {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.8;
  padding: 4px 4px 20px;
}
.gallery-modal__credit-left {
  flex: 1;
  min-width: 0;
}
.gallery-modal__credit-link {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transition: color 0.2s;
}
.gallery-modal__credit-link:hover {
  color: rgba(255, 255, 255, 0.75);
}
.gallery-modal__credit-copy {
  margin: 0 0 8px;
  white-space: pre-line;
}
.gallery-modal__credit-body {
  white-space: pre-line;
}
.gallery-modal__credit-body p {
  margin: 0 0 4px;
}
.gallery-modal__credit-body p:last-child {
  margin-bottom: 0;
}
.gallery-modal__credit-body strong {
  font-weight: bold;
}
.gallery-modal__credit-body em {
  font-style: italic;
}

/* ============================================================
   デスクトップ明示的列配置（CSS columnsのバランシング空き列を回避）
   ============================================================ */

.gallery-modal__images-cols {
  grid-column: 1 / -1;
  display: flex;
  gap: 40px;
  align-items: start;
}
.gallery-modal__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 40px;
}
.gallery-modal__col .gallery-modal__item {
  margin-bottom: 0;
}

@media (min-width: 600px) and (max-width: 900px) {
  .gallery-modal__images-cols { gap: 14px; }
  .gallery-modal__col { gap: 14px; }
}

/* ============================================================
   モバイル明示的2カラム（iOS Safari CSS columns gap 回避）
   ============================================================ */

.gallery-modal__images-mobile {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
}
.gallery-modal__mcol {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gallery-modal__mcol .gallery-modal__item {
  margin-bottom: 0;
}

@media (max-width: 599px) {
  .gallery-modal__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 84px 12px 40px;
  }
  .gallery-modal__video-section {
    grid-column: span 2;
  }
  .gallery-modal__item--wide {
    grid-row: span 1;
  }
  .gallery-modal__images {
    columns: 2;
    column-gap: 10px;
  }
  .gallery-modal__images .gallery-modal__item {
    margin-bottom: 10px;
  }
  .gallery-modal__close {
    right: 12px;
  }
  .gallery-modal__title {
    top: 20px;
    right: 60px;
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 8px 0 16px;
    font-size: 11px;
  }
}

@media (min-width: 600px) and (max-width: 900px) {
  .gallery-modal__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 72px 16px 50px;
  }
  .gallery-modal__video-section {
    grid-column: span 2;
  }
  .gallery-modal__images {
    columns: 2;
    column-gap: 14px;
  }
  .gallery-modal__images .gallery-modal__item {
    margin-bottom: 14px;
  }
}
