/* ==========================================================================
   TUC Gallery – Stylesheet v1.1
   Equal-height rows using aspect-ratio-proportional flex-grow
   ========================================================================== */

.tuc-gallery {
    margin: 1.5em 0;
    width: 100%;
}

/* Row: flex container with fixed gap */
.tuc-gallery-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    width: 100%;
}

.tuc-gallery-row:last-child {
    margin-bottom: 0;
}

/* Item: flex-grow is set inline proportional to aspect ratio.
   This ensures all items in a row reach the same height. */
.tuc-gallery-item {
    flex-shrink: 0;
    min-width: 0;
    overflow: hidden;
}

/* Aspect ratio box: reserves vertical space before image loads */
.tuc-gallery-aspect {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Link: fills the aspect box */
.tuc-gallery-link {
    position: absolute;
    inset: 0;
    display: block;
    line-height: 0;
    cursor: pointer;
    text-decoration: none;
    border: none;
    outline: none;
}

/* Image: fill box, cover, no distortion */
.tuc-gallery-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: opacity 0.2s ease;
}

.tuc-gallery-link:hover .tuc-gallery-img {
    opacity: 0.88;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.tuc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.tuc-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.tuc-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tuc-lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tuc-lightbox-img.is-loaded {
    opacity: 1;
}

.tuc-lightbox-caption {
    position: absolute;
    bottom: -2em;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85em;
    line-height: 1.4;
    padding: 0 1em;
}

.tuc-lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000000;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.tuc-lightbox-close:hover {
    transform: scale(1.1);
}

.tuc-lightbox-close svg {
    width: 28px;
    height: 28px;
    stroke: #fff;
    stroke-width: 2;
    fill: none;
}

.tuc-lightbox-prev,
.tuc-lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000000;
    width: 50px;
    height: 50px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
    opacity: 0.7;
}

.tuc-lightbox-prev:hover,
.tuc-lightbox-next:hover {
    opacity: 1;
}

.tuc-lightbox-prev { left: 16px; }
.tuc-lightbox-next { right: 16px; }

.tuc-lightbox-prev svg,
.tuc-lightbox-next svg {
    width: 32px;
    height: 32px;
    stroke: #fff;
    stroke-width: 2;
    fill: none;
}

.tuc-lightbox-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8em;
    letter-spacing: 0.05em;
}

.tuc-lightbox[data-total="1"] .tuc-lightbox-prev,
.tuc-lightbox[data-total="1"] .tuc-lightbox-next,
.tuc-lightbox[data-total="1"] .tuc-lightbox-counter {
    display: none;
}

.tuc-lightbox-spinner {
    position: absolute;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tuc-spin 0.7s linear infinite;
}

@keyframes tuc-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
    .tuc-gallery-row {
        gap: 4px;
        margin-bottom: 4px;
    }

    .tuc-lightbox-prev { left: 8px; }
    .tuc-lightbox-next { right: 8px; }
    .tuc-lightbox-close { top: 12px; right: 12px; }

    .tuc-lightbox-prev svg,
    .tuc-lightbox-next svg {
        width: 24px;
        height: 24px;
    }
}
