/*
 * ABC Home product-family controls
 * --------------------------------
 * The product page control deliberately occupies the quiet left edge of the
 * gallery. It shares the gallery's grid cell and never enters the summary or
 * purchase column, so the red add-to-cart action keeps its visual priority.
 */
.single-product div.product.product > .abchpf-configurator {
  position: relative;
  z-index: 8;
  align-self: stretch;
  grid-column: 1;
  grid-row: 1;
  height: 100%;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
}

.abchpf-configurator__panel {
  position: absolute;
  top: 50%;
  bottom: auto;
  left: clamp(14px, 2.5vw, 22px);
  display: flex;
  max-height: min(calc(100% - 144px), 320px);
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  padding: 7px 6px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: rgba(255, 253, 249, .86);
  box-shadow: 0 2px 10px rgba(33, 56, 76, .13);
  pointer-events: auto;
  transform: translateY(-50%);
  -webkit-backdrop-filter: blur(8px) saturate(.82);
  backdrop-filter: blur(8px) saturate(.82);
}

.single-product .woocommerce-product-gallery.abc-product-gallery--has-thumbnails
  + .abchpf-configurator .abchpf-configurator__panel {
  max-height: min(calc(100% - 210px), 300px);
}

.abchpf-axis,
.abchpf-axis__rail {
  display: flex;
  min-width: 0;
}

.abchpf-axis {
  max-width: 100%;
  flex-direction: column;
}

.abchpf-axis--color {
  min-height: 0;
  flex: 1 1 auto;
}

.abchpf-axis--text {
  flex: 0 0 auto;
}

.abchpf-axis__rail {
  max-height: 100%;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px;
  overscroll-behavior: contain;
  scrollbar-color: rgba(76, 120, 152, .45) transparent;
  scrollbar-width: thin;
}

.abchpf-option {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--abc-navy, #21384c);
  text-decoration: none !important;
  -webkit-tap-highlight-color: transparent;
}

.abchpf-option:focus-visible {
  border-radius: 0;
  outline: 3px solid color-mix(in srgb, var(--abc-blue, #4c7898) 42%, transparent);
  outline-offset: 2px;
}

.abchpf-option--color {
  width: 22px;
  height: 22px;
}

.abchpf-option__sample {
  display: block;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(23, 35, 50, .28);
  border-radius: 50%;
  background: var(--abchpf-swatch, #d6dde2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .36);
  transition: box-shadow .14s, transform .14s;
}

.abchpf-option--color:hover .abchpf-option__sample,
.abchpf-option--color:focus-visible .abchpf-option__sample {
  transform: scale(1.08);
}

.abchpf-option--color.is-current .abchpf-option__sample {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .38),
    0 0 0 2px #fffdfa,
    0 0 0 4px var(--abc-red, #d84d57);
}

.abchpf-option.is-unavailable {
  opacity: .48;
}

.abchpf-option.is-unavailable::after {
  position: absolute;
  width: 22px;
  height: 1px;
  background: var(--abc-red-deep, #b93642);
  content: "";
  transform: rotate(-45deg);
}

.abchpf-option__tooltip {
  position: absolute;
  z-index: 12;
  top: 50%;
  left: calc(100% + 9px);
  width: max-content;
  max-width: 190px;
  padding: 5px 7px;
  border-radius: 3px;
  background: rgba(33, 56, 76, .96);
  box-shadow: 0 4px 12px rgba(23, 35, 50, .18);
  color: #fff;
  font-size: .72rem;
  font-weight: 750;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(3px, -50%);
  transition: opacity .12s, transform .12s;
  white-space: nowrap;
}

.abchpf-option--color:hover .abchpf-option__tooltip,
.abchpf-option--color:focus-visible .abchpf-option__tooltip {
  opacity: 1;
  transform: translate(0, -50%);
}

.abchpf-axis--text .abchpf-axis__rail {
  gap: 4px;
}

.abchpf-option--text {
  min-width: 34px;
  min-height: 21px;
  padding: 2px 4px;
  border: 1px solid rgba(76, 120, 152, .32);
  border-radius: 0;
  background: rgba(255, 253, 249, .86);
  font-size: .62rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.abchpf-option--text:hover,
.abchpf-option--text:focus-visible {
  border-color: var(--abc-blue, #4c7898);
  background: #fff;
}

.abchpf-option--text.is-current {
  border-color: var(--abc-red, #d84d57);
  background: var(--abc-red, #d84d57);
  color: #fff;
  box-shadow: 0 2px 7px rgba(185, 54, 66, .2);
}

/*
 * Catalog cards use one compact discovery chip in the lower-left image corner.
 * The existing add-to-cart circle keeps the lower-right corner to itself.
 */
.woocommerce ul.products li.product .abchpf-family-chip,
.woocommerce-page ul.products li.product .abchpf-family-chip {
  position: absolute;
  z-index: 5;
  top: calc(100cqi - 3.35rem);
  left: .8rem;
  display: inline-flex;
  width: auto;
  max-width: calc(100% - 4.6rem);
  min-height: 2.2rem;
  align-items: center;
  gap: .38rem;
  margin: 0;
  padding: .3rem .5rem .3rem .38rem;
  overflow: hidden;
  border: 1px solid rgba(76, 120, 152, .55);
  border-radius: 999px;
  background: rgba(255, 253, 249, .9);
  box-shadow: 0 2px 9px rgba(33, 56, 76, .13);
  color: var(--abc-navy, #21384c);
  text-decoration: none !important;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.woocommerce ul.products li.product .abchpf-family-chip:hover,
.woocommerce-page ul.products li.product .abchpf-family-chip:hover,
.woocommerce ul.products li.product .abchpf-family-chip:focus-visible,
.woocommerce-page ul.products li.product .abchpf-family-chip:focus-visible {
  border-color: var(--abc-red, #d84d57);
  background: #fffdfa;
  color: var(--abc-red-deep, #b93642);
}

.abchpf-family-chip:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--abc-blue, #4c7898) 38%, transparent);
  outline-offset: 2px;
}

.abchpf-family-chip__samples {
  display: inline-flex;
  flex: 0 0 auto;
  padding-left: 2px;
}

.abchpf-family-chip__samples > span {
  display: block;
  width: 11px;
  height: 11px;
  margin-left: -2px;
  border: 1px solid rgba(23, 35, 50, .3);
  border-radius: 50%;
  background: var(--abchpf-swatch, #d6dde2);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .8);
}

.abchpf-family-chip__text {
  min-width: 0;
  overflow: hidden;
  font-size: clamp(.62rem, 5.1cqi, .72rem);
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.abchpf-family-chip__text--compact {
  display: none;
}

@container (max-width: 210px) {
  .abchpf-family-chip__text--full {
    display: none;
  }

  .abchpf-family-chip__text--compact {
    display: inline;
  }
}

@container (max-width: 135px) {
  .abchpf-family-chip__samples {
    display: none;
  }
}

@media (max-width: 900px) {
  .single-product div.product.product > .woocommerce-product-gallery {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  .single-product div.product.product > .abchpf-configurator {
    align-self: stretch !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    height: 100%;
  }

  .single-product div.product.product > .summary {
    grid-column: 1 !important;
    grid-row: 2 !important;
  }

  .abchpf-configurator__panel {
    top: auto;
    right: 12px;
    bottom: 66px;
    left: 12px;
    display: flex;
    max-width: none;
    max-height: none;
    min-height: 40px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    padding: 5px 7px;
    background: rgba(255, 253, 249, .86);
    transform: none;
  }

  .single-product .woocommerce-product-gallery.abc-product-gallery--has-thumbnails
    + .abchpf-configurator .abchpf-configurator__panel {
    bottom: 144px;
    max-height: none;
  }

  .abchpf-axis {
    min-width: 0;
    flex: 0 0 auto;
    flex-direction: row;
  }

  .abchpf-axis--color {
    flex: 1 1 auto;
    overflow: hidden;
  }

  .abchpf-axis__rail,
  .abchpf-axis--text .abchpf-axis__rail {
    max-width: 100%;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px;
    scroll-snap-type: x proximity;
  }

  .abchpf-option {
    scroll-snap-align: start;
  }

  .abchpf-option--color {
    width: 28px;
    height: 28px;
  }

  .abchpf-option__sample {
    width: 20px;
    height: 20px;
  }

  .abchpf-option__tooltip {
    display: none;
  }

  .abchpf-option--text {
    min-width: 42px;
    min-height: 27px;
    font-size: .7rem;
  }
}

@media (max-width: 480px) {
  .abchpf-configurator__panel {
    right: 8px;
    left: 8px;
    gap: 5px;
    padding: 4px 5px;
  }

  .woocommerce ul.products li.product .abchpf-family-chip,
  .woocommerce-page ul.products li.product .abchpf-family-chip {
    left: .55rem;
    max-width: calc(100% - 4rem);
    min-height: 2rem;
    padding: .26rem .42rem .26rem .32rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .abchpf-option,
  .abchpf-option__sample,
  .abchpf-option__tooltip {
    transition: none !important;
  }
}
