/*--------------------------------------------------
Sketch assemble (index.html, the portrait under "We're reynald"). Script: js/sketch-reveal.js

The man is broken into sharp shards that fly in and lock together, then
the design objects fly back into place as you scroll; the portrait is
pinned on screen meanwhile. The drawing's edges are feathered into the
page, so the slightly deeper blue of its paper never shows a hard
rectangle. The moving pieces and shards hold only ink (no paper); the
shards carry their own edge feathering (baked in by the script).
---------------------------------------------------*/

.sketch-reveal {
	/* Never taller than the screen: it is pinned on screen while it assembles */
	--sketch-w: min(32rem, 36vw, 68vh);
	--sketch-feather: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent), linear-gradient(to bottom, transparent, #000 6%, #000 94%, transparent);
	position: relative;
	width: var(--sketch-w);
	aspect-ratio: 1122 / 1402;
	margin: 0;
}

/* The artwork (the base plate once the script runs), the paper sheet the
   shards land on, and the canvas holding the shards that have landed (their
   exact pixels). The sharp <img> takes over when every shard is home. */
.sketch-reveal > img,
.sketch-plate,
.sketch-landed {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	-webkit-mask-image: var(--sketch-feather);
	-webkit-mask-composite: source-in;
	mask-image: var(--sketch-feather);
	mask-composite: intersect;
	transform-origin: 50% 50%;
}

.sketch-plate,
.sketch-landed {
	position: absolute;
	top: 0;
	left: 0;
	pointer-events: none;
}

.sketch-plate {
	opacity: 0;
}

.sketch-reveal.is-ready > img {
	opacity: 0;
}

.sketch-reveal.is-ready.is-whole > img {
	opacity: 1;
}

.sketch-reveal.is-whole .sketch-plate,
.sketch-reveal.is-whole .sketch-landed {
	visibility: hidden;
}

/* The pieces, laid over it at their home positions */
.sketch-parts {
	position: absolute;
	inset: 0;
	pointer-events: none;
	transform-origin: 50% 50%;
}

.sketch-piece {
	position: absolute;
	display: block;
	max-width: none;
	margin: 0;
	transform-origin: 50% 50%;
	backface-visibility: hidden;
}

/* The scroll thread's layers inside the object layer (js/thread.js) don't
   take the drawing's settling zoom (103.5% -> 100%, set on .sketch-parts by
   the script), so the line meets the page's thread without a break */
.sketch-parts > .thread-local {
	transform: scale(var(--sketch-unzoom, 1));
	transform-origin: 50% 50%;
}

/* Shards of the man: canvases placed over their home spot (set by the
   script), under the design objects */
.sketch-shard {
	position: absolute;
	display: block;
	transform-origin: 50% 50%;
	backface-visibility: hidden;
}

.sketch-reveal.is-moving .sketch-piece,
.sketch-reveal.is-moving .sketch-shard {
	will-change: transform, opacity;
}

/* Desktop: larger, centred on the page (its column is 74% of the row, so 50%
   of the row is 50% / 0.74 of the column; never past the column's right
   edge), and closer under "Creative Professional" (the row above is as tall
   as the brain drawing beside the sentence, which leaves a gap) */
@media only screen and (min-width: 1025px) {
	.sketch-reveal {
		--sketch-w: min(36rem, 40vw, 70vh);
		margin-top: -8vw;
		margin-left: min(calc(50% / 0.74 - var(--sketch-w) / 2), calc(100% - var(--sketch-w)));
	}
}

/* Tablets: the column is wide, so the drawing can be too; centred in it
   (the paragraph sits beside it) */
@media only screen and (min-width: 768px) and (max-width: 1024px) {
	.sketch-reveal {
		--sketch-w: min(32rem, 56vw, 66vh);
		margin-left: auto;
		margin-right: auto;
	}
}

/* Phones: full column, centred, above the text */
@media only screen and (max-width: 767px) {
	.sketch-reveal {
		--sketch-w: min(26rem, 100%, 66vh);
		margin: 0 auto 1rem;
	}
}
