/**
 * Ody's — Single product: galería y productos similares
 * ---------------------------------------------------------------------------
 * Se carga solo en is_product() desde functions.php, DESPUÉS del CSS adicional
 * del personalizador (post custom_css #3673). Ese CSS usa !important en casi
 * todo, así que aquí se sube un nivel de especificidad (.custom-figma-card
 * como ancestro) para poder ganarle sin tener que editar la base de datos.
 *
 * Reglas del CSS adicional que estas líneas sustituyen:
 *   .custom-figma-gallery .woocommerce-product-gallery__image img
 *     { aspect-ratio: 4/5; border-radius: 24px; box-shadow: ... }
 *   .flex-control-nav.flex-control-thumbs (miniaturas)
 * Si algún día se limpia el CSS adicional, hay que quitar esas reglas de allí,
 * no de aquí.
 */

/* ===========================================================================
   1. GALERÍA
   ---------------------------------------------------------------------------
   El problema: el CSS adicional forzaba aspect-ratio 4/5 (retrato) con
   object-fit:cover sobre fotos que son 3:2 (1536x1024 en 13 de 18 productos).
   Resultado: se recortaba ~45% del ancho y quedaban franjas de mármol muertas
   arriba y abajo. 4/3 es el compromiso: recorta un 11% de los 3:2 y un 19%
   de los cuadrados (1024x943), siempre por los bordes, nunca por el centro
   del plato.
   =========================================================================== */

.custom-figma-card {
    /* Antes las dos columnas se estiraban a la misma altura, lo que dejaba un
       hueco blanco enorme bajo la foto cuando el formulario era más alto. */
    align-items: start !important;
}

.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery {
    position: relative !important;
}

/* El marco: el redondeo, el borde y la sombra viven aquí, no en el <img>,
   para que el recorte y el zoom del plugin queden dentro del marco. */
.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__wrapper,
.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__image {
    border-radius: 16px !important;
    overflow: hidden !important;
}

.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__wrapper {
    /* Mismo lenguaje visual que las tarjetas del menú: borde fino azulado,
       sombra baja y difusa. */
    border: 1px solid #e1e8f0 !important;
    box-shadow: 0 6px 20px rgba(13, 59, 65, 0.08) !important;
    background: #f4f6f8 !important;
    margin: 0 !important;
}

.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__image {
    aspect-ratio: 4 / 3 !important;
    display: block !important;
    position: relative !important;
}

.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__image > a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__image img {
    width: 100% !important;
    height: 100% !important;
    /* La proporción la manda el contenedor; el img solo lo rellena. */
    aspect-ratio: auto !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    /* El marco ya pone redondeo y sombra. */
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Botón de pantalla completa (la lupa). Antes era un emoji suelto sobre la
   foto; ahora es un botón redondo legible sobre cualquier imagen. */
.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__trigger {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    z-index: 9 !important;
    width: 38px !important;
    height: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 17px !important;
    line-height: 1 !important;
    text-indent: 0 !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.92) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14) !important;
    backdrop-filter: blur(4px);
    transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1),
                background-color 160ms ease;
}

.custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__trigger:active {
    transform: scale(0.94) !important;
}

@media (hover: hover) and (pointer: fine) {
    .custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__trigger:hover {
        background: #ffffff !important;
        transform: scale(1.06) !important;
    }
}

/* Miniaturas: cuadradas, con el mismo borde que el marco y un anillo en la
   activa. Antes ocupaban el 25% cada una sin ningún estado visible. */
.custom-figma-card .custom-figma-gallery .flex-control-thumbs {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
    margin: 12px 0 0 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.custom-figma-card .custom-figma-gallery .flex-control-thumbs li {
    width: auto !important;
    margin: 0 !important;
    float: none !important;
}

.custom-figma-card .custom-figma-gallery .flex-control-thumbs img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    border-radius: 10px !important;
    border: 1px solid #e1e8f0 !important;
    opacity: 0.72 !important;
    cursor: pointer !important;
    transition: opacity 160ms ease, border-color 160ms ease;
}

.custom-figma-card .custom-figma-gallery .flex-control-thumbs img:hover,
.custom-figma-card .custom-figma-gallery .flex-control-thumbs img.flex-active {
    opacity: 1 !important;
    border-color: #831b11 !important;
}

/* Cuando el producto tiene una sola foto, flexslider igual imprime la lista
   de miniaturas con un único elemento: no aporta nada, fuera. */
.custom-figma-card .custom-figma-gallery .flex-control-thumbs:not(:has(li + li)) {
    display: none !important;
}

/* La fila beige de información tenía un separador vertical fijo en el primer
   elemento. Con un solo dato (lo normal desde que se quitaron varios "Serves")
   la línea quedaba colgando a la derecha de la caja. */
.custom-figma-card .custom-info-box:first-child:last-child {
    border-right: 0 !important;
}

@media (max-width: 767px) {
    .custom-figma-card .custom-figma-gallery .woocommerce-product-gallery__image {
        /* En móvil la tarjeta es una columna: 4/3 sigue siendo la proporción
           correcta, pero el marco puede ocupar todo el ancho. */
        aspect-ratio: 4 / 3 !important;
    }

    .custom-figma-card .custom-figma-gallery .flex-control-thumbs {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
}

/* ===========================================================================
   2. PRODUCTOS SIMILARES
   ---------------------------------------------------------------------------
   Clon deliberado de .tmc-card (widget-menu-custom.php): mismo borde, mismo
   radio, misma sombra, imagen al 40% a la izquierda, botón ámbar a la derecha.
   Se duplica en lugar de reutilizar porque el CSS de .tmc-card se imprime
   inline dentro del widget de Elementor y aquí no hay widget.
   =========================================================================== */

.ody-related {
    max-width: 1100px;
    margin: 0 auto 60px auto;
    padding: 0 20px;
    box-sizing: border-box;
    font-family: "Montserrat", "Poppins", sans-serif;
}

.ody-related-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 20px;
    border-bottom: 1px solid #eee;
    margin-bottom: 25px;
    padding-bottom: 10px;
}

.ody-related-title {
    font-size: 28px;
    font-weight: 900;
    color: #0d3b41;
    margin: 0;
    line-height: 1.2;
}

.ody-related-all {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    text-decoration: underline;
    text-underline-offset: 4px;
    white-space: nowrap;
    transition: color 160ms ease;
}

.ody-related-all:hover {
    color: #f39c12;
}

.ody-related-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .ody-related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.ody-related-card {
    display: flex;
    background: #fff;
    border: 1px solid #e1e8f0;
    border-radius: 8px;
    position: relative;
    height: 100%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 200ms ease;
}

.ody-related-img {
    flex: 0 0 40%;
    max-width: 40%;
    align-self: stretch;
    overflow: hidden;
    border-radius: 8px 0 0 8px;
    background: #f4f6f8;
}

.ody-related-img a {
    display: block;
    width: 100%;
    height: 100%;
}

.ody-related-img img {
    width: 100%;
    height: 100%;
    min-height: 200px;
    display: block;
    object-fit: cover;
    object-position: center;
    border-radius: 8px 0 0 8px;
    transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) and (pointer: fine) {
    .ody-related-card:hover {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
        transform: translateY(-3px);
    }

    .ody-related-card:hover .ody-related-img img {
        transform: scale(1.05);
    }
}

.ody-related-content {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.ody-related-info {
    flex-grow: 1;
}

/* El tema deja los h3 a 32px. Si el tamaño solo se baja en el <a>, el h3
   conserva un "strut" de 32px y la caja de línea sigue midiendo 36,8px: los
   títulos de dos líneas salían con un hueco enorme entre ellas. La clave es
   bajar el font-size en el propio h3 y que el enlace lo herede. */
/* La cadena larga de clases no es decorativa: hay una regla del tema con
   !important que gana a dos clases, así que hacen falta cuatro. Comprobado en
   el navegador (con dos clases el h3 se queda en 32px; con cuatro baja a
   17,6px y la caja de línea a 22px). */
.ody-related .ody-related-grid .ody-related-card .ody-related-name {
    margin: 0 0 8px 0;
    font-size: 1.1rem !important;
    line-height: 1.25 !important;
}

.ody-related .ody-related-grid .ody-related-card .ody-related-name a {
    font-size: inherit !important;
    line-height: inherit !important;
    font-weight: 900;
    color: #0d3b41;
    text-decoration: none;
    transition: color 160ms ease;
}

.ody-related-name a:hover {
    color: #f39c12;
}

.ody-related-price {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0d3b41;
    margin-bottom: 12px;
}

.ody-related-price .woocommerce-Price-currencySymbol {
    font-weight: normal;
    color: #777;
    margin-right: 2px;
}

.ody-related-desc {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 15px;
    line-height: 1.4;
}

.ody-related-action {
    display: flex;
    justify-content: flex-end;
    margin-top: auto;
    width: 100%;
    padding-top: 10px;
}

.ody-related-btn {
    background: #f2a632;
    color: #000;
    font-weight: 800;
    text-transform: uppercase;
    padding: 9px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    white-space: nowrap;
    display: inline-block;
    margin-left: auto;
    transition: background-color 200ms ease, transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.ody-related-btn:hover {
    background: #e0962b;
    color: #fff;
}

.ody-related-btn:active {
    transform: scale(0.97);
}

@media (max-width: 767px) {
    .ody-related {
        margin-bottom: 40px;
    }

    .ody-related-title {
        font-size: 22px;
    }

    .ody-related-card {
        flex-direction: column;
    }

    .ody-related-img {
        flex: none;
        max-width: 100%;
        height: 210px;
        border-radius: 8px 8px 0 0;
    }

    .ody-related-img img {
        height: 100%;
        min-height: 0;
        border-radius: 8px 8px 0 0;
    }

    .ody-related-action {
        justify-content: stretch;
    }

    .ody-related-btn {
        width: 100%;
        text-align: center;
    }
}
