/* ==========================================================================
   Section: ugc-gallery  →  assets/section-ugc-gallery.css
   Figma 1346-5362 ("Instagram"): a 1440×820 #080808 band, flush under Brand Story. Its content is
   centred: header row (38) → 24px → 440px row of 327px tiles, 4px apart, the row centred on the page
   (Figma +0.5px), so three whole tiles sit in the middle and the neighbours peek 222px in.
   Tile (UGC Video, 1346-5575): frosted Pause / sound buttons 12px in and the tagged product — 94px
   thumbnail, 1px gap, 208px white box (title, price, "Quick View") 12px off the bottom — both shown
   on hover or keyboard focus (always on touch screens, which have no hover).
   The row drifts sideways on its own (<snap-carousel data-autoplay>) and eases to a stop on hover.
   ========================================================================== */
.ugc-gallery {
  --ugc-card-w: 327px;
  --ugc-gap: 4px;
  /* track inset that puts the second whole tile at the start edge (226px at 1440) */
  --ugc-edge: calc(50% - 1.5 * var(--ugc-card-w) - var(--ugc-gap) + 0.5px);

  padding-block: 159px;
  background: var(--color-surface-primary);
  color: var(--color-text-inverse);
}

.ugc-gallery__inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header row — Heading/H3 title, the Instagram link on the bottom edge */
.ugc-gallery__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  height: 38px;
}

.ugc-gallery__title {
  font-family: var(--font-display);
  font-size: var(--text-display-s-size);
  font-weight: 500;
  line-height: 38px;
  white-space: nowrap;
}

/* the shared .button--tertiary in white; Figma sets this one without tracking. Its 1px hover
   underline hangs below the 16px row, so the row sits on the header's bottom edge. */
.ugc-gallery__link {
  margin-bottom: -1px;
  color: var(--color-text-inverse);
}

.ugc-gallery__link .icon {
  color: var(--color-icon-inverse);
}

/* ---------------------------------------------------------------- carousel */
.ugc-carousel {
  display: block;
}

.ugc-carousel__track {
  display: flex;
  gap: var(--ugc-gap);
  padding-inline: var(--ugc-edge);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--ugc-edge);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.ugc-carousel__track::-webkit-scrollbar {
  display: none;
}

/* <snap-carousel data-drag>: a mouse drag moves the row; snapping waits until it is let go */
.ugc-carousel__track.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  user-select: none;
}

/* ---------------------------------------------------------------- tile */
.ugc-card {
  position: relative;
  flex: 0 0 var(--ugc-card-w);
  aspect-ratio: 327 / 440;
  overflow: hidden;
  background: var(--card-bg, radial-gradient(53.31% 53.31% at 50% 46.69%, #ffffff 0%, #f3f3f3 100%));
  color: var(--color-text-primary);
  scroll-snap-align: start;
}

.ugc-card__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focal-x, 50%) var(--focal-y, 50%);
  transform: scale(var(--zoom, 1));
  transform-origin: var(--focal-x, 50%) var(--focal-y, 50%);
  pointer-events: none;
  -webkit-user-drag: none;
}

/* cut-outs placed inside the tile, as on the product card */
.ugc-card__image--cutout {
  inset: auto;
  top: var(--img-y, 0);
  left: var(--img-x, 0);
  width: var(--img-w, 100%);
  max-width: none;
  height: var(--img-h, 100%);
  transform: none;
  filter: var(--img-shadow, none);
}

/* Video controls — Sound/Default: 24px frosted pills, 1px #e2e2e2, 4px apart; Button/S #4b4b4b.
   Shown with the product on hover / keyboard focus (always on touch, see below). */
.ugc-card__controls {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--duration-fast) ease, transform var(--duration-base) var(--ease-out);
}

.ugc-card:hover .ugc-card__controls,
.ugc-card:focus-within .ugc-card__controls {
  opacity: 1;
  transform: none;
}

.ugc-card__control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 24px;
  min-width: 24px;
  padding: 0 8px;
  border: 1px solid var(--color-border-tertiary);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.64);
  backdrop-filter: blur(4px);
  color: var(--color-icon-secondary);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease;
}

.ugc-card__control span {
  width: var(--width-whole-px);
  color: var(--color-text-secondary);
}

.ugc-card__control--sound {
  width: 24px;
  padding: 0;
}

.ugc-card__control:hover {
  background: rgba(255, 255, 255, 0.88);
}

.ugc-card__control:focus-visible {
  outline: 2px solid var(--color-white);
  outline-offset: 2px;
}

/* the icon for the action the button takes: pause while playing, play while paused;
   the sound button shows the current state (muted by default) */
.ugc-card__control .icon-play,
.ugc-card.is-paused .ugc-card__control .icon-pause,
.ugc-card__control .icon-volume,
.ugc-card.is-unmuted .ugc-card__control .icon-volume-off {
  display: none;
}

.ugc-card.is-paused .ugc-card__control .icon-play,
.ugc-card.is-unmuted .ugc-card__control .icon-volume {
  display: block;
}

/* Tagged product — 12px off the sides and bottom; shown on hover / keyboard focus (always on touch) */
.ugc-card__product {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 1px;
  height: 94px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-fast) ease, transform var(--duration-base) var(--ease-out);
}

.ugc-card:hover .ugc-card__product,
.ugc-card:focus-within .ugc-card__product {
  opacity: 1;
  transform: none;
}

@media (hover: none) {
  .ugc-card__controls,
  .ugc-card__product {
    opacity: 1;
    transform: none;
  }
}

/* 94px white square, 1px white frame, the photo filling the 92px inside */
.ugc-card__product-thumb {
  position: relative;
  flex: 0 0 94px;
  overflow: hidden;
  border: 1px solid var(--color-white);
  border-radius: var(--radius-sm);
  background: var(--color-white);
}

.ugc-card__product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focal-x, 50%) var(--focal-y, 50%);
  transform: scale(var(--zoom, 1));
  transform-origin: var(--focal-x, 50%) var(--focal-y, 50%);
  -webkit-user-drag: none;
}

.ugc-card__product-info {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--color-white);
}

.ugc-card__product-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 147px;
  font-weight: 500;
}

/* Body/S and Body/M (500) in Figma's whole-pixel line boxes */
.ugc-card__product-title {
  overflow: hidden;
  font-size: var(--text-body-s-size);
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ugc-card__product-title:hover {
  text-decoration: underline;
}

.ugc-card__product-price {
  font-size: var(--text-body-m-size);
  line-height: 17px;
}

/* Quick View — #080808, 4/8 padding: Label/S + 14px eye, 4px apart */
.ugc-card__quick-view {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-primary);
  color: var(--color-text-inverse);
  font-size: var(--text-label-s-size);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease;
}

.ugc-card__quick-view span {
  width: var(--width-whole-px);
}

.ugc-card__quick-view .icon {
  color: var(--color-icon-inverse);
}

.ugc-card__quick-view:hover {
  background: var(--color-text-menu);
}

.ugc-card__quick-view:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: 2px;
}

@media (max-width: 989px) {
  .ugc-gallery {
    padding-block: 96px;
  }
}

/* Phones: one tile centred, its neighbours peeking */
@media (max-width: 749px) {
  .ugc-gallery {
    --ugc-card-w: min(280px, 100vw - 80px);
    --ugc-edge: calc(50% - var(--ugc-card-w) / 2);

    padding-block: 64px;
  }

  .ugc-gallery__header {
    flex-wrap: wrap;
    row-gap: 12px;
    height: auto;
  }
}
