/*
 * "Ask GradeIt" chat widget (TGF_Assistant).
 * GradeIt's own look, as the site notice uses it: Montserrat, the yellow CTA
 * (#f5cb45 on black), and the logo-star bar along the top edge. Hardcoded,
 * because this prints into wp_footer outside the theme's scoped selectors.
 */
.tgf-ai {
	--tgf-ai-bottom: 16px;
	position: fixed;
	right: 16px;
	bottom: var(--tgf-ai-bottom);
	z-index: 1000; /* above the cutoff bar (999), below modals */
	font-family: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #1e1e1e;
}

/* Before the script runs (wp-rocket delays it until the first interaction),
   clear the cutoff bar roughly; the script then measures it exactly. */
body:has(.tgf-cutoff-bar) .tgf-ai { --tgf-ai-bottom: 128px; }

.tgf-ai *,
.tgf-ai *::before,
.tgf-ai *::after { box-sizing: border-box; }

.tgf-ai--left { right: auto; left: 16px; }

/* A small round button: the bot on GradeIt's dark, with a thin yellow ring. */
.tgf-ai__launcher {
	display: grid;
	place-items: center;
	width: 60px;
	height: 60px;
	padding: 0;
	border: 2px solid #f5cb45;
	border-radius: 50%;
	background: #1e1e1e;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
	transition: transform .15s ease, box-shadow .15s ease;
}
.tgf-ai__bot {
	display: block;
	width: 44px;
	height: 44px;
	max-width: none;
	pointer-events: none;
}
/* The theme paints every button:hover/:focus teal; hold our own colours. */
.tgf-ai button.tgf-ai__launcher:hover,
.tgf-ai button.tgf-ai__launcher:focus { background: #1e1e1e; border-color: #f5cb45; }
.tgf-ai button.tgf-ai__send:hover,
.tgf-ai button.tgf-ai__send:focus { background: #f5cb45; color: #000; }
.tgf-ai button.tgf-ai__reset:hover, .tgf-ai button.tgf-ai__reset:focus,
.tgf-ai button.tgf-ai__close:hover, .tgf-ai button.tgf-ai__close:focus { background: transparent; color: #fff; }
.tgf-ai button.tgf-ai__chip:focus { background: #fff; color: #1e1e1e; }
.tgf-ai button.tgf-ai__chip:hover { background: #f5cb45; border-color: #f5cb45; color: #000; }
.tgf-ai__launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.tgf-ai__launcher:focus-visible { outline: 3px solid #77cfd1; outline-offset: 2px; }

.tgf-ai__head-bot { width: 28px; height: 28px; flex: none; }

.tgf-ai.is-open .tgf-ai__launcher { display: none; }

.tgf-ai__panel {
	display: flex;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - var(--tgf-ai-bottom) - 24px);
	overflow: hidden;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}
.tgf-ai__panel[hidden] { display: none; }

.tgf-ai__head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 14px 12px 12px 16px;
	border-top: 4px solid #f5cb45;
	border-image: linear-gradient(90deg, #f5cb45 0 33.3%, #77cfd1 33.3% 66.6%, #e56a59 66.6%) 1;
	background: #1e1e1e;
	color: #fff;
}
.tgf-ai__title {
	flex: 1;
	font-weight: 600;
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: .04em;
}
.tgf-ai__reset,
.tgf-ai__close {
	border: 0;
	background: transparent;
	color: #ccc;
	cursor: pointer;
	padding: 4px 6px;
	font: inherit;
}
.tgf-ai__reset { font-size: 12px; text-decoration: underline; }
.tgf-ai__close { font-size: 24px; line-height: 1; }
.tgf-ai__reset:hover,
.tgf-ai__close:hover { color: #fff; }

.tgf-ai__log {
	position: relative;
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f6f6f4;
}

.tgf-ai__msg {
	max-width: 88%;
	margin: 0 0 10px;
	padding: 10px 12px;
	border-radius: 12px;
	word-wrap: break-word;
	color: #4c4c4c;
}
.tgf-ai__msg p { margin: 0 0 6px; }
.tgf-ai__msg p:last-child { margin-bottom: 0; }
.tgf-ai__msg ul { margin: 4px 0 6px; padding-left: 18px; }
.tgf-ai__msg li { margin: 2px 0; }
.tgf-ai__msg strong { color: #1e1e1e; }
.tgf-ai__msg a { color: #1e1e1e; text-decoration: underline; }

.tgf-ai__msg--assistant {
	background: #fff;
	border: 1px solid #e6e6e2;
	border-bottom-left-radius: 4px;
}
.tgf-ai__msg--user {
	margin-left: auto;
	background: #1e1e1e;
	color: #fff;
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}
.tgf-ai__msg--error { border-color: #e56a59; }

.tgf-ai__msg--typing { display: inline-flex; gap: 4px; }
.tgf-ai__msg--typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #bbb;
	animation: tgf-ai-blink 1.2s infinite ease-in-out;
}
.tgf-ai__msg--typing span:nth-child(2) { animation-delay: .2s; }
.tgf-ai__msg--typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tgf-ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.tgf-ai__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 12px 0;
	background: #f6f6f4;
}
.tgf-ai__chips[hidden] { display: none; }
.tgf-ai__chip {
	padding: 6px 10px;
	border: 1px solid #1e1e1e;
	border-radius: 999px;
	background: #fff;
	color: #1e1e1e;
	font: 500 12px/1.3 Montserrat, sans-serif;
	cursor: pointer;
}
.tgf-ai__chip:hover { background: #f5cb45; border-color: #f5cb45; }
a.tgf-ai__chip {
	display: inline-block;
	text-decoration: none;
}
.tgf-ai a.tgf-ai__chip--link,
.tgf-ai a.tgf-ai__chip--link:visited {
	background: #1e1e1e;
	border-color: #1e1e1e;
	color: #fff;
}
.tgf-ai a.tgf-ai__chip--link:hover,
.tgf-ai a.tgf-ai__chip--link:focus { background: #f5cb45; border-color: #f5cb45; color: #000; text-decoration: none; }

.tgf-ai__form {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	padding: 12px;
	background: #f6f6f4;
	border-top: 1px solid #e6e6e2;
}
.tgf-ai__input {
	flex: 1;
	min-height: 40px;
	max-height: 120px;
	padding: 9px 12px;
	border: 1px solid #ccc;
	border-radius: 8px;
	background: #fff;
	color: #1e1e1e;
	font: 14px/1.4 Montserrat, sans-serif;
	resize: none;
}
.tgf-ai__input:focus { outline: 2px solid #77cfd1; border-color: #77cfd1; }
.tgf-ai__send {
	height: 40px;
	padding: 0 16px;
	border: 0;
	border-radius: 4px;
	background: #f5cb45;
	color: #000;
	font: 600 12px/1 Montserrat, sans-serif;
	text-transform: uppercase;
	cursor: pointer;
}
.tgf-ai__send:disabled { opacity: .5; cursor: default; }

.tgf-ai__foot {
	margin: 0;
	padding: 0 12px 10px;
	background: #f6f6f4;
	color: #777;
	font-size: 11px;
}
.tgf-ai__foot a { color: #4c4c4c; }

.tgf-ai .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

@media (max-width: 560px) {
	.tgf-ai { right: 12px; }
	.tgf-ai--left { right: auto; left: 12px; }
	.tgf-ai__launcher { width: 54px; height: 54px; }
	.tgf-ai__bot { width: 40px; height: 40px; }
	.tgf-ai.is-open,
	.tgf-ai--left.is-open {
		top: 0;
		right: 0;
		left: 0;
		bottom: 0;
	}
	.tgf-ai__panel {
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border-radius: 0;
	}
	/* 16px stops iOS zooming into the field. */
	.tgf-ai__input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
	.tgf-ai__launcher,
	.tgf-ai__msg--typing span { transition: none; animation: none; }
}

/* "Have a question?" speech bubble beside the launcher. Revealed by CSS after
   the configured delay, so it appears even before wp-rocket releases the
   script; the script only takes it away again (opened, or closed with ×). */
.tgf-ai__nudge {
	position: absolute;
	right: 72px;
	bottom: 10px;
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 4px 4px 4px 14px;
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
	white-space: nowrap;
	opacity: 0;
	visibility: hidden;
	transform: translateX(8px);
	animation: tgf-ai-nudge-in .35s ease forwards;
	animation-delay: var(--tgf-ai-nudge-delay, 10s);
}
/* The tail, pointing at the bot. */
.tgf-ai__nudge::after {
	content: "";
	position: absolute;
	right: -6px;
	bottom: 14px;
	width: 12px;
	height: 12px;
	background: #fff;
	transform: rotate(45deg);
	border-radius: 2px;
}
.tgf-ai--left .tgf-ai__nudge { right: auto; left: 72px; }
.tgf-ai--left .tgf-ai__nudge::after { right: auto; left: -6px; }
@keyframes tgf-ai-nudge-in {
	to { opacity: 1; visibility: visible; transform: none; }
}
.tgf-ai.is-open .tgf-ai__nudge,
.tgf-ai.is-nudged .tgf-ai__nudge { display: none; }

.tgf-ai .tgf-ai__nudge button {
	position: relative;
	z-index: 1;
	margin: 0;
	border: 0;
	background: transparent;
	color: #1e1e1e;
	font: 600 14px/1.2 Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	box-shadow: none;
}
.tgf-ai .tgf-ai__nudge .tgf-ai__nudge-text { padding: 6px 4px; }
.tgf-ai .tgf-ai__nudge .tgf-ai__nudge-x { width: 26px; height: 26px; padding: 0; border-radius: 50%; color: #888; font-size: 18px; }
.tgf-ai .tgf-ai__nudge button:hover,
.tgf-ai .tgf-ai__nudge button:focus { background: transparent; color: #000; }
.tgf-ai .tgf-ai__nudge .tgf-ai__nudge-x:hover { background: #f1f1f1; }
@media (prefers-reduced-motion: reduce) {
	.tgf-ai__nudge { transform: none; animation-duration: .01s; }
}

/* Illustrated steps under an answer (1.29.1 — the packing guide). */
.tgf-ai__steps {
	display: flex;
	gap: 8px;
	margin: 10px -4px 2px;
	padding: 0 4px 6px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
}
.tgf-ai__step {
	flex: 0 0 150px;
	scroll-snap-align: start;
	border-radius: 10px;
	background: linear-gradient(160deg, #26262a, #141416);
	color: #f4f5f7;
	padding: 8px 8px 10px;
	font-family: Montserrat, sans-serif;
}
.tgf-ai__step-art { aspect-ratio: 16 / 10; }
.tgf-ai__step-art svg { width: 100%; height: 100%; display: block; }
.tgf-ai__step-n {
	display: inline-block;
	margin-top: 6px;
	padding: 1px 8px;
	border-radius: 999px;
	background: #F6C33D;
	color: #1a1a1b;
	font-size: 10px;
	font-weight: 800;
	letter-spacing: .06em;
	text-transform: uppercase;
}
.tgf-ai__step-t { margin-top: 4px; font-size: 12px; font-weight: 700; line-height: 1.3; color: #fff; }
.tgf-ai__msg .tgf-ai__step strong { color: #fff; }
