/* Stern Cohen Diamond Portraits
 * Same diamond everywhere (Figma "Mugshot Diamond", 290x290 at card size); only the headroom above it differs:
 *   card  (grid, small): 290x331 - 41px above the diamond, like the 580x663 card PNGs.
 *   bio:                 290x390 - 100px above the diamond, like the 580x780 bio PNGs (420x565 on the page).
 * The diamond sits at the bottom of the frame and the photo is anchored to the bottom too,
 * so one framing (zoom, x, y) looks the same in both frames; the bio just shows more above the head.
 *
 * Layers, back to front:
 *   tilted  - the diamond rotated -20deg, diamond colour at 20%, clipped to the diamond's square
 *             (bio: shape at 97%, so about half as much of it shows; tilted-bio.svg)
 *   diamond - the diamond in the chosen colour
 *   clip    - the photo, masked to diamond + the area above its middle (head breaks out of the top)
 * x/y are in cqw (percent of frame width), so the same values look the same at any size.
 */

.sc-portrait {
	--sc-diamond: #18476b;
	--sc-zoom: 1;
	--sc-x: 0;
	--sc-y: 0;

	position: relative;
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	aspect-ratio: 290 / 331;
	container-type: inline-size;
}

.sc-portrait__tilted,
.sc-portrait__diamond,
.sc-portrait__clip {
	position: absolute;
	inset: 0;
	display: block;
	-webkit-mask-size: 100% 100%;
	-webkit-mask-repeat: no-repeat;
	mask-size: 100% 100%;
	mask-repeat: no-repeat;
}

.sc-portrait__tilted {
	background-color: var(--sc-diamond);
	opacity: 0.2;
	-webkit-mask-image: url("../img/tilted.svg");
	mask-image: url("../img/tilted.svg");
}

.sc-portrait__diamond {
	background-color: var(--sc-diamond);
	-webkit-mask-image: url("../img/diamond.svg");
	mask-image: url("../img/diamond.svg");
}

.sc-portrait__clip {
	-webkit-mask-image: url("../img/clip.svg");
	mask-image: url("../img/clip.svg");
}

/* Bio frame: more headroom (580:780, same as the existing bio PNGs). */
.sc-portrait--bio { aspect-ratio: 290 / 390; }
.sc-portrait--bio .sc-portrait__tilted { -webkit-mask-image: url("../img/tilted-bio.svg?v=1.7.1"); mask-image: url("../img/tilted-bio.svg?v=1.7.1"); }
.sc-portrait--bio .sc-portrait__diamond { -webkit-mask-image: url("../img/diamond-bio.svg"); mask-image: url("../img/diamond-bio.svg"); }
.sc-portrait--bio .sc-portrait__clip { -webkit-mask-image: url("../img/clip-bio.svg"); mask-image: url("../img/clip-bio.svg"); }

/* Doubled class beats common theme rules such as `img { max-width: 100% }`. */
.sc-portrait .sc-portrait__photo {
	position: absolute;
	left: 50%;
	bottom: 0;
	width: 100%;
	max-width: none;
	max-height: none;
	height: auto;
	margin: 0;
	transform-origin: 50% 100%;
	transform: translateX(-50%) scale(var(--sc-zoom));
}

@supports (width: 1cqw) {
	.sc-portrait .sc-portrait__photo {
		transform: translate(calc(-50% + var(--sc-x) * 1cqw), calc(var(--sc-y) * 1cqw)) scale(var(--sc-zoom));
	}
}

/* Fallback for browsers without CSS masks: plain diamond shapes. */
@supports (not (mask-image: url(x))) and (not (-webkit-mask-image: url(x))) {
	.sc-portrait__tilted { display: none; }
	.sc-portrait__diamond { clip-path: polygon(50% 12.39%, 100% 56.19%, 50% 100%, 0 56.19%); }
	.sc-portrait__clip { clip-path: polygon(0 0, 100% 0, 100% 56.19%, 50% 100%, 0 56.19%); }
	.sc-portrait--bio .sc-portrait__diamond { clip-path: polygon(50% 25.64%, 100% 62.82%, 50% 100%, 0 62.82%); }
	.sc-portrait--bio .sc-portrait__clip { clip-path: polygon(0 0, 100% 0, 100% 62.82%, 50% 100%, 0 62.82%); }
}

/* ---- Placement in the Stern Cohen theme (same spots as the old pre-drawn PNGs) ---- */

/* Our Team card: 290 wide, breakout pulled up over the card like the old images (-41px at 290). */
.our-team-picture .sc-portrait--grid {
	max-width: 290px;
	margin-top: -14.14%;
}

/* Bio page, desktop: 420x565 like the old PNG (theme: img top -75px inside a figure with margin-top -26px),
   hanging 80px left of the column, diamond in the same place. */
@media (min-width: 1024px) {
	.our-team-picture > .sc-portrait--bio {
		position: relative;
		z-index: 1;
		width: 162%;
		max-width: 420px;
		left: -80px;
		margin: -101px 0 75px;
	}
}

/* Bio page, tablet and mobile: same sizes and spot as the old images (theme pulls them up 26px). */
@media (max-width: 1023px) {
	.our-team-picture > .sc-portrait--bio { margin-top: -26px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
	.our-team-picture > .sc-portrait--bio { max-width: 323px; }
}
@media (max-width: 767px) {
	.our-team-picture > .sc-portrait--bio { max-width: 329px; }
}

/* Bio page "Our People" list: small 64px diamond like the old thumbnails (designer's bio/small set, no tilted layer). */
.sc-portrait--small { width: 64px; }
.sc-portrait--small .sc-portrait__tilted { display: none; }
