/*
 * Typingo app and landing styles: shared pieces used by every app
 * view: finger colours, the app container, switches, message cards, key
 * chips and charts. View-specific styles live in home.css, journey.css,
 * progress.css, share.css and account.css (see inc/enqueue.php).
 */

/* ---------- Finger colours ---------- */
.ty-finger--lp { --ty-f: var(--ty-f-lp); }
.ty-finger--lr { --ty-f: var(--ty-f-lr); }
.ty-finger--lm { --ty-f: var(--ty-f-lm); }
.ty-finger--li { --ty-f: var(--ty-f-li); }
.ty-finger--ri { --ty-f: var(--ty-f-ri); }
.ty-finger--rm { --ty-f: var(--ty-f-rm); }
.ty-finger--rr { --ty-f: var(--ty-f-rr); }
.ty-finger--rp { --ty-f: var(--ty-f-rp); }
.ty-finger--th { --ty-f: var(--ty-f-th); }
.ty-finger--none { --ty-f: var(--ty-line); }

/* ---------- Shared app page chrome ---------- */
.ty-app-page {
	padding-block: var(--ty-step);
}

.ty-page-intro {
	max-width: var(--ty-narrow);
	margin-bottom: 2rem;
}

.ty-page-intro__text {
	color: var(--ty-muted);
	font-size: 1.125rem;
}

.ty-section-title {
	margin-bottom: 0.75rem;
}

.ty-section-lead {
	max-width: 68ch;
	margin-bottom: 2rem;
	color: var(--ty-muted);
	font-size: 1.125rem;
}

.ty-questions {
	margin-top: 2rem;
	color: var(--ty-muted);
}

/* ---------- App container ---------- */
.typingo-app {
	position: relative;
	margin-block: 2rem;
	padding: clamp(1.25rem, 3vw, 2rem);
	border: 1px solid var(--ty-line);
	border-radius: calc(var(--ty-radius) + 4px);
	background: var(--ty-surface);
	box-shadow: var(--ty-shadow);
	scroll-margin-top: 1rem;
}

.typingo-app:focus {
	outline: none;
}

.typingo-app:focus-visible {
	outline: 3px solid var(--ty-focus);
	outline-offset: 3px;
}

/*
 * The still picture of the app shown until the script takes over (see
 * typingo_app_skeleton()). It uses the app's own classes, so it has the same
 * size; the description stays available to screen readers.
 */
.ty-app-shell--skel .ty-app-shell__intro {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.ty-skel {
	pointer-events: none;
}

.ty-skel .ty-skel__tools {
	display: block;
	width: min(28rem, 100%);
	height: 2.6rem;
	border-radius: 999px;
	background: var(--ty-surface-2);
}

.ty-skel__lines span {
	display: block;
	height: var(--ty-line-h, 2em);
	background: linear-gradient(transparent 30%, var(--ty-surface-2) 30% 70%, transparent 70%) no-repeat;
	background-size: 100% 100%;
}

.ty-skel__lines span:nth-child(1) { width: 94%; }
.ty-skel__lines span:nth-child(2) { width: 86%; }
.ty-skel__lines span:nth-child(3) { width: 62%; }

@media (prefers-reduced-motion: no-preference) {
	.ty-skel__lines span,
	.ty-skel .ty-skel__tools {
		animation: ty-skel-pulse 1.4s ease-in-out infinite alternate;
	}
}

@keyframes ty-skel-pulse {
	to { opacity: 0.45; }
}

/* The toolbars of lessons and practice hold more than the placeholder shows. */
.ty-skel--lesson .ty-toolbar {
	min-height: 57px;
}

.ty-skel--practice .ty-toolbar {
	min-height: 109px;
}

/* Length picker, live numbers and switches take two rows on the Typing Test. */
.ty-skel--test .ty-toolbar {
	min-height: 111px;
}

.ty-skel--practice .ty-timerbar {
	min-height: 48px;
}

.ty-skel .ty-nokb {
	display: none;
}

/* "Sam typed 40 WPM. Your turn." above the challenge. */
.ty-skel__intro {
	height: 66px;
}

/* Same test as probablyNoKeyboard() in ui/no-keyboard.js. */
@media (hover: none) and (pointer: coarse) {
	.ty-skel .ty-toolbar,
	.ty-skel .ty-timerbar,
	.ty-skel .ty-stage,
	.ty-skel .ty-stepmeta,
	.ty-skel .ty-kb-wrap {
		display: none;
	}

	.ty-skel .ty-nokb {
		display: block;
	}

	/* Empty until the learner starts. */
	.ty-skel .ty-coachline {
		font-size: 0;
	}
}

/* A learner who hid the keyboard does not see it flash in. */
.ty-no-kb .ty-skel .ty-kb-wrap {
	display: none;
}

.ty-app-shell__title {
	font-size: 1.35rem;
}

.ty-app-shell__text {
	max-width: 68ch;
	color: var(--ty-muted);
}

.ty-app-shell__points {
	display: grid;
	gap: 0.5rem;
	margin-bottom: 0;
	padding: 0;
	list-style: none;
}

.ty-app-shell__points li {
	position: relative;
	padding-left: 1.75rem;
}

.ty-app-shell__points li::before {
	content: "";
	position: absolute;
	top: 0.5em;
	left: 0.2rem;
	width: 0.7rem;
	height: 0.7rem;
	border-radius: 50%;
	background: var(--ty-accent);
}

.ty-app-shell noscript .ty-notice {
	margin: 1.25rem 0 0;
}

/* ---------- Segmented switch (typing modes, share options, log in / sign up) ---------- */
.ty-seg {
	display: inline-flex;
	flex-wrap: wrap;
	padding: 4px;
	border-radius: 999px;
	background: var(--ty-surface-2);
}

.ty-seg__btn {
	min-height: 40px;
	padding: 0.4rem 1.05rem;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--ty-muted);
	font: inherit;
	font-size: 0.95rem;
	font-weight: 500;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ty-seg__btn:hover {
	color: var(--ty-ink);
}

.ty-seg__btn[aria-pressed="true"],
.ty-seg__btn[aria-current="true"] {
	background: var(--ty-surface);
	box-shadow: 0 1px 2px rgb(26 29 46 / 10%), 0 2px 8px rgb(26 29 46 / 6%);
	color: var(--ty-ink);
	font-weight: 600;
}

/* ---------- Message cards (lesson steps, empty states) ---------- */
.ty-card-note {
	padding: clamp(1.25rem, 3.5vw, 2.25rem);
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius);
	background: var(--ty-surface);
}

.ty-card-note__title {
	font-size: 1.3rem;
}

.ty-card-note p:last-child {
	margin-bottom: 0;
}

/* ---------- Key chips ---------- */
.ty-key {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0 0.35rem 0.35rem 0;
	padding: 0.2rem 0.6rem 0.2rem 0.25rem;
	border: 1px solid color-mix(in srgb, var(--ty-f) 60%, var(--ty-line));
	border-radius: 999px;
	background: color-mix(in srgb, var(--ty-f) 16%, var(--ty-surface));
	font-size: 0.85rem;
	line-height: 1.2;
	white-space: nowrap;
}

.ty-key kbd {
	display: inline-flex;
	/* The page font, so a key chip never pulls in the typing font before first paint. */
	font-family: var(--ty-font-sans);
	align-items: center;
	justify-content: center;
	min-width: 1.9rem;
	height: 1.9rem;
	padding: 0 0.4rem;
	border-radius: 6px;
	background: var(--ty-f);
	color: #1b1f2a;
	font-size: 1rem;
	font-weight: 600;
	box-shadow: inset 0 -2px 0 rgb(0 0 0 / 15%);
}

.ty-key__who {
	font-weight: 600;
}

/* ---------- Job-Ready presets ---------- */
.ty-preset-list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
	gap: 1rem;
	margin: 0 0 1rem;
	padding: 0;
	list-style: none;
}

.ty-preset {
	padding: 1.25rem;
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius);
	background: var(--ty-surface);
}

.ty-preset__title {
	font-size: 1.1rem;
}

.ty-preset__facts {
	display: grid;
	gap: 0.35rem;
	margin: 0;
}

.ty-preset__facts div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding-bottom: 0.35rem;
	border-bottom: 1px dashed var(--ty-line);
}

.ty-preset__facts dt {
	color: var(--ty-muted);
}

.ty-preset__facts dd {
	margin: 0;
	font-weight: 600;
}

/* ---------- Contact ---------- */
.ty-contact-card {
	margin-top: 2rem;
	padding: 1.5rem;
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius);
	background: var(--ty-surface);
}

.ty-contact-card__hint {
	margin: 0;
	color: var(--ty-muted);
	font-size: 0.95rem;
}

/* color-mix() fallback for older browsers: solid soft tints. */
@supports not (background: color-mix(in srgb, red 10%, white)) {
	.ty-key,
	.ty-home-row__key kbd,
	.ty-home-row__space kbd {
		background: var(--ty-surface-2);
		border-color: var(--ty-f);
	}

	.ty-day-card--checkpoint,
	.ty-day-card--graduation {
		background: var(--ty-surface);
	}
}

/* ---------- Journey banner progress bar ---------- */
.ty-journey-banner__bar,
.ty-pnext__bar {
	height: 8px;
	margin: 0.25rem 0 0.75rem;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--ty-accent) calc(var(--ty-progress, 0) * 100%), color-mix(in srgb, var(--ty-ink) 10%, transparent) 0);
}

/* ---------- Interactive charts ---------- */
/* Chart basics (results, lessons and My Progress all draw charts). */
.ty-chart {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.ty-chart__grid {
	stroke: var(--ty-line);
	stroke-width: 1;
}

.ty-chart__tick {
	fill: var(--ty-muted);
	font-family: var(--ty-font-sans);
	font-size: 12px;
}

.ty-chart {
	--ty-tone: var(--ty-primary);
}

.ty-chart--accent {
	--ty-tone: var(--ty-accent);
}

.ty-chart__line {
	fill: none;
	stroke: var(--ty-tone);
	stroke-width: 3;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.ty-chart__area {
	fill: color-mix(in srgb, var(--ty-tone) 12%, transparent);
}

.ty-chart__dot {
	fill: var(--ty-surface);
	stroke: var(--ty-tone);
	stroke-width: 2;
}

.ty-chart__dot.is-last {
	fill: var(--ty-tone);
}

.ty-chartbox {
	position: relative;
	border-radius: 10px;
	touch-action: pan-y;
}

.ty-chartbox:focus-visible {
	outline: 3px solid var(--ty-focus);
	outline-offset: 4px;
}

.ty-chart__guide {
	stroke: var(--ty-muted);
	stroke-width: 1;
	stroke-dasharray: 4 4;
}

.ty-chart__dot.is-active {
	r: 7;
	fill: var(--ty-tone);
	stroke: var(--ty-surface);
	stroke-width: 3;
}

.ty-chart__marker {
	fill: var(--ty-bad);
	opacity: 0.85;
}

.ty-chart__tip {
	position: absolute;
	z-index: 2;
	padding: 0.35rem 0.65rem;
	border: 1px solid var(--ty-line);
	border-radius: 8px;
	background: var(--ty-surface);
	color: var(--ty-ink);
	font-size: 0.82rem;
	font-weight: 500;
	line-height: 1.35;
	white-space: nowrap;
	pointer-events: none;
	transform: translate(-50%, -115%);
	box-shadow: var(--ty-shadow);
}

.ty-chart__tip[hidden] {
	display: none;
}

/* Long tooltips wrap instead of running off narrow screens. */
.ty-chart__tip {
	max-width: min(22rem, calc(100vw - 48px));
	white-space: normal;
	text-align: center;
}

/* ---------- Style variants: typing area ---------- */
.ty-typing--outlined .typingo-app {
	border-width: 2px;
	box-shadow: none;
}

.ty-typing--flat .typingo-app:not([data-typingo-app="progress"]) {
	padding: 0;
	border: 0;
	background: transparent;
	box-shadow: none;
}

/* A one-line pointer under an app to the page that does the other job. */
.ty-crosslink {
	max-width: 72ch;
	margin: 1.25rem 0 0;
	color: var(--ty-muted);
	font-size: 0.95rem;
}
