/* ============================================================
   Synergy Sales Group: home.css
   What the cover (scene 1), a grand scene (scene 2) and the price
   scene (scene 8) need. Scenes 3 to 7 are the shared film scene and
   are not touched here. Colours, type roles, gaps and every shared
   part (.btn, .link, .leaders, .actions, the lamp) come from
   core.css. Nothing here sets a raw colour, a font name, a box or a
   coloured word.

   These scenes place their film by hand instead of letting it be
   cropped to fit: the cover keeps the whole engraved logo in view,
   scene 2 keeps the lit movement clear of the statement, the price
   scene keeps the lit ledger clear of the list. The placement is
   measured with container units (cqw, cqh), so it holds on the
   stage and when scenes stack on a phone.
   ============================================================ */

/* ---------- 1. cover: two lasers carve the logo into dark steel (.cover--carve) ---------- */
/* The laser film is the whole picture of this scene (home.js builds it; no lamp lies over it:
   the film carries its own light). It is 1912 x 1080 (1.7704 : 1). In its last frame the
   engraving runs from 8.2% to 91.9% of the width (0.836 of it, centred) and from the peak of the
   mark, 17% down, to the foot of the motto, 77% down (0.60 of the height).

   The film is as large as these three allow, whichever is smallest:
     1. it fills the window (a wide desktop window);
     2. the engraved name runs from the page's left edge (--pad) to its right edge, so no
        letter is ever cut (a narrower or taller window, a phone);
     3. the logo, 24px and the words under it fit between the frame and the bottom line.
   Then the logo and the words are centred together in that height. The words start 24px under
   the foot of the motto (--words-top), so they never cover it.

   --cw, --ch: the scene's width and height (the scene is the container; stacked on a phone its
   height is the window's). --words: the height of the line and the two actions. */
#cover.cover--carve {
  container-type: inline-size;
  --cw: 100cqw;
  --ch: 100svh;
  --lead: clamp(1.1875rem, 1.45vw, 1.375rem);                 /* the size of .t-lead */
  --words: calc(1.5 * var(--lead) + var(--s2) + 44px);        /* one line, 16px, the actions */
  --top: calc(var(--frame-h) + var(--s3));
  --bot: var(--s5);
  --room: calc(var(--ch) - var(--top) - var(--bot) - var(--s3) - var(--words));
  --fw: min(max(var(--cw), 1.7704 * var(--ch)), (var(--cw) - 2 * var(--pad)) / 0.836, max(var(--room), 8.5rem) * 2.9507);
  --fh: calc(var(--fw) / 1.7704);
  --logo-top: calc(var(--top) + max(0px, var(--room) - 0.6 * var(--fh)) / 2);
  --ft: calc(var(--logo-top) - 0.17 * var(--fh));
  --words-top: calc(var(--logo-top) + 0.6 * var(--fh) + var(--s3));
}
html.has-stage #cover.cover--carve {
  container-type: size;
  --ch: 100cqh;
  --bot: calc(var(--s5) + var(--s3));   /* the bottom line: the readout and the round steps */
}
/* a narrow phone: the line takes two lines and the two actions stand one under the other */
@media (max-width: 519.98px) {
  #cover.cover--carve { --words: calc(3 * var(--lead) + var(--s2) + 96px); }
}

/* The film's box. Its four edges dissolve into the ground, so no rectangle shows in any window:
   a short fade on the left and right (the name begins 8.2% in), a longer one at the top (above
   the peak of the mark there is only smoke) and at the bottom, which begins right under the
   motto and takes the loose sparks down, so the words stand on dark steel. */
.cover-film {
  position: absolute;
  left: calc((var(--cw) - var(--fw)) / 2); top: var(--ft);
  width: var(--fw); height: var(--fh);
  --_x: linear-gradient(to right,
      transparent 0, rgb(var(--ink-rgb) / 0.5) 2.5%, var(--ink) 6%,
      var(--ink) 94%, rgb(var(--ink-rgb) / 0.5) 97.5%, transparent 100%);
  --_y: linear-gradient(to bottom,
      transparent 0, rgb(var(--ink-rgb) / 0.4) 6%, var(--ink) 15%,
      var(--ink) 79%, rgb(var(--ink-rgb) / 0.7) 84%, rgb(var(--ink-rgb) / 0.3) 90%, rgb(var(--ink-rgb) / 0.06) 96%, transparent 100%);
  -webkit-mask-image: var(--_x), var(--_y);
  -webkit-mask-composite: source-in;
  mask-image: var(--_x), var(--_y);
  mask-composite: intersect;
}
/* And each picture in the box is taken out along an ellipse centred on the name, so the box has
   no corner and no straight side to show. The ellipse is exactly as wide as the box when the box
   stands free in a wide window (the name's first and last letters are just inside it), and
   wider, so more of the lit steel shows, the further the box runs off the window's sides.
   (Its two radii are plain lengths: a browser may refuse a percentage mixed into them, and a
   refused mask is a bare rectangle. It is a rule of its own for the same reason.) */
.cover-film > * {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover;
  --_c: radial-gradient(
      ellipse calc(var(--fw) / 2 + 5 * max(0px, (var(--fw) - var(--cw)) / 2)) calc(0.6 * var(--fh)) at 50% 62%,
      var(--ink) 86%, transparent 100%);
  -webkit-mask-image: var(--_c);
  mask-image: var(--_c);
}
.cover-film > video { pointer-events: none; }

/* The end still (the film's last frame as a picture) lies over the film and is clear until the
   end state: then it is shown over the held last frame, or over whatever frame the film was
   stopped on (home.js brings it up with GSAP). On a page load without the film it is simply
   there. .is-in: the picture has arrived. */
.cover-film__end { opacity: 0; }
.cover--carve.is-done .cover-film__end.is-in, .cover--carve.is-still .cover-film__end { opacity: 1; }

/* Nothing of the stage darkens the engraving: no shade along the bottom of the picture (the
   film ends in its own fade), none behind the words (home.js: data-shade="off"), and none behind
   the index ticks, which stand over the film's dark right edge here. */
#cover.cover--carve > .scene__media > .media::after { content: none; }
html[data-page="home"][data-scene="cover"]:has(#cover.cover--carve) .stage-index::before { content: none; }

/* The words: centred under the engraving. They are hidden while the lasers work (.is-hush) and
   come up as the film finishes (home.js). */
#cover.cover--carve > .scene__body { justify-content: flex-start; padding-top: var(--words-top); }
#cover.cover--carve .scene__text { position: relative; margin: 0 auto; gap: var(--s2); }
#cover.cover--carve .scene__text > .t-lead { max-width: none; }
#cover.cover--carve .scene__text > .actions { margin-top: 0; }
.cover--carve.is-hush .scene__text > :is(.t-lead, .actions) { visibility: hidden; }

/* "Skip the film": one small plain link where the actions will be, for as long as they are hidden. */
.cover-skip {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: 1rem; white-space: nowrap;
}

/* A film with a choir (home.js, "the choir"). Before it starts the cover is the bare plate and
   two plain choices, the same button and link as any scene's actions, centred on the part of
   the plate the lasers will carve (from the peak of the mark to the foot of the motto, never
   less than 136px high, so the two fit one under the other on the narrowest phone). */
.cover-gate {
  position: absolute; left: var(--pad); right: var(--pad);
  top: var(--logo-top); height: calc(0.6 * var(--fh));
  margin: 0; justify-content: center; align-content: center;
}
/* The keyboard starts on "Enter" (home.js). Until a key has been used its focus shows as the
   lit ring of its circle alone; the outline joins it with the first key. */
html:not([data-input="keys"]) .cover-gate > .btn:focus-visible { outline: none; }

/* The sound control: one small plain link, the scene's last line, centred. On the stage that is
   the bottom line itself, between the readout and the round steps; stacked on a phone it stands
   in the 64px the cover keeps clear under its words. It never meets "Skip the film" or the
   actions, which end above that line. */
.cover-sound {
  position: absolute; left: 50%; bottom: var(--s1); transform: translateX(-50%);
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: 1rem; white-space: nowrap;
}
html.has-stage .cover-sound { bottom: var(--s2); }

/* ---------- 2. a grand scene (.scene--grand; `grand: true` in config.js) ---------- */
/* The standard film scene with its statement at the largest size on the site: one colour, one
   face, set solid (line-height 1) in a column about six of its own ems wide, so it stands as
   four short lines. On the stage the size also answers to the window's height, so the four
   lines, the lead and the action always fit between the frame and the bottom line. */
.scene--grand { --grand: clamp(3rem, 8.5vw, 9rem); }
html.has-stage .scene--grand { --grand: max(2.75rem, min(clamp(3rem, 8.5vw, 9rem), (100svh - 23.5rem) / 4.1)); }
.scene--grand .scene__text > .t-display { font-size: var(--grand); line-height: 1; max-width: 6.2em; }
.scene--grand .scene__text > .t-lead { max-width: min(44ch, 6.2 * var(--grand)); }

/* Scene 2, the clock movement (1928 x 1076, 1.792 : 1). The movement begins 42% across the
   picture; everything left of that is dark. The picture is placed by hand so the movement
   begins 40px to the right of the statement's column (--edge) and still covers the window:
   the words keep to the dark and the lit instrument stands beside them. (Stacked on a phone
   the film is a picture above the words: core.css.) */
@media (min-width: 700px) {
  #system.scene--grand > .scene__media { container-type: size; }
  #system.scene--grand .media > video {
    --edge: calc(var(--pad) + 6.2 * var(--grand) + var(--s4));
    --pw: max(179.2cqh, var(--edge) / 0.42, (100cqw - var(--edge)) / 0.58);
    --ph: calc(var(--pw) / 1.792);
    inset: auto;
    left: calc(var(--edge) - 0.42 * var(--pw));
    top: clamp(100cqh - var(--ph), 50cqh - 0.56 * var(--ph), 0px);
    width: var(--pw); height: var(--ph);
  }
}

/* ---------- 1b. the cover without the laser film (.cover--tower): the logo in the dark, the bulb beside it ---------- */
/* Used only when the cover scene has no `intro` in config.js. The clock-tower film, like the
   desk film of scene 8, is 1928 x 1076 (1.792 : 1). */
/* --beside: the dark kept between the logo's last letter and the lit iron frame of the film. */
#cover.cover--tower { --logo-w: min(52vw, 620px); --beside: clamp(40px, 3.4vw, 64px); }
#cover.cover--tower .lockup { width: var(--logo-w); }

/* The logo blends with the film (mix-blend-mode: screen, core.css), so the layer it sits in must
   not close itself off from the picture. The words under it stay above the logo's backlight. */
#cover.cover--tower > .scene__body { z-index: auto; }
#cover.cover--tower .scene__text > :is(.t-lead, .actions) { position: relative; }
/* when the one line has to wrap, it wraps into two even lines */
#cover.cover--tower .scene__text > .t-lead { text-wrap: balance; }

/* The artwork's lettering runs almost to its left and right edges, so its edges are taken out
   with a soft fade on each side (rounded at the corners) and none of the name is lost. */
#cover.cover--tower .brand--lockup {
  -webkit-mask-image:
    linear-gradient(to right, transparent, var(--ink) 6%, var(--ink) 94%, transparent),
    linear-gradient(to bottom, transparent, var(--ink) 7%, var(--ink) 93%, transparent),
    radial-gradient(ellipse farthest-corner at 50% 50%, var(--ink) 68%, transparent 96%);
  mask-image:
    linear-gradient(to right, transparent, var(--ink) 6%, var(--ink) 94%, transparent),
    linear-gradient(to bottom, transparent, var(--ink) 7%, var(--ink) 93%, transparent),
    radial-gradient(ellipse farthest-corner at 50% 50%, var(--ink) 68%, transparent 96%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

/* The clock-tower film. In the picture the bulb's glass is 69.1% across and 41.5% down, and the
   iron frame it hangs in begins 60.3% across. The frame's edge is set a little to the right of
   the logo's last letter (40px in a small window, 64px in a large one), so the logo lies over the
   dark, out-of-focus part of the room and the lit instrument stands beside it. --pw is the
   smallest picture that still covers the window then. */
#cover.cover--tower .scene__media { container-type: size; }
#cover.cover--tower .media > video {
  --edge: calc(50cqw + 0.42 * var(--logo-w) + var(--beside));
  --pw: max(179.2cqh, var(--edge) / 0.603, (100cqw - var(--edge)) / 0.397);
  --ph: calc(var(--pw) / 1.792);
  inset: auto;
  left: calc(var(--edge) - 0.603 * var(--pw));
  top: clamp(100cqh - var(--ph), 38cqh - 0.415 * var(--ph), 0px);
  width: var(--pw); height: var(--ph);
}

/* On the stage the words under the logo keep to the dark with it and never reach the lit iron
   frame (--edge above: the logo's last letter plus a gap). The line stops 24px short of the
   frame and wraps into two even lines when it has to; the two actions stop 12px short of it,
   and when they cannot, the link goes under the button. */
@media (min-width: 700px) {
  #cover.cover--tower .scene__text { --reach: calc(0.84 * var(--logo-w) + 2 * var(--beside)); }
  #cover.cover--tower .scene__text > .t-lead { max-width: min(40ch, var(--reach) - 48px); }
  #cover.cover--tower .scene__text > .actions { max-width: calc(var(--reach) - 24px); }
}

/* A phone: the bulb hangs on the centre line near the top, and the logo sits in its light.
   The logo is as large as the screen allows: its name runs from the left text edge to the right
   one. In the artwork the name starts 9.87% in and is 81.8% of its width, so the artwork itself
   is wider than the screen and its empty black sides hang off both edges (the scene clips them;
   the page does not scroll sideways). Lying on its side, a phone is short: the logo then keeps
   to 110% of the height. */
@media (max-width: 699.98px) {
  #cover.cover--tower { --logo-w: min((100vw - 2 * var(--pad)) / 0.818, 110svh); }
  #cover.cover--tower .lockup {
    max-width: none; justify-self: start;
    margin-left: calc((100% - 0.818 * var(--logo-w)) / 2 - 0.0987 * var(--logo-w));
  }
  /* At this size the name's last word and the motto lie over the lit brass wheel, so the dark
     behind the logo is held a little deeper and further out than on a wide screen (core.css
     .lockup::before: the same faint backlight, the same soft edge). */
  #cover.cover--tower .lockup::before {
    background:
      radial-gradient(closest-side, rgb(var(--glow) / 0.13), rgb(var(--glow) / 0.05) 50%, transparent 82%),
      radial-gradient(closest-side, rgb(var(--ink-rgb) / 0.9), rgb(var(--ink-rgb) / 0.8) 62%, transparent 100%);
  }
  #cover.cover--tower .media > video {
    --pw: max(245cqh, 162cqw);
    left: calc(50cqw - 0.691 * var(--pw));
    top: calc(20cqh - 0.415 * var(--ph));
  }
  /* the block starts 24px under the bulb's glass (which ends 28% down) instead of holding the centre */
  #cover.cover--tower .scene__text--center { margin: calc(28svh - var(--frame-h)) auto auto; }
}

/* ---------- 8. start: the price list on the dark wood, the ledger in the light ---------- */
/* The desk film. The open ledger's page begins 49% across the picture. When the window is
   narrower than the film the picture leans to the right of centre (--lean: how much of the
   overflow is cut from the left), which leaves the left half to the dark wood. Where that
   would leave the list less than its full 34rem column, the picture moves right as far as it
   can (its left edge on the window's) and the wood gets the room. */
#start { --lean: 0.3; }
#start .scene__media { container-type: size; }
#start .media > video {
  --pw: max(100cqw, 179.2cqh);
  --ph: calc(var(--pw) / 1.792);
  inset: auto;
  left: max((100cqw - var(--pw)) * var(--lean), min(0px, var(--pad) + 34rem + var(--s3) - 0.49 * var(--pw)));
  top: calc((100cqh - var(--ph)) / 2);
  width: var(--pw); height: var(--ph);
}

/* The list keeps to the wood: its column stops 24px short of the ledger's page. (The same
   sums as the picture above, in window units: on the stage the scene is the window.) */
@media (min-width: 700px) {
  #start > .scene__body {
    --pw: max(100vw, 179.2svh);
    --left: max((100vw - var(--pw)) * var(--lean), min(0px, var(--pad) + 34rem + var(--s3) - 0.49 * var(--pw)));
    --col: min(34rem, var(--left) + 0.49 * var(--pw) - var(--pad) - var(--s3));
  }
  #start .scene__text, #start .home-print { max-width: var(--col); }
}

/* The two actions share one line of the column: the link follows the button's circle at 24px. */
#start .scene__text > .actions { column-gap: var(--s3); }

/* a note that has to wrap never leaves one word alone on its last line */
#start :is(.scene__text > .t-small, .home-print) { text-wrap: balance; }

/* The small print is the last line of the scene. home.js sets it under the list's block, not
   inside it: core.css lays a shade behind the words of a scene's block, measured from the block,
   and that shade must not follow the small print along the bottom line and across the ledger.
   Under the block it keeps the block's own gap (24px; 16px in a short window; 8px in the
   shortest). In a wide window on the stage (1200px and up) it fits on one line and is the
   bottom line itself: it follows the readout, where a client film carries its label. */
#start .home-print { margin-top: var(--s3); }
@media (min-width: 700px) and (max-height: 760px) {
  html.has-stage #start .home-print { margin-top: var(--s2); }
}
@media (min-width: 700px) and (max-height: 639.98px) {
  html.has-stage #start .home-print { margin-top: var(--s1); }
}
@media (min-width: 1200px) {
  html.has-stage #start .home-print {
    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;
  }
}

/* A short window on the stage (a laptop with its toolbars open). --rest is what the frame, the
   bottom line, seven prices, the note and the actions need of its height (and the small print
   too, where it stands under the block). The statement takes what two lines can have of what
   is left, and below that it runs as one line across the column (it is 11em long). Never larger
   than its role. */
@media (min-width: 700px) and (max-height: 760px) {
  html.has-stage #start .scene__text { --rest: 589px; }
  html.has-stage #start .scene__text > .t-display {
    font-size: min(clamp(2.4rem, 5.6vw, 5.5rem), max(0.088 * var(--col), (100svh - var(--rest)) / 2.08));
  }
}
@media (min-width: 1200px) and (max-height: 760px) {
  html.has-stage #start .scene__text { --rest: 525px; }
}
/* The shortest stage (under 640px high): the column is too narrow there for both actions on one
   line, so something has to go, and it is the note about the fee: the same sentence opens the
   note of "What each one includes". The block also stands 16px nearer the bottom line and its
   parts close up to 8px (16px under the statement), so the statement stays clear of the frame. */
@media (min-width: 700px) and (max-height: 639.98px) {
  html.has-stage #start > .scene__body { padding-bottom: calc(var(--s5) + var(--s1)); }
  html.has-stage #start .scene__text { gap: var(--s1); }
  html.has-stage #start .scene__text > .t-display { margin-bottom: var(--s1); }
  html.has-stage #start .scene__text > .t-small { display: none; }
}

/* A phone: the desk is a picture across the top of the scene, fading into the ground, and the
   list sits under it. */
@media (max-width: 699.98px) {
  #start .media > video {
    left: 0; top: 0; width: 100cqw; height: min(44svh, 110cqw);
    object-position: 76% 50%;
    -webkit-mask-image: linear-gradient(to bottom, var(--ink) 58%, transparent);
    mask-image: linear-gradient(to bottom, var(--ink) 58%, transparent);
  }
  /* the list starts 40px before the picture ends (the scene's own top padding is the frame + 24px) */
  #start .scene__text { margin-top: calc(min(44svh, 110vw) - var(--s4) - var(--frame-h) - var(--s3)); }
  /* a narrow column: the name and its price share the first line, with whatever leader fits
     between them, and the detail ("one week") goes under the name */
  #start .leaders dt { flex-wrap: wrap; row-gap: 0; }
  #start .leaders dt::after { flex: 1 1 0; min-width: 0; }
  #start .leaders__detail { order: 1; flex-basis: 100%; }
}
