/* ============================================================
   IME — Gallery page
   Uses the design tokens declared in mystyle.css
   (--ime-ink, --ime-red, --ime-red-tint, --ime-radius, --ime-shadow)
   Filter pills reuse .ime-tab-bar / .ime-tab-btn / .ime-tab-highlight
   from mystyle.css so the animated-pill behaviour matches Events/Home.
   ============================================================ */

/* ---- Masonry-style grid ----
   4 equal columns, dense auto-flow so tagged "big" / "wide" / "tall"
   tiles can take up extra space without leaving gaps. */
.ime-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 180px;
    grid-auto-flow: dense;
    gap: 18px;
    margin-bottom: 8px;
}

.ime-gallery-item {
    position: relative;
    grid-column: span 1;
    grid-row: span 1;
    border-radius: var(--ime-radius);
    overflow: hidden;
    background: var(--ime-paper);
    border: 1px solid var(--ime-line);
    cursor: pointer;
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.ime-gallery-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--ime-shadow);
    border-color: transparent;
    z-index: 2;
}

/* Size variants — set via PHP on individual items to echo the
   "some tiles bigger than others" masonry look */
.ime-gallery-item--wide { grid-column: span 2; }
.ime-gallery-item--tall { grid-row: span 2; }
.ime-gallery-item--big  { grid-column: span 2; grid-row: span 2; }

@media (max-width: 992px) {
    .ime-gallery-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
    .ime-gallery-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 150px; }
    .ime-gallery-item--big  { grid-column: span 2; grid-row: span 2; }
    .ime-gallery-item--wide { grid-column: span 2; }
}
@media (max-width: 480px) {
    .ime-gallery-grid { grid-template-columns: 1fr; grid-auto-rows: 220px; }
    .ime-gallery-item--wide,
    .ime-gallery-item--big { grid-column: span 1; }
}

/* Media */
.ime-gallery-media {
    position: absolute;
    inset: 0;
}
.ime-gallery-media img,
.ime-gallery-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* Diagonal-stripe placeholder backdrop, cycling through a few tints
   so an "album" of placeholders still reads as a gallery, not one grey block */
.ime-gallery-media:not(:has(img)) {
    background: repeating-linear-gradient(135deg, #E9F7F1 0 10px, #fff 10px 20px);
}
.ime-gallery-item:nth-of-type(4n+2) .ime-gallery-media:not(:has(img)) {
    background: repeating-linear-gradient(135deg, #FBEBEA 0 10px, #fff 10px 20px);
}
.ime-gallery-item:nth-of-type(4n+3) .ime-gallery-media:not(:has(img)) {
    background: repeating-linear-gradient(135deg, #E9F1FB 0 10px, #fff 10px 20px);
}
.ime-gallery-item:nth-of-type(4n+4) .ime-gallery-media:not(:has(img)) {
    background: repeating-linear-gradient(135deg, #FBF3E1 0 10px, #fff 10px 20px);
}
.ime-gallery-placeholder-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ime-ink-soft);
}

/* "Video" badge, top-right */
.ime-gallery-video-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(20,22,27,.66);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
}
.ime-gallery-video-badge i { font-size: 10px; }

/* Bottom gradient + caption, shown on big/tall tiles by default and
   on every tile on hover */
.ime-gallery-caption {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 2;
    padding: 40px 18px 16px;
    background: linear-gradient(180deg, rgba(20,22,27,0) 0%, rgba(20,22,27,.82) 100%);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .22s ease, transform .22s ease;
}
.ime-gallery-item--big .ime-gallery-caption,
.ime-gallery-item--tall .ime-gallery-caption,
.ime-gallery-item--wide .ime-gallery-caption {
    opacity: 1;
    transform: translateY(0);
}
.ime-gallery-item:hover .ime-gallery-caption { opacity: 1; transform: translateY(0); }

.ime-gallery-caption-tag {
    display: block;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgba(255,255,255,.72);
    margin-bottom: 4px;
}
.ime-gallery-caption-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.3;
}

.ime-gallery-empty {
    text-align: center;
    color: var(--ime-muted);
    font-size: 14px;
    padding: 40px 0 4px;
}

/* Load more */
.ime-gallery-more {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}
.ime-btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--ime-paper);
    color: var(--ime-ink) !important;
    font-weight: 700;
    font-size: 14px;
    padding: 13px 28px;
    border: 1px solid var(--ime-line);
    border-radius: 10px;
    text-decoration: none !important;
    transition: border-color .2s ease, color .2s ease, transform .2s ease;
}
.ime-btn-outline:hover {
    border-color: var(--ime-red);
    color: var(--ime-red) !important;
    transform: translateY(-2px);
}

/* ---- Lightbox (simple, dependency-free) ---- */
.ime-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(14,15,18,.92);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.ime-lightbox.active { display: flex; }
.ime-lightbox-inner {
    position: relative;
    max-width: 900px;
    width: 100%;
}
.ime-lightbox-media {
    width: 100%;
    max-height: 78vh;
    border-radius: 10px;
    overflow: hidden;
    background: repeating-linear-gradient(135deg, #2A2D35 0 14px, #34383F 14px 28px);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
}
.ime-lightbox-media img,
.ime-lightbox-media video {
    width: 100%;
    height: 100%;
    max-height: 78vh;
    object-fit: contain;
    display: block;
}
.ime-lightbox-caption {
    color: #fff;
    text-align: center;
    margin-top: 16px;
}
.ime-lightbox-caption .tag {
    display: block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ime-red);
    margin-bottom: 6px;
}
.ime-lightbox-close {
    position: absolute;
    top: -46px;
    right: 0;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: background .2s ease;
}
.ime-lightbox-close:hover { background: var(--ime-red); border-color: var(--ime-red); }


/* ============================================================
   Sub-category (event) chips — shown under the category pills
   ============================================================ */
.ime-gallery-subfilter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -12px 0 26px;
}
.ime-gallery-subfilter[hidden] { display: none; }
.ime-gallery-chip {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 7px 8px 7px 14px;
    border: 1px solid var(--ime-line) !important;
    border-radius: 999px !important;
    background: var(--ime-paper) !important;
    color: var(--ime-ink-soft) !important;
    font-family: inherit;
    font-size: 13px !important;
    font-weight: 700;
    line-height: 1.2 !important;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.ime-gallery-chip em {
    font-style: normal;
    font-size: 11px;
    font-weight: 800;
    min-width: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--ime-paper-alt);
    color: var(--ime-muted);
    text-align: center;
}
.ime-gallery-chip:hover { border-color: var(--ime-red) !important; color: var(--ime-red) !important; }
.ime-gallery-chip.active {
    background: var(--ime-red-tint) !important;
    border-color: var(--ime-red) !important;
    color: var(--ime-red) !important;
}
.ime-gallery-chip.active em { background: var(--ime-red); color: #fff; }
.ime-gallery-chip:focus-visible { outline: 2px solid var(--ime-red); outline-offset: 2px; }

/* ============================================================
   Gallery pagination (16 per page)
   ============================================================ */
.ime-gallery-pager-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--ime-line);
}
.ime-gallery-pager-wrap .ime-gallery-count {
    margin: 0 !important;
    font-size: 13.5px !important;
    line-height: 1.4 !important;
    color: var(--ime-muted) !important;
    font-weight: 600;
}
.ime-gallery-pager-wrap .ime-gallery-pager { display: flex; align-items: center; gap: 6px; }
.ime-gallery-pager .ime-page-btn {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    min-width: 38px;
    height: 38px;
    margin: 0;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ime-line) !important;
    border-radius: 10px !important;
    background: var(--ime-paper) !important;
    color: var(--ime-ink) !important;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 700;
    line-height: 1 !important;
    box-shadow: none;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, transform .2s ease;
}
.ime-gallery-pager .ime-page-btn:hover:not(:disabled):not(.active) {
    border-color: var(--ime-red) !important;
    color: var(--ime-red) !important;
    transform: translateY(-1px);
}
.ime-gallery-pager .ime-page-btn.active {
    background: var(--ime-red) !important;
    border-color: var(--ime-red) !important;
    color: #fff !important;
    box-shadow: var(--ime-shadow-red);
    cursor: default;
}
.ime-gallery-pager .ime-page-btn:disabled { opacity: .35; cursor: not-allowed; }
.ime-gallery-pager .ime-page-btn:focus-visible { outline: 2px solid var(--ime-red); outline-offset: 2px; }
.ime-gallery-pager .ime-page-arrow { padding: 0; width: 38px; }
.ime-gallery-pager .ime-page-arrow i { font-size: 12px; }
.ime-gallery-pager .ime-page-dots { min-width: 22px; text-align: center; color: var(--ime-muted); font-weight: 700; }

@media (max-width: 575px) {
    .ime-gallery-subfilter { margin-top: -14px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .ime-gallery-chip { flex: 0 0 auto; }
    .ime-gallery-pager-wrap { flex-direction: column-reverse; align-items: center; }
    .ime-gallery-pager .ime-page-btn { min-width: 34px; height: 34px; font-size: 13px !important; }
    .ime-gallery-pager .ime-page-arrow { width: 34px; }
}

/* Clicked tab pills: no black browser focus ring (keyboard users still get one) */
.ime-tab-btn:focus { outline: none; box-shadow: none; }
.ime-tab-btn:focus-visible { outline: 2px solid var(--ime-red); outline-offset: 2px; }
