/* Gallery lightbox — vanilla <dialog> + Swiper. */

.tm-gallery {
    padding: 0;
    border: 0;
    background: transparent;
    width: 100%;
    max-width: 100vw;
    max-height: 100vh;
    color: var(--tm-white);
}

.tm-gallery::backdrop {
    background: rgba(13, 22, 38, 0.92);
    backdrop-filter: blur(6px);
}

.tm-gallery[open] {
    display: flex;
}

.tm-gallery-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--tm-space-4) var(--tm-space-4) var(--tm-space-6);
    gap: var(--tm-space-3);
}

.tm-gallery-head {
    display: flex;
    align-items: center;
    gap: var(--tm-space-4);
    flex-wrap: wrap;
}

.tm-gallery-count {
    margin: 0;
    font-size: var(--tm-font-size-sm);
    color: rgba(255, 255, 255, 0.7);
    font-variant-numeric: tabular-nums;
    min-width: 70px;
}

.tm-gallery-count [data-tm-gallery-current] {
    color: var(--tm-white);
    font-weight: var(--tm-font-weight-semibold);
}

.tm-gallery-sep {
    margin: 0 4px;
    opacity: 0.5;
}

.tm-gallery-filter {
    display: flex;
    gap: 6px;
    flex: 1;
    flex-wrap: wrap;
    justify-content: center;
    min-width: 0;
}

.tm-gallery-chip {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    font-family: inherit;
    font-size: var(--tm-font-size-sm);
    font-weight: var(--tm-font-weight-medium);
    padding: 6px 14px;
    border-radius: var(--tm-radius-full);
    cursor: pointer;
    transition: background var(--tm-transition-fast), color var(--tm-transition-fast);
}

.tm-gallery-chip:hover {
    background: rgba(255, 255, 255, 0.16);
    color: var(--tm-white);
}

.tm-gallery-chip.is-active {
    background: var(--tm-white);
    color: var(--tm-dark);
}

.tm-gallery-close {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    color: var(--tm-white);
    width: 40px;
    height: 40px;
    border-radius: var(--tm-radius-full);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    transition: background var(--tm-transition-fast);
}

.tm-gallery-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tm-gallery-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tm-gallery-nav {
    appearance: none;
    border: 0;
    background: rgba(0, 0, 0, 0.35);
    color: var(--tm-white);
    width: 48px;
    height: 48px;
    border-radius: var(--tm-radius-full);
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--tm-transition-fast);
}

.tm-gallery-nav:hover {
    background: rgba(0, 0, 0, 0.55);
}

.tm-gallery-nav--prev { left: var(--tm-space-2); }
.tm-gallery-nav--next { right: var(--tm-space-2); }

.tm-gallery-swiper {
    width: 100%;
    height: 100%;
}

.tm-gallery-slide {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    gap: var(--tm-space-3);
}

.tm-gallery-slide.is-hidden {
    display: none !important;
}

.tm-gallery-slide picture {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
}

.tm-gallery-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--tm-radius-md);
}

/* Fixed single-line height — so a long/short alt text never changes the
   caption's height and steals space from the flex:1 picture above it.
   That keeps the image viewport identical on every slide (no jump when
   swiping between photos). */
.tm-gallery-caption {
    display: flex;
    align-items: center;
    gap: var(--tm-space-3);
    font-size: var(--tm-font-size-sm);
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    justify-content: center;
    min-height: 30px;
    overflow: hidden;
}

.tm-gallery-caption-alt {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tm-gallery-caption-tag {
    background: rgba(255, 255, 255, 0.12);
    padding: 4px 10px;
    border-radius: var(--tm-radius-full);
    font-size: var(--tm-font-size-xs);
    font-weight: var(--tm-font-weight-medium);
    color: var(--tm-white);
}

@media (max-width: 575.98px) {
    .tm-gallery-head { gap: var(--tm-space-2); }
    .tm-gallery-filter { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
    .tm-gallery-nav { width: 40px; height: 40px; }
}
