/**
 * Image style 1 — a framed photo.
 *
 *   figure.gx-img         padding makes room for the decoration
 *     .gx-img__stage      the photo's own box; decor and badge sit on it
 *       .gx-img__decor    offset frame / dot grid / soft glow, behind
 *       .gx-img__frame    rounded clip; the scroll wipe runs on this
 *         .gx-img__media  aspect ratio, optional link
 *       .gx-img__badge    floating card that hangs over the edge
 *
 * Nothing is hidden until goxom-image.js adds `.gx-img--js`, so without
 * the script (or with reduced motion) the photo simply shows.
 */

.gx-img {
	--gx-img-accent: var(--color-primary, #1273C4);
	--gx-img-ink: var(--color-black, #0C2338);
	--gx-img-body: var(--color-body, #5A7387);
	--gx-img-radius: 28px;
	--gx-img-ratio: auto;
	--gx-img-offset: 22px;
	--gx-img-badge-bg: #ffffff;
	--gx-img-badge-out: 28px;
	--gx-img-ease: cubic-bezier(.77, 0, .18, 1);
	--gx-img-soft: cubic-bezier(.22, .61, .36, 1);

	position: relative;
	isolation: isolate;
	margin: 0;
}

.gx-img *,
.gx-img *::before,
.gx-img *::after {
	box-sizing: border-box;
}

/* Room for the decoration, on its side and below. */
.gx-img:not(.gx-img--decor-none) {
	padding-bottom: var(--gx-img-offset);
}
.gx-img--side-right:not(.gx-img--decor-none) { padding-right: var(--gx-img-offset); }
.gx-img--side-left:not(.gx-img--decor-none)  { padding-left: var(--gx-img-offset); }

.gx-img__stage {
	position: relative;
}

/* ------------------------------------------------------------------ photo */

.gx-img__frame {
	position: relative;
	z-index: 1;
	overflow: hidden;
	border-radius: var(--gx-img-radius);
	clip-path: inset(0 0 0 0 round var(--gx-img-radius));
	/* Safari: keep the rounded clip while the image scales. */
	transform: translateZ(0);
}

.gx-img__media {
	position: relative;
	display: block;
	aspect-ratio: var(--gx-img-ratio);
	overflow: hidden;
	color: inherit;
}

.gx-img__media img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 0;
	object-fit: cover;
	transform: scale(1);
	transform-origin: 50% 50%;
	transition: transform 1.4s var(--gx-img-soft), filter .6s var(--gx-img-soft);
}

a.gx-img__media:focus-visible {
	outline: 3px solid var(--gx-img-accent);
	outline-offset: -3px;
}

/* ------------------------------------------------------------------ hover */

.gx-img--hover-zoom .gx-img__frame:hover img,
.gx-img--hover-shine .gx-img__frame:hover img {
	transform: scale(1.06);
}

.gx-img__shine {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .38) 50%, transparent 70%);
	transform: translateX(-110%);
}
.gx-img__frame:hover .gx-img__shine {
	transform: translateX(110%);
	transition: transform 1s var(--gx-img-soft);
}

/* ------------------------------------------------------------- decoration */

.gx-img__decor {
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	transition: opacity .8s var(--gx-img-soft) .5s, translate .9s var(--gx-img-soft) .5s;
}

.gx-img--side-right .gx-img__decor { translate: var(--gx-img-offset) var(--gx-img-offset); }
.gx-img--side-left .gx-img__decor  { translate: calc(-1 * var(--gx-img-offset)) var(--gx-img-offset); }

.gx-img--decor-frame .gx-img__decor {
	border: 2px solid var(--gx-img-accent);
	border-radius: var(--gx-img-radius);
	opacity: .55;
}

.gx-img--decor-dots .gx-img__decor {
	inset: auto 0 0 auto;
	width: 46%;
	aspect-ratio: 1;
	background-image: radial-gradient(var(--gx-img-accent) 2px, transparent 2.5px);
	background-size: 16px 16px;
	opacity: .45;
	-webkit-mask-image: radial-gradient(circle at 100% 100%, #000 45%, transparent 72%);
	mask-image: radial-gradient(circle at 100% 100%, #000 45%, transparent 72%);
}
.gx-img--side-left.gx-img--decor-dots .gx-img__decor {
	inset: auto auto 0 0;
	-webkit-mask-image: radial-gradient(circle at 0 100%, #000 45%, transparent 72%);
	mask-image: radial-gradient(circle at 0 100%, #000 45%, transparent 72%);
}

.gx-img--decor-glow .gx-img__decor {
	inset: 12%;
	border-radius: 50%;
	background: var(--gx-img-accent);
	filter: blur(56px);
	opacity: .32;
}

/* ------------------------------------------------------------------ badge */

.gx-img__badge {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: calc(100% - 24px);
	padding: 12px 20px 12px 12px;
	border-radius: 18px;
	background: var(--gx-img-badge-bg);
	box-shadow: 0 22px 44px -18px rgba(12, 35, 56, .35), 0 2px 6px rgba(12, 35, 56, .06);
	transition: opacity .7s var(--gx-img-soft) .7s, translate .8s var(--gx-img-soft) .7s;
}

.gx-img--badge-tl .gx-img__badge { top: 32px;    left: calc(-1 * var(--gx-img-badge-out)); }
.gx-img--badge-tr .gx-img__badge { top: 32px;    right: calc(-1 * var(--gx-img-badge-out)); }
.gx-img--badge-bl .gx-img__badge { bottom: 32px; left: calc(-1 * var(--gx-img-badge-out)); }
.gx-img--badge-br .gx-img__badge { bottom: 32px; right: calc(-1 * var(--gx-img-badge-out)); }

.gx-img__badge-icon {
	display: grid;
	flex: none;
	place-items: center;
	width: 46px;
	height: 46px;
	border-radius: 14px;
	background: var(--gx-img-accent);
	color: #ffffff;
	font-size: 18px;
	line-height: 1;
}
.gx-img__badge-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.gx-img__badge-body {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.gx-img__badge-title {
	font-family: var(--font-title, inherit);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--gx-img-ink);
}

.gx-img__badge-text {
	font-size: 13px;
	line-height: 1.35;
	color: var(--gx-img-body);
}

.gx-img--float .gx-img__badge {
	animation: gx-img-float 5s ease-in-out infinite;
}

@keyframes gx-img-float {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-8px); }
}

/* ----------------------------------------------------------------- reveal */

.gx-img--js .gx-img__frame {
	transition: clip-path 1.1s var(--gx-img-ease), opacity .9s var(--gx-img-soft);
}

.gx-img--js:not(.is-in) .gx-img__media img { transform: scale(1.18); }

.gx-img--js.gx-img--reveal-left:not(.is-in) .gx-img__frame  { clip-path: inset(0 100% 0 0 round var(--gx-img-radius)); }
.gx-img--js.gx-img--reveal-right:not(.is-in) .gx-img__frame { clip-path: inset(0 0 0 100% round var(--gx-img-radius)); }
.gx-img--js.gx-img--reveal-up:not(.is-in) .gx-img__frame    { clip-path: inset(100% 0 0 0 round var(--gx-img-radius)); }
.gx-img--js.gx-img--reveal-down:not(.is-in) .gx-img__frame  { clip-path: inset(0 0 100% 0 round var(--gx-img-radius)); }
.gx-img--js.gx-img--reveal-fade:not(.is-in) .gx-img__frame  { opacity: 0; }

.gx-img--js:not(.is-in) .gx-img__decor {
	opacity: 0;
	translate: 0 0;
}

.gx-img--js:not(.is-in) .gx-img__badge {
	opacity: 0;
	translate: 0 18px;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1024px) {
	.gx-img {
		--gx-img-badge-out: 16px;
	}
}

@media (max-width: 767px) {
	.gx-img {
		--gx-img-offset: 14px;
		--gx-img-badge-out: -14px; /* tucked inside the photo */
	}

	.gx-img--badge-tl .gx-img__badge,
	.gx-img--badge-tr .gx-img__badge { top: 14px; }
	.gx-img--badge-bl .gx-img__badge,
	.gx-img--badge-br .gx-img__badge { bottom: 14px; }

	.gx-img__badge {
		padding: 10px 16px 10px 10px;
		border-radius: 14px;
	}
	.gx-img__badge-icon {
		width: 38px;
		height: 38px;
		border-radius: 11px;
		font-size: 15px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gx-img__media img,
	.gx-img__shine,
	.gx-img__decor,
	.gx-img__badge {
		transition: none;
		animation: none;
	}
	.gx-img__frame:hover img { transform: none; }
}
