/* GYM GALLERY — admin grid + public thumbnails + lightbox. Uses design tokens only. */

/* ---------- admin ---------- */
.gal-cover { aspect-ratio: var(--ar, 16/9); overflow: hidden; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface-2); }
.gal-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gal-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--sp-4); }
.gal-item { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.gal-item__media { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.gal-item__media img, .gal-item__media video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.gal-item__tags { position: absolute; inset-block-start: var(--sp-2); inset-inline-start: var(--sp-2); display: flex; gap: var(--sp-1); pointer-events: none; }
.gal-item__body { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); }
.gal-caption { display: flex; gap: var(--sp-2); align-items: center; }
.gal-caption .input { flex: 1; min-width: 0; }
.gal-item__meta { font-size: var(--fs-sm); }
.gal-item .row-actions { flex-wrap: wrap; }

/* ---------- public thumbnails (inside a gym card) ---------- */
.gym__gallery { display: flex; gap: var(--sp-2); overflow-x: auto; padding-block-end: var(--sp-1); scroll-snap-type: x proximity; scrollbar-width: thin; }
.gthumb { position: relative; flex: 0 0 auto; width: 6.5rem; aspect-ratio: 4 / 3; padding: 0; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); cursor: pointer; scroll-snap-align: start; transition: border-color .15s ease, transform .15s ease; }
.gthumb:hover { border-color: var(--accent); transform: translateY(-1px); }
.gthumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gthumb img, .gthumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; background: #000; }
.gthumb__play { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / .32); }
.gthumb__play::before { content: ""; width: 0; height: 0; border-block: .55rem solid transparent; border-inline-start: .9rem solid #fff; margin-inline-start: .15rem; filter: drop-shadow(0 1px 3px rgb(0 0 0 / .5)); }

/* ---------- lightbox ---------- */
html.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgb(5 7 10 / .94); color: #fff; z-index: var(--z-modal); }
.lightbox::backdrop { background: rgb(5 7 10 / .94); }
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; }
.lightbox__stage { display: grid; place-items: center; min-height: 0; padding: var(--sp-12) var(--sp-4) var(--sp-2); }
.lightbox__stage img, .lightbox__stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); background: #000; }
.lightbox__err { color: #fff; text-align: center; }
.lightbox__bar { display: flex; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) var(--sp-5) var(--sp-5); font-size: var(--fs-sm); color: rgb(255 255 255 / .85); }
.lightbox__btn { position: absolute; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border: 1px solid rgb(255 255 255 / .25); border-radius: 50%; background: rgb(255 255 255 / .1); color: #fff; cursor: pointer; z-index: 1; }
.lightbox__btn:hover { background: rgb(255 255 255 / .22); }
.lightbox__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lightbox__btn[hidden] { display: none; }
.lightbox__close { inset-block-start: var(--sp-4); inset-inline-end: var(--sp-4); }
.lightbox__prev, .lightbox__next { inset-block-start: 50%; transform: translateY(-50%); }
.lightbox__prev { inset-inline-start: var(--sp-4); }   /* RTL: «قبلی» سمت راست */
.lightbox__next { inset-inline-end: var(--sp-4); }
@media (max-width: 767px) {
  .lightbox__stage { padding-inline: 0; }
  .lightbox__prev, .lightbox__next { inset-block-start: auto; inset-block-end: var(--sp-12); transform: none; }
  .gthumb { width: 5.5rem; }
}
@media (prefers-reduced-motion: reduce) { .gthumb { transition: none; } .gthumb:hover { transform: none; } }

/* ---------- Same-size, readable media ---------- */
/* Lightbox: every photo is scaled to the same stage (small ones are enlarged, big ones fit) → consistent and legible. */
.lightbox__stage img, .lightbox__stage video { width: 100%; height: 100%; object-fit: contain; }
.lightbox__stage { padding-block-start: var(--sp-16); }
/* Thumbnails: identical frames, cover crop. */
.gthumb { width: 6.5rem; height: 4.875rem; }
@media (max-width: 767px) { .gthumb { width: 5.5rem; height: 4.125rem; } }
