/* ベース */
*,
*::before,
*::after {
  box-sizing: border-box;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* アクセシビリティ用：見出しを視覚的に隠す */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ギャラリー：PC 4列 / SP 2列 */
.gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 768px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

/* サムネ：中心基準の正方形トリミング */
.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  /* 正方形 */
  overflow: hidden;
  border-radius: 8px;
  background: #f3f3f3;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 中心基準にトリミング */
  object-position: center;
  display: block;
  transition: transform .25s ease;
  user-select: none;
}

.thumb:hover img {
  transform: scale(1.03);
  cursor: zoom-in;
}

/* モーダル（ライトボックス） */
.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  /* is-open で表示 */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .8);
  z-index: 9999;
  padding: 24px;
  /* 端に貼り付かない余白 */
}

.lightbox.is-open {
  display: flex;
}

/* 画像コンテナ：画像クリックでは閉じない */
.lightbox__figure {
  margin: 0;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__figure img {
  max-width: 100%;
  max-height: 90vh;
  /* 画面内に収める */
  width: auto;
  height: auto;
  object-fit: contain;
  /* はみ出さない */
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  background: #111;
}

/* ナビボタン（前/次） */
.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background .2s ease, transform .2s ease;
}

.nav:hover {
  background: rgba(255, 255, 255, .2);
  transform: translateY(-50%) scale(1.05);
}

.nav:active {
  transform: translateY(-50%) scale(0.98);
}

.nav.prev {
  left: 16px;
}

.nav.next {
  right: 16px;
}

/* スマホ向け微調整 */
@media (max-width: 480px) {
  .lightbox {
    padding: 12px;
  }

  .nav {
    font-size: 24px;
    padding: 8px 10px;
  }

  .lightbox__figure img {
    max-height: 82vh;
    /* モバイルのUI領域を少し考慮 */
  }
}

/* ====== スマホ時の右ズレ是正（最終オーバーライド） ====== */
@media (max-width: 768px) {

  /* 右寄せや右フロートの影響を無効化 */
  .wrap,
  .container2,
  .gallery {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    float: none !important;
    text-align: left !important;
    /* 右寄せ指定の打ち消し */
    padding-left: 8px;
    /* 端ギリ対策：必要なければ0でもOK */
    padding-right: 8px;
    box-sizing: border-box;
  }

  /* グリッドが狭くなっても均等に割り付けられるように */
  .gallery {
    display: grid !important;
    /* 万一別のdisplayが当たっても上書き */
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    justify-content: center;
    /* グリッド自体を中央に */
    justify-items: stretch;
    /* 各セルが均等に広がる */
    align-items: stretch;
  }

  /* 子要素にfloatやinline影響が残っているケースを潰す */
  .gallery .thumb {
    float: none !important;
    display: block !important;
    margin: 0 !important;
  }

  /* 画像のはみ出し防止（念のため） */
  .gallery .thumb img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
  }
}

.page-title  {
  font-size: 23px;
  line-height: 30px;
  letter-spacing: 3px;
  font-weight: normal;
  text-align: center;
  color: #009fde;
  margin-bottom: 1.6rem; 
}

.page-text  {
  text-align: center;
}

.gallery-title  {
  font-size: 16px;
  line-height: 30px;
  letter-spacing: 3px;
  font-weight: normal;
  text-align: center;
  color: #009fde;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

/* スマホ時のみ表示する改行 */
br.mobile-only { display: none; }

/* スマホ判定は幅767px以下。必要に応じて調整してください */
@media (max-width: 767px) {
  br.mobile-only { display: block; line-height: 0; }
}


.blue-line {
  width: 100%;
  height: 1px;
  background-color: #009fde; /* ソラマドブランドカラー */
  margin: 80px 0;           /* 上下の余白 */
}

/* ===== フッターを box-sizing: content-box に戻す（footer()対策） ===== */
/* まずサイト全体のやり方を「継承」型に整えるのがベスト */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

/* フッター配下だけ content-box に切り替え（root で切替→子は継承） */
footer, .footer, #footer { box-sizing: content-box !important; }
footer *, .footer *, #footer *,
footer *::before, footer *::after,
.footer *::before, .footer *::after,
#footer *::before, #footer *::after {
  box-sizing: inherit !important; /* 親（=content-box）を継承させる */
}