/* GRID */
.establecimientos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin: 40px 0;
}

/* CARD */
.flip-card {
    aspect-ratio: 3 / 4; /* mantiene proporción */
    perspective: 1200px; /* flip 3D */

    opacity: 1;
    transform: scale(1);
    transition: opacity .35s ease, transform .35s ease;

    /*evitar estirarmiento*/
    max-width: 380px;
    width: 100%;
    margin: 0 auto;
}

/* MOTOR 3D */
.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.7s ease;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

/* CARAS */
.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* FRONT */
.flip-card-front {
    background: #f1ecec;
}

.flip-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* BACK */
.flip-card-back {
    background: linear-gradient(135deg, #c6c4c4, #d5d0d0);
    color: #000000;
    transform: rotateY(180deg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: left;
    text-align: left;
}

.flip-card-back p {
    margin: 4px 0;
    font-size: 15px;
}

.flip-card-back h2 {
    justify-content: center;
    text-align: center;
    font-size: 18px;
}

/* LAZY LOADING */
.lazy-img {
    opacity: 0;
    transition: opacity .4s ease;
}

.lazy-img.loaded {
    opacity: 1;
}

@media (max-width: 600px) {
    .flip-card {
        aspect-ratio: 4 / 5;
    }
}


.flip-card.hide {
    display: none;
}

.flip-card.show {
    opacity: 1;
    transform: scale(1);
}

.me-pagination {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 40px 0;
}

.me-pagination button {
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    background: #007ad9;
    color: #fff;
    cursor: pointer;
}

.me-pagination button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.me-socials {
    margin-top: 10px;
    display: flex;
    justify-content: left;
    gap: 12px;
}

.me-socials img {
    width: 40px;
    height: 40px;
    transition: transform .2s ease, opacity .2s ease;
}

.me-socials a:hover img {
    transform: scale(1.15);
    opacity: .85;
}

.me-links {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 14px;
}

.me-links a {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: transform .25s ease, background .25s ease;
}

.me-links a:hover {
    transform: scale(1.15);
    background: rgba(255, 255, 255, 0.3);
}

.me-links img {
    width: 18px;
    height: 18px;
}

.me-filtros-row {
    display: flex;
    gap: 16px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.me-filtros-row select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    min-width: 220px;
}

.me-counter {
    margin: 10px 0 15px;
    font-weight: 600;
    color: #333;
}


.me-search {
    margin: 0 0;
}

.me-search input {
    width: 100%;
    max-width: 420px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 15px;
}

.me-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.me-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .7);
}

.me-modal-content {
    position: relative;
    background: #fff;
    max-width: 900px;
    margin: 5vh auto;
    padding: 20px;
    border-radius: 8px;
}

.me-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.me-gallery-grid img {
    width: 100%;
    border-radius: 6px;
}

/* ===== MODAL GALERÍA ===== */
.me-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none; /* se controla por JS */
    align-items: center;
    justify-content: center;
    z-index: 999999; /* más alto que cualquier tema */
}

.me-modal.is-open {
    display: flex;
}

.me-modal-content {
    background: #fff;
    max-width: 90%;
    max-height: 90%;
    padding: 20px;
    border-radius: 12px;
    overflow: auto;
}

.me-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 28px;
    background: none;
    border: none;
    cursor: pointer;
}

.me-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.me-gallery-grid img {
    width: 100%;
    border-radius: 8px;
}

/* Modal base */
.me-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 9999;
}

.me-modal.is-open {
    display: block;
}

.me-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .75);
}

/* Contenido */
.me-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    margin: 5vh auto;
    background: #000;
    padding: 20px;
}

/* Galería grid */
.me-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.me-gallery-grid img {
    width: 100%;
    cursor: zoom-in;
}

/* Lightbox */
#me-lightbox-img {
    display: none;
    max-width: 100%;
    max-height: 80vh;
    margin: auto;
}

.me-lightbox-prev,
.me-lightbox-next {
    display: none;
    position: absolute;
    top: 50%;
    font-size: 40px;
    background: none;
    color: #fff;
    border: none;
    cursor: pointer;
}

.me-lightbox-prev {
    left: 10px;
}

.me-lightbox-next {
    right: 10px;
}

.me-modal.lightbox-active #me-lightbox-img,
.me-modal.lightbox-active .me-lightbox-prev,
.me-modal.lightbox-active .me-lightbox-next {
    display: block;
}

.me-modal.lightbox-active .me-gallery-grid {
    display: none;
}

/* Lazy + blur */
.me-gallery-grid img,
#me-lightbox-img {
    filter: blur(12px);
    transition: filter .4s ease;
}

.me-gallery-grid img.loaded,
#me-lightbox-img.loaded {
    filter: blur(0);
}

/* Mejor UX */
.me-gallery-grid img {
    background: #111;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.me-lightbox {
    position: relative;
    text-align: center;
    margin-bottom: 20px;
}

#me-lightbox-img {
    max-width: 100%;
    max-height: 70vh;
    cursor: zoom-in;
    transition: transform .25s ease, filter .25s ease;
    filter: blur(8px);
}

#me-lightbox-img.loaded {
    filter: blur(0);
}

#me-lightbox-img.zoomed {
    transform: scale(2);
    cursor: zoom-out;
}

.me-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    z-index: 10;
}

.me-nav.prev {
    left: 0;
}

.me-nav.next {
    right: 0;
}

/*
*   TEXTO SOBRE IMAGEN (FLIP CARD)
 */

/*.flip-card-front {*/
/*    position: relative;*/
/*    overflow: hidden;*/
/*}*/

/*.flip-card-front img {*/
/*    width: 100%;*/
/*    height: 100%;*/
/*    object-fit: cover;*/
/*}*/

/* Overlay inferior */
.flip-card-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px 10px;

    background: linear-gradient(
            to top,
            rgba(255, 255, 255, 0.7),
            rgba(255, 255, 255, 0.82)
    );

    color: #fff;
    text-align: center;
}

/* Título */
.flip-card-title h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;

    display: -webkit-box;
    -webkit-line-clamp: 2; /* Máx 2 líneas */
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/**
*   RATING ESTRELLAS
**/

.flip-card-rating {
    position: absolute;
    top: 10px;
    left: 10px;

    font-size: 1rem;
    letter-spacing: 2px;
    display: flex;
    gap: 2px;

    color: rgba(255, 255, 255, 0.51);
    background: rgba(0, 0, 0, 0.17);
    padding: 4px 8px;
    border-radius: 12px;

    overflow: hidden;
}


.flip-card-rating .star {
    color: rgba(255,255,255,0.3);
}

.flip-card-rating .star.filled {
    color: #FFD700; /* dorado */
}

.flip-card-rating {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.star-icon {
    width: 18px;
    height: 18px;
    fill: rgba(255,255,255,0.35);
}

/* Estrella activa */
.star.filled .star-icon {
    fill: #FFD700;
}

/* 📱 MOBILE */
@media (max-width: 768px) {
    .star-icon {
        width: 14px;
        height: 14px;
    }

    .flip-card-rating {
        gap: 3px;
    }
}