/*
 * Values & vibes — sticky intro beside a scrolling list.
 *
 * Mechanism (reference `.template-service_how` audit, mirrored so the intro
 * sits on the right): two equal tracks of two grid columns each. The intro
 * track is a full-height grid item; its *child* is `position: sticky`, so the
 * panel travels with the section, pins under the chrome, and is pushed back
 * up when the track's bottom reaches it. No JS, no scroll listener.
 *
 * Edges follow _specs/LAYOUT.md §7: every box is .ui-framed, the boxes touch
 * with no gap or margin, and neighbours therefore share one hairline. Do not
 * add `overflow: hidden` to any wrapper here — the 1px overhang is required.
 */
.values-section {
  /* Clears the fixed menu button: the chrome's top padding, one module for the
   * button itself, and a gap. */
  --values-sticky-top: calc(
    var(--chrome-padding-block) + var(--ui-module) + var(--space-s-m)
  );

  /* Bottom padding is omitted: the footer already supplies its own top
   * margin, so a bottom pad here would double the gap above it. */
  padding-top: var(--space-2xl-3xl);
}

.values-section__intro,
.values-section__item {
  --ui-frame-color: var(--wp--preset--color--off-black);

  /* Same translucent surface as the hero and the video frame, so the
   * background hairlines stay faintly visible through the panels. The audit's
   * cards are opaque; this is a deliberate house deviation. */
  background-color: color-mix(
    in srgb,
    var(--wp--preset--color--off-white) 70%,
    transparent
  );
  padding: var(--panel-padding);
}

/* Two classes deep on purpose: .ui-framed also declares `position: relative`
 * and this component's stylesheet is not guaranteed to load after main.css. */
.values-section__intro-track > .values-section__intro {
  position: sticky;
  top: var(--values-sticky-top);
  text-align: center;
}

/* On a short window every pixel of the offset is a pixel the panel loses, so
 * the breathing gap under the button is dropped and the panel pins directly
 * below it. */
@media (max-height: 779px) {
  .values-section {
    --values-sticky-top: calc(var(--chrome-padding-block) + var(--ui-module));
  }
}

.values-section__heading {
  text-wrap: balance;
  text-transform: uppercase;
}

/*
 * Static badge above the card list, right-aligned so it sits on the edge the
 * two tracks share. Same construction as the video section's film badge: the
 * off-white magnetic button's tokens, but a plain box with no panel layer and no
 * hover. The hairline comes from .ui-framed, so the badge shares one line with
 * the first card below it (LAYOUT.md §7). The icon is an <img> because the
 * file carries its own SMIL animation, which an inlined icon would lose.
 */
.values-section__head {
  display: flex;
  justify-content: flex-end;
}

/* The panel centres its text; the illustration is deliberately left-aligned,
 * so it takes the free margin on the right only. */
.values-section__image {
  display: block;
  /* The third term is the one that keeps the sticky panel usable: a pinned box
   * taller than the space under its offset never shows its own bottom, so the
   * illustration is capped against the viewport height as well as the panel
   * width. It only bites on a short window; from ~870px tall the 260px cap
   * wins and the image is at full size. */
  width: min(50%, 260px, 30vh);
  height: auto;
  margin-top: var(--space-m-l);
  margin-inline-end: auto;
}

.values-section__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.values-section__item {
  display: flex;
}

.values-section__number {
  flex: 0 0 3em;
  padding-inline-end: 1em;
  text-align: center;
  font-size: var(--step-0);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  font-family: var(--font-label);
}

.values-section__body {
  /* Fixed basis: with inline-size containment the body has no content width
   * of its own, so it must take the free space explicitly. */
  flex: 1 1 0%;
  min-width: 0;
  container-type: inline-size;
}

/* The title shrinks only when its longest word would not fit the card:
 * „PROJEKTOWANIE” is 9.34em wide in Montserrat Bold capitals, so 100cqi / 9.6
 * keeps it on one line (and the „w standardzie” no-break pair, 8.76em).
 * Where there is room the step size wins. Raise 9.6 if a longer word is
 * added — overflow-wrap below would split it again. Measured at 1024px
 * (two narrow card columns) and on phones. */
.values-section__title {
  font-size: min(var(--step-2), 100cqi / 9.6);
  font-weight: var(--fw-bold);
  line-height: 1.2;
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  overflow-wrap: break-word;
}

/* Phones: the number moves above the title so the title gets the card's
 * full width (step 2 then fits from ~360px). */
@media (max-width: 639px) {
  .values-section__item {
    flex-direction: column;
    gap: var(--space-2xs);
  }

  .values-section__number {
    flex: none;
    padding-inline-end: 0;
    text-align: start;
  }
}

.values-section__body > p {
  margin-top: var(--space-s-m);
  font-size: var(--step-0);
  line-height: 1.6;
}

/* Four columns: the list holds 1-2 and the intro 3-4. Both tracks are pinned
 * to row 1 because grid auto-placement is sparse — it never moves the cursor
 * backwards, so the list (starting at column 1, after an item that ends at
 * column 5) would otherwise drop to a second row. Pinning the row also lets
 * the intro track stretch to the list's height, which is what gives the
 * sticky panel its travel. */
@media (min-width: 1024px) {
  .values-section__intro-track,
  .values-section__list-track {
    grid-row: 1;
  }
}


/* Stacked layout, below 1024px: the panel is full width, so the illustration
 * moves over to the right-hand column instead of the left, and the cog badge
 * — decorative, and stranded on its own row once the tracks stack — is
 * dropped. `display: none` on the badge's own row keeps the card list flush
 * with the panel above it. */
@media (max-width: 1023px) {
  .values-section__image {
    margin-inline: auto 0;
  }

  .values-section__head {
    display: none;
  }
}

/* Below 1024px both tracks span the whole two-column grid and stack, so the
 * intro's parent is only as tall as the intro itself and sticky has nothing
 * to travel through. Turning it off keeps the behaviour explicit. It falls
 * back to `relative`, not `static`: .ui-framed's right/bottom hairlines are
 * absolutely positioned and need this box as their containing block. */
@media (max-width: 1023px) {
  .values-section__intro-track > .values-section__intro {
    position: relative;
    /* `relative` still honours `top`, which would push the panel down over
     * the first card while its layout box stayed put. */
    top: auto;
  }
}
