/*
 * JETWHEELS — WoodMart 8.6.6
 * JW866-CATALOG-CARDS
 *
 * Compact catalog cards.
 * Desktop only.
 */

@media (min-width: 1025px) {

    /* JW866-CARDS-EQUAL-HEIGHT
       All products stretch to the height of their grid row.
    */
    body.tax-product_cat .wd-products .wd-product,
    body.post-type-archive-product .wd-products .wd-product {
        display: flex !important;
        flex-direction: column !important;
        align-self: stretch !important;
    }

    /* Высота карточек */
    body.tax-product_cat .wd-products .wd-product .product-wrapper,
    body.post-type-archive-product .wd-products .wd-product .product-wrapper {
        flex: 1 1 auto !important;
        height: auto !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box;
    }

    /* Убираем лишний отступ после фото */
    body.tax-product_cat .wd-products .wd-product .product-element-top,
    body.post-type-archive-product .wd-products .wd-product .product-element-top {
        flex: 0 0 240px !important;
        height: 240px !important;
        min-height: 0 !important;
        margin-bottom: 4px !important;
    }

    /* Компактный информационный блок */
    body.tax-product_cat .wd-products .wd-product .product-element-bottom,
    body.post-type-archive-product .wd-products .wd-product .product-element-bottom {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        padding-top: 0 !important;
    }

    /* Название товара */
    body.tax-product_cat .wd-products .wd-product .wd-entities-title,
    body.post-type-archive-product .wd-products .wd-product .wd-entities-title {
        margin-top: 0 !important;
        margin-bottom: 6px !important;
        line-height: 1.25 !important;
    }

    /* Последний блок удерживаем внизу карточки */
    body.tax-product_cat .wd-products .wd-product
    .product-element-bottom > :last-child,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-bottom > :last-child {
        margin-top: auto !important;
    }
}

/* JW866-SPARKA-SKU-LAYOUT
 * Desktop catalog cards.
 * Pair badge at the right side of the article area.
 */

@media (min-width: 1025px) {

    /* Anchor for the pair badge */
    body.tax-product_cat .wd-products .wd-product .product-element-bottom,
    body.post-type-archive-product .wd-products .wd-product .product-element-bottom {
        position: relative !important;
    }

    /* Move СПАРКА out of normal vertical flow */
    body.tax-product_cat .wd-products .wd-product .jw-wheel-pair-available-badge,
    body.post-type-archive-product .wd-products .wd-product .jw-wheel-pair-available-badge {
        position: absolute !important;
        right: 2px !important;
        bottom: 47px !important;
        margin: 0 !important;
        min-height: 20px !important;
        padding: 3px 9px !important;
        z-index: 2;
        white-space: nowrap;
    }

    /* More space around the product heading */
    body.tax-product_cat .wd-products .wd-product .wd-entities-title,
    body.post-type-archive-product .wd-products .wd-product .wd-entities-title {
        margin-top: 4px !important;
        margin-bottom: 10px !important;
        line-height: 1.3 !important;
    }

    /* Small breathing space after the image / split area */
    body.tax-product_cat .wd-products .wd-product .product-element-top,
    body.post-type-archive-product .wd-products .wd-product .product-element-top {
        margin-bottom: 8px !important;
    }
}

/* JW866-CARD-MIDDLE-GAPS
 * Compact spacing between title, specifications and SKU.
 * Do not change image size, Split widget or price footer.
 */
@media (min-width: 1025px) {

    body.tax-product_cat .wd-products .wd-product .product-element-bottom,
    body.post-type-archive-product .wd-products .wd-product .product-element-bottom {
        row-gap: 5px !important;
    }

    body.tax-product_cat .wd-products .wd-product
    .product-element-bottom > :not(:last-child),
    body.post-type-archive-product .wd-products .wd-product
    .product-element-bottom > :not(:last-child) {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    body.tax-product_cat .wd-products .wd-product .wd-entities-title,
    body.post-type-archive-product .wd-products .wd-product .wd-entities-title {
        margin-top: 0 !important;
        margin-bottom: 2px !important;
        line-height: 1.25 !important;
    }

    body.tax-product_cat .wd-products .wd-product
    .product-element-bottom > :last-child,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-bottom > :last-child {
        margin-top: auto !important;
    }
}

/* JW866-TITLE-TWO-LINES-SKU-GAP
 * Unified title height and article spacing.
 */
@media (min-width: 1025px) {

    /* Единая область под две строки названия */
    body.tax-product_cat .wd-products .wd-product .wd-entities-title,
    body.post-type-archive-product .wd-products .wd-product .wd-entities-title {
        position: relative !important;
        display: block !important;
        box-sizing: border-box !important;
        height: 2.5em !important;
        min-height: 2.5em !important;
        max-height: 2.5em !important;
        flex: 0 0 2.5em !important;
        line-height: 1.25 !important;
        margin-top: 0 !important;
        margin-bottom: 3px !important;
        overflow: hidden !important;
    }

    /* Однострочный текст по центру, двухстрочный занимает обе строки */
    body.tax-product_cat .wd-products .wd-product .wd-entities-title > a,
    body.post-type-archive-product .wd-products .wd-product .wd-entities-title > a {
        position: absolute !important;
        top: 50% !important;
        left: 0 !important;
        transform: translateY(-50%) !important;
        display: -webkit-box !important;
        -webkit-box-orient: vertical !important;
        -webkit-line-clamp: 2 !important;
        width: 100% !important;
        height: auto !important;
        max-height: 2.5em !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.25 !important;
        text-align: left !important;
        white-space: normal !important;
        overflow: hidden !important;
    }

    /* Артикул ниже параметров с реальным отступом */
    body.tax-product_cat .wd-products .wd-product
    .product-element-bottom > [class*="sku"],
    body.post-type-archive-product .wd-products .wd-product
    .product-element-bottom > [class*="sku"] {
        margin-top: 10px !important;
        margin-bottom: 2px !important;
        position: relative !important;
        top: 0 !important;
        translate: none !important;
    }

    /* СПАРКА остаётся справа на уровне строки артикула */
    body.tax-product_cat .wd-products .wd-product .jw-wheel-pair-available-badge,
    body.post-type-archive-product .wd-products .wd-product .jw-wheel-pair-available-badge {
        position: absolute !important;
        right: 2px !important;
        bottom: 47px !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }
}

/* =========================================================
   JW866-STAGGERED-SQUARE-BADGE
   Квадратный бейдж "Разноширокие диски"
========================================================= */

@media (min-width: 1025px) {

  body.tax-product_cat .wd-products .wd-product,
  body.post-type-archive-product .wd-products .wd-product {
    position: relative !important;
  }

  /* Сам бейдж СПАРКА */
  body.tax-product_cat .wd-products .wd-product .jw-wheel-pair-available-badge,
  body.post-type-archive-product .wd-products .wd-product .jw-wheel-pair-available-badge {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    z-index: 31 !important;

    display: block !important;
    width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 12px !important;

    background: #caff00 url('../img/jw-staggered-badge.svg') center/100% 100% no-repeat !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    text-indent: -9999px !important;
    overflow: visible !important;

    box-shadow: 0 6px 18px rgba(0,0,0,.18) !important;
    cursor: help !important;
    border: 0 !important;
  }

  /* Если есть FF-бейдж — ставим СПАРКУ ниже него */
  body.tax-product_cat .wd-products .wd-product:has(.jw-ff-trigger) .jw-wheel-pair-available-badge,
  body.post-type-archive-product .wd-products .wd-product:has(.jw-ff-trigger) .jw-wheel-pair-available-badge {
    top: 64px !important;
  }

  /* Hover tooltip */
  body.tax-product_cat .wd-products .wd-product .jw-wheel-pair-available-badge::after,
  body.post-type-archive-product .wd-products .wd-product .jw-wheel-pair-available-badge::after {
    content: "Разноширокие диски";
    position: absolute;
    right: 56px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;

    background: rgba(17,17,17,.96);
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: .01em;

    padding: 8px 10px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.22);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease, visibility .15s ease;
  }

  body.tax-product_cat .wd-products .wd-product .jw-wheel-pair-available-badge:hover::after,
  body.post-type-archive-product .wd-products .wd-product .jw-wheel-pair-available-badge:hover::after {
    opacity: 1;
    visibility: visible;
  }
}

@media (max-width: 1024px) {

  body.tax-product_cat .wd-products .wd-product .jw-wheel-pair-available-badge,
  body.post-type-archive-product .wd-products .wd-product .jw-wheel-pair-available-badge {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 31 !important;

    display: block !important;
    width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 10px !important;

    background: #caff00 url('../img/jw-staggered-badge.svg') center/100% 100% no-repeat !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    text-indent: -9999px !important;
    overflow: hidden !important;

    box-shadow: 0 5px 14px rgba(0,0,0,.18) !important;
    border: 0 !important;
  }

  body.tax-product_cat .wd-products .wd-product:has(.jw-ff-trigger) .jw-wheel-pair-available-badge,
  body.post-type-archive-product .wd-products .wd-product:has(.jw-ff-trigger) .jw-wheel-pair-available-badge {
    top: 54px !important;
  }

  /* На мобиле hover всё равно не нужен */
  body.tax-product_cat .wd-products .wd-product .jw-wheel-pair-available-badge::after,
  body.post-type-archive-product .wd-products .wd-product .jw-wheel-pair-available-badge::after {
    display: none !important;
  }
}

/* JW866-STAGGERED-BADGE-PHOTO-ANCHOR
   Badge is moved into the real photo container.
   No changes to card spacing or product information.
*/

body.tax-product_cat .wd-products .wd-product .product-element-top,
body.post-type-archive-product .wd-products .wd-product .product-element-top {
    position: relative !important;
}

/* Remove the previous experimental pseudo-badge */
body.tax-product_cat .wd-products .wd-product:has(.jw-wheel-pair-available-badge) .product-element-top::after,
body.post-type-archive-product .wd-products .wd-product:has(.jw-wheel-pair-available-badge) .product-element-top::after {
    content: none !important;
    display: none !important;
}

/* The actual badge, anchored to the photo */
body.tax-product_cat .wd-products .wd-product .product-element-top > .jw-wheel-pair-available-badge,
body.post-type-archive-product .wd-products .wd-product .product-element-top > .jw-wheel-pair-available-badge {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    clip-path: none !important;
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    z-index: 50 !important;
    overflow: visible !important;
}

/* When FF is present: stack with a small gap */
body.tax-product_cat .wd-products .wd-product:has(.jw-ff-trigger, .jw-flow-forming-badge, [class*="flow-forming-badge"]) .product-element-top > .jw-wheel-pair-available-badge,
body.post-type-archive-product .wd-products .wd-product:has(.jw-ff-trigger, .jw-flow-forming-badge, [class*="flow-forming-badge"]) .product-element-top > .jw-wheel-pair-available-badge {
    top: 58px !important;
}

/* JW866-STAGGERED-POPOVER */

/* Disable the old small tooltip */
body .wd-product .jw-wheel-pair-available-badge::before,
body .wd-product .jw-wheel-pair-available-badge::after {
    content: none !important;
    display: none !important;
}

#jw-staggered-popover {
    position: fixed;
    z-index: 2147483000;
    width: 310px;
    max-width: calc(100vw - 24px);
    padding: 20px;
    border: 1px solid #ededed;
    border-radius: 12px;
    background: #fff;
    color: #171717;
    font-family: inherit;
    box-shadow: 0 12px 35px rgba(0,0,0,.18);
    box-sizing: border-box;
    pointer-events: none;
}

#jw-staggered-popover[hidden] {
    display: none !important;
}

#jw-staggered-popover .jw-sp-title {
    font-size: 15px;
    line-height: 1.35;
    font-weight: 800;
    margin-bottom: 18px;
}

#jw-staggered-popover .jw-sp-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 15px;
}

#jw-staggered-popover .jw-sp-num {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 27px;
    width: 27px;
    height: 27px;
    background: #caff00;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
}

#jw-staggered-popover .jw-sp-name {
    font-size: 12px;
    line-height: 1.3;
    font-weight: 800;
}

#jw-staggered-popover .jw-sp-description {
    font-size: 12px;
    line-height: 1.4;
    color: #888;
    margin-top: 4px;
}

#jw-staggered-popover .jw-sp-note {
    margin-top: 16px;
    font-size: 12px;
    line-height: 1.4;
    color: #777;
}

/* JW866-DESKTOP-TITLE-INNER-HEIGHT-FIX
 * Real WoodMart/JETWHEELS markup:
 * h3.wd-entities-title.jw-min-card__title > a
 *
 * The title container reserves two lines.
 * The link itself must have natural text height.
 */
@media (min-width: 1025px) {

    body.tax-product_cat .wd-products .wd-product
    h3.wd-entities-title.jw-min-card__title,
    body.post-type-archive-product .wd-products .wd-product
    h3.wd-entities-title.jw-min-card__title {
        position: relative !important;
        display: block !important;
        height: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
        overflow: hidden !important;
    }

    body.tax-product_cat .wd-products .wd-product
    h3.wd-entities-title.jw-min-card__title > a,
    body.post-type-archive-product .wd-products .wd-product
    h3.wd-entities-title.jw-min-card__title > a {
        position: absolute !important;
        top: 50% !important;
        left: 0 !important;
        transform: translateY(-50%) !important;

        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: 44px !important;

        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.25 !important;
        white-space: normal !important;
        overflow: hidden !important;
    }
}

/* JW866-DESKTOP-CARD-WIDTH-AND-BADGE-ALIGN
 * Wider cards and aligned FF / staggered badges.
 */

/* Expand cards into the existing gaps */
@media (min-width: 1280px) {

    body.tax-product_cat .wd-products .wd-product .product-wrapper,
    body.post-type-archive-product .wd-products .wd-product .product-wrapper {
        margin-left: -6px !important;
        margin-right: -6px !important;
    }
}

/* Match the right edge of the Flow Forming badge */
@media (min-width: 1025px) {

    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-wheel-pair-available-badge,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-wheel-pair-available-badge {
        right: 0 !important;
        left: auto !important;
    }
}


/* JW866-REAL-BADGE-STACK
 * One shared container for both product badges.
 * No independent positioning coordinates.
 */
@media (min-width: 0px) {

    /* До объединения скрываем исходный значок,
       чтобы он не появлялся возле артикула. */
    body.tax-product_cat .wd-products .wd-product
    .product-element-top .jw-wheel-pair-available-badge,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top .jw-wheel-pair-available-badge {
        visibility: hidden !important;
    }

    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-ff-trigger,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-ff-trigger {
        visibility: hidden !important;
    }

    /* Единственная точка позиционирования */
    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-card-badges,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-card-badges {
        position: absolute !important;
        inset: 8px 8px auto auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 4px !important;
        width: 44px !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        z-index: 80 !important;
        pointer-events: none !important;
    }

    /* Оба значка имеют идентичную геометрию */
    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-ff-trigger,
    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-wheel-pair-available-badge,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-ff-trigger,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-wheel-pair-available-badge {
        position: static !important;
        inset: auto !important;
        transform: none !important;
        display: block !important;
        box-sizing: border-box !important;
        flex: 0 0 44px !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        max-width: 44px !important;
        max-height: 44px !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 9px !important;
        clip-path: none !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    /* Только внешний вид значка двух дисков */
    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-wheel-pair-available-badge,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-wheel-pair-available-badge {
        background: #caff00
          url('../img/jw-staggered-badge.svg')
          center / contain no-repeat !important;
        color: transparent !important;
        font-size: 0 !important;
        text-indent: -9999px !important;
        overflow: hidden !important;
    }

    /* Картинка FF заполняет свой квадрат */
    body .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-ff-trigger img {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }
}

@media (max-width: 767px) {

    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-card-badges,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-card-badges {
        inset: 6px 6px auto auto !important;
        width: 38px !important;
    }

    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-ff-trigger,
    body.tax-product_cat .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-wheel-pair-available-badge,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-ff-trigger,
    body.post-type-archive-product .wd-products .wd-product
    .product-element-top > .jw-card-badges > .jw-wheel-pair-available-badge {
        flex-basis: 38px !important;
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
        max-width: 38px !important;
        max-height: 38px !important;
    }
}

/* JW866-DESKTOP-DISKI-CLEANUP
 * Desktop category "Diski" only.
 * Hide duplicate category tiles and empty prefooter.
 */

@media (min-width: 1025px) {

    /* Дублирующие плитки Литые / Кованые */
    body.tax-product_cat.term-diski
    .wd-content-area > .wd-products-element:has(
        > .products > .category-grid-item.product-category
    ) {
        display: none !important;
    }

    /* Пустая белая полоса перед футером */
    body.tax-product_cat.term-diski .wd-prefooter {
        display: none !important;
    }

}
