/* ─────────────────────────────────────────────────────────────────
   Ben Mo — Level 3 shared component · Lightbox
   ─────────────────────────────────────────────────────────────────
   Extracted from photographs/cellphone-and-people (lightbox v2) so every
   gallery page reuses one implementation. Pair with level3-lightbox.js.

   Usage in a gallery page (paths relative to the page):
     <link rel="stylesheet" href="../../level3.css" />
     <link rel="stylesheet" href="../../level3-lightbox.css" />
     ...
     <script src="../../level3-lightbox.js" defer></script>

   The overlay is always dark, regardless of the page's own theme, so it
   carries its own tokens. Override the --lb-* custom properties on
   .lightbox if a page really needs a different overlay.

   Markup contract for the page (what the script looks for):
     <figure class="photo-card" data-frame="01" data-plate="PLATE I · 地下">
       <div class="photo-wrapper">
         <span class="photo-index">01 / 19</span>
         <img class="gallery-img" src="..." alt="..." />
       </div>
     </figure>
   ───────────────────────────────────────────────────────────────── */

.lightbox {
  --lb-bg:          rgba(8, 7, 6, 0.96);
  --lb-ink:         #f1ede2;
  --lb-ink-soft:    #c4bfb0;
  --lb-ink-muted:   #8a8478;
  --lb-ink-dim:     #5a554c;
  --lb-line-strong: rgba(241, 237, 226, 0.28);
  --lb-serif: var(--bm-serif, 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', serif);
  --lb-mono:  var(--bm-mono, 'IBM Plex Mono', ui-monospace, monospace);

  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--lb-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 28px 40px;
  gap: 16px;
  color: var(--lb-ink-soft);
}
.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

/* header strip */
.lightbox__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.lightbox__file {
  font-family: var(--lb-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lb-ink-muted);
}
.lightbox__close {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--lb-line-strong);
  color: var(--lb-ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 200ms, color 200ms, transform 220ms cubic-bezier(.2,.7,.2,1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--lb-mono);
}
.lightbox__close:hover {
  background: var(--lb-ink);
  color: #131110;
}

/* body: image centered, prev/next arrows on sides */
.lightbox__body {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox__img {
  max-width: calc(100vw - 200px);
  max-height: calc(100vh - 210px);
  object-fit: contain;
  display: block;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.85);
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 280ms ease, transform 380ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}
.lightbox.is-loaded .lightbox__img {
  opacity: 1;
  transform: scale(1);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: rgba(241, 237, 226, 0.04);
  border: 1px solid var(--lb-line-strong);
  color: var(--lb-ink);
  font-family: var(--lb-serif);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 220ms, color 220ms, border-color 220ms, transform 240ms cubic-bezier(.2,.7,.2,1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2010;
}
.lightbox__nav--prev { left: 36px; }
.lightbox__nav--next { right: 36px; }
.lightbox__nav:hover:not(:disabled) {
  background: var(--lb-ink);
  color: #131110;
  border-color: var(--lb-ink);
}
.lightbox__nav--prev:hover:not(:disabled) { transform: translateY(-50%) translateX(-3px); }
.lightbox__nav--next:hover:not(:disabled) { transform: translateY(-50%) translateX(3px); }
.lightbox__nav:disabled {
  opacity: 0.22;
  cursor: not-allowed;
}

/* footer: counter + plate + hint */
.lightbox__footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.lightbox__counter {
  font-family: var(--lb-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.32em;
  color: var(--lb-ink);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.lightbox__counter::before,
.lightbox__counter::after {
  content: '';
  width: 28px;
  height: 1px;
  background: var(--lb-line-strong);
}
.lightbox__plate {
  font-family: var(--lb-serif);
  font-size: 13px;
  color: var(--lb-ink-soft);
  letter-spacing: 0.06em;
  text-align: center;
  grid-column: 2;
  grid-row: 2;
  margin-top: 4px;
}
.lightbox__hint {
  font-family: var(--lb-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lb-ink-dim);
  text-align: right;
}
.lightbox__hint--left {
  text-align: left;
}

/* Responsive — site-wide 640 / 1024 breakpoints */
@media (max-width: 1024px) {
  .lightbox { padding: 22px 24px; }
  .lightbox__nav { width: 44px; height: 44px; font-size: 17px; }
  .lightbox__nav--prev { left: 16px; }
  .lightbox__nav--next { right: 16px; }
  .lightbox__img {
    max-width: calc(100vw - 130px);
    max-height: calc(100vh - 200px);
  }
  .lightbox__hint { display: none; }
  .lightbox__footer { grid-template-columns: 1fr; gap: 6px; text-align: center; }
  .lightbox__plate { grid-column: 1; grid-row: 2; }
}

@media (max-width: 640px) {
  .lightbox { padding: 14px 12px; gap: 10px; }
  .lightbox__file { font-size: 9.5px; letter-spacing: 0.14em; }
  .lightbox__nav { width: 38px; height: 38px; font-size: 16px; }
  .lightbox__nav--prev { left: 8px; }
  .lightbox__nav--next { right: 8px; }
  .lightbox__img {
    max-width: calc(100vw - 90px);
    max-height: calc(100vh - 170px);
  }
  .lightbox__counter { font-size: 10.5px; letter-spacing: 0.24em; gap: 10px; }
  .lightbox__counter::before,
  .lightbox__counter::after { width: 18px; }
  .lightbox__plate { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox__img,
  .lightbox__nav,
  .lightbox__close { transition: none; }
}
