/* Real installation photographs. Native WordPress owns lightbox interaction. */
.cnx-installation-gallery {
    min-width: 0;
    color: var(--ink, #102746);
}

/* Core calculates from innerWidth, which can include a desktop scrollbar in a
   narrow preview. Keep the active image inside the actual overlay on phones. */
@media (max-width: 600px) {
    body:has(.cnx-installation-gallery) .wp-lightbox-overlay.active .lightbox-image-container {
        max-width: calc(100% - 32px);
        max-height: calc(100% - 120px);
    }
    body:has(.cnx-installation-gallery) .wp-lightbox-overlay.active .lightbox-image-container img {
        width: 100% !important;
        height: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain !important;
    }
}

.cnx-installation-gallery .cnx-photo-jump {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
    margin: 0 0 28px;
    padding: 0;
}

.cnx-installation-gallery .cnx-photo-jump > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    max-width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--line, #d8e1ed);
    border-radius: 5px;
    background: #fff;
    color: var(--navy, #041b47);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.5;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.cnx-installation-gallery .cnx-photo-jump > a:hover {
    border-color: #aac7ed;
    background: #f2f7ff;
    color: #0756cf;
}

.cnx-installation-gallery .cnx-photo-count {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    padding: 2px 7px;
    border-radius: 4px;
    background: #eaf2ff;
    color: #0756cf;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

.cnx-installation-gallery .cnx-photo-group {
    min-width: 0;
    margin: 0;
    padding: 0;
    scroll-margin-top: calc(var(--header-height, 86px) + 24px);
}

.cnx-installation-gallery .cnx-photo-group + .cnx-photo-group {
    margin-top: 40px;
}

.cnx-installation-gallery .cnx-photo-group-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
    margin: 0 0 18px;
    padding: 0;
}

.cnx-installation-gallery .cnx-photo-group-header > h2 {
    min-width: 0;
    margin: 0;
    color: var(--navy, #041b47);
    font-size: clamp(25px, 2.4vw, 32px);
    line-height: 1.3;
    letter-spacing: -.03em;
    overflow-wrap: anywhere;
}

.cnx-installation-gallery .cnx-photo-group-header > .text-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    max-width: 100%;
    padding-block: 7px;
    color: #0756cf;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.6;
    text-decoration: underline;
    text-underline-offset: 4px;
    overflow-wrap: anywhere;
}

.cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 20px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images > figure.wp-block-image {
    /* Core uses :not(#individual-image) for widths and automatic margins. */
    width: 100% !important;
    min-width: 0;
    max-width: none;
    height: auto;
    margin: 0 !important;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    justify-content: flex-start;
    border: 1px solid var(--line, #d8e1ed);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}

.cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images > figure.wp-block-image::before {
    content: none;
    display: none;
}

.cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images > figure.wp-block-image > img {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: 260px;
    max-height: none;
    margin: 0;
    padding: 12px;
    aspect-ratio: auto;
    object-fit: contain;
    background: #f4f6f9;
    border-radius: 0;
}

.cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images > figure.wp-block-image > figcaption {
    position: static;
    inset: auto;
    flex: 1 0 auto;
    width: 100%;
    max-height: none;
    margin: 0;
    padding: 13px 15px 15px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    color: var(--muted, #516176);
    font-size: 13px;
    line-height: 1.7;
    text-align: left;
    text-shadow: none;
    overflow: visible;
    overflow-wrap: anywhere;
    scrollbar-gutter: auto;
}

.cnx-installation-gallery .cnx-photo-grid > figure.wp-block-image > figcaption > strong {
    display: block;
    color: var(--navy, #041b47);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.55;
}

.cnx-installation-gallery .cnx-photo-grid > figure.wp-block-image > figcaption > span {
    display: block;
    margin-top: 4px;
}

.cnx-installation-gallery .cnx-photo-grid > figure.wp-block-image > button.lightbox-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 12px;
    border: 1px solid #c6d5e8;
    border-radius: 5px;
    background: #ffffffed;
    color: var(--navy, #041b47);
    opacity: 1;
}

.cnx-installation-gallery .cnx-photo-grid .lightbox-trigger > svg {
    display: block;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
}

.cnx-installation-gallery .cnx-photo-grid .lightbox-trigger svg path {
    fill: currentColor;
}

.cnx-installation-gallery .cnx-photo-jump > a:focus-visible,
.cnx-installation-gallery .cnx-photo-group-header > a:focus-visible,
.cnx-installation-gallery .cnx-photo-grid .lightbox-trigger:focus-visible {
    outline: 3px solid var(--blue, #146cff);
    outline-offset: 3px;
}

/* Reuse the existing continuous carousel without cropping real equipment. */
.cnx-carousel--projects [data-carousel-item].cnx-project-card--installation > figure {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    background: #f4f6f9;
}

.cnx-carousel--projects [data-carousel-item].cnx-project-card--installation > figure > img {
    width: 100%;
    height: 220px;
    max-height: none;
    margin: 0;
    padding: 12px;
    aspect-ratio: auto;
    object-fit: contain;
    background: #f4f6f9;
}

@media (max-width: 1000px) {
    .cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }
}

@media (max-width: 600px) {
    .cnx-installation-gallery .cnx-photo-jump {
        gap: 8px;
        margin-bottom: 25px;
    }
    .cnx-installation-gallery .cnx-photo-jump > a {
        padding: 9px 11px;
        font-size: 12px;
    }
    .cnx-installation-gallery .cnx-photo-group-header {
        gap: 2px 15px;
        margin-bottom: 15px;
    }
    .cnx-installation-gallery .cnx-photo-group-header > h2 {
        flex-basis: 100%;
        font-size: 26px;
    }
    .cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }
    .cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images > figure.wp-block-image > img {
        height: 250px;
        padding: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cnx-installation-gallery .cnx-photo-jump > a,
    .cnx-installation-gallery .cnx-photo-grid .lightbox-trigger {
        transition: none;
    }
}

@media print {
    .cnx-installation-gallery .cnx-photo-jump,
    .cnx-installation-gallery .cnx-photo-grid .lightbox-trigger {
        display: none;
    }
    .cnx-installation-gallery .wp-block-gallery.cnx-photo-grid.has-nested-images {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .cnx-installation-gallery .cnx-photo-grid > figure.wp-block-image {
        break-inside: avoid;
    }
}
