/* Gallery page: screenshot grid + full-screen viewer */
html { scrollbar-gutter: stable; }   /* page does not jump when the viewer locks scrolling */

/* ── Toolbar above the grid ── */
.gallery-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.gallery-bar__hint { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* ── Grid ── */
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.gallery-grid__item { min-width: 0; }
.gallery-grid--feature .gallery-grid__item--big { grid-column: span 2; grid-row: span 2; }
@media (max-width: 960px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .gallery-grid--feature .gallery-grid__item--big { grid-column: auto; grid-row: auto; }
}
@media (max-width: 420px) { .gallery-grid { gap: 8px; } }

.shot {
  position: relative; display: block; height: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-solid);
  box-shadow: 0 14px 34px -22px rgba(0, 0, 0, 0.9);
  cursor: zoom-in; isolation: isolate;
  transition: transform 0.35s var(--ease), border-color 0.3s, box-shadow 0.35s var(--ease);
}
.gallery-grid__item--big .shot { aspect-ratio: auto; min-height: 100%; }
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s var(--ease), filter 0.4s; }
.shot__shade { position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(5, 10, 22, 0) 45%, rgba(5, 10, 22, 0.85) 100%); opacity: 0; transition: opacity 0.35s var(--ease); }
.shot__zoom {
  position: absolute; top: 50%; left: 50%; z-index: 2; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%;
  color: #fff; background: rgba(5, 10, 22, 0.45); border: 1px solid rgba(125, 211, 252, 0.6);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 0 30px -4px rgba(56, 189, 248, 0.6);
  opacity: 0; transform: translate(-50%, -50%) scale(0.7); transition: opacity 0.3s, transform 0.35s var(--ease);
}
.shot__cap {
  position: absolute; left: 14px; right: 14px; bottom: 12px; z-index: 2; display: flex; align-items: center; gap: 10px;
  color: #fff; font-size: 0.86rem; font-weight: 600; opacity: 0; transform: translateY(8px); transition: opacity 0.3s, transform 0.35s var(--ease);
}
.shot__num { flex: none; padding: 2px 8px; border-radius: 999px; background: rgba(56, 189, 248, 0.2); border: 1px solid rgba(56, 189, 248, 0.45); color: #bfe9ff; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.shot__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); }
.shot:hover, .shot:focus-visible { border-color: rgba(56, 189, 248, 0.55); box-shadow: 0 24px 50px -22px rgba(56, 189, 248, 0.55); transform: translateY(-3px); }
.shot:hover img, .shot:focus-visible img { transform: scale(1.07); filter: saturate(1.1) brightness(1.05); }
.shot:hover .shot__shade, .shot:focus-visible .shot__shade,
.shot:hover .shot__zoom, .shot:focus-visible .shot__zoom,
.shot:hover .shot__cap, .shot:focus-visible .shot__cap { opacity: 1; }
.shot:hover .shot__zoom, .shot:focus-visible .shot__zoom { transform: translate(-50%, -50%) scale(1); }
.shot:hover .shot__cap, .shot:focus-visible .shot__cap { transform: none; }
.shot:focus-visible { outline-offset: 3px; }
/* the large first screenshot always shows its caption */
.gallery-grid__item--big .shot__shade, .gallery-grid__item--big .shot__cap { opacity: 1; transform: none; }
.gallery-grid__item--big .shot__cap { left: 22px; bottom: 20px; font-size: 1rem; }
@media (hover: none) {
  .shot__zoom { display: none; }
  .shot:hover { transform: none; }
}
@media (max-width: 960px) {
  .gallery-grid__item--big .shot { aspect-ratio: 16 / 9; }
  .gallery-grid__item--big .shot__shade, .gallery-grid__item--big .shot__cap { opacity: 0; }
  .gallery-grid__item--big .shot__cap { left: 14px; bottom: 12px; font-size: 0.86rem; }
}
@media (max-width: 640px) { .shot { border-radius: 12px; } .gallery-bar__hint { font-size: 0.82rem; } }

.gallery-empty { display: grid; justify-items: center; gap: 12px; }
.gallery-empty .icon { color: var(--primary); opacity: 0.7; }
.gallery-empty p { margin: 0; }

/* ── Call to action under the grid ── */
.gallery-cta { display: flex; align-items: center; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap; margin-top: clamp(32px, 5vw, 56px); }
.gallery-cta__text { flex: 1 1 360px; min-width: 0; }
.gallery-cta__title { margin: 0 0 6px; font-size: clamp(1.3rem, 2.4vw, 1.7rem); }
@media (max-width: 640px) { .gallery-cta .row { width: 100%; } .gallery-cta .btn { flex: 1 1 100%; } }

/* ── Full-screen viewer ── */
html.lb-open, html.lb-open body { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  display: grid; grid-template-columns: 88px minmax(0, 1fr) 88px; grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top top top" "prev stage next" "cap cap cap" "strip strip strip";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--text); opacity: 0; transition: opacity 0.25s var(--ease);
}
.lightbox.is-open { opacity: 1; }
.lightbox__backdrop {
  position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(1000px 600px at 50% 40%, rgba(20, 40, 80, 0.55), transparent 70%), rgba(3, 6, 14, 0.94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.lightbox__top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.lightbox__counter { margin: 0; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--text-2); font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.lightbox__counter [data-lb-index] { color: #fff; }
.lightbox__of { color: var(--muted); }
.lightbox__tools { display: flex; gap: 8px; }
.lightbox__tool { width: 44px; height: 44px; color: var(--text); background: rgba(255, 255, 255, 0.06); }
.lightbox__close:hover { color: #fff; border-color: rgba(251, 113, 133, 0.55); background: rgba(251, 113, 133, 0.14); }

.lightbox__stage { grid-area: stage; position: relative; min-height: 0; margin: 0 4px; touch-action: pan-y pinch-zoom; }
.lightbox__img {
  position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; width: auto; height: auto;
  border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-solid);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s var(--ease), transform 0.35s var(--ease);
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
}
.lightbox.is-loading .lightbox__img { opacity: 0.35; }
.lightbox__img.is-in-next { animation: lbInNext 0.4s var(--ease); }
.lightbox__img.is-in-prev { animation: lbInPrev 0.4s var(--ease); }
.lightbox.is-open .lightbox__img.is-first { animation: lbZoomIn 0.4s var(--ease); }
@keyframes lbInNext { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes lbInPrev { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes lbZoomIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.lightbox__spinner {
  position: absolute; top: 50%; left: 50%; width: 42px; height: 42px; margin: -21px 0 0 -21px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14); border-top-color: var(--primary);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; animation: lbSpin 0.8s linear infinite;
}
.lightbox.is-loading .lightbox__spinner { opacity: 1; transition-delay: 0.15s; }
@keyframes lbSpin { to { transform: rotate(360deg); } }

.lightbox__nav {
  align-self: center; justify-self: center; display: grid; place-items: center; width: 56px; height: 56px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line-2); background: rgba(5, 10, 22, 0.6); color: #fff; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, transform 0.25s var(--ease), box-shadow 0.25s;
}
.lightbox__nav:hover { background: rgba(56, 189, 248, 0.18); border-color: rgba(125, 211, 252, 0.7); box-shadow: var(--shadow-glow); }
.lightbox__nav--prev { grid-area: prev; }
.lightbox__nav--prev .icon { transform: rotate(180deg); }
.lightbox__nav--next { grid-area: next; }
.lightbox__nav--prev:hover { transform: translateX(-2px); }
.lightbox__nav--next:hover { transform: translateX(2px); }

.lightbox__caption { grid-area: cap; margin: 0; padding: 14px 20px 4px; min-height: 2.6em; text-align: center; color: var(--text-2); font-size: 0.95rem; }

.lightbox__strip {
  grid-area: strip; position: relative; display: flex; gap: 8px; padding: 10px 18px 16px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: rgba(130, 180, 255, 0.3) transparent;
  justify-content: safe center; overscroll-behavior-x: contain;
}
.lightbox__thumb {
  flex: none; width: 96px; aspect-ratio: 16 / 9; padding: 0; overflow: hidden; border-radius: 8px;
  border: 2px solid transparent; background: var(--surface-solid); cursor: pointer; opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.lightbox__thumb img { width: 100%; height: 100%; object-fit: cover; }
.lightbox__thumb:hover { opacity: 0.9; }
.lightbox__thumb[aria-current="true"] { opacity: 1; border-color: var(--primary); box-shadow: 0 0 18px -4px rgba(56, 189, 248, 0.8); }

.lightbox--single .lightbox__nav, .lightbox--single .lightbox__strip { display: none; }

@media (max-width: 760px) {
  .lightbox {
    grid-template-columns: 56px minmax(0, 1fr) 56px;
    grid-template-areas: "top top top" "stage stage stage" "prev cap next" "strip strip strip";
  }
  .lightbox__top { padding: 10px 12px; }
  .lightbox__stage { margin: 0; }
  .lightbox__img { border-radius: 0; border-left: 0; border-right: 0; }
  .lightbox__nav { width: 44px; height: 44px; }
  .lightbox__caption { align-self: center; padding: 10px 4px; font-size: 0.88rem; }
  .lightbox__strip { padding: 6px 12px 12px; gap: 6px; }
  .lightbox__thumb { width: 64px; border-radius: 6px; }
}
@media (max-height: 520px) { .lightbox__strip { display: none; } }
