/* ============================================================
   Synergy Sales Group: stagepages.css (Contractors and Work)
   Only what these two pages need on top of core.css and components.css:
   0. the small print of a last scene
   1. .sp-placed  a film hung by measurement, so its subject stands clear of a block of small lines
   2. .sp-rows    Contractors "The leaks": five rows beside the dripping tap
   3. .sp-lists   Contractors "The rules": two short lists beside the row of helmets
   4. the same two scenes on a phone
   5. .sp-still   Work: a screenshot as the subject of its scene
   Standard film scenes are core.css's; two films get one correction each here (the plumb bob's
   frame edge, the hourglass's place in a narrow window). Colours and type come from the tokens
   and role classes in core.css. Gaps are 8, 16, 24, 40 or 64px. No boxes, no rules, no second
   colour. The hooks are set on the scene by js/pages/contractors.js and js/pages/work.js.
   ============================================================ */

/* ---------- 0. The last scene's small print ---------- */
/* There is no footer on a stage page. In a wide window on the stage the small print is the
   bottom line of the last scene: one line after the readout, where a client film carries its
   label. Anywhere it would need a second line (under 1200px, the same as the home page) it is
   the last line under the text block instead, 24px under the action.
   The page scripts set it after the block, not inside it: stage.js measures the block for the
   shade behind the words, and a line that sits in the bottom bar would stretch that shade
   across the picture. */
.scene__body > .sp-small { margin-top: var(--s3); max-width: 34rem; text-wrap: balance; }
@media (min-width: 700px) and (max-width: 999.98px) {
  .scene__body > .sp-small { max-width: 27.5rem; }
}
@media (min-width: 700px) and (max-height: 640px) {
  html.has-stage .scene__body > .sp-small { margin-top: var(--s2); max-width: 34rem; }
}
@media (min-width: 1200px) {
  html.has-stage .scene__body > .sp-small {
    position: absolute; bottom: 24px; margin: 0;
    left: calc(var(--pad) + var(--readout-w, 13rem) + var(--s4));
    right: calc(var(--pad) + 3 * 44px + 2 * var(--s1) + var(--s3));
    max-width: none;
  }
}

/* The plumb-bob film carries a thin dark frame edge round the picture (rounded corners, two
   notches on the left). The film is shown a little over its box, so the edge is never in view. */
.scene__media > .media[data-key="plumb"] > video { inset: -4.5%; width: 109%; height: 109%; }

/* The hourglass stands in the right third of its film. A window narrower than the film crops
   it from both sides and would cut the hourglass at the window's edge, so on the stage the film
   leans to the right, and the words keep to a narrower measure so they end short of the glass. */
html.has-stage .scene__media > .media[data-key="hourglass"] > video { object-position: 72% 50%; }
html.has-stage .scene:has(> .scene__media > .media[data-key="hourglass"]) .scene__text > .t-display { max-width: 10em; }
html.has-stage .scene:has(> .scene__media > .media[data-key="hourglass"]) .scene__text > .t-lead { max-width: 23em; }

/* ---------- 1. A film hung by measurement ---------- */
/* The page script measures the words and writes the film's left, top and width in px (--fx,
   --fy, --fw). Contractors (contractors.js): the dark part of the frame lies under the words
   and the subject stands beside them. Work's closing scene (work.js): the projector's beam
   passes above the words. */
html.has-stage .sp-placed > .scene__media > .media > video {
  inset: auto; left: var(--fx, 0px); top: var(--fy, 0px);
  width: var(--fw, 100%); height: auto; aspect-ratio: 1928 / 1076;
}
/* When the film cannot fill the scene and keep its subject clear, it is set smaller in the
   upper right, above the words, and its left side and foot fade into the ground.
   --band-keep: how far down the film stays whole before it fades. --band-top: a film that
   does not start at the window's top edge fades in over this much. */
html.has-stage .sp-placed--band > .scene__media > .media > video {
  -webkit-mask-image:
    linear-gradient(to right, transparent 0, var(--ink) 36%),
    linear-gradient(to bottom, transparent 0, var(--ink) var(--band-top, 0%), var(--ink) var(--band-keep, 60%), transparent 96%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent 0, var(--ink) 36%),
    linear-gradient(to bottom, transparent 0, var(--ink) var(--band-top, 0%), var(--ink) var(--band-keep, 60%), transparent 96%);
  mask-composite: intersect;
}
/* a window so small that the film would be a scrap in the corner: the scene goes without it */
html.has-stage .sp-placed--none > .scene__media > .media > video { visibility: hidden; }
/* the projector: its lens sits lower in the frame, and it may hang a little below the frame's links */
.sp-placed--low { --band-keep: 72%; --band-top: 6%; }
/* the side shade core.css lays under a block of small lines is not needed over a film that
   already keeps its dark side under them (it would only dim the subject); the bottom shade
   stays, and so does the shade core.css lays behind the words themselves */
html.has-stage .sp-placed > .scene__media > .media::after {
  background: linear-gradient(to top,
    rgb(var(--ink-rgb) / 0.86) 0,
    rgb(var(--ink-rgb) / 0.84) 56px,
    transparent 30%);
}

/* ---------- 2. Five rows beside the tap ---------- */
/* A page set like a ledger entry: the statement, then five rows on two fixed edges. Every name
   starts on the page edge and every line starts on one second edge, 40px after the longest
   name, so the two columns read as columns. The rows stand 24px apart at every stage size. */
.sp-rows .scene__text { gap: var(--s4); }
.sp-rows .scene__text > .actions { margin-top: 0; }
@media (min-width: 700px) {
  .sp-rows .rows {
    grid-template-columns: max-content minmax(0, 28rem);
    column-gap: var(--s4); row-gap: var(--s3);
    width: auto; max-width: 100%;
  }
  .sp-rows .rows > li { grid-column: 1 / -1; grid-template-columns: subgrid; column-gap: var(--s4); }
  .sp-rows .rows__line { max-width: none; }
  html.has-stage .sp-rows .scene__text--wide .rows { row-gap: var(--s3); }
}
/* a narrower stage: the second edge moves in so every line still fits on one line */
@media (min-width: 700px) and (max-width: 1099.98px) {
  .sp-rows .rows, .sp-rows .rows > li { column-gap: var(--s3); }
}
/* a short stage: the three parts close up before the rows do */
@media (min-width: 700px) and (max-height: 760px) {
  html.has-stage .sp-rows .scene__text { gap: var(--s3); }
}
/* the shortest stage (560 to 640px tall): the block may start right under the frame, the
   statement may run on one line, and the rows stand 16px apart (8px where the window is also
   so narrow that the lines need two lines each) */
@media (min-width: 700px) and (max-height: 640px) {
  html.has-stage .stage > .scene:is(.sp-rows, .sp-lists) > .scene__body { padding-top: var(--frame-h); }
  html.has-stage .sp-rows .scene__text { gap: var(--s2); }
  html.has-stage .sp-rows .scene__text > .t-display { max-width: none; }
  html.has-stage .sp-rows .scene__text--wide .rows { row-gap: var(--s2); }
}
@media (min-width: 700px) and (max-width: 799.98px) and (max-height: 640px) {
  html.has-stage .sp-rows .scene__text--wide .rows { row-gap: var(--s1); }
}

/* ---------- 3. Two short lists beside the helmets ---------- */
/* In the film the wall is dark on the left and the lamp and the helmets run off to the right.
   The lists are two narrow columns that keep to the dark. */
.sp-lists .scene__text { gap: var(--s4); }
.sp-lists .scene__text > .actions { margin-top: 0; }
@media (min-width: 700px) {
  .sp-lists .lists { grid-template-columns: repeat(2, minmax(0, 15rem)); column-gap: var(--s4); width: auto; }
}
/* a narrower stage: the columns close up, so the lamp and the first helmets stay in the window */
@media (min-width: 700px) and (max-width: 999.98px) {
  .sp-lists .lists { grid-template-columns: repeat(2, minmax(0, 13rem)); column-gap: var(--s3); }
}
@media (min-width: 700px) and (max-height: 760px) {
  html.has-stage .sp-lists .scene__text { gap: var(--s3); }
}
/* the shortest stage: the columns take their full width again (fewer lines), since height is
   what is short there */
@media (min-width: 700px) and (max-height: 640px) {
  html.has-stage .sp-lists .scene__text { gap: var(--s2); }
  html.has-stage .sp-lists .lists { grid-template-columns: repeat(2, minmax(0, 15rem)); }
}

/* ---------- 4. The same two scenes on a phone ---------- */
/* Stacked, these two are set the way core.css sets every standard film scene on a phone: the
   picture above (the room the words leave, never less than a third of the screen), fading into
   the ground 64px under the first line, and the words below it on the dark. contractors.js
   writes which part of the film is kept in view (--film-x, --film-y on the picture). */
html.has-flow .sp-placed {
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(34svh, 1fr) auto;
}
html.has-flow .sp-placed > .scene__media {
  position: relative; inset: auto; grid-area: 1 / 1;
  margin-bottom: calc(-1 * var(--s5));
  -webkit-mask-image: linear-gradient(to bottom, var(--ink) 0, var(--ink) 50%, rgb(var(--ink-rgb) / 0.6) 70%, rgb(var(--ink-rgb) / 0.2) 87%, transparent 100%);
  mask-image: linear-gradient(to bottom, var(--ink) 0, var(--ink) 50%, rgb(var(--ink-rgb) / 0.6) 70%, rgb(var(--ink-rgb) / 0.2) 87%, transparent 100%);
}
html.has-flow .sp-placed > .scene__body { grid-area: 2 / 1; min-height: 0; padding-top: 0; }
html.has-flow .sp-placed .media > video { object-position: var(--film-x, 50%) var(--film-y, 50%); }
html.has-flow .sp-placed > .scene__media > .media::after { content: none; }

/* ---------- 5. A screenshot as the subject of its scene ---------- */
/* A visitor comes to this page to see the work, so the picture is the scene. It is shown as
   large as the window allows and never larger than the file (so it is always sharp), and it is
   lit like film: dark until the lamp is on it, with a bright page taken down so it does not
   glare (--sp-dim, set from the picture's own brightness by work.js).
   work.js wraps the picture (.sp-pic > .sp-crop > img), crops the file's own black margins
   (--crop-*), and writes on the scene: --still-w / --still-h (the picture's size in px) and, on
   the stage, --sp-w (the width it is shown at), --sp-words (the height of the words) and --sp-yw
   (where the words begin, measured from the picture's top). */
.sp-still {
  --sp-top: calc(var(--frame-h) + var(--s2));
  --sp-foot: calc(var(--s5) + var(--s3));
  --sp-r: max(var(--pad), calc(var(--index-edge) + var(--index-tick) + var(--s2)));   /* the page edge, clear of the index ticks */
}
/* the picture is its own ground: no shade is laid over it, along the bottom or behind the words
   (the words stand on the dark ground here, not on the picture) */
.sp-still > .scene__media > .media::after,
.sp-still > .scene__media .lamp::after { content: none; }
.sp-still .sp-crop { position: relative; overflow: hidden; aspect-ratio: var(--still-w) / var(--still-h); }
.sp-still .sp-crop > img {
  display: block; max-width: none; height: auto;
  width: var(--crop-w, 100%); margin: var(--crop-y, 0) 0 0 var(--crop-x, 0);
}
/* a bright page is taken down by a veil of the ground's own colour (a filter on a picture that
   arrives late was not always painted) */
.sp-still .sp-crop::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: rgb(var(--ink-rgb) / var(--sp-dim, 0));
}
/* a dark page: what is left of its own black falls away into the ground */
.sp-still--dark .sp-crop > img { mix-blend-mode: lighten; }
/* the pool of light is wider here, so a whole page reads at once */
.sp-still .lamp { --_r: calc(var(--lr, max(24vmax, 420px)) * 1.7); }
.sp-still .scene__text > .t-lead { max-width: 62ch; }

/* Stacked (phones): the picture comes first, as tall as the file or about half the screen, and
   wider than the screen: a strip the visitor pans sideways. The words follow underneath, and
   the two together stand at the foot of the scene like every other text block. */
.sp-still { display: flex; flex-direction: column; justify-content: flex-end; }
.sp-still > .scene__media { position: relative; inset: auto; flex: none; padding-top: var(--sp-top); }
.sp-still > .scene__media > .media { position: relative; inset: auto; }
.sp-still .sp-pic {
  display: flex; overflow-x: auto; overflow-y: hidden;
  padding-left: var(--pad);
  overscroll-behavior-x: contain; scrollbar-width: none;
}
.sp-still .sp-pic::-webkit-scrollbar { display: none; }
.sp-still .sp-pic::after { content: ""; flex: 0 0 var(--pad); }
.sp-still .sp-pic:focus-visible { outline-offset: -3px; }
.sp-still .sp-crop { flex: none; height: min(var(--still-h) * 1px, max(46svh, 280px)); }
.sp-still > .scene__body { flex: none; min-height: 0; padding-top: var(--s4); }

/* The stage. The picture layer covers the whole scene, so the lamp follows the pointer
   everywhere as on film; the picture is one box in it. */
html.has-stage .stage > .scene.sp-still { display: block; container-type: size; }
html.has-stage .stage > .scene.sp-still > .scene__media { position: absolute; inset: 0; padding: 0; }
html.has-stage .stage > .scene.sp-still > .scene__media > .media { position: absolute; inset: 0; }
html.has-stage .stage > .scene.sp-still > .scene__body { justify-content: flex-end; }
html.has-stage .sp-still .sp-pic {
  position: absolute; display: block; overflow: visible; padding: 0;
  left: var(--pad); top: var(--sp-top);
  width: var(--sp-w, min(var(--still-w) * 1px, 100cqw - var(--pad) - var(--sp-r)));
}
html.has-stage .sp-still .sp-pic::after { content: none; }
html.has-stage .sp-still .sp-crop { height: auto; width: 100%; }

/* over: the picture hangs under the frame on the left edge and the words stand below. Where
   the words begin, the foot of the picture dissolves into the dark, like a page that carries on. */
html.has-stage .sp-still:not(.sp-still--side, .sp-still--strip) .sp-pic {
  --_y: var(--sp-yw, 62cqh);
  -webkit-mask-image: linear-gradient(to bottom,
    var(--ink) 0, var(--ink) calc(var(--_y) - 80px),
    rgb(var(--ink-rgb) / 0.4) calc(var(--_y) - 40px),
    rgb(var(--ink-rgb) / 0.1) calc(var(--_y) - 8px),
    rgb(var(--ink-rgb) / 0.03) calc(var(--_y) + 24px),
    transparent calc(var(--_y) + 56px));
  mask-image: linear-gradient(to bottom,
    var(--ink) 0, var(--ink) calc(var(--_y) - 80px),
    rgb(var(--ink-rgb) / 0.4) calc(var(--_y) - 40px),
    rgb(var(--ink-rgb) / 0.1) calc(var(--_y) - 8px),
    rgb(var(--ink-rgb) / 0.03) calc(var(--_y) + 24px),
    transparent calc(var(--_y) + 56px));
}

/* a short stage: the words step down a size and close up, so the picture keeps its room */
@media (min-width: 700px) and (max-height: 760px) {
  html.has-stage .sp-still .scene__text { gap: var(--s2); }
  html.has-stage .sp-still .scene__text > .t-display {
    font-size: clamp(1.6rem, 2.7vw, 2.5rem); line-height: 1.14; max-width: none;
  }
}

/* a strip: whole, on the left edge, above the words */
html.has-stage .sp-still--strip .sp-pic {
  top: auto; bottom: calc(var(--sp-foot) + var(--sp-words, 40cqh) + var(--sp-gap, var(--s4)));
}

/* side: the words are a narrow column on the left, set a size down (the title role's size),
   and the picture stands whole to the right of them on the same bottom line. */
html.has-stage .sp-still--side .sp-pic {
  left: auto; right: var(--sp-r); top: auto; bottom: var(--sp-foot);
}
html.has-stage .sp-still--side .scene__text {
  max-width: calc(100cqw - var(--pad) - var(--sp-r) - var(--s4) - var(--sp-w));
}
html.has-stage .sp-still--side .scene__text > .t-display {
  font-size: clamp(1.6rem, 2.7vw, 2.5rem); line-height: 1.14; max-width: none;
}
html.has-stage .sp-still--side .scene__text > .t-lead { max-width: none; text-wrap: pretty; }
html.has-stage .sp-still--side .facts > * { white-space: normal; }

/* ---------- Where a number came from ---------- */
/* One small line under the facts of a scene that quotes a study (Who I build for). */
.scene__text > .sp-source { font-size: 0.8125rem; line-height: 1.45; max-width: 44ch; }
