/* Hallmark · component: section-head · genre: modern-minimal · theme: yoo-system
 * Cabeceras de grupo de categoría del shop (2026-06-29): contador en badge pill,
 * título sentence-case con acento de marca, "Ver todos" con flecha animada, chip
 * "activa". states: default · hover · focus-visible · active. contrast: pass.
 */
/**
 * Títulos de categoría/subcategoría del grid de la tienda + loader del infinite
 * scroll.
 *
 * FUENTE ÚNICA de estilo para los títulos que imprime yoo_render_category_title()
 * / yoo_render_subcategory_title() (yoo-extras/includes/infinite-scroll-handler.php),
 * usados por igual en el render inicial (archive-product.php) y en las páginas
 * cargadas por AJAX. Antes el estilo estaba triplicado (inline en la plantilla,
 * inline "activa", y aquí) con valores que no coincidían; ahora hay uno solo.
 *
 * Todos los colores/medidas vienen del Sistema de Diseño (yoo-extras/includes/
 * tokens.css, variables --yoo-*). Cada var lleva fallback al valor real por si
 * los tokens no cargaran. NO escribas hex/px sueltos aquí: usa los tokens.
 */

/* ====================================================================
 * Escala tipográfica de los titulares del grid (local, derivada de tokens).
 * Una sola relación de tamaños para que H2 (categoría) y H3 (subcategoría)
 * guarden proporción en vez de ser números sueltos.
 * ==================================================================== */
.woocommerce.main-products {
    --yoo-cat-title-size:    24px;  /* H2 categoría principal */
    --yoo-cat-count-size:    var(--yoo-font-size-lg, 18px);
    --yoo-subcat-title-size: 20px;  /* H3 subcategoría (un escalón por debajo del H2) */
    --yoo-subcat-count-size: var(--yoo-font-size-md, 15px);
    --yoo-cat-link-size:     var(--yoo-font-size-base, 14px);
}

/* ---- Item contenedor del título de categoría (li) ----
 * margin-top amplio: separa el título de la fila de productos de la categoría
 * anterior. margin-bottom corto: el título queda "pegado" a SU propia rejilla,
 * leyéndose como un único bloque (título + productos).
 */
.products li.yoo-category-title-item {
    grid-column: 1 / -1;
    list-style: none;
    width: 100%;
    margin: var(--yoo-space-10, 40px) 0 var(--yoo-space-4, 16px) 0;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
}

/* El primer título de la página no necesita el gran margen superior. */
.products li.yoo-category-title-item:first-child {
    margin-top: var(--yoo-space-2, 8px);
}

/* Item de subcategoría: separación intermedia (menor que entre categorías
 * principales, mayor que entre filas de productos). */
.products li.yoo-subcategory-title-item {
    grid-column: 1 / -1;
    list-style: none;
    width: 100%;
    margin: var(--yoo-space-8, 32px) 0 var(--yoo-space-3, 12px) 0;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
}

/* Quitar el "look" de tarjeta de producto (sombra/hover) que el tema aplica a
 * los <li> del grid. (Antes era un <style> inline en archive-product.php.) */
.products li.category-title-item:hover {
    box-shadow: none !important;
    transform: none !important;
}

/* ====================================================================
 * Barra del título de CATEGORÍA principal
 * Selector reforzado (.products li ... .yoo-category-section-title) para ganar
 * en especificidad/orden a cualquier estilo residual de la plantilla.
 * ==================================================================== */
.products li.yoo-category-title-item .yoo-category-section-title,
.yoo-subcategory-page-header .yoo-category-section-title {
    width: 100%;
    padding-bottom: var(--yoo-space-4, 16px);
    border: none;
    /* Línea base sutil bajo TODO el ancho + acento fuerte solo bajo el título
       (el acento se dibuja con un ::after sobre el h2, ver abajo). */
    box-shadow: inset 0 -1px 0 0 var(--yoo-color-line, #e9ecf1);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--yoo-space-4, 16px);
    background: none;
}

/* Enlace que envuelve el título: toda la zona del nombre dirige a la categoría.
   No subraya ni cambia el color del título; solo lo hace clicable. El acento de
   marca (::after) vive en el h2, así que se conserva. */
.yoo-cat-title-link {
    display: inline-block;
    text-decoration: none !important;
    color: inherit;
    border-radius: var(--yoo-radius-xs, 4px);
    transition: opacity var(--yoo-transition-base, .22s ease);
}
.yoo-cat-title-link:hover { opacity: .82; }
.yoo-cat-title-link:focus-visible {
    outline: 2px solid var(--yoo-color-primary, #125bc9);
    outline-offset: 3px;
}

.yoo-category-section-title h2 {
    margin: 0;
    position: relative;
    padding-bottom: var(--yoo-space-3, 12px);
    font-size: var(--yoo-cat-title-size, 24px);
    font-weight: var(--yoo-font-weight-bold, 700);
    color: var(--yoo-color-text, #1a1a1a);
    /* Sentence case real: el nombre llega ya capitalizado desde WordPress; no
       forzamos MAYÚSCULAS (menos agresivo, más editorial). */
    text-transform: none;
    letter-spacing: -0.01em;
    line-height: var(--yoo-line-height-tight, 1.2);
    display: inline-flex;
    align-items: center;
    gap: var(--yoo-space-3, 12px);
    flex-wrap: wrap;
}

/* Acento de marca: barra corta SOLO bajo el título, no en toda la fila. */
.yoo-category-section-title h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 100%;
    height: 3px;
    border-radius: var(--yoo-radius-pill, 999px);
    background: var(--yoo-color-primary, #125bc9);
}
.products li.yoo-category-title-item .yoo-category-section-title.is-active h2::after,
.yoo-subcategory-page-header .yoo-category-section-title.is-active h2::after {
    background: var(--yoo-color-accent, #ff6b35);
}

/* Contador (23) -> badge pill azul suave junto al título. */
.yoo-category-section-title .yoo-cat-count {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 var(--yoo-space-2, 8px);
    font-size: var(--yoo-font-size-sm, 13px);
    font-weight: var(--yoo-font-weight-semibold, 600);
    line-height: 1;
    color: var(--yoo-color-primary, #125bc9);
    background: var(--yoo-color-primary-soft, #eaf1fd);
    border-radius: var(--yoo-radius-pill, 999px);
    /* Las paréntesis del markup se ocultan visualmente (quedan para lectores
       de pantalla vía el contenido del span); mostramos solo el número. */
    font-variant-numeric: tabular-nums;
}
.products li.yoo-category-title-item .yoo-category-section-title.is-active .yoo-cat-count,
.yoo-subcategory-page-header .yoo-category-section-title.is-active .yoo-cat-count {
    color: var(--yoo-color-accent, #ff6b35);
    background: var(--yoo-color-accent-soft, #fff0eb);
}

/* Enlace "Ver todos en ..." (compartido por categoría y subcategoría) */
.yoo-category-section-title .yoo-cat-link,
.yoo-subcategory-section-title .yoo-cat-link {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: var(--yoo-space-1, 4px);
    font-size: var(--yoo-cat-link-size, 14px);
    color: var(--yoo-color-primary, #125bc9);
    text-decoration: none;
    font-weight: var(--yoo-font-weight-semibold, 600);
    text-transform: none;
    white-space: nowrap;
    flex-shrink: 0;
    /* El markup ya incluye la flecha "→" al final del texto; NO añadimos otra
       con ::after (eso duplicaría la flecha). Animamos el conjunto en hover. */
    transition: color var(--yoo-transition-base, .22s ease),
                transform var(--yoo-transition-base, .22s ease);
}
.yoo-category-section-title .yoo-cat-link:hover,
.yoo-subcategory-section-title .yoo-cat-link:hover,
.yoo-category-section-title .yoo-cat-link:focus-visible,
.yoo-subcategory-section-title .yoo-cat-link:focus-visible {
    color: var(--yoo-color-primary-hover, #0f4ea8);
    transform: translateX(3px);
}
.yoo-category-section-title .yoo-cat-link:focus-visible,
.yoo-subcategory-section-title .yoo-cat-link:focus-visible {
    outline: 2px solid var(--yoo-color-primary, #125bc9);
    outline-offset: 3px;
    border-radius: var(--yoo-radius-xs, 4px);
}

/* Indicador "Categoría activa" / "Subcategoría activa" -> chip naranja suave */
.yoo-active-indicator {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: var(--yoo-space-2, 8px);
    padding: var(--yoo-space-1, 4px) var(--yoo-space-3, 12px);
    font-size: var(--yoo-font-size-sm, 13px);
    color: var(--yoo-color-accent, #ff6b35);
    background: var(--yoo-color-accent-soft, #fff0eb);
    border-radius: var(--yoo-radius-pill, 999px);
    font-weight: var(--yoo-font-weight-semibold, 600);
    text-transform: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.yoo-active-indicator .yoo-active-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--yoo-color-accent, #ff6b35);
    border-radius: var(--yoo-radius-circle, 50%);
    /* pulso sutil de "activo", respeta reduced-motion (ver bloque al final). */
    animation: yoo-active-pulse 2.4s var(--yoo-ease-in-out, ease-in-out) infinite;
}

@keyframes yoo-active-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .55; transform: scale(.82); }
}
@media (prefers-reduced-motion: reduce) {
    .yoo-active-indicator .yoo-active-dot { animation: none; }
    .yoo-category-section-title .yoo-cat-link,
    .yoo-subcategory-section-title .yoo-cat-link { transition: color var(--yoo-transition-base, .22s ease); }
    .yoo-category-section-title .yoo-cat-link:hover,
    .yoo-subcategory-section-title .yoo-cat-link:hover { transform: none; }
}

/* ====================================================================
 * Barra del título de SUBCATEGORÍA (dentro del grid)
 * ==================================================================== */
.yoo-subcategory-section-title {
    width: 100%;
    padding-bottom: var(--yoo-space-3, 12px);
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 2px solid var(--yoo-color-line-strong, #d4d8e0);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--yoo-space-4, 16px);
    background: none;
}

.yoo-subcategory-section-title h3 {
    margin: 0;
    font-size: var(--yoo-subcat-title-size, 20px);
    font-weight: var(--yoo-font-weight-semibold, 600);
    color: var(--yoo-color-text-body, #333333);
    text-transform: uppercase;
    letter-spacing: 0.2px;
    line-height: var(--yoo-line-height-tight, 1.2);
    display: flex;
    align-items: baseline;
    gap: var(--yoo-space-2, 8px);
}

/* Marca "↳" delante del nombre de la subcategoría: refuerza la jerarquía. */
.yoo-subcategory-section-title .yoo-subcat-mark {
    color: var(--yoo-color-text-subtle, #8a8f98);
    font-weight: var(--yoo-font-weight-normal, 400);
}

.yoo-subcategory-section-title .yoo-cat-count {
    font-size: var(--yoo-subcat-count-size, 15px);
    color: var(--yoo-color-text-subtle, #8a8f98);
    font-weight: var(--yoo-font-weight-normal, 400);
    margin-left: var(--yoo-space-1, 4px);
}

/* ====================================================================
 * Cabecera de página cuando se navega DIRECTAMENTE a una subcategoría
 * (no es un título dentro del grid; va sobre la rejilla).
 * ==================================================================== */
.yoo-subcategory-page-header {
    width: 100%;
    margin-bottom: var(--yoo-space-8, 32px);
}

/* ---- Título de producto (el titular bajo cada caja) ----
 * Limpio, máximo 2 líneas con elipsis y altura reservada para que todas las
 * tarjetas de una fila queden alineadas aunque el nombre ocupe 1 o 2 líneas.
 * Scoped a la rejilla de la tienda para no afectar otras listas de producto.
 */
.woocommerce.main-products ul.products li.product .product-name {
    margin: var(--yoo-space-3, 12px) 0 0;
    font-size: var(--yoo-font-size-md, 15px);
    line-height: 1.35;
    font-weight: var(--yoo-font-weight-medium, 500);
}

.woocommerce.main-products ul.products li.product .product-name a {
    color: var(--yoo-color-text-body, #333333);
    transition: color var(--yoo-transition-base, .22s ease);
    /* Recorte a 2 líneas con elipsis (con fallback de altura fija). */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Reserva 2 líneas de alto para alinear las filas. */
    min-height: calc(1.35em * 2);
}

.woocommerce.main-products ul.products li.product .product-name a:hover {
    color: var(--yoo-color-primary, #125bc9);
}

/* ====================================================================
 * Marcadores invisibles que estructuran el grid
 * ==================================================================== */
.products li.yoo-subcategory-end-marker {
    display: none !important;
    height: 0;
    width: 0;
    margin: 0;
    padding: 0;
    border: none;
}

.products li.yoo-subcategory-separator {
    grid-column: 1 / -1;
    width: 100%;
    height: 1px;
    margin: var(--yoo-space-5, 20px) 0;
    padding: 0;
    border: none;
    background: transparent;
    list-style: none;
}

/* ====================================================================
 * Eliminar bordes/líneas del contenedor principal cuando hay categorías.
 * (Antes era un <style> inline al inicio de archive-product.php.)
 * ==================================================================== */
body.archive.woocommerce .main-products.products:before,
body.archive.woocommerce .main-products.products:after,
body.product-border-radius .woocommerce .main-products.products:before,
body.product-border-radius .woocommerce .main-products.products:after,
body.product-border-radius.ajax-pagination .woocommerce > .products:before,
body.product-border-radius.ajax-pagination .woocommerce > .products:after,
.woocommerce .main-products.products:after,
.ts-slider:not(.ts-product-category-wrapper) .products:after {
    display: none !important;
}

/* ====================================================================
 * Loader del infinite scroll + ocultar la paginación tradicional.
 * (Antes el spinner y estas reglas estaban inline en archive-product.php.)
 * ==================================================================== */
.yoo-infinite-scroll-loader {
    text-align: center;
    padding: var(--yoo-space-10, 40px) var(--yoo-space-5, 20px);
    clear: both;
    /* Colchón: mientras carga, reserva alto para que el sticky del sidebar
       no toque el fondo de su contenedor si el usuario baja muy deprisa
       (era el "sidebar descolocado hasta que recarga"). */
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.yoo-infinite-scroll-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--yoo-color-surface-3, #f5f6f8);
    border-top: 4px solid var(--yoo-color-primary, #125bc9);
    border-radius: var(--yoo-radius-circle, 50%);
    animation: yoo-infinite-spin 1s linear infinite;
}

.yoo-infinite-scroll-text {
    margin-top: var(--yoo-space-3, 12px);
    color: var(--yoo-color-text-muted, #6b7280);
    font-size: var(--yoo-font-size-lg, 18px);
}

@keyframes yoo-infinite-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ocultar la paginación tradicional: el infinite scroll la sustituye. */
.woocommerce-pagination {
    display: none !important;
}

/* ====================================================================
 * Responsive de las cabeceras de grupo: en móvil el "Ver todos" / chip
 * "activa" baja a su propia línea bajo el título (en vez de apretarse).
 * ==================================================================== */
@media (max-width: 575px) {
    .products li.yoo-category-title-item .yoo-category-section-title,
    .yoo-subcategory-page-header .yoo-category-section-title {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: var(--yoo-space-2, 8px) var(--yoo-space-3, 12px);
    }
    .yoo-category-section-title h2 {
        font-size: var(--yoo-font-size-xl, 20px);
        width: 100%;
    }
    .yoo-category-section-title .yoo-cat-link,
    .yoo-subcategory-section-title .yoo-cat-link,
    .yoo-active-indicator {
        align-self: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yoo-infinite-scroll-spinner {
        animation-duration: 0.001ms !important;
    }
    .yoo-category-section-title .yoo-cat-link,
    .yoo-subcategory-section-title .yoo-cat-link {
        transition: none !important;
    }
}

/* ====================================================================
 * Caja "Ver todo en X" (yoo_render_view_all_box).
 * Ocupa UNA casilla del grid (como un producto) pero es un enlace-botón a la
 * (sub)categoría. Mismo borde, radius (5px) y hover (sombra) que las fichas de
 * producto del tema. Fondo azul MUY tenue para distinguirse suavemente.
 * ==================================================================== */
.products li.product.yoo-view-all-box {
    list-style: none;
    display: flex;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}
.products li.product.yoo-view-all-box::before,
.products li.product.yoo-view-all-box::after {
    content: none !important;
}

.yoo-view-all-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    width: 100%;
    min-height: 220px;
    padding: 24px 18px;
    border-radius: var(--ts-border-radius, 5px);        /* mismo radius que el producto */
    background: #f4f8fd;                                 /* azulito muy tenue */
    /* Mismo borde que la ficha de producto del tema. */
    border: 1px solid var(--ts-border, #E5E5E5);
    color: var(--yoo-color-primary, #125bc9);
    text-decoration: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
/* Mismo hover que el producto: sombra suave y el radius se mantiene. */
.yoo-view-all-inner:hover,
.yoo-view-all-inner:focus-visible {
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
    border-radius: var(--ts-border-radius, 5px);
    outline: none;
}

.yoo-view-all-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--yoo-color-primary-soft, #eaf1fd);
    color: inherit;
    transition: transform 0.2s ease;
}
.yoo-view-all-inner:hover .yoo-view-all-icon,
.yoo-view-all-inner:focus-visible .yoo-view-all-icon {
    transform: translateX(3px);
}
.yoo-view-all-icon svg {
    width: 30px;
    height: 30px;
    stroke: currentColor;
}

.yoo-view-all-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.25;
}
.yoo-view-all-label {
    font-size: var(--yoo-font-size-base, 14px);
    font-weight: 600;
    opacity: 0.85;
}
.yoo-view-all-name {
    font-size: var(--yoo-font-size-lg, 18px);
    font-weight: 800;
}
.yoo-view-all-count {
    font-size: var(--yoo-font-size-sm, 12px);
    font-weight: 600;
    opacity: 0.75;
    margin-top: 2px;
}
