/*
 * A2Z Image Widgets core styling + Elementor editor UI
 */

.a2z-images,
.a2z-images *,
.a2z-images *::before,
.a2z-images *::after {
    box-sizing: border-box !important;
}

.a2z-images {
    --a2z-gap-desktop: 8px;
    --a2z-gap-mobile: 0px;
    --a2z-radius: 6px;
    --a2z-object-fit: cover;
    --a2z-placeholder: #eceef3;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    position: relative;
    font-family: inherit;
    margin-top: 0px;
    margin-bottom: 0px;
    padding-left: 0;
    padding-right: 0;
}

/* Negative margin to counteract container padding */
.a2z-images__grid {
    margin-top: -5px;
    margin-bottom: -5px;
}

.a2z-images--display-cover {
    --a2z-object-fit: cover;
}

.a2z-images__frame {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    aspect-ratio: 16 / 9;
    display: grid;
    grid-auto-rows: 1fr;
    gap: var(--a2z-gap-desktop);
    border-radius: var(--a2z-radius);
    overflow: hidden;
    background: transparent;
}

.a2z-images--layout-stacked .a2z-images__frame,
.a2z-images--layout-two-stacked .a2z-images__frame {
    grid-template-columns: minmax(0, 1fr);
}

.a2z-images--layout-two-side .a2z-images__frame,
.a2z-images--layout-grid-2x2 .a2z-images__frame {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Layout: Single (1 image) */
.a2z-images--layout-single .a2z-images__frame,
.a2z-layout--single .a2z-images__grid {
    aspect-ratio: auto !important;
    height: auto !important;
    display: block !important;
    width: 100% !important;
}

.a2z-images--layout-single .a2z-images__image,
.a2z-layout--single .a2z-images__img,
.a2z-layout--single .a2z-images__media,
.a2z-images--layout-stacked .a2z-images__image,
.a2z-images--layout-two-stacked .a2z-images__image,
.a2z-images--layout-three-stacked .a2z-images__image,
.a2z-images--layout-four-stacked .a2z-images__image,
.a2z-images--layout-five-stacked .a2z-images__image,
.a2z-images--layout-six-stacked .a2z-images__image {
    height: auto !important;
    width: 100% !important;
    aspect-ratio: auto !important;
}

.a2z-images--layout-grid-3x2 .a2z-images__frame {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.a2z-images--layout-grid-uniform .a2z-images__frame {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.a2z-images--layout-mosaic-3 .a2z-images__frame {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
}

.a2z-images--layout-mosaic-3 .a2z-images__tile:nth-child(1) {
    grid-row: span 2;
}

.a2z-images--layout-mosaic-3 .a2z-images__tile:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.a2z-images--layout-mosaic-3 .a2z-images__tile:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.a2z-images--layout-feature-grid .a2z-images__frame {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
}

.a2z-images--layout-feature-grid .a2z-images__tile:nth-child(1) {
    grid-column: span 2;
    grid-row: span 2;
}

.a2z-images--layout-feature-grid .a2z-images__tile:nth-child(2) {
    grid-column: 3;
    grid-row: 1;
}

.a2z-images--layout-feature-grid .a2z-images__tile:nth-child(3) {
    grid-column: 3;
    grid-row: 2;
}

.a2z-images--layout-feature-grid .a2z-images__tile:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
}

.a2z-images--layout-feature-grid .a2z-images__tile:nth-child(5) {
    grid-column: 2;
    grid-row: 3;
}

.a2z-images--layout-stacked .a2z-images__frame,
.a2z-images--layout-two-stacked .a2z-images__frame {
    grid-template-columns: minmax(0, 1fr);
}

.a2z-images--layout-two-side .a2z-images__frame {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.a2z-images__tile {
    width: 100%;
    height: 100%;
    position: relative;
    background: transparent;
    border-radius: calc(var(--a2z-radius) / 1.5);
    overflow: hidden;
    display: flex;
    align-items: stretch;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    backface-visibility: hidden;
    transform: translateZ(0);
}

@media (hover: hover) {
    .a2z-images__tile:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }
}

.a2z-images--display-contain .a2z-images__tile {
    background: #e6e8ed;
}

.a2z-images__trigger {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    display: block;
}

.a2z-images__trigger:focus-visible {
    outline: 2px solid #9aa0b5;
    outline-offset: 2px;
}

.a2z-images__image,
.a2z-images__placeholder {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: var(--a2z-object-fit);
    background: var(--a2z-placeholder);
    aspect-ratio: 16 / 9;
}

.a2z-images__tile .a2z-images__image,
.elementor .a2z-images__image,
.elementor-editor-active .a2z-images__image {
    height: 100% !important;
    width: 100% !important;
}

.a2z-images__tile img {
    max-height: none;
}

.a2z-images__placeholder {
    border: none;
}

.elementor-editor-active .a2z-images__placeholder {
    border: 1px dashed rgba(0, 0, 0, 0.07);
}

.elementor-editor-active .a2z-images__placeholder {
    animation: a2zSlideFromTop 1.8s ease-in-out infinite;
}

@keyframes a2zSlideFromTop {
    0% {
        opacity: 0.55;
        transform: translateY(-8px);
    }

    50% {
        opacity: 0.9;
        transform: translateY(0);
    }

    100% {
        opacity: 0.55;
        transform: translateY(-8px);
    }
}

.a2z-images__limit,
.a2z-images__notice {
    margin: 8px 0;
    font-size: 12px;
    color: #6c7280;
}

.a2z-images__notice-wrap {
    margin-top: 6px;
}

/* Layout picker (Elementor control) */
.a2z-layout-picker {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.a2z-layout-picker__group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #818693;
    font-weight: 600;
}

.a2z-layout-picker__options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.a2z-layout-card {
    border: 1px solid #cfd3dd;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.a2z-layout-card.is-selected {
    border-color: #6c6f7f;
    box-shadow: 0 0 0 1px #6c6f7f;
}

.a2z-layout-card.is-disabled,
.a2z-layout-card[data-disabled="yes"] {
    opacity: 0.45;
    cursor: not-allowed;
}

.a2z-layout-card__label {
    font-size: 12px;
    font-weight: 600;
    color: #1f2430;
}

.a2z-layout-card__note {
    font-size: 11px;
    color: #7b808f;
}

.a2z-layout-diagram {
    width: 100%;
    max-width: 140px;
    aspect-ratio: 16 / 9;
    border: 1px solid #dfe1e9;
    border-radius: 6px;
    background: #f6f7fa;
    position: relative;
    overflow: hidden;
}

.a2z-layout-diagram__cell {
    position: absolute;
    border-radius: 4px;
    background: #d8dae3;
    border: 1px solid #c4c7d4;
}

.a2z-layout-diagram {
    --a2z-cols: 2;
    --a2z-rows: 2;
}

.a2z-layout-diagram__cell {
    left: calc((var(--a2z-x, 1) - 1) * (100% / var(--a2z-cols, 2)));
    top: calc((var(--a2z-y, 1) - 1) * (100% / var(--a2z-rows, 2)));
    width: calc(var(--a2z-w, 1) * (100% / var(--a2z-cols, 2)));
    height: calc(var(--a2z-h, 1) * (100% / var(--a2z-rows, 2)));
}

/* Lightbox UI */
.a2z-lightbox__dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 100;
}

.a2z-lightbox__dots button {
    width: 56px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgba(255, 255, 255, 0.15);
    opacity: 1;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.a2z-lightbox__dots button.is-active {
    border-color: #ffffff;
    transform: scale(1.1);
}

.a2z-lightbox__btn {
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    padding: 10px;
}

.a2z-lightbox__btn svg {
    width: 36px;
    height: 36px;
    fill: currentColor;
}

/* Mobile Usability & Containment */
@media (max-width: 767px) {
    .a2z-images {
        margin-top: 0;
        margin-bottom: var(--a2z-gap-desktop, 8px);
        padding-left: 12px !important;
        padding-right: 12px !important;
        overflow-x: hidden;
        max-width: 100%;
    }

    .a2z-images__frame {
        gap: var(--a2z-gap-mobile, 16px) !important;
    }

    /* Larger download target on mobile (2x) */
    .a2z-lightbox__btn {
        padding: 16px;
    }

    .a2z-lightbox__btn svg {
        width: 36px;
        height: 36px;
    }

    /* Force arrows to be visible if they exist */
    .pswp__button--arrow--left,
    .pswp__button--arrow--right,
    .pswp__button--arrow--prev,
    .pswp__button--arrow--next {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/**
 * Header Widget Styles
 */
.a2z-images-header-wrapper {
    width: 100%;
    margin-bottom: 15px;
    padding: 0;
}

.a2z-images-header-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 0;
    gap: 10px;
}

.a2z-images-header-title {
    margin: 0;
    white-space: nowrap;
    line-height: 1;
    text-transform: uppercase;
    font-weight: 600;
    font-size: 20px;
    font-family: 'Inter', sans-serif;
    color: inherit;
}

.a2z-images-header-divider::before,
.a2z-images-header-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background-color: #d5d5d5;
    display: block;
}

.a2z-images-header-description {
    font-family: "Inter", sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    text-align: center;
    color: #7a7a7a;
    margin-top: 0 !important;
    padding: 0 60px 15px 60px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .a2z-images-header-title {
        font-size: 20px;
    }

    .a2z-images-header-description {
        font-size: 14px;
        padding: 0;
    }

    .a2z-images-header-wrapper {
        padding: 0;
    }
}