.model-gallery-block {
    position: relative;
    border: var(--mgb-gallery-border-w, 0px) solid var(--mgb-gallery-border-color, transparent);
    border-radius: var(--mgb-gallery-radius, 12px);
    overflow: hidden;
    background: var(--mgb-gallery-bg, #fff);
    display: block;
    margin-block: var(--mgb-gallery-block-spacing, 24px);
    box-shadow: var(--mgb-gallery-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
    padding: var(--mgb-gallery-padding, 0px);
    transition: box-shadow 0.3s ease;
    --mgb-gap: 20px;
    --mgb-columns: 3;
    --mgb-height: 360px;
    --mgb-spot-color: #f59e0b;
    --mgb-spot-border: #fff;
    --mgb-spot-size: 14px;
    --mgb-tooltip-bg: rgba(17, 24, 39, 0.9);
    --mgb-tooltip-color: #fff;
    --mgb-download-bg: #dcdcde;
    --mgb-download-color: #50575e;
}

.model-gallery-block:hover {
    box-shadow: var(--mgb-gallery-hover-shadow, 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1));
}

.model-gallery-slides {
    position: relative;
    height: var(--mgb-height);
    width: 100%;
}

.model-gallery-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(1.05);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.model-gallery-slide.is-active {
    opacity: 1;
    position: relative;
    transform: scale(1);
    pointer-events: auto;
}

.model-gallery-slide__media {
    position: relative;
    width: 100%;
    height: var(--mgb-height);
}

.model-gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.model-gallery-block__tags {
    margin-top: 12px;
    background: transparent;
    text-align: center;
    font-size: var(--mgb-taglist-font, 13px);
    font-weight: 500;
    letter-spacing: var(--mgb-taglist-letter, 0.02em);
    padding: 8px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.model-gallery-block__tag-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.model-gallery-block__tag-group-label {
    color: var(--mgb-taglist-color, #4b5563);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    opacity: 0.8;
    text-transform: uppercase;
}

.model-gallery-block__tag-group-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.model-gallery-block__tags-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.model-gallery-block__tags--cloud .model-gallery-block__tags-inner {
    width: 100%;
}

.model-gallery-block__tags--cloud.is-collapsed .model-gallery-block__tag-item.is-overflow-hidden {
    display: none;
}

.model-gallery-block__tags a,
.model-gallery-block__tags span {
    background: var(--mgb-taglist-bg, #f3f4f6);
    color: var(--mgb-taglist-color, #4b5563);
    padding: 6px 16px;
    border-radius: 999px;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.model-gallery-block__tags .model-gallery-block__tags-more {
    background: var(--mgb-taglist-bg, #f3f4f6);
    color: var(--mgb-taglist-color, #4b5563);
    padding: 6px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.model-gallery-block__tags a:hover {
    background: #38bdf8;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(56 189 248 / 0.3), 0 2px 4px -2px rgb(56 189 248 / 0.3);
}

.model-gallery-block__tags .model-gallery-block__tags-more:hover,
.model-gallery-block__tags .model-gallery-block__tags-more:focus-visible {
    background: #38bdf8;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(56 189 248 / 0.3), 0 2px 4px -2px rgb(56 189 248 / 0.3);
    outline: none;
}

.model-gallery-block__tags .mgb-tag-sep {
    display: none;
}

.model-gallery-hotspot-list {
    margin-top: 12px;
    width: 100%;
}

.model-gallery-hotspot-list__items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.model-gallery-hotspot-list__item {
    margin: 0;
    padding: 0;
}

.model-gallery-hotspot-list__button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--mgb-taglist-bg, #f3f4f6);
    color: var(--mgb-taglist-color, #4b5563);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.model-gallery-hotspot-list__button::before {
    content: "";
    width: 8px;
    height: 8px;
    flex: none;
    border-radius: 50%;
    background: currentcolor;
    opacity: 0.55;
}

.model-gallery-hotspot-list__button:hover,
.model-gallery-hotspot-list__button:focus-visible {
    background: #38bdf8;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(56 189 248 / 0.3), 0 2px 4px -2px rgb(56 189 248 / 0.3);
    outline: none;
}

.model-gallery-hotspot-list__button:hover::before,
.model-gallery-hotspot-list__button:focus-visible::before {
    opacity: 1;
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slides,
.model-gallery-block[data-layout="pinterest"] .model-gallery-slides {
    height: auto;
    padding: var(--mgb-gap);
    box-sizing: border-box;
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slide,
.model-gallery-block[data-layout="pinterest"] .model-gallery-slide {
    position: relative;
    inset: auto;
    opacity: 1;
    min-width: 0;
    display: block;
    transform: none;
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slides {
    display: grid;
    grid-template-columns: repeat(var(--mgb-columns), minmax(0, 1fr));
    /* Fine row unit: the JS span engine (assets/masonry-spans.js and the copy in
       assets/block-model-gallery-frontend.js) converts tile height into
       `grid-row-end: span N`; a coarse unit (20px) rounded every tile up by up to
       a whole row, so 8px keeps the packing tight. */
    grid-auto-rows: 8px;
    gap: var(--mgb-gap);
    align-items: start;
}

.model-gallery-block[data-layout="pinterest"] .model-gallery-slides {
    column-count: var(--mgb-columns);
    column-gap: var(--mgb-gap);
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slide {
    margin-bottom: 0;
}

.model-gallery-block[data-layout="pinterest"] .model-gallery-slide {
    break-inside: avoid;
    margin-bottom: var(--mgb-gap);
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slide img,
.model-gallery-block[data-layout="pinterest"] .model-gallery-slide img {
    height: auto;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slide:hover img,
.model-gallery-block[data-layout="pinterest"] .model-gallery-slide:hover img {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.15);
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slide__media,
.model-gallery-block[data-layout="pinterest"] .model-gallery-slide__media {
    height: auto;
}

.model-gallery-block.mgb-masonry-same[data-layout="masonry"] .model-gallery-slides {
    grid-auto-rows: auto;
}

.model-gallery-block.mgb-masonry-same[data-layout="masonry"] .model-gallery-slide {
    margin-bottom: 0;
}

.model-gallery-block.mgb-masonry-same[data-layout="masonry"] .model-gallery-slide img {
    width: 100%;
    height: auto;
    aspect-ratio: var(--mgb-media-ratio, auto);
    object-fit: cover;
    object-position: center;
}

.model-gallery-block[data-layout="masonry"] .model-gallery-slide__media,
.model-gallery-block[data-layout="pinterest"] .model-gallery-slide__media {
    height: auto;
}

.model-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.model-gallery-slides:hover .model-gallery-nav {
    opacity: 1;
}

.model-gallery-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.model-gallery-nav--prev {
    left: 20px;
}

.model-gallery-nav--next {
    right: 20px;
}

.model-gallery-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    border-radius: 999px;
}

.model-gallery-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.model-gallery-dot.is-active {
    background: #fff;
    width: 20px;
    border-radius: 4px;
}

.model-hotspot {
    position: absolute;
    left: var(--mgb-hotspot-left, 50%);
    top: var(--mgb-hotspot-top, 50%);
    transform: translate(-50%, -50%);
    display: block;
    font-size: 0;
    line-height: 0;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.model-hotspot:hover,
.model-hotspot:focus-within {
    transform: translate(-50%, -50%);
    z-index: 2147483000;
}

.model-hotspot.mgb-tooltip-measuring {
    z-index: 2147483000;
}

.model-hotspot.mgb-hotspot-active-self {
    z-index: 2147483200 !important;
}

.model-hotspot.mgb-hotspot-active-self .model-hotspot__tooltip {
    z-index: 2147483201 !important;
}

.model-hotspot__dot {
    width: var(--spot-size, var(--mgb-spot-size));
    height: var(--spot-size, var(--mgb-spot-size));
    box-sizing: border-box;
    --mgb-spot-border-width: 2px;
    background: var(--spot-color, var(--mgb-spot-color));
    border: var(--mgb-spot-border-width, 2px) solid var(--spot-border, var(--mgb-spot-border));
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.3);
    display: block;
    position: relative;
    transform-origin: center center;
    color: var(--spot-pulse-color, var(--mgb-spot-pulse-color, var(--spot-color, var(--mgb-spot-color))));
    opacity: var(--spot-opacity, var(--mgb-spot-opacity, 1));
    overflow: visible;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.model-gallery-block.mgb-hotspot-active {
    z-index: 2147482900;
}

.model-gallery-block.mgb-hotspot-active .model-gallery-slide.mgb-hotspot-active-slide {
    z-index: 2147482901 !important;
}

.model-gallery-block.mgb-hotspot-active .model-gallery-slide__media.mgb-hotspot-active-media {
    position: relative;
    z-index: 2147482902 !important;
    overflow: visible !important;
}

@keyframes mgbSpotPulse {

    0% {
        transform: scale(1);
        opacity: var(--spot-pulse-opacity, var(--mgb-spot-pulse-opacity, 0.7));
    }

    100% {
        transform: scale(var(--mgb-spot-pulse-scale-factor, 1.6));
        opacity: 0;
    }
}

.model-gallery-block.mgb-spot-style--pulse .model-hotspot__dot::before {
    content: "";
    position: absolute;
    inset: 0;
    transform-origin: center center;
    background: currentcolor;
    border-radius: 50%;
    animation: mgbSpotPulse var(--spot-pulse-duration, var(--mgb-spot-pulse-duration, 1.8s)) ease-out infinite;
    pointer-events: none;
    z-index: -1;
}

.model-gallery-block.mgb-spot-style--pulse .model-hotspot__dot::after {
    content: none;
}

.model-hotspot:hover .model-hotspot__dot {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.2);
}

.model-hotspot:focus-within .model-hotspot__dot {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.2);
}

/* Keep pulse visually locked to the hotspot center on frontend. */
.model-gallery-block.mgb-spot-style--pulse .model-hotspot:hover .model-hotspot__dot,
.model-gallery-block.mgb-spot-style--pulse .model-hotspot:focus-within .model-hotspot__dot,
.model-gallery-block.mgb-spot-style--pulse .model-hotspot.mgb-hotspot-active-self .model-hotspot__dot {
    transform: none;
}

.model-hotspot__tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%) translateY(10px);
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--mgb-tooltip-color);
    padding: 14px;
    border-radius: 12px;
    font-size: 13px;
    min-width: 200px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: 0.36s;
    display: grid;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    z-index: 101;
}

.model-hotspot:hover .model-hotspot__tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    transition-delay: 0.36s;
}

.model-hotspot:focus-within .model-hotspot__tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    transition-delay: 0s;
}

.model-hotspot.mgb-tooltip-below .model-hotspot__tooltip {
    top: calc(100% + 12px + var(--mgb-tooltip-extra-y, 0px));
    bottom: auto;
    transform: translateX(-50%) translateY(-10px);
}

.model-hotspot.mgb-tooltip-below:hover .model-hotspot__tooltip,
.model-hotspot.mgb-tooltip-below:focus-within .model-hotspot__tooltip {
    transform: translateX(-50%) translateY(0);
}

.model-hotspot.mgb-tooltip-align-left .model-hotspot__tooltip {
    left: 0;
    right: auto;
    transform: translateX(0) translateY(10px);
}

.model-hotspot.mgb-tooltip-align-left:hover .model-hotspot__tooltip,
.model-hotspot.mgb-tooltip-align-left:focus-within .model-hotspot__tooltip {
    transform: translateX(0) translateY(0);
}

.model-hotspot.mgb-tooltip-align-left.mgb-tooltip-below .model-hotspot__tooltip {
    transform: translateX(0) translateY(-10px);
}

.model-hotspot.mgb-tooltip-align-left.mgb-tooltip-below:hover .model-hotspot__tooltip,
.model-hotspot.mgb-tooltip-align-left.mgb-tooltip-below:focus-within .model-hotspot__tooltip {
    transform: translateX(0) translateY(0);
}

.model-hotspot.mgb-tooltip-align-right .model-hotspot__tooltip {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(10px);
}

.model-hotspot.mgb-tooltip-align-right:hover .model-hotspot__tooltip,
.model-hotspot.mgb-tooltip-align-right:focus-within .model-hotspot__tooltip {
    transform: translateX(0) translateY(0);
}

.model-hotspot.mgb-tooltip-align-right.mgb-tooltip-below .model-hotspot__tooltip {
    transform: translateX(0) translateY(-10px);
}

.model-hotspot.mgb-tooltip-align-right.mgb-tooltip-below:hover .model-hotspot__tooltip,
.model-hotspot.mgb-tooltip-align-right.mgb-tooltip-below:focus-within .model-hotspot__tooltip {
    transform: translateX(0) translateY(0);
}

.model-hotspot.mgb-tooltip-measuring .model-hotspot__tooltip {
    opacity: 1;
    pointer-events: none;
    transition: none;
}

.model-hotspot__tooltip strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    color: #fff;
}

.model-hotspot__tooltip span {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.model-hotspot__title {
    margin: 0;
    padding: 8px 10px;
    font-size: 16px;
    line-height: 1.3;
    font-weight: 700;
    color: #fff;
}

.model-hotspot__tooltip > .mgb-asset-details {
    margin-top: 10px;
    margin-bottom: 10px;
}

.model-hotspot__tooltip > :first-child.mgb-asset-details {
    margin-top: 0;
}

.model-hotspot__tooltip > :last-child.mgb-asset-details {
    margin-bottom: 0;
}

.model-hotspot__html {
    font-size: 12px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.model-hotspot__tooltip .model-hotspot__html p {
    margin: 0;
}

.model-hotspot__tooltip .model-hotspot__html figure,
.model-hotspot__tooltip .model-hotspot__html ul,
.model-hotspot__tooltip .model-hotspot__html ol {
    margin: 0;
}

.model-hotspot__tax {
    font-size: 11px;
    color: #38bdf8;
    font-weight: 600;
    padding: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.model-hotspot__tax-label {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.78;
}

.model-hotspot__tax-items {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.model-hotspot__tax-items a,
.model-hotspot__tax-items span {
    display: inline-flex;
    align-items: center;
}

.model-gallery-block.mgb-tooltip-preview-height .model-hotspot__tooltip .model-hotspot__html {
    max-height: var(--mgb-tooltip-preview-height, 72px);
    overflow: hidden;
}

.model-gallery-block.mgb-tooltip-preview-height .model-hotspot > .model-hotspot__tooltip.mgb-tooltip-has-content .model-hotspot__html {
    height: var(--mgb-tooltip-preview-height, 72px);
    max-height: var(--mgb-tooltip-preview-height, 72px);
}

.model-gallery-block.mgb-tooltip-preview-lines .model-hotspot__tooltip .model-hotspot__html {
    display: -webkit-box;
    -webkit-line-clamp: var(--mgb-tooltip-preview-lines, 3);
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.model-gallery-block.mgb-tooltip-preview-height .model-hotspot > .model-hotspot__tooltip.mgb-tooltip-has-content > :not(.model-hotspot__html):not(.model-hotspot__title),
.model-gallery-block.mgb-tooltip-preview-lines .model-hotspot > .model-hotspot__tooltip.mgb-tooltip-has-content > :not(.model-hotspot__html):not(.model-hotspot__title) {
    display: none;
}

.model-hotspot__tooltip.mgb-tooltip-has-content.is-preview {
    padding: 2px;
    border-radius: 0;
}

.model-hotspot > .model-hotspot__tooltip.is-preview {
    filter: blur(8px);
    -webkit-filter: blur(8px);
    will-change: opacity, transform, filter;
    transition-property: opacity, transform, filter;
    transition-duration: 0.3s, 0.3s, 0.45s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1), cubic-bezier(0.4, 0, 0.2, 1), ease;
}

.model-hotspot:hover > .model-hotspot__tooltip.is-preview,
.model-hotspot:focus-within > .model-hotspot__tooltip.is-preview {
    filter: blur(0);
    -webkit-filter: blur(0);
}

.model-hotspot__tooltip.mgb-tooltip-has-content.mgb-tooltip-has-title.is-preview {
    overflow: hidden;
    row-gap: 0;
    z-index: 2147483001;
}

.model-hotspot__tooltip.mgb-tooltip-has-content.mgb-tooltip-has-title.is-preview .model-hotspot__title {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    margin: 0 0 4px;
    padding: 0 10px;
    line-height: 1.35;
    text-align: center;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.model-hotspot__tooltip.mgb-tooltip-has-content.is-preview .model-hotspot__html img {
    border-radius: 0 !important;
}

.model-gallery-block .model-hotspot__tooltip.is-preview::after {
    content: "Read more →";
    font-size: 11px;
    font-weight: 600;
    color: #38bdf8;
    display: block;
    margin-top: 4px;
}

.model-hotspot__download {
    float: left;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c3c4c7;
    border-bottom: none;
    margin-left: 0.5em;
    padding: 5px 10px;
    font-size: var(--mgb-download-font, 14px);
    line-height: 1.71428571;
    font-weight: 600;
    border-radius: 0;
    background: var(--mgb-download-bg);
    color: var(--mgb-download-color);
    text-decoration: none;
    white-space: nowrap;
}

.mgb-hotspot-download-block-wrap.alignleft,
.mgb-hotspot-download-block-wrap.aligncenter,
.mgb-hotspot-download-block-wrap.alignright {
    display: flex;
}

.mgb-hotspot-download-block-wrap.alignleft {
    justify-content: flex-start;
}

.mgb-hotspot-download-block-wrap.aligncenter {
    justify-content: center;
}

.mgb-hotspot-download-block-wrap.alignright {
    justify-content: flex-end;
}

.mgb-hotspot-download-block-wrap.alignleft .mgb-download-block,
.mgb-hotspot-download-block-wrap.aligncenter .mgb-download-block,
.mgb-hotspot-download-block-wrap.alignright .mgb-download-block {
    display: flex;
}

.model-hotspot__download.is-countdown,
.single-model-download-cta__button.is-countdown,
.cloud3dg-download-btn.is-countdown {
    border-color: var(--mgb-countdown-bar-fill, #2563eb);
    background: var(--mgb-countdown-bg, #eff6ff);
    color: var(--mgb-countdown-color, #111827);
    opacity: 1;
    pointer-events: none;
}

.model-hotspot__download.is-countdown:focus-visible,
.single-model-download-cta__button.is-countdown:focus-visible,
.cloud3dg-download-btn.is-countdown:focus-visible {
    outline: 2px solid var(--mgb-countdown-bar-fill, #2563eb);
    outline-offset: 2px;
}

.mgb-inline-countdown-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: 0 0 1em;
    box-sizing: border-box;
    margin-left: 0.5em;
    border: 2px solid currentcolor;
    border-right-color: transparent;
    border-radius: 50%;
    opacity: 0.9;
    animation: mgb-inline-countdown-spin 0.8s linear infinite;
}

@keyframes mgb-inline-countdown-spin {

    to {
        transform: rotate(360deg);
    }
}

.model-hotspot__download.mgb-inline-countdown--progress,
.single-model-download-cta__button.mgb-inline-countdown--progress,
.mgb-instant-download__button.mgb-inline-countdown--progress {
    position: relative;
    overflow: hidden;
}

.mgb-inline-countdown-progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--mgb-countdown-bar-bg, #dbeafe);
    overflow: hidden;
    pointer-events: none;
}

.mgb-inline-countdown-progress__fill {
    display: block;
    width: 0;
    height: 100%;
    background: var(--mgb-countdown-bar-fill, #2563eb);
    transition: width 0.15s linear;
}

/* The in-page button carries its own bar colours so the admin can restyle it
   without touching the countdown page. */
.mgb-instant-download__button .mgb-inline-countdown-progress {
    background: var(--mgb-instant-bar-bg, var(--mgb-countdown-bar-bg, #dbeafe));
}

.mgb-instant-download__button .mgb-inline-countdown-progress__fill {
    background: var(--mgb-instant-bar-fill, var(--mgb-countdown-bar-fill, #2563eb));
}

.mgb-instant-downloads {
    position: absolute;
    right: 0;
    bottom: 14px;
    left: 0;
    z-index: 11;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    transition: top 0.12s ease-out, bottom 0.12s ease-out;
}

/* Opacity-only hiding keeps the button focusable, so Tab can reach it and
   :focus-within reveals the row for keyboard visitors. */
.mgb-instant-downloads.is-hover {
    opacity: 0;
    transition: opacity 0.2s ease-in-out, top 0.12s ease-out, bottom 0.12s ease-out;
}

/* Hover-intent delay on the reveal only: a pointer that just crosses the photo
   never flashes the row, while leaving still fades out at once. The three delay
   slots match opacity, top and bottom so the pointer-following edge keeps its
   own timing. Keyboard focus reveals immediately. */
.model-gallery-slide:hover .mgb-instant-downloads.is-hover {
    opacity: 1;
    transition-delay: var(--mgb-instant-hover-delay, 200ms), 0ms, 0ms;
}

.mgb-instant-downloads.is-hover:focus-within {
    opacity: 1;
}

@media (hover: none) {

    .mgb-instant-downloads.is-hover {
        opacity: 1;
    }
}

/* The edge follows the pointer, so visitors who asked for less motion get an instant
   jump instead of a slide across the photo. */
@media (prefers-reduced-motion: reduce) {

    .mgb-instant-downloads {
        transition: none;
    }

    .mgb-instant-downloads.is-hover {
        transition: opacity 0.2s ease-in-out;
    }
}

/* A content image has no positioned media wrapper to hang the row on, so the image
   container becomes the anchor as soon as it carries a download button. Some themes
   put wp-block-image on the figure itself, others on a wrapper div. Kept as a
   standalone rule because browsers without :has() drop the whole selector list. */
.wp-block-image:has(.mgb-instant-downloads--inline),
.wp-block-image figure:has(.mgb-instant-downloads--inline) {
    position: relative;
}

.wp-block-image:hover .mgb-instant-downloads--inline {
    opacity: 1;
    transition-delay: var(--mgb-instant-hover-delay, 200ms), 0ms, 0ms;
}

.mgb-instant-downloads--inline {
    /* Resting corner before the pointer arrives, and the keyboard reveal: a captioned
       figure puts the caption under the image, so the row may only ever reach the
       bottom of the photo itself, never the caption. */
    top: 12px;
    right: 12px;
    bottom: auto;
    left: auto;
    padding: 0;
    justify-content: flex-end;
}

.mgb-instant-download__button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-style: solid;
    border-color: var(--mgb-instant-border, #c3c4c7);
    border-width: var(--mgb-instant-border-w, 1px);
    border-radius: var(--mgb-instant-radius, var(--mgb-download-radius, 6px));
    padding: var(--mgb-instant-pad-y, 5px) var(--mgb-instant-pad-x, 10px);
    font-family: inherit;
    font-size: var(--mgb-instant-font, var(--mgb-download-font, 14px));
    line-height: 1.71428571;
    font-weight: 600;
    background: var(--mgb-instant-bg, var(--mgb-download-bg, #dcdcde));
    color: var(--mgb-instant-color, var(--mgb-download-color, #50575e));
    box-shadow: var(--mgb-instant-shadow, 0 4px 12px rgba(0, 0, 0, 0.12));
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.mgb-instant-download__button svg {
    flex: 0 0 auto;
}

.mgb-instant-download__button:focus-visible {
    outline: 2px solid var(--mgb-countdown-bar-fill, #2563eb);
    outline-offset: 2px;
}

/* The visitor is paying a quota unit while the timer runs: keep the button
   visible and clickable, the script ignores clicks until the run resolves. */
.mgb-instant-download__button.is-countdown {
    border-color: var(--mgb-countdown-bar-fill, #2563eb);
    background: var(--mgb-countdown-bg, #eff6ff);
    color: var(--mgb-countdown-color, #111827);
}

/* 1. Desktop Layout (Default) */
.model-gallery-block[data-layout="masonry"] .model-gallery-slides {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(min(var(--mgb-track-min, 220px), 100%), 1fr)) !important;
    gap: var(--mgb-gap, 24px) !important;
}

.model-gallery-block[data-layout="pinterest"] .model-gallery-slides {
    column-count: auto !important;
    column-gap: var(--mgb-gap, 24px) !important;
}

/* 1b. Responsive tokens: desktop defaults come first so the
   "Apply Overrides" rules below resolve at every width. Without
   them, --mgb-cols-now is undefined above 1024px and the
   !important grid-template-columns / gap declarations become
   invalid at computed-value time (grid collapses to one column). */
.model-gallery-block[data-layout="masonry"] .model-gallery-slides,
.model-gallery-block[data-layout="pinterest"] .model-gallery-slides {
    --mgb-cols-now: var(--mgb-columns, 3);
    --mgb-gap-now: var(--mgb-gap, 24px);
}

/* 2. Responsive Overrides */
@media (max-width: 1024px) {
    .model-gallery-block[data-layout="masonry"] .model-gallery-slides,
    .model-gallery-block[data-layout="pinterest"] .model-gallery-slides {
        --mgb-cols-now: var(--mgb-columns-tablet, 1);
        --mgb-gap-now: var(--mgb-gap-tablet, 24px);
    }
}

@media (max-width: 640px) {
    .model-gallery-block[data-layout="masonry"] .model-gallery-slides,
    .model-gallery-block[data-layout="pinterest"] .model-gallery-slides {
        --mgb-cols-now: var(--mgb-columns-mobile, 1);
        --mgb-gap-now: var(--mgb-gap-mobile, 16px);
    }
}

/* 3. Apply Overrides for Tablet/Mobile */
.model-gallery-block[data-layout="masonry"] .model-gallery-slides {
    grid-template-columns: repeat(var(--mgb-cols-now), minmax(var(--mgb-track-min, 220px), 1fr)) !important;
    gap: var(--mgb-gap-now) !important;
}

.model-gallery-block[data-layout="pinterest"] .model-gallery-slides {
    column-count: var(--mgb-cols-now) !important;
    column-gap: var(--mgb-gap-now) !important;
}

/* 4. Track minimum calculation (must be present for both auto-fit and fixed) */
.model-gallery-block[data-layout="masonry"] .model-gallery-slides {
    --mgb-track-min: max(var(--mgb-item-min-width, 220px), min(100%, calc((100% - (var(--mgb-gap-now) * (var(--mgb-cols-now) - 1))) / var(--mgb-cols-now))));
}

/* ===== Hotspot details popup: base chrome =====
   build/block-model-gallery-frontend.js appends this overlay straight to
   <body>, so without these rules it renders in normal flow at the end of the
   document (a thin strip below the footer) instead of as a fixed dialog, and
   the moved .model-hotspot__tooltip keeps its absolute positioning inside
   .model-hotspot-popup__content, collapsing the dialog to zero height.
   Themes may restyle the dialog, but they must not have to re-create its
   layout. */
.model-hotspot-popup-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.55);
}

.model-hotspot-popup-overlay.is-opening,
.model-hotspot-popup-overlay.is-active,
.model-hotspot-popup-overlay.is-closing {
    display: flex;
}

.model-hotspot-popup {
    position: relative;
    box-sizing: border-box;
    width: min(720px, 92vw);
    max-height: min(90vh, calc(100dvh - 48px));
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 20px 24px 24px;
    border-radius: 16px;
    background: var(--mgb-popup-bg, #fff);
    color: var(--mgb-popup-color, #111827);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.35);
}

.model-hotspot-popup__close {
    position: absolute;
    top: 10px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.08);
    color: var(--mgb-popup-color, #111827);
    font-size: 0;
    line-height: 0;
    cursor: pointer;
}

.model-hotspot-popup__close::before,
.model-hotspot-popup__close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 2px;
    border-radius: 999px;
    background: currentcolor;
    pointer-events: none;
}

.model-hotspot-popup__close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.model-hotspot-popup__close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* The tooltip node is re-parented into the dialog; it must join the normal
   flow there or the content box measures 0px tall. */
.model-hotspot-popup__content .model-hotspot__tooltip {
    position: static;
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    min-width: 0;
    background: transparent;
    color: inherit;
    box-shadow: none;
    pointer-events: auto;
}

.model-hotspot-popup__content .model-hotspot__tooltip::after {
    content: none;
    display: none;
}

.model-hotspot-popup__content .model-hotspot__html {
    max-height: none;
    overflow: visible;
}

/* ===== Copy-prompt button: base chrome =====
   Only .single-model-copy-prompt / .single-model-specs__header scopes were
   styled in the theme, so inside the hotspot tooltip and the dialog the
   button fell back to the browser default (grey face, no padding, no border). */
.model-hotspot__tooltip .mgb-copy-prompt-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    margin-left: 0;
}

.model-hotspot__tooltip .mgb-copy-prompt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #0f172a;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.model-hotspot__tooltip .mgb-copy-prompt-btn:hover,
.model-hotspot__tooltip .mgb-copy-prompt-btn:focus-visible {
    border-color: #94a3b8;
    background: #f8fafc;
    color: #020617;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
    outline: none;
}

.model-hotspot__tooltip .mgb-copy-prompt-actions .model-hotspot__download {
    float: none;
    margin-left: 0;
    min-height: 36px;
    border-bottom: 1px solid #c3c4c7;
    border-radius: var(--mgb-download-radius, 6px);
}

.model-hotspot-popup__content .mgb-copy-prompt-actions {
    display: flex;
    align-items: center;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    margin-top: 16px;
}

.model-hotspot-popup__content .mgb-copy-prompt-btn {
    width: 100%;
    min-height: 40px;
    border-radius: 8px;
    white-space: normal;
}

.model-hotspot-popup__content .mgb-asset-details__title-row .mgb-copy-prompt-actions--inline {
    width: auto;
    margin: 0;
}

/* The dialog's close control shows an icon via ::before/::after, so its text
   label must stay available to assistive tech but out of the rendered box. */
.model-hotspot-popup__close-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.model-hotspot-popup__content .model-info-inline {
    margin: 12px 0;
}

.model-hotspot__html > .mgb-hotspot-generated-content {
    margin: 0 0 14px;
    padding: 0 0 14px;
    border-bottom: 1px solid color-mix(in srgb, currentcolor 16%, transparent);
}

.model-hotspot__html > .mgb-hotspot-generated-content p {
    margin: 0;
}

.model-hotspot__html > .mgb-hotspot-generated-content p + p {
    margin-top: 10px;
}

/* ===== Scroll lock while the hotspot dialog is open =====
   The toggle class is applied by build/block-model-gallery-frontend.js; without
   these rules the page keeps scrolling behind the fixed overlay. */
html:has(body.mgb-hotspot-popup-open) {
    overflow: hidden;
    scrollbar-gutter: stable;
}

body.mgb-hotspot-popup-open {
    overflow: hidden;
}
