/*
**
**
**
**
**
** His Introduction
** =================================
**
** The few screens he walks someone through the first time they open search with him on
** (TL.MascotIntro, scripts/nav-mascot.intro.js). It's on his stage (.TL-Mascot-Stage,
** styles/nav-mascot.debut.css): first his hello in the middle of the screen, then a card with
** a tab for each thing he does. He perches over the open tab and hops along as they're
** clicked through.
**
** data-state is the stage's own ("closed", "open", "leaving"). data-step says what's showing:
** "wait" (he's on his way down), "hello", then the open tab ("new", "ask", "do", "learn").
** data-kind is "first" for someone new to him and "again" after an update. --Tabs is how many
** tabs there are and --At which one is open, counted from 0, for the marker that slides
** between them.
**
** The hello and the card share the middle of the stage, one fading out as the other comes
** up. The spot and the perches only mark where he goes, so nothing moves or scales them
** except the card settling in, which he follows.
*/

#TL-Mascot-Intro {
	--Intro-Accent: #7350ff;
	--Intro-Ink: #1d1d24;
	--Intro-Muted: rgba(29, 29, 36, 0.62);
	--Intro-Card: rgba(255, 255, 255, 0.97);
	--Intro-Soft: rgba(115, 80, 255, 0.07);
	--Intro-Track: rgba(60, 60, 80, 0.08);
	--Intro-Pill: #ffffff;
	--Intro-Spring: cubic-bezier(0.34, 1.56, 0.64, 1);
	--Intro-Perch: 68px;

	/* As tall as the screen that's really showing, so a phone's toolbar never covers the buttons.
	   On a screen too short for the card it starts at the top and scrolls, never cut off above */
	bottom: auto;
	height: 100dvh;
	box-sizing: border-box;
	display: grid;
	place-items: safe center;
	padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
	overflow-y: auto;
	overscroll-behavior: contain;
	outline: none;
}

#TL-Mascot-Intro > .hello,
#TL-Mascot-Intro > .card {
	grid-area: 1 / 1;
	position: relative;
}

/*
** Hello
** =================================
**
** His spot, with his name for them and a line under it. A tap moves on to the card.
*/

#TL-Mascot-Intro > .hello {
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 440px;
	padding-bottom: 8dvh;
	text-align: center;
	cursor: pointer;
	transition: opacity 260ms ease;
}
#TL-Mascot-Intro > .hello > .title,
#TL-Mascot-Intro > .hello > .line {
	margin: 0;
	opacity: 0;
	transform: translateY(16px) scale(0.92);
	transition:
		opacity 260ms ease,
		transform 520ms var(--Intro-Spring);
}
#TL-Mascot-Intro > .hello > .title {
	margin-top: 30px;
	font-family: var(--Theme-Font);
	font-size: 38px;
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: -0.035em;
	color: var(--Intro-Ink);
}
#TL-Mascot-Intro > .hello > .line {
	margin-top: 10px;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.45;
	letter-spacing: -0.01em;
	color: var(--Intro-Muted);
	transition-delay: 160ms;
}
#TL-Mascot-Intro[data-step="hello"] > .hello > .title,
#TL-Mascot-Intro[data-step="hello"] > .hello > .line {
	opacity: 1;
	transform: none;
}

/* Only the line that fits: meeting him, or seeing him again for something new */
#TL-Mascot-Intro[data-kind="first"] > .hello > .line[data-intro-line="again"],
#TL-Mascot-Intro[data-kind="again"] > .hello > .line[data-intro-line="first"] {
	display: none;
}

/* Out of the way once the card is up */
#TL-Mascot-Intro:not([data-step="wait"]):not([data-step="hello"]) > .hello {
	opacity: 0;
	pointer-events: none;
}

/*
** Card
** =================================
**
** Rises into place after his hello. The room above it is his: he sits on its top edge.
*/

#TL-Mascot-Intro > .card {
	box-sizing: border-box;
	width: min(500px, 100%);
	margin-top: calc(var(--Intro-Perch) + 6px);
	padding: 16px;
	border-radius: 30px;
	background-color: var(--Intro-Card);
	box-shadow:
		0 40px 90px -36px rgba(50, 36, 120, 0.45),
		0 10px 28px -14px rgba(20, 20, 30, 0.18),
		inset 0 0 0 1px rgba(255, 255, 255, 0.7);
	opacity: 0;
	transform: translateY(26px) scale(0.96);
	pointer-events: none;
	transition:
		opacity 240ms ease,
		transform 460ms var(--Intro-Spring);
}
#TL-Mascot-Intro:not([data-step="wait"]):not([data-step="hello"]) > .card {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

/*
** Tabs
** =================================
**
** One pill of a track with a tab for each step, and a marker that slides under the open one.
** Each tab carries his perch, over the card's top edge.
*/

#TL-Mascot-Intro .tabs {
	position: relative;
	display: flex;
	padding: 4px;
	border-radius: 999px;
	background-color: var(--Intro-Track);
}
#TL-Mascot-Intro .tabs > .marker {
	position: absolute;
	top: 4px;
	bottom: 4px;
	left: calc(4px + (100% - 8px) / var(--Tabs, 3) * var(--At, 0));
	width: calc((100% - 8px) / var(--Tabs, 3));
	border-radius: 999px;
	background-color: var(--Intro-Pill);
	box-shadow:
		0 6px 14px -8px rgba(40, 30, 90, 0.4),
		0 1px 2px rgba(20, 20, 30, 0.08);
	transition: left 420ms var(--Intro-Spring);
}
#TL-Mascot-Intro .tabs > .tab {
	position: relative;
	flex: 1 1 0;
	min-width: 0;
	height: 40px;
	padding: 0;
	background: none;
	border: none;
	border-radius: 999px;
	font: inherit;
	font-size: 14.5px;
	font-weight: 500;
	letter-spacing: -0.01em;
	color: var(--Intro-Muted);
	cursor: pointer;
	transition:
		color 200ms ease,
		transform 200ms var(--Intro-Spring);
}
#TL-Mascot-Intro .tabs > .tab[hidden] {
	display: none;
}
#TL-Mascot-Intro .tabs > .tab[aria-selected="true"] {
	color: var(--Intro-Ink);
}
#TL-Mascot-Intro .tabs > .tab:active {
	transform: scale(0.95);
}
#TL-Mascot-Intro .tabs > .tab:focus-visible,
#TL-Mascot-Intro .actions > button:focus-visible {
	outline: 2px solid rgba(115, 80, 255, 0.55);
	outline-offset: 2px;
}

/* Where he sits for this tab: on the card's top edge, right above it */
#TL-Mascot-Intro .tabs > .tab > .perch {
	position: absolute;
	left: calc(50% - var(--Intro-Perch) / 2);
	bottom: calc(100% + 16px);
	width: var(--Intro-Perch);
	height: var(--Intro-Perch);
	pointer-events: none;
}

/*
** Panels
** =================================
**
** They share one space, as tall as the tallest, so the card never changes size. The open one
** slides in from the side it's on; data-side says which side of the open one the others are.
*/

#TL-Mascot-Intro .panels {
	display: grid;
	margin-top: 6px;
}
#TL-Mascot-Intro .panel {
	grid-area: 1 / 1;
	padding: 18px 10px 6px;
	opacity: 0;
	pointer-events: none;
	transition:
		opacity 200ms ease,
		transform 420ms var(--Intro-Spring);
}
#TL-Mascot-Intro .panel[data-side="before"] {
	transform: translateX(-28px);
}
#TL-Mascot-Intro .panel[data-side="after"] {
	transform: translateX(28px);
}
#TL-Mascot-Intro .panel[data-side="open"] {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}
#TL-Mascot-Intro .panel[hidden] {
	display: none;
}
#TL-Mascot-Intro .panel > h3 {
	margin: 0;
	font-family: var(--Theme-Font);
	font-size: 24px;
	font-weight: 500;
	line-height: 1.15;
	letter-spacing: -0.03em;
	color: var(--Intro-Ink);
}
#TL-Mascot-Intro .panel > p {
	margin: 8px 0 0;
	font-size: 15px;
	line-height: 1.5;
	letter-spacing: -0.005em;
	color: var(--Intro-Muted);
}

/* What's new keeps the line breaks it was written with */
#TL-Mascot-Intro .panel > .notes {
	white-space: pre-line;
}
#TL-Mascot-Intro .panel > .eyebrow {
	display: inline-block;
	margin-bottom: 10px;
	padding: 3px 10px;
	border-radius: 999px;
	background-color: var(--Intro-Soft);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.02em;
	color: var(--Intro-Accent);
}
#TL-Mascot-Intro .panel > .eyebrow:empty {
	display: none;
}

/* Things to try, as he'd hear them */
#TL-Mascot-Intro .examples {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 7px;
	margin: 16px 0 0;
	padding: 0;
	list-style: none;
}
#TL-Mascot-Intro .examples > li {
	padding: 8px 14px;
	border-radius: 16px 16px 16px 6px;
	background-color: var(--Intro-Soft);
	font-size: 14px;
	font-weight: 400;
	line-height: 1.35;
	color: var(--Intro-Ink);
}

/*
** Actions
** =================================
**
** Skip on the left, and the way on at the right: Next, then "Let's go" on the last tab.
*/

#TL-Mascot-Intro .actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 14px;
}
#TL-Mascot-Intro .actions > button {
	height: 44px;
	border: none;
	border-radius: 999px;
	font: inherit;
	font-size: 15px;
	font-weight: 500;
	letter-spacing: -0.01em;
	cursor: pointer;
	transition:
		transform 200ms var(--Intro-Spring),
		box-shadow 200ms ease,
		background-color 160ms ease,
		color 160ms ease;
}
#TL-Mascot-Intro .actions > button:active {
	transform: scale(0.95);
}
#TL-Mascot-Intro .actions > .skip {
	padding: 0 16px;
	background: none;
	color: var(--Intro-Muted);
}
#TL-Mascot-Intro .actions > .skip:hover {
	background-color: var(--Intro-Track);
	color: var(--Intro-Ink);
}
#TL-Mascot-Intro .actions > .next {
	min-width: 112px;
	padding: 0 24px;
	background-image: linear-gradient(160deg, #8b6bff, #6a45f5);
	box-shadow:
		0 12px 24px -12px rgba(106, 69, 245, 0.75),
		inset 0 1px 0 rgba(255, 255, 255, 0.28);
	color: #ffffff;
}
#TL-Mascot-Intro .actions > .next:hover {
	transform: translateY(-1px) scale(1.03);
	box-shadow:
		0 16px 28px -12px rgba(106, 69, 245, 0.85),
		inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
#TL-Mascot-Intro .actions > .next:active {
	transform: scale(0.95);
}

/* The button says where it goes: on, or (on the last tab) into search */
#TL-Mascot-Intro:not([data-last]) .next > [data-intro-label="go"],
#TL-Mascot-Intro[data-last] .next > [data-intro-label="next"] {
	display: none;
}

/*
** Dark
** =================================
*/

body[data-theme="dark"] #TL-Mascot-Intro,
body[data-home="true"][data-home-theme="dark"] #TL-Mascot-Intro {
	--Intro-Ink: #f5f5f8;
	--Intro-Muted: rgba(245, 245, 248, 0.66);
	--Intro-Card: rgba(34, 34, 42, 0.97);
	--Intro-Soft: rgba(150, 125, 255, 0.16);
	--Intro-Track: rgba(255, 255, 255, 0.08);
	--Intro-Pill: rgba(255, 255, 255, 0.14);
	--Intro-Accent: #b3a1ff;
}
body[data-theme="dark"] #TL-Mascot-Intro > .card,
body[data-home="true"][data-home-theme="dark"] #TL-Mascot-Intro > .card {
	box-shadow:
		0 40px 90px -36px rgba(0, 0, 0, 0.8),
		inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/*
** Small Screens and Reduced Motion
** =================================
*/

/* Phones: the card takes the width with a little air either side, and what's tapped is a
   full thumb tall */
@media (max-width: 640px) {
	#TL-Mascot-Intro {
		--Intro-Perch: 64px;
		padding: calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
	}
	#TL-Mascot-Intro > .hello {
		padding: 0 10px 6dvh;
	}
	#TL-Mascot-Intro > .hello > .title {
		font-size: 32px;
	}
	#TL-Mascot-Intro > .card {
		padding: 14px;
		border-radius: 28px;
	}
	#TL-Mascot-Intro .tabs > .tab {
		height: 44px;
	}
	#TL-Mascot-Intro .panel {
		padding: 18px 8px 4px;
	}
	#TL-Mascot-Intro .panel > h3 {
		font-size: 22px;
	}
	#TL-Mascot-Intro .actions {
		margin-top: 16px;
	}
	#TL-Mascot-Intro .actions > button {
		height: 48px;
		font-size: 15.5px;
	}
	#TL-Mascot-Intro .actions > .next {
		min-width: 132px;
	}
}

/* Small phones: a little less air, so the whole card and its buttons fit without scrolling */
@media (max-height: 640px) {
	#TL-Mascot-Intro {
		--Intro-Perch: 54px;
		padding-top: calc(10px + env(safe-area-inset-top));
		padding-bottom: calc(12px + env(safe-area-inset-bottom));
	}
	#TL-Mascot-Intro .panel {
		padding-top: 14px;
	}
	#TL-Mascot-Intro .examples {
		gap: 6px;
		margin-top: 12px;
	}
	#TL-Mascot-Intro .actions {
		margin-top: 10px;
	}
}

/* Short screens (a phone on its side): he's smaller, and the card gives up some of its air */
@media (max-height: 560px) {
	#TL-Mascot-Intro {
		--Intro-Perch: 48px;
	}
	#TL-Mascot-Intro > .hello > .spot {
		width: clamp(96px, 30vmin, 132px);
	}
	#TL-Mascot-Intro .panel {
		padding-top: 12px;
	}
	#TL-Mascot-Intro .examples {
		flex-direction: row;
		flex-wrap: wrap;
		margin-top: 10px;
	}
}

/* Everything still comes and goes, it just fades instead of sliding and popping */
@media (prefers-reduced-motion: reduce) {
	#TL-Mascot-Intro > .hello > .title,
	#TL-Mascot-Intro > .hello > .line,
	#TL-Mascot-Intro > .card,
	#TL-Mascot-Intro .panel {
		transform: none !important;
		transition: opacity 200ms ease;
	}
	#TL-Mascot-Intro .tabs > .marker {
		transition: none;
	}
}
