/*-----------------------------------------------------------------------------------

  Zovencia Pvt. Ltd. — portfolio Gallery
  Sole owner of .z-project-card styling. Replaces the previous vertical
  scroll-reveal hover with a uniform cropped grid plus a lightbox.

  Layout contract
    Every card is identical in size no matter what the source image measures.
    The thumb is a fixed-aspect box and the image is absolutely positioned
    inside it with object-fit: cover, so intrinsic image dimensions can never
    reach the grid. Nothing here depends on the image having loaded.

------------------------------------------------------------------------------------

/************ TABLE OF CONTENTS ***************
01. grid
02. card
03. thumbnail
04. hover overlay
05. card content
06. lightbox
07. reduced motion
08. selected work (homepage)
**********************************************/


/*----------------------------------------*/
/* 01. grid */
/*----------------------------------------*/


/* Scoped with :has() so only project galleries are affected — the category
   cards on portfolio-5 share .works-wrapper-6 and keep their own rhythm. */

.works-wrapper-6:has(.z-project-card) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 34px;
    align-items: start;
}


/* The template builds an editorial masonry out of this grid by giving
   `.works-wrapper-6 > *:nth-child(n)` a `grid-column: span 2` (and span 4 on
   the 8th). That is what made cards different widths — a spanning card is
   twice as wide, and with a fixed aspect ratio it is then twice as tall too.
   Every project card is pinned back to a single column here.

   Specificity note: the template's rules are (0,2,0). This selector is (0,3,0)
   — class + :has(class) + class — so it wins on merit rather than !important. */

.works-wrapper-6:has(.z-project-card)>.z-project-card {
    grid-column: span 1;
    grid-row: auto;
}

@media only screen and (max-width: 1399px) {
    .works-wrapper-6:has(.z-project-card) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 28px;
    }
}

@media only screen and (max-width: 991px) {
    .works-wrapper-6:has(.z-project-card) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
    }
}

@media only screen and (max-width: 575px) {
    .works-wrapper-6:has(.z-project-card) {
        grid-template-columns: repeat(1, minmax(0, 1fr));
        gap: 22px;
    }
}


/*----------------------------------------*/
/* 02. card */
/*----------------------------------------*/

.z-project-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--z-white, #fff);
    border: 1px solid var(--z-green-dark-soft, rgba(2, 53, 6, 0.16));
    border-radius: 16px;
    padding: 12px;
    /* min-width:0 stops a long title from widening its grid column */
    min-width: 0;
    box-shadow: 0 4px 14px -8px rgba(2, 53, 6, 0.18);
    transition:
        transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.z-project-card:hover,
.z-project-card:focus-within {
    transform: translate3d(0, -6px, 0);
    border-color: var(--z-green, #0AEA0A);
    box-shadow:
        0 20px 42px -22px rgba(2, 53, 6, 0.42),
        0 0 0 1px rgba(10, 234, 10, 0.12);
}


/*----------------------------------------*/
/* 03. thumbnail */
/*----------------------------------------*/


/* Fixed aspect box. Height comes from the ratio, never from the image, so a
   tall or wide source cannot change the row. */

/* Selectors below carry the wrapper and .work-box so they out-specify the
   template's own `.works-wrapper-6 .work-box .thumb …` rules (0,4,0). Without
   that the template keeps `transform: scale(0.9)` on .image and the picture
   floats inset inside the card instead of filling it edge to edge. */

.z-project-card .thumb,
.works-wrapper-6 .work-box.z-project-card .thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    background: #f2f4f2;
    cursor: pointer;
}

/* aspect-ratio fallback for older engines */
@supports not (aspect-ratio: 4 / 3) {
    .z-project-card .thumb {
        height: 0;
        padding-top: 75%;
    }
}


/* the template scales .image down and rounds it — reset inside the gallery */

.z-project-card .thumb .image,
.works-wrapper-6 .work-box.z-project-card .thumb .image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: none;
    border-radius: 0;
    overflow: hidden;
}

.z-project-card .thumb .image a,
.works-wrapper-6 .work-box.z-project-card .thumb .image a {
    display: block;
    width: 100%;
    height: 100%;
}

.z-project-card .thumb img,
.works-wrapper-6 .work-box.z-project-card .thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    /* screenshots read best from the top edge */
    object-position: top center;
    /* the ONLY transform on hover is a small zoom — no panning, no sliding */
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: pointer;
}

.z-project-card:hover .thumb img,
.z-project-card:focus-within .thumb img {
    transform: scale(1.04);
}


/*----------------------------------------*/
/* 04. hover overlay */
/*----------------------------------------*/


/* A soft wash plus a "view" affordance. The title and category already sit
   below the card, so the overlay signals the lightbox rather than repeating
   text. */

.z-project-card .thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    border-radius: 10px;
    background: linear-gradient(180deg,
            rgba(2, 53, 6, 0) 45%,
            rgba(2, 53, 6, 0.42) 100%);
    opacity: 0;
    transition: opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.z-project-card:hover .thumb::after,
.z-project-card:focus-within .thumb::after {
    opacity: 1;
}

.z-gallery-view {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 50%;
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--z-green, #0AEA0A);
    color: #000;
    font-size: 16px;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.82);
    transition:
        opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.z-project-card:hover .z-gallery-view,
.z-project-card:focus-within .z-gallery-view {
    opacity: 1;
    transform: scale(1);
}


/*----------------------------------------*/
/* 05. card content */
/*----------------------------------------*/

.z-project-card .content {
    padding: 16px 6px 6px;
}

.z-project-card .z-service-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--z-green-readable, #05850B);
    margin-bottom: 6px;
}

/* The title always occupies two lines' worth of space, so a one-line and a
   two-line project name produce exactly the same card height. Without this a
   longer title pushes its card ~26px taller and the row stops aligning.
   Clamped to two lines as well, so an unusually long name can't grow the card
   either. */

.z-project-card .title {
    font-size: 18px;
    line-height: 1.3;
    margin-bottom: 5px;
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.35s ease;
}

.z-project-card .title a {
    color: var(--z-black, #000);
}

.z-project-card:hover .title a {
    color: var(--z-green-readable, #05850B);
}

.z-project-card .z-project-cat {
    font-size: 13px;
    font-weight: 400;
    color: var(--secondary, #555);
}


/*----------------------------------------*/
/* 06. lightbox */
/*----------------------------------------*/

.z-lb {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5vh 6vw;
    opacity: 0;
    visibility: hidden;
    background: rgba(0, 0, 0, 0.82);
    -webkit-backdrop-filter: blur(18px) saturate(115%);
    backdrop-filter: blur(18px) saturate(115%);
    transition:
        opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    /* the template hides the system cursor over gallery images */
    cursor: default;
}

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

.z-lb__figure {
    position: relative;
    margin: 0;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transform: scale(0.94) translate3d(0, 12px, 0);
    opacity: 0;
    transition:
        transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.z-lb.z-lb-open .z-lb__figure {
    transform: scale(1) translate3d(0, 0, 0);
    opacity: 1;
}


/* the full, uncropped image — contained, never cropped or stretched */

.z-lb__img {
    display: block;
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    background: #0b0b0b;
    box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
    cursor: default;
}

.z-lb__caption {
    text-align: center;
    color: rgba(255, 255, 255, 0.92);
    max-width: 60ch;
}

.z-lb__title {
    display: block;
    font-size: 18px;
    line-height: 1.35;
}

.z-lb__meta {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: var(--z-green, #0AEA0A);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}


/* controls */

.z-lb__btn {
    position: absolute;
    z-index: 2;
    width: 52px;
    height: 52px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease,
        transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.z-lb__btn:hover,
.z-lb__btn:focus-visible {
    background: var(--z-green, #0AEA0A);
    border-color: var(--z-green, #0AEA0A);
    color: #000;
    transform: scale(1.06);
}

.z-lb__close {
    top: 24px;
    right: 24px;
}

.z-lb__prev {
    top: 50%;
    left: 24px;
    margin-top: -26px;
}

.z-lb__next {
    top: 50%;
    right: 24px;
    margin-top: -26px;
}

.z-lb__count {
    position: absolute;
    top: 30px;
    left: 30px;
    z-index: 2;
    font-size: 13px;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.75);
}


/* single-image galleries hide the arrows */

.z-lb.is-single .z-lb__prev,
.z-lb.is-single .z-lb__next,
.z-lb.is-single .z-lb__count {
    display: none;
}

@media only screen and (max-width: 767px) {
    .z-lb {
        padding: 4vh 4vw;
    }

    .z-lb__btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .z-lb__close {
        top: 14px;
        right: 14px;
    }

    .z-lb__prev {
        left: 10px;
    }

    .z-lb__next {
        right: 10px;
    }

    .z-lb__img {
        max-height: 66vh;
    }
}


/*----------------------------------------*/
/* 07. reduced motion */
/*----------------------------------------*/

@media (prefers-reduced-motion: reduce) {

    .z-project-card,
    .z-project-card .thumb img,
    .z-lb,
    .z-lb__figure,
    .z-lb__btn {
        transition-duration: 0.01ms;
    }

    .z-project-card:hover,
    .z-project-card:focus-within {
        transform: none;
    }

    .z-project-card:hover .thumb img,
    .z-project-card:focus-within .thumb img {
        transform: none;
    }

    .z-lb__figure {
        transform: none;
    }
}


/*----------------------------------------*/
/* 08. selected work (homepage) */
/*----------------------------------------*/


/* The homepage "Selected Work" grid (.works-wrapper-2) gets the SAME crop +
   lightbox behaviour as the portfolio galleries, applied only to the
   thumbnail. Card padding, title, meta and the masonry column offsets are
   untouched — they keep whatever style.css / zovencia-brand.css /
   zovencia-motion.css already gives them, so the section's layout, spacing
   and typography stay exactly as designed.

   zovencia-gallery.js reads this grid's `.work-box` cards through the same
   CARD selector as `.z-project-card`, falling back from `.z-project-cat` /
   `.z-service-label` to this grid's `.meta .tag` / `.meta .date` spans when
   building the lightbox caption. */

.works-wrapper-2 .work-box .thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    cursor: pointer;
}

@supports not (aspect-ratio: 4 / 3) {
    .works-wrapper-2 .work-box .thumb {
        height: 0;
        padding-top: 75%;
    }
}

.works-wrapper-2 .work-box .thumb a {
    display: block;
    width: 100%;
    height: 100%;
}

.works-wrapper-2 .work-box .thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    /* screenshots read best from the top edge, same as the galleries */
    object-position: top center;
    cursor: pointer;
}

/* same soft wash + expand badge used on the portfolio thumbnails, so hovering
   a Selected Work card signals "click to view" exactly the same way */

.works-wrapper-2 .work-box .thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    border-radius: 10px;
    background: linear-gradient(180deg,
            rgba(2, 53, 6, 0) 45%,
            rgba(2, 53, 6, 0.42) 100%);
    opacity: 0;
    transition: opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.works-wrapper-2 .work-box:hover .thumb::after,
.works-wrapper-2 .work-box:focus-within .thumb::after {
    opacity: 1;
}

.works-wrapper-2 .work-box:hover .z-gallery-view,
.works-wrapper-2 .work-box:focus-within .z-gallery-view {
    opacity: 1;
    transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
    .works-wrapper-2 .work-box .thumb::after {
        transition-duration: 0.01ms;
    }
}


/* The task requires every card to stay equal in size. Real project titles
   vary between one and two lines (unlike the original single-word
   placeholders), and .works-wrapper-2 .work-box .title had no line limit, so
   a two-line title pushed its card ~27px taller than its neighbours. Clamped
   to the same two lines the portfolio galleries use, with matching reserved
   height — font-size, weight, colour and family are untouched. */

.works-wrapper-2 .work-box .title {
    min-height: 2.7em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
