/**
 * DJ Refresh — New Arrivals.
 * Figma: 5 visible cards (272px), 20px gutters, each a square light panel with a red NEW
 * badge top-left and the product name beneath. A scroll-progress bar sits under the row.
 *
 * The .djr-scroller block is shared with the reels section.
 */

/* ---------- Shared horizontal scroller ---------- */

.djr-scroller {
  --djr-scroller-gap: 20px;
}

a.djr-arrivals__card:hover {
  text-decoration: none;
}
a.djr-arrivals__card:hover span:not(.djr-arrivals__badge) {
  color: var(--djr-red)!important;
}

.djr-scroller__track {
  display: flex;
  gap: var(--djr-scroller-gap);
  overflow-x: auto;
  /*
   * Must be explicit. Per spec, when one axis is `auto` the other computes from `visible`
   * to `auto` as well — so the track becomes vertically scrollable (the cards' hover-scale
   * spills a few pixels), and it then swallows page wheel gestures. This row scrolls
   * horizontally only.
   */
  overflow-y: hidden;
  /* Don't let a horizontal fling chain into the page scroll, or vice versa. */
  overscroll-behavior-x: contain;
  /* Touch: pan horizontally here, but let vertical drags scroll the page. */
  touch-action: pan-x;
  /* Proximity, not mandatory: a mandatory snap forces every short swipe back to a card edge,
     which reads as a "sticky", hard-to-move rail on touch. Proximity lets a swipe scroll
     freely and only gently aligns when it comes to rest near a card. */
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  /* Native scrollbar hidden — we render our own progress bar. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.djr-scroller__track::-webkit-scrollbar {
  display: none;
}

/* Wraps the track so the arrows can be positioned over the cards (js/djr-scroller.js). */
.djr-scroller__viewport {
  position: relative;
}

/* ---------- Prev / next arrows ----------
 * Injected by js/djr-scroller.js. Revealed on hover, POINTER DEVICES ONLY — touch users swipe.
 */
.djr-scroller__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--djr-white);
  color: var(--djr-ink);
  box-shadow: 0 6px 18px rgba(12, 16, 22, 0.18);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.djr-scroller__arrow--prev {
  left: 8px;
}

.djr-scroller__arrow--next {
  right: 8px;
}

.djr-scroller__arrow svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.djr-scroller__arrow:hover {
  background: var(--djr-red);
  color: var(--djr-white);
}

.djr-scroller__arrow:disabled {
  opacity: 0 !important;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .djr-scroller.is-scrollable:hover .djr-scroller__arrow {
    display: inline-flex;
    opacity: 1;
  }
}

.djr-scroller__bar {
  position: relative;
  height: 10px;
  margin-top: 36px;
  border-radius: var(--djr-radius-pill);
  /* Figma: #d9d9d9 track. */
  background: #d9d9d9;
  overflow: hidden;
}

/* The bar becomes an interactive scrollbar once the track overflows. */
.djr-scroller.is-scrollable .djr-scroller__bar {
  cursor: pointer;
}

.djr-scroller.is-scrollable .djr-scroller__thumb {
  cursor: grab;
}

/* While dragging (cards or thumb): grabbing cursor, and suspend snap so the drag tracks the
   pointer 1:1 instead of fighting it. Snap re-engages on release. */
.djr-scroller__track.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  scroll-behavior: auto;
  user-select: none;
}

.djr-scroller__thumb {
  display: block;
  height: 100%;
  width: 20%;
  border-radius: var(--djr-radius-pill);
  background: var(--djr-red);
  transition: transform 0.08s linear;
}

/* Everything fits — no bar needed. */
.djr-scroller.is-static .djr-scroller__bar {
  display: none;
}

/* ---------- Cards ---------- */

.djr-arrivals__track {
  /* 5 across at the design width; they shrink no further than 220px before scrolling. */
  --djr-arrivals-card-w: calc((100% - (4 * var(--djr-scroller-gap))) / 5);
}

.djr-arrivals__item {
  flex: 0 0 max(220px, var(--djr-arrivals-card-w));
  scroll-snap-align: start;
  min-width: 0;
}

.djr-arrivals__card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.djr-arrivals__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  padding: 20px;
  border-radius: var(--djr-radius);
  background: var(--djr-surface);
  overflow: hidden;
  transition: background-color 0.2s ease;
}

.djr-arrivals__card:hover .djr-arrivals__media,
.djr-arrivals__card:focus-visible .djr-arrivals__media {
  background: #e9e9e9;
}
.djr-arrivals__card:hover {
  text-decoration: none!important;
}


.djr-arrivals__image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.25s ease;
  /* Match the media radius so the hover scale never squares off the tile corners (a
     transformed child otherwise escapes the ancestor's border-radius clip in Chrome). */
  border-radius: inherit;
}

.djr-arrivals__card:hover .djr-arrivals__image {
  transform: scale(1.05);
}

.djr-arrivals__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 5px 12px;
  border-radius: var(--djr-radius-pill);
  background: var(--djr-red);
  color: var(--djr-white);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
}

.djr-arrivals__name {
  font-size: var(--djr-body-size);
  font-weight: 700;
  line-height: 1.3;
  color: var(--djr-ink);
  text-align: center;
}

.djr-arrivals__cta {
  flex: 0 0 auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .djr-arrivals__item {
    flex-basis: 200px;
  }

  /* Keep the heading and CTA on one row — the CTA stays on the right, per the mobile frame,
     rather than wrapping under the heading. */
  .djr-section__head {
    flex-wrap: nowrap;
    gap: 16px;
  }

  .djr-arrivals__cta {
    flex: 0 0 auto;
  }
}

/* Phones: shorten "All New Products" to "All New" and tighten the pill so it sits neatly
   beside the heading (Figma mobile: 12px label). */
@media (max-width: 560px) {
  .djr-arrivals__cta-suffix {
    display: none;
  }

  .djr-arrivals__cta {
    padding: 9px 16px;
    font-size: 12px;
  }
}
