/* ==========================================================================
   THE PDP DISCOVERY RAIL — "Discover more / You may also like"
   --------------------------------------------------------------------------
   Owner instruction, 8 September 2026, ruling J-27, implemented as RC-97.
   Product page only: functions.php enqueues this sheet inside
   korotana_enqueue_product()'s is_singular( 'product' ) branch and nowhere
   else, and inc/render-rail.php refuses to render off a product page.

   MONCLER IS THE INTERACTION REFERENCE, NOT A STYLE SOURCE. Nothing here is
   copied from it: no colour, no type, no wording, no asset, no markup. What is
   reproduced is observable behaviour — one product at a time on a phone with a
   deliberate peek of the next, arrows at the outer ends of a row with a scrub
   between them, no dots, no counter, no autoplay.

   WHAT IS INHERITED RATHER THAN RESTATED. The card's media ratio is F-01's
   archived measurement and it is not repeated in this file: the rail renders
   the one Section 15 card, so `.k-pcard__frame` keeps collection.css's BASE
   rule — `aspect-ratio: 1 / 1` below 768 and `4 / 5` from 768 — the values F-01
   measured on the approved Louis Vuitton reference at 430 and at 768/1280/1440.
   A rail-local ratio would be a second source of a number the card already
   owns, and the two would disagree at the first breakpoint. The same goes for
   the card's transparent frame background, its `object-fit: contain` and its
   §15.5/§15.6 metadata split, all of which arrive with the component.

   J-41.1 (1 October 2026) takes the COLLECTION card to 4:5 at every width and
   does not reach this file: that ruling is written as `.k-col .k-pcard__frame`,
   and the rail renders inside `.k-pdp`, never inside `.k-col`. So the rail is
   still 1:1 below 768, which is still what F-01 measured, and `rail.spec.js`
   still pins both regimes at five widths. RC-150.

   WHY THE TEXT IS NOT CENTRED. The reference centres name and price under the
   image. The KOROTANA card left-aligns them, on F-01's measured 16px/8px inset,
   and the owner's instruction is explicit that Moncler is "the
   interaction/behavior reference only" and that the component "should inherit
   KOROTANA typography, product data and visual language". Centring would fork
   the card's own text block for one surface. Divergence recorded in RC-97.
   ========================================================================== */

.k-discover {
  /*
   * GEOMETRY, AND WHERE EVERY NUMBER CAME FROM.
   *
   * --k-discover-visible  how many whole cards stand in the viewport.
   * --k-discover-peek     the fraction of the NEXT card left showing.
   * --k-discover-gap      the space between two cards.
   * --k-discover-gutter   the space before the first card and after the last.
   *
   * PEEK = 0.37 BELOW 768, MEASURED (Run 25, RC-98). Run 24 built this from
   * the Run 24 brief's prose — "roughly a fifth of the following card" — because
   * the reference frames were never supplied. They have since been re-extracted
   * at native resolution (384 x 848) and measured: the card slot runs from the
   * page gutter at x 15 to x 269.5 and the next card shows 94px, which is 37%
   * of a card, not 20%. The measurement validates itself on the product image
   * inside the slot — inset 29px left and 28.5px right, a symmetry that only
   * holds if the slot is where it was measured — and the card's text centre
   * (name 142.5, price 142.0) agrees with the slot centre (142.25) to within
   * half a pixel.
   *
   * IT STAYS AT 0.2 FROM 768. The recording is mobile only. There is no
   * measurement for 768 or 1200, so the mobile figure is not extrapolated
   * upward and the desktop peek keeps the Run 24 DEFAULT.
   *
   * VISIBLE = 1 / 3 / 4. One at phone widths is the reference itself. The two
   * desktop steps are chosen so the rail card lands beside the card width F-01
   * MEASURED on the approved reference at the same acceptance widths — 188.25
   * at 768, 316.25 at 1280, 356.25 at 1440 — rather than at a number invented
   * for this component: three cards give 203.75 at 768, four give 274.76 at
   * 1280 and 315.24 at 1440. G-03's two-per-row is a rule about the collection
   * GRID and is untouched from 768 up, which is every width these desktop steps
   * describe; a horizontal rail with a deliberate peek cannot be a two-column
   * grid and the instruction says so. DEFAULT.
   *
   * J-40 (30 September 2026) made the COLLECTION grid one-up below 768. It does
   * not reach this file: the rail is not a grid, it declares no column count,
   * and its below-768 figure is one visible card plus a peek — which is what the
   * one-up collection now shows too, so the two surfaces have moved closer
   * together rather than apart. The card's RATIO is still inherited and still
   * 1:1 below 768 and 4:5 from 768; J-40 changed no ratio anywhere.
   *
   * GAP = 21px BELOW 768, MEASURED (Run 25); --k-space-4 (16px) from 768.
   * The reference measures 20.5px between cards at 384. The token was one
   * declaration shared by every width, so it is SPLIT rather than pushed
   * upward: the measured figure applies where it was measured, and from 768 the
   * gap stays the 16px the two-column grid this rail replaces already used.
   *
   * GUTTER mirrors `.k-pdp__section`'s own padding-inline at each breakpoint —
   * 12 / 40 / 20 / 52 — because the rail bleeds out of that padding and has to
   * put it back. tests/phpunit/RailTest.php asserts the four values against
   * product.css so the two cannot drift. The reference's own page gutter is
   * 15px (3.9%); it is NOT adopted, because this gutter is bound to the PDP
   * section's and moving one without the other is the drift that test exists to
   * stop. Recorded in RC-98 as an available follow-up, not a defect.
   *
   * THE CONTROL ROW, ALSO MEASURED (Run 25). Run 24 set none of it: the row was
   * a flex line and the numbers fell out of it. All four are fractions of the
   * VIEWPORT, so they carry to every width without extrapolating a card count.
   *
   *   TRACK = 57.8% of the viewport, centred. 222px of 384, with 81px clear
   *   each side.
   *   ARROW INSET = 6.25%. The arrow CENTRES measure x 24 and x 360 of 384.
   *   That also reproduces the measured arrow-centre-to-track clearance:
   *   81 - 24 = 57px, and 360 - 303 = 57px.
   *   RAIL = 1px, FILL = 3px. The fill's LENGTH is not here and must never be:
   *   it is clientWidth / scrollWidth, written by rail.js as --k-scrub-width,
   *   which is data about the rail and not a style value.
   */
  --k-discover-visible: 1;
  --k-discover-peek: 0.37;
  --k-discover-gap: 21px;
  --k-discover-gutter: var(--k-gutter-mobile);
  --k-discover-track: 57.8%;
  --k-discover-arrow-inset: 6.25%;
  --k-discover-rail: var(--k-hairline);
  --k-discover-fill: 3px;
}

.k-discover__head { margin-bottom: var(--k-space-4); }
.k-discover__title { margin: 0; }

/*
 * The sub-heading, underlined as the reference shows it.
 *
 * TYPE IS BOUND, NOT INVENTED. `.kr-store-discover` is v4.0 §07's captured
 * "Store discover action" row — M12, 12/16, Medium 500, source case, 0
 * tracking — and it is the closed spec's only discover-labelled small role. The
 * underline is added HERE and not in fonts.css: §11 permits a colour, underline
 * or surface change and forbids a metric change, so a decoration belongs in the
 * component sheet and the metric stays in the one place TypographyTest reads.
 * The two underline values are the §05 LOCKED tokens.
 */
.k-discover__sub {
  margin: var(--k-space-2) 0 0;
  color: var(--k-graphite);
  text-decoration: underline;
  text-decoration-thickness: var(--kr-underline-weight);
  text-underline-offset: var(--kr-underline-offset);
}

/* ==========================================================================
   THE TRACK
   ========================================================================== */

/*
 * FULL BLEED, AND THE PEEK IS WHY.
 *
 * `.k-pdp__section` pads the rail on both sides. A peek has to run to the
 * viewport edge or it is not a peek — it reads as a clipped column inside a
 * margin — so the viewport steps back out of that padding and puts the same
 * value back as its own, which is what --k-discover-gutter holds.
 *
 * `scroll-padding-inline` makes the snap agree with that padding: without it a
 * snapped card sits under the left gutter instead of beside it.
 *
 * TOUCH-ACTION IS DELIBERATELY NOT DECLARED. 15.4's card gallery takes
 * `pan-y` because a script owns its horizontal axis; this rail has no such
 * script — the browser scrolls it — so the user agent keeps BOTH axes and
 * arbitrates them itself. That is exactly the behaviour the instruction asks
 * for: a mostly-vertical gesture scrolls the page, a mostly-horizontal one
 * moves the rail, and the decision is the platform's rather than a threshold
 * this file would have to guess. `overscroll-behavior-x: contain` stops a
 * flick that reaches the end from chaining outward.
 */
.k-discover__viewport {
  display: flex;
  gap: var(--k-discover-gap);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin-inline: calc(-1 * var(--k-discover-gutter));
  padding-inline: var(--k-discover-gutter);
  scroll-padding-inline: var(--k-discover-gutter);
}

.k-discover__viewport::-webkit-scrollbar { display: none; }

/*
 * THE SNAP IS SUSPENDED FOR THE LENGTH OF A SCRIPTED TRAVEL, AND ONLY THAT.
 * RC-37, measured again here, and it is the rule that makes the travel a
 * travel.
 *
 * `scroll-snap-type: x mandatory` is not a promise about scrolls the USER AGENT
 * drove. CSS Scroll Snap §5 requires the container to rest on a snap position
 * whenever no scrolling operation is in progress, and a `scrollLeft` assignment
 * is not a scrolling operation — it completes instantly, so the engine
 * re-snaps it on the spot. Measured on staging at 390 with the rail's own
 * instrument, in BOTH engines, before this rule existed:
 *
 *   chromium  0 0 0 0 0 318 318 318 …   (idle rAF cadence 17ms: healthy)
 *   webkit    0 0 0 318 318 318 …       (idle rAF cadence 15ms: healthy)
 *
 * Every eased position below the midpoint was read straight back as 0 and
 * every one above it as the whole card — the exact signature collection.css
 * records for the card track. The travel was not slow or dropped; it was
 * arbitrated away, and the run's own reduced-motion test would have passed for
 * the wrong reason.
 *
 * SUSPENDED, NOT REMOVED, AND NEVER AT REST. rail.js writes the attribute when
 * a travel starts and removes it after the final position is assigned, so the
 * mandatory rule is in force at every moment the rail is not being moved by
 * this file — which is what settles a finger, a wheel and a trackpad. The
 * destination is a card's own snap position, so restoring the rule at the end
 * moves nothing.
 */
.k-discover__viewport[data-korotana-rail-travelling] { scroll-snap-type: none; }

.k-discover__viewport:focus-visible {
  outline: var(--k-focus-ring) solid var(--k-ink);
  outline-offset: var(--k-focus-offset);
}

/*
 * THE CARD WIDTH, DERIVED RATHER THAN TYPED.
 *
 *   N·C + N·gap + peek·C = W − gutter
 *
 * where W is the viewport width and the right-hand side is what is visible
 * beyond the leading gutter: N whole cards, N gaps, and the peek. `100%` inside
 * a padded flex container resolves against the CONTENT box, which is
 * W − 2·gutter, so W − gutter is `100% + gutter`. Solving for C gives the
 * expression below. Change --k-discover-visible or --k-discover-peek at a
 * breakpoint and the width follows; no width is written anywhere.
 */
.k-discover__viewport > .k-pcard {
  flex: 0 0 calc(
    (100% + var(--k-discover-gutter) - var(--k-discover-gap) * var(--k-discover-visible))
    / (var(--k-discover-visible) + var(--k-discover-peek))
  );
  min-width: 0;
  scroll-snap-align: start;
}

/* ==========================================================================
   THE CONTROL ROW — arrow, scrub, arrow
   ========================================================================== */

/*
 * FULL BLEED, LIKE THE TRACK ABOVE IT, AND FOR THE SAME REASON.
 *
 * The measured arrow centres are 6.25% of the VIEWPORT — 24px of 384 — which is
 * inside `.k-pdp__section`'s own padding. A row laid out in the padded content
 * box cannot put a control there, so the row steps out of the padding exactly
 * as the viewport does and every figure below is a fraction of the full width.
 *
 * The arrows are taken out of flow and placed on their measured centres; the
 * scrub is the only thing left in the flex line, so `justify-content: center`
 * IS the "centred, equal clearance both sides" the measurement asks for, and
 * the clearance is arithmetic rather than a second pair of numbers.
 */
.k-discover__controls {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--k-touch-min);
  margin-top: var(--k-space-4);
  margin-inline: calc(-1 * var(--k-discover-gutter));
}

/*
 * §08 / 40.5: the target is 44px on BOTH axes, and the glyph is sized
 * independently. commerce.css records what happens when only one axis is set.
 * The focus ring is opt-in by class in this build — there is no universal
 * :focus-visible rule — so it is declared here rather than assumed.
 */
.k-discover__arrow {
  position: absolute;
  top: 50%;
  flex: 0 0 auto;
  min-width: var(--k-touch-min);
  min-height: var(--k-touch-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: 0;
  color: var(--k-ink);
  cursor: pointer;
}

/*
 * ON THE MEASURED CENTRE, not at a measured edge. `left`/`right` place the
 * inset and the translate moves the box back by half its own width, so the
 * 44px target grows around the centre the reference gives and the §08 hit area
 * is never traded for the geometry.
 */
.k-discover__arrow--prev {
  left: var(--k-discover-arrow-inset);
  transform: translate(-50%, -50%);
}

.k-discover__arrow--next {
  right: var(--k-discover-arrow-inset);
  transform: translate(50%, -50%);
}

.k-discover__arrow:focus-visible {
  outline: var(--k-focus-ring) solid var(--k-ink);
  outline-offset: var(--k-focus-offset);
}

/*
 * THE END STATE IS NOT CARRIED BY COLOUR ALONE (§02, §08).
 *
 * The control is really `disabled`: the click cannot fire, the name is still
 * announced, and assistive technology is told the state by the attribute. The
 * colour change is the visible half of a fact the markup already states, which
 * is the only way §08 permits colour to take part at all.
 */
.k-discover__arrow[disabled] {
  color: var(--k-stone);
  cursor: default;
}

.k-discover__chev {
  width: var(--k-icon);
  height: var(--k-icon);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--k-icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

/*
 * THE SCRUB IS PRESENTATIONAL. inc/render-rail.php marks it aria-hidden and
 * nothing is conveyed by it alone: the arrows carry the same fact
 * programmatically and the rail is fully operable with the scrub removed.
 *
 * The fill is positioned by two custom properties rail.js writes —
 * --k-scrub-width and --k-scrub-x — so the stylesheet keeps the geometry and
 * the script only supplies two numbers.
 */
/*
 * THE BOX IS THE FILL'S HEIGHT AND THE RAIL IS DRAWN INSIDE IT.
 *
 * The measurement gives a 1px rail under a 3px fill, so the two cannot both be
 * the element's own height. The box takes the fill's 3px and the rail is a
 * centred background line — a gradient rather than a pseudo-element, because
 * this file emits no generated content and RailTest asserts that.
 *
 * `flex: 0 0 var(--k-discover-track)` and nothing else: the width is the
 * measured fraction of the viewport and the flex line centres it.
 */
.k-discover__scrub {
  flex: 0 0 var(--k-discover-track);
  position: relative;
  height: var(--k-discover-fill);
  background: linear-gradient(var(--k-stone), var(--k-stone)) center center / 100% var(--k-discover-rail) no-repeat;
  overflow: hidden;
}

.k-discover__scrubfill {
  position: absolute;
  inset-block: 0;
  left: 0;
  display: block;
  width: var(--k-scrub-width, 100%);
  background: var(--k-ink);
  transform: translateX(var(--k-scrub-x, 0px));
}

/*
 * The travel is animated in rail.js against --k-motion-standard and
 * --k-ease-calm, so the scrub follows the real scroll position frame by frame
 * and needs no transition of its own. Under reduced motion the scroll is
 * instant and the fill lands with it. Nothing here animates, which is why
 * there is no prefers-reduced-motion branch in this file.
 */

/* ==========================================================================
   BREAKPOINTS — v4.0 §04's inclusive starts, and .k-pdp__section's gutters
   ========================================================================== */

/*
 * The two measured values are mobile-only and are handed back here, because the
 * recording they come from is mobile only. `--k-discover-visible` and the 1200
 * step are Run 24's reasoned DEFAULTs and Run 25 does not touch either.
 */
@media (min-width: 768px) {
  .k-discover {
    --k-discover-visible: 3;
    --k-discover-peek: 0.2;
    --k-discover-gap: var(--k-space-4);
    --k-discover-gutter: var(--k-gutter-desktop);
  }
}

@media (min-width: 992px) {
  .k-discover { --k-discover-gutter: var(--k-pdp-gutter); }
}

@media (min-width: 1200px) {
  .k-discover { --k-discover-visible: 4; }
}
