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

   The section it dresses is DAWN'S OWN `collection-list`, which is already the
   right data model: one block per collection, each rendering that collection's
   image, title and URL. Its blocks, columns, colour scheme, padding, view-all
   and mobile-slider settings are untouched; the card comes from
   snippets/ragazzi-collection-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; our card snippet renders them.
     .category                ->  .ragazzi-category .collection-list-wrapper
     .category__head          ->  .ragazzi-category .title-wrapper-with-link
     .category__title         ->  .ragazzi-category .collection-list-title
     .category__subtitle      ->  unchanged (a new element, see the section)
     .category__cards         ->  .ragazzi-category .collection-list
     .category__card…         ->  unchanged

   ONE DELIBERATE DEVIATION, marked `PORT:` below: the photographs become real
   <img> elements instead of CSS backgrounds, and the four hand-derived crop
   percentages become the image's own focal point. The static's own comment
   explains those percentages were converted from each Figma node's
   `imageTransform` — they describe two specific bitmaps, not whatever a
   merchant sets as a collection image.
============================================================================ */

/* ---------------------------------------------------------------------------
   SECTION TOKENS — carried verbatim, in the static's own band order.
--------------------------------------------------------------------------- */
.ragazzi-category {
  --c-black:         #000000;
  --c-ink:           #161616;
  --c-white:         #ffffff;
  --fw-card-label:   500;
  --lh-110:          1.1;
  --sp-head-gap:     clamp(13px, calc(25px * (var(--max-vw) / var(--vw-base))), 25px);
  --sp-section-y:    clamp(53px, calc(100px * (var(--max-vw) / var(--vw-base))), 100px);
  --text-card-label: clamp(13px, calc(25px * (var(--max-vw) / var(--vw-base))), 25px);
}

@media (max-width: 767px) {
  .ragazzi-category {
    --fw-card-label:   600;
    --sp-head-gap:     clamp(9px, calc(10px + (var(--max-vw) - 375px) * 0.015), 20px);
    --sp-section-y:    clamp(34px, calc(40px + (var(--max-vw) - 375px) * 0.015), 82px);
    --text-card-label: clamp(12px, calc(14px + (var(--max-vw) - 375px) * 0.015), 29px);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .ragazzi-category {
    --fw-card-label:   600;
    --sp-head-gap:     clamp(10px, calc(10px + (var(--max-vw) - 768px) * 0.025), 25px);
    --sp-section-y:    clamp(40px, calc(40px + (var(--max-vw) - 768px) * 0.025), 100px);
    --text-card-label: clamp(14px, calc(14px + (var(--max-vw) - 768px) * 0.025), 25px);
  }
}

/* ============================================================
   category.css — page-order section 3.
   Figma 3080:13536 (desktop, 1920 frame) / 3080:14078 (mobile, 375 frame).

   Mobile-first: base rules are the 375 layer; 768 flips the ARRANGEMENT
   (direction + aspect-ratio, which must move together — D-11), 1024 carries the
   discrete desktop type values.
============================================================ */

.ragazzi-category .collection-list-wrapper {
  /* ---- section-local spacing tokens, MOBILE band (slice §2.4) ---- */
  --sp-cat-block-gap:   clamp(17px, calc(20px + (var(--max-vw) - 375px) * 0.015), 41px);
  --sp-cat-card-gap:    clamp(9px,  calc(10px + (var(--max-vw) - 375px) * 0.015), 20px);
  --sp-cat-label-pad-x: clamp(17px, calc(20px + (var(--max-vw) - 375px) * 0.015), 41px);
  --sp-cat-label-pad-y: clamp(9px,  calc(10px + (var(--max-vw) - 375px) * 0.015), 20px);
  --sp-cat-label-h:     clamp(30px, calc(35px + (var(--max-vw) - 375px) * 0.015), 72px);

  /* Longhand only. A `padding` shorthand here would replace the container's
     horizontal gutter with 0 and send the section full-bleed (pitfall #8). */
  padding-block: var(--sp-section-y);
  background-color: var(--c-white);
}

/* ---------- Head block: 3080:14079 / 3080:13537 ----------
   Figma is a vertical auto-layout, alignItems MIN, gap 10 mobile / 25 desktop. */
.ragazzi-category .title-wrapper-with-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-head-gap);
}

/* 3080:14080 / 3080:13538 — Onest 500, line-height 110%, letter-spacing 0,
   #000000 on both layers. Size is the page token. */
.ragazzi-category .collection-list-title {
  font-family: var(--font-body);
  font-size: var(--text-h2);
  font-weight: 500;
  line-height: var(--lh-110);
  color: var(--c-black);
}

/* 3080:14081 / 3080:13539 — Onest 400, #000000. line-height is 120% on mobile
   and 110% on desktop; that is a measured per-layer difference (D-7), not drift. */
.ragazzi-category .category__subtitle {
  font-family: var(--font-body);
  font-size: var(--text-body-lg);
  font-weight: 400;
  line-height: var(--lh-120);
  color: var(--c-black);
}

/* ---------- Cards row/stack: 3080:14082 / 3080:13540 ----------
   Mobile is a vertical stack, gap 10, alignItems MIN. The head-to-cards gap
   (20 mobile / 60 desktop) is carried by a margin here rather than a flex gap on
   the section, so the section stays a block box and both children keep the full
   content width. Never both. */
.ragazzi-category .collection-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-cat-card-gap);
  margin-top: var(--sp-cat-block-gap);
}

/* ---------- Card: 3080:14083 / 14087 (M) · 3080:13541 / 13545 (D) ----------
   justifyContent MAX in Figma pushes the single child (the label bar) to the
   bottom edge. alignItems MIN on the PARENT means the card does not inherit the
   stack's cross size, so it needs an explicit width: 100% in the column band
   (D-10). The ratio itself changes per layer — 0.74944 mobile, 0.79999 desktop
   (D-4) — and switches at 768 together with the direction.

   PORT: `position: relative` and `overflow: hidden` are ours, to hold and clip
   the <img> that replaced the background-image. */
.ragazzi-category .category__card {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  width: 100%;
  aspect-ratio: 335 / 447;
  background-repeat: no-repeat;
  /* BA-2: Figma ships one static state, so this is a deliberate accessible
     default, not a Figma value. */
  transition: filter 0.3s ease;
  position: relative;
  overflow: hidden;
}

.ragazzi-category .category__card:hover {
  filter: brightness(0.95);
}

/* PORT: replaces the static's per-card background rules. Their percentages are
   the FD-52 conversion of each Figma node's `imageTransform` — they describe two
   specific bitmaps and would crop a merchant's collection image at random. The
   image's own focal point is the same intent in data the merchant controls, and
   an <img> can carry a srcset where a background cannot. */
.ragazzi-category .category__card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--card-image-position, 50% 50%);
}

/* ---------- Label bar: 3080:14084 / 14088 (M) · 3080:13542 / 13546 (D) ----------
   Flush to the card's bottom and to both side edges, over the photo; a DOM child
   of the card, not a sibling and not an absolute overlay (D-10). width: 100%
   because the card is alignItems MIN too. Desktop's 96.51 height is NOT a hug
   (30.48 + 28 + 30.48 = 88.95), so min-height + centring reproduces Figma's own
   34.25px inner offset.
   `position: relative` only so the bar paints above the photo. */
.ragazzi-category .category__card-label {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--sp-cat-label-h);
  padding-block: var(--sp-cat-label-pad-y);
  padding-inline: var(--sp-cat-label-pad-x);
  background-color: var(--c-ink);
  position: relative;
}

/* 3080:14086 / 14090 (M) · 3080:13544 / 13548 (D) — Onest, #ffffff, 110%.
   The weight is 600 mobile / 500 desktop, which --fw-card-label already encodes;
   take it from the token, never hard-code it. letter-spacing is 0 on all four
   labels.
   nowrap is measured, not invented: 88 + 20 + 20 = 128 <= 335 mobile and
   155 + 30.48 * 2 = 215.96 <= 843.17 desktop. A second line would grow the bar
   and break the card's pinned aspect ratio. */
.ragazzi-category .category__card-label-text {
  font-family: var(--font-body);
  font-size: var(--text-card-label);
  font-weight: var(--fw-card-label);
  line-height: var(--lh-110);
  letter-spacing: 0;
  color: var(--c-white);
  white-space: nowrap;
}

/* ============================================================
   768+ — the ARRANGEMENT switch (brief §7.2 / §7.3, D-11).
   flex-direction and aspect-ratio move together. Never 1024 — at 1023 in column
   mode a 0.8-ratio card would be ~1176px tall and jump ~600px at the boundary.
============================================================ */
@media (min-width: 768px) {
  .ragazzi-category .collection-list-wrapper {
    --sp-cat-block-gap:   clamp(20px, calc(20px + (var(--max-vw) - 768px) * 0.025), 60px);
    --sp-cat-card-gap:    clamp(10px, calc(10px + (var(--max-vw) - 768px) * 0.025), 30.48px);
    --sp-cat-label-pad-x: clamp(20px, calc(20px + (var(--max-vw) - 768px) * 0.025), 30.48px);
    --sp-cat-label-pad-y: clamp(10px, calc(10px + (var(--max-vw) - 768px) * 0.025), 30.48px);
    --sp-cat-label-h:     clamp(35px, calc(35px + (var(--max-vw) - 768px) * 0.025), 96.51px);
  }

  /* SPACE_BETWEEN on 3080:13540, alignItems MIN. No flex-wrap: the two cards
     provably fit (843.17 * 2 + 30.48 = 1716.82 <= 1720) and must stay side by
     side at every width above 768. */
  .ragazzi-category .collection-list {
    flex-direction: row;
    justify-content: space-between;
  }

  /* flex: 1 1 0 builds the row at the full 1720 content width instead of the
     1716.83 hug -> 844.76 per card at 1920, +0.19% (D-3). NOT capped with
     max-width: 843.17px — a hardcoded D-base max-width caps fluid scaling. */
  .ragazzi-category .collection-list__item {
    flex: 1 1 0;
  }

  .ragazzi-category .category__card {
    aspect-ratio: 843.17 / 1053.97;
  }
}

/* ============================================================
   1024+ — the discrete desktop TYPE values (D-7 / D-11). The fluid sizes need no
   switch; their three-band clamps already cross both edges.
============================================================ */
@media (min-width: 1024px) {
  /* Without this band the five section-local values stay on the 768
     pseudo-tablet formula all the way to 1920 and under-report: measured 63.8px
     for the 96.51px label bar and 48.8px for the 60px head-to-cards gap. */
  .ragazzi-category .collection-list-wrapper {
    --sp-cat-block-gap:   clamp(32px, calc(60px    * (var(--max-vw) / var(--vw-base))), 60px);
    --sp-cat-card-gap:    clamp(16px, calc(30.48px * (var(--max-vw) / var(--vw-base))), 30.48px);
    --sp-cat-label-pad-x: clamp(16px, calc(30.48px * (var(--max-vw) / var(--vw-base))), 30.48px);
    --sp-cat-label-pad-y: clamp(16px, calc(30.48px * (var(--max-vw) / var(--vw-base))), 30.48px);
    --sp-cat-label-h:     clamp(51px, calc(96.51px * (var(--max-vw) / var(--vw-base))), 96.51px);
  }

  /* 3080:13539 is 110%, its mobile counterpart 3080:14081 is 120% — real. */
  .ragazzi-category .category__subtitle {
    line-height: var(--lh-110);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ragazzi-category .category__card {
    transition: none;
  }
}

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

/* 1. The gutter and the width cap, exactly as in ragazzi-bestsellers.css:
      Dawn's `page-width` means 5rem inside a 1200px box, the design's container
      is 1920 with the site gutter. `width: 100%` is load-bearing — the wrapper
      is not a flex item here, but the same `margin: 0 auto` would still centre a
      shrink-to-fit box if anything above ever makes it one. */
.ragazzi-category .page-width {
  width: 100%;
  max-width: 1920px;
  padding-left: var(--container-pad);
  padding-right: var(--container-pad);
}

/* 2. Dawn's `.grid` is a wrapping flex list with its own gaps, a 2rem bottom
      margin and a `<ul>`'s browser top margin; `.grid__item` carries a
      percentage width and a 50% max-width. The design's row is two cards that
      share the width. Same set the bestsellers track needed, for the same
      reasons. */
.ragazzi-category .collection-list {
  flex-wrap: nowrap;
  margin-bottom: 0;
}

/* 2b. …and Dawn gives the same list a SECOND gutter below 750px:
       `.section-collection-list .collection-list:not(.slider)
        { padding-left: 1.5rem; padding-right: 1.5rem }`.
       The section already carries the design's gutter on `.page-width` (rule 1),
       so this one is added on top of it: measured at 390px, the wrapper padded
       correctly to 20.225 and then the list took 15px more from each side,
       leaving the card 304.6 wide where the design draws it edge to edge inside
       the gutter (335 of 375, i.e. 349.55 at 390). That is the reported extra
       padding, and it is mobile-only because Dawn's rule is.

       Needs `ul` + `:not(.slider)` to outrank it: Dawn's selector is (0,3,0) and
       rule 2 above is only (0,2,0), so extending that block would silently lose.
       No media query here — Dawn sets no other padding on this list at any
       width, so "this section's list never has a gutter of its own" is the whole
       truth and cannot drift out of step with Dawn's breakpoint. */
.ragazzi-category ul.collection-list:not(.slider) {
  padding-inline: 0;
}

.ragazzi-category .collection-list__item {
  max-width: none;
}

/* 3. Dawn's heading block: `.title-wrapper-with-link` is a horizontal
      space-between row with a 3rem bottom margin, and `.collection-list-title`
      brings the `.h0`–`.h5` size, Dawn's tracking and `word-break: break-word`.
      The design's head is a vertical stack whose gap is its own token, and the
      space below it belongs to the cards' `margin-top`.

      IT ALSO CARRIES THE SAME 1.5rem MOBILE GUTTER AS THE LIST (rule 2b), from a
      different Dawn rule: the section renders the wrapper with
      `title-wrapper--self-padded-mobile`, and base.css pads that class by 1.5rem
      until 750px. Two rules, one mistake — Dawn assumes a section whose own
      container is NOT padded and lets each part pad itself; this port pads once,
      on `.page-width`. Left in, the heading sat 15px inside the cards: measured
      at a 375 layout width, h2 and subtitle started at x=35.2 against the card's
      20.2. Zeroed here rather than in a fourth rule because it is the same
      element and the same reason as the margins above. */
.ragazzi-category .title-wrapper-with-link,
.ragazzi-category .collection-list-title {
  margin: 0;
}

.ragazzi-category .title-wrapper-with-link {
  padding-inline: 0;
}

.ragazzi-category .collection-list-title {
  letter-spacing: normal;
  word-break: normal;
}

/* 4. The whole card is one `<a>`, and outside our own sections this theme does
      not carry the static's global `a { text-decoration: none }`. */
.ragazzi-category .category__card {
  text-decoration: none;
}

/* 5. The section's colour scheme paints a background and a text colour on the
      wrapper. This section is white with black type and a near-black label bar,
      all of which the carried rules set themselves. */
.ragazzi-category.gradient {
  background: var(--color-bg);
  color: var(--color-text);
}
