/* ============================================================
   lightbox.css — 画像ライトボックス（assets/js/lightbox.js 用）

   ※ ライトボックスは <body> 直下に生成され、.content-wrap などの
      コンテナの外に出るため、cqw 単位は使わず px で指定している。
============================================================ */

/* 拡大できる画像であることを示す */
[data-lightbox] {
  cursor: zoom-in;
}

/* 表示中は背面をスクロールさせない */
html.lb-lock {
  overflow: hidden;
}


/* ---- 全体 ---- */
.lb {
  position: fixed;
  inset: 0;
  z-index: 9999;               /* ヘッダー(最大200)より前面 */
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-base);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lb[hidden] {
  display: none;
}

.lb.is-open {
  opacity: 1;
}

.lb__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(46, 32, 22, 0.92);   /* --color-footer-bg をベースにした暗い茶色 */
}


/* ---- 画像エリア ---- */
.lb__figure {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 64px 88px 24px;
  box-sizing: border-box;
  pointer-events: none;        /* 画像まわりの余白クリックで閉じられるようにする */
}

.lb__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.lb__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

.lb__caption {
  min-height: 1.6em;
  max-width: min(90vw, 720px);
  margin: 14px 0 0;
  color: var(--color-bg, #f5ede0);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  pointer-events: auto;
}


/* ---- 読み込み中・エラー ---- */
.lb.is-loading .lb__img {
  opacity: 0;
}

.lb__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease 0.25s;   /* 一瞬で読み込めた時にチラつかせない */
  animation: lb-spin 0.8s linear infinite;
}

.lb.is-loading .lb__spinner {
  opacity: 1;
}

.lb__error {
  display: none;
  margin: 0;
  padding: 24px;
  color: var(--color-bg, #f5ede0);
  font-size: 15px;
  pointer-events: auto;
}

.lb.is-error .lb__error {
  display: block;
}

.lb.is-error .lb__img {
  display: none;
}

@keyframes lb-spin {
  to { transform: rotate(360deg); }
}


/* ---- ボタン・カウンター ---- */
.lb__btn {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition-fast, 0.15s ease);
  -webkit-tap-highlight-color: transparent;
}

.lb__btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lb__btn:focus-visible {
  outline: 3px solid var(--color-primary-light, #f7c4a8);
  outline-offset: 2px;
}

.lb__btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb__close {
  top: 12px;
  right: 12px;
}

.lb__prev,
.lb__next {
  top: 50%;
  margin-top: -24px;
}

.lb__prev {
  left: 16px;
}

.lb__next {
  right: 16px;
}

.lb__counter {
  position: absolute;
  z-index: 2;
  top: 24px;
  left: 20px;
  margin: 0;
  color: var(--color-bg, #f5ede0);
  font-size: 14px;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

/* 画像が1枚だけの時は、送りボタンと枚数表示を出さない */
.lb.is-single .lb__prev,
.lb.is-single .lb__next,
.lb.is-single .lb__counter {
  display: none;
}


/* ---- SP ---- */
@media (max-width: 768px) {
  .lb__figure {
    padding: 60px 12px 16px;
  }

  .lb__img {
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
  }

  .lb__btn {
    width: 40px;
    height: 40px;
  }

  .lb__prev,
  .lb__next {
    margin-top: -20px;
    background: rgba(46, 32, 22, 0.55);   /* 画像に重なっても見えるよう少し濃くする */
  }

  .lb__prev { left: 6px; }
  .lb__next { right: 6px; }

  .lb__counter {
    top: 22px;
    left: 16px;
  }
}


/* ---- 動きを減らす設定の人向け ---- */
@media (prefers-reduced-motion: reduce) {
  .lb,
  .lb__img,
  .lb__spinner {
    transition: none;
  }

  .lb__spinner {
    animation-duration: 2s;
  }
}
