/* ============================================
   ГАЛЕРЕЯ РАБОТ: сетка, фильтр, просмотр, сравнение
   Общая для главной и /portfolio/
   ============================================ */

/* ---- Фильтр по видам ---- */
.g-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    max-width: 900px;
    margin: 0 auto 2.2rem;
}

.g-filter {
    font-family: var(--font-body);
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    min-height: 44px;
    padding: 0.55rem 1.2rem;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.g-filter:hover,
.g-filter.is-active {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-glow);
}

.g-filter:focus-visible,
.g-item:focus-visible,
.g-lb button:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

/* ---- Сетка «как в журнале» ---- */
.portfolio__grid.g-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: clamp(160px, 17vw, 250px);
    grid-auto-flow: dense;
    gap: 1.2rem;
}

.g-grid .g-item {
    aspect-ratio: auto;
    min-height: 0;
}

.g-grid .g-item--big  { grid-column: span 2; grid-row: span 2; }
.g-grid .g-item--wide { grid-column: span 2; }
.g-grid .g-item--tall { grid-row: span 2; }
.g-grid .g-item[hidden] { display: none; }

.g-grid .g-item--big .portfolio__card-title { font-size: 1.6rem; }

/* Пометка «днём · с подсветкой» */
.g-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 3;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    padding: 0.3rem 0.65rem;
    background: rgba(10, 10, 15, 0.78);
    border: 1px solid var(--gold-dim);
    color: var(--gold-light);
    pointer-events: none;
}

/* Плавное появление при прокрутке (класс ставит gallery.js) */
.g-grid.g-reveal .g-item {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.4s ease;
}

.g-grid.g-reveal .g-item.is-in {
    opacity: 1;
    transform: none;
}

.g-grid.g-reveal .g-item.is-in:hover {
    transform: scale(1.02);
}

@media (max-width: 1024px) {
    .portfolio__grid.g-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: clamp(160px, 24vw, 240px);
    }
}

@media (max-width: 768px) {
    .portfolio__grid.g-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 44vw;
        gap: 0.7rem;
    }

    .g-grid .portfolio__card { padding: 8px; }
    .g-grid .portfolio__card img {
        inset: 8px;
        width: calc(100% - 16px);
        height: calc(100% - 16px);
    }
    .g-grid .portfolio__card::after {
        inset: 8px;
        background: linear-gradient(180deg, transparent 35%, rgba(10, 10, 15, 0.88) 100%);
    }
    .g-grid .portfolio__card-frame { inset: 3px; }
    .g-grid .portfolio__card-info {
        bottom: 8px;
        left: 8px;
        right: 8px;
        padding: 0.6rem 0.7rem;
    }
    .g-grid .portfolio__card-title,
    .g-grid .g-item--big .portfolio__card-title { font-size: 1.1rem; }
    .g-grid .portfolio__card-desc { font-size: 0.8rem; letter-spacing: 0.02em; }
    .g-grid .portfolio__card:hover,
    .g-grid.g-reveal .g-item.is-in:hover { transform: none; }

    .g-badge { top: 12px; right: 12px; font-size: 0.68rem; padding: 0.2rem 0.45rem; }

    .g-filters { gap: 0.4rem; margin-bottom: 1.5rem; }
    .g-filter { padding: 0.5rem 0.9rem; font-size: 0.85rem; }
}

/* ---- Просмотр на весь экран ---- */
.g-lb {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: #060609;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.g-lb.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

.g-lb__stage {
    position: absolute;
    inset: 0 0 118px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 72px 0;
}

.g-lb__slide {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
}

.g-lb__img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 190px);
    max-height: calc(100dvh - 190px);
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    -webkit-user-drag: none;
}

.g-lb__slide.is-enter-next { animation: g-in-next 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
.g-lb__slide.is-enter-prev { animation: g-in-prev 0.35s cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes g-in-next { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
@keyframes g-in-prev { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }

.g-lb__close {
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    z-index: 3;
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2.4rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.25s ease;
}

.g-lb__close:hover { color: var(--gold); }

.g-lb__nav {
    position: absolute;
    top: calc(50% - 59px);
    transform: translateY(-50%);
    z-index: 3;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.55);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    color: var(--gold);
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.g-lb__nav svg { width: 22px; height: 22px; }
.g-lb__nav:hover { background: var(--gold-glow); border-color: var(--gold); }
.g-lb__prev { left: 1rem; }
.g-lb__next { right: 1rem; }
.g-lb__nav[hidden] { display: none; }

.g-lb__footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 118px;
    padding: 0.9rem 1rem 1.2rem;
    text-align: center;
    z-index: 2;
}

.g-lb__title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    color: var(--gold);
    margin-bottom: 0.2rem;
}

.g-lb__counter {
    font-size: 0.9rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.g-lb__dots {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    margin-top: 0.4rem;
}

.g-lb__dot {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    position: relative;
}

.g-lb__dot::before {
    content: '';
    position: absolute;
    inset: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.25s ease;
}

.g-lb__dot.is-active::before { background: var(--gold); }

/* ---- Сравнение «днём / с подсветкой» ---- */
.g-cmp-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.g-cmp {
    position: relative;
    width: min(calc(100vw - 180px), calc((100vh - 250px) * var(--ar, 1.6)));
    width: min(calc(100vw - 180px), calc((100dvh - 250px) * var(--ar, 1.6)));
    aspect-ratio: var(--ar, 1.6);
    overflow: hidden;
    cursor: ew-resize;
    touch-action: pan-y;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    --pos: 50%;
}

.g-cmp img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    -webkit-user-drag: none;
    pointer-events: none;
}

.g-cmp__night { clip-path: inset(0 0 0 var(--pos)); }
.g-cmp.is-animating .g-cmp__night { transition: clip-path 0.45s ease; }
.g-cmp.is-animating .g-cmp__line { transition: left 0.45s ease; }

.g-cmp__line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--pos);
    width: 2px;
    margin-left: -1px;
    background: var(--gold-light);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.g-cmp__knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(10, 10, 15, 0.8);
    border: 2px solid var(--gold-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold-light);
}

.g-cmp__knob svg { width: 22px; height: 22px; }

.g-cmp__label {
    position: absolute;
    top: 10px;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.6rem;
    background: rgba(10, 10, 15, 0.72);
    color: var(--text-primary);
    pointer-events: none;
}

.g-cmp__label--day { left: 10px; }
.g-cmp__label--night { right: 10px; }

.g-cmp__range {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.g-cmp:focus-within { outline: 2px solid var(--gold); outline-offset: 3px; }

.g-cmp__switch {
    display: inline-flex;
    border: 1px solid var(--border-light);
}

.g-cmp__switch button {
    min-height: 44px;
    padding: 0.4rem 1.1rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
    letter-spacing: 0.05em;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease;
}

.g-cmp__switch button.is-active {
    background: var(--gold-glow);
    color: var(--gold);
}

@media (max-width: 768px) {
    .g-lb__stage { padding: 52px 10px 0; inset: 0 0 112px; }
    .g-lb__nav { width: 44px; height: 44px; top: auto; bottom: 30px; transform: none; }
    .g-lb__prev { left: 0.75rem; }
    .g-lb__next { right: 0.75rem; }
    .g-lb__footer { padding: 0.8rem 64px 1rem; height: 112px; }
    .g-lb__title { font-size: 1.15rem; }
    .g-lb__close { top: 0.3rem; right: 0.3rem; }
    .g-lb__img { max-height: calc(100vh - 175px); max-height: calc(100dvh - 175px); }
    .g-cmp {
        width: min(calc(100vw - 20px), calc((100vh - 240px) * var(--ar, 1.6)));
        width: min(calc(100vw - 20px), calc((100dvh - 240px) * var(--ar, 1.6)));
    }
}

/* Без движения для тех, кто его отключил */
@media (prefers-reduced-motion: reduce) {
    .g-grid.g-reveal .g-item { opacity: 1; transform: none; transition: none; }
    .g-lb, .g-lb.is-open { transition: none; }
    .g-lb__slide.is-enter-next,
    .g-lb__slide.is-enter-prev { animation: none; }
    .g-cmp.is-animating .g-cmp__night,
    .g-cmp.is-animating .g-cmp__line { transition: none; }
    .g-grid .portfolio__card,
    .g-grid .portfolio__card img { transition: none; }
    .g-grid .portfolio__card:hover,
    .g-grid .portfolio__card:hover img { transform: none; }
}
