/**
 * BeYou — layer 5: WooCommerce block styling.
 *
 * Selectors target WooCommerce's own block classes rather than replacing its
 * markup. Nothing here changes cart, checkout or stock behaviour.
 */

/* ==========================================================================
   Product grid
   ========================================================================== */

.beyou-product-grid .wc-block-product-template {
  display: grid;
  grid-template-columns: repeat(var(--by-grid-columns, 3), minmax(0, 1fr));
  gap: clamp(1rem, 2.4vw, 2rem) clamp(0.75rem, 1.8vw, 1.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.beyou-product-grid--4 {
  --by-grid-columns: 4;
}

.beyou-product-grid .wc-block-product {
  display: flex;
  margin: 0;
  padding: 0;
}

.beyou-product-card {
  display: flex;
  flex-direction: column;
  inline-size: 100%;
}

/* Product image */
.beyou-product-card .wp-block-woocommerce-product-image {
  position: relative;
  display: block;
  margin: 0 0 var(--by-space-3);
  overflow: hidden;
  /* Catalogue photography is square on a white ground; the panel matches it
     so the product is never cropped by the card. */
  background: var(--by-white);
  aspect-ratio: var(--by-ratio-product);
}

.beyou-product-card .wc-block-components-product-image__inner-container,
.beyou-product-card .wc-block-components-product-image a {
  display: block;
  block-size: 100%;
}

.beyou-product-card .wc-block-components-product-image img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
  transition: transform var(--by-motion-slow), opacity var(--by-motion-base);
}

.beyou-product-card:hover .wc-block-components-product-image img {
  transform: scale(1.045);
}

/* Card details */
.beyou-card-details {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--by-space-1);
}

.beyou-product-card .wp-block-post-title {
  margin: 0;
  font-family: var(--by-font-display);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.25;
}

.beyou-product-card .wp-block-post-title a:hover {
  color: var(--by-gold);
}

.beyou-product-card .wc-block-components-product-price {
  color: var(--by-ink-soft);
  font-family: var(--by-font-body);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}

.beyou-product-card .wc-block-components-product-price__value.is-discounted {
  color: var(--by-gold-ink);
}

.beyou-product-card del .wc-block-components-product-price__value,
.beyou-product-card .wc-block-components-product-price del {
  color: var(--by-muted);
  opacity: 0.7;
}

/* Add-to-cart button inside a card: quiet by default, present on hover/focus
   and always visible on touch devices. */
.beyou-product-card .wp-block-woocommerce-product-button {
  inline-size: 100%;
  margin-block-start: var(--by-space-3);
}

.beyou-product-card .wc-block-components-product-button__button {
  inline-size: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--by-ink);
  border-radius: var(--by-radius);
  background: transparent;
  color: var(--by-ink);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: var(--by-track-wide);
  text-transform: uppercase;
  transition: background var(--by-motion-base), color var(--by-motion-base),
    opacity var(--by-motion-base);
}

@media (hover: hover) and (min-width: 782px) {
  .beyou-product-card .wc-block-components-product-button__button {
    opacity: 0;
  }

  .beyou-product-card:hover .wc-block-components-product-button__button,
  .beyou-product-card:focus-within .wc-block-components-product-button__button {
    opacity: 1;
  }
}

.beyou-product-card .wc-block-components-product-button__button:hover {
  background: var(--by-ink);
  color: var(--by-ivory);
}

.beyou-product-card .wc-block-components-product-button__button.added,
.beyou-product-card .wc-block-components-product-button__button.loading {
  opacity: 1;
}

/* Sale badge */
.beyou-product-card .wc-block-components-product-sale-badge {
  position: absolute;
  inset-block-start: var(--by-space-3);
  inset-inline-end: var(--by-space-3);
  z-index: 2;
  padding: 0.3rem 0.6rem;
  border: 0;
  border-radius: 0;
  background: var(--by-ink);
  color: var(--by-ivory);
  font-size: 0.625rem;
  letter-spacing: var(--by-track-wide);
  text-transform: uppercase;
}

/* Out-of-stock treatment — inventory here is one-of-a-kind, so sold-out is a
   common and important state. */
.beyou-product-grid .outofstock .wc-block-components-product-image img {
  opacity: 0.55;
  filter: grayscale(0.2);
}

/* ==========================================================================
   Catalog toolbar, pagination, empty state
   ========================================================================== */

.beyou-catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--by-space-3);
  padding-block: var(--by-space-4);
  margin-block-end: var(--by-space-4);
  border-block-end: var(--by-hairline);
}

.beyou-catalog-count {
  color: var(--by-muted);
  font-size: 0.8125rem;
}

.wp-block-woocommerce-catalog-sorting select,
.beyou-catalog-toolbar select {
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  border: var(--by-hairline);
  border-radius: var(--by-radius);
  background-color: var(--by-surface-raised);
  color: var(--by-ink);
  font-family: var(--by-font-body);
  font-size: 0.8125rem;
}

.beyou-pagination-wrap {
  margin-block-start: var(--by-space-6);
  padding-block-start: var(--by-space-4);
  border-block-start: var(--by-hairline);
}

.beyou-pagination-wrap .wp-block-query-pagination {
  gap: var(--by-space-2);
  font-size: 0.875rem;
}

.beyou-pagination-wrap .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 38px;
  min-block-size: 38px;
  padding-inline: 0.5rem;
  border: 1px solid transparent;
  text-decoration: none;
}

.beyou-pagination-wrap .page-numbers:hover {
  border-color: var(--by-line);
}

.beyou-pagination-wrap .page-numbers.current {
  border-color: var(--by-ink);
  color: var(--by-ink);
}

.wp-block-woocommerce-product-collection-no-results {
  padding-block: var(--by-space-6);
  text-align: center;
  color: var(--by-muted);
}

/* ==========================================================================
   Store notices
   ========================================================================== */

.wc-block-components-notice-banner {
  border-radius: var(--by-radius);
  border-inline-start-width: 3px;
  font-size: 0.875rem;
}

.wc-block-components-notices {
  margin-block: var(--by-space-4);
}

/* ==========================================================================
   Single product
   ========================================================================== */

.beyou-product-page {
  padding-block: var(--by-space-5) var(--by-space-7);
}

.beyou-single-product-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(1.5rem, 5vw, 4.5rem);
  align-items: start;
}

.beyou-product-gallery-col {
  min-inline-size: 0;
}

.beyou-product-gallery-col .woocommerce-product-gallery {
  margin: 0;
}

.beyou-product-gallery-col .woocommerce-product-gallery__image img {
  inline-size: 100%;
  background: var(--by-surface-sunken);
}

.beyou-product-gallery-col .flex-control-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--by-space-2);
  margin-block-start: var(--by-space-2);
  padding: 0;
  list-style: none;
}

.beyou-product-gallery-col .flex-control-thumbs img {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--by-motion-fast);
}

.beyou-product-gallery-col .flex-control-thumbs img.flex-active,
.beyou-product-gallery-col .flex-control-thumbs img:hover {
  opacity: 1;
}

.beyou-product-summary-col {
  position: sticky;
  inset-block-start: calc(var(--by-header-height) + var(--by-space-4));
  min-inline-size: 0;
}

.beyou-product-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--by-space-3);
  margin-block-end: var(--by-space-3);
  color: var(--by-muted);
  font-size: 0.6875rem;
  letter-spacing: var(--by-track-wide);
  text-transform: uppercase;
}

.beyou-product-title {
  margin: 0 0 var(--by-space-3);
  font-size: clamp(1.875rem, 3.6vw, 2.75rem);
}

.beyou-product-price-wrap .wc-block-components-product-price,
.beyou-product-price .wc-block-components-product-price__value {
  font-family: var(--by-font-body);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.beyou-product-excerpt {
  max-inline-size: 52ch;
  margin-block: var(--by-space-4);
  color: var(--by-ink-soft);
}

.beyou-add-to-cart-box {
  padding-block: var(--by-space-4);
  border-block: var(--by-hairline);
}

.beyou-add-to-cart-box form.cart {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--by-space-3);
  margin: 0;
}

.beyou-add-to-cart-box .quantity {
  display: flex;
  align-items: stretch;
}

.beyou-add-to-cart-box .quantity input[type="number"],
.beyou-add-to-cart-box input.qty {
  inline-size: 84px;
  padding: 0.85rem 0.5rem;
  border: 1px solid var(--by-ink);
  border-radius: var(--by-radius);
  background: transparent;
  color: var(--by-ink);
  font-family: var(--by-font-body);
  font-size: 0.9375rem;
  text-align: center;
}

.beyou-add-to-cart-box button[type="submit"],
.beyou-add-to-cart-box .single_add_to_cart_button {
  flex: 1 1 200px;
  padding: 0.95rem 2rem;
  border: 1px solid var(--by-ink);
  border-radius: var(--by-radius);
  background: var(--by-ink);
  color: var(--by-ivory);
  cursor: pointer;
  font-family: var(--by-font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: var(--by-track-wide);
  text-transform: uppercase;
  transition: background var(--by-motion-base), color var(--by-motion-base),
    border-color var(--by-motion-base);
}

.beyou-add-to-cart-box button[type="submit"]:hover,
.beyou-add-to-cart-box .single_add_to_cart_button:hover {
  background: var(--by-gold);
  border-color: var(--by-gold);
  color: var(--by-white);
}

.beyou-add-to-cart-box .stock {
  flex-basis: 100%;
  margin: 0;
  color: var(--by-muted);
  font-size: 0.8125rem;
}

.beyou-add-to-cart-box .stock.out-of-stock {
  color: var(--by-ink);
}

.beyou-product-assurance {
  display: grid;
  gap: var(--by-space-3);
  margin-block-start: var(--by-space-4);
}

.beyou-passurance-row {
  display: flex;
  align-items: flex-start;
  gap: var(--by-space-3);
  font-size: 0.8125rem;
}

.beyou-passurance-row strong {
  display: block;
  font-weight: 600;
}

.beyou-passurance-row p {
  margin: 0;
  color: var(--by-muted);
}

.beyou-passurance-icon {
  inline-size: 16px;
  color: var(--by-gold-ink);
  flex: none;
  margin-block-start: 3px;
}

.beyou-related-section {
  margin-block-start: var(--by-space-8);
  padding-block-start: var(--by-space-6);
  border-block-start: var(--by-hairline);
}

/* ==========================================================================
   Cart and checkout (native WooCommerce blocks)
   ========================================================================== */

.beyou-standard-page .wp-block-woocommerce-cart,
.beyou-standard-page .wp-block-woocommerce-checkout {
  margin-block: var(--by-space-5);
}

.wc-block-components-title,
.wp-block-woocommerce-cart h2,
.wp-block-woocommerce-checkout h2 {
  font-family: var(--by-font-display);
  font-weight: 400;
}

.wc-block-components-product-name {
  font-family: var(--by-font-display);
  font-size: 1.0625rem;
}

.wc-block-components-button:not(.is-link) {
  border-radius: var(--by-radius);
  background: var(--by-ink);
  color: var(--by-ivory);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: var(--by-track-wide);
  text-transform: uppercase;
}

.wc-block-components-button:not(.is-link):hover {
  background: var(--by-gold);
  color: var(--by-white);
}

.wc-block-components-text-input input,
.wc-block-components-textarea,
.wc-block-components-combobox-control input {
  border-radius: var(--by-radius);
}

.wc-block-components-totals-item__value,
.wc-block-formatted-money-amount {
  font-family: var(--by-font-body);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  .beyou-single-product-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .beyou-product-summary-col {
    position: static;
  }
}

@media (max-width: 900px) {
  .beyou-product-grid .wc-block-product-template,
  .beyou-product-grid--4 {
    --by-grid-columns: 3;
  }
}

@media (max-width: 782px) {
  .beyou-product-grid .wc-block-product-template {
    --by-grid-columns: 2;
  }

  .beyou-product-card .wp-block-post-title {
    font-size: 1rem;
  }
}

@media (max-width: 400px) {
  .beyou-product-grid .wc-block-product-template {
    --by-grid-columns: 1;
  }
}
