/**
 * TiAuto TWT v1.2.4 - responsive WooCommerce category tiles.
 * Phones: red, unbordered category titles. Tablet/desktop (>=576px):
 * original red outline and red-fill/white-text hover treatment.
 * Scoped to three-column product-category tiles only.
 */

/* Shared title typography, without changing the product-card headings. */
:is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title {
  font-family: 'VanguardCF', sans-serif !important;
  font-weight: 700 !important;
  line-height: 1.05 !important;
  text-transform: uppercase;
  text-decoration: none !important;
  overflow-wrap: normal;
  word-break: normal;
}

/* Restore the ORIGINAL outlined title on tablets and desktop. The theme's
 * #home-category h2 hover scaled the heading and filled the red outline. */
@media (min-width: 576px) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title,
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title {
    display: inline-block !important;
    width: auto !important;
    max-width: 100%;
    min-width: 0;
    margin: 0 auto !important;
    padding: 5px clamp(10px, 1.7vw, 20px) 10px !important;
    border: 2px solid var(--twt-red, #d90016) !important;
    border-radius: .5rem !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--twt-red, #d90016) !important;
    font-size: 20px !important;
    text-align: center;
    transform: none !important;
    transition: background-color 1.2s ease, color 1.2s ease, border-color 1.2s ease, transform 1.2s ease !important;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category:hover .woocommerce-loop-category__title,
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category:hover .woocommerce-loop-category__title {
    background: var(--twt-red, #d90016) !important;
    color: #fff !important;
    border-color: var(--twt-red, #d90016) !important;
    transform: scale(1.09) !important;
  }
}

/* Phone only: large red title, no outline or pill, including on hover. */
@media (max-width: 575.98px) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title,
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title,
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category:hover .woocommerce-loop-category__title,
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category:hover .woocommerce-loop-category__title {
    display: block !important;
    width: 100% !important;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--twt-red, #d90016) !important;
    text-align: left !important;
    transform: none !important;
    transition: color 200ms ease !important;
  }
}

@media (min-width: 576px) and (prefers-reduced-motion: reduce) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title {
    transition: none !important;
  }
}

/* Keep focus feedback on the whole link, not around its title. */
:is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category > a:focus-visible {
  outline: 3px solid var(--twt-red, #d90016) !important;
  outline-offset: 3px;
}

/* Tablet and small laptop: retain EXACTLY THREE category columns. */
@media (min-width: 576px) and (max-width: 1199.98px) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3:has(> li.product-category) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: clamp(10px, 1.6vw, 20px);
    align-items: stretch;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category {
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    margin: 0 !important;
    padding: clamp(10px, 1.35vw, 17px) !important;
    box-sizing: border-box;
    background: #fff !important;
    background-image: none !important;
    border: 1px solid #ededed !important;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,.045);
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category > a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(8px, 1.1vw, 14px);
    width: 100%;
    height: 100%;
    min-width: 0;
    text-align: center;
    text-decoration: none;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category > a > img {
    display: block;
    width: min(100%, 220px) !important;
    max-width: 100% !important;
    max-height: clamp(105px, 17vw, 220px);
    height: auto !important;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    margin: 0 auto !important;
    border: 0 !important;
    border-radius: 0 !important;
    flex: 0 1 auto;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title,
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title {
    width: auto !important;
    font-size: clamp(17px, 2.2vw, 20px) !important;
    text-align: center;
    overflow-wrap: normal;
  }
}

/* Phone: horizontal editorial cards with spacious image and large clean title. */
@media (max-width: 575.98px) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3:has(> li.product-category) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px;
    margin: 0;
    padding: 0;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category {
    display: block;
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    height: auto;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    background-image: none !important;
    border: 1px solid #e9e9e9 !important;
    border-radius: 12px;
    box-shadow: 0 5px 18px rgba(0,0,0,.052);
    overflow: hidden;
    box-sizing: border-box;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category > a {
    display: grid;
    grid-template-columns: clamp(114px, 34vw, 160px) minmax(0, 1fr) 18px;
    align-items: center;
    gap: clamp(9px, 2.7vw, 18px);
    min-height: 153px;
    width: 100%;
    padding: 12px clamp(10px, 2.9vw, 18px) 12px 10px;
    box-sizing: border-box;
    color: #111;
    text-align: left;
    text-decoration: none;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category > a > img {
    display: block;
    width: 100% !important;
    max-width: 160px !important;
    max-height: 142px;
    height: auto !important;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title,
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title {
    width: 100% !important;
    font-size: clamp(34px, 9vw, 42px) !important;
    text-align: left !important;
    overflow-wrap: normal;
  }

  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category > a::after {
    content: '\203A';
    display: block;
    color: var(--twt-red, #d90016);
    font: 400 32px/1 Arial, sans-serif;
    text-align: right;
    transform: translateY(-1px);
    pointer-events: none;
  }
}

@media (max-width: 350px) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category > a {
    grid-template-columns: 97px minmax(0, 1fr) 15px;
    gap: 8px;
    min-height: 121px;
    padding: 9px 10px 9px 8px;
  }
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title,
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category .woocommerce-loop-category__title {
    font-size: 30px !important;
  }
}

/* Small interaction lift; no new layout, no changes to normal product tiles. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category {
    transition: box-shadow .26s ease, border-color .26s ease;
  }
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category:hover {
    box-shadow: 0 10px 24px rgba(0,0,0,.09);
    border-color: #dedede !important;
  }
  #home-category :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category:hover img {
    transform: scale(1.025);
    transition: transform .3s ease;
  }
}

/* Always visible, including in hidden WPBakery tabs, inline previews and
 * AJAX fragments. Start a cosmetic animation only on actual intersection;
 * never rely on a future JavaScript callback to make category links visible. */
@media (prefers-reduced-motion: no-preference) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category.twt-category-reveal.twt-category-visible {
    animation: twt-category-enter .58s cubic-bezier(.2,.65,.3,1) var(--twt-category-delay, 0ms) both;
  }
  @keyframes twt-category-enter {
    from { opacity: .75; transform: translate3d(0, 12px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
  }
}
@media (prefers-reduced-motion: reduce) {
  :is(.woocommerce, .woocommerce-page) ul.products.columns-3 > li.product-category {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
