/* =========================================================
   TC Gallery — Mobile-first Grid & Custom Lightbox
   ========================================================= */

.tc-gallery-host {
    background: #0d0d0d;
    padding: 6px;
    font-size: 16px;
}

.tc-gallery-wrap + .tc-gallery-wrap {
    margin-top: 16px;
}

.tc-gallery-title {
    color: #fff;
    font-family: "PT Sans Narrow", sans-serif;
    font-size: 20px;
    padding: 8px 6px 10px;
    text-align: center;
}

.tc-gallery-video {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.tc-gallery-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- Сетка превью (Mobile-first) --- */
.tc-gallery {
    display: grid;
    gap: 6px;
    grid-auto-flow: dense;
}

/* Сброс возможных правил из main.min7.css для figure */
.tc-gallery-host .tc-gallery__item {
    width: auto !important;
    display: block !important;
    margin: 0 !important;
    border: 0 !important;
    padding: 0 !important;
    position: relative;
    overflow: hidden;
    background: #1a1a1a;
    border-radius: 3px;
}

.tc-gallery__link {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
    overflow: hidden;
}

.tc-gallery__link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease, opacity 0.25s ease;
}

.tc-gallery__link:hover img {
    transform: scale(1.04);
}

/* 1. Горизонтальная галерея (3:2) */
.tc-gallery--horizontal {
    grid-template-columns: repeat(2, 1fr);
}
.tc-gallery--horizontal .tc-gallery__item {
    aspect-ratio: 3 / 2;
}

/* 2. Вертикальная галерея (3:4) */
.tc-gallery--vertical {
    grid-template-columns: repeat(2, 1fr);
}
.tc-gallery--vertical .tc-gallery__item {
    aspect-ratio: 3 / 4;
}

/* 3. Микс (1 горизонтальное = 2 вертикальных по ширине и высоте) */
.tc-gallery--mix {
    grid-template-columns: repeat(2, 1fr);
}
.tc-gallery--mix .tc-gallery__item--v {
    grid-column: span 1;
    aspect-ratio: 3 / 4;
}
.tc-gallery--mix .tc-gallery__item--h {
    grid-column: span 2;
    aspect-ratio: 3 / 2;
}

/* Планшеты (>= 768px) */
@media (min-width: 768px) {
    .tc-gallery {
        gap: 8px;
    }
    .tc-gallery--horizontal {
        grid-template-columns: repeat(3, 1fr);
    }
    .tc-gallery--vertical {
        grid-template-columns: repeat(4, 1fr);
    }
    .tc-gallery--mix {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Ноутбуки (>= 1024px) */
@media (min-width: 1024px) {
    .tc-gallery--horizontal {
        grid-template-columns: repeat(4, 1fr);
    }
    .tc-gallery--vertical {
        grid-template-columns: repeat(5, 1fr);
    }
    .tc-gallery--mix {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Широкие экраны (>= 1400px) */
@media (min-width: 1400px) {
    .tc-gallery--horizontal {
        grid-template-columns: repeat(5, 1fr);
    }
    .tc-gallery--vertical {
        grid-template-columns: repeat(6, 1fr);
    }
    .tc-gallery--mix {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* =========================================================
   Лайтбокс (Fullscreen + Swipe + 1:1 Zoom & Pan)
   ========================================================= */
html.tc-lb-open,
html.tc-lb-open body {
    overflow: hidden !important;
    touch-action: none;
}

.tc-lb {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(10, 10, 12, 0.96);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.tc-lb.is-open {
    opacity: 1;
    visibility: visible;
}

/* Верхняя панель */
.tc-lb__bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent);
    pointer-events: none;
}

.tc-lb__counter {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.5px;
    padding-left: 6px;
    pointer-events: auto;
}

.tc-lb__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.tc-lb__btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    padding: 0;
}

.tc-lb__btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.tc-lb__btn:active {
    transform: scale(0.94);
}

.tc-lb__btn--zoom {
    width: auto;
    padding: 0 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.4px;
}

.tc-lb__btn--zoom.is-active {
    background: #c00;
}

/* Стрелки навигации */
.tc-lb__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 46px;
    height: 64px;
    border: 0;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
    padding: 0;
}

.tc-lb__nav:hover {
    background: rgba(0, 0, 0, 0.7);
}

.tc-lb__nav--prev { left: 10px; }
.tc-lb__nav--next { right: 10px; }

/* На мобильных прячем стрелки (работают свайпы), но оставляем клик по кнопкам на планшетах/ПК */
@media (max-width: 767.98px) {
    .tc-lb__nav {
        display: none;
    }
}

.tc-lb.is-zoomed .tc-lb__nav {
    opacity: 0;
    pointer-events: none;
}

/* Сцена с изображением */
.tc-lb__stage {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tc-lb__img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    cursor: zoom-in;
    transform-origin: center center;
    will-change: transform;
    transition: opacity 0.2s ease;
    -webkit-user-drag: none;
}

.tc-lb__img.is-ready {
    opacity: 1;
}

.tc-lb.is-zoomed .tc-lb__img {
    cursor: grab;
}

.tc-lb.is-zoomed.is-dragging .tc-lb__img {
    cursor: grabbing;
}

/* Подпись снизу */
.tc-lb__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.88);
    font-size: 14px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
    pointer-events: none;
    z-index: 9;
    transition: opacity 0.2s ease;
}

.tc-lb__caption:empty,
.tc-lb.is-zoomed .tc-lb__caption {
    opacity: 0;
}

/* Цветной переливающийся текст Loading... */
.tc-lb__loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.tc-lb.is-loading .tc-lb__loader {
    opacity: 1;
}

.tc-lb__loader-text {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(
        90deg,
        #ff3b30 0%,
        #ff9500 18%,
        #ffcc00 34%,
        #34c759 50%,
        #00c7be 66%,
        #0a84ff 82%,
        #bf5af2 92%,
        #ff3b30 100%
    );
    background-size: 260% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: tcShimmer 1.6s linear infinite;
}

@keyframes tcShimmer {
    0%   { background-position: 0% 50%; }
    100% { background-position: 260% 50%; }
}