.hrsj-story-gallery {
    width: 100%;
    max-width: 100%;
    margin-block: 1.5rem;
}

.hrsj-story-gallery > figure.wp-block-gallery.has-nested-images,
.editor-styles-wrapper figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel,
.hrsj-en-content-styles figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.hrsj-story-gallery > figure.wp-block-gallery::-webkit-scrollbar,
.editor-styles-wrapper figure.wp-block-gallery.is-style-hrsj-carousel::-webkit-scrollbar,
.hrsj-en-content-styles figure.wp-block-gallery.is-style-hrsj-carousel::-webkit-scrollbar {
    display: none;
}

.hrsj-story-gallery > figure.wp-block-gallery.has-nested-images > figure.wp-block-image:not(#individual-image),
.editor-styles-wrapper figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel > figure.wp-block-image:not(#individual-image),
.hrsj-en-content-styles figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel > figure.wp-block-image:not(#individual-image) {
    box-sizing: border-box;
    flex: 0 0 calc((100% - 24px) / 3);
    width: calc((100% - 24px) / 3);
    max-width: none;
    min-width: 0;
    scroll-snap-align: start;
    align-self: stretch;
}

.hrsj-story-gallery > figure.wp-block-gallery.has-nested-images > figure.wp-block-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.hrsj-story-gallery > .blocks-gallery-caption {
    margin-top: 8px;
    text-align: center;
    font-size: 0.875rem;
}

.hrsj-story-gallery__controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 12px;
}

.hrsj-story-gallery__count {
    color: #555;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.hrsj-story-gallery__buttons {
    display: flex;
    gap: 8px;
}

.hrsj-story-gallery__buttons button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #b6bcc4;
    border-radius: 50%;
    background: #fff;
    color: #15212c;
    font: inherit;
    cursor: pointer;
}

.hrsj-story-gallery__buttons button:hover:not(:disabled) { border-color: #d4232d; color: #d4232d; }
.hrsj-story-gallery__buttons button:focus-visible { outline: 3px solid #1d70b8; outline-offset: 2px; }
.hrsj-story-gallery__buttons button:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 900px) {
    .hrsj-story-gallery > figure.wp-block-gallery.has-nested-images > figure.wp-block-image:not(#individual-image),
    .editor-styles-wrapper figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel > figure.wp-block-image:not(#individual-image),
    .hrsj-en-content-styles figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel > figure.wp-block-image:not(#individual-image) {
        flex-basis: calc((100% - 12px) / 2);
        width: calc((100% - 12px) / 2);
    }
}

@media (max-width: 600px) {
    .hrsj-story-gallery > figure.wp-block-gallery.has-nested-images > figure.wp-block-image:not(#individual-image),
    .editor-styles-wrapper figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel > figure.wp-block-image:not(#individual-image),
    .hrsj-en-content-styles figure.wp-block-gallery.has-nested-images.is-style-hrsj-carousel > figure.wp-block-image:not(#individual-image) {
        flex-basis: 100%;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hrsj-story-gallery > figure.wp-block-gallery { scroll-behavior: auto; }
}
