/* RMS商品投稿ページの画像ギャラリー */

.rms-gallery-slider {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    margin: 1.5rem 0;
}

.wp-block-gallery.rms-product-gallery img,
figure.wp-block-gallery.rms-product-gallery .wp-block-image img {
    max-height: 600px;
    width: auto !important;
    height: auto !important;
    max-width: 100%;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

figure.wp-block-gallery.rms-product-gallery .wp-block-image img[src*="taitoru"],
figure.wp-block-gallery.rms-product-gallery .wp-block-image img[src*="title"],
figure.wp-block-gallery.rms-product-gallery .wp-block-image img[src$=".gif"] {
    max-width: min(100%, 520px);
}

/* 複数枚: 横スライダー */
figure.wp-block-gallery.rms-product-gallery--slider,
.wp-block-gallery.rms-product-gallery--slider {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    gap: 0 !important;
    scrollbar-width: none;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 12rem;
    list-style: none;
}

figure.wp-block-gallery.rms-product-gallery--slider::-webkit-scrollbar,
.wp-block-gallery.rms-product-gallery--slider::-webkit-scrollbar {
    display: none;
}

figure.wp-block-gallery.rms-product-gallery--slider > figure.wp-block-image,
figure.wp-block-gallery.rms-product-gallery--slider > .wp-block-image,
.wp-block-gallery.rms-product-gallery--slider > figure.wp-block-image,
.wp-block-gallery.rms-product-gallery--slider > .wp-block-image {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    scroll-snap-align: start;
    margin: 0 !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    min-height: 12rem;
}

figure.wp-block-gallery.rms-product-gallery--slider.has-nested-images > figure.wp-block-image,
.wp-block-gallery.rms-product-gallery--slider.has-nested-images > figure.wp-block-image {
    width: 100% !important;
    max-width: 100% !important;
}

.rms-gallery-slider__btn {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #333;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s;
}

.rms-gallery-slider__btn:hover {
    background: #fff;
}

.rms-gallery-slider__btn--prev {
    left: 0.5rem;
}

.rms-gallery-slider__btn--next {
    right: 0.5rem;
}

/* サムネイル一覧 */
.rms-gallery-slider__thumbs {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.15rem 0;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.rms-gallery-slider__thumb {
    flex: 0 0 auto;
    width: 4.5rem;
    height: 4.5rem;
    padding: 0;
    border: 2px solid #dde3ea;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.rms-gallery-slider__thumb:hover {
    border-color: #a0aec0;
}

.rms-gallery-slider__thumb.is-active {
    border-color: #4a5568;
    box-shadow: 0 0 0 1px #4a5568;
}

.rms-gallery-slider__thumb img {
    width: 100%;
    height: 100%;
    max-height: none !important;
    object-fit: cover;
    display: block;
    margin: 0;
}

@media (max-width: 767px) {
    figure.wp-block-gallery.rms-product-gallery--slider,
    .wp-block-gallery.rms-product-gallery--slider {
        min-height: 10rem;
    }

    .rms-gallery-slider__btn {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.65rem;
    }

    .rms-gallery-slider__thumbs {
        margin-top: 0.55rem;
    }
}