/**
 * TMT Giving Back Popup.
 *
 * Everything is namespaced under .tmt-gb-popup. Button resets carry an
 * element selector (`button.tmt-gb-popup__x`) so a theme's global button
 * styling cannot outrank them, while staying below the three-class selectors
 * Elementor generates from the panel - those must keep winning.
 */

.tmt-gb-popup {
	--tmt-cards-overlay-default: #12384b;
	--tmt-cards-overlay-opacity: 0.55;
	--tmt-cards-overlay-opacity-hover: 0.7;
	--tmt-cards-speed: 400ms;
	--tmt-cards-zoom: 1.06;
	--tmt-cards-lift: 6px;

	position: relative;
	display: block;
}

.tmt-gb-popup *,
.tmt-gb-popup *::before,
.tmt-gb-popup *::after {
	box-sizing: border-box;
}

/* Grid, Card, Overlay, Heading, Plus ---------------------------------------
   NOT USED by default. This widget renders only the popup; the cards it opens
   are built in Elementor and are never styled from here. These rules are kept
   so the card-rendering version can be restored by re-registering the matching
   control sections in the widget class. None of them can reach the page's own
   cards: every selector requires this plugin's own block class.
   ------------------------------------------------------------------------- */

.tmt-gb-popup .tmt-gb-popup__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	column-gap: 24px;
	row-gap: 24px;
}

/* Card -------------------------------------------------------------------- */

.tmt-gb-popup .tmt-gb-popup__card {
	position: relative;
	display: flex;
	/* Overridden by the Position control's wrapper class. */
	align-items: flex-start;
	height: 515px;
	min-width: 0;
	margin: 0;
	overflow: hidden;
	border-radius: 4px;
	background-color: #0f2a3a;
}

.tmt-gb-popup .tmt-gb-popup__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center center;
	transition: transform var(--tmt-cards-speed) ease;
}

.tmt-gb-popup .tmt-gb-popup__card:hover .tmt-gb-popup__image,
.tmt-gb-popup .tmt-gb-popup__card:focus-within .tmt-gb-popup__image {
	transform: scale(var(--tmt-cards-zoom));
}

/*
 * The per-card colour lands on the card as --tmt-cards-overlay; unset, the
 * global default takes over. Opacity is separate so one control can dim every
 * card without touching the colours.
 */
.tmt-gb-popup .tmt-gb-popup__overlay {
	position: absolute;
	inset: 0;
	background-color: var(--tmt-cards-overlay, var(--tmt-cards-overlay-default));
	opacity: var(--tmt-cards-overlay-opacity);
	transition: opacity var(--tmt-cards-speed) ease;
	pointer-events: none;
}

.tmt-gb-popup .tmt-gb-popup__card:hover .tmt-gb-popup__overlay,
.tmt-gb-popup .tmt-gb-popup__card:focus-within .tmt-gb-popup__overlay {
	opacity: var(--tmt-cards-overlay-opacity-hover);
}

.tmt-gb-popup .tmt-gb-popup__heading {
	position: relative;
	z-index: 2;
	width: 100%;
	margin: 0;
	padding: 24px;
	font-family: inherit;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: normal;
	overflow-wrap: break-word;
	color: #fff;
	transition: transform var(--tmt-cards-speed) ease;
}

.tmt-gb-popup .tmt-gb-popup__card:hover .tmt-gb-popup__heading,
.tmt-gb-popup .tmt-gb-popup__card:focus-within .tmt-gb-popup__heading {
	transform: translateY(calc(var(--tmt-cards-lift) * -1));
}

.tmt-gb-popup-title-bottom .tmt-gb-popup__card {
	align-items: flex-end;
}

.tmt-gb-popup-title-top .tmt-gb-popup__card {
	align-items: flex-start;
}

/* Shared reset for every button this widget owns. */
.tmt-gb-popup button.tmt-gb-popup__plus,
.tmt-gb-popup button.tmt-gb-popup__close,
.tmt-gb-popup button.tmt-gb-popup__playpause,
.tmt-gb-popup button.tmt-gb-popup__gallery-btn,
.tmt-gb-popup button.tmt-gb-popup__nav-btn,
.tmt-gb-popup button.tmt-gb-popup__dot {
	min-width: 0;
	min-height: 0;
	max-width: none;
	margin: 0;
	border: 0;
	box-shadow: none;
	font-family: inherit;
	line-height: 1;
	/* nav buttons re-declare their border below; everything else stays flat. */
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	white-space: normal;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.tmt-gb-popup button.tmt-gb-popup__plus {
	position: absolute;
	right: 20px;
	bottom: 20px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border-radius: 50%;
	background-color: #fff;
	color: #12384b;
	font-size: 18px;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.tmt-gb-popup .tmt-gb-popup__plus svg,
.tmt-gb-popup .tmt-gb-popup__close svg,
.tmt-gb-popup .tmt-gb-popup__playpause svg,
.tmt-gb-popup .tmt-gb-popup__gallery-btn svg {
	display: block;
	width: 1em;
	height: 1em;
}

.tmt-gb-popup .tmt-gb-popup__plus i,
.tmt-gb-popup .tmt-gb-popup__close i {
	font-size: inherit;
	line-height: 1;
}

.tmt-gb-popup :focus {
	outline: none;
}

.tmt-gb-popup :focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

/* Hiding ------------------------------------------------------------------
   Every layout rule in this file is a two-class selector, which outranks the
   browser's own `[hidden] { display: none }`. So anything the script hides by
   setting .hidden = true would otherwise stay on screen -- which is exactly
   what happened to the slider controls on cards with no gallery. One rule
   covers every case, present and future.
   ------------------------------------------------------------------------- */

.tmt-gb-popup [hidden] {
	display: none !important;
}

/* The footer only exists to hold the slider controls, so when they are hidden
   it must not leave its own gap behind. */
.tmt-gb-popup .tmt-gb-popup__footer:not(:has(> *:not([hidden]))) {
	display: none;
}

/* Popup ------------------------------------------------------------------- */

.tmt-gb-popup .tmt-gb-popup__popup[hidden] {
	display: none;
}

.tmt-gb-popup .tmt-gb-popup__popup {
	position: fixed;
	inset: 0;
	z-index: 99990;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.tmt-gb-popup .tmt-gb-popup__backdrop {
	position: absolute;
	inset: 0;
	background-color: rgba(9, 27, 38, 0.75);
}

.tmt-gb-popup .tmt-gb-popup__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 860px;

	/* dvh first: on phones a toolbar makes vh lie, and the popup ends up taller
	   than the screen with its close button off the top. */
	max-height: 90vh;
	max-height: 90dvh;

	/* Fluid between the breakpoints, so there is no width where the padding is
	   suddenly wrong. */
	padding: clamp(64px, 9vw, 110px) clamp(18px, 5vw, 56px) clamp(22px, 5vw, 56px);
	overflow: hidden;
	border-radius: 6px;
	background-color: #f2f5f8;
}

.tmt-gb-popup button.tmt-gb-popup__close {
	position: absolute;
	top: 56px;
	right: 56px;
	z-index: 4;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border-radius: 50%;
	background-color: #e8542b;
	color: #fff;
	font-size: 12px;
	transition: background-color 0.2s ease, color 0.2s ease;
}

/*
 * Header row. The heading is moved in here by the script; keeping the two in
 * one flex row means a long heading wraps beside the buttons instead of running
 * underneath them, which is what an absolutely positioned nav would have done.
 */
.tmt-gb-popup .tmt-gb-popup__head {
	flex: 0 0 auto;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 24px;
	margin-bottom: 4px;
}

.tmt-gb-popup .tmt-gb-popup__head-title {
	min-width: 0;
}

.tmt-gb-popup .tmt-gb-popup__head-title:empty {
	display: none;
}

.tmt-gb-popup .tmt-gb-popup__nav {
	flex: 0 0 auto;
}

/* The only scrolling region, so the dialog itself never overflows the screen. */
.tmt-gb-popup .tmt-gb-popup__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.tmt-gb-popup .tmt-gb-popup__body:focus {
	outline: none;
}

.tmt-gb-popup .tmt-gb-popup__popup-heading {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: clamp(20px, 3.2vw, 34px);
	font-weight: 700;
	line-height: 1.2;
	overflow-wrap: break-word;
	color: #12384b;
}

.tmt-gb-popup .tmt-gb-popup__popup-text {
	font-family: inherit;
	font-size: 15px;
	line-height: 1.6;
	color: #3e5a70;
}

.tmt-gb-popup .tmt-gb-popup__popup-text > *:first-child {
	margin-top: 0;
}

.tmt-gb-popup .tmt-gb-popup__popup-text > *:last-child {
	margin-bottom: 0;
}

/* Gallery ----------------------------------------------------------------- */

/* Category, sub-heading, link, logo, banner --------------------------------
   Order inside the popup, top to bottom:
       category -> heading -> sub-heading -> description -> link -> logo
       -> banner -> gallery
   Category and heading are moved into the header row on open, so they end up
   beside Prev/Next; the rest stay in the scrolling body.
   ------------------------------------------------------------------------- */

.tmt-gb-popup .tmt-gb-popup__popup-category {
	margin: 0 0 8px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.4;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #d34400;
}

/* Sits directly under the header row, so it carries the gap the heading used
   to own. */
.tmt-gb-popup .tmt-gb-popup__popup-subheading {
	margin: 16px 0 16px;
	font-family: inherit;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.35;
	color: #12384b;
}

/* With no sub-heading the description needs that gap instead. */
.tmt-gb-popup .tmt-gb-popup__popup-subheading + .tmt-gb-popup__popup-text {
	margin-top: 0;
}

.tmt-gb-popup .tmt-gb-popup__body > .tmt-gb-popup__popup-text:first-child {
	margin-top: 16px;
}

.tmt-gb-popup .tmt-gb-popup__popup-link {
	margin: 16px 0 0;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.6;

	/* A pasted address must wrap rather than widen the dialog on a phone. */
	overflow-wrap: anywhere;
}

.tmt-gb-popup .tmt-gb-popup__popup-link a {
	color: #007cbd;
	text-decoration: underline;
}

.tmt-gb-popup .tmt-gb-popup__popup-link a:hover,
.tmt-gb-popup .tmt-gb-popup__popup-link a:focus-visible {
	text-decoration: none;
}

/* The extra line carries the same class, so everything under Style > Popup
   Website Link applies to it too and there is only one place to style links.
   The modifier exists so its own spacing can be set separately. */
.tmt-gb-popup .tmt-gb-popup__popup-link--extra {
	margin-top: 12px;
}

/* Contained, never cropped -- which is the whole difference between a logo and
   a gallery image. */
.tmt-gb-popup .tmt-gb-popup__popup-logo {
	margin: 24px 0 0;
}

.tmt-gb-popup .tmt-gb-popup__logo-img {
	display: block;
	width: auto;
	height: auto;
	max-width: 228px;
	max-height: 90px;
	object-fit: contain;
}

.tmt-gb-popup .tmt-gb-popup__popup-banner {
	margin: 24px 0 0;
	overflow: hidden;
	border-radius: 4px;
}

.tmt-gb-popup .tmt-gb-popup__banner-img {
	display: block;
	width: 100%;
	height: 320px;
	object-fit: cover;
	object-position: center;
}

.tmt-gb-popup .tmt-gb-popup__gallery {
	margin-top: 24px;
}

/*
 * Slides share one grid cell, so the viewport is never taller than one image
 * and swapping slides cannot shift the dialog around them.
 */
.tmt-gb-popup .tmt-gb-popup__viewport {
	display: grid;
	grid-template-areas: "slide";
	height: 400px;
	overflow: hidden;
	border-radius: 4px;
}

.tmt-gb-popup .tmt-gb-popup__slide {
	grid-area: slide;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.tmt-gb-popup .tmt-gb-popup__slide.is-current {
	opacity: 1;
	visibility: visible;
	transition-delay: 0s;
}

.tmt-gb-popup .tmt-gb-popup__slide img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Footer: slider controls + card navigation ------------------------------- */

.tmt-gb-popup .tmt-gb-popup__footer {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	flex-wrap: wrap;
	gap: 16px;
	margin-top: 18px;
}

.tmt-gb-popup .tmt-gb-popup__slider-controls {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.tmt-gb-popup button.tmt-gb-popup__playpause,
.tmt-gb-popup button.tmt-gb-popup__gallery-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 6px;
	background-color: transparent;
	color: #1b7fc4;
	font-size: 14px;
	transition: color 0.2s ease;
}

.tmt-gb-popup .tmt-gb-popup__gallery-nav {
	display: flex;
	align-items: center;
	gap: 4px;
}

.tmt-gb-popup .tmt-gb-popup__playpause .tmt-gb-popup__pp-icon--play {
	display: none;
}

.tmt-gb-popup.is-gallery-paused .tmt-gb-popup__playpause .tmt-gb-popup__pp-icon--play {
	display: inline-flex;
}

.tmt-gb-popup.is-gallery-paused .tmt-gb-popup__playpause .tmt-gb-popup__pp-icon--pause {
	display: none;
}

.tmt-gb-popup .tmt-gb-popup__dots {
	--tmt-cards-dot: #c5d5e2;
	--tmt-cards-dot-progress: #5b8cb0;
	--tmt-cards-dot-size: 7px;
	--tmt-cards-dot-active: 30px;

	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
}

.tmt-gb-popup button.tmt-gb-popup__dot {
	position: relative;
	display: block;
	flex: 0 0 auto;
	width: var(--tmt-cards-dot-size);
	height: var(--tmt-cards-dot-size);
	padding: 0;
	overflow: hidden;
	border-radius: 999px;
	background-color: var(--tmt-cards-dot);
	transition: width 0.25s ease;
}

.tmt-gb-popup .tmt-gb-popup__dot.is-current {
	width: var(--tmt-cards-dot-active);
}

.tmt-gb-popup .tmt-gb-popup__dot-fill {
	position: absolute;
	inset: 0 auto 0 0;
	display: block;
	width: 0;
	border-radius: inherit;
	background-color: var(--tmt-cards-dot-progress);
}

/*
 * The fill is a paused/running animation rather than a re-started one: pressing
 * play has to carry on from where pause left it, not rewind to the first image.
 */
.tmt-gb-popup .tmt-gb-popup__dot.is-current .tmt-gb-popup__dot-fill {
	animation: tmt-cards-progress var(--tmt-cards-progress-duration, 4s) linear forwards;
}

.tmt-gb-popup.is-gallery-paused .tmt-gb-popup__dot.is-current .tmt-gb-popup__dot-fill {
	animation-play-state: paused;
}

@keyframes tmt-cards-progress {
	from {
		width: 0;
	}

	to {
		width: 100%;
	}
}

.tmt-gb-popup .tmt-gb-popup__nav {
	display: flex;
	align-items: center;
	gap: 12px;
}

.tmt-gb-popup button.tmt-gb-popup__nav-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 20px;
	border: 1px solid rgba(18, 56, 75, 0.3);
	border-radius: 40px;
	background-color: transparent;
	color: #12384b;
	font-size: 14px;
	font-weight: 700;
	transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.tmt-gb-popup .tmt-gb-popup__nav-btn[disabled] {
	opacity: 0.4;
	cursor: default;
}

.tmt-gb-popup .tmt-gb-popup__nav-btn[hidden] {
	display: none;
}

/* Screen-reader only. */
.tmt-gb-popup .tmt-gb-popup__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1024px) {
	.tmt-gb-popup .tmt-gb-popup__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tmt-gb-popup .tmt-gb-popup__popup-heading {
		font-size: 24px;
	}

	.tmt-gb-popup .tmt-gb-popup__popup-subheading {
		font-size: 18px;
	}

	.tmt-gb-popup .tmt-gb-popup__banner-img {
		height: 260px;
	}

	.tmt-gb-popup .tmt-gb-popup__viewport {
		height: 320px;
	}
}

@media (max-width: 767px) {
	.tmt-gb-popup .tmt-gb-popup__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.tmt-gb-popup .tmt-gb-popup__popup {
		padding: 10px;
	}

	.tmt-gb-popup .tmt-gb-popup__dialog {
		max-height: 94vh;
		padding: 60px 18px 22px;
	}

	.tmt-gb-popup .tmt-gb-popup__viewport {
		height: 220px;
	}

	.tmt-gb-popup button.tmt-gb-popup__close {
		top: 16px;
		right: 16px;
	}

	.tmt-gb-popup .tmt-gb-popup__popup-heading {
		font-size: 20px;
	}

	.tmt-gb-popup .tmt-gb-popup__popup-category {
		font-size: 13px;
	}

	.tmt-gb-popup .tmt-gb-popup__popup-subheading {
		margin: 12px 0;
		font-size: 17px;
	}

	.tmt-gb-popup .tmt-gb-popup__popup-logo {
		margin-top: 18px;
	}

	.tmt-gb-popup .tmt-gb-popup__logo-img {
		max-width: 180px;
		max-height: 70px;
	}

	.tmt-gb-popup .tmt-gb-popup__popup-banner {
		margin-top: 18px;
	}

	.tmt-gb-popup .tmt-gb-popup__banner-img {
		height: 180px;
	}

	/* Long words and pasted URLs must not force a sideways scroll. */
	.tmt-gb-popup .tmt-gb-popup__body {
		overflow-wrap: break-word;
	}

	/* Images and embeds inside the description obey the dialog, not the other
	   way round. */
	.tmt-gb-popup .tmt-gb-popup__popup-text img,
	.tmt-gb-popup .tmt-gb-popup__popup-text iframe,
	.tmt-gb-popup .tmt-gb-popup__popup-text table {
		max-width: 100%;
		height: auto;
	}

	/* Wrap rather than squeeze when play/pause, dots and arrows share a narrow
	   row. */
	.tmt-gb-popup .tmt-gb-popup__slider-controls {
		flex-wrap: wrap;
		gap: 10px;
	}

	/* Stack the two control groups so neither is squeezed off screen. */
	.tmt-gb-popup .tmt-gb-popup__footer {
		justify-content: center;
		gap: 12px;
	}

	.tmt-gb-popup .tmt-gb-popup__head {
		flex-wrap: wrap;
		gap: 12px;
	}

	.tmt-gb-popup .tmt-gb-popup__nav {
		width: 100%;
		justify-content: flex-start;
	}

	.tmt-gb-popup .tmt-gb-popup__nav-btn {
		flex: 1 1 0;
	}
}

/* Landscape phones: plenty of width, almost no height. Without this the image
   alone fills the screen and the text below it is unreachable. */
@media (max-height: 520px) and (orientation: landscape) {

	.tmt-gb-popup .tmt-gb-popup__dialog {
		max-height: 96dvh;
		padding: 48px 20px 16px;
	}

	.tmt-gb-popup .tmt-gb-popup__viewport {
		height: 160px;
	}

	.tmt-gb-popup .tmt-gb-popup__banner-img {
		height: 160px;
	}

	.tmt-gb-popup .tmt-gb-popup__popup-heading {
		font-size: 20px;
	}
}

/* Very narrow phones. */
@media (max-width: 380px) {

	.tmt-gb-popup .tmt-gb-popup__popup {
		padding: 6px;
	}

	.tmt-gb-popup .tmt-gb-popup__dialog {
		padding: 52px 14px 18px;
	}

	.tmt-gb-popup .tmt-gb-popup__viewport {
		height: 180px;
	}

	.tmt-gb-popup .tmt-gb-popup__banner-img {
		height: 150px;
	}

	/* Prev and Next share the row evenly instead of one wrapping alone. */
	.tmt-gb-popup .tmt-gb-popup__nav-btn {
		padding-inline: 10px;
		font-size: 13px;
	}

	.tmt-gb-popup .tmt-gb-popup__slider-controls {
		gap: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tmt-gb-popup .tmt-gb-popup__image,
	.tmt-gb-popup .tmt-gb-popup__overlay,
	.tmt-gb-popup .tmt-gb-popup__heading,
	.tmt-gb-popup .tmt-gb-popup__slide,
	.tmt-gb-popup .tmt-gb-popup__dot {
		transition-duration: 1ms !important;
	}
}

/* Clickable cards ---------------------------------------------------------
 *
 * The whole card opens its popup, so the whole card should look like it does.
 * Without this the pointer is an arrow over the card and a text caret over the
 * category, heading and description inside it, which reads as "this text is
 * selectable" rather than "this opens something".
 *
 * The class is put on by the script, which is the only place that knows which
 * elements the panel's selector matched. The descendant rule is what covers the
 * headings; it is scoped to inside a card, so nothing else on the page is
 * affected. Anything a card may legitimately contain that needs its own cursor
 * - a real link, a button, an input - keeps it.
 */

.tmt-gb-popup-card,
.tmt-gb-popup-card * {
	cursor: pointer;
}

.tmt-gb-popup-card a,
.tmt-gb-popup-card button,
.tmt-gb-popup-card input,
.tmt-gb-popup-card select,
.tmt-gb-popup-card textarea {
	cursor: revert;
}
