/*
 * Typingo base styles: tokens, reset, typography, layout, header, footer,
 * blog, forms, ad slots and WordPress core classes. Loaded on every page.
 */

/* ---------- Bundled fonts (SIL OFL 1.1, see CREDITS.md) ---------- */
@font-face {
	font-family: Lexend;
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("../fonts/lexend-latin.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
	font-family: Lexend;
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("../fonts/lexend-latin-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
	font-family: "Roboto Mono";
	font-style: normal;
	font-weight: 100 700;
	font-display: swap;
	src: url("../fonts/roboto-mono-latin.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
	--ty-primary: #4f46e5;
	--ty-accent: #0d9488;
	--ty-bg: #f6f6fb;
	--ty-surface: #ffffff;
	--ty-surface-2: #eeeff8;
	--ty-ink: #1a1d2e;
	--ty-muted: #555b70;
	--ty-line: #e1e3ee;
	--ty-link: var(--ty-primary);
	--ty-on-primary: #ffffff;
	--ty-focus: #f59f00;
	--ty-info-bg: #eef0ff;
	--ty-warn-bg: #fff4d6;
	--ty-good: #0f766e;
	--ty-bad: #c92a2a;
	--ty-bad-bg: #ffe3e3;

	--ty-f-lp: #f07a73;
	--ty-f-lr: #f4a347;
	--ty-f-lm: #e2bd3c;
	--ty-f-li: #5fbf73;
	--ty-f-ri: #3fb0bd;
	--ty-f-rm: #5a8cf0;
	--ty-f-rr: #9a7de8;
	--ty-f-rp: #e27bb0;
	--ty-f-th: #95a1b0;

	--ty-font-sans: Lexend, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
	--ty-font-mono: "Roboto Mono", ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

	--ty-radius: 18px;
	--ty-radius-sm: 10px;
	--ty-shadow: 0 1px 2px rgb(26 29 46 / 5%), 0 8px 24px rgb(26 29 46 / 6%);
	--ty-shadow-lg: 0 2px 6px rgb(26 29 46 / 5%), 0 20px 48px rgb(26 29 46 / 10%);
	--ty-gutter: 16px;
	--ty-max: 1160px;
	--ty-narrow: 720px;
	--ty-step: clamp(2.5rem, 6vw, 4.5rem);
}

@media (min-width: 700px) {
	:root {
		--ty-gutter: 28px;
	}
}

@media (prefers-color-scheme: dark) {
	:root {
		--ty-bg: #0e1018;
		--ty-surface: #161925;
		--ty-surface-2: #1f2332;
		--ty-ink: #eceef6;
		--ty-muted: #a5abbe;
		--ty-line: #2b3044;
		--ty-link: #a5b4fc;
		--ty-info-bg: #1c2346;
		--ty-warn-bg: #3a3014;
		--ty-good: #5eead4;
		--ty-bad: #ff8787;
		--ty-bad-bg: #4a1f24;
		--ty-shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
		--ty-shadow-lg: 0 2px 6px rgb(0 0 0 / 30%), 0 20px 48px rgb(0 0 0 / 35%);
	}
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

body {
	margin: 0;
	background: var(--ty-bg);
	color: var(--ty-ink);
	font-family: var(--ty-font-sans);
	font-size: 1.0625rem;
	font-weight: 400;
	line-height: 1.7;
	overflow-wrap: break-word;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

strong,
b {
	font-weight: 600;
}

img,
svg,
video,
iframe {
	max-width: 100%;
	height: auto;
}

svg {
	height: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	margin: 0 0 0.5em;
	line-height: 1.2;
	font-weight: 600;
	letter-spacing: -0.02em;
	text-wrap: balance;
}

h1 {
	font-size: clamp(2rem, 4.5vw, 2.8rem);
}

h2 {
	font-size: clamp(1.5rem, 3vw, 2rem);
}

h3 {
	font-size: 1.25rem;
}

p,
ul,
ol,
dl,
figure,
blockquote,
pre,
table {
	margin: 0 0 1.25em;
}

a {
	color: var(--ty-link);
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

a:hover {
	text-decoration-thickness: 2px;
}

:focus-visible {
	outline: 3px solid var(--ty-focus);
	outline-offset: 2px;
	border-radius: 4px;
}

kbd,
code,
pre {
	font-family: var(--ty-font-mono);
}

code {
	padding: 0.1em 0.35em;
	border-radius: 4px;
	background: var(--ty-surface-2);
	font-size: 0.9em;
}

pre {
	padding: 1rem;
	overflow-x: auto;
	border-radius: var(--ty-radius-sm);
	background: var(--ty-surface-2);
}

blockquote {
	margin-left: 0;
	padding-left: 1.25rem;
	border-left: 4px solid var(--ty-primary);
	color: var(--ty-muted);
}

hr {
	border: 0;
	border-top: 1px solid var(--ty-line);
	margin: 2rem 0;
}

table {
	width: 100%;
	border-collapse: collapse;
}

th,
td {
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid var(--ty-line);
	text-align: left;
}

/* ---------- Accessibility ---------- */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
	word-wrap: normal !important;
}

.screen-reader-text:focus,
.skip-link:focus {
	position: fixed !important;
	top: 8px;
	left: 8px;
	z-index: 100000;
	width: auto;
	height: auto;
	padding: 0.75rem 1rem;
	margin: 0;
	clip: auto;
	clip-path: none;
	background: var(--ty-surface);
	color: var(--ty-ink);
	font-weight: 700;
	border-radius: var(--ty-radius-sm);
	box-shadow: var(--ty-shadow);
}

/* ---------- Layout ---------- */
.site {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.site-main {
	flex: 1 0 auto;
	min-width: 0;
}

.ty-container {
	width: 100%;
	max-width: calc(var(--ty-max) + 2 * var(--ty-gutter));
	margin-inline: auto;
	padding-inline: var(--ty-gutter);
}

.ty-container--narrow {
	max-width: calc(var(--ty-narrow) + 2 * var(--ty-gutter));
}

.ty-layout,
.ty-container--narrow > .site-main {
	padding-block: var(--ty-step);
}

.ty-layout {
	display: grid;
	gap: 3rem;
	flex: 1 0 auto;
}

@media (min-width: 1024px) {
	.ty-has-sidebar .ty-layout {
		grid-template-columns: minmax(0, 1fr) 320px;
	}
}

/* ---------- Buttons ---------- */
.ty-button,
.wp-block-button__link,
button[type="submit"],
input[type="submit"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-height: 46px;
	padding: 0.65em 1.4em;
	border: 2px solid var(--ty-primary);
	border-radius: 999px;
	background: var(--ty-primary);
	color: var(--ty-on-primary);
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	box-shadow: 0 1px 2px rgb(26 29 46 / 12%), 0 6px 16px color-mix(in srgb, var(--ty-primary) 22%, transparent);
	transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.ty-button:hover,
.wp-block-button__link:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
	box-shadow: 0 2px 4px rgb(26 29 46 / 12%), 0 10px 22px color-mix(in srgb, var(--ty-primary) 30%, transparent);
	transform: translateY(-1px);
	color: var(--ty-on-primary);
}

.ty-button:active {
	transform: translateY(0);
}

.ty-button--ghost {
	border-color: var(--ty-line);
	background: var(--ty-surface);
	color: var(--ty-ink);
	box-shadow: none;
}

.ty-button--ghost:hover {
	border-color: var(--ty-primary);
	color: var(--ty-link);
	box-shadow: none;
}

.ty-button--small {
	min-height: 40px;
	padding: 0.45em 1.05em;
	font-size: 0.95rem;
}

.ty-button--large {
	min-height: 56px;
	padding: 0.8em 1.8em;
	font-size: 1.1rem;
}

.ty-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

.ty-link-arrow {
	font-weight: 600;
}

.ty-link-arrow::after {
	content: " →";
}

.ty-eyebrow {
	margin: 0 0 0.5rem;
	color: var(--ty-link);
	font-size: 0.82rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.ty-notice {
	padding: 0.9rem 1.15rem;
	border: 1px solid color-mix(in srgb, #f59f00 30%, transparent);
	border-radius: var(--ty-radius-sm);
	background: var(--ty-warn-bg);
}

.ty-notice--info {
	border-color: color-mix(in srgb, var(--ty-primary) 22%, transparent);
}

.ty-notice--info {
	background: var(--ty-info-bg);
}

.ty-notice--good {
	border-color: color-mix(in srgb, var(--ty-accent) 35%, transparent);
	background: color-mix(in srgb, var(--ty-accent) 10%, var(--ty-surface));
}

/* ---------- Header ---------- */
.site-header {
	position: relative;
	z-index: 10;
	border-bottom: 1px solid var(--ty-line);
	background: color-mix(in srgb, var(--ty-surface) 92%, transparent);
	transition: opacity 0.4s ease;
}

.site-header__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1.5rem;
	min-height: 72px;
	padding-block: 0.6rem;
}

.site-branding {
	margin-right: auto;
}

.site-title {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	color: var(--ty-ink);
	font-size: 1.35rem;
	font-weight: 700;
	letter-spacing: -0.03em;
	text-decoration: none;
}

.site-title__mark {
	display: inline-flex;
	color: var(--ty-primary);
}

.custom-logo {
	display: block;
	width: auto;
	max-height: 48px;
}

.menu-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	min-height: 44px;
	padding: 0.4rem 0.9rem;
	border: 1px solid var(--ty-line);
	border-radius: 999px;
	background: var(--ty-surface);
	color: var(--ty-ink);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.menu-toggle[hidden] {
	display: none;
}

.main-navigation {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
}

.ty-menu {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ty-menu a {
	display: block;
	padding: 0.5rem 0.85rem;
	border-radius: 999px;
	color: var(--ty-muted);
	font-weight: 500;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ty-menu a:hover {
	background: var(--ty-surface-2);
	color: var(--ty-ink);
}

.ty-menu .current-menu-item > a,
.ty-menu a[aria-current="page"] {
	background: color-mix(in srgb, var(--ty-primary) 10%, var(--ty-surface));
	color: var(--ty-link);
	font-weight: 600;
}

.ty-menu .sub-menu {
	margin: 0;
	padding: 0 0 0 1rem;
	list-style: none;
}

@media (min-width: 960px) {
	.ty-menu .menu-item-has-children {
		position: relative;
	}

	.ty-menu .sub-menu {
		position: absolute;
		top: 100%;
		left: 0;
		display: none;
		min-width: 220px;
		padding: 0.5rem;
		border: 1px solid var(--ty-line);
		border-radius: var(--ty-radius-sm);
		background: var(--ty-surface);
		box-shadow: var(--ty-shadow);
	}

	.ty-menu .menu-item-has-children:hover > .sub-menu,
	.ty-menu .menu-item-has-children:focus-within > .sub-menu {
		display: block;
	}
}

/* JS-enhanced mobile menu: collapsed until toggled. Without JS the menu simply wraps. */
@media (max-width: 959px) {
	.js .main-navigation {
		display: none;
		flex-basis: 100%;
		flex-direction: column;
		align-items: stretch;
		padding-bottom: 0.75rem;
	}

	.js .main-navigation.is-open {
		display: flex;
	}

	.js .ty-menu {
		flex-direction: column;
	}

	.js .site-header__cta {
		align-self: flex-start;
	}
}

@media (min-width: 960px) {
	.menu-toggle {
		display: none;
	}
}

/* ---------- Page headers ---------- */
.page-header {
	margin-bottom: 2rem;
}

.page-title,
.entry-title {
	margin-bottom: 0.4rem;
}

.archive-description {
	color: var(--ty-muted);
}

/* ---------- Blog ---------- */
.ty-post-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
	gap: 1.5rem;
	margin-bottom: 2rem;
}

.ty-card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius);
	background: var(--ty-surface);
	box-shadow: var(--ty-shadow);
}

.ty-card .entry-thumbnail {
	display: block;
	aspect-ratio: 16 / 9;
	background: var(--ty-surface-2);
}

.ty-card .entry-thumbnail img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ty-card__body {
	padding: 1.25rem 1.25rem 0.5rem;
}

.ty-card .entry-title {
	font-size: 1.2rem;
}

.ty-card .entry-title a {
	color: var(--ty-ink);
	text-decoration: none;
}

.ty-card .entry-title a:hover {
	color: var(--ty-link);
}

.entry-meta,
.entry-footer {
	color: var(--ty-muted);
	font-size: 0.92rem;
}

.entry-meta > * + *::before,
.entry-footer > * + *::before {
	content: " · ";
}

.ty-article .entry-header {
	margin-bottom: 1.75rem;
}

.ty-article .entry-title {
	font-size: clamp(2rem, 4.5vw, 2.75rem);
}

.entry-thumbnail {
	margin: 0 0 2rem;
}

.entry-thumbnail img {
	border-radius: var(--ty-radius);
}

.entry-content {
	max-width: 72ch;
}

.entry-content > * + h2,
.entry-content > * + h3 {
	margin-top: 2rem;
}

.entry-footer {
	margin-top: 2rem;
	padding-top: 1rem;
	border-top: 1px solid var(--ty-line);
}

.sticky .ty-card__body::before {
	content: "★";
	color: var(--ty-accent);
	font-weight: 700;
}

.bypostauthor > .comment-body .fn::after {
	content: " ✎";
	color: var(--ty-muted);
}

.page-links,
.nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 2rem 0;
}

.nav-links a,
.nav-links .current {
	display: inline-flex;
	min-width: 44px;
	min-height: 44px;
	align-items: center;
	justify-content: center;
	padding: 0.35rem 0.8rem;
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius-sm);
	background: var(--ty-surface);
	text-decoration: none;
}

.nav-links .current {
	border-color: var(--ty-primary);
	font-weight: 700;
}

.post-navigation .nav-links {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

.post-navigation .nav-links a {
	flex-direction: column;
	align-items: flex-start;
	justify-content: flex-start;
	padding: 1rem;
}

.nav-subtitle {
	color: var(--ty-muted);
	font-size: 0.85rem;
}

/* ---------- Widgets and sidebar ---------- */
.widget-area .widget {
	margin-bottom: 2rem;
}

.widget-title {
	font-size: 1rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--ty-muted);
}

.widget ul {
	padding-left: 1.1rem;
}

@media (max-width: 1023px) {
	.widget-area .typingo-ad--sidebar {
		display: none;
	}
}

/* ---------- Forms ---------- */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="password"],
input[type="number"],
textarea,
select {
	width: 100%;
	min-height: 44px;
	padding: 0.55rem 0.8rem;
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius-sm);
	background: var(--ty-surface);
	color: var(--ty-ink);
	font: inherit;
}

.search-form {
	display: flex;
	gap: 0.5rem;
	max-width: 520px;
	margin-bottom: 1.5rem;
}

/* ---------- Comments ---------- */
.comments-area {
	margin-top: 3rem;
}

.comment-list,
.comment-list .children {
	padding-left: 0;
	list-style: none;
}

.comment-list .children {
	padding-left: 1.5rem;
}

.comment-body {
	margin-bottom: 1.25rem;
	padding: 1rem;
	border: 1px solid var(--ty-line);
	border-radius: var(--ty-radius-sm);
	background: var(--ty-surface);
}

.comment-meta {
	font-size: 0.92rem;
}

.comment-author .avatar {
	float: left;
	margin-right: 0.75rem;
	border-radius: 50%;
}

.comment-form label {
	display: block;
	font-weight: 600;
}

/* ---------- WordPress core classes ---------- */
.alignleft {
	float: left;
	margin: 0.3em 1.5em 1em 0;
}

.alignright {
	float: right;
	margin: 0.3em 0 1em 1.5em;
}

.aligncenter {
	display: block;
	margin-inline: auto;
}

.alignwide,
.alignfull {
	max-width: none;
}

.wp-caption {
	max-width: 100%;
	margin-bottom: 1.25em;
}

.wp-caption-text,
.gallery-caption,
figcaption {
	color: var(--ty-muted);
	font-size: 0.9rem;
}

/* ---------- Ad slots ---------- */
.typingo-ad {
	display: block;
	min-height: var(--ty-ad-min-h, 0);
	margin: 2rem auto;
	max-width: calc(var(--ty-max) + 2 * var(--ty-gutter));
	padding-inline: var(--ty-gutter);
	text-align: center;
	contain: layout;
}

.typingo-ad__label {
	display: block;
	margin-bottom: 0.25rem;
	color: var(--ty-muted);
	font-size: 0.72rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.widget-area .typingo-ad,
.ty-container .typingo-ad,
.entry-content .typingo-ad {
	padding-inline: 0;
}

/* Keep result-screen ads well clear of the typing area and keyboard. */
.typingo-ad--results,
.typingo-ad--below-content {
	margin-top: 3.5rem;
}

@media (max-width: 699px) {
	.typingo-ad {
		min-height: min(var(--ty-ad-min-h, 0), 280px);
	}
}

/* ---------- Footer ---------- */
.site-footer {
	margin-top: auto;
	padding-top: 3rem;
	border-top: 1px solid var(--ty-line);
	background: var(--ty-surface);
	font-size: 0.95rem;
}

.site-footer__inner {
	display: grid;
	gap: 2rem;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

.site-footer__name {
	margin-bottom: 0.25rem;
	font-size: 1.15rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.site-footer__promise {
	color: var(--ty-muted);
}

.ty-footer-menu {
	margin: 0;
	padding: 0;
	list-style: none;
}

.ty-footer-menu a {
	display: inline-block;
	padding: 0.3rem 0;
	color: var(--ty-muted);
	text-decoration: none;
}

.ty-footer-menu a:hover {
	color: var(--ty-link);
	text-decoration: underline;
}

.site-footer__legal {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.5rem 1.5rem;
	margin-top: 2rem;
	padding-block: 1.25rem;
	border-top: 1px solid var(--ty-line);
	color: var(--ty-muted);
}

.site-footer__legal p {
	margin: 0;
}

/* ---------- 404 ---------- */
.error-404 .ty-eyebrow {
	font-family: var(--ty-font-mono);
	font-size: 1.25rem;
}

/* ---------- Focus mode (body.ty-is-typing is set while a session runs) ---------- */
.ty-is-typing .site-header,
.ty-is-typing .typingo-ad,
.ty-is-typing .ty-page-intro,
.ty-is-typing .ty-lesson__header,
.ty-is-typing .ty-breadcrumbs {
	opacity: 0.28;
	transition: opacity 0.4s ease;
}

.ty-is-typing .site-header:hover,
.ty-is-typing .site-header:focus-within {
	opacity: 1;
}

/* ---------- Print ---------- */
@media print {
	.site-header,
	.site-footer,
	.typingo-ad,
	.widget-area,
	.comments-area {
		display: none !important;
	}

	body {
		background: #fff;
		color: #000;
	}
}
