/* .news-card — one post in the Latest News stack (News spec D6). Its place comes from one number,
   --d, its distance from the front (approach A, decision 27). Right of the front (d > 0): each card
   --shrink smaller than the one before, scaled from its left edge (.origin-left in the HTML), over
   the one before by --overlap. Left (d < 0): --strips thin strips, smaller and tilted; the rest hide
   (opacity 0) exactly under the last strip, so a click there lands on that strip (plan design
   call 15).
   One-job settings are utilities in the HTML (home.html.erb), not here: the card as a column whose
   body takes the room the tallest card leaves (flex flex-column, flex-grow on the stack; A8), its
   clipped corners (overflow-hidden), its lifted background (bg-raised), the body's top and bottom padding
   (padding-top-md, padding-bottom-lg) and the room over Read more (padding-bottom-xs on the summary:
   the stack's gap plus --space-xs, D6). The date is a <small>: the global role gives it one step
   under body text and the muted colour (the approved mockup's, decision 14). */

/* Registered so the controller reads a card's target place as px, a number and an angle. */
@property --x {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --s {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

@property --r {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

/* primitive tried: none places items by an index or overlaps them in one cell (no composition). */
.news-card {
  --d: calc(var(--i, 0) - var(--front, 0)); /* both written inline: the server's --i, the controller's --front */
  --right: max(var(--d), 0);
  --left: clamp(-1 * var(--strips), var(--d), 0);
  --x: calc(var(--right) * (var(--card-w) - var(--overlap)) - var(--right) * (var(--right) - 1) / 2 * var(--shrink) * var(--card-w) + var(--left) * var(--strip));
  --s: calc(1 - var(--right) * var(--shrink) + var(--left) * var(--strip-shrink));
  /* lint-allow: restated(--r) — only strips (left of the front) tilt, and at first load there are none; news_test "strips left of the front tilt" fails without it (deleted 2026-11-23; before, news_mockup_match_test.rb, 2026-11-20) */
  --r: calc(clamp(0, -1 * var(--d), 1) * var(--tilt));
  --inset: clamp(0, var(--d), 1); /* 1 on cards to the right of the front: their left edge is covered */
  grid-area: 1 / 1;
  transform: translateX(calc(var(--shift, 0px) + var(--x))) scale(var(--s)) rotate(var(--r));
  z-index: calc(10 - max(var(--d), -1 * var(--d)));
  /* lint-allow: restated(opacity) — hides strips past the second, which exist only from the 3rd post on; news_test "phones show one strip" fails without it (deleted 2026-11-23; before, news_mockup_match_test.rb, 2026-11-20) */
  opacity: clamp(0, var(--strips) + 1 + var(--d), 1);
  transition: transform var(--news-move), opacity var(--news-move), z-index var(--news-move), border-color var(--transition-fade), outline-color var(--transition-fade), box-shadow var(--transition-fade); /* keeps .glow's fade: this rule wins over the utility */
  container-type: inline-size; /* the picture's 100cqi: the card's own width */
  color: var(--text-muted); /* date and summary (decision 14); .more green by its role */
  /* Every card casts a faint teal glow down and right, lit from the top left (decision 25; the approved
     mockup's offsets as steps, its 0.2 as --alpha-20). The front card's lit border and glow are the
     shared .glow's ("lit", glow.css), which wins over this. */
  box-shadow: var(--space-xs) var(--space-2xs) var(--space-lg) calc(-1 * var(--space-xs)) hsl(var(--color-blue-base-hsl) / var(--alpha-20));
}

/* A card behind takes a click (decision 8): a pointer; its picture and text a step darker, never the
   chip (decision 11, O1: the dim is on the img, not the frame). The cards behind are the ones the
   server and controller mark aria-hidden (A10), so no :not(front): the restated lint cannot force a
   state inside :not() (it cuts the selector at [data-state). */
.news-card[aria-hidden="true"] {
  cursor: pointer;
}

.news-card[aria-hidden="true"] :is(img, .stack) {
  filter: brightness(0.7);
}

.news-card :is(img, .stack) {
  transition: filter var(--transition-fade);
}

/* A lit card reads fully: full brightness, white date and summary (decision 24). Under a mouse, or
   keyboard focus inside it, as the shared .glow lights. Two selectors, not :is(:hover, …): the restated
   lint forces hover on the selector cut at ":hover", and ".news-card:is(" matches nothing. */
@media (hover: hover) and (pointer: fine) {
  .news-card:hover :is(img, .stack),
  .news-card:has(:focus-visible) :is(img, .stack) {
    filter: none;
  }

  .news-card:hover :is(time, p),
  .news-card:has(:focus-visible) :is(time, p) {
    color: var(--color-white);
  }
}

/* 5/6 of the card's width, less --space-xs (Mitchell, 2026-11-18: 10px from the photo to Read more).
   The frame composition crops the img (object-fit: cover). With a set height its 16:9 ratio would
   make the frame 16/9 of that wide (614px at 1440, measured 2026-11-20); the card's flex column
   stretches it to the card's width instead. */
.news-card .frame {
  block-size: calc(100cqi * 5 / 6 - var(--space-xs));
}

/* The kind, a pill on the picture's top-left corner (D6, decisions 13, 25, 28; Mitchell, 2026-11-23:
   "inside of a pill"): place, padding, corners, teal, navy text and weight are utilities in the HTML.
   On cards to the right it clears the card in front (decision 30.6); an Announcement is orange. */
.news-card .frame > span {
  margin-inline-start: calc(var(--overlap) * var(--inset));
}

.news-card .frame > [data-kind="announcement"] {
  background-color: var(--color-orange-base);
}

/* Text never under the card in front of it: the padding moves to the covered side, so the text box
   keeps one width and every card keeps one height as the front moves (plan design call 13). */
.news-card > .stack {
  min-block-size: var(--news-card-body-min);
  padding-inline: calc(var(--space-s) + var(--overlap) * var(--inset)) calc(var(--space-s) + var(--overlap) * (1 - var(--inset)));
}

/* One step up from the role (D6). White: the card is muted for its date and summary, and an h3 has
   no colour of its own (it inherits the body's white); the mockup's title is white. */
.news-card h3 {
  font-size: var(--step-2);
  color: var(--color-white);
}

.news [data-state~="snap"] :is(.news-card, .cluster, [data-more="below"]) {
  transition: none; /* a resize jumps (plan design call 20) */
}
