/**
 * Floating "AI Mode" button + "Find Your Best-Fit Program." card.
 * Figma "Frame 2" (252 wide, column, gap 4):
 *  - card: white, radius 19, 2px "AI Gradient" border, padding 16/40/13/13
 *  - button: white pill 165 × 55, radius 50, 2px "AI Gradient" border,
 *    icon 23 + "AI Mode" (gradient text, 17 medium)
 *  - mobile: icon-only round button
 * AI Gradient: #E4E4E4 0%, #5B2CB7 25%, #BD138F 54%, #616161 82%, #FFF 100%
 * (here as a rotating conic border).
 *
 * @package AIBM
 * @author  Sameer Ali N
 */

.aibm-ai {
	/* Static "AI Gradient" border (Figma stroke) */
	--aibm-ai-base: linear-gradient(135deg, #E4E4E4 0%, #5B2CB7 25%, #BD138F 54%, #616161 82%, #FFFFFF 100%);
	/*
	 * Moving light: two short bright streaks (opposite each other) that
	 * travel around the border, like the reference video.
	 */
	--aibm-ai-ring: conic-gradient(
		from 0deg,
		transparent 0deg,
		transparent 118deg,
		rgba(91, 44, 183, .9) 136deg,
		#BD138F 150deg,
		#FFFFFF 160deg,
		#38BDF8 168deg,
		transparent 186deg,
		transparent 298deg,
		rgba(91, 44, 183, .9) 316deg,
		#BD138F 330deg,
		#FFFFFF 340deg,
		#38BDF8 348deg,
		transparent 360deg
	);
	--aibm-ai-text: linear-gradient(90deg, #5B2CB7 0%, #8A1FA8 45%, #BD138F 80%, #9C1C8C 100%);

	/*
	 * Position (Figma "Frame 2"): near the bottom of the first screen and
	 * starting left of the content edge (the hero text), in the side margin
	 * (Figma: 48px from the screen edge when the text starts at 120px). It is fixed,
	 * so it stays in this spot while the page scrolls.
	 * Adjust with these two variables.
	 */
	--aibm-ai-bottom: max(18px, 4vh);
	--aibm-ai-left: max(16px, calc(max(var(--aibm-gutter, 40px), calc(50vw - var(--aibm-container, 1340px) / 2)) * .42));

	position: fixed;
	bottom: var(--aibm-ai-bottom);
	left: var(--aibm-ai-left);
	z-index: 990;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	width: max-content;
	max-width: calc(100vw - 32px);
	font-family: var(--aibm-font-body, "Spoof", "Inter", system-ui, sans-serif);
	pointer-events: none;
}

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

/* Gradient border (card + button): static AI Gradient + moving light */
.aibm-ai__card,
.aibm-ai__btn {
	position: relative;
	isolation: isolate;
	border: 2px solid transparent !important;
	background:
		linear-gradient(#fff, #fff) padding-box,
		var(--aibm-ai-base) border-box !important;
}

/* Ring layer: only the 2px border area is visible (mask), a large
   conic square inside it rotates, so the light travels round the edge. */
.aibm-ai__glow {
	position: absolute;
	inset: -2px;
	z-index: 1;
	padding: 2px;
	border-radius: inherit;
	overflow: hidden;
	pointer-events: none;
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.aibm-ai__glow::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 170%;
	aspect-ratio: 1;
	background: var(--aibm-ai-ring);
	transform: translate(-50%, -50%) rotate(0deg);
	animation: aibm-ai-spin 3s linear infinite;
	will-change: transform;
}

.aibm-ai__card > .aibm-ai__glow::before {
	width: 150%;
}

@keyframes aibm-ai-spin {
	to {
		transform: translate(-50%, -50%) rotate(360deg);
	}
}

/* ---------------------------------------------------------------
   Card (hidden until hover / tap)
--------------------------------------------------------------- */
.aibm-ai__card {
	position: relative;
	width: 290px;
	max-width: 100%;
	margin: 0;
	padding: 18px 34px 16px 18px;
	border-radius: 19px;
	box-shadow: 0 24px 48px -20px rgba(27, 20, 100, .45), 0 8px 18px -10px rgba(189, 19, 143, .25);
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px) scale(.97);
	transform-origin: bottom left;
	transition: opacity .25s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
	pointer-events: none;
}

.aibm-ai.is-open .aibm-ai__card {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .25s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s;
	pointer-events: auto;
}

/* Invisible bridge over the gap, so the card stays open while the
   mouse moves from the button to the card. */
.aibm-ai__card::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: -12px;
	left: 0;
	height: 12px;
}

@media (hover: hover) and (pointer: fine) {
	.aibm-ai:hover .aibm-ai__card {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: opacity .25s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s;
		pointer-events: auto;
	}
}

.aibm-ai .aibm-ai__title {
	margin: 0;
	padding: 0;
	background: var(--aibm-ai-text);
	-webkit-background-clip: text;
	background-clip: text;
	color: #5B2CB7;
	-webkit-text-fill-color: transparent;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.25;
	letter-spacing: -.01em;
}

.aibm-ai .aibm-ai__subtitle {
	margin: 2px 0 0;
	padding: 0;
	color: #898989;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.35;
}

.aibm-ai .aibm-ai__text {
	margin: 14px 0 0;
	padding: 0;
	color: #424242;
	font-size: 12.5px;
	font-weight: 400;
	line-height: 1.45;
	letter-spacing: -.005em;
}

.aibm-ai .aibm-ai__cta,
.aibm-ai .aibm-ai__cta:visited {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	margin-top: 15px;
	padding: 0 22px;
	border-radius: 50px;
	background: #1B1464;
	color: #E2E8F0;
	font-size: 12.5px;
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
	transition: background-color .2s ease, color .2s ease, transform .2s ease;
}

.aibm-ai .aibm-ai__cta:hover {
	background: #0F1396;
	color: #fff;
	transform: translateY(-1px);
}

.aibm-ai .aibm-ai__cta:focus-visible {
	outline: 2px solid #BD138F;
	outline-offset: 3px;
}

/* ---------------------------------------------------------------
   AI Mode button
--------------------------------------------------------------- */
.aibm-ai .aibm-ai__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-width: 165px;
	height: 55px;
	margin: 0;
	padding: 0 32px;
	border-radius: 50px;
	box-shadow: 0 14px 30px -12px rgba(27, 20, 100, .55), 0 6px 16px -8px rgba(189, 19, 143, .35);
	color: #5B2CB7;
	font: inherit;
	line-height: 1;
	text-transform: none;
	cursor: pointer;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
	transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s ease;
}

/* Same colours in every state (the theme restyles button:hover/focus). */
.aibm-ai .aibm-ai__btn:hover,
.aibm-ai .aibm-ai__btn:focus,
.aibm-ai .aibm-ai__btn:active,
.aibm-ai.is-open .aibm-ai__btn {
	border-color: transparent !important;
	background:
		linear-gradient(#fff, #fff) padding-box,
		var(--aibm-ai-base) border-box !important;
	color: #5B2CB7 !important;
}

.aibm-ai .aibm-ai__btn:hover,
.aibm-ai.is-open .aibm-ai__btn {
	transform: translateY(-2px);
	box-shadow: 0 18px 36px -12px rgba(27, 20, 100, .6), 0 8px 22px -8px rgba(189, 19, 143, .45);
}

.aibm-ai .aibm-ai__btn:focus {
	outline: none;
}

.aibm-ai .aibm-ai__btn:focus-visible {
	outline: 2px solid #BD138F;
	outline-offset: 4px;
}

.aibm-ai__icon {
	display: block;
	flex: 0 0 23px;
	width: 23px;
	height: 23px;
}

.aibm-ai__label {
	background: var(--aibm-ai-text);
	-webkit-background-clip: text;
	background-clip: text;
	color: #5B2CB7;
	-webkit-text-fill-color: transparent;
	font-size: 17px;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: -.01em;
	white-space: nowrap;
}

/* ---------------------------------------------------------------
   Tablet / phone
--------------------------------------------------------------- */
@media (max-width: 1099px) {
	.aibm-ai {
		--aibm-ai-left: var(--aibm-gutter, 32px);
	}
}

@media (max-width: 767px) {
	.aibm-ai {
		--aibm-ai-bottom: max(16px, 3vh);
		--aibm-ai-left: 16px;
		gap: 8px;
	}

	/* Icon-only round button */
	.aibm-ai .aibm-ai__btn {
		min-width: 0;
		width: 64px;
		height: 44px;
		padding: 0;
	}

	.aibm-ai__label {
		display: none;
	}

	.aibm-ai__icon {
		flex-basis: 22px;
		width: 22px;
		height: 22px;
	}

	.aibm-ai__card {
		width: min(300px, calc(100vw - 32px));
		padding: 16px 20px 16px 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.aibm-ai__glow::before {
		animation: none;
	}

	.aibm-ai__card,
	.aibm-ai.is-open .aibm-ai__card {
		transform: none;
		transition: opacity .15s ease, visibility 0s;
	}
}

@media print {
	.aibm-ai {
		display: none !important;
	}
}
