/* Shared layout for the product and featured product sections. */
.product {
  display: grid;
  gap: 2rem;
}
.product__media {
  display: grid;
  gap: 0.5rem;
}
.product__info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
@media (min-width: 990px) {
  .product {
    grid-template-columns: 3fr 2fr;
  }
  .product__info {
    position: sticky;
    top: 2rem;
    align-self: start;
  }
}

/* ---------- Gallery ---------- */
.product-gallery {
  position: relative;
}

.product-gallery__list {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.product-gallery--grid .product-gallery__list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.product-gallery--grid .product-gallery__item:first-child {
  grid-column: 1 / -1;
}

.product-gallery__zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.product-gallery__zoom img,
.product-gallery__item > * {
  width: 100%;
  height: auto;
}

.product-gallery__counter {
  display: none;
}

/* Phones: swipeable strip with counter. */
@media (max-width: 989px) {
  .product-gallery__list,
  .product-gallery--grid .product-gallery__list {
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .product-gallery__list::-webkit-scrollbar {
    display: none;
  }

  .product-gallery__item {
    scroll-snap-align: start;
  }

  .product-gallery--grid .product-gallery__item:first-child {
    grid-column: auto;
  }

  .product-gallery__counter {
    display: block;
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--color-background);
  }
}

/* ---------- Zoom ---------- */
.zoom-dialog {
  width: 100%;
  height: 100%;
  background: var(--color-background);
  overflow: auto;
}

.zoom-dialog__close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  padding: 0.5rem 0.75rem;
  background: var(--color-background);
}

.zoom-dialog__image {
  width: 100%;
  max-width: none;
  height: auto;
  cursor: zoom-out;
}

/* ---------- Info column ---------- */
.product-vendor {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.product-vendor a {
  text-decoration: none;
}

.product-title {
  font-size: calc(clamp(2rem, 1.5rem + 2vw, 3.25rem) * var(--heading-scale));
}

.product-price {
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

.product-price__compare {
  margin-inline-start: 0.5rem;
  color: var(--color-foreground-muted);
}

/* ---------- Variant picker ---------- */
.variant-picker {
  display: grid;
  gap: 1.25rem;
  margin-block-end: 1.25rem;
}

.variant-option {
  margin: 0;
  padding: 0;
  border: 0;
}

.variant-option__legend {
  margin-block-end: 0.5rem;
  padding: 0;
}

.variant-option__selected {
  color: var(--color-foreground-muted);
}

.variant-option__values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.variant-option__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.variant-option__value {
  display: inline-grid;
  place-items: center;
  min-width: 3rem;
  min-height: 2.75rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--color-hairline);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.variant-option__value:hover {
  border-color: var(--color-foreground);
}

.variant-option__input:checked + .variant-option__value {
  border-color: var(--color-foreground);
  background: var(--color-foreground);
  color: var(--color-background);
}

.variant-option__input:focus-visible + .variant-option__value {
  outline: 1px solid var(--color-foreground);
  outline-offset: 3px;
}

.variant-option__value.is-unavailable {
  color: var(--color-foreground-muted);
  text-decoration: line-through;
}

.variant-option__value--swatch {
  width: 2.25rem;
  min-width: 0;
  height: 2.25rem;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--swatch-color, var(--color-hairline));
  overflow: hidden;
}

.variant-option__input:checked + .variant-option__value--swatch {
  background: var(--swatch-color, var(--color-hairline));
  box-shadow: 0 0 0 2px var(--color-background), 0 0 0 3px var(--color-foreground);
}

.variant-option__value--swatch.is-unavailable {
  opacity: 0.35;
}

.variant-option__swatch-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Buy buttons ---------- */
.buy-buttons__form {
  display: grid;
  gap: 0.75rem;
}

.buy-buttons__quantity {
  display: grid;
  gap: 0.25rem;
  justify-items: start;
}

.buy-buttons__quantity input {
  width: 5rem;
  min-height: 2.75rem;
  padding-inline: 0.5rem;
  border: 1px solid var(--color-hairline);
  background: transparent;
  color: inherit;
}

.buy-buttons__add {
  width: 100%;
  min-height: 3.25rem;
}

/* ---------- Pickup ---------- */
.pickup {
  display: grid;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.pickup:empty {
  display: none;
}

.pickup__time,
.pickup__address {
  color: var(--color-foreground-muted);
}

.pickup__locations ul {
  display: grid;
  gap: 1rem;
  padding: 0.75rem 0 0;
  list-style: none;
}

.pickup__location {
  font-family: var(--font-heading--family);
  font-size: 1.125rem;
}

/* ---------- Thumbnail scrubber (desktop, stacked gallery) ---------- */
/* Jumps land below the sticky header. */
.product-gallery__item {
  scroll-margin-top: calc(var(--header-overlay-height, 4rem) + 1rem);
}

.product-gallery__scrubber {
  display: none;
}

@media (min-width: 990px) {
  .product-gallery__scrubber {
    position: sticky;
    bottom: 1.5rem;
    z-index: 2;
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    width: max-content;
    max-width: 100%;
    margin: 1rem auto 0;
    padding: 0.375rem;
    background: color-mix(in srgb, var(--color-background) 85%, transparent);
    backdrop-filter: blur(8px);
  }

  .product-gallery__scrub {
    width: 3rem;
    aspect-ratio: 1;
    overflow: hidden;
    padding: 0;
    border: 1px solid transparent;
    background: var(--color-well, var(--color-hairline));
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 150ms ease, border-color 150ms ease;
  }

  .product-gallery__scrub img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .product-gallery__scrub:hover,
  .product-gallery__scrub[aria-current='true'] {
    opacity: 1;
  }

  .product-gallery__scrub[aria-current='true'] {
    border-color: var(--color-foreground);
  }

  .product-gallery__scrub:focus-visible {
    outline: 1px solid var(--color-foreground);
    outline-offset: 2px;
  }
}

/* ---------- Size and fit ---------- */
.size-fit {
  display: grid;
  gap: 0.75rem;
}

.size-fit__model {
  margin: 0;
  color: var(--color-foreground-muted);
}

.size-fit__scale {
  display: grid;
  gap: 0.375rem;
}

.size-fit__track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 0.75rem;
  border-inline: 1px solid var(--color-foreground);
}

.size-fit__track::before {
  content: '';
  position: absolute;
  inset-inline: 0;
  top: 50%;
  border-top: 1px solid var(--color-hairline);
}

.size-fit__marker {
  grid-column: var(--fit-position);
  justify-self: center;
  width: 2px;
  height: 100%;
  background: var(--color-foreground);
}

.size-fit__ends {
  display: flex;
  justify-content: space-between;
  color: var(--color-foreground-muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
}

.size-fit__guide {
  justify-self: start;
}

.size-dialog {
  width: min(100%, 40rem);
  max-height: 100%;
  height: 100%;
  margin: 0 0 0 auto;
  padding: 1.5rem;
  border: 0;
  background: var(--color-background);
  color: var(--color-foreground);
  overflow: auto;
}

.size-dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.size-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-block-end: 1.5rem;
}

.size-dialog__content table {
  width: 100%;
  border-collapse: collapse;
}

.size-dialog__content :is(th, td) {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--color-hairline);
  text-align: start;
}

/* ---------- Pre-order ---------- */
.buy-buttons__preorder-note {
  margin: 0;
  color: var(--color-foreground-muted);
}

/* ---------- Centred layout: info left, images centre, buy right ---------- */
@media (min-width: 990px) {
  .product--centered {
    grid-template-columns: minmax(14rem, 18rem) minmax(0, 31rem) minmax(14rem, 18rem);
    justify-content: space-between;
    align-items: start;
    gap: 2rem;
    padding-block: 1.5rem 3rem;
  }

  .product--centered .product__media {
    grid-column: 2;
    grid-row: 1;
  }

  /* Side columns stay in view, vertically centred, while the images scroll. */
  .product--centered :is(.product__info, .product__buy) {
    position: sticky;
    top: var(--header-overlay-height, 4rem);
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    min-height: calc(100svh - var(--header-overlay-height, 4rem) - 3rem);
  }

  .product--centered .product__info {
    grid-column: 1;
  }

  .product--centered .product__buy {
    grid-column: 3;
  }

  .product--centered .product-gallery__scrubber {
    display: none;
  }
}

/* ---------- Accordions (description, collapsible tabs) ---------- */
.product-accordion {
  border-block-end: 1px solid var(--color-foreground);
}

.product-accordion__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.8rem;
  font-size: 0.625rem;
  letter-spacing: 0.05em;
  list-style: none;
  cursor: pointer;
}

.product-accordion__toggle::-webkit-details-marker {
  display: none;
}

.product-accordion__toggle::after {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  margin-inline-end: 0.2rem;
  border-inline-end: 1px solid currentcolor;
  border-block-end: 1px solid currentcolor;
  transform: rotate(45deg) translateY(-25%);
  transition: transform 200ms ease;
}

.product-accordion[open] > .product-accordion__toggle::after {
  transform: rotate(-135deg) translateY(-25%);
}

.product-accordion__content {
  padding-block: 0.25rem 1.25rem;
  color: var(--color-foreground-muted);
}
