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

:root {
    --rms-gallery-bg: #f4f6f8;
    --rms-gallery-border: #e2e8f0;
    --rms-gallery-accent: #3d4f5f;
    --rms-gallery-muted: #64748b;
    --rms-gallery-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --rms-gallery-radius: 10px;
    --rms-gallery-compact-max: 400px;
}

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

.rms-gallery-slider__viewport {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--rms-gallery-border);
    border-radius: var(--rms-gallery-radius);
    background: var(--rms-gallery-bg);
    box-shadow: var(--rms-gallery-shadow);
}

.rms-gallery-slider__viewport:focus {
    outline: none;
}

.rms-gallery-slider__viewport:focus-visible {
    box-shadow: var(--rms-gallery-shadow), 0 0 0 3px rgba(61, 79, 95, 0.28);
}

.rms-gallery-slider__viewport--single {
    cursor: default;
}

figure.wp-block-gallery.rms-product-gallery,
.wp-block-gallery.rms-product-gallery {
    margin: 0;
}

figure.wp-block-gallery.rms-product-gallery .wp-block-image,
.wp-block-gallery.rms-product-gallery .wp-block-image {
    width: 100%;
    min-height: 500px;
    height: 500px;
    margin: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: var(--rms-gallery-bg);
}

.wp-block-gallery.rms-product-gallery img:not(.rms-gallery-img--compact),
figure.wp-block-gallery.rms-product-gallery .wp-block-image img:not(.rms-gallery-img--compact),
.rms-product-gallery .rms-gallery-img:not(.rms-gallery-img--compact) {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 auto;
    object-fit: contain;
    object-position: center;
}

.rms-gallery-slide--zoomable {
    cursor: zoom-in;
    position: relative;
}

.rms-gallery-slide--zoomable::after {
    content: "";
    position: absolute;
    right: 0.85rem;
    bottom: 0.85rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233d4f5f'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1.5h2V11h1.5V9.5H12V8h-2V6z'/%3E%3C/svg%3E")
        center / 1.1rem no-repeat;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.rms-gallery-slide--zoomable:hover::after,
.rms-gallery-slide--zoomable:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

/* 元画像が小さい場合: 最大 400px の枠内に収める（これ以上拡大しない） */
figure.wp-block-gallery.rms-product-gallery .wp-block-image.rms-gallery-slide--compact img.rms-gallery-img--compact,
.wp-block-gallery.rms-product-gallery .wp-block-image.rms-gallery-slide--compact img.rms-gallery-img--compact {
    display: block !important;
    box-sizing: border-box !important;
    width: var(--rms-gallery-compact-max) !important;
    height: var(--rms-gallery-compact-max) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: var(--rms-gallery-compact-max) !important;
    max-height: var(--rms-gallery-compact-max) !important;
    margin: 0 auto !important;
    padding: 0 !important;
    object-fit: contain !important;
    object-position: center !important;
}

/* 複数枚: 横スライダー */
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: 500px;
    height: 500px;
    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;
    scroll-snap-stop: always;
}

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: 3;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    color: var(--rms-gallery-accent);
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.16);
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.rms-gallery-slider__viewport:hover .rms-gallery-slider__btn,
.rms-gallery-slider__viewport:focus-within .rms-gallery-slider__btn {
    opacity: 1;
}

.rms-gallery-slider__btn:hover:not(:disabled) {
    background: #fff;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2);
    transform: translateY(-50%) scale(1.04);
}

.rms-gallery-slider__btn:focus-visible {
    opacity: 1;
    outline: none;
    box-shadow: 0 0 0 3px rgba(61, 79, 95, 0.35);
}

.rms-gallery-slider__btn:disabled {
    opacity: 0.35 !important;
    cursor: default;
    pointer-events: none;
}

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

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

/* 枚数バッジ */
.rms-gallery-slider__badge {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 2;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

/* ツールバー */
.rms-gallery-slider__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.55rem;
    padding: 0 0.15rem;
    color: var(--rms-gallery-muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.rms-gallery-slider__status {
    margin: 0;
    font-weight: 600;
    color: var(--rms-gallery-accent);
}

.rms-gallery-slider__hint {
    margin: 0;
    text-align: right;
}

/* サムネイル一覧 */
.rms-gallery-slider__thumbs {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.55rem;
    margin-top: 0.7rem;
    padding: 0.2rem 0.15rem 0.35rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    -webkit-overflow-scrolling: touch;
}

.rms-gallery-slider__thumbs--scrollable {
    mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 12px,
        #000 calc(100% - 12px),
        transparent 100%
    );
}

.rms-gallery-slider__thumbs::-webkit-scrollbar {
    height: 6px;
}

.rms-gallery-slider__thumbs::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #cbd5e1;
}

.rms-gallery-slider__thumb {
    flex: 0 0 auto;
    width: 4.75rem;
    height: 4.75rem;
    padding: 0;
    border: 2px solid var(--rms-gallery-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    scroll-snap-align: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.rms-gallery-slider__thumb:hover {
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.rms-gallery-slider__thumb:focus-visible {
    outline: none;
    border-color: var(--rms-gallery-accent);
    box-shadow: 0 0 0 3px rgba(61, 79, 95, 0.22);
}

.rms-gallery-slider__thumb.is-active {
    border-color: var(--rms-gallery-accent);
    box-shadow: 0 0 0 1px var(--rms-gallery-accent), 0 4px 12px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
}

.rms-gallery-slider__thumb img {
    width: 100%;
    height: 100%;
    max-height: none !important;
    min-height: 0 !important;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0;
    background: #f8fafc;
    cursor: pointer;
}

/* クリック拡大（子テーマ内蔵ライトボックス） */
.rms-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    background: rgba(0, 0, 0, 0.88);
}

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

html.rms-gallery-lightbox-open {
    overflow: hidden;
}

.rms-gallery-lightbox__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(96vw, 1200px);
    height: min(88vh, 900px);
    overflow: hidden;
}

.rms-gallery-lightbox__img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
}

.rms-gallery-lightbox__img--zoomed {
    cursor: grab;
}

.rms-gallery-lightbox__img--zoomed.rms-gallery-lightbox__img--dragging {
    cursor: grabbing;
}

.rms-gallery-lightbox__close,
.rms-gallery-lightbox__nav {
    position: absolute;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: #222;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: background 0.2s ease, transform 0.2s ease;
}

.rms-gallery-lightbox__close:hover,
.rms-gallery-lightbox__nav:hover {
    background: #fff;
    transform: scale(1.04);
}

.rms-gallery-lightbox__close {
    top: 1rem;
    right: 1rem;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    font-size: 1.75rem;
    line-height: 1;
}

.rms-gallery-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    font-size: 1.75rem;
    line-height: 1;
}

.rms-gallery-lightbox__nav:hover {
    transform: translateY(-50%) scale(1.04);
}

.rms-gallery-lightbox__nav--prev {
    left: 1rem;
}

.rms-gallery-lightbox__nav--next {
    right: 1rem;
}

.rms-gallery-lightbox__nav[hidden],
.rms-gallery-lightbox__nav:hidden {
    display: none;
}

@media (max-width: 767px) {
    figure.wp-block-gallery.rms-product-gallery .wp-block-image,
    .wp-block-gallery.rms-product-gallery .wp-block-image,
    figure.wp-block-gallery.rms-product-gallery--slider,
    .wp-block-gallery.rms-product-gallery--slider,
    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 {
        min-height: min(500px, 70vh);
        height: min(500px, 70vh);
    }

    .rms-gallery-slider__btn {
        opacity: 1;
        width: 2.85rem;
        height: 2.85rem;
    }

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

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

    .rms-gallery-slider__badge {
        left: 0.55rem;
        bottom: 0.55rem;
        font-size: 0.74rem;
    }

    .rms-gallery-slider__toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
        font-size: 0.78rem;
    }

    .rms-gallery-slider__hint {
        text-align: left;
    }

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

    .rms-gallery-slider__thumb {
        width: 4.25rem;
        height: 4.25rem;
    }

    .rms-gallery-slide--zoomable::after {
        opacity: 1;
        transform: translateY(0);
        width: 1.85rem;
        height: 1.85rem;
        right: 0.55rem;
        bottom: 0.55rem;
        background-size: 1rem;
    }

    .rms-gallery-lightbox__nav--prev {
        left: 0.35rem;
    }

    .rms-gallery-lightbox__nav--next {
        right: 0.35rem;
    }
}

/* 商品仕様テーブル */
.wp-block-table.rms-product-spec-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.96em;
}

.wp-block-table.rms-product-spec-table th,
.wp-block-table.rms-product-spec-table td {
    padding: 0.65em 0.85em;
    border: 1px solid #e2e8f0;
    vertical-align: top;
    text-align: left;
    line-height: 1.65;
}

.wp-block-table.rms-product-spec-table tr.rms-spec-section th {
    background: #3a4b05;
    color: #fff;
    font-size: 0.92em;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.55em 0.85em;
    border-color: #3a4b05;
}

.wp-block-table.rms-product-spec-table tr:not(.rms-spec-section):not(.rms-spec-block) th[scope="row"] {
    width: 30%;
    background: #f8fafc;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}

.wp-block-table.rms-product-spec-table tr.rms-spec-block > td {
    padding: 0.85em;
    background: #fff;
}

.wp-block-table.rms-product-spec-table .rms-spec-expanded-note {
    margin-top: 0;
    border-color: #f6d365;
    background: #fffbeb;
}

.wp-block-table.rms-product-spec-table .rms-spec-expanded-note__heading {
    color: #92400e;
}

.wp-block-table.rms-product-spec-table .rms-spec-expanded-note__size {
    color: #78350f;
    font-size: 1.02em;
}

.rms-product-notice {
    margin: 1.1em 0 1.5em;
    padding: 0.9em 1em;
    border: 1px solid #fcd34d;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    background: #fffbeb;
    color: #78350f;
}

.rms-product-notice__title {
    margin: 0 0 0.55em;
    font-weight: 700;
    font-size: 0.95em;
    color: #92400e;
}

.rms-product-notice__item {
    margin: 0.35em 0 0;
    font-size: 0.92em;
    line-height: 1.7;
}

@media (max-width: 599px) {
    .wp-block-table.rms-product-spec-table tr:not(.rms-spec-section):not(.rms-spec-block) {
        display: block;
        border-bottom: 1px solid #e2e8f0;
    }

    .wp-block-table.rms-product-spec-table tr:not(.rms-spec-section):not(.rms-spec-block) th,
    .wp-block-table.rms-product-spec-table tr:not(.rms-spec-section):not(.rms-spec-block) td {
        display: block;
        width: 100%;
        border: 0;
        padding: 0.45em 0.85em;
    }

    .wp-block-table.rms-product-spec-table tr:not(.rms-spec-section):not(.rms-spec-block) th {
        padding-bottom: 0.15em;
        background: transparent;
        color: #64748b;
        font-size: 0.84em;
    }

    .wp-block-table.rms-product-spec-table tr:not(.rms-spec-section):not(.rms-spec-block) td {
        padding-top: 0;
        padding-bottom: 0.75em;
        font-weight: 600;
    }
}

/* 商品仕様の内訳テーブル */
.wp-block-table.min_width20_ table.rms-spec-detail {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 0.95em;
}

.wp-block-table.min_width20_ table.rms-spec-detail th,
.wp-block-table.min_width20_ table.rms-spec-detail td {
    padding: 0.55em 0.75em;
    border: 1px solid #e2e8f0;
    vertical-align: top;
    text-align: left;
}

.wp-block-table.min_width20_ table.rms-spec-detail th {
    width: 32%;
    background: #f8fafc;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}

.wp-block-table.min_width20_ table.rms-spec-detail tr:nth-child(even) td {
    background: #fcfdff;
}

.wp-block-table.min_width20_ .rms-spec-expanded-note {
    margin-top: 0.85em;
    padding: 0.75em 0.9em;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 0.95em;
    line-height: 1.7;
    color: #334155;
}

.wp-block-table.min_width20_ .rms-spec-expanded-note__heading {
    margin: 0 0 0.45em;
    font-weight: 600;
}

.wp-block-table.min_width20_ .rms-spec-expanded-note__size {
    margin: 0;
    font-weight: 600;
}

.maroan-rms-product-summary {
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--rms-gallery-border);
    border-radius: var(--rms-gallery-radius);
    background: #f8faf5;
}

.maroan-rms-product-summary p {
    margin: 0;
    line-height: 1.75;
    color: #374151;
    font-size: 0.92rem;
}

.maroan-rms-product-summary p + p {
    margin-top: 0.45rem;
}

@media (prefers-reduced-motion: reduce) {
    .rms-gallery-slider__btn,
    .rms-gallery-slide--zoomable::after,
    .rms-gallery-slider__thumb,
    .rms-gallery-lightbox__close,
    .rms-gallery-lightbox__nav {
        transition: none;
    }

    figure.wp-block-gallery.rms-product-gallery--slider,
    .wp-block-gallery.rms-product-gallery--slider {
        scroll-behavior: auto;
    }
}