/*
 * M2 Projects Showcase v1.1
 * Scoped to .m2ps-* so Elementor/theme styles remain untouched.
 */

:root {
    --m2ps-black: #000;
    --m2ps-white: #fff;
    --m2ps-gap: 24px;
    --m2ps-font: "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.m2ps-projects-wrap,
.m2ps-projects-grid,
.m2ps-single-project,
.m2ps-lightbox {
    box-sizing: border-box;
}

.m2ps-projects-wrap *,
.m2ps-projects-grid *,
.m2ps-single-project *,
.m2ps-lightbox * {
    box-sizing: border-box;
}

/* -------------------------
   PROJECT LOOP / SHORTCODE
   ------------------------- */
.m2ps-projects-wrap {
    width: 100%;
}

.m2ps-projects-grid {
    display: grid;
    grid-template-columns: repeat(var(--m2ps-columns, 3), minmax(0, 1fr));
    gap: var(--m2ps-gap);
    width: 100%;
}

.m2ps-project-card {
    margin: 0;
    min-width: 0;
    overflow: hidden;
}

.m2ps-project-card[hidden],
.m2ps-project-card--hidden {
    display: none !important;
}

.m2ps-project-card__link {
    display: block;
    color: inherit;
    text-decoration: none !important;
    border: 0 !important;
    box-shadow: none !important;
}

.m2ps-project-card__media {
    position: relative;
    aspect-ratio: 1.45 / 1;
    overflow: hidden;
    background: #d8d8d8;
}

.m2ps-project-card__image,
.m2ps-project-card__placeholder {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .45s cubic-bezier(.22,.61,.36,1);
}

.m2ps-project-card__placeholder {
    background: linear-gradient(135deg, #d8d8d8, #bdbdbd);
}

.m2ps-project-card__overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(0, 0, 0, .38);
    transition: background-color .28s ease;
}

.m2ps-project-card__title {
    position: absolute;
    z-index: 2;
    inset: 50% 22px auto;
    transform: translateY(-50%);
    margin: 0;
    color: var(--m2ps-white);
    font-family: var(--m2ps-font) !important;
    font-size: clamp(22px, 2vw, 36px);
    font-style: normal;
    font-weight: 500;
    line-height: 1.08;
    letter-spacing: .02em;
    text-align: center;
    text-transform: uppercase;
    text-wrap: balance;
    text-shadow: 0 2px 18px rgba(0,0,0,.3);
}

.m2ps-project-card__link:hover .m2ps-project-card__image,
.m2ps-project-card__link:focus-visible .m2ps-project-card__image {
    transform: scale(1.035);
}

.m2ps-project-card__link:hover .m2ps-project-card__overlay,
.m2ps-project-card__link:focus-visible .m2ps-project-card__overlay {
    background: rgba(0, 0, 0, .52);
}

.m2ps-project-card__link:focus-visible {
    outline: 2px solid #111;
    outline-offset: 4px;
}

.m2ps-empty,
.m2ps-admin-notice {
    grid-column: 1 / -1;
    margin: 0;
}

/* Load More - intentionally simple/premium and compatible with Elementor. */
.m2ps-load-more-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 34px;
}

.m2ps-load-more.elementor-button,
button.m2ps-load-more {
    appearance: none;
    min-width: 150px;
    margin: 0 !important;
    padding: 14px 30px !important;
    border: 1px solid #000 !important;
    border-radius: 0 !important;
    background: #000 !important;
    color: #fff !important;
    box-shadow: none !important;
    font-family: var(--m2ps-font) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    letter-spacing: .09em !important;
    text-transform: uppercase !important;
    cursor: pointer;
    transition: background-color .22s ease, color .22s ease;
}

.m2ps-load-more.elementor-button:hover,
.m2ps-load-more.elementor-button:focus-visible,
button.m2ps-load-more:hover,
button.m2ps-load-more:focus-visible {
    background: #fff !important;
    color: #000 !important;
}

.m2ps-load-more[hidden] {
    display: none !important;
}

/* -------------------------
   SINGLE PROJECT HERO
   ------------------------- */
.m2ps-single-project {
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
}

.m2ps-project-hero {
    position: relative;
    isolation: isolate;
    min-height: clamp(470px, 66vh, 760px);
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #1a1a1a;
}

.m2ps-project-hero__image-wrap,
.m2ps-project-hero__shade {
    position: absolute;
    inset: 0;
}

.m2ps-project-hero__image-wrap {
    z-index: -2;
}

.m2ps-project-hero__image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
}

.m2ps-project-hero__shade {
    z-index: -1;
    background: rgba(0, 0, 0, .38);
}

.m2ps-project-hero__content {
    position: relative;
    z-index: 3;
    width: min(1200px, calc(100% - 40px));
    margin: 0 auto;
    padding: 70px 0 110px;
    text-align: center;
}

.m2ps-project-hero__title {
    max-width: 1000px;
    margin: 0 auto;
    color: #fff;
    font-family: var(--m2ps-font) !important;
    font-size: clamp(42px, 5vw, 78px);
    font-style: normal;
    font-weight: 400;
    line-height: 1.03;
    letter-spacing: -.015em;
    text-wrap: balance;
    text-shadow: 0 3px 28px rgba(0,0,0,.34);
}

/* M2-style angled white cut matching the site's hero sections. */
.m2ps-project-hero::after {
    content: "";
    position: absolute;
    z-index: 2;
    left: 0;
    right: 0;
    bottom: -1px;
    height: clamp(78px, 8vw, 130px);
    background: #fff;
    clip-path: polygon(0 78%, 48% 43%, 90% 0, 100% 34%, 100% 100%, 0 100%);
    pointer-events: none;
}

/* -------------------------
   SINGLE PROJECT GALLERY
   ------------------------- */
.m2ps-project-gallery-section {
    padding: clamp(36px, 5vw, 76px) 20px clamp(52px, 6vw, 90px);
    background: #fff;
}

.m2ps-project-gallery-shell {
    width: min(1320px, 100%);
    margin: 0 auto;
}

.m2ps-project-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

/* Anchors instead of buttons keep theme/Elementor button borders out of gallery cards. */
a.m2ps-gallery-item,
a.m2ps-gallery-item:link,
a.m2ps-gallery-item:visited {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1.35 / 1;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit;
    text-decoration: none !important;
    cursor: zoom-in;
}

.m2ps-gallery-item__image {
    width: 100%;
    height: 100%;
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    object-fit: cover;
    transition: transform .35s cubic-bezier(.22,.61,.36,1);
}

.m2ps-gallery-item__hover {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background-color .25s ease;
    pointer-events: none;
}

.m2ps-gallery-item:hover .m2ps-gallery-item__image,
.m2ps-gallery-item:focus-visible .m2ps-gallery-item__image {
    transform: scale(1.025);
}

.m2ps-gallery-item:hover .m2ps-gallery-item__hover,
.m2ps-gallery-item:focus-visible .m2ps-gallery-item__hover {
    background: rgba(0,0,0,.12);
}

.m2ps-gallery-item:focus-visible {
    outline: 2px solid #000;
    outline-offset: 4px;
}

.m2ps-no-gallery {
    padding: 56px 20px;
    text-align: center;
    border: 1px solid #e5e5e5;
}

/* -------------------------
   LIGHTBOX
   ------------------------- */
.m2ps-lightbox[hidden] {
    display: none !important;
}

.m2ps-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    padding: 18px;
    background: rgba(0, 0, 0, .96) !important;
    overflow: hidden;
}

.m2ps-lightbox__backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, .96);
    cursor: zoom-out;
}

.m2ps-lightbox__dialog {
    position: relative;
    z-index: 1;
    width: min(1600px, 100%);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 76px;
}

.m2ps-lightbox__figure {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.m2ps-lightbox__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 92px);
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    object-fit: contain;
}

.m2ps-lightbox__counter {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    margin: 0;
    color: rgba(255,255,255,.8);
    font-family: var(--m2ps-font) !important;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: .12em;
}

/* Strong reset so Elementor/theme button styling cannot corrupt the modal controls. */
.m2ps-lightbox button.m2ps-lightbox__close,
.m2ps-lightbox button.m2ps-lightbox__nav {
    appearance: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    font-family: Arial, sans-serif !important;
    font-weight: 200 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: opacity .18s ease;
}

.m2ps-lightbox button.m2ps-lightbox__close:hover,
.m2ps-lightbox button.m2ps-lightbox__nav:hover {
    background: transparent !important;
    color: #fff !important;
    opacity: .72;
}

.m2ps-lightbox__close {
    position: absolute !important;
    top: 10px;
    right: 10px;
    z-index: 4;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    font-size: 40px !important;
}

.m2ps-lightbox__nav {
    position: absolute !important;
    z-index: 3;
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 76px;
    display: grid;
    place-items: center;
    font-size: 56px !important;
}

.m2ps-lightbox__nav--prev {
    left: 8px;
}

.m2ps-lightbox__nav--next {
    right: 8px;
}

.m2ps-lightbox__loader {
    position: absolute;
    z-index: 2;
    width: 34px;
    height: 34px;
    border: 2px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    animation: m2ps-spin .75s linear infinite;
    transition: opacity .12s ease;
}

.m2ps-lightbox.is-loading .m2ps-lightbox__loader {
    opacity: 1;
}

.m2ps-lightbox.is-loading .m2ps-lightbox__image {
    opacity: .42;
}

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

body.m2ps-lightbox-open,
html.m2ps-lightbox-open {
    overflow: hidden !important;
}

/* -------------------------
   RESPONSIVE
   ------------------------- */
@media (max-width: 1024px) {
    .m2ps-projects-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }

    .m2ps-project-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .m2ps-project-card__title {
        font-size: clamp(22px, 4vw, 32px);
    }
}

@media (max-width: 767px) {
    :root {
        --m2ps-gap: 14px;
    }

    .m2ps-projects-grid {
        grid-template-columns: 1fr;
    }

    .m2ps-project-card__media {
        aspect-ratio: 1.38 / 1;
    }

    .m2ps-project-card__title {
        left: 18px;
        right: 18px;
        font-size: clamp(24px, 7.5vw, 32px);
    }

    .m2ps-load-more-wrap {
        margin-top: 26px;
    }

    .m2ps-project-hero {
        min-height: 470px;
    }

    .m2ps-project-hero__content {
        width: min(100% - 28px, 1200px);
        padding: 56px 0 96px;
    }

    .m2ps-project-hero__title {
        font-size: clamp(36px, 11vw, 56px);
    }

    .m2ps-project-hero::after {
        height: 76px;
        clip-path: polygon(0 78%, 48% 48%, 88% 8%, 100% 36%, 100% 100%, 0 100%);
    }

    .m2ps-project-gallery-section {
        padding: 28px 14px 56px;
    }

    .m2ps-project-gallery {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    a.m2ps-gallery-item {
        aspect-ratio: 1.3 / 1;
    }

    .m2ps-lightbox {
        padding: 10px;
    }

    .m2ps-lightbox__dialog {
        padding: 0 42px;
    }

    .m2ps-lightbox__image {
        max-height: calc(100dvh - 76px);
    }

    .m2ps-lightbox__nav {
        width: 38px;
        height: 60px;
        font-size: 44px !important;
    }

    .m2ps-lightbox__nav--prev {
        left: 0;
    }

    .m2ps-lightbox__nav--next {
        right: 0;
    }

    .m2ps-lightbox__close {
        top: 2px;
        right: 2px;
        width: 42px;
        height: 42px;
        font-size: 34px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .m2ps-project-card__image,
    .m2ps-project-card__overlay,
    .m2ps-gallery-item__image,
    .m2ps-gallery-item__hover,
    .m2ps-load-more {
        transition: none !important;
    }
}
