/* ==========================================================================
   Halfmoon — product.css (single product + TC Extra Product Options)
   TC EPO's own stylesheet still loads; rules here are scoped under
   .single-product so they win without !important where possible.
   ========================================================================== */

.single-product .wc-main {
  padding: var(--space-6) 0 var(--space-9);
}
.single-product div.product {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
}

/* ---------- Image ---------- */
.woocommerce-product-gallery {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  margin: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-2);
  opacity: 1 !important; /* Woo fades it in with JS we don't load */
}
.woocommerce-product-gallery__wrapper {
  margin: 0;
}
.woocommerce-product-gallery__image a {
  pointer-events: none;
}
.woocommerce-product-gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
.woocommerce-product-gallery .flex-control-thumbs,
.woocommerce-product-gallery__trigger {
  display: none;
}

/* ---------- Summary ---------- */
.summary {
  min-width: 0;
}
.product-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: var(--space-3);
}
.product-crumb a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.product-crumb a:hover {
  color: var(--red-600);
}
.product_title {
  font-size: var(--text-4xl);
  font-weight: 800;
  letter-spacing: -0.025em;
}
.summary > .price {
  display: block;
  margin: var(--space-3) 0 var(--space-4);
  font-size: var(--text-xl);
  color: var(--red-600);
}
.summary > .price del {
  color: var(--ink-300);
  font-size: 0.75em;
  margin-right: 6px;
}
.summary > .price ins {
  text-decoration: none;
}
.woocommerce-product-details__short-description {
  color: var(--ink-700);
  font-size: var(--text-lg);
  margin-bottom: var(--space-5);
}
.woocommerce-product-details__short-description p {
  margin: 0;
}
.summary .stock {
  font-weight: 600;
}
.summary .out-of-stock {
  color: var(--red-700);
}
.product-description {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
}

/* ---------- Woo variations (products without TC EPO) ---------- */
table.variations {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}
table.variations th,
table.variations td {
  display: block;
  padding: 0;
  text-align: left;
}
table.variations th label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
}
.variation-select.is-enhanced {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.variation-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
/* TC EPO renders its own size picker on these products */
.tm-has-styled-variations .variation-pills {
  display: none;
}
.reset_variations {
  display: inline-block;
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-decoration: underline;
}

/* Shared chip look: our pills + every TC EPO choice */
.pill {
  position: relative;
  cursor: pointer;
  margin: 0;
}
.pill input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.pill-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 96px;
  padding: 12px 16px;
  border: 1.5px solid var(--ink-200);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink-900);
  font-weight: 600;
  line-height: 1.2;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.pill-price {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-muted);
}
.pill:hover .pill-body {
  border-color: var(--ink-500);
}
.pill input:checked + .pill-body {
  border-color: var(--red-600);
  background: var(--red-50);
}
.pill input:checked + .pill-body .pill-price {
  color: var(--red-700);
}
.pill input:focus-visible + .pill-body {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}
.pill.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- TC Extra Product Options ---------- */
.single-product .tc-extra-product-options {
  margin: 0 0 var(--space-5);
}
.single-product .tm-extra-product-options-fields,
.single-product .tmcp-ul-wrap {
  list-style: none;
  margin: 0;
  padding: 0;
}
.single-product .tc-extra-product-options .tc-row,
.single-product .tc-extra-product-options .tc-container {
  margin: 0;
}
.single-product .cpf-section + .cpf-section,
.single-product .cpf-element + .cpf-element {
  margin-top: var(--space-5);
}
/* Element headings ("Crust", "Base", "Extra toppings") */
.single-product .tc-epo-label.tm-epo-element-label {
  display: flex;
  justify-content: flex-start;
  text-align: left;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--space-3);
  padding: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink-900);
  line-height: 1.2;
}
.single-product .tm-epo-required {
  order: 2;
  color: var(--red-600);
  float: none;
}
.single-product .tm-element-description {
  margin: -6px 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.single-product .tmcp-ul-wrap.tc-text-container,
.single-product .tm-extra-product-options-variations,
.single-product .tm-element-ul-radio,
.single-product .tm-element-ul-checkbox {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.single-product .tmcp-field-wrap {
  margin: 0;
  padding: 0;
  width: auto;
  flex: none;
  border: 0;
}
.single-product .tmcp-field-wrap-inner,
.single-product .tc-field-label-wrap,
.single-product .tc-epo-text-label-wrapper,
.single-product .tc-label-wrap {
  display: block;
  margin: 0;
  padding: 0;
  width: auto;
}
/* Separators inside a checkbox group ("Veg", "Non-Veg", "Cheese") */
.single-product .tmcp-field-wrap.is-separator {
  flex-basis: 100%;
  margin-top: var(--space-2) !important;
}
.single-product .tmcp-field-wrap.is-separator:first-child {
  margin-top: 0;
}
.single-product .tc-separator-label,
.single-product .tc-separator {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.single-product .cpf-type-divider hr {
  display: none;
}
.single-product .tmcp-textarea {
  min-height: 90px;
}
.single-product .tm-extra-product-options .tc-epo-element-label-text {
  flex: none;
}

/* TC EPO choices ("text mode"): the <li> is the chip; TC adds .tc-active when selected. */
.single-product .tm-extra-product-options ul.tmcp-ul-wrap li.tmcp-field-wrap.tc-mode-text {
  border: 1.5px solid var(--ink-200) !important;
  border-radius: var(--radius-md) !important;
  background: #fff !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  outline: none !important; /* TC EPO adds its own dark outline on the active choice */
  min-width: 0;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}
.single-product .tm-extra-product-options ul.tmcp-ul-wrap li.tmcp-field-wrap.tc-mode-text:hover {
  border-color: var(--ink-500) !important;
}
/* Selected: same border width, only colour + tint change. */
.single-product .tm-extra-product-options ul.tmcp-ul-wrap li.tmcp-field-wrap.tc-mode-text.tc-active {
  border-color: var(--red-600) !important;
  background: var(--red-50) !important;
}
.single-product .tm-extra-product-options ul.tmcp-ul-wrap li.tmcp-field-wrap.tc-mode-text:has(input:focus-visible) {
  outline: 3px solid var(--color-focus) !important;
  outline-offset: 2px;
}
.single-product .tm-extra-product-options li.tc-mode-text .tc-label-text,
.single-product .tm-extra-product-options li.tc-mode-text label.tm-epo-field-label {
  outline: none !important;
}
.single-product .tm-extra-product-options li.tc-mode-text label.tm-epo-field-label {
  display: block !important;
  padding: 11px 16px !important;
  margin: 0 !important;
  cursor: pointer;
}
.single-product .tm-extra-product-options li.tc-mode-text .tc-label {
  display: block !important;
  border: 0 !important;
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
.single-product .tm-extra-product-options li.tc-mode-text .tc-label-inner {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: auto !important;
  padding: 0 !important;
}
.single-product .tm-extra-product-options li.tc-mode-text .tc-label-text {
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1.2;
}
.single-product .tm-extra-product-options li.tc-mode-text .tc-price-wrap {
  padding: 0 !important;
  margin: 0 !important;
}
.single-product .tm-extra-product-options li.tc-mode-text .tc-price,
.single-product .tm-extra-product-options li.tc-mode-text .tc-price .amount {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-muted);
}
.single-product .tm-extra-product-options li.tc-mode-text.tc-active .tc-price .amount {
  color: var(--red-700);
}
.single-product .tm-extra-product-options li.tc-mode-text input.tmcp-field,
.single-product .tm-extra-product-options li.tc-mode-text .tc-input-wrap {
  position: absolute !important;
  opacity: 0 !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
}
/* Separator rows ("Veg", "Non-Veg", "Cheese") are headings, not chips. */
.single-product .tm-extra-product-options ul.tmcp-ul-wrap li.tmcp-field-wrap.tc-mode-text.is-separator {
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
}
.single-product .tm-extra-product-options li.is-separator label.tm-epo-field-label {
  padding: 0 !important;
  cursor: default;
}
.single-product .tm-extra-product-options li.is-separator .tc-separator-label {
  border: 0 !important;
  background: none !important;
  padding: 0 !important;
}
.single-product .tc-cell.tm_padding {
  display: none;
}
.single-product .reset_variations.tc-cell {
  display: none !important; /* a size is always required; "Reset" only confuses */
}

/* Spacing between option groups */
.single-product .tm-epo-variation-section {
  margin-bottom: var(--space-5) !important;
}
.single-product .cpf-element.cpf-type-divider {
  margin-block: var(--space-4) !important;
  border-top: 1px solid var(--color-border);
}
.single-product .tc-cell:has(> .cpf-type-divider:only-child):last-child,
.single-product .cpf-section:last-child .cpf-type-divider:last-child {
  display: none;
}

/* Totals */
.single-product .tc-totals-form,
.single-product .tc-epo-totals {
  margin: 0;
}
.single-product .tm-extra-product-options-totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px var(--space-4);
  margin: var(--space-5) 0 0;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--ink-100);
}
.single-product .tm-extra-product-options-totals dt,
.single-product .tm-extra-product-options-totals dd {
  margin: 0;
  padding: 0;
  float: none;
  width: auto;
  border: 0 !important;
}
.single-product .tm-extra-product-options-totals dd {
  text-align: right;
  font-weight: 600;
  color: var(--ink-900);
}
.single-product .tm-extra-product-options-totals .tm-final-totals {
  padding-top: 8px;
  border-top: 1px solid var(--ink-200);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--ink-900);
}
.single-product .tm-extra-product-options-totals dd.tm-final-totals .amount {
  color: var(--red-600);
}
.single-product .woocommerce-variation-price {
  display: none; /* TC EPO's totals box shows the live price */
}

/* ---------- Add to cart row ---------- */
.single-product form.cart:not(.variations_form),
.single-product .woocommerce-variation-add-to-cart {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.single-product .woocommerce-variation-add-to-cart > .tc-extra-product-options,
.single-product .woocommerce-variation-add-to-cart > .tc-totals-form,
.single-product form.cart > .tc-extra-product-options,
.single-product form.cart > .tc-totals-form {
  flex-basis: 100%;
}
.single_add_to_cart_button {
  flex: 1;
  min-height: 52px;
  font-size: 1.0625rem;
}
.single_add_to_cart_button.disabled {
  opacity: 0.55;
}

/* ---------- Related ---------- */
.single-product .related {
  max-width: var(--container);
  margin: var(--space-9) auto 0;
  padding: 0 var(--gutter);
}
.single-product .related > h2 {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-5);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .single-product div.product {
    grid-template-columns: 1fr;
  }
  .woocommerce-product-gallery {
    position: static;
    max-width: 520px;
    width: 100%;
    margin-inline: auto;
  }
}
@media (max-width: 680px) {
  .single-product .wc-main {
    padding-top: var(--space-4);
  }
  /* Sticky order bar: qty + add button always in reach */
  .single-product .woocommerce-variation-add-to-cart .quantity,
  .single-product form.cart:not(.variations_form) .quantity {
    position: sticky;
    bottom: 12px;
    z-index: 5;
  }
  .single_add_to_cart_button {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    box-shadow: var(--shadow-3);
  }
  .pill-body {
    min-width: 0;
    padding: 10px 14px;
  }
  .single-product .tm-extra-product-options li.tc-mode-text label.tm-epo-field-label {
    padding: 9px 13px !important;
  }
}

/* ---------- Builder helpers (product.js) ---------- */
.single-product .pick-count {
  margin-left: 8px;
  order: 99;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--red-600);
}
.single-product .is-collapsible .tc-element-container {
  position: relative;
}
.single-product .is-collapsible.is-collapsed .tc-element-container {
  max-height: 150px;
  overflow: hidden;
}
.single-product .is-collapsible.is-collapsed .tc-element-container::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 64px;
  background: linear-gradient(to bottom, rgba(250, 246, 240, 0), var(--bg));
  pointer-events: none;
}
.single-product .collapse-toggle {
  margin-top: var(--space-3);
  padding: 9px 16px;
  border: 1.5px solid var(--ink-900);
  border-radius: var(--radius-pill);
  background: transparent;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--ink-900);
}
.single-product .collapse-toggle:hover {
  background: var(--ink-900);
  color: #fff;
}
.single_add_to_cart_button {
  justify-content: space-between;
}
.single_add_to_cart_button:not(:has(.btn-total)) {
  justify-content: center;
}
.btn-total {
  font-family: var(--font-display);
  font-weight: 800;
}
