/* Custom Slider Styles */
.custom-slider {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.slider-container {
    position: relative;
    width: 100%;
}

.slider-track {
    display: flex;
    transition: transform 0.6s ease-in-out, opacity 0.6s ease-in-out;
    will-change: transform, opacity;
    opacity: 1;
}

.slider-track.is-fading {
    opacity: 0;
}

.slider-slide {
    width: 100%;
    flex-shrink: 0;
    position: relative;
}

.slider-slide img {
    width: 100%;
    display: block;
    cursor: pointer;
    user-select: none;
}

/* Navigation Buttons */
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: background 0.3s ease;
    opacity: 0;
}

.slider-btn[style*="display: none"] {
    display: none !important;
}

.custom-slider:hover .slider-btn {
    opacity: 1;
}

.slider-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.slider-btn-prev {
    left: 10px;
}

.slider-btn-next {
    right: 10px;
}

.slider-btn .material-icons {
    font-size: 24px;
}

/* Dots Indicator */
.slider-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
    padding: 0 40px;
}

.slider-dots[style*="display: none"] {
    display: none !important;
}

.slider-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    padding: 0;
}

.slider-dot:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.2);
}

.slider-dot.active {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.3);
}

/* Modal Styles (Fancybox-like) */
.slider-modal {
    display: none;
    --modal-info-min-height: 76px;
    --modal-info-min-width: 120px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100svh;
    height: 100dvh;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.slider-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1B1B1B;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    max-height: 100svh;
    max-height: 100dvh;
    width: 100%;
    height: 100%;
    height: 100svh;
    height: 100dvh;
    z-index: 10000;
    animation: zoomIn 0.2s ease;
    border-radius: 6px;
    overflow: hidden;
    background: #000000;
    display: flex;
    flex-direction: column;
}

.modal-image-container {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    min-height: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
    align-items: center;
}

.modal-image-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: #1B1B1B;
    z-index: -1;
}

.modal-image-wrapper {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    /* fills remaining height above modal-info */
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    /* image sticks to bottom, touching modal-info */
    justify-content: center;
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

.modal-image-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    align-items: flex-end;
    width: 100%;
    height: 100%;
}

.modal-image-slide {
    width: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    /* image sits at bottom edge of slide */
    justify-content: center;
    overflow: hidden;
    position: relative;
    height: 100%;
    align-self: flex-end;
}

.modal-image {
    max-width: 100%;
    max-height: 90vh;
    max-height: calc(100vh - 60px);
    max-height: calc(100svh - var(--modal-info-min-height) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 60px);
    max-height: calc(100dvh - var(--modal-info-min-height) - env(safe-area-inset-bottom));
    object-fit: contain;
    display: block;
    transform-origin: center center;
    transition: transform 0.3s ease, opacity 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    opacity: 0;
    cursor: zoom-in;
}

.slider-expand img {
    width: 100%;
    height: 100%;
}

.slider-modal.is-zoomed .modal-image {
    cursor: pointer;
}

.modal-image[src] {
    opacity: 1;
}

.modal-image:not([src]) {
    background: #f0f0f0;
    min-height: 200px;
}

.modal-close {
    position: absolute;
    top: 13px;
    right: 20px;
    border: none;
    width: 30px;
    height: 30px;
    cursor: pointer;
    z-index: 10001;
}

.modal-close:hover {
    background: rgba(24, 24, 27, 0.3);
    transform: scale(1.1);
}

.modal-close .material-icons {
    font-size: 28px;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(24, 24, 27, 0);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: background 0.3s ease, color 0.3s ease, transform 0.3s ease;
    height: 50%;
}

.modal-nav:hover {
    background: transparent;
    color: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
}

.modal-nav.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.modal-nav img.nav-arrow-icon {
    width: clamp(60px, 4vw, 120px);
    height: clamp(60px, 4vw, 120px);
    object-fit: contain;
}

.modal-nav img.nav-arrow-icon.prev-arrow {
    transform: scaleX(-1);
}

.modal-info {
    position: relative;
    min-width: 120px;
    min-height: var(--modal-info-min-height);
    color: white;
    font-size: 14px;
    z-index: 10001;
    background: #040000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 8px;
    align-self: flex-start;
    justify-content: flex-start;
}

.modal-camera-selector-label {
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 500;
    font-style: normal;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0;
    color: #FFFFFF;
    text-align: left;
    margin-top: 4px;
    vertical-align: middle;
}

.modal-camera-list {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: start;
}

.modal-camera-list-item {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    border-radius: 2px;
    /* Button/borderRadiusSM typically */
    color: black;
    cursor: pointer;
    background: #FFFFFF;
    transition: all 0.2s ease;
    padding: 0 12px 2px;
    gap: 10px;
    height: 22px;
    font-family: Noto Sans JP, serif;
    font-weight: 700;
    font-size: 20px;
}


.slider-modal.portrait-mode.is-vertical-item .modal-camera-selector-label {
    flex-shrink: 0;
}

.modal-camera-list-item:hover {
    background: rgba(183, 31, 34, 0.1);
}

.modal-counter {
    font-weight: 500;
}

/* Thumbnails strip at bottom (Fancybox-like) */
.modal-thumbnails {
    z-index: 10001;
}

.thumbnails-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
    box-sizing: border-box;
    pointer-events: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.thumbnails-container::-webkit-scrollbar {
    height: 4px;
}

.thumbnails-container::-webkit-scrollbar-track {
    background: transparent;
}

.thumbnails-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.thumbnails-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.thumbnails-track {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    padding: 0 10px;
}

.thumbnail-item {
    flex-shrink: 0;
    height: 60px;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.3s ease, transform 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail-item:hover {
    border: 2px solid #1570EF;
}

.thumbnail-item.active {
    border: 2px solid #1570EF;
    opacity: 1;
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
    transition: width 0.3s ease;
}

.thumbnail-item.active img {
    width: 100%;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

.slider-modal.closing .modal-backdrop,
.slider-modal.closing-with-transform .modal-backdrop {
    animation: fadeOut 0.2s ease;
}

.slider-modal.closing .modal-content {
    animation: zoomOut 0.2s ease;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Rotate modal to landscape for carousel/h images */
.slider-modal.rotate-landscape {
    transform: rotate(90deg);
    transform-origin: center center;
    width: 100vh;
    width: 100dvh;
    height: 100vw;
    height: 100dvw;
    top: 50%;
    left: 50%;
    margin-top: -50vw;
    margin-top: calc(-50dvw);
    margin-left: -50vh;
    margin-left: calc(-50dvh);
}

.slider-modal.rotate-landscape .modal-content {
    max-width: 100vh;
    max-width: 100dvh;
    max-height: 100vw;
    max-height: 100dvw;
    width: 100vh;
    width: 100dvh;
    height: 100vw;
    height: 100dvw;
    display: flex;
    flex-direction: row;
}

.slider-modal.rotate-landscape .modal-image-container {
    height: fit-content;
    margin: auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.slider-modal.rotate-landscape .modal-image-wrapper {
    width: 100%;
    height: fit-content;
}

.slider-modal.rotate-landscape .modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.slider-modal.rotate-landscape .modal-thumbnails {
    position: static;
    width: auto;
    max-height: 100%;
    height: 100%;
    flex-direction: column;
    padding: 0;
    margin: 0;
}

.slider-modal.rotate-landscape .thumbnails-container {
    width: auto;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
}

.slider-modal.rotate-landscape .thumbnails-track {
    flex-direction: column;
    gap: 20px;
    padding: 0;
}

.slider-modal.rotate-landscape .thumbnail-item {
    width: 120px;
    height: 90px;
    margin: 0;
}

.slider-modal.rotate-landscape .modal-close {
    transform: rotate(-90deg);
    top: 10px;
    right: 10px;
}

.slider-modal.switching-camera .modal-controls-overlay,
.slider-modal.switching-camera .modal-info,
.slider-modal.switching-camera .modal-camera-list-item,
.slider-modal.switching-camera .modal-nav-prev,
.slider-modal.switching-camera .modal-nav-next {
    transition: none !important;
}

.slider-modal.switching-camera .modal-image,
.slider-modal.switching-camera .modal-image-track,
.slider-modal.switching-camera .modal-image-wrapper {
    transition: none !important;
}

/* Portrait mode for carousel/v images - vertical fullscreen with thumbnails at bottom */
.slider-modal.portrait-mode .modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.slider-modal.portrait-mode .modal-image-container {
    align-items: center;
    justify-content: flex-start;
    flex-direction: column;
    height: 100%;
}

.slider-modal.portrait-mode .modal-image-wrapper {
    width: 100%;
    flex: 1;
    min-height: 0;
    margin: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.slider-modal.portrait-mode .modal-image-track {
    width: 100%;
    height: 100%;
    align-items: flex-end;
    /* propagate flush-bottom */
}

.slider-modal.portrait-mode .modal-image-slide {
    height: 100%;
    align-items: flex-start;
    /* image at bottom of slide */
    justify-content: center;
    overflow: hidden;
}

.slider-modal.portrait-mode .modal-image {
    width: auto;
    height: auto;
    /* Constrain to the flex wrapper's actual pixel height */
    max-height: 100%;
    object-fit: contain;
}

.slider-modal.portrait-mode .modal-thumbnails {
    flex-direction: row;
    background: #FFFFFF;
}

.slider-modal.portrait-mode .thumbnails-container {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 16px 10px;
}

.slider-modal.portrait-mode .thumbnails-track {
    flex-direction: row;
    gap: 20px;
    justify-content: center;
    align-items: center;
    padding: 0 10px;
}

.slider-modal.portrait-mode .thumbnail-item {
    height: 60px;
}

.slider-modal.portrait-mode .modal-close {
    transform: none;
}

/* Touch support */
.slider-track {
    touch-action: pan-y;
}

.relative {
    position: relative;
}

.modal-image-action {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 55px;
    background: rgba(0, 0, 0, 0.25);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 10002;
}

/* Responsive */
@media (max-width: 600px) {
    .slider-btn {
        width: 35px;
        height: 35px;
    }

    .slider-btn .material-icons {
        font-size: 20px;
    }

    .modal-nav .material-icons {
        font-size: 80px;
    }
}

/* CSS for all items now (removed vertical-only restriction) */
.slider-modal .modal-thumbnails {
    display: none !important;
}

.slider-modal .modal-close {
    display: none !important;
}

.modal-controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none !important;
    z-index: 10001;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-controls-overlay.controls-visible {
    opacity: 1;
}

.modal-controls-overlay > * {
    pointer-events: auto !important;
}

.modal-controls-overlay button {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.modal-controls-overlay button:focus,
.modal-controls-overlay button:focus-visible,
.modal-controls-overlay button:active {
    outline: none;
}

.modal-expand {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 5px 40px 12px 5px;
    background: rgba(24, 24, 27, 0);
    border: none;
    cursor: pointer;
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.small-slider-expand {
    color: white;
}

.slider-modal .modal-expand {
    display: flex !important;
}

/* Portrait-mode: pin collapse button to the bottom-right of the image overlay */
.slider-modal.portrait-mode .modal-expand {
    bottom: 0;
    right: 0;
    padding-right: 8px;
}

.modal-dots {
    display: none;
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    padding: 0;
}

.slider-modal.is-vertical-item .modal-dots {
    display: flex !important;
    align-items: center;
}

.modal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    transition: background 0.3s ease, transform 0.3s ease;
    padding: 0;
}

.slider-modal.portrait-mode .modal-dots .modal-dot-wrap:first-child,
.slider-modal .modal-dots .modal-dot-wrap:first-child {
    padding-left: 20px;
}

.slider-modal.portrait-mode .modal-dots .modal-dot-wrap:last-child,
.slider-modal .modal-dots .modal-dot-wrap:last-child {
    padding-right: 20px;
}

.modal-dot-wrap {
    padding: 8px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
    flex: 0 0 auto;
    background-color: transparent;
    border: none;
}

.modal-dot.active {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.3);
}

.slider-modal .modal-dots {
    display: flex !important;
}

/* Adjust navigation arrows for all items universally inside overlay */
.slider-modal .modal-nav-next {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.slider-modal .modal-nav-prev {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* Reverse rotation when closing modal */
.slider-modal.reverse-rotate {
    transition: transform 200ms ease, opacity 200ms ease !important;
}

button:focus,
button:focus-visible,
button:active {
    border: none;
    outline: none;
    box-shadow: none;
}

/* Horizontal items in landscape mode */
@media (orientation: landscape) {
    /* Row layout: image fills left, info panel sits flush on the right */
    .slider-modal:not(.is-vertical-item) .modal-image-container {
        flex-direction: row;
        align-items: center;
        height: 100%;
        padding-right: 0;
        display: flex;
    }

    .slider-modal:not(.is-vertical-item) .modal-image-wrapper {
        flex: 1 1 auto;
        min-width: 0;
        height: 100%;
        align-items: center;
    }

    .slider-modal:not(.is-vertical-item) .modal-image-track {
        height: 100%;
        width: 100%;
        align-items: center;
    }

    .slider-modal:not(.is-vertical-item) .modal-image-slide {
        height: 100%;
        align-items: center;
        align-self: center;
    }

    .slider-modal:not(.is-vertical-item) .modal-image {
        max-width: 100%;
        max-height: 100%;
        max-height: 100dvh;
    }

    /* Info panel: in-flow flex column, no absolute/fixed positioning */
    .slider-modal:not(.is-vertical-item) .modal-info {
        position: relative;
        /* back in normal flow, flush against image wrapper */
        height: auto;
        /* height comes from align-items:stretch on parent */
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        width: 120px;
        z-index: 10002;
        padding: 0;
    }

    .slider-modal:not(.is-vertical-item) .modal-camera-list {
        display: flex;
        flex-direction: column;
        gap: clamp(4px, 1.5dvh, 8px);
        background: transparent;
        border-radius: 6px;
        z-index: 10002;
    }

    .slider-modal:not(.is-vertical-item) .modal-camera-selector-label {
        text-align: center;
        margin: 0;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

@media (min-width: 1024px) {
    .modal-expand {
        bottom: 0;
    }

    .modal-dots {
        bottom: 20px;
    }

    .slider-modal:not(.is-vertical-item) .modal-image {
        width: 3840px;
        height: 2160px;
    }

    /* Scale up no_image on desktop landscape */
    .slider-modal:not(.is-vertical-item) span.modal-image{
        width: 3840px !important;
        height: 2160px !important;
    }
}

.slider-modal,
.modal-image-wrapper {
    overscroll-behavior-x: none !important;
    overscroll-behavior-y: none !important;
}