/* ==========================================================================
   TV Kikinda — galleries in stories (mosaic) and the viewer over the whole screen
   ========================================================================== */

/* ---------- Mosaic ---------- */
.gallery { margin-block: 32px; }
.gallery__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 12px; }
.gallery__eyebrow {
  display: inline-flex; align-items: center; gap: 10px; margin: 0;
  font: 800 .78rem/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; color: var(--ink);
}
.gallery__count { margin: 0; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.gallery__all { margin-left: auto; min-height: 36px; }
.prose .gallery__grid, .gallery__grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: clamp(92px, 10.5vw, 148px); gap: 6px;
}
.prose .gallery__cell, .gallery__cell { margin: 0; padding: 0; min-width: 0; }
.gallery__cell::marker { content: none; }
.gallery__cell:first-child { grid-column: span 2; grid-row: span 2; }
.gallery--n1 .gallery__grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
.gallery--n1 .gallery__cell:first-child { grid-column: auto; grid-row: auto; aspect-ratio: 16 / 9; }
.gallery--n2 .gallery__cell { grid-column: span 2; grid-row: span 2; }
.gallery--n3 .gallery__cell:not(:first-child) { grid-column: span 2; }
.gallery--n4 .gallery__cell:nth-child(2) { grid-column: span 2; }
.js .gallery__cell--extra { display: none; } /* in the viewer; without JavaScript every picture stays in the grid */

.prose a.gallery__item, .gallery__item {
  position: relative; display: block; width: 100%; height: 100%; overflow: hidden; border-radius: var(--r);
  background: var(--surface-2); color: #fff; text-decoration: none; cursor: zoom-in;
}
.gallery__item--video, .gallery__item--youtube { cursor: pointer; }
.prose .gallery__item img, .gallery__item img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 0; display: block;
  transition: transform .7s var(--ease-out), filter .4s;
}
.gallery__item::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(7, 7, 26, .35)); opacity: 0; transition: opacity .3s;
}
@media (hover: hover) {
  .gallery__item:hover img { transform: scale(1.05); }
  .gallery__item:hover::after { opacity: 1; }
}
.gallery__item:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.gallery__noposter { position: absolute; inset: 0; background: var(--grad-v); }
.gallery__play {
  position: absolute; left: 50%; top: 50%; z-index: 1; display: grid; place-items: center; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(7, 7, 26, .62); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background-color .25s, transform .35s var(--ease-out);
}
.gallery__play .ico { width: 20px; height: 20px; margin-left: 3px; fill: currentColor; }
.gallery__item:hover .gallery__play { background: var(--orange); color: var(--navy-950); transform: scale(1.08); }
.gallery__more {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
  background: rgba(7, 7, 26, .58); font: italic 900 clamp(1.6rem, 1.2rem + 1.4vw, 2.4rem)/1 var(--font-display); color: #fff;
  transition: background-color .3s;
}
.gallery__item:hover .gallery__more { background: rgba(7, 7, 26, .7); }

@media (max-width: 640px) {
  .prose .gallery__grid, .gallery__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 26vw; gap: 4px; }
  .gallery__cell:first-child { grid-column: 1 / -1; grid-row: span 2; }
  .gallery--n2 .gallery__cell, .gallery--n3 .gallery__cell:not(:first-child) { grid-column: auto; grid-row: auto; }
  .gallery--n2 .gallery__cell:not(:first-child), .gallery--n4 .gallery__cell:nth-child(2) { grid-column: 1 / -1; }
  .gallery__all { margin-left: 0; }
}

/* ---------- Viewer ---------- */
.lb {
  position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; justify-items: center;
  background: rgba(4, 4, 16, .9); color: #fff; opacity: 0; transition: opacity .25s;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
/* At most 1920 px wide; on wider screens the page stays dimmed on both sides */
.lb__panel {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: min(100%, 1920px); height: 100%; min-height: 0;
  background: var(--navy-950);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.lb.is-open { opacity: 1; }
.lb[hidden] { display: none; }
.lb__bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 10px 12px 10px 20px; }
.lb__count { font: italic 900 1.15rem/1 var(--font-display); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.lb__count span { color: rgba(255, 255, 255, .55); }
.lb__caption { margin: 0; text-align: center; color: rgba(255, 255, 255, .85); font-size: .95rem; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lb__btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: #fff;
  background: rgba(255, 255, 255, .08); transition: background-color .2s, color .2s, transform .3s var(--ease-out);
}
.lb__btn:hover { background: var(--orange); color: var(--navy-950); }
.lb__btn:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.lb__btn .ico { width: 22px; height: 22px; }
.lb__stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: pan-y pinch-zoom; user-select: none; }
.lb__media {
  grid-area: 1 / 1; display: grid; place-items: center; width: 100%; height: 100%; padding: 0 clamp(8px, 7vw, 96px);
  will-change: transform, opacity;
}
.lb__media img, .lb__media video {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8); background: rgba(255, 255, 255, .03);
}
.lb__media video { width: min(100%, 1280px); background: #000; }
.lb__yt { width: min(100%, calc((100dvh - 200px) * 16 / 9), 1280px); aspect-ratio: 16 / 9; border: 0; border-radius: 4px; background: #000; }
.lb__nav { position: absolute; top: 50%; z-index: 2; margin-top: -24px; }
.lb__nav--prev { left: clamp(6px, 2vw, 24px); }
.lb__nav--next { right: clamp(6px, 2vw, 24px); }
.lb__nav[disabled] { opacity: 0; pointer-events: none; }
.lb__nav--prev .ico { transform: rotate(180deg); }
.lb__thumbs {
  display: flex; gap: 6px; padding: 10px 16px 14px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; justify-content: safe center;
}
.lb__thumbs::-webkit-scrollbar { display: none; }
.lb__thumb {
  position: relative; flex: none; width: 64px; height: 46px; border-radius: 4px; overflow: hidden; opacity: .45; scroll-snap-align: center;
  outline: 2px solid transparent; outline-offset: 1px; transition: opacity .2s, outline-color .2s; background: rgba(255, 255, 255, .08);
}
.lb__thumb img { width: 100%; height: 100%; object-fit: cover; }
.lb__thumb:hover, .lb__thumb[aria-current="true"] { opacity: 1; }
.lb__thumb[aria-current="true"] { outline-color: var(--orange); }
.lb__thumb--video::after { content: ''; position: absolute; left: 50%; top: 50%; margin: -6px 0 0 -4px; border: 6px solid transparent; border-left: 10px solid #fff; border-right: 0; }
.lb__thumb:focus-visible { outline: 3px solid var(--orange); opacity: 1; }

@media (max-width: 640px) {
  .lb__bar { grid-template-columns: auto auto; padding-left: 16px; }
  .lb__caption { grid-column: 1 / -1; grid-row: 2; text-align: left; font-size: .88rem; }
  .lb__close { grid-column: 2; grid-row: 1; justify-self: end; }
  .lb__media { padding: 0; }
  .lb__media img { border-radius: 0; }
  .lb__nav { display: none; } /* swipe */
  .lb__thumb { width: 52px; height: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .lb, .gallery__item img, .gallery__play, .lb__btn { transition: none; }
}
