/* ==========================================================================
   Мирчев Студио — Photo gallery redesign (photo-gallery-v1)
   Builds on the shared v1 design system in index-v1.css (header, split hero,
   buttons, CTA, footer). Only gallery + lightbox styles live here.
   Scoped to body.v1-page-photo.
   ========================================================================== */

/* ---------- Hero ---------- */
.v1-photo-hero__title {
    margin-bottom: 32px !important;
}

/* ---------- Intro ---------- */
.v1-gallery__head {
    max-width: 780px;
}

.v1-gallery__intro {
    margin: 22px auto 0 !important;
    max-width: 62ch;
    color: var(--v1-muted);
}

.v1-gallery__motto {
    margin: 18px 0 0 !important;
    font-family: var(--v1-serif);
    font-style: italic;
    font-size: clamp(1.4rem, 1.2rem + .8vw, 1.8rem);
    color: var(--v1-gold-text);
}

/* ---------- Justified rows ----------
   Every tile grows in proportion to its aspect ratio, so each row fills the
   width with equal-height photos and nothing is cropped; reading order is kept. */
.v1-justified {
    --v1-row: 250px;
    --v1-gap: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--v1-gap);
}

/* Stops the last, incomplete row from stretching */
.v1-justified::after {
    content: "";
    flex: 999999 1 0;
}

.v1-tile {
    --v1-ar: 1.5;
    flex: var(--v1-ar) 1 calc(var(--v1-ar) * var(--v1-row));
    aspect-ratio: var(--v1-ar);
    min-width: 0;
}

/* Set by photo-gallery-v1.js when the last row is short: centre it */
.v1-justified.has-short-last {
    justify-content: center;
}

.v1-justified.has-short-last::after {
    display: none;
}

.v1-tile.is-last-row {
    flex-grow: 0;
}

.v1-tile--landscape { --v1-ar: 1.5; }
.v1-tile--portrait  { --v1-ar: .6667; }

@media (max-width: 1199.98px) { .v1-justified { --v1-row: 220px; } }
@media (max-width: 767.98px)  { .v1-justified { --v1-row: 200px; --v1-gap: 8px; } }
@media (max-width: 479.98px)  { .v1-justified { --v1-row: 160px; --v1-gap: 6px; } }

.v1-tile__link {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: var(--v1-radius);
    background: var(--v1-sand);
    cursor: zoom-in;
}

.v1-tile__link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.2s var(--v1-ease), filter .6s var(--v1-ease);
}

.v1-tile__link::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(22, 17, 13, .55), rgba(22, 17, 13, 0) 55%);
    opacity: 0;
    transition: opacity .4s var(--v1-ease);
}

.v1-tile__zoom {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--v1-gold);
    color: var(--v1-ink);
    opacity: 0;
    transform: translateY(8px) scale(.9);
    transition: opacity .35s var(--v1-ease), transform .35s var(--v1-ease);
}

.v1-tile__zoom .v1-icon {
    width: 20px;
    height: 20px;
}

.v1-tile__link:hover img,
.v1-tile__link:focus-visible img {
    transform: scale(1.04);
}

.v1-tile__link:hover::after,
.v1-tile__link:focus-visible::after,
.v1-tile__link:hover .v1-tile__zoom,
.v1-tile__link:focus-visible .v1-tile__zoom {
    opacity: 1;
}

.v1-tile__link:hover .v1-tile__zoom,
.v1-tile__link:focus-visible .v1-tile__zoom {
    transform: none;
}

.v1-tile__link:focus-visible {
    outline-offset: 3px;
}

/* Touch screens: no hover, so keep the zoom hint faintly visible */
@media (hover: none) {
    .v1-tile__zoom {
        opacity: .9;
        transform: none;
        width: 36px;
        height: 36px;
        right: 8px;
        bottom: 8px;
    }

    .v1-tile__zoom .v1-icon { width: 16px; height: 16px; }
}

.v1-gallery__hint {
    margin: 22px 0 0 !important;
    text-align: center;
    font-size: .9rem;
    color: var(--v1-muted);
}

.v1-gallery__next {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: clamp(40px, 5vw, 64px);
}

@media (max-width: 575.98px) {
    .v1-gallery__next .v1-btn { flex: 1 1 100%; }
}

/* ---------- Lightbox ---------- */
.v1-lb {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(14, 10, 8, .96);
    color: var(--v1-on-dark);
    overflow: hidden;
}

.v1-lb::backdrop {
    background: rgba(14, 10, 8, .96);
}

.v1-lb[open] {
    display: grid;
    place-items: center;
    animation: v1-lb-in .3s var(--v1-ease);
}

@keyframes v1-lb-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.v1-lb__stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin: 0;
    padding: 72px 96px 24px;
    max-width: 100%;
    max-height: 100%;
    touch-action: pan-y;
}

.v1-lb__img {
    display: block;
    max-width: min(100%, 1600px);
    max-height: calc(100vh - 170px);
    max-height: calc(100dvh - 170px);
    width: auto;
    height: auto;
    border-radius: var(--v1-radius);
    box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9);
    transition: opacity .25s var(--v1-ease), transform .25s var(--v1-ease);
    user-select: none;
    -webkit-user-drag: none;
}

.v1-lb.is-loading .v1-lb__img {
    opacity: .25;
}

.v1-lb__caption {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 6px 16px;
    max-width: 70ch;
    text-align: center;
    font-size: .95rem;
    color: var(--v1-on-dark-muted);
}

.v1-lb__count {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .18em;
    color: var(--v1-gold);
    font-variant-numeric: tabular-nums;
}

.v1-lb__alt::first-letter {
    text-transform: uppercase;
}

.v1-lb__btn {
    position: absolute;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 50%;
    background: rgba(22, 17, 13, .6);
    color: #fff;
    cursor: pointer;
    transition: background-color .25s, color .25s, border-color .25s;
}

.v1-lb__btn:hover {
    background: var(--v1-gold);
    border-color: var(--v1-gold);
    color: var(--v1-ink);
}

.v1-lb__btn .v1-icon {
    width: 22px;
    height: 22px;
}

.v1-lb__close {
    top: 18px;
    right: 18px;
}

.v1-lb__nav {
    top: 50%;
    transform: translateY(-50%);
}

.v1-lb__nav--prev { left: 24px; }
.v1-lb__nav--next { right: 24px; }

@media (max-width: 767.98px) {
    .v1-lb__stage {
        padding: 72px 12px 96px;
    }

    .v1-lb__img {
        max-height: calc(100vh - 220px);
        max-height: calc(100dvh - 220px);
    }

    .v1-lb__nav {
        top: auto;
        bottom: 22px;
        transform: none;
    }

    .v1-lb__nav--prev { left: calc(50% - 64px); }
    .v1-lb__nav--next { right: calc(50% - 64px); }
}

@media (prefers-reduced-motion: reduce) {
    .v1-lb[open] { animation: none; }
}
