/**
 * TWT responsive release 1.1.8
 * Adds a two-column mobile footer and a progressive-enhancement off-canvas
 * filter sidebar. No desktop layout or WooCommerce business rules are changed.
 */

/* Footer widgets must remain side by side on phones instead of col-12 stacks. */
@media (max-width: 991.98px) {
  .site-footer .footer-right-content > .row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem 0.85rem;
    margin: 0;
    padding: 0;
    align-items: start;
  }

  .site-footer .footer-right-content > .row > .twt-footer-column {
    box-sizing: border-box;
    width: auto !important;
    max-width: none;
    min-width: 0;
    flex: none;
    padding: 0 0.3rem;
    margin: 0 !important;
  }

  .site-footer .twt-footer-column .footer-widget {
    margin: 0;
    padding: 0;
    min-width: 0;
  }

  .site-footer .twt-footer-column .footer-widget-title {
    overflow-wrap: break-word;
    line-height: 1.18;
    margin-bottom: 0.75rem;
  }

  .site-footer .twt-footer-column a {
    overflow-wrap: anywhere;
  }

  .site-footer .footer-right-content,
  .site-footer .footer-left-content {
    box-sizing: border-box;
    max-width: 100vw;
  }
}

@media (min-width: 700px) and (max-width: 991.98px) {
  .site-footer .footer-right-content > .row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 1rem;
  }
}

/* No JavaScript: keep the native sidebar visible and usable. */
.twt-mobile-filters-bar,
.twt-mobile-filters-heading,
.twt-shop-filters-backdrop {
  display: none;
}

.twt-shop-archive .twt-shop-content {
  min-width: 0;
}

@media (max-width: 991.98px) {
  .twt-shop-archive.twt-filters-ready .twt-mobile-filters-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 0 0.85rem;
  }

  .twt-shop-archive .twt-mobile-filters-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    min-height: 44px;
    min-width: 120px;
    background: var(--twt-red, #d90016);
    color: #fff;
    border: 1px solid var(--twt-red, #d90016);
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.015em;
    box-shadow: none;
    text-transform: uppercase;
  }

  .twt-shop-archive .twt-mobile-filters-toggle:hover,
  .twt-shop-archive .twt-mobile-filters-toggle:focus-visible {
    background: #b60016;
    color: #fff;
  }

  .twt-shop-archive.twt-filters-ready .twt-shop-filters-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999990;
    background: rgba(0, 0, 0, 0.55);
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
  }

  .twt-shop-archive.twt-filters-ready.twt-filters-open .twt-shop-filters-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .twt-shop-archive.twt-filters-ready .twt-shop-sidebar {
    position: fixed !important;
    inset: 0 auto 0 0;
    z-index: 999991;
    box-sizing: border-box;
    width: min(390px, 89vw) !important;
    max-width: 89vw !important;
    height: 100vh;
    height: 100dvh;
    margin: 0 !important;
    padding: 0 0 1.25rem;
    background: #f7f7f7;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.18);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-103%);
    transition: transform 0.24s ease, visibility 0.24s ease;
    visibility: hidden;
    pointer-events: none;
  }

  .twt-shop-archive.twt-filters-ready.twt-filters-open .twt-shop-sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .twt-shop-archive.twt-filters-ready .twt-mobile-filters-heading {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #e5e5e5;
  }

  .twt-shop-archive .twt-mobile-filters-heading h2 {
    font-family: 'VanguardCF', sans-serif;
    font-size: 1.55rem;
    line-height: 1.2;
    margin: 0;
    color: #171717;
  }

  .twt-shop-archive .twt-mobile-filters-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #111;
    box-shadow: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    font-size: 2rem;
    line-height: 1;
  }

  .twt-shop-archive .twt-mobile-filters-close:hover {
    color: var(--twt-red, #d90016);
  }

  .twt-shop-archive .twt-mobile-filters-close:focus-visible,
  .twt-shop-archive .twt-mobile-filters-toggle:focus-visible {
    outline: 3px solid #171717;
    outline-offset: 2px;
  }

  .twt-shop-archive.twt-filters-ready .twt-shop-sidebar > .widget {
    margin: 0.9rem 0.8rem 0;
  }

  /* Avoid horizontal overflow from long options inside the scrollable drawer. */
  .twt-shop-archive .twt-shop-sidebar select,
  .twt-shop-archive .twt-shop-sidebar input,
  .twt-shop-archive .twt-shop-sidebar button {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .twt-shop-archive .twt-shop-sidebar,
  .twt-shop-archive .twt-shop-filters-backdrop {
    transition: none !important;
  }
}

/* v1.2.1: Keep the original red/grey two-piece price and quantity design.
 * These selectors only neutralise generic field/button styling introduced
 * elsewhere in the theme, keeping the native shape artwork and typography.
 */
.woocommerce.single-product div.product .single-tyre-price.bg-style,
.single-product .single-tyre-price.bg-style,
.woocommerce.single-product div.product .add-to-cart-tools,
.single-product .add-to-cart-tools {
  box-sizing: border-box;
}
.woocommerce.single-product div.product .single-tyre-quantity .twt-minus,
.woocommerce.single-product div.product .single-tyre-quantity .twt-plus,
.single-product .single-tyre-quantity .twt-minus,
.single-product .single-tyre-quantity .twt-plus {
  background: transparent !important;
  color: #000 !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
}
.woocommerce.single-product div.product .single-tyre-quantity .twt-qty-input,
.single-product .single-tyre-quantity .twt-qty-input {
  box-sizing: border-box;
  width: 50px;
  height: 56px;
  margin: 0;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.single-product .single-tyre-quantity .twt-qty-input::-webkit-inner-spin-button,
.single-product .single-tyre-quantity .twt-qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.single-product .single-tyre-quantity .twt-minus:disabled,
.single-product .single-tyre-quantity .twt-plus:disabled {
  opacity: 1 !important;
  cursor: default;
}
/* Keep the original grey wedge inside the padded content at tablet widths. */
@media (min-width: 768px) and (max-width: 991.98px) {
  .woocommerce.single-product div.product .summary { box-sizing: border-box; }
  .woocommerce.single-product div.product .single-tyre-quantity,
  .single-product .single-tyre-quantity { margin-right: 0; }
}

@media (max-width: 767px) {
  /* Preserve the original two-piece price/quantity art on small screens.
     Only size and spacing adapt; no replacement buttons or background. */
  .woocommerce.single-product div.product .single-tyre-price.bg-style,
  .single-product .single-tyre-price.bg-style {
    display: inline-block;
    width: 60%;
    min-width: 0;
    min-height: clamp(82px, 24vw, 100px);
    box-sizing: border-box;
    margin-left: 0;
    margin-bottom: 12px;
    padding: clamp(7px, 2vw, 12px) clamp(10px, 3vw, 18px);
    vertical-align: top;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
  }
  .woocommerce.single-product div.product .add-to-cart-tools,
  .single-product .add-to-cart-tools {
    display: block;
    float: right;
    width: 40%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  .woocommerce.single-product div.product .single-tyre-quantity,
  .single-product .single-tyre-quantity {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: clamp(82px, 24vw, 100px);
    height: auto;
    box-sizing: border-box;
    gap: clamp(1px, .5vw, 5px);
    margin: 0;
    padding: 0 5px 0 clamp(10px, 3vw, 18px);
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
  }
  .woocommerce.single-product div.product .single-tyre-quantity .twt-minus,
  .woocommerce.single-product div.product .single-tyre-quantity .twt-plus,
  .single-product .single-tyre-quantity .twt-minus,
  .single-product .single-tyre-quantity .twt-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 1 clamp(22px, 6.4vw, 32px);
    width: clamp(22px, 6.4vw, 32px);
    min-width: 0;
    height: clamp(36px, 11vw, 52px);
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    font-size: clamp(21px, 6.3vw, 28px) !important;
    line-height: 1 !important;
    text-decoration: none;
  }
  .woocommerce.single-product div.product .single-tyre-quantity .twt-qty-input,
  .single-product .single-tyre-quantity .twt-qty-input {
    display: block;
    flex: 0 1 clamp(28px, 9vw, 48px);
    width: clamp(28px, 9vw, 48px);
    min-width: 0;
    max-width: 48px;
    height: clamp(40px, 12vw, 56px);
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-align: center;
    font-size: clamp(24px, 7.5vw, 34px) !important;
    font-family: var(--wp--preset--font-family--vanguardcf), serif;
    font-weight: 700;
    line-height: 1;
    -moz-appearance: textfield;
    appearance: textfield;
  }
  .single-product .single-tyre-quantity .twt-qty-input::-webkit-inner-spin-button,
  .single-product .single-tyre-quantity .twt-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  /* A disabled minus at quantity 1 must remain visually identical to the
     original selector, even while clicks are blocked by quantity limits. */
  .single-product .single-tyre-quantity .twt-minus:disabled,
  .single-product .single-tyre-quantity .twt-plus:disabled {
    opacity: 1 !important;
    color: #000 !important;
    cursor: default;
  }
  .single-product .single-tyre-quantity button:focus-visible,
  .single-product .single-tyre-quantity input:focus-visible {
    outline: 2px solid var(--twt-red, #d90016) !important;
    outline-offset: 2px;
  }
  .single-product .single-tyre-price.bg-style span.per-item {
    font-size: clamp(13px, 4vw, 19px);
    line-height: 1;
  }
  .single-product .single-tyre-price.bg-style h2 {
    margin-top: -5px;
    line-height: 1;
  }
  .single-product .single-tyre-price.bg-style h2 span {
    font-size: clamp(27px, 7.5vw, 42px);
  }
  .single-product .single-tyre-price.bg-style h2 sup {
    font-size: clamp(14px, 4vw, 22px);
    top: -.45em;
  }
  .woocommerce.single-product div.product .summary { box-sizing: border-box; }
  .woocommerce.single-product div.product .summary,
  .woocommerce.single-product div.product .woocommerce-product-details__short-description { min-width: 0; overflow-wrap: break-word; }
  .woocommerce.single-product div.product .product_title { font-size: clamp(22px, 6.2vw, 32px); line-height: 1.18; }
  .woocommerce.single-product div.product .price_notices,
  .woocommerce.single-product div.product #instalmentCalc { font-size: 12px !important; line-height: 1.45; }
  /* Smaller description and finance text avoids collisions with badges. */
  .woocommerce ul.products > li.product .twt-card-title,
  .woocommerce ul.products > li.product .woocommerce-loop-product__title { font-size: clamp(14px, 3.8vw, 18px); line-height: 1.18; }
  .woocommerce ul.products > li.product #float_on_archive,
  .woocommerce ul.products > li.product .float_on_archive,
  .woocommerce ul.products > li.product .float-on-archive {
    font-size: clamp(10px, 2.8vw, 12px) !important;
    line-height: 1.35;
    white-space: normal !important;
    overflow-wrap: anywhere;
    max-width: 100%;
  }
  .woocommerce ul.products > li.product #float_on_archive img.float-logo,
  .woocommerce ul.products > li.product .float_on_archive img.float-logo { max-width: 32px !important; height: auto; }
  .woocommerce .woocommerce-result-count,
  .woocommerce .woocommerce-ordering { font-size: 12px; line-height: 1.4; }
  .site-footer .footer-left-content h2,
  .site-footer .footer-left-content h3,
  .site-footer .footer-left-content .widget-title,
  .site-footer .footer-left-content .footer-widget-title {
    font-size: clamp(19px, 4.4vw, 24px) !important;
    line-height: 1.15;
    overflow-wrap: break-word;
  }
  .site-footer .footer-left-content p,
  .site-footer .footer-left-content label,
  .site-footer .footer-right-content li,
  .site-footer .footer-right-content a { font-size: clamp(11px, 3.1vw, 13px); line-height: 1.5; }
  .site-footer .footer-right-content .footer-widget-title { font-size: clamp(18px, 4.5vw, 24px); }
}
