/* ============================================================================
   ragazzi-bestsellers.css — CARRIED from ragazzi-site/css/sections/bestsellers.css.

   The section it dresses is DAWN'S OWN `featured-collection`: its collection
   picker, product limit, pagination, column settings, colour scheme and section
   padding are untouched. Only the presentation is the design's, and the card
   markup comes from snippets/ragazzi-product-card.liquid.

   SELECTOR MAP — the design's names on the left, the Dawn element each rule now
   hangs on. The card's own names are unchanged because our card snippet renders
   them verbatim.
     .bestsellers                       ->  .ragazzi-bestsellers .collection
     .bestsellers__title                ->  .ragazzi-bestsellers .title
     .bestsellers__slider .slides-blocks ->  .ragazzi-bestsellers .product-grid
     .slide-wrapper                     ->  .ragazzi-bestsellers .grid__item
     .product-card…                     ->  unchanged

   TWO DELIBERATE DEVIATIONS from the static, both marked `PORT:` below:
   the photo becomes a real <img> instead of a background (Shopify serves
   responsive images and a background cannot carry a srcset), and the per-card
   crop percentages become the image's own focal point (they were tuned for four
   specific photographs that no longer exist here).
============================================================================ */

/* ---------------------------------------------------------------------------
   SECTION TOKENS — carried verbatim, in the static's own band order.
--------------------------------------------------------------------------- */
.ragazzi-bestsellers {
  --size-card-w:         clamp(218.67px, calc(410px * (var(--max-vw) / var(--vw-base))), 410px);
  --size-h2-max:         clamp(423.96px, calc(794.92px * (var(--max-vw) / var(--vw-base))), 794.92px);
  --sp-bs-card-gap:      clamp(13.33px, calc(25px * (var(--max-vw) / var(--vw-base))), 25px);
  --sp-bs-heading-gap:   clamp(32px, calc(60px * (var(--max-vw) / var(--vw-base))), 60px);
  --sp-bs-pad-y:         clamp(53.33px, calc(100px * (var(--max-vw) / var(--vw-base))), 100px);
  --sp-gutter:           var(--container-pad);
  --text-h2-section:     clamp(35px, calc(65px * (var(--max-vw) / var(--vw-base))), 65px);
}

@media (max-width: 767px) {
  .ragazzi-bestsellers {
    --size-card-w:         clamp(221.87px, calc(260px + (var(--max-vw) - 375px) * 0.015), 531.79px);
    --sp-bs-card-gap:      clamp(8.53px, calc(10px + (var(--max-vw) - 375px) * 0.015), 20.45px);
    --sp-bs-heading-gap:   clamp(17.07px, calc(20px + (var(--max-vw) - 375px) * 0.015), 40.91px);
    --sp-bs-pad-y:         clamp(34.13px, calc(40px + (var(--max-vw) - 375px) * 0.015), 81.81px);
    --text-h2-section:     clamp(27px, calc(32px + (var(--max-vw) - 375px) * 0.015), 65px);
}
}


@media (min-width: 768px) and (max-width: 1023px) {
  .ragazzi-bestsellers {
    --size-card-w:         clamp(260px, calc(260px + (var(--max-vw) - 768px) * 0.025), 410px);
    --size-h2-max:         clamp(335px, calc(335px + (var(--max-vw) - 768px) * 0.025), 794.92px);
    --sp-bs-card-gap:      clamp(10px, calc(10px + (var(--max-vw) - 768px) * 0.025), 25px);
    --sp-bs-heading-gap:   clamp(20px, calc(20px + (var(--max-vw) - 768px) * 0.025), 60px);
    --sp-bs-pad-y:         clamp(40px, calc(40px + (var(--max-vw) - 768px) * 0.025), 100px);
    --text-h2-section:     clamp(32px, calc(32px + (var(--max-vw) - 768px) * 0.025), 65px);
}
}


/* ============================================================
   bestsellers — section 2, desktop 3080:13476 / mobile 3080:14018
   Pattern A: no section background, content sits in the gutter.
============================================================ */

/* Figma's section is a vertical auto-layout with `gap: 60` (D) / `20` (M)
   between the heading and the card row — expressed as the same flex gap rather
   than a margin on the title, so the node's own mechanism survives into the DOM.
   NEVER the `padding` shorthand: the gutter is the two `page-width` children's
   own (see ADAPTATION 1), and a shorthand here would fight it. */
.ragazzi-bestsellers .collection {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  row-gap: var(--sp-bs-heading-gap);
  padding-top: var(--sp-bs-pad-y);
  padding-bottom: var(--sp-bs-pad-y);
  background: var(--color-bg);
}

.ragazzi-bestsellers .title {
  font-family: var(--font-body);
  font-size: var(--text-h2-section);
  font-weight: 500;
  line-height: var(--lh-tight);
  color: var(--color-black);
}

/* ---------------- Slider ----------------
   ONE component on both layers (brief §11 D-4). Mobile: 4 x 260 + 3 x 10 = 1070
   in a 335 content box, so it scrolls and card 2 peeks — that peek IS the swipe
   affordance. Desktop: 4 cards fill the row exactly and it does not scroll.
   No arrows, no dots, no tabs, no autoplay anywhere in Figma. */
.ragazzi-bestsellers .product-grid {
  display: flex;
  flex-direction: row;
  align-items: stretch;            /* equal-height cards (brief §5) */
  column-gap: var(--sp-bs-card-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  /* AUTO, never `smooth`: a CSS-level smooth scroll fights mandatory snap — the
     snap re-targets mid-animation and programmatic scrolls read back at the old
     position. */
  scroll-behavior: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Full-bleed scroll container (brief §1b MUST-APPLY): Figma's mobile row is a
     375-wide box with its own 20px padding inside a section that has none, so
     the cards scroll edge to edge and card 2 peeks past the viewport. Without
     the break-out the peek stops 20px short and the slider reads as a clipped
     grid. Both reset at >=1024. */
  margin-inline: calc(var(--sp-gutter) * -1);
  padding-inline: var(--sp-gutter);
  /* MUST accompany the padding above. `scroll-snap-align: start` aligns a slide
     with the SCROLLPORT's start edge, which ignores padding-left — so on load
     the browser silently scrolled the track and card 1 sat flush against the
     viewport instead of at Figma's x=20. */
  scroll-padding-inline: var(--sp-gutter);
}

.ragazzi-bestsellers .product-grid::-webkit-scrollbar {
  display: none;
}

.ragazzi-bestsellers .grid__item {
  flex: 0 0 var(--size-card-w);
  scroll-snap-align: start;
  display: flex;
}

/* With snap on, the LAST slide needs `end` or its start-offset sits beyond the
   maximum scroll and the end of the list can never be reached. */
.ragazzi-bestsellers .grid__item:last-child {
  scroll-snap-align: end;
}@media (min-width: 1024px) {
  .ragazzi-bestsellers .title {
    max-width: var(--size-h2-max);
  }

  .ragazzi-bestsellers .product-grid {
    margin-inline: 0;
    padding-inline: 0;
    scroll-padding-inline: 0;
    /* Figma fits all four cards in the content box (1715 in 1720) — desktop is a
       static row, so the track must NOT be a live scroll container here. `clip`
       instead of `auto`: nothing can scroll, and nothing can spill into the page
       either if a fluid edge case rounds a pixel the wrong way. */
    overflow-x: clip;
  }

  /* Sized against the REAL container width rather than a proportional 410px.
     100vw includes the scrollbar and the container's width does not, so a
     proportional card row overshoots its box by roughly the scrollbar width and
     clips the 4th card at the design viewport (build-pitfalls #2). This form
     always fits exactly four across, at every desktop width. */
  .ragazzi-bestsellers .grid__item {
    flex: 0 0 calc((100% - 3 * var(--sp-bs-card-gap)) / 4);
  }
}


/* Reduced motion — there is no autoplay and no arrows here, so the only motion
   to suppress is a programmatic smooth scroll. */
@media (prefers-reduced-motion: reduce) {
  .ragazzi-bestsellers .product-grid {
    scroll-behavior: auto;
  }
}


/* ============================================================================
   ADDED FROM FIGMA — the "VIEW ALL" pill. NOT in the static export.

   The pipeline's home-page bestsellers frame (3080:13476) has no button, so the
   static has none and the port faithfully reproduced that. The design DOES draw
   one: file KHd6DbX5f6HbBBVKfHLqUd, section `Best Sellers` 134:342, whose
   heading row `Container` 134:343 is a HORIZONTAL auto-layout, width FILL 1720,
   height HUG 144, `justifyContent: SPACE_BETWEEN`, with the heading left and the
   `Link` 134:403 right, bottom-aligned (the 63.94 pill sits at y 80.06 of the
   144 row = 144 - 63.94).

   Measured off 134:403 / its label 134:404 at the 1920 scale:
     fill #000000, border 1.27 #000000, radius 162.54, min-width 163.82,
     padding 12.7 / 40.63, box HUG 178.81 x 63.94
     label Onest 700, 17.78px, line-height 35.56 (= 2.0), tracking 1.28px
     (= 7.2%), uppercase, centred, #ffffff, box 95 x 36
   The arithmetic closes both ways: 40.63 + 95 + 40.63 + 2x1.27 = 178.81 and
   12.7 + 36 + 12.7 + 2x1.27 = 63.94, so the pill HUGS and no dimension is
   pinned here.

   This is the design's ONE button component, inverted. Every number above is
   the same one `.shop-banner__cta` already carries (padding 12.698/40.635,
   min-width 163.82, radius 162.54 -> --radius-pill, tracking 7.11%) — the two
   pills are the same object at the same scale, drawn white-on-black there and
   black-on-white here. So the type comes from the site-wide `--text-btn`
   (18px desktop) rather than a literal 17.78: 17.78 is 14 x 1.2698, the raw
   1512 -> 1920 scale factor this whole design was uprezzed by, and 18 is what
   the pipeline rounded every other instance of it to. Matching the pipeline
   keeps the site's buttons identical; matching the raw node would make this one
   0.22px odd.

   NO MOBILE LAYER EXISTS for this button — the only frame that has it is the
   1920 one. The three bands below therefore mirror `.shop-banner__cta`'s, which
   is the same component and the only measured evidence at the mobile scale.
   Flagged rather than silently invented.
============================================================================ */

/* Figma 134:343: the heading row. `align-items: flex-end` is the bottom
   alignment described above; `space-between` needs no gap to work, but one is
   set anyway so a long heading cannot touch the pill, and it reuses the
   section's OWN gap token rather than adding a number.

   `flex-wrap` + the description's full-basis are for markup the design does not
   have: Dawn's `.collection__title` can also hold `.collection__description`. It
   is not part of this design, so instead of being styled it is given its own
   row, where it cannot break the two-item composition. */
.ragazzi-bestsellers .collection__title {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  /* Both axes. The column gap is inert while `space-between` has room, and it
     stops a long heading touching the pill when it does not; the ROW gap is
     what separates them once the pill wraps under the heading, which is what
     happens on the narrow bands — with no row gap it would sit flush against
     the last line. Same token either way, so no new number. */
  gap: var(--sp-bs-heading-gap);
}

.ragazzi-bestsellers .collection__description {
  flex-basis: 100%;
}

/* MOBILE ONLY — the pill moves BELOW the card row.

   `order` alone cannot do it. The pill is markup-wise a child of
   `.collection__title`, and `order` only sorts an element among its OWN
   siblings, so from inside that wrapper it can never pass the slider. Removing
   the wrapper's box with `display: contents` promotes the heading and the pill
   into `.collection`, which is already a flex COLUMN, and there `order: 1` puts
   the pill last.

   THE WRAPPER WAS CARRYING THE GUTTER, and `display: contents` takes it away
   with the box — measured 100px of padding-inline on it, which is exactly
   `--sp-gutter`. Both promoted children get it back as a margin from the same
   token, so the heading keeps its indent at every width instead of going
   full-bleed.

   No new spacing number: the 20px asked for at 375 IS `--sp-bs-heading-gap`
   there (`clamp(17.07px, 20px + (max-vw - 375px) * 0.015, 40.91px)`), and
   `.collection`'s own `row-gap` already applies it between every pair — the same
   mechanism the heading gap uses, per the note at the top of this file.

   `align-self` because `.collection` stretches its items; without it the pill
   would go full width instead of hugging its label. */
@media (max-width: 767px) {
  .ragazzi-bestsellers .collection__title {
    display: contents;
  }

  /* THE DOUBLED CLASSES ARE LOAD-BEARING, and it takes FOUR to win here.
     ADAPTATION 3 below zeroes margins twice: `.ragazzi-bestsellers .title` at
     (0,2,0) and `.ragazzi-bestsellers .collection__title .title` at (0,3,0).
     Both are LATER in this file, so they take any tie. A plain
     `.collection__title > *` (0,2,0) lost, and so did the (0,3,0) version — the
     heading shipped flush against the screen edge on mobile, which is how this
     was found. Verified at (0,4,0) from the earliest possible position in the
     document, the worst case for source order: it holds on specificity alone,
     so neither rule moving can break it again.

     `margin`, not `padding`: the wrapper's own gutter went with its box when
     `display: contents` removed it, and these are now flex items of
     `.collection`, where a margin is what insets them. */
  .ragazzi-bestsellers.ragazzi-bestsellers
    .collection__title.collection__title > * {
    margin-inline: var(--sp-gutter);
  }

  .ragazzi-bestsellers__view-all {
    order: 1;
    align-self: flex-start;
  }
}

.ragazzi-bestsellers__view-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: clamp(100px, calc(117.44px + (var(--max-vw) - 375px) * 0.015), 240px);
  /* 8.5 at 375, from the redrawn frame: its 47.54 box holds a 28 line (14px at
     `line-height: 2`) and 1.27 of border a side, so (47.54 - 28 - 2.54) / 2.
     Measured 60 -> 47 in the browser rather than 60.54 -> 47.54, because Chrome
     snaps a 1.27px border to 1px at DPR 1; a phone at DPR 2-3 draws the real
     47.54. Bounds scaled by the same 8.5/15 so the ramp keeps its shape, and the
     hand-off to the 768 band improves as a side effect — 767 now reads 14.38
     into that band's 15, where it used to read 20.88 and drop. */
  padding-block: clamp(7.25px, calc(8.5px + (var(--max-vw) - 375px) * 0.015), 17.4px);
  padding-inline: clamp(34px, calc(40px + (var(--max-vw) - 375px) * 0.015), 82px);
  border: 1.27px solid var(--color-black);
  border-radius: var(--radius-pill);
  background-color: var(--color-black);
  color: var(--color-white);
  font-family: var(--font-body);
  font-size: var(--text-btn);
  font-weight: 700;                  /* Figma label weight 700 */
  line-height: 2;                    /* Figma 35.56 / 17.78 */
  letter-spacing: 0.072em;           /* Figma 1.28px at 17.78px */
  text-transform: uppercase;          /* Figma textCase: UPPER */
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 200ms ease;
}

/* Figma has a `default` state only, on either pill. The same opacity affordance
   `.shop-banner__cta` uses, for the same reason: it cannot conflict with a real
   hover colour if one is ever drawn. */
.ragazzi-bestsellers__view-all:hover,
.ragazzi-bestsellers__view-all:focus-visible {
  opacity: 0.9;
}

@media (min-width: 768px) {
  .ragazzi-bestsellers__view-all {
    min-width: clamp(117.44px, calc(117.44px + (var(--max-vw) - 768px) * 0.025), 163.82px);
    /* Descending M 15 -> D 12.698, written the way tokens.css writes
       --text-logo: hold M-base across the band and let 1024 take the descent. */
    padding-block: clamp(12.698px, calc(15px + (var(--max-vw) - 768px) * 0.025), 15px);
    padding-inline: clamp(40px, calc(40px + (var(--max-vw) - 768px) * 0.025), 40.635px);
  }
}


@media (min-width: 1024px) {
  .ragazzi-bestsellers__view-all {
    min-width: clamp(87.37px, calc(163.82px * (var(--max-vw) / var(--vw-base))), 163.82px);
    padding-block: clamp(6.77px, calc(12.698px * (var(--max-vw) / var(--vw-base))), 12.698px);
    padding-inline: clamp(21.67px, calc(40.635px * (var(--max-vw) / var(--vw-base))), 40.635px);
  }
}


/* ============================================================================
   ADAPTATION — Dawn reconciliation. Nothing above this line is ours.
============================================================================ */

/* 1. The gutter and the width cap. Dawn puts `page-width` on the title wrapper
      and on the slider separately, and it means 5rem of padding inside a
      `--page-width` (1200px by default) box. The design's container is 1920 wide
      with the site gutter. Both `page-width` rules are (0,1,0), so a (0,2,0)
      scoped rule settles it — unlike the announcement bar, nothing here reaches
      (0,5,1), so the class can stay on the elements and keep doing its job for
      any Dawn markup that shows up inside.

      `width: 100%` is the part that is easy to miss and was measured: the design
      section is a flex COLUMN, and `.page-width`'s `margin: 0 auto` turns into
      an auto margin on a flex item — which absorbs the free space and shrinks
      the item to its content instead of stretching it. The heading came out 544
      wide and centred in a 1140 row. */
.ragazzi-bestsellers .page-width {
  width: 100%;
  max-width: 1920px;
  padding-left: var(--sp-gutter);
  padding-right: var(--sp-gutter);
}

/* 2. Dawn's `.grid` is a wrapping flex list with its own gaps and a 2rem bottom
      margin, and `.grid__item` carries a percentage width plus a 50% max-width
      that would cap the cards at half the row. The design's track is a
      non-wrapping scroller whose items are sized by a token. `flex-wrap` and
      `max-width` are the two that survive the carried rules above, because those
      set neither.

      `margin-block`, not `margin-bottom`: the track is a `<ul>`, and Dawn's
      `.grid` zeroes its padding and its bottom margin but never the browser's
      own `1em` TOP margin — the static never saw it because that site resets
      every element's margin globally, which this theme deliberately does not do
      outside our own sections. Measured 16px of it between the heading and the
      cards. */
.ragazzi-bestsellers .product-grid {
  flex-wrap: nowrap;
  margin-block: 0;
}

.ragazzi-bestsellers .grid__item {
  max-width: none;
}

/* 3. Dawn spaces the heading with margins in FOUR places — `.title-wrapper`
      (3rem), `.collection__title.title-wrapper` (2.5rem), `.title` itself
      (`3rem 0 2rem`) and, in template-collection.css,
      `.collection__title .title:not(:only-child) { margin-bottom: 1rem }` — all
      of which would stack on top of the section's own 60px flex gap. The gap is
      the design's mechanism; the margins go.

      The fourth one is a TRAP worth naming: `:not(:only-child)` means it lies
      dormant while the heading is alone in the wrapper and switches itself on
      the moment anything joins it — which is exactly what adding the VIEW ALL
      pill does. It landed as 10px of bottom margin under the h2, which pushed
      the flex row 10px taller than the heading and dropped the bottom-aligned
      pill 10px below the heading's baseline box. At (0,3,0) it outranks the pair
      above, so it needs a rule at its own weight; ragazzi-bestsellers.css is
      linked after template-collection.css, so the tie goes our way. */
.ragazzi-bestsellers .collection__title,
.ragazzi-bestsellers .title {
  margin: 0;
}

.ragazzi-bestsellers .collection__title .title {
  margin: 0;
}

/* 4. Dawn's heading sizes come from the `heading_size` setting as `.h0`–`.h5`
      classes, each with its own font-size, and its base heading rule adds
      tracking and `word-break: break-word`. The design has one heading size,
      from its own token. `.ragazzi-bestsellers .title` above is (0,2,0) and
      beats every one of them for the properties it sets; these two it does not
      set, so they are reset here — the same pair the header needed. */
.ragazzi-bestsellers .title {
  letter-spacing: normal;
  word-break: normal;
}

/* 6. The section's colour scheme paints a background and a text colour on the
      wrapper. The design's section is Pattern A — no section background, black
      on the page's own ground — and the card sets its own colours. Left as a
      merchant control it would silently repaint the cards' surfaces. */
.ragazzi-bestsellers.gradient {
  background: var(--color-bg);
  color: var(--color-text);
}

/* ============================================================================
   THE PRODUCT RAIL: NO REVEAL ON THE CARDS, AND NO VERTICAL SCROLL.

   Reported as "the sliders are clipped in height on mobile and get a vertical
   scroll they should not have". This section is the one the user pointed at, and
   it is a SEPARATE case from the rail template even though the cause is the
   same - which is why the first fix, written against `.slides-blocks`, never
   touched it. Here the rail is Dawn's `slider-component` wrapping
   `ul.product-grid`, and the design gives that UL `overflow-x: auto`.

   Cause: each `li.grid__item` carries Dawn's `scroll-trigger animate--slide-in`,
   whose resting state is `transform: translateY(2rem)`. The item is exactly as
   tall as the rail, so the 20px translate pushes its bottom past the content
   box; and because the rail declares `overflow-x: auto`, the other axis computes
   to `auto` too, so those 20px become a real vertical scroll. Measured at 390px
   on the live store: 21px of vertical overflow, gone to 1px once the transform
   is cancelled.

   NOT cancelled globally for `.product-grid`: the SAME class is the static grid
   on /collections, where `overflow-x` is `visible`, nothing scrolls, and the
   reveal is wanted. Scoped to this section's rail only - checked both.

   The last 1px is sub-pixel rounding on a fractional card height, not content.
   `overflow-y: hidden` absorbs it so a rounding difference can never put a
   scrollbar back; with the transform gone there is nothing left to clip -
   verified, the first card's bottom sits exactly on the rail's.
============================================================================ */
.ragazzi-bestsellers slider-component .scroll-trigger.animate--slide-in,
.ragazzi-bestsellers slider-component .scroll-trigger.animate--fade-in {
  animation: none;
  opacity: 1;
  transform: none;
}

.ragazzi-bestsellers slider-component .product-grid {
  overflow-y: hidden;
}
