/* ============================================================
   Our work: the hang (WP-17, the her-site wave stage 2; design brief § 5.5,
   plan § 7.2; recomposed by the 2026-11-20 shine pass, seat `work`).
   Loaded by src/components/pages/Work.astro.

   Every colour, face, size and gap is a token from chishan.css :root; no hex
   here. The parts (SectionHead, StoryCard, Photo, Lightbox) are placed, not
   restyled, except where a rule below says so for this page.
   ============================================================ */

/* ---- Hero: the h1, and beside it the wall's index (her three row labels) ---- */
.work-hero { padding-block: var(--s-9) var(--s-8); }
.work-hero-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--grid-gap);
  align-items: start;
}
.work-head { grid-column: 1 / span 7; max-width: none; margin-bottom: 0; }
.work-index { grid-column: 8 / span 5; }
.work-index ul { list-style: none; border-bottom: 1px solid var(--line); }
.work-index li { border-top: 1px solid var(--line); }
.work-index-link {
  display: flex; align-items: center;
  min-height: 52px; padding-block: var(--s-2);
  font-family: var(--label);
  font-size: var(--t-label); line-height: var(--lh-label);
  letter-spacing: var(--track-label); font-weight: 500;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: underline; text-decoration-color: transparent;
  text-decoration-thickness: 1px; text-underline-offset: 5px;
  transition: text-decoration-color var(--dur-hover) var(--ease);
}
.work-index-link:hover { text-decoration-color: var(--brass-deep); }
@media (prefers-reduced-motion: reduce) { .work-index-link { transition: none; } }

/* ---- Sections: the schools share the hero's paper; the rows alternate band and paper ---- */
.work-sec { padding-block: var(--section-y); }
.work-schools { padding-top: 0; }
.work-sec-head { margin-bottom: var(--s-8); }

/* ---- The schools: the first story hung as a set ----
   The lead photo on columns 1–5 at 4/5 (519 × 649 at 1440; drawn 973 wide, under her
   file's 1280 max); her words on columns 7–12 from the top, and the pair of squares
   (302 px at 1440) at the foot, level with the lead photo's foot. */
.work-set {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--grid-gap);
}
.work-set-lead { grid-column: 1 / span 5; min-width: 0; }
.work-set-side {
  grid-column: 7 / span 6; min-width: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  gap: var(--s-7);
}
.work-set--alone .work-set-side { grid-column: 1 / span 8; }
.work-set-words .story-label { padding-top: var(--s-1); }
.work-set-words .story-title { text-wrap: balance; }
.work-set-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--grid-gap); align-items: start; }
.work-set-pair--one { grid-template-columns: minmax(0, 1fr); }

/* Her Chinese summary breaks at its punctuation or a space, never inside a word (一起 split
   across two lines at 1440); a clause too long for its line still breaks, so nothing overflows */
.work-schools .story-summary:lang(zh) { word-break: keep-all; overflow-wrap: anywhere; }

/* Each further school story: a feature across the wall, alternating sides */
.work-feature { margin-top: var(--s-10); }
.work-feature .story-title { text-wrap: balance; }

/* ---- A row of the hang (events, gatherings): her label, heading and lede, then the line ---- */
.work-row-label { margin-bottom: var(--s-6); }

/* A line: each tile grows by its ratio from a zero basis, so every photo in the line is drawn
   at the same height; the line's width is capped (--hang-max) so a row of small files or one
   lone tile is not drawn too large */
.work-hang {
  display: flex;
  align-items: flex-start;
  gap: var(--grid-gap);
  max-width: var(--hang-max, none);
}
.work-hang + .work-hang { margin-top: var(--s-8); }
.work-tile { flex: var(--r, 1.5) 1 0; min-width: 0; }

/* The tile's words, as the carry sets them for this page */
.work-tile .story-title { font-size: var(--t-h4); line-height: var(--lh-h4); font-weight: var(--w-h4); text-wrap: balance; }
.work-tile .story-summary { max-width: 30em; font-size: var(--t-small); line-height: var(--lh-small); color: var(--ink-soft); }

/* A one-line row that stays narrow under its cap (gatherings today) hangs beside its head:
   the head on columns 1–4, the line filling columns 5–12 — no row stops part-way across */
@media (min-width: 1200px) {
  .work-row--side .work-row-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--grid-gap);
    align-items: start;
  }
  .work-row--side .work-row-head,
  .work-row--side .work-row-label { grid-column: 1 / span 4; max-width: none; margin-bottom: 0; }
  .work-row--side .work-lines { grid-column: 5 / span 8; min-width: 0; }
  .work-row--side .work-hang { max-width: var(--hang-side, none); }
}

/* ---- 761–1199: a line of three hangs as two lines at ONE height. The first two tiles
   share the width by ratio; the third hangs under them at the same height (its --tw is
   its ratio over the pair's, so its width gives the pair's height). ---- */
@media (min-width: 761px) and (max-width: 1199px) {
  .work-hang--split { flex-wrap: wrap; max-width: none; row-gap: var(--s-8); }
  .work-hang--split .work-tile { flex: none; width: calc((100% - var(--grid-gap)) * var(--tw, .5)); }
  /* The third tile does not stop part-way across: it takes the line, its photo at the pair's
     height and its words beside it at the photo's foot (at least 200 px of words; a photo
     that would leave less is drawn a little smaller) */
  .work-hang--split .work-tile:nth-child(3) { width: 100%; }
  .work-hang--split .work-tile:nth-child(3) .story-tile {
    display: grid;
    grid-template-columns: minmax(0, calc((100% - var(--grid-gap)) * var(--tw, .5))) minmax(200px, 1fr);
    column-gap: var(--grid-gap);
    align-items: end;
  }
  .work-hang--split .work-tile:nth-child(3) .story-body { margin-top: 0; }
  .work-set-lead { grid-column: 1 / span 6; }
}

/* ---- 761–1023: the index goes under the h1; the set's words sit beside the lead photo and
   the pair runs under both, so the narrow side column is not stretched into a tower ---- */
@media (min-width: 761px) and (max-width: 1023px) {
  .work-head, .work-index { grid-column: 1 / -1; }
  .work-index { margin-top: var(--s-6); max-width: calc((100% + var(--grid-gap)) * 7 / 12 - var(--grid-gap)); }
  .work-set-side { display: contents; }
  .work-set-lead { grid-row: 1; }
  .work-set-words { grid-column: 7 / span 6; grid-row: 1; align-self: start; }
  .work-set-pair { grid-column: 1 / -1; grid-row: 2; margin-top: var(--s-5); }
}

/* ---- Phone: one column; each photo full width at its own ratio (2/3 becomes 4/5); the
   set's pair side by side ---- */
@media (max-width: 760px) {
  .work-hero { padding-block: var(--s-8) var(--s-7); }
  .work-hero-grid { display: block; }
  .work-index { margin-top: var(--s-6); }
  .work-index-link { min-height: 48px; }
  .work-sec-head { margin-bottom: var(--s-6); }
  .work-set { display: block; }
  .work-set-side { display: block; margin-top: var(--s-5); }
  .work-set-pair { margin-top: var(--s-6); gap: var(--s-3); }
  .work-feature { margin-top: var(--s-8); }
  /* her caption under the photo, then air before the story's own label */
  .work-feature > .story-body { margin-top: var(--s-6); }
  .work-hang { flex-direction: column; gap: var(--s-7); max-width: none; }
  .work-hang + .work-hang { margin-top: var(--s-7); }
  .work-tile { flex: none; width: 100%; }
}
