/**
 * TMT Culture Circle.
 *
 * Every selector is namespaced under .tmt-culture-circle so nothing here can
 * reach the theme, and the button resets are written with an element selector
 * (`button.tmt-culture-circle__item`) so a theme's global button styling cannot
 * outrank them. They stay below the three-class selectors Elementor generates
 * from the panel, which must keep winning.
 *
 * Geometry contract:
 *   Panel writes  --tmt-cc-ring-max, --tmt-cc-circle-pref, --tmt-cc-circle-min,
 *                 --tmt-cc-circle-gap, --tmt-cc-center-gap
 *   Script writes --tmt-cc-size, --tmt-cc-radius, --tmt-cc-circle,
 *                 --tmt-cc-center-max
 *   PHP writes    --tmt-cc-angle (per item)
 */

.tmt-culture-circle {
	--tmt-cc-ring-max: 520px;
	--tmt-cc-circle-pref: 118px;
	--tmt-cc-circle-min: 60px;
	--tmt-cc-circle-gap: 12px;
	--tmt-cc-center-gap: 18px;
	--tmt-cc-media: 26px;
	--tmt-cc-fade: 350ms;

	/* Solved by the script; these are only the pre-hydration fallbacks. */
	--tmt-cc-size: var(--tmt-cc-ring-max);
	--tmt-cc-circle: var(--tmt-cc-circle-pref);
	--tmt-cc-radius: calc((var(--tmt-cc-ring-max) - var(--tmt-cc-circle-pref)) / 2);
	--tmt-cc-center-max: 60%;

	--tmt-cc-bg: transparent;
	--tmt-cc-color: #fff;
	--tmt-cc-active-bg: transparent;
	--tmt-cc-active-color: #4a5a6a;
	--tmt-cc-active-scale: 1;
	/* Shipped artwork; the media controls override these. */
	--tmt-cc-image: url("../images/culture-circles.svg");
	--tmt-cc-active-image: url("../images/culture-circles-active.svg");
	--tmt-cc-pulse-speed: 2s;
	--tmt-cc-pulse-scale: 1.06;

	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-sizing: border-box;
	width: 100%;
}

.tmt-culture-circle *,
.tmt-culture-circle *::before,
.tmt-culture-circle *::after {
	box-sizing: border-box;
}

/* Stage / ring ------------------------------------------------------------ */

.tmt-culture-circle .tmt-culture-circle__stage {
	width: 100%;
	display: flex;
	justify-content: center;
}

.tmt-culture-circle .tmt-culture-circle__ring {
	position: relative;
	width: var(--tmt-cc-size);
	height: var(--tmt-cc-size);
	max-width: 100%;
	flex: 0 0 auto;
}

/*
 * rotate -> push out -> counter-rotate keeps every label upright whatever the
 * angle. The angle is the item's only fixed value; the radius is shared, so a
 * different item count needs no new CSS.
 */
/*
 * Placement and scale are variables, and `transform` is declared exactly once.
 * Every state - active, stacked - just rewrites a variable, so no two rules
 * ever compete for the transform property and no state can be shadowed by a
 * specificity accident.
 */
.tmt-culture-circle__item {
	--tmt-cc-place:
		rotate(var(--tmt-cc-angle, 0deg))
		translateY(calc(var(--tmt-cc-radius) * -1))
		rotate(calc(var(--tmt-cc-angle, 0deg) * -1));
	--tmt-cc-scale: 1;
}

.tmt-culture-circle button.tmt-culture-circle__item {
	position: absolute;
	top: 50%;
	left: 50%;
	width: var(--tmt-cc-circle);
	height: var(--tmt-cc-circle);
	margin: calc(var(--tmt-cc-circle) / -2) 0 0 calc(var(--tmt-cc-circle) / -2);
	padding: 18px;
	transform: var(--tmt-cc-place) scale(var(--tmt-cc-scale));
	transition:
		background-color 0.25s ease,
		border-color 0.25s ease,
		opacity 0.25s ease,
		transform 0.35s cubic-bezier(0.33, 0, 0.2, 1);
}

/* Theme/kit button reset. Deliberately free of anything a control writes. */
.tmt-culture-circle button.tmt-culture-circle__item,
.tmt-culture-circle button.tmt-culture-circle__item:hover,
.tmt-culture-circle button.tmt-culture-circle__item:focus,
.tmt-culture-circle button.tmt-culture-circle__item:active {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	min-height: 0;
	max-width: none;
	border: 0;
	border-radius: 50%;
	box-shadow: none;
	font-family: inherit;
	letter-spacing: normal;
	text-align: center;
	text-transform: none;
	text-decoration: none;
	white-space: normal;
	word-break: normal;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

/*
 * State paint, deliberately outside the reset above. That reset lists
 * :hover/:focus/:active, which makes it three classes plus an element - enough
 * to outrank `.is-active` and leave a just-clicked circle showing its normal
 * background. Keeping colour out of it removes the contest entirely.
 */
.tmt-culture-circle .tmt-culture-circle__item {
	background-color: var(--tmt-cc-item-bg, var(--tmt-cc-bg));
	background-image: var(--tmt-cc-item-image, var(--tmt-cc-image, none));
	background-repeat: no-repeat;
	background-position: center center;
	/* contain, not cover: the artwork's outer rings must not be cropped. */
	background-size: contain;
	color: var(--tmt-cc-item-color, var(--tmt-cc-color));
}

.tmt-culture-circle .tmt-culture-circle__item.is-active {
	--tmt-cc-scale: var(--tmt-cc-active-scale, 1);

	background-color: var(--tmt-cc-item-active-bg, var(--tmt-cc-active-bg));
	background-image: var(--tmt-cc-item-active-image, var(--tmt-cc-active-image, none));
	color: var(--tmt-cc-item-active-color, var(--tmt-cc-active-color));
	z-index: 2;
}

/*
 * The live site pulses the active circle. The keyframes repeat the placement
 * transform because an animation replaces the property outright - dropping it
 * would fling the circle back to the centre for the duration.
 */
.tmt-culture-circle.tmt-cc-pulse .tmt-culture-circle__item.is-active {
	animation: tmt-cc-pulse var(--tmt-cc-pulse-speed, 2s) infinite ease-in-out;
}

@keyframes tmt-cc-pulse {
	0%,
	100% {
		transform: var(--tmt-cc-place) scale(var(--tmt-cc-scale));
	}

	50% {
		transform: var(--tmt-cc-place) scale(calc(var(--tmt-cc-scale) * var(--tmt-cc-pulse-scale, 1.06)));
	}
}

.tmt-culture-circle .tmt-culture-circle__item:focus {
	outline: none;
}

.tmt-culture-circle .tmt-culture-circle__item:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

.tmt-culture-circle .tmt-culture-circle__item-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	width: 100%;
	min-width: 0;
}

.tmt-culture-circle .tmt-culture-circle__item-label {
	display: block;
	width: 100%;
	/* Tracks the solved diameter, so more circles shrink the label too. */
	font-size: clamp(9px, calc(var(--tmt-cc-circle) * 0.112), 15px);
	font-weight: 700;
	line-height: 1.2;
	white-space: normal;
	/* Breaks only a word with nowhere else to go; normal wrapping otherwise. */
	overflow-wrap: break-word;
}

.tmt-culture-circle .tmt-culture-circle__item-media {
	display: block;
	width: var(--tmt-cc-media);
	height: var(--tmt-cc-media);
	object-fit: contain;
	font-size: var(--tmt-cc-media);
	line-height: 1;
}

.tmt-culture-circle .tmt-culture-circle__item-media svg {
	width: 1em;
	height: 1em;
	display: block;
	fill: currentColor;
}

/* Centre ------------------------------------------------------------------ */

/*
 * All panels share one grid cell, so the box is as tall as the tallest panel
 * and swapping panels cannot shift anything around it.
 */
.tmt-culture-circle .tmt-culture-circle__center {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: grid;
	grid-template-areas: "panel";
	width: var(--tmt-cc-center-max);
	max-width: var(--tmt-cc-center-max);
	text-align: center;
	pointer-events: none;
}

.tmt-culture-circle .tmt-culture-circle__panel {
	grid-area: panel;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--tmt-cc-fade) ease, visibility 0s linear var(--tmt-cc-fade);
}

.tmt-culture-circle .tmt-culture-circle__panel.is-active {
	opacity: 1;
	visibility: visible;
	transition-delay: 0s;
	pointer-events: auto;
}

.tmt-culture-circle .tmt-culture-circle__heading {
	margin: 0 0 10px;
	padding: 0;
	font-family: inherit;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.35;
	overflow-wrap: break-word;
	color: #fff;
}

.tmt-culture-circle .tmt-culture-circle__text {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.5;
	overflow-wrap: break-word;
	color: #d8e2ea;
}

.tmt-culture-circle a.tmt-culture-circle__cta,
.tmt-culture-circle span.tmt-culture-circle__cta {
	display: inline-block;
	margin-top: 14px;
	border: 0;
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	background-color: #1b7fc4;
	color: #fff;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Play / pause ------------------------------------------------------------ */

.tmt-culture-circle .tmt-culture-circle__controls {
	display: flex;
	width: 100%;
	max-width: var(--tmt-cc-size);
	margin-top: 16px;
}

.tmt-cc-controls-bottom-left .tmt-culture-circle__controls {
	justify-content: flex-start;
}

.tmt-cc-controls-bottom .tmt-culture-circle__controls {
	justify-content: center;
}

.tmt-cc-controls-bottom-right .tmt-culture-circle__controls {
	justify-content: flex-end;
}

/* Inside the ring: sits under the centre text without affecting its box. */
.tmt-cc-controls-center .tmt-culture-circle__controls {
	position: absolute;
	left: 50%;
	top: calc(50% + var(--tmt-cc-radius) - var(--tmt-cc-circle));
	transform: translateX(-50%);
	width: auto;
	margin-top: 0;
	justify-content: center;
	z-index: 3;
}

.tmt-culture-circle button.tmt-culture-circle__playpause,
.tmt-culture-circle button.tmt-culture-circle__playpause:hover,
.tmt-culture-circle button.tmt-culture-circle__playpause:focus,
.tmt-culture-circle button.tmt-culture-circle__playpause:active {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 0;
	min-height: 0;
	max-width: none;
	margin: 0;
	border: 0;
	box-shadow: none;
	background-color: transparent;
	font-family: inherit;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	color: #1b7fc4;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.tmt-culture-circle .tmt-culture-circle__playpause:focus {
	outline: none;
}

.tmt-culture-circle .tmt-culture-circle__playpause:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

.tmt-culture-circle .tmt-culture-circle__pp-icon {
	display: inline-flex;
	width: 1em;
	height: 1em;
}

.tmt-culture-circle .tmt-culture-circle__pp-icon svg,
.tmt-culture-circle .tmt-culture-circle__pp-icon i {
	width: 1em;
	height: 1em;
	font-size: inherit;
	line-height: 1;
	display: block;
}

/*
 * Playing shows pause, paused shows play. Three classes so a two-class-plus-
 * element rule on the svg can never win and leave both icons on screen.
 */
.tmt-culture-circle .tmt-culture-circle__playpause .tmt-culture-circle__pp-icon--play {
	display: none;
}

.tmt-culture-circle.is-paused .tmt-culture-circle__playpause .tmt-culture-circle__pp-icon--play {
	display: inline-flex;
}

.tmt-culture-circle.is-paused .tmt-culture-circle__playpause .tmt-culture-circle__pp-icon--pause {
	display: none;
}

.tmt-culture-circle .tmt-culture-circle__pp-text {
	font-size: 13px;
	font-weight: 700;
}

/* Stacked fallback -------------------------------------------------------- */

/*
 * Chosen by the script, not by a breakpoint: when the solved diameter would
 * fall under the configured minimum the ring cannot hold the circles without
 * overlap, so they become a centred wrapped row with the panel underneath.
 * Nothing is hidden and every control still works.
 */
.tmt-culture-circle.is-stacked .tmt-culture-circle__ring {
	width: 100%;
	height: auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var(--tmt-cc-circle-gap);
}

/* Identity placement: the flex row puts them where they belong. */
.tmt-culture-circle.is-stacked .tmt-culture-circle__item {
	--tmt-cc-place: translate(0, 0);
}

.tmt-culture-circle.is-stacked button.tmt-culture-circle__item {
	position: static;
	margin: 0;
	width: var(--tmt-cc-circle);
	height: var(--tmt-cc-circle);
}

.tmt-culture-circle.is-stacked .tmt-culture-circle__center {
	position: static;
	order: 99;
	transform: none;
	width: 100%;
	max-width: 100%;
	margin-top: 24px;
	pointer-events: auto;
}

.tmt-culture-circle.is-stacked.tmt-cc-controls-center .tmt-culture-circle__controls,
.tmt-cc-controls-center .tmt-culture-circle.is-stacked .tmt-culture-circle__controls {
	position: static;
	transform: none;
	margin-top: 16px;
	width: 100%;
}

/* Reduced motion ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.tmt-culture-circle .tmt-culture-circle__item,
	.tmt-culture-circle .tmt-culture-circle__panel,
	.tmt-culture-circle .tmt-culture-circle__cta,
	.tmt-culture-circle .tmt-culture-circle__playpause {
		transition-duration: 1ms !important;
	}

	.tmt-culture-circle.tmt-cc-pulse .tmt-culture-circle__item.is-active {
		animation: none;
	}
}
