/* ============================================================
   Gallery — views/public/gallery.php, gallery-event.php, partials/gallery-item-card.php
   + the Techage Lightbox (public/js/lightbox.js)
   ============================================================ */

/* ── Toolbar ── */
.gl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: -40px 0 30px; position: relative; z-index: 2;
    background: var(--white); border: 1px solid var(--border); border-radius: 18px; padding: 12px; box-shadow: 0 14px 40px rgba(0, 0, 80, .08); }
.gl-tabs { display: flex; gap: 6px; background: var(--light-bg); padding: 4px; border-radius: 12px; }
.gl-tab { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 9px; font-weight: 700; font-size: .88rem; color: var(--muted); text-decoration: none; min-height: 40px; transition: all .15s; }
.gl-tab:hover { color: var(--navy); }
.gl-tab.active { background: var(--white); color: var(--navy); box-shadow: 0 2px 8px rgba(0, 0, 80, .10); }
.gl-tab span { font-size: .74rem; background: rgba(0, 0, 128, .08); color: var(--navy); border-radius: 99px; padding: 1px 8px; font-weight: 700; }
.gl-tab.active span { background: var(--navy); color: #fff; }
.gl-toolbar-note { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 8px; padding-right: 8px; }
.gl-toolbar-note i { color: var(--orange-dark); }

/* ── Album / video grid ── */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
.gl-card { position: relative; border-radius: 20px; overflow: hidden; background: #0d0d3a; box-shadow: 0 6px 26px rgba(0, 0, 80, .10); aspect-ratio: 4 / 3; isolation: isolate; transition: transform .25s ease, box-shadow .25s ease; }
.gl-card:hover { transform: translateY(-4px); box-shadow: 0 18px 44px rgba(0, 0, 80, .18); }
.gl-card-link { position: absolute; inset: 0; display: block; color: #fff; text-decoration: none; }
.gl-card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s ease; }
.gl-card:hover img { transform: scale(1.07); }
.gl-card-ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 2.4rem; color: rgba(255, 255, 255, .35); background: linear-gradient(135deg, #0b0b4a, #1c1c7a); }
.gl-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 30, 0) 40%, rgba(0, 0, 30, .85) 100%); pointer-events: none; z-index: 1; }
.gl-card-body { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 18px 16px; z-index: 2; color: #fff; pointer-events: none; }
.gl-card-cat { display: inline-block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--orange); margin-bottom: 4px; }
.gl-card-title { font-family: var(--font-display); font-weight: 800; font-size: 1.12rem; line-height: 1.25; margin: 0 0 4px; text-shadow: 0 1px 8px rgba(0, 0, 0, .3); }
.gl-card-meta { font-size: .78rem; color: rgba(255, 255, 255, .78); display: flex; gap: 12px; align-items: center; }
.gl-card-badge { position: absolute; top: 14px; left: 14px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; font-size: .74rem; font-weight: 700;
    background: rgba(0, 0, 30, .55); color: #fff; backdrop-filter: blur(6px); pointer-events: none; }
.gl-card-play { position: absolute; top: 12px; right: 12px; z-index: 3; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
    background: rgba(255, 255, 255, .95); color: var(--navy); display: grid; place-items: center; font-size: .9rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    opacity: 0; transform: scale(.85); transition: opacity .2s, transform .2s, background .2s; }
.gl-card:hover .gl-card-play, .gl-card-play:focus-visible { opacity: 1; transform: none; }
.gl-card-play:hover { background: var(--orange); }
.gl-card-video-ic { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; pointer-events: none; }
.gl-card-video-ic span { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .92); color: var(--navy); font-size: 1.3rem; padding-left: 4px;
    box-shadow: 0 0 0 10px rgba(255, 255, 255, .18); transition: transform .25s; }
.gl-card:hover .gl-card-video-ic span { transform: scale(1.1); }
@media (hover: none) { .gl-card-play { opacity: 1; transform: none; } }

/* ── Album page ── */
.gl-album-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: -40px 0 28px; position: relative; z-index: 2;
    background: var(--white); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; box-shadow: 0 14px 40px rgba(0, 0, 80, .08); }
.gl-back { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: .88rem; text-decoration: none; min-height: 40px; }
.gl-back:hover { color: var(--navy); }
.gl-album-meta { font-size: .86rem; color: var(--muted); }
.gl-album-meta strong { color: var(--dark-text); }
.gl-album-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Masonry: photos keep their natural shape. */
.gl-masonry { columns: 4 260px; column-gap: 16px; }
.gl-photo { display: block; margin: 0 0 16px; border-radius: 14px; overflow: hidden; position: relative; break-inside: avoid; background: var(--light-bg); box-shadow: 0 2px 12px rgba(0, 0, 80, .06); }
.gl-photo img { width: 100%; height: auto; display: block; transition: transform .5s ease, filter .3s; }
.gl-photo::after { content: "\f00e"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.4rem;
    background: rgba(0, 0, 40, .35); opacity: 0; transition: opacity .25s; }
.gl-photo:hover img { transform: scale(1.04); }
.gl-photo:hover::after, .gl-photo:focus-visible::after { opacity: 1; }
.gl-empty { text-align: center; color: var(--muted); margin: 40px 0; }
#galleryLoadMore.is-loading { opacity: .6; pointer-events: none; }

@media (max-width: 760px) {
    .gl-toolbar, .gl-album-head { margin-top: -28px; padding: 10px; border-radius: 14px; }
    .gl-tabs { width: 100%; }
    .gl-tab { flex: 1; justify-content: center; padding: 9px 8px; }
    .gl-toolbar-note { display: none; }
    .gallery-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .gl-card { border-radius: 14px; aspect-ratio: 1 / 1; }
    .gl-card-body { padding: 12px; }
    .gl-card-title { font-size: .92rem; }
    .gl-card-meta { font-size: .7rem; }
    .gl-card-video-ic span { width: 48px; height: 48px; font-size: 1rem; }
    .gl-card-play { width: 38px; height: 38px; top: 8px; right: 8px; }
    .gl-card-badge { top: 8px; left: 8px; font-size: .68rem; padding: 4px 8px; }
    .gl-masonry { columns: 2; column-gap: 10px; }
    .gl-photo { margin-bottom: 10px; border-radius: 10px; }
    .gl-album-actions { width: 100%; }
    .gl-album-actions .pbtn { flex: 1; justify-content: center; }
}
@media (max-width: 380px) { .gallery-grid { grid-template-columns: 1fr; } .gl-card { aspect-ratio: 4 / 3; } }

/* ============================================================
   Lightbox
   ============================================================ */
html.tlb-open, html.tlb-open body { overflow: hidden; }
.tlb { position: fixed; inset: 0; z-index: 10000; display: grid; grid-template-rows: auto 3px minmax(0, 1fr) auto auto; background: rgba(6, 6, 22, .97); color: #fff;
    opacity: 0; transition: opacity .22s ease; font-family: var(--font-main, system-ui); user-select: none; -webkit-user-select: none; }
.tlb.is-visible { opacity: 1; }
.tlb[hidden] { display: none; }
.tlb-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.tlb-info { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tlb-counter { font-weight: 800; font-size: .86rem; background: rgba(255, 255, 255, .1); padding: 5px 11px; border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tlb-title { font-size: .92rem; color: rgba(255, 255, 255, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlb-tools { display: flex; gap: 4px; flex-shrink: 0; }
.tlb-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: #fff; display: grid; place-items: center; font-size: 1.05rem; cursor: pointer; text-decoration: none; transition: background .15s; }
.tlb-btn:hover, .tlb-btn:focus-visible { background: rgba(255, 255, 255, .12); color: #fff; }
.tlb-btn:focus-visible { outline: 2px solid var(--orange, #ffa500); outline-offset: 1px; }
.tlb-btn[hidden] { display: none; }
.tlb-play { background: rgba(255, 165, 0, .18); color: var(--orange, #ffa500); }
.tlb.is-playing .tlb-play { background: var(--orange, #ffa500); color: #0d0d2b; }
.tlb-close { background: rgba(255, 255, 255, .1); }
.tlb-progress { height: 3px; background: rgba(255, 255, 255, .08); }
.tlb-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffa500, #ffc94d); }

.tlb-stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.tlb-media { position: relative; width: 100%; height: 100%; display: grid; place-items: center; padding: 10px 76px; box-sizing: border-box; }
.tlb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); transition: transform .25s ease, opacity .3s ease; opacity: 0; cursor: zoom-in; will-change: transform; }
.tlb-media.is-loaded .tlb-img { opacity: 1; }
.tlb.is-zoomed .tlb-img { cursor: grab; transition: opacity .3s ease; }
.tlb.is-zoomed .tlb-nav, .tlb.is-zoomed .tlb-caption { opacity: 0; pointer-events: none; }
.tlb-spinner { position: absolute; width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--orange, #ffa500); animation: tlbSpin .8s linear infinite; }
.tlb-media.is-loaded .tlb-spinner { display: none; }
.tlb-media.is-error::before { content: "This photo could not be loaded."; color: rgba(255, 255, 255, .6); }
@keyframes tlbSpin { to { transform: rotate(360deg); } }
.tlb-video { width: min(100%, 1100px); aspect-ratio: 16 / 9; max-height: 100%; background: #000; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.tlb-video iframe, .tlb-video video { width: 100%; height: 100%; border: 0; display: block; }

.tlb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 1.2rem; z-index: 2; backdrop-filter: blur(4px); transition: background .15s, opacity .2s; }
.tlb-nav:hover { background: rgba(255, 255, 255, .22); }
.tlb-prev { left: 14px; }
.tlb-next { right: 14px; }
.tlb.is-single .tlb-nav { display: none; }

.tlb-caption { text-align: center; padding: 8px 20px 4px; font-size: .9rem; color: rgba(255, 255, 255, .85); max-width: 900px; margin: 0 auto; transition: opacity .2s; }
.tlb-caption[hidden] { display: none; }
.tlb-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent; justify-content: safe center; }
.tlb.no-thumbs .tlb-thumbs, .tlb.no-thumb-strip .tlb-thumbs { display: none; }
.tlb.no-thumb-strip .tlb-thumbs-toggle { display: none; }
.tlb-thumb { flex: 0 0 72px; height: 52px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; padding: 0; background: rgba(255, 255, 255, .08); cursor: pointer; opacity: .5; transition: opacity .15s, border-color .15s; color: #fff; }
.tlb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tlb-thumb:hover { opacity: .85; }
.tlb-thumb.active { opacity: 1; border-color: var(--orange, #ffa500); }
.tlb-toast { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); background: #fff; color: #0d0d2b; padding: 9px 16px; border-radius: 10px; font-weight: 700; font-size: .84rem; }

/* Full screen: hide chrome while the slideshow plays; it comes back on hover/tap. */
.tlb.is-fullscreen.is-playing .tlb-thumbs, .tlb.is-fullscreen.is-playing .tlb-nav { opacity: 0; transition: opacity .3s; }
.tlb.is-fullscreen.is-playing:hover .tlb-nav { opacity: 1; }

@media (max-width: 760px) {
    .tlb-top { padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
    .tlb-title { display: none; }
    .tlb-btn { width: 40px; height: 40px; font-size: .98rem; }
    .tlb-share, .tlb-thumbs-toggle { display: none; }
    .tlb-media { padding: 6px; }
    .tlb-nav { width: 42px; height: 42px; font-size: 1rem; background: rgba(0, 0, 0, .35); }
    .tlb-prev { left: 6px; }
    .tlb-next { right: 6px; }
    .tlb-thumb { flex-basis: 56px; height: 42px; }
    .tlb-img { border-radius: 0; box-shadow: none; }
}
@media (max-width: 380px) { .tlb-zoom { display: none; } }
@media (prefers-reduced-motion: reduce) { .tlb, .tlb-img, .gl-card, .gl-card img, .gl-photo img { transition: none !important; } }
.gl-card .d-block { display: block; }
