/* Ask Nora — Liquid Metal button

   Markup:
   <button class="ai-metal" type="button">
     <span class="material-symbols-rounded">auto_awesome</span>
     <span class="ai-metal__label">Ask Nora</span>
   </button>

   Theme integration:
   Set data-theme-resolved="light" or "dark" on <html>.
   The button follows that attribute automatically.
   Load Material Symbols Rounded on your site, as you already do.
*/

.ai-metal {
	--ai-metal-ink: #171717;
	--ai-metal-face-top: #ffffff;
	--ai-metal-face-mid: #f4f4f4;
	--ai-metal-face-bottom: #dedede;
	--ai-metal-base-edge: rgba(255, 255, 255, .98);
	--ai-metal-rim-dark: rgba(25, 25, 25, .94);
	--ai-metal-rim-mid: rgba(120, 120, 120, .9);
	--ai-metal-rim-light: rgba(255, 255, 255, .98);
	--ai-metal-shadow:
		0 7px 13px rgba(0, 0, 0, .15),
		0 2px 4px rgba(0, 0, 0, .10),
		inset 0 1px 0 rgba(255, 255, 255, .96),
		inset 0 -1px 1px rgba(70, 70, 70, .16);

	position: relative;
	isolation: isolate;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .58em;
	width: max-content;
	max-width: 100%;
	min-width: 0;
	padding: .64em 1.12em;
	border: 1px solid var(--ai-metal-base-edge);
	border-radius: 999px;
	color: var(--ai-metal-ink);
	background: linear-gradient(
		180deg,
		var(--ai-metal-face-top) 0%,
		var(--ai-metal-face-mid) 48%,
		var(--ai-metal-face-bottom) 100%
	);
	box-shadow: var(--ai-metal-shadow);
	font: inherit;
	line-height: 1.05;
	letter-spacing: normal;
	text-align: center;
	white-space: nowrap;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition:
		color .35s ease,
		background .35s ease,
		border-color .35s ease,
		box-shadow .35s ease,
		transform .25s ease,
		filter .25s ease;
}

/* Animated specular streak around the perimeter. */
.ai-metal::before {
	content: "";
	position: absolute;
	z-index: 1;
	inset: -1.25px;
	padding: 1.35px;
	border-radius: inherit;
	pointer-events: none;
	background: conic-gradient(
		from 0deg,
		transparent 0deg 25deg,
		var(--ai-metal-rim-dark) 28deg,
		var(--ai-metal-rim-mid) 29.2deg,
		var(--ai-metal-rim-light) 30.4deg,
		rgba(180, 220, 238, .95) 31.2deg,
		rgba(221, 190, 160, .8) 32.2deg,
		transparent 35deg 178deg,
		rgba(255, 255, 255, .32) 181deg,
		transparent 185deg 360deg
	);
	-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, linear-gradient(#000 0 0);
	mask-composite: exclude;
	animation: ai-metal-rim-spin 7.8s linear infinite;
	will-change: transform;
}

/*
 * Face shimmer: the pseudo-element itself never moves. Only its background
 * position animates, so the highlight is clipped by this inset rounded layer
 * and cannot slide outside the button.
 */
.ai-metal::after {
	content: "";
	position: absolute;
	z-index: 0;
	inset: 1.5px;
	border-radius: inherit;
	pointer-events: none;
	background-image: linear-gradient(
		108deg,
		transparent 0%,
		transparent 38%,
		rgba(255, 255, 255, 0) 43%,
		rgba(255, 255, 255, .14) 46%,
		rgba(255, 255, 255, .52) 49%,
		rgba(255, 255, 255, .18) 52%,
		rgba(255, 255, 255, 0) 56%,
		transparent 62%,
		transparent 100%
	);
	background-repeat: no-repeat;
	background-size: 260% 100%;
	background-position: 100% 50%;
	animation: ai-metal-face-glint 8.5s ease-in-out infinite;
}

.ai-metal .material-symbols-rounded,
.ai-metal__label {
	position: relative;
	z-index: 2;
}

.ai-metal .material-symbols-rounded {
	display: inline-block;
	flex: 0 0 auto;
	font-size: 1.14em;
	font-weight: normal;
	line-height: 1;
	white-space: nowrap;
}

.ai-metal__label {
	display: inline-block;
	font: inherit;
	line-height: inherit;
}

.ai-metal:hover {
	transform: translateY(-1.5px) scale(1.018);
	box-shadow:
		0 10px 18px rgba(0, 0, 0, .18),
		0 3px 5px rgba(0, 0, 0, .11),
		inset 0 1px 0 rgba(255, 255, 255, .98),
		inset 0 -1px 1px rgba(70, 70, 70, .18);
	filter: saturate(1.05) brightness(1.015);
}

.ai-metal:hover::before { animation-duration: 3.5s; }
.ai-metal:hover::after { animation-duration: 3.6s; }

.ai-metal:active {
	transform: translateY(0) scale(.985);
	box-shadow:
		0 2px 4px rgba(0, 0, 0, .13),
		inset 0 2px 4px rgba(0, 0, 0, .12),
		inset 0 1px 0 rgba(255, 255, 255, .6);
}

.ai-metal:focus-visible {
	outline: 3px solid rgba(90, 140, 255, .72);
	outline-offset: 4px;
}

/* Theme is resolved by the site's existing updateThemeUI() function. */
:root[data-theme-resolved="dark"] .ai-metal {
	--ai-metal-ink: #f5f5f5;
	--ai-metal-face-top: #3d3d3d;
	--ai-metal-face-mid: #292929;
	--ai-metal-face-bottom: #171717;
	--ai-metal-base-edge: rgba(235, 235, 235, .78);
	--ai-metal-rim-dark: rgba(12, 12, 12, .98);
	--ai-metal-rim-mid: rgba(130, 130, 130, .95);
	--ai-metal-rim-light: rgba(255, 255, 255, .98);
	--ai-metal-shadow:
		0 7px 15px rgba(0, 0, 0, .52),
		0 2px 4px rgba(0, 0, 0, .45),
		inset 0 1px 0 rgba(255, 255, 255, .42),
		inset 0 -1px 1px rgba(0, 0, 0, .92);
}

:root[data-theme-resolved="dark"] .ai-metal::after {
	background-image: linear-gradient(
		108deg,
		transparent 0%,
		transparent 38%,
		rgba(255, 255, 255, 0) 43%,
		rgba(255, 255, 255, .08) 46%,
		rgba(255, 255, 255, .30) 49%,
		rgba(255, 255, 255, .10) 52%,
		rgba(255, 255, 255, 0) 56%,
		transparent 62%,
		transparent 100%
	);
}

:root[data-theme-resolved="dark"] .ai-metal:hover {
	box-shadow:
		0 10px 20px rgba(0, 0, 0, .62),
		0 3px 5px rgba(0, 0, 0, .48),
		inset 0 1px 0 rgba(255, 255, 255, .48),
		inset 0 -1px 1px rgba(0, 0, 0, .95);
}

@keyframes ai-metal-rim-spin {
	to { transform: rotate(1turn); }
}

/* From background-position 100% to 0%, the glint travels left to right. */
@keyframes ai-metal-face-glint {
	0%, 18% { background-position: 100% 50%; }
	62%, 100% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
	.ai-metal,
	.ai-metal::before,
	.ai-metal::after {
		animation: none !important;
		transition: none !important;
	}
}
