/**
 * Gallery Mobile Optimization
 * Otimizações específicas para mobile e tablets
 */

/* Garantir que imagens não ultrapassem container */
.lsc-gallery-image img {
    max-width: 100%;
    height: auto;
}

/* Tablet (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .lsc-gallery-main {
        aspect-ratio: 4 / 3;
    }

    .lsc-gallery-thumbs {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .lsc-gallery-thumb {
        min-width: 70px;
        height: 70px;
    }

    .lsc-gallery-more {
        min-width: 70px;
        height: 70px;
    }
}

/* Desktop grande (1025px+) */
@media (min-width: 1025px) {
    .lsc-gallery-main {
        aspect-ratio: 16 / 9;
    }

    .lsc-gallery-thumbs {
        display: flex;
        grid-template-columns: unset;
    }

    /* Scroll suave em desktop */
    .lsc-gallery-thumbs {
        scroll-behavior: smooth;
    }
}

/* iPad Pro e tablets grandes */
@media (min-width: 1024px) and (max-height: 1366px) and (orientation: landscape) {
    .lsc-gallery-main {
        aspect-ratio: 16 / 9;
        max-height: 50vh;
    }
}

/* iPhone e smartphones pequenos */
@media (max-width: 375px) {
    .lsc-gallery-main {
        aspect-ratio: 1 / 1;
    }

    .lsc-gallery-thumbs {
        padding: 6px;
        gap: 4px;
    }

    .lsc-gallery-thumb,
    .lsc-gallery-more {
        flex: 0 0 45px;
        min-width: 45px;
        height: 45px;
        width: 45px;
    }

    .lsc-gallery-expand {
        width: 36px;
        height: 36px;
        bottom: 10px;
        right: 10px;
    }

    .lsc-gallery-expand svg {
        width: 18px;
        height: 18px;
    }
}

/* Suporte a notch (iPhone X+) */
@supports (padding: max(0px)) {
    .lsc-gallery-expand {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(20px, env(safe-area-inset-right));
    }

    .lsc-gallery-thumbs {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* Modo landscape em mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .lsc-gallery-main {
        aspect-ratio: auto;
        height: calc(100vh - 200px);
    }

    .lsc-gallery-thumbs {
        height: 50px;
    }

    .lsc-gallery-thumb,
    .lsc-gallery-more {
        height: 50px;
        min-width: 50px;
    }
}

/* Forçar aspect-ratio suportado */
@supports (aspect-ratio: 1) {
    .lsc-gallery-main {
        aspect-ratio: 16 / 9;
    }

    .lsc-gallery-thumb {
        aspect-ratio: 4 / 3;
    }

    .lsc-gallery-more {
        aspect-ratio: 4 / 3;
    }
}

/* Fallback para navegadores sem suporte a aspect-ratio */
@supports not (aspect-ratio: 1) {
    .lsc-gallery-main {
        padding-bottom: 56.25%;
        height: 0;
        overflow: hidden;
    }

    .lsc-gallery-image {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* Performance: GPU acceleration */
.lsc-gallery-main,
.lsc-gallery-image,
.lsc-gallery-thumb {
    transform: translateZ(0);
    will-change: transform;
}

/* Otimizar scroll em mobile */
.lsc-gallery-thumbs {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
}

.lsc-gallery-thumb {
    scroll-snap-align: start;
    scroll-snap-stop: auto;
}

/* Imagens de alta DPI */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .lsc-gallery-image img,
    .lsc-gallery-thumb img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .lsc-property-gallery {
        background: #0a0a0a;
    }

    .lsc-gallery-main {
        background: #000;
    }

    .lsc-gallery-image img {
        background: #1a1a1a;
    }
}

/* Light mode support */
@media (prefers-color-scheme: light) {
    .lsc-property-gallery {
        background: #f5f5f5;
    }

    .lsc-gallery-main {
        background: #fff;
    }

    .lsc-gallery-image img {
        background: #eee;
    }
}

/* Reduzir movimento se preferência do usuário */
@media (prefers-reduced-motion: reduce) {
    .lsc-gallery-expand,
    .lsc-gallery-thumb,
    .lsc-gallery-more,
    .lsc-gallery-image img {
        transition: none !important;
    }

    .lsc-gallery-thumb:hover img {
        transform: none;
    }
}
