/**
 * Product page (wine sheet): adapts the WooCommerce markup the sheet keeps (gallery,
 * add-to-cart form, notices) to the UI kit, and neutralises the TheGem layout around it.
 * Loaded after toolkit.css on product pages only. Same rules as the kit: px, no !important.
 */

/* ---- TheGem layout: the sheet brings its own containers ---- */
/* TheGem wraps woocommerce_content() in .container > .panel.row > .panel-center.col-xs-12 */
.vp-product-page .block-content > .container {
  width: auto;
  max-width: none;
  padding-inline: 0;
}

.vp-product-page .block-content > .container > .panel {
  margin-inline: 0;
}

.vp-product-page .block-content > .container > .panel > .panel-center {
  float: none;
  width: auto;
  padding-inline: 0;
}

/* ---- Typography: TheGem element rules (h1, p, ul margins) outrank the kit :where(.vp-base) base ---- */
/* Doubled class: beats TheGem element and .single-product rules without !important */
.vp-product-sheet.vp-product-sheet :is(h1, h2, h3, p, dl, ol, form) {
  margin-block: 0;
}

.vp-product__title.vp-product__title {
  color: var(--vp-color-heading);
  font-family: var(--vp-font-heading);
  font-size: var(--vp-fs-3xl); /* UI kit h1 (components.css: --fs-3xl) */
  font-weight: 700;
  letter-spacing: normal;
  line-height: 1.15;
  text-transform: none;
}

/* ---- Add-to-cart form (WooCommerce core template) styled as the kit form ---- */
.vp-product__buy {
  display: block;
  width: 100%;
}

.vp-product__buy form.cart {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--vp-space-3);
}

/* Quantity: kit field with a visible label (WooCommerce prints it for screen readers only).
   TheGem forces .screen-reader-text { position: absolute !important }: the label stays absolute,
   pinned to the top of the field wrapper, which reserves its line height. */
.vp-product__buy form.cart .quantity {
  --vp-qty-label-height: calc(var(--vp-fs-sm) * 1.5);
  position: relative;
  float: none;
  width: 96px;
  margin: 0;
  padding-top: calc(var(--vp-qty-label-height) + var(--vp-space-1));
}

.vp-product__buy form.cart .quantity .screen-reader-text {
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  color: var(--vp-color-text);
  font-size: var(--vp-fs-sm);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.vp-product__buy form.cart .quantity .qty {
  width: 100%;
  height: var(--vp-control-height-lg);
  line-height: 1.2;
  margin: 0;
  padding: var(--vp-space-2) var(--vp-space-3);
  border: var(--vp-border-width) solid var(--vp-color-border);
  border-radius: var(--vp-radius-sm);
  background: var(--vp-white);
  color: var(--vp-rich-mahogany);
  font-family: var(--vp-font-body);
  font-size: var(--vp-fs-base);
  text-align: start;
}

/* Kit button, large size (.vp-button.vp-button--lg) */
.vp-product__buy .cart .single_add_to_cart_button.single_add_to_cart_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--vp-space-2);
  min-height: var(--vp-control-height-lg);
  margin: 0;
  padding: var(--vp-space-2) var(--vp-space-8);
  border: var(--vp-border-width) solid transparent;
  border-radius: var(--vp-radius-sm);
  background: var(--vp-color-action-primary);
  color: var(--vp-color-on-primary);
  cursor: pointer;
  font-family: var(--vp-font-body);
  font-size: var(--vp-fs-lg);
  font-weight: 600;
  letter-spacing: normal;
  line-height: 1.2;
  text-transform: none;
  transition:
    background-color var(--vp-duration-fast) var(--vp-easing),
    color var(--vp-duration-fast) var(--vp-easing);
}

.vp-product__buy .cart .single_add_to_cart_button.single_add_to_cart_button:hover {
  background: var(--vp-color-action-primary-hover);
  color: var(--vp-color-on-primary-hover);
}

.vp-product__buy .cart .single_add_to_cart_button.single_add_to_cart_button:focus-visible {
  outline: var(--vp-focus-width) solid var(--vp-color-focus);
  outline-offset: 2px;
}

/* Cart icon of the kit button, drawn in CSS: the button markup is WooCommerce's (Lucide shopping-cart) */
.vp-product__buy .single_add_to_cart_button::before {
  content: "";
  width: var(--vp-icon-md);
  height: var(--vp-icon-md);
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='21' r='1'/%3E%3Ccircle cx='19' cy='21' r='1'/%3E%3Cpath d='M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---- Stock line: out of stock is not a success ---- */
.vp-product__stock--out {
  color: var(--vp-color-error);
}

/* ---- Gallery (WooCommerce core: flexslider, zoom, photoswipe) inside the kit gallery box ---- */
/* Full width: in the centring grid the slider would size itself from its 400% wide track */
.vp-product__gallery .woocommerce-product-gallery {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0;
  float: none;
}

.vp-product__gallery .woocommerce-product-gallery__image img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  margin-inline: auto;
  filter: drop-shadow(0 12px 18px rgb(44 7 3 / 0.25));
}

.vp-product__gallery .flex-control-thumbs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--vp-space-2);
  margin: var(--vp-space-4) 0 0;
  padding: 0;
  list-style: none;
}

.vp-product__gallery .flex-control-thumbs li {
  width: 64px;
  margin: 0;
  padding: 0;
}

.vp-product__gallery .flex-control-thumbs img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--vp-radius-sm);
  cursor: pointer;
  opacity: 0.6;
}

.vp-product__gallery .flex-control-thumbs img.flex-active,
.vp-product__gallery .flex-control-thumbs img:hover {
  opacity: 1;
}

/* Lightbox trigger (WooCommerce prints an emoji magnifier) */
.vp-product__gallery .woocommerce-product-gallery__trigger {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: var(--vp-control-height);
  height: var(--vp-control-height);
  border-radius: 50%;
  background: var(--vp-white);
  box-shadow: var(--vp-shadow-sm);
  text-decoration: none;
}

/* ---- Accordion panels: client HTML (ACF WYSIWYG or TheGem description) ---- */
/* TheGem sizes p and li in the content area; the panel keeps the kit body text. Doubled class: no !important */
.vp-accordion__panel.vp-accordion__panel :is(p, li, span, strong, u) {
  font-size: inherit;
  line-height: inherit;
}

.vp-accordion__panel.vp-accordion__panel > * + * {
  margin-block-start: var(--vp-space-3);
}

.vp-accordion__panel.vp-accordion__panel ul {
  margin-block: 0;
}

/* Sold individually: WooCommerce prints a hidden quantity input, the visible label would be orphaned */
.vp-product__buy form.cart .quantity:has(input[type="hidden"]) {
  display: none;
}

/* ---- Headings: TheGem letter-spacing and sizes outrank the kit :where(.vp-base) base ---- */
.vp-product-sheet.vp-product-sheet :is(h1, h2, h3) {
  letter-spacing: normal;
  text-transform: none;
}

.vp-product-sheet.vp-product-sheet .vp-section__header h2 {
  color: var(--vp-color-heading);
  font-family: var(--vp-font-heading);
  font-size: var(--vp-fs-2xl); /* UI kit h2 (components.css: --fs-2xl) */
  font-weight: 700;
  line-height: 1.2;
}

/* ---- WooCommerce notices (TheGem templates) as kit alerts (.vp-alert) ---- */
.vp-product-sheet .woocommerce-notices-wrapper:not(:empty) {
  margin-block-end: var(--vp-space-6);
}

.vp-product-sheet.vp-product-sheet :is(.woocommerce-message, .woocommerce-info, .woocommerce-error) {
  --vp-alert-color: var(--vp-color-info);
  display: block;
  margin: 0 0 var(--vp-space-3);
  padding: var(--vp-space-4);
  border: 1px solid var(--vp-alert-color);
  border-inline-start-width: 4px;
  border-radius: var(--vp-radius-md);
  background: var(--vp-color-bg);
  color: var(--vp-color-text);
  font-size: var(--vp-fs-base);
  list-style: none;
}

/* Success (add to cart): solid almond-silk surface, no border; the icon keeps the success colour */
.vp-product-sheet.vp-product-sheet .woocommerce-message {
  --vp-alert-color: var(--vp-color-success);
  border-color: transparent;
  background: var(--vp-color-surface);
}

.vp-product-sheet.vp-product-sheet .woocommerce-error {
  --vp-alert-color: var(--vp-color-error);
}

/* TheGem forces a 65px left padding (!important) for its icon font glyph:
   that space holds the kit alert icon instead (Lucide circle-check / circle-alert) */
.vp-product-sheet.vp-product-sheet :is(.woocommerce-message, .woocommerce-info, .woocommerce-error) {
  position: relative;
  box-shadow: none;
}

.vp-product-sheet.vp-product-sheet :is(.woocommerce-message, .woocommerce-info, .woocommerce-error)::before {
  content: "";
  position: absolute;
  top: 50%;
  left: var(--vp-space-6);
  width: var(--vp-icon-md);
  height: var(--vp-icon-md);
  margin: 0;
  border-radius: 0;
  /* TheGem forces background-color: transparent !important here: an inset shadow paints the masked icon */
  box-shadow: inset 0 0 0 var(--vp-icon-md) var(--vp-alert-color);
  transform: translateY(-50%);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4'/%3E%3Cpath d='M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

.vp-product-sheet.vp-product-sheet .woocommerce-message::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E");
}

/* Add-to-cart confirmation: text then the "View cart" link as a kit primary button.
   TheGem lays it out as a table (.woocommerce-message .cart-added): one more class wins */
.vp-product-sheet .woocommerce-message .cart-added {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--vp-space-3);
}

.vp-product-sheet.vp-product-sheet .cart-added-button .button {
  display: inline-flex;
  align-items: center;
  min-height: var(--vp-control-height);
  margin: 0;
  padding: var(--vp-space-2) var(--vp-space-6);
  border: var(--vp-border-width) solid transparent;
  border-radius: var(--vp-radius-sm);
  background: var(--vp-color-action-primary);
  color: var(--vp-color-on-primary);
  font-family: var(--vp-font-body);
  font-size: var(--vp-fs-base);
  font-weight: 600;
  letter-spacing: normal;
  line-height: 1.2;
  text-decoration: none;
  text-transform: none;
}

.vp-product-sheet.vp-product-sheet .cart-added-button .button:hover {
  background: var(--vp-color-action-primary-hover);
  color: var(--vp-color-on-primary-hover);
}

.vp-product-sheet .woocommerce-message .cart-added :is(.cart-added-text, .cart-added-button) {
  display: block;
  width: auto;
  padding: 0;
}

/* TheGem icon font arrow after the link */
.vp-product-sheet.vp-product-sheet .cart-added-button .button::after {
  content: none;
}

/* ---- Focus: TheGem's reset (a:focus { outline: 0 none }) outranks the kit :where(.vp-base) :focus-visible ---- */
.vp-product-sheet.vp-product-sheet :is(a, button, input):focus-visible {
  outline: var(--vp-focus-width) solid var(--vp-color-focus);
  outline-offset: 2px;
}

/* Active gallery thumbnail: a border too, not only the opacity change */
.vp-product__gallery .flex-control-thumbs img.flex-active {
  outline: 2px solid var(--vp-color-link);
  outline-offset: 2px;
}

/* ---- Top bar: notices (full width), breadcrumb, previous / next wine ---- */
.vp-product-sheet__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--vp-space-3) var(--vp-space-6);
}

.vp-product-sheet__top > .woocommerce-notices-wrapper {
  flex-basis: 100%;
}

.vp-product-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--vp-space-3);
}

/* Doubled class: TheGem colours links on hover */
.vp-product-nav__link.vp-product-nav__link {
  min-height: var(--vp-control-height);
  padding-inline: var(--vp-space-4);
  font-size: var(--vp-fs-sm);
  text-decoration: none;
}

.vp-product-nav__link.vp-product-nav__link:hover {
  color: var(--vp-color-on-primary);
}
