/* The prologue (src/ui/prologue.js): a grey halftone street in the rain, an old cart under a canvas sheet, the
   colourist as the one denim cut-out, a line box at the foot in the Refillit OS window style. Over everything, the
   café waiting behind it.
   Until the cup is drunk (.bw) the whole scene, the colourist and the UI included, is black and white; then the
   street fills in with faded colour (a colour photo under the halftone print) and the colourist's denim comes in a
   moment later, the one strong colour. The cart stays grey till the centre well runs into it. */
#prologue { position: fixed; inset: 0; z-index: 90; overflow: hidden; background: #2b2b2e; color: var(--os-ink);
  font-family: var(--os-font); user-select: none; -webkit-user-select: none; cursor: pointer; touch-action: manipulation; }
#prologue > * { position: absolute; pointer-events: none; }
#prologue .pr-skip, #prologue .pr-line { pointer-events: auto; }
#prologue > * { filter: grayscale(0); transition: filter 1.8s ease-out; }
#prologue.bw > * { filter: grayscale(1); }

.pr-street { inset: -8%; background: #fff; opacity: 0; }
.pr-street > i { position: absolute; inset: 0; background-position: center 60%; background-size: cover; background-repeat: no-repeat; }
.pr-col { background-image: url('../../assets/ui/collage/street_colour.webp');
  -webkit-mask: url('../../assets/ui/collage/bloom.webp') center 50% / 0.1% auto no-repeat; mask: url('../../assets/ui/collage/bloom.webp') center 50% / 0.1% auto no-repeat; }
.pr-col.full { -webkit-mask: none; mask: none; }
.pr-paint { background-image: url('../../assets/ui/collage/bloom.webp'); background-position: center 50%; background-size: 0.1% auto; mix-blend-mode: multiply; opacity: 0; }
.pr-ht { background-image: url('../../assets/ui/collage/street.webp'); mix-blend-mode: multiply; }
/* two sheets of rain at different speeds */
.pr-rain { inset: -20% 0 0; opacity: 0;
  background:
    repeating-linear-gradient(104deg, transparent 0 31px, rgba(255, 255, 255, .22) 31px 32px, transparent 32px 57px),
    repeating-linear-gradient(98deg, transparent 0 19px, rgba(255, 255, 255, .12) 19px 20px, transparent 20px 41px);
  background-size: 220px 180px, 140px 120px; animation: pr-rain .5s linear infinite; }
@keyframes pr-rain { to { background-position: -40px 180px, -26px 120px; } }

/* the colourist: a denim cut-out under the lamp, on the right; it fades into the rain when it goes */
.pr-figure { right: 9%; bottom: 13%; height: min(64vh, 560px); aspect-ratio: 410 / 833; }
.pr-figure { opacity: 0; background: url('../../assets/ui/collage/figure.webp') center / contain no-repeat; filter: grayscale(0) drop-shadow(5px 6px 0 rgba(31, 42, 74, .35));
  transition: filter 2.4s ease-out .9s; }
#prologue.bw .pr-figure { filter: grayscale(1) drop-shadow(5px 6px 0 rgba(31, 42, 74, .35)); }

/* the old cart under the lamp, on the left: a real cart photo as a sticker, grey halftone; the same photo in colour
   over it (.pr-cart-col), let in by a watercolour bloom from the awning at the end; the canvas sheet over it till it
   is pulled off (.pr-cover, the same framing). Its counter carries the brewing things once it is open. */
.pr-cart { right: calc(9% + min(64vh, 560px) * .38); bottom: 13%; width: min(40vw, 480px); aspect-ratio: 721 / 653; opacity: 0; container-type: inline-size;
  filter: grayscale(0) drop-shadow(5px 6px 0 rgba(31, 42, 74, .35)); transform-origin: 50% 100%; }
#prologue.bw .pr-cart { filter: grayscale(1) drop-shadow(5px 6px 0 rgba(31, 42, 74, .35)); }
.pr-cart-grey, .pr-cart-col, .pr-cover { position: absolute; inset: 0; background: center / 100% 100% no-repeat; }
.pr-cart-grey { background-image: url('../../assets/ui/collage/cart.webp'); }
.pr-cart-col { background-image: url('../../assets/ui/collage/cart_colour.webp'); opacity: 0;
  -webkit-mask: url('../../assets/ui/collage/bloom.webp') 56% 22% / 0.1% auto no-repeat; mask: url('../../assets/ui/collage/bloom.webp') 56% 22% / 0.1% auto no-repeat; }
.pr-cart-col.full { opacity: 1; -webkit-mask: none; mask: none; }
.pr-cover { width: 101.9%; background-image: url('../../assets/ui/collage/cart_covered.webp'); }
/* the blank board over the awning: the name brushed onto it by hand, left to right, in denim (a sign painter's
   lettering, not a lit box); a little warm light from the street lamp finds it */
.pr-sign { position: absolute; left: 22%; top: 2.6%; width: 51.6%; height: 8.2%; }
.pr-sign::before { content: ''; position: absolute; inset: -70% -12%; opacity: 0; transition: opacity 2.6s ease-out .4s;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 232, 186, .38), rgba(255, 226, 170, 0) 70%); }
.pr-letters { position: absolute; inset: -18% 0 -14%; background: url('../../assets/ui/collage/sign_lettering.webp') center / contain no-repeat;
  -webkit-mask: linear-gradient(90deg, #000 44%, transparent 56%) 100% 0 / 230% 100% no-repeat; mask: linear-gradient(90deg, #000 44%, transparent 56%) 100% 0 / 230% 100% no-repeat; }
.pr-sign.on::before, .pr-sign.painted::before { opacity: 1; }
.pr-sign.on .pr-letters { animation: pr-brush 1.9s cubic-bezier(.45, .1, .4, 1) forwards; }
.pr-sign.painted .pr-letters { -webkit-mask: none; mask: none; }
@keyframes pr-brush { to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
/* a real brush stroke of the centre well's colour: the cart's own colour photo, let in through a real stroke of paint
   (--stroke, a scan) as far as the brush has got (the gradient, swept left to right) */
.pr-stroke { position: absolute; background: url('../../assets/ui/collage/cart_colour.webp') no-repeat;
  -webkit-mask: var(--stroke) 0 0 / 100% 100% no-repeat, linear-gradient(90deg, #000 46%, transparent 54%) 100% 0 / 230% 100% no-repeat;
  mask: var(--stroke) 0 0 / 100% 100% no-repeat, linear-gradient(90deg, #000 46%, transparent 54%) 100% 0 / 230% 100% no-repeat;
  -webkit-mask-composite: source-in; mask-composite: intersect; }

/* the canvas sheet, pulled off the cart and thrown away (laid over the cart when it goes) */
.pr-tarp { aspect-ratio: 553 / 360; opacity: 0; background: url('../../assets/ui/collage/tarp.webp') center / contain no-repeat;
  filter: drop-shadow(5px 6px 0 rgba(31, 42, 74, .3)); }
.pr-tarp.on { opacity: 1; }

/* the grey hand with the cup, coming in from the top right; the cup sits low on the left of the picture */
.pr-hand { right: max(4%, 50% - 300px); top: 4%; width: min(58vw, 380px); aspect-ratio: 411 / 590; opacity: 0; }
.pr-hand.on { opacity: 1; }
.pr-arm { position: absolute; inset: 0; background: url('../../assets/ui/collage/hand_cup.webp') center / contain no-repeat;
  filter: drop-shadow(5px 6px 0 rgba(31, 42, 74, .3)); }
/* steam out of the cup's mouth (low on the left of the picture), behind the fingers above it: each wisp rises, swells,
   sways and thins out, the next one already on its way */
.pr-steam { position: absolute; left: 23%; bottom: 17%; width: 24%; aspect-ratio: 194 / 720; transform: rotate(-14deg); transform-origin: 50% 100%; }
.pr-steam i { position: absolute; inset: 0; background: url('../../assets/ui/collage/steam_wisp.webp') center bottom / contain no-repeat;
  transform-origin: 50% 100%; opacity: 0; animation: pr-waft 3.6s linear infinite; animation-delay: calc(var(--i) * -1.2s); }
.pr-steam i:nth-child(2) { scale: -1 1; }
@keyframes pr-waft {
  0% { opacity: 0; transform: translateY(12%) scale(.55, .5); }
  18% { opacity: .95; }
  50% { transform: translate(-6%, -14%) scale(.85, .9) skewX(6deg); }
  75% { opacity: .55; }
  100% { opacity: 0; transform: translate(4%, -34%) scale(1.15, 1.2) skewX(-5deg); }
}

/* the palette: a real porcelain one, a sticker; the centre well (in the middle of the picture) glows at the end */
.pr-palette { left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); width: min(62vw, 300px); aspect-ratio: 1; transform: translate(-50%, 160%); opacity: 0;
  background: url('../../assets/ui/collage/palette.webp') center / contain no-repeat; filter: drop-shadow(6px 7px 0 rgba(31, 42, 74, .4)); }
.pr-palette.on { opacity: 1; }
.pr-glow { position: absolute; left: 50%; top: 50%; width: 28%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(255, 236, 190, .95), rgba(255, 214, 140, .5) 45%, transparent 70%); mix-blend-mode: screen; }
.pr-palette.centre .pr-glow { animation: pr-glow 1.2s ease-in-out infinite; }
@keyframes pr-glow { 0%, 100% { opacity: .35; scale: 1; } 50% { opacity: 1; scale: 1.18; } }

/* looking down: a shot of its own, the puddle filling the screen (the street, the cart and the colourist out of it).
   No figure in the water: rain rings, the lamp's light shivering on it, and a soft blur of colour in the middle, the
   only colour in the grey water (the paper doll gives it a shape later) */
.pr-puddle { inset: 0; opacity: 0; overflow: hidden; background: #1c1d22 url('../../assets/ui/collage/puddle.webp') 50% 47% / cover no-repeat; }
.pr-puddle.on { opacity: 1; }
.pr-self { position: absolute; left: 50%; top: 47%; width: min(52vw, 46vh); aspect-ratio: 3 / 4; translate: -50% -50%; opacity: 0; transition: opacity 1.8s ease-out;
  border-radius: 50%; mix-blend-mode: screen;
  background:
    radial-gradient(ellipse 38% 30% at 46% 38%, rgba(111, 140, 214, .95), transparent 70%),
    radial-gradient(ellipse 30% 26% at 58% 60%, rgba(236, 170, 120, .65), transparent 70%),
    radial-gradient(ellipse 50% 44% at 50% 50%, rgba(80, 108, 186, .6), transparent 72%);
  filter: blur(14px); animation: pr-wobble 3.2s ease-in-out infinite; }
.pr-self.on { opacity: 1; }
@keyframes pr-wobble { 50% { transform: skewX(4deg) scale(1.04, .97); } }
/* the lamp's light on the water, a slow shimmer across it */
.pr-sheen { position: absolute; inset: 0; mix-blend-mode: screen; opacity: .55; animation: pr-sheen 4s ease-in-out infinite alternate;
  background: linear-gradient(112deg, transparent 38%, rgba(255, 238, 200, .16) 46%, transparent 52%, transparent 60%, rgba(210, 225, 255, .1) 64%, transparent 69%); }
@keyframes pr-sheen { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
/* rain landing on it: rings opening here and there */
.pr-ripple { position: absolute; width: min(26vw, 150px); aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(235, 240, 250, .6);
  box-shadow: 0 0 0 5px rgba(235, 240, 250, .12); opacity: 0; translate: -50% -50%; animation: pr-ripple 2.6s ease-out infinite; animation-delay: calc(var(--i) * -.52s); }
.pr-ripple:nth-of-type(3) { left: 30%; top: 30%; }
.pr-ripple:nth-of-type(4) { left: 68%; top: 22%; }
.pr-ripple:nth-of-type(5) { left: 40%; top: 70%; }
.pr-ripple:nth-of-type(6) { left: 74%; top: 60%; }
.pr-ripple:nth-of-type(7) { left: 22%; top: 52%; }
@keyframes pr-ripple { 0% { opacity: .9; transform: scale(.08, .05); } 100% { opacity: 0; transform: scale(1.3, .85); } }

/* the paintbrush that carries the centre well's colour to the cart (a real one, cut out; its bristles' tip is at 3% 97%) */
.pr-brush { left: 0; top: 0; width: min(30vw, 150px); aspect-ratio: 282 / 356; opacity: 0; transform-origin: 3% 97%;
  background: url('../../assets/ui/collage/brush.webp') center / contain no-repeat; filter: drop-shadow(4px 6px 0 rgba(31, 42, 74, .3)); }
.pr-brush.on { opacity: 1; }
/* the well the brush took it from, empty now */
.pr-palette.spent .pr-glow { opacity: 0; }

/* the note the colourist leaves: the first recipe, on a scrap of kraft paper (it ends up on the counter) */
.pr-note { left: 50%; top: 42%; width: min(66vw, 300px); aspect-ratio: 351 / 500; opacity: 0;
  background: url('../../assets/ui/collage/note.webp') center / contain no-repeat; filter: drop-shadow(5px 6px 0 rgba(31, 42, 74, .35)); }
.pr-note.on { opacity: 1; }
.pr-note-in { position: absolute; inset: 19% 13% 10%; color: #3b2a1c; font: 16px/1.45 var(--os-font); transform: rotate(-1deg); }
.pr-note-in p { margin: 0 0 8px; }
.pr-note-row { display: flex; gap: 6px; align-items: baseline; font-size: 19px; }
.pr-note-row::after { content: ''; order: 1; flex: 1; border-bottom: 2px dotted rgba(59, 42, 28, .5); }
.pr-note-row span { order: 2; }
.pr-note-sign { margin-top: 14px; color: var(--os-denim); text-align: right; transform: rotate(-2deg); }

/* the first card: who we are (a slanted denim plate) */
.pr-title { left: 6%; top: calc(14% + env(safe-area-inset-top)); max-width: 88%; padding: 10px 20px 12px; opacity: 1; transform: translate(-130%, 0);
  background: var(--os-denim); color: #fff; font: 30px/1.15 'Refillit Display', var(--os-font); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--os-ink), 6px 7px 0 5px rgba(31, 42, 74, .45); }
.pr-title:empty { display: none; }

/* the line box: an OS window at the foot; who speaks on a plate breaking out of its top */
.pr-line { left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); width: min(92vw, 640px); translate: -50% 0; min-height: 92px; padding: 18px 20px 16px;
  background: var(--os-frame); border: var(--os-b) solid var(--os-ink); border-radius: 3px; box-shadow: var(--os-bevel), var(--os-drop);
  font-size: 18px; line-height: 1.5; opacity: 0; transform: translateY(14px); transition: opacity .18s, transform .18s; }
.pr-line.show { opacity: 1; transform: none; }
.pr-line.narr { background: var(--os-paper); }
.pr-who { position: absolute; left: 14px; top: -16px; padding: 3px 12px; background: var(--os-denim); color: #fff; font-size: 15px; transform: skewX(-8deg); box-shadow: 3px 3px 0 var(--os-ink); }
.pr-who:empty { display: none; }
.pr-more { position: absolute; right: 14px; bottom: 8px; font-style: normal; font-size: 13px; color: var(--os-denim); animation: pr-blink .9s steps(2, end) infinite; }
@keyframes pr-blink { 50% { opacity: 0; } }

/* a beat with no words: a ▼ low in the corner, where the line would end */
.pr-nudge { right: max(18px, 50% - 306px); bottom: calc(26px + env(safe-area-inset-bottom)); color: #fff; font-style: normal; font-size: 15px;
  opacity: 0; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.pr-nudge.on { opacity: 1; animation: pr-blink .9s steps(2, end) infinite; }

.pr-skip { right: calc(14px + env(safe-area-inset-right)); top: calc(14px + env(safe-area-inset-top)); padding: 6px 14px; cursor: pointer;
  background: var(--os-frame); color: var(--os-ink); border: var(--os-b) solid var(--os-ink); border-radius: 3px; box-shadow: var(--os-bevel); font: 15px var(--os-font); }

/* before anything has been tapped: a black screen asking for the tap that lets the sound play */
.pr-start { inset: 0; display: grid; place-items: center; background: #111; z-index: 2; }
.pr-start span { padding: 8px 18px; color: #e8e8ea; border: 2px solid #e8e8ea; font-size: 18px; animation: pr-blink 1.4s steps(2, end) infinite; }

/* the centre well opening over everything: the café's cream */
.pr-dive { inset: 0; background: var(--os-paper); }

/* the opening (opening.js): the same stage laid over the 3D café, see-through, for the lines, the rain, the hints and
   the colour coming back into the first guest */
#prologue.over3d { background: transparent; }
.op-rain { opacity: .5; }
/* the rain's grey over the lot, lifted when it stops */
.op-dim { inset: 0; background: rgba(46, 54, 78, .3); mix-blend-mode: multiply; }
/* how many of the cart's things are back: an OS chip at the top */
.op-count { left: 50%; top: calc(16px + env(safe-area-inset-top)); translate: -50% 0; padding: 6px 16px; opacity: 0; transition: opacity .3s;
  background: var(--os-paper); color: var(--os-ink); border: var(--os-b) solid var(--os-ink); box-shadow: 3px 3px 0 var(--os-ink); font: 16px var(--os-font); white-space: nowrap; }
.op-count.on { opacity: 1; }
/* over each thing still lying about: a denim marker, bobbing (tap the thing, or the marker) */
.op-marks { inset: 0; }
.op-mark { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.op-mark::before { content: ''; position: absolute; left: -11px; top: -24px; width: 22px; height: 18px; background: var(--os-denim);
  clip-path: polygon(0 0, 100% 0, 50% 100%); filter: drop-shadow(0 0 0 #fff); animation: op-bob .8s ease-in-out infinite alternate; }
.op-mark::after { content: ''; position: absolute; left: -15px; top: -28px; width: 30px; height: 26px; background: #fff; z-index: -1;
  clip-path: polygon(0 0, 100% 0, 50% 100%); animation: op-bob .8s ease-in-out infinite alternate; }
@keyframes op-bob { from { transform: translateY(-6px); } to { transform: translateY(2px); } }
/* the colourist's note, shown over the cart, then put away */
.op-note { top: 46%; }
/* their colour coming back: a watercolour bloom of it round them (--hue, read off their portrait), rings on the wet
   ground at their feet, a few flecks rising as the steam rose off the cup (placed by opening.js over the character) */
.op-paint { left: 0; top: 0; opacity: 0; background: var(--hue, #3f5daa); mix-blend-mode: multiply;
  -webkit-mask: url('../../assets/ui/collage/bloom.webp') center / 3% auto no-repeat; mask: url('../../assets/ui/collage/bloom.webp') center / 3% auto no-repeat; }
.op-rings { left: 0; top: 0; }
.op-rings i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--hue, #3f5daa); opacity: 0; }
.op-rings.on i { animation: op-ring 2.6s cubic-bezier(.2, .7, .3, 1) calc(var(--i) * .55s + .4s) 2 both; }
@keyframes op-ring { 0% { opacity: .9; transform: scale(.1); } 100% { opacity: 0; transform: scale(1.25); } }
.op-flecks { left: 0; top: 0; }
.op-flecks i { position: absolute; left: var(--x); top: 58%; width: 7px; aspect-ratio: 1; border-radius: 50%; background: var(--hue, #3f5daa);
  opacity: 0; box-shadow: 0 0 6px var(--hue, #3f5daa); }
.op-flecks.on i { animation: op-rise 3.2s ease-out calc(var(--i) * .22s + .3s) both; }
@keyframes op-rise { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 20% { opacity: .95; }
  60% { transform: translate(8px, -90px) scale(1); } 100% { opacity: 0; transform: translate(-6px, -170px) scale(.4); } }

@media (max-width: 600px) {
  .pr-street > i { background-position: 70% 60%; }   /* the lamp in the picture, over the colourist and the cart */
  .pr-figure { right: 2%; bottom: 22%; height: 50vh; }
  .pr-cart { right: auto; left: -9%; bottom: 23%; width: 80vw; }
  .pr-title { font-size: 24px; }
  .pr-line { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .pr-rain, .pr-more, .pr-nudge.on { animation: none; }
  .pr-steam i { animation: none; opacity: .8; }
  .pr-self, .pr-ripple, .pr-sheen, .op-rings.on i, .op-flecks.on i, .op-mark::before, .op-mark::after { animation: none; }
  .pr-sign.on .pr-letters { animation-duration: 1ms; }
}
