/* .news — Latest News (News spec D5-D7). The stage (the stack's box) holds every knob the cards
   read (news-card.css) and the two values the news controller writes: --front and --shift. */

/* Read by the controller in px (registered, so its computed value is a length; unregistered it
   would read back as the step's clamp() text). */
@property --floor-gap {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

.news {
  overflow: clip; /* cards to the right run off the page: the cut card is the peek (D7). Both axes: stylelint's
     layout mappings refuse overflow-x, and overflow-inline's Safari support is not checked; nothing
     overflows the section above or below (the stage's padding holds the tilt and glow) */
}

/* primitive tried: with-sidebar; meets it (column beside the stack, above it on phones, A1). The
   column's ~20rem is the composition's own default (the mockup's 20rem). The gap is a step over
   the framework's --gutter (--space-s-md): the mockup's --space-xl. The column sits mid-height
   (D6): items-center in the HTML. */
.news .with-sidebar {
  --sidebar-gap: var(--space-xl);
}

/* The header sits --space-s higher (Mitchell, 2026-11-18, "move up more about 20px") and the
   button one step further down than the header's own gaps (D6; the mockup's inline
   --stack-space-before on the button's div: globals.css, section header > div). Higher by room below it, not a translate: centred
   beside the stack, 2 × --space-s below lifts it by one; on phones, where it tops the section, a
   translate pushed the title out of the section's clip (Mitchell, phone 2026-11-24: "cut off"). */
.news header {
  padding-block-end: calc(2 * var(--space-s));
}

/* The stage. Its knobs: the card's width (the named size, or the stage less a step), how far each
   card covers the one before, the strips' width and count, the shrink per card and per strip, the
   strips' tilt (the mockup's 1.5deg, 0.07, 0.04, 2), the floor's gap from the letters (the
   mockup's --min-gap, recorded as --space-xl) and the move (the mockup's 520ms curve; the arrows
   follow it at T12). Spaces are steps (design call 14). Room above and below for the tilted strips
   and the glow (the mockup's --space-xl): padding-y-xl in the HTML. */
.news .with-sidebar > div {
  --card-w: min(var(--news-card-w), 100cqi - var(--space-xl));
  --overlap: var(--space-lg);
  --strip: var(--space-s-md);
  --strips: 2;
  --shrink: 0.07;
  --strip-shrink: 0.04;
  /* lint-allow: restated(--tilt) — at first load no card is left of the front, so nothing is tilted; news_test "strips left of the front tilt" fails without it (deleted 2026-11-23; before, news_mockup_match_test.rb, 2026-11-20) */
  --tilt: -1.5deg;
  /* lint-allow: restated(--floor-gap) — read by the news controller only once strips show (front > 0); news_test "the floor" fails without it (deleted 2026-11-23; before, news_mockup_match_test.rb, 2026-11-20) */
  --floor-gap: var(--space-xl);
  --news-move: 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
  container-type: inline-size; /* the cards' 100cqi: the stage's width */
  touch-action: pan-y pinch-zoom; /* up and down stays the page's scroll, pinch still zooms; sideways is the stack's swipe (D7) */
}

/* primitive tried: stack, reel; fail: both lay the cards out one after another. One shared grid
   cell overlaps them (each card's grid-area, news-card.css), and the cell is as tall as the
   tallest card (A8). The cell is one card wide, at the stage's left edge; the cards to the right
   run past it. */
.news ol {
  display: grid;
}

/* The list, the arrows and the phones' View all news are one card wide: the arrows and the link
   sit centred under the front card and move with it by the controller's --shift (Mitchell,
   2026-11-18, 2026-11-23: "centred under the cards"; 2026-11-24: the link "centered underneath the
   arrows"); centred by justify-center in the HTML. */
.news :is(ol, .cluster, [data-more="below"]) {
  inline-size: var(--card-w);
}

.news :is(.cluster, [data-more="below"]) {
  translate: var(--shift, 0px) 0;
  transition: translate var(--news-move);
}

.news .cluster {
  font-size: var(--step-2); /* the arrows one step up, as the approved mockup has them; margin-top-md in the HTML */
}

/* Phones: one strip (decision 30.7) and the mockup's phone room (4rem; --space-2xl the nearest
   step). primitive tried: the stage's min() card width alone; fails: it cannot drop the second
   strip. The stage is a size container, so its own width decides (news.md, T9: the width table).
   Set on the list and the arrows: their own width and the cards read them. */
@container (width < 30rem) {
  .news :is(ol, .cluster, [data-more="below"]) {
    --strips: 1;
    --card-w: calc(100cqi - var(--space-2xl));
  }
}

/* View all news: in the column, or under the arrows once the column sits above the stack (phones;
   Mitchell, 2026-11-24: "two buttons, that's all"). The news controller marks the section
   "wrapped", exactly where the layout wraps; without it the column's link shows. The hidden one is
   display: none, so screen readers and Tab meet one. */
.news [data-more="below"],
.news[data-state~="wrapped"] [data-more="column"] {
  display: none;
}

.news[data-state~="wrapped"] [data-more="below"] {
  display: flex; /* its link centred by justify-center in the HTML */
}

/* Once wrapped, the cards sit --space-lg under the paragraph (Mitchell, phone 2026-11-24: "too much
   space", then "even less … maximum use of the vertical available space"; then --space-md was
   "about ten pixels" too tight: --space-lg, 32px at 390, the same as the teal line to the paragraph,
   the section head's own gap in globals.css, as he asked): no lift room under the
   header, no tilt-and-glow room over the stage (the gap above is inside the section, so its clip
   cuts nothing), and the stage pulled up into the column gap. The gap itself stays: with-sidebar
   wraps by it, so changing it once wrapped could unwrap. */
.news[data-state~="wrapped"] header {
  padding-block-end: 0;
}

.news[data-state~="wrapped"] [data-news-target="stage"] {
  padding-block-start: 0;
  margin-block-start: calc(var(--space-lg) - var(--space-xl)); /* --space-xl: the column gap (--sidebar-gap above; registered non-inheriting, so not readable here) */
}
