/* Andersons responsive vehicle photography gallery */

#dialogphoto.ag-mounted {
    display: block;
    height: auto;
    min-height: 0;
    background: #090b0e;
}

.ag-gallery {
    width: 100%;
    min-width: 0;
    background: #090b0e;
    color: #f5f6f8;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
}

.ag-gallery *,
.ag-gallery *::before,
.ag-gallery *::after {
    box-sizing: border-box;
}

.ag-gallery [hidden] {
    display: none !important;
}

.ag-viewer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: clamp(240px, 48vw, 470px);
    overflow: hidden;
    background: #090b0e;
    touch-action: pan-y pinch-zoom;
}

.ag-viewer .ag-main-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.ag-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #737983;
    border-radius: 8px;
    background: rgba(10, 12, 16, .86);
    color: #fff;
    font-size: 25px;
    cursor: pointer;
    z-index: 1;
}

.ag-previous {
    left: 12px;
}

.ag-next {
    right: 12px;
}

.ag-arrow:hover {
    background: #c51c32;
    border-color: #ff5265;
}

.ag-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 15px;
    background: #191d24;
    border-top: 1px solid #373d46;
    border-bottom: 1px solid #373d46;
}

.ag-counter {
    font-size: 13px;
    font-weight: 700;
    color: #d7dbe1;
    font-variant-numeric: tabular-nums;
}

.ag-expand {
    min-height: 44px;
    padding: 9px 15px;
    border: 1px solid #737983;
    border-radius: 6px;
    background: #252a32;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.ag-expand:hover {
    border-color: #ff5265;
    background: #343a44;
}

.ag-thumbnails {
    position: relative;
    display: flex;
    gap: 8px;
    padding: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #626975 #15191f;
    background: #11151a;
    overscroll-behavior-x: contain;
}

.ag-thumbnail {
    flex: 0 0 100px;
    width: 100px;
    height: 72px;
    padding: 2px;
    overflow: hidden;
    background: #090b0e;
    border: 2px solid #454b55;
    border-radius: 6px;
    cursor: pointer;
}

.ag-thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 3px;
}

.ag-thumbnail.selected {
    border-color: #ff344c;
    box-shadow: 0 0 0 1px #ff344c;
}

.ag-gallery button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -4px;
}

.ag-image-error {
    padding: 30px;
    color: #b5bbc5;
    font-size: 15px;
    text-align: center;
}

/* Expanded photo viewing */

.ag-gallery.ag-expanded {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding:
        env(safe-area-inset-top, 0px)
        env(safe-area-inset-right, 0px)
        env(safe-area-inset-bottom, 0px)
        env(safe-area-inset-left, 0px);
    background: #050608;
}

.ag-expanded .ag-viewer {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
}

.ag-expanded .ag-toolbar,
.ag-expanded .ag-thumbnails {
    flex: 0 0 auto;
}

.ag-expanded .ag-expand {
    background: #b9182c;
    border-color: #ff5265;
}

/* Tablet and mobile */

@media (max-width: 850px) {
    .ag-viewer {
        height: clamp(240px, 55vw, 420px);
    }

    .ag-thumbnail {
        flex-basis: 88px;
        width: 88px;
        height: 64px;
    }
}

@media (max-width: 580px) {
    .overlay.ag-gallery-open {
        padding: 8px;
    }

    .ag-gallery-open .dialog {
        width: 100%;
        max-height: 94vh;
        max-height: 94dvh;
    }

    .ag-viewer {
        height: clamp(210px, 65vw, 340px);
    }

    .ag-arrow {
        width: 44px;
        height: 48px;
        font-size: 21px;
    }

    .ag-previous {
        left: 7px;
    }

    .ag-next {
        right: 7px;
    }

    .ag-toolbar {
        padding: 8px 10px;
    }

    .ag-counter {
        font-size: 12px;
    }

    .ag-expand {
        padding: 8px 12px;
        font-size: 12px;
    }

    .ag-thumbnails {
        padding: 9px;
        gap: 7px;
    }

    .ag-thumbnail {
        flex-basis: 76px;
        width: 76px;
        height: 58px;
    }

    .ag-expanded .ag-viewer {
        height: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ag-gallery * {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
