/**
 * Gareth Promo Popup — front-end styles.
 *
 * Every token is declared on the .gpp wrapper, never on :root, so nothing here can
 * leak into the theme. Every class is prefixed. No webfonts are loaded — the popup
 * uses the Lato the site already serves, with a system fallback stack.
 */

.gpp {
	/* --- palette (Involved Holidays logo colours) --- */
	--gpp-blue-900: #12283f;
	--gpp-blue-800: #1b3f63;
	--gpp-blue-700: #275a92;
	--gpp-blue-100: #e6f2f9;
	--gpp-gold-600: #8f7c45;
	--gpp-gold-500: #ab8b44;
	--gpp-gold-400: #c99c43;
	--gpp-sand: #f6f2e9;
	--gpp-grey-800: #39434e;
	--gpp-grey-600: #6f7c8a;
	--gpp-white: #fff;

	/* --- overridable by the popup's own colour fields --- */
	--gpp-primary: var(--gpp-blue-700);
	--gpp-accent: var(--gpp-gold-500);
	--gpp-accent-grad: linear-gradient(90deg, var(--gpp-gold-600) 0%, var(--gpp-gold-400) 100%);

	/* --- type --- */
	--gpp-font: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif;

	/* --- shape --- */
	--gpp-radius: 16px;
	--gpp-radius-md: 10px;
	--gpp-shadow: 0 24px 60px rgba(18, 40, 63, .32);
	--gpp-focus: 0 0 0 3px rgba(37, 149, 198, .45);
	--gpp-ease: cubic-bezier(.4, 0, .2, 1);

	/* --- responsive sizes, overridden in the media queries below --- */
	--gpp-media-w: 43%;
	--gpp-media-h: 440px;
	--gpp-pad: 40px 44px 42px;
	--gpp-title: 700 34px/1.2 var(--gpp-font);
	--gpp-badge-size: 124px;
	--gpp-badge-offset: -20px;
	--gpp-badge-main: 34px;
	--gpp-badge-gap: 6px;
	--gpp-close-offset: -14px;
	--gpp-media-mobile-h: 150px;

	position: fixed;
	inset: 0;
	z-index: 99990;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px 30px;
	box-sizing: border-box;
	font: 400 17px/1.6 var(--gpp-font);
	color: var(--gpp-grey-800);
}

.gpp[hidden] {
	display: none !important;
}

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

/* ------------------------------------------------------------------ overlay */

.gpp__overlay {
	position: absolute;
	inset: 0;
	background: rgba(18, 40, 63, .55);
	animation: gpp-fade 400ms var(--gpp-ease) both;
}

/* ------------------------------------------------------------------- dialog */

.gpp__stage {
	position: relative;
	display: flex;
	justify-content: center;
	width: 100%;
	max-height: 100%;
}

.gpp__dialog {
	position: relative;
	width: 100%;
	max-width: 960px;
	max-height: 100%;
	animation: gpp-pop 400ms var(--gpp-ease) both;
}

.gpp--narrow .gpp__dialog {
	max-width: 540px;
}

/* The dialog takes focus when it opens, so screen readers land in the right place.
   It should not draw a ring for that — only real keyboard targets do. */
.gpp__dialog:focus {
	outline: none;
}

.gpp__panel {
	position: relative;
	display: flex;
	flex-direction: row;
	max-height: calc(100vh - 64px);
	/* dvh keeps the popup inside the visible area on phones, where the browser's own
	   toolbars make vh taller than what you can actually see. */
	max-height: calc(100dvh - 64px);
	overflow: hidden;
	background: var(--gpp-white);
	border-radius: var(--gpp-radius);
	box-shadow: var(--gpp-shadow);
}

.gpp--layout-right .gpp__panel {
	flex-direction: row-reverse;
}

.gpp--layout-top .gpp__panel,
.gpp--no-image .gpp__panel {
	flex-direction: column;
}

/* -------------------------------------------------------------------- media */

.gpp__media {
	position: relative;
	flex: 0 0 auto;
	width: var(--gpp-media-w);
	min-height: var(--gpp-media-h);
	overflow: hidden;
	background: var(--gpp-blue-100);
}

.gpp--layout-top .gpp__media,
.gpp--no-image .gpp__media {
	width: 100%;
	height: 230px;
	min-height: 0;
}

/*
 * The photo is pinned to its box and nothing else decides its size. Themes very
 * commonly ship a blanket `img { height: auto }` (or set position on images), which
 * would otherwise let a tall portrait photo stretch the panel to its full natural
 * height and push the text off the screen. These few declarations are deliberately
 * !important so the popup renders identically whatever the surrounding theme does —
 * they are scoped to this one element and cannot affect anything else on the page.
 */
.gpp .gpp__media > .gpp__image {
	position: absolute !important;
	top: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	left: 0 !important;
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	min-width: 0 !important;
	min-height: 0 !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	object-fit: cover;
	object-position: center;
}

/* -------------------------------------------------------------------- close */

/*
 * The close button sits just outside the panel's top-left corner, mirroring the
 * badge on the opposite corner. Keeping it out of the panel means it can never
 * land on the heading or the photo, whichever side the image is on.
 */
.gpp__close {
	position: absolute;
	top: var(--gpp-close-offset);
	left: var(--gpp-close-offset);
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	color: var(--gpp-primary);
	background: var(--gpp-white);
	border: 0;
	border-radius: 999px;
	box-shadow: 0 6px 18px rgba(18, 40, 63, .28);
	cursor: pointer;
	transition: color 160ms var(--gpp-ease), box-shadow 160ms var(--gpp-ease), transform 160ms var(--gpp-ease);
}

.gpp__close:hover {
	color: var(--gpp-blue-900);
	box-shadow: 0 10px 26px rgba(18, 40, 63, .34);
	transform: scale(1.05);
}

.gpp__close svg {
	display: block;
}

/* --------------------------------------------------------------------- body */

.gpp__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 18px;
	min-width: 0;
	/* Without this a flex item refuses to shrink below its content, so a long popup
	   would burst out of the panel's max-height instead of scrolling inside it. */
	min-height: 0;
	padding: var(--gpp-pad);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.gpp__head {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/*
 * Only keep clear of the badge when the badge actually sits over the text — that is,
 * when the body column is on the right. With the image on the right (or on top) the
 * badge lands on the photo, so the heading can use the full width.
 */
.gpp--layout-left.gpp--has-badge .gpp__head,
.gpp--no-image.gpp--has-badge .gpp__head {
	padding-right: 77px;
}

.gpp__eyebrow {
	font: 700 13px/1.35 var(--gpp-font);
	letter-spacing: .14em;
	color: var(--gpp-accent);
	text-transform: uppercase;
}

.gpp__title {
	margin: 0;
	font: var(--gpp-title);
	color: var(--gpp-primary);
	text-wrap: pretty;
}

.gpp__text {
	max-width: 52ch;
	margin: 0;
	font: 400 17px/1.6 var(--gpp-font);
	color: var(--gpp-grey-800);
	text-wrap: pretty;
}

/* ----------------------------------------------------------------- code box */

.gpp__code {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	background: var(--gpp-sand);
	border: 1px dashed var(--gpp-accent);
	border-radius: var(--gpp-radius-md);
}

.gpp__code-main {
	display: flex;
	flex: 1 1 140px;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.gpp__code-label {
	font: 400 13px/1.35 var(--gpp-font);
	letter-spacing: .04em;
	color: var(--gpp-grey-600);
	text-transform: uppercase;
}

.gpp__code-value {
	font: 900 24px/1.1 var(--gpp-font);
	letter-spacing: .06em;
	color: var(--gpp-primary);
	word-break: break-word;
}

/* ------------------------------------------------------------------ buttons */

.gpp__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px 18px;
}

.gpp__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 0 26px;
	font: 700 15px/1 var(--gpp-font);
	text-align: center;
	text-decoration: none;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 160ms var(--gpp-ease), color 160ms var(--gpp-ease), box-shadow 160ms var(--gpp-ease), transform 160ms var(--gpp-ease);
}

.gpp__btn--primary,
.gpp__btn--primary:visited {
	color: var(--gpp-white);
	background: var(--gpp-primary);
}

.gpp__btn--primary:hover,
.gpp__btn--primary:focus {
	color: var(--gpp-white);
	text-decoration: none;
	background: var(--gpp-blue-800);
}

.gpp__btn--gold {
	color: var(--gpp-white);
	background: var(--gpp-accent-grad);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.gpp__btn--gold:hover {
	filter: brightness(1.06);
}

.gpp__btn--gold.is-copied {
	background: var(--gpp-gold-600);
}

.gpp__btn--ghost {
	min-height: 44px;
	padding: 0 12px;
	color: var(--gpp-primary);
	background: transparent;
}

.gpp__btn--ghost:hover {
	color: var(--gpp-blue-800);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.gpp__btn:active {
	transform: scale(.985);
}

.gpp a:focus-visible,
.gpp button:focus-visible {
	outline: none;
	box-shadow: var(--gpp-focus);
}

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

.gpp__badge {
	position: absolute;
	top: var(--gpp-badge-offset);
	right: var(--gpp-badge-offset);
	width: var(--gpp-badge-size);
	height: var(--gpp-badge-size);
	transform: rotate(-8deg);
	filter: drop-shadow(0 8px 20px rgba(18, 40, 63, .32));
	pointer-events: none;
}

.gpp__badge-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.gpp__roundel {
	width: 100%;
	height: 100%;
	padding: 5px;
	background: var(--gpp-white);
	border-radius: 999px;
}

.gpp__roundel-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--gpp-badge-gap);
	width: 100%;
	height: 100%;
	color: var(--gpp-white);
	text-align: center;
	background: var(--gpp-accent-grad);
	border-radius: 999px;
	box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .55);
}

.gpp__roundel-top {
	font: 700 12px/1 var(--gpp-font);
	letter-spacing: .18em;
	text-transform: uppercase;
}

.gpp__roundel-main {
	font: 900 var(--gpp-badge-main)/1 var(--gpp-font);
	letter-spacing: -.01em;
}

.gpp__roundel-rule {
	width: 26px;
	height: 1px;
	background: rgba(255, 255, 255, .65);
}

.gpp__roundel-bottom {
	font: 700 12px/1 var(--gpp-font);
	letter-spacing: .12em;
	text-transform: uppercase;
}

/* ----------------------------------------------------------------- confetti */

.gpp__confetti {
	position: absolute;
	inset: 0;
	z-index: 4;
	display: block;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

/* --------------------------------------------------------------- animations */

@keyframes gpp-pop {
	from {
		opacity: 0;
		transform: translateY(14px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes gpp-fade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

/* Closing state — JS adds this, then removes the element after the transition. */
.gpp.is-closing .gpp__overlay,
.gpp.is-closing .gpp__dialog {
	opacity: 0;
	transition: opacity 200ms var(--gpp-ease);
}

/* ------------------------------------------------------------------ tablet */

@media (max-width: 1023px) {
	.gpp {
		--gpp-media-w: 36%;
		--gpp-media-h: 400px;
		--gpp-pad: 30px 32px 32px;
		--gpp-badge-size: 108px;
		--gpp-badge-main: 30px;
	}

	.gpp--layout-left.gpp--has-badge .gpp__head,
	.gpp--no-image.gpp--has-badge .gpp__head {
		padding-right: 67px;
	}
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 719px) {
	.gpp {
		--gpp-pad: 24px 20px 26px;
		--gpp-title: 700 28px/1.2 var(--gpp-font);
		--gpp-badge-size: 92px;
		--gpp-badge-offset: -14px;
		--gpp-badge-main: 26px;
		--gpp-badge-gap: 4px;
		--gpp-close-offset: -10px;

		padding: 20px 16px;
	}

	.gpp__dialog,
	.gpp--narrow .gpp__dialog {
		max-width: 460px;
	}

	/*
	 * Every layout stacks on a phone. The layout modifiers are listed explicitly
	 * because a media query adds no specificity of its own — a bare `.gpp__panel`
	 * here would lose to `.gpp--layout-right .gpp__panel` above and the popup would
	 * stay side-by-side on a 390px screen.
	 */
	.gpp--layout-left .gpp__panel,
	.gpp--layout-right .gpp__panel,
	.gpp--layout-top .gpp__panel,
	.gpp--no-image .gpp__panel,
	.gpp__panel {
		flex-direction: column;
		max-height: calc(100vh - 40px);
		max-height: calc(100dvh - 40px);
	}

	/*
	 * On a phone the photo is a short banner across the top, never a full-height
	 * panel — the offer and the buttons have to be the first thing on screen.
	 * A fixed height (not min-height) means no image can push the text below the fold.
	 */
	.gpp--layout-left .gpp__media,
	.gpp--layout-right .gpp__media,
	.gpp--layout-top .gpp__media,
	.gpp--no-image .gpp__media,
	.gpp__media {
		width: 100%;
		height: var(--gpp-media-mobile-h);
		min-height: 0;
	}

	/* "Hide it on phones" — the popup becomes a compact text-and-buttons card. */
	.gpp--mobile-image-off .gpp__media,
	.gpp--mobile-image-off.gpp--layout-left .gpp__media,
	.gpp--mobile-image-off.gpp--layout-right .gpp__media,
	.gpp--mobile-image-off.gpp--layout-top .gpp__media {
		display: none;
	}

	.gpp--layout-left.gpp--has-badge .gpp__head,
	.gpp--no-image.gpp--has-badge .gpp__head {
		padding-right: 0;
	}

	/* With the photo hidden the badge lands on the copy, so make room for it. */
	.gpp--mobile-image-off {
		--gpp-badge-size: 78px;
	}

	.gpp--mobile-image-off.gpp--has-badge .gpp__head {
		padding-right: 62px;
	}

	.gpp__text {
		font-size: 16px;
	}

	.gpp__actions {
		flex-direction: column;
		align-items: stretch;
	}

	.gpp__btn {
		width: 100%;
	}

	.gpp__code .gpp__btn {
		width: auto;
	}
}

/* ------------------------------------------------------------ small phones */

@media (max-width: 379px) {
	.gpp {
		--gpp-badge-size: 78px;
		--gpp-badge-offset: -10px;
		--gpp-badge-main: 22px;
		--gpp-close-offset: -8px;
		--gpp-media-mobile-h: 120px;

		padding: 16px 12px;
	}
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
	.gpp__overlay,
	.gpp__dialog {
		animation-duration: .01ms;
	}

	.gpp__btn,
	.gpp__close {
		transition-duration: .01ms;
	}
}
