/*
 * TBY Wide Storefront V1
 * Every rule is gated by html.tby-wide-active. No mobile rule exists.
 */

.tby-wide-breadcrumb { display: none; }

@media (min-width: 768px) {
  html.tby-wide-active,
  html.tby-wide-active body {
    overflow-x: clip !important;
  }

  /* Header: transparent on home, glass everywhere else. */
  html.tby-wide-active body:not(.home) :is(.site-header, #site-header, header.header, .header-main, .ecomus-header) {
    background: rgba(248, 248, 246, .18) !important;
    -webkit-backdrop-filter: blur(22px) saturate(135%) !important;
    backdrop-filter: blur(22px) saturate(135%) !important;
    border-bottom: 1px solid rgba(0, 0, 0, .07);
    box-shadow: none !important;
  }

  html.tby-wide-active body.home :is(.site-header, #site-header, header.header, .header-main, .ecomus-header) {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }

  html.tby-wide-active :is(.site-header, #site-header, header.header, .header-main, .ecomus-header) {
    isolation: isolate;
    z-index: 1000 !important;
  }

  html.tby-wide-active :is(.site-header, #site-header, header.header, .header-main, .ecomus-header) a {
    pointer-events: auto !important;
    position: relative;
    z-index: 2;
  }

  html.tby-wide-active .tby-wide-nav-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -8px;
    height: 1px;
    background: currentColor;
  }

  /* Shop/category grids: reference algorithm—edge-to-edge equal tracks. */
  html.tby-wide-active body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag)
  :is(.site-content, #content, .content-area, .shop-content) {
    width: 100% !important;
    max-width: none !important;
    margin-inline: 0 !important;
    padding-inline: clamp(16px, 2.2vw, 44px) !important;
  }

  html.tby-wide-active body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag)
  :is(.widget-area, .shop-sidebar, .catalog-sidebar, aside.sidebar) {
    display: none !important;
  }

  html.tby-wide-active :is(
    ul.products,
    .products.grid,
    .products-grid,
    .ecomus-products-grid,
    .tby-wide-product-grid
  ) {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }

  html.tby-wide-active :is(
    ul.products,
    .products.grid,
    .products-grid,
    .ecomus-products-grid,
    .tby-wide-product-grid
  ) > :is(li.product, .product, .product-item) {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    height: clamp(610px, calc(100svh - 255px), 830px) !important;
    min-height: 610px !important;
    margin: 0 !important;
    padding: clamp(12px, 1.4vw, 28px) clamp(12px, 1.6vw, 30px) clamp(20px, 2vw, 36px) !important;
    position: relative;
    display: block !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    overflow: hidden;
  }

  /* Exact Ecomus card structure. The inner card—not the LI—owns the geometry. */
  html.tby-wide-active ul.products > li.product > .product-inner,
  html.tby-wide-active .products-grid > .product > .product-inner {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-rows: minmax(0, 1fr) auto !important;
    align-items: stretch !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html.tby-wide-active ul.products > li.product .product-thumbnail,
  html.tby-wide-active .products-grid > .product .product-thumbnail {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  html.tby-wide-active ul.products > li.product .product-thumbnail > .woocommerce-loop-product__link,
  html.tby-wide-active .products-grid > .product .product-thumbnail > .woocommerce-loop-product__link {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    overflow: hidden !important;
  }

  html.tby-wide-active ul.products > li.product .product-thumbnail > .woocommerce-loop-product__link img.tby-sfc-server-image,
  html.tby-wide-active .products-grid > .product .product-thumbnail > .woocommerce-loop-product__link img.tby-sfc-server-image {
    position: absolute !important;
    inset: 7% 7% 9% !important;
    width: 86% !important;
    height: 84% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: contain !important;
    object-position: center !important;
  }

  html.tby-wide-active ul.products > li.product .product-thumbnail > .woocommerce-loop-product__link img.tby-sfc-server-image + img,
  html.tby-wide-active .products-grid > .product .product-thumbnail > .woocommerce-loop-product__link img.tby-sfc-server-image + img {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  html.tby-wide-active ul.products > li.product .product-summary,
  html.tby-wide-active .products-grid > .product .product-summary {
    position: relative !important;
    width: 100% !important;
    min-height: 58px !important;
    margin: 0 !important;
    padding: 11px 0 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto !important;
    column-gap: 16px !important;
    align-items: start !important;
  }

  html.tby-wide-active ul.products > li.product .product-summary .woocommerce-loop-product__title,
  html.tby-wide-active .products-grid > .product .product-summary .woocommerce-loop-product__title {
    grid-column: 1 !important;
    grid-row: 1 !important;
    margin: 0 !important;
  }

  html.tby-wide-active ul.products > li.product .product-summary .tby-colour-count,
  html.tby-wide-active .products-grid > .product .product-summary .tby-colour-count {
    grid-column: 1 !important;
    grid-row: 2 !important;
    margin: 2px 0 0 !important;
  }

  html.tby-wide-active ul.products > li.product .product-summary > .price,
  html.tby-wide-active .products-grid > .product .product-summary > .price {
    grid-column: 2 !important;
    grid-row: 1 / span 2 !important;
    margin: 0 !important;
    text-align: right !important;
    align-self: start !important;
  }

  html.tby-wide-active ul.products > li.product.tby-wide-private-product,
  html.tby-wide-active .products-grid > .product.tby-wide-private-product {
    display: none !important;
  }

  /* Keep existing TBY sale badges and quick-add controls unmodified. */
  html.tby-wide-active :is(li.product, .product-item):hover {
    transform: none !important;
  }

  html.tby-wide-active :is(li.product, .product-item) :is(
    .woocommerce-loop-product__title,
    .product-title,
    .product-name
  ) {
    font-family: inherit;
    font-size: clamp(13px, .9vw, 16px) !important;
    font-weight: 600 !important;
    line-height: 1.25 !important;
    letter-spacing: 0 !important;
  }

  /* Recommendations use the same card geometry as the shop. */
  html.tby-wide-active :is(.related.products, .upsells.products, .tby-you-may-also-like, .you-may-also-like) {
    width: 100% !important;
    max-width: none !important;
    padding-inline: clamp(16px, 2.2vw, 44px) !important;
  }

  html.tby-wide-active :is(.related.products, .upsells.products, .tby-you-may-also-like, .you-may-also-like)
  :is(ul.products, .products-grid) > :is(li.product, .product-item) {
    height: clamp(570px, 68svh, 760px) !important;
    min-height: 570px !important;
  }

  /* Wide product page: retain the current columns/positions. */
  html.tby-wide-active body.single-product .tby-wide-breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0 0 28px;
    padding: 0 clamp(18px, 3.2vw, 64px);
    font-size: 14px;
    letter-spacing: .01em;
  }

  html.tby-wide-active body.single-product :is(
    .woocommerce-breadcrumb,
    .ecomus-breadcrumb,
    .site-breadcrumb,
    .breadcrumb
  ):not(.tby-wide-breadcrumb) {
    display: none !important;
  }

  html.tby-wide-active body.single-product :is(
    .flex-control-nav,
    .flex-control-paging,
    .swiper-pagination,
    .slick-dots,
    .flickity-page-dots,
    .tby-gallery-dots
  ) {
    display: none !important;
  }

  html.tby-wide-active body.single-product :is(
    .woocommerce-product-gallery,
    .tby-colour-gallery,
    .tby-product-gallery
  ) {
    overflow: hidden !important;
  }

  html.tby-wide-active body.single-product :is(
    .woocommerce-product-gallery__wrapper,
    .tby-colour-gallery__track,
    .tby-gallery-track
  ) {
    display: block !important;
    height: min(76svh, 920px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scroll-snap-type: y proximity;
    scrollbar-width: thin;
  }

  html.tby-wide-active body.single-product :is(
    .woocommerce-product-gallery__image,
    .tby-colour-gallery__slide,
    .tby-gallery-slide
  ) {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    min-width: 100% !important;
    height: min(72svh, 860px) !important;
    display: grid !important;
    place-items: center;
    scroll-snap-align: start;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
  }

  html.tby-wide-active body.single-product :is(
    .woocommerce-product-gallery__image,
    .tby-colour-gallery__slide,
    .tby-gallery-slide
  ) img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
  }

  html.tby-wide-active body.single-product:not(.tby-wide-colour-ready)
  :is(.tby-colour-swatches, .variable-items-wrapper, .tby-swatch-list) {
    opacity: 0 !important;
  }

  html.tby-wide-active body.single-product.tby-wide-colour-ready
  :is(.tby-colour-swatches, .variable-items-wrapper, .tby-swatch-list) {
    opacity: 1;
    transition: opacity .12s linear;
  }

  /* Homepage duplicate membership/sign-in block is suppressed only on wide screens. */
  html.tby-wide-active body.home .tby-wide-duplicate-account-cta {
    display: none !important;
  }

  /* Footer becomes a clean wide multi-column area without altering its content. */
  html.tby-wide-active footer.tby-wide-footer-ready .tby-wide-footer-groups {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(28px, 5vw, 90px);
    align-items: start;
  }
}

@media (min-width: 1024px) {
  html.tby-wide-active :is(
    ul.products,
    .products.grid,
    .products-grid,
    .ecomus-products-grid,
    .tby-wide-product-grid
  ) {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}
