/*
 * Las fichas siguen procediendo de content-product.php del tema. Este archivo
 * solo compone las cabeceras y el carrusel progresivamente mejorado.
 */
.thpb-home-blocks,
.thpb-home-blocks .thpb-section {
    width: 100%;
    background: transparent;
}

.thpb-home-blocks .thpb-section {
    margin: 0 0 clamp(2rem, 3.5vw, 3.15rem);
    padding: 0;
    scroll-margin-top: 7rem;
}

/* Separa de la franja anterior el primer bloque que realmente se renderiza. */
.thpb-home-blocks > .thpb-section:first-child {
    padding-top: clamp(1.25rem, 2vw, 1.75rem);
}

.thpb-home-blocks .thpb-section-inner {
    margin-inline: auto;
    background: transparent;
}

.thpb-home-blocks .thpb-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin: 0 0 clamp(.7rem, 1vw, .9rem);
    padding: 0;
}

.thpb-home-blocks .thpb-section-copy {
    max-width: 58rem;
}

.thpb-home-blocks .thpb-section-eyebrow {
    margin: 0 0 .45rem;
    color: #657b69;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .09em;
    line-height: 1.3;
    text-transform: uppercase;
}

.thpb-home-blocks .thpb-section-head h2 {
    margin: 0;
    font-size: clamp(1.75rem, 3.2vw, 2.75rem);
    line-height: 1.08;
}

.thpb-home-blocks .thpb-section-description {
    max-width: 52rem;
    margin: .5rem 0 0;
    line-height: 1.55;
}

.thpb-home-blocks .thpb-section-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: .65rem;
    min-width: 0;
}

.thpb-home-blocks .thpb-section-cta {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-height: 2.625rem;
    padding: .65rem 1rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    color: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.thpb-home-blocks .thpb-section-cta:hover {
    transform: translateY(-1px);
}

.thpb-home-blocks .thpb-section-cta:focus-visible,
.thpb-home-blocks .thpb-carousel-button:focus-visible,
.thpb-home-blocks .thpb-carousel-viewport:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

.thpb-carousel-controls {
    display: flex;
    justify-content: flex-end;
    gap: .55rem;
    margin: 0;
}

.thpb-carousel-controls[hidden] {
    display: none;
}

.thpb-carousel-status {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.thpb-carousel.has-load-error .thpb-carousel-status {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 0 .75rem !important;
    padding: .55rem .75rem !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    border: 1px solid rgba(176, 45, 45, .25) !important;
    border-radius: .6rem;
    background: #fff4f4;
    color: #8f2525;
    font-size: .84rem;
    line-height: 1.4;
}

.thpb-carousel-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.625rem;
    height: 2.625rem;
    padding: 0;
    border: 1px solid rgba(24, 45, 29, .26);
    border-radius: 999px;
    background: #fff;
    color: #253b2a;
    cursor: pointer;
    font: inherit;
    font-size: 1.2rem;
    line-height: 1;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    transition: border-color .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.thpb-carousel-button:hover:not(:disabled) {
    border-color: currentColor;
    box-shadow: 0 4px 14px rgba(24, 45, 29, .12);
}

.thpb-carousel-button:disabled {
    opacity: .35;
    cursor: default;
}

/* Sin JavaScript, WooCommerce conserva su cuadrícula completa habitual. */
.thpb-carousel.is-enhanced .thpb-carousel-viewport {
    overflow-x: auto;
    overflow-y: hidden;
    padding: .65rem .15rem .7rem;
    scroll-padding-inline: .15rem;
    scroll-snap-type: inline mandatory;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.thpb-carousel.is-enhanced .thpb-carousel-viewport::-webkit-scrollbar {
    display: none;
}

.thpb-carousel.is-enhanced .thpb-carousel-viewport > ul.products {
    display: grid !important;
    grid-auto-columns: calc((100% - 72px) / 4);
    grid-auto-flow: column;
    grid-template-columns: none !important;
    gap: 24px !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
}

.thpb-carousel.is-enhanced .thpb-carousel-viewport > ul.products::before,
.thpb-carousel.is-enhanced .thpb-carousel-viewport > ul.products::after {
    display: none !important;
    content: none !important;
}

.thpb-carousel.is-enhanced .thpb-carousel-viewport > ul.products > li.product {
    float: none !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    scroll-snap-align: start;
}

/*
 * Oculta solo las etiquetas visuales de categoría que pueda imprimir la
 * plantilla del tema; no altera taxonomías ni datos del producto.
 */
.thpb-home-blocks .woocommerce-loop-product__category,
.thpb-home-blocks .product-category,
.thpb-home-blocks .product-categories,
.thpb-home-blocks .product-cat,
.thpb-home-blocks .product-category-name,
.thpb-home-blocks .triwuu-product-card__category,
.thpb-home-blocks .triwuu-product-category,
.thpb-home-blocks .posted_in {
    display: none !important;
}

@media (max-width: 1024px) {
    .thpb-carousel.is-enhanced .thpb-carousel-viewport > ul.products {
        grid-auto-columns: calc((100% - 40px) / 3);
        gap: 20px !important;
    }
}

@media (max-width: 767px) {
    .thpb-home-blocks .thpb-section-head {
        align-items: flex-start;
        flex-direction: column;
        gap: .8rem;
        margin-bottom: .75rem;
    }

    .thpb-home-blocks .thpb-section-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: .55rem;
        width: 100%;
    }

    .thpb-home-blocks .thpb-section-cta {
        align-self: flex-start;
        min-width: 0;
        max-width: 100%;
        min-height: 2.5rem;
        padding: .58rem .85rem;
        font-size: .9rem;
        text-align: center;
        white-space: normal;
    }

    .thpb-home-blocks .thpb-carousel-button {
        width: 2.5rem;
        height: 2.5rem;
    }

    .thpb-home-blocks .thpb-section {
        margin-bottom: 1.8rem;
    }

    .thpb-home-blocks > .thpb-section:first-child {
        padding-top: 1.25rem;
    }

    .thpb-carousel.is-enhanced .thpb-carousel-viewport > ul.products {
        grid-auto-columns: calc((100% - 12px) / 2);
        gap: 12px !important;
    }
}

@media (max-width: 360px) {
    .thpb-home-blocks .thpb-section-actions {
        gap: .4rem;
    }

    .thpb-home-blocks .thpb-section-cta {
        padding-inline: .7rem;
        font-size: .82rem;
        overflow-wrap: anywhere;
    }

    .thpb-home-blocks .thpb-carousel-controls {
        gap: .35rem;
    }

    .thpb-home-blocks .thpb-carousel-button {
        width: 2.25rem;
        height: 2.25rem;
    }
}

/* TRIWUU_HOME_BUTTON_CONTAINMENT
 * En táctil no quedan estados hover desplazados ni sombras recortadas.
 */
@media (hover: none), (pointer: coarse) {
    .thpb-home-blocks .triwuu-product-card:hover,
    .thpb-home-blocks .triwuu-supermarket-card:hover {
        transform: none !important;
        box-shadow: 0 12px 30px rgba(17, 64, 49, .07) !important;
    }

    .thpb-home-blocks .thpb-section-cta:hover {
        transform: none;
    }

    .thpb-home-blocks .thpb-carousel-button:hover:not(:disabled) {
        box-shadow: none;
    }
}

/* TRIWUU_HOME_PRODUCT_CLARITY
 * La plantilla de producto procede del tema. Estas reglas se limitan al loop
 * de la Home para mantener el catálogo general intacto.
 */
.thpb-home-blocks .triwuu-supermarket-card .triwuu-product-card__media-wrap {
    padding: 8px 8px 0 !important;
}

.thpb-home-blocks .triwuu-supermarket-card .triwuu-product-card__media {
    padding: 8px !important;
}

.thpb-home-blocks .triwuu-product-card__media img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thpb-home-blocks .triwuu-product-card__title {
    display: -webkit-box !important;
    min-height: 2.5em !important;
    max-height: 2.5em;
    overflow: hidden;
    line-height: 1.25 !important;
    text-overflow: ellipsis;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* TRIWUU_HOME_PACK_COUNT_ALIGNMENT
 * El tema aporta el marcado semántico del contador. El bloque de Home fija
 * aquí una sola línea de alineación para que bolsa, cifra y etiqueta respiren
 * y compartan centro visual en todos los anchos del carrusel.
 */
.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count--enhanced {
    position: relative;
    display: grid !important;
    grid-template-columns: 24px max-content minmax(0, 1fr);
    align-items: center !important;
    align-content: center;
    column-gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 32px;
    margin: 0 0 .65rem !important;
    padding: 4px 0 !important;
    border: 0;
    background: transparent;
    color: #075b43 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    text-align: left !important;
    box-sizing: border-box;
}

.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count__icon {
    position: relative;
    display: block !important;
    align-self: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    margin: 0 !important;
    padding: 0;
    border: 1px solid rgba(0, 110, 85, .18);
    border-radius: 7px;
    background: #dcf4eb;
    color: #006e55;
    line-height: 0;
    box-sizing: border-box;
}

.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count__icon::before {
    position: absolute;
    top: 8px;
    left: 6px;
    width: 10px;
    height: 9px;
    border: 1.5px solid currentColor;
    border-radius: 2px 2px 4px 4px;
    content: "";
    box-sizing: content-box;
}

.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count__icon::after {
    position: absolute;
    top: 5px;
    left: 9px;
    width: 6px;
    height: 5px;
    border: 1.5px solid currentColor;
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
    content: "";
    box-sizing: content-box;
}

.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count__number,
.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count__label {
    display: inline-flex !important;
    align-items: center;
    align-self: stretch;
    min-width: 0;
    min-height: 24px;
    margin: 0 !important;
    padding: 0;
    border: 0;
    background: transparent;
    line-height: 1.15 !important;
    box-sizing: border-box;
}

.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count__number {
    color: #006e55;
    font-size: 14px;
    font-weight: 900;
}

.thpb-home-blocks .thpb-section-pack_products .triwuu-pack-loop-product-count__label {
    color: #3c5149;
    font-size: 13px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

/* Contrato compartido con content-product.php del tema. También aceptamos las
 * clases estándar de WooCommerce como fallback para futuras plantillas. */
.thpb-home-blocks .thpb-quantity-selector {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    width: 100%;
    min-width: 0;
    margin: 0 0 .7rem !important;
    box-sizing: border-box;
}

.thpb-home-blocks .thpb-quantity-selector .triwuu-card-quantity__label {
    flex: 0 0 auto;
}

.thpb-home-blocks .thpb-quantity-selector .triwuu-card-quantity__control,
.thpb-home-blocks .triwuu-product-card__quantity,
.thpb-home-blocks .triwuu-product-card .quantity {
    display: grid !important;
    grid-template-columns: 2.5rem minmax(3rem, 1fr) 2.5rem;
    align-items: stretch;
    flex: 0 1 11rem;
    width: min(100%, 11rem);
    min-width: 0;
    min-height: 2.5rem;
    margin: 0 !important;
    border: 1px solid rgba(0, 110, 85, .38);
    border-radius: 999px;
    background: #fff;
    box-sizing: border-box;
    overflow: hidden;
}

.thpb-home-blocks .thpb-quantity-selector button,
.thpb-home-blocks .triwuu-product-card__quantity button,
.thpb-home-blocks .triwuu-product-card .quantity button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 2.5rem;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #006e55;
    cursor: pointer;
    font: inherit;
    font-size: 1.15rem;
    font-weight: 850;
    line-height: 1;
    box-shadow: none;
    transform: none;
}

.thpb-home-blocks .thpb-quantity-selector button:hover:not(:disabled),
.thpb-home-blocks .triwuu-product-card__quantity button:hover:not(:disabled),
.thpb-home-blocks .triwuu-product-card .quantity button:hover:not(:disabled) {
    background: #e9f8f3;
    color: #005b48;
    transform: none;
}

.thpb-home-blocks .thpb-quantity-selector button:disabled,
.thpb-home-blocks .triwuu-product-card__quantity button:disabled,
.thpb-home-blocks .triwuu-product-card .quantity button:disabled {
    opacity: .35;
    cursor: default;
}

.thpb-home-blocks .thpb-quantity-selector input[type="number"],
.thpb-home-blocks .triwuu-product-card__quantity input[type="number"],
.thpb-home-blocks .triwuu-product-card .quantity input.qty {
    width: 100% !important;
    min-width: 0;
    height: 2.5rem !important;
    min-height: 2.5rem;
    margin: 0 !important;
    padding: 0 .25rem !important;
    border-width: 0 1px !important;
    border-style: solid !important;
    border-color: rgba(0, 110, 85, .2) !important;
    border-radius: 0 !important;
    background: #fff !important;
    color: #173d33 !important;
    font: inherit;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    box-shadow: none !important;
    box-sizing: border-box;
    appearance: textfield;
    -moz-appearance: textfield;
}

.thpb-home-blocks .thpb-quantity-selector input[type="number"]::-webkit-inner-spin-button,
.thpb-home-blocks .thpb-quantity-selector input[type="number"]::-webkit-outer-spin-button,
.thpb-home-blocks .triwuu-product-card__quantity input[type="number"]::-webkit-inner-spin-button,
.thpb-home-blocks .triwuu-product-card__quantity input[type="number"]::-webkit-outer-spin-button,
.thpb-home-blocks .triwuu-product-card .quantity input.qty::-webkit-inner-spin-button,
.thpb-home-blocks .triwuu-product-card .quantity input.qty::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
}

.thpb-home-blocks .thpb-quantity-selector button:focus-visible,
.thpb-home-blocks .thpb-quantity-selector input:focus-visible,
.thpb-home-blocks .triwuu-product-card__quantity button:focus-visible,
.thpb-home-blocks .triwuu-product-card__quantity input:focus-visible,
.thpb-home-blocks .triwuu-product-card .quantity button:focus-visible,
.thpb-home-blocks .triwuu-product-card .quantity input:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid #006e55;
    outline-offset: -3px;
}

@media (max-width: 520px) {
    .thpb-carousel.is-enhanced .thpb-carousel-viewport {
        max-width: 100%;
        overflow-y: hidden;
    }

    .thpb-carousel.is-enhanced .thpb-carousel-viewport > ul.products > li.product {
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .thpb-home-blocks .triwuu-supermarket-card .triwuu-product-card__media-wrap {
        padding: 7px 7px 0 !important;
    }

    .thpb-home-blocks .triwuu-supermarket-card .triwuu-product-card__media {
        aspect-ratio: 4 / 3 !important;
        padding: 7px !important;
    }

    .thpb-home-blocks .triwuu-product-card__title {
        min-height: 2.5em !important;
        max-height: 2.5em;
        font-size: 16px !important;
    }

    .thpb-home-blocks .thpb-quantity-selector {
        width: 100%;
    }

    .thpb-home-blocks .thpb-quantity-selector .triwuu-card-quantity__control,
    .thpb-home-blocks .triwuu-product-card__quantity,
    .thpb-home-blocks .triwuu-product-card .quantity {
        width: min(100%, 12rem);
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .thpb-home-blocks .thpb-quantity-selector {
        align-items: stretch;
        flex-direction: column;
        gap: .3rem;
    }

    .thpb-home-blocks .thpb-quantity-selector .triwuu-card-quantity__control,
    .thpb-home-blocks .triwuu-product-card__quantity,
    .thpb-home-blocks .triwuu-product-card .quantity {
        grid-template-columns: 2.25rem minmax(0, 1fr) 2.25rem;
        flex: 0 0 auto;
        width: 100%;
    }
}

@media (max-width: 360px) {
    .thpb-home-blocks .thpb-quantity-selector {
        align-items: stretch;
        flex-direction: column;
        gap: .25rem;
    }

    .thpb-home-blocks .thpb-quantity-selector .triwuu-card-quantity__control {
        flex: 0 0 auto;
        width: 100%;
    }
}

/* TRIWUU_HOME_MOBILE_IMAGE_QUALITY
 * Algunas imágenes importadas solo disponen de un original de 200 × 200 px.
 * En móvil no se amplían por encima de su tamaño natural: se centran dentro
 * de un marco más compacto y las imágenes grandes siguen reduciéndose con
 * normalidad. Escritorio conserva la presentación existente.
 */
@media (max-width: 767px) {
    .thpb-home-blocks .triwuu-supermarket-card .triwuu-product-card__media {
        display: grid !important;
        place-items: center !important;
        width: 100% !important;
        height: clamp(130px, 38vw, 170px) !important;
        aspect-ratio: auto !important;
        padding: clamp(10px, 3vw, 14px) !important;
        box-sizing: border-box !important;
    }

    .thpb-home-blocks .triwuu-supermarket-card .triwuu-product-card__media img {
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: auto !important;
        object-fit: contain !important;
        object-position: center center !important;
        place-self: center !important;
    }

    /* TRIWUU_HOME_PACK_MOBILE_IMAGE_BALANCE
     * El contenedor general heredaba un padding inferior cero. En los Carros
     * de ahorro de la Home se igualan los cuatro lados para que la imagen
     * respire lo mismo arriba y abajo, también en Safari móvil.
     */
    .thpb-home-blocks .thpb-section-pack_products .triwuu-supermarket-card .triwuu-product-card__media-wrap {
        padding: 7px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .thpb-home-blocks .thpb-section-cta,
    .thpb-home-blocks .thpb-carousel-button {
        transition: none;
    }
}
