/* ==========================================================================
   mahapps.com - global styles
   1. Tokens  2. Base  3. Layout  4. Utilities  5. Header & drawer  6. Search
   7. Buttons, labels, forms  8. Cards  9. Section heads  10. Side boxes
   11. Breadcrumbs & pagination  12. Footer  13. Motion & print
   Palette: midnight text on white / pale cool grey, indigo primary, cyan as accent only
   (fills, rules, focus on dark) - never small cyan text on white.
   ========================================================================== */

/* 1. Tokens ----------------------------------------------------------------- */
:root {
	--midnight: #111827;
	--indigo: #5B4BFF;
	--indigo-ink: #4B3BEF;
	--indigo-tint: #EEEDFF;
	--cyan: #00B8D9;
	--cyan-ink: #007A91;
	--cyan-tint: #E3F7FB;
	--pale: #F5F7FC;
	--white: #FFFFFF;
	--text: #111827;
	--body: #283041;
	--muted: #4E5869;
	--line: #E3E7F0;
	--line-strong: #CBD2E1;
	--on-dark: #FFFFFF;
	--on-dark-muted: #C7CCE0;

	--font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

	--fs-xs: 0.75rem;
	--fs-sm: 0.875rem;
	--fs-base: 1rem;
	--fs-md: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
	--fs-lg: clamp(1.1875rem, 1.1rem + 0.45vw, 1.375rem);
	--fs-xl: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
	--fs-2xl: clamp(1.75rem, 1.35rem + 1.7vw, 2.625rem);
	--fs-3xl: clamp(2rem, 1.45rem + 2.4vw, 3.25rem);

	--container: 1280px;
	--gutter: clamp(16px, 3vw, 32px);
	--gap: clamp(16px, 2vw, 24px);
	--gap-lg: clamp(28px, 4vw, 56px);
	--radius: 14px;
	--radius-sm: 12px;
	--radius-lg: 16px;
	--shadow: 0 1px 2px rgb(17 24 39 / 0.05), 0 8px 24px rgb(17 24 39 / 0.06);
	--header-h: 68px;
	--ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* 2. Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
	margin: 0;
	background: var(--white);
	color: var(--body);
	font-family: var(--font-sans);
	font-size: var(--fs-base);
	line-height: 1.6;
	overflow-x: clip;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
	margin: 0 0 0.5em;
	color: var(--text);
	font-family: var(--font-sans);
	font-weight: 750;
	line-height: 1.2;
	letter-spacing: -0.015em;
	text-wrap: balance;
}

p { margin: 0 0 1em; }
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: var(--indigo-ink); text-underline-offset: 0.18em; }
a:hover { color: var(--midnight); }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { padding-left: 1.25em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

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

.site-main:focus { outline: none; }

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

.page-pad { padding-block: var(--gap-lg); }

/* 4. Utilities -------------------------------------------------------------- */
.sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	left: 16px;
	top: -100px;
	z-index: 1000;
	padding: 10px 16px;
	border-radius: var(--radius-sm);
	background: var(--midnight);
	color: var(--white);
	font-weight: 600;
}
.skip-link:focus { top: 12px; color: var(--white); }

.meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 14px;
	margin: 0;
	color: var(--muted);
	font-family: var(--font-mono);
	font-size: 0.78rem;
	letter-spacing: -0.01em;
}

.badge-demo {
	padding: 1px 8px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	color: var(--muted);
	font-family: var(--font-sans);
	font-size: 0.7rem;
	font-weight: 600;
}

.empty-state { color: var(--muted); padding-block: 24px; }
.empty-state--big { padding: 32px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--pale); }

/* 5. Header & drawer --------------------------------------------------------- */
.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: var(--white);
	border-bottom: 1px solid var(--line);
	/* No backdrop-filter/transform here: they would trap the fixed drawer and search overlay. */
}
.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 0; } }

.site-header__inner {
	display: flex;
	align-items: center;
	gap: 24px;
	min-height: var(--header-h);
}

.site-header__brand { flex: none; }
.brand { display: block; }
.brand__img, .custom-logo { width: auto; height: 28px; }

.primary-nav { flex: 1; min-width: 0; }
.primary-nav__label, .primary-nav__pages { display: none; }

.nav-list {
	display: flex;
	justify-content: center;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.nav-list a {
	position: relative;
	display: block;
	padding: 8px 11px;
	border-radius: 10px;
	color: var(--midnight);
	font-size: 0.9rem;
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}
.nav-list a:hover { background: var(--pale); color: var(--indigo-ink); }
.nav-list a[aria-current]::after,
.nav-list .current-menu-item > a::after {
	content: "";
	position: absolute;
	left: 11px;
	right: 11px;
	bottom: -13px;
	height: 3px;
	border-radius: 3px 3px 0 0;
	background: var(--cyan);
}

.site-header__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.search-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 0 16px 0 12px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--pale);
	color: var(--midnight);
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
}
.search-trigger:hover { border-color: var(--indigo); color: var(--indigo-ink); }

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--white);
	color: var(--midnight);
	cursor: pointer;
}
.icon-btn:hover { border-color: var(--indigo); color: var(--indigo-ink); }

.menu-toggle { display: none; }
.menu-toggle__close { display: none; }
.menu-open .menu-toggle__open { display: none; }
.menu-open .menu-toggle__close { display: block; }

.nav-scrim[hidden] { display: none; }

@media (max-width: 1199px) {
	.menu-toggle { display: inline-grid; }

	.primary-nav {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		z-index: 120;
		width: min(86vw, 360px);
		padding: 24px;
		overflow-y: auto;
		background: var(--white);
		box-shadow: -12px 0 40px rgb(17 24 39 / 0.18);
		/* Closed drawer is removed from layout (an off-screen transform widens the mobile viewport). */
		display: none;
	}
	.menu-open .primary-nav { display: block; animation: drawer-in 0.22s var(--ease); }
	@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
	.admin-bar .primary-nav { top: 32px; }

	.primary-nav__label {
		display: block;
		margin-bottom: 8px;
		color: var(--muted);
		font-size: var(--fs-xs);
		font-weight: 600;
	}
	.nav-list { display: block; }
	.nav-list a { padding: 13px 4px; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 1.0625rem; }
	.nav-list a[aria-current]::after, .nav-list .current-menu-item > a::after { left: -24px; right: auto; top: 10px; bottom: 10px; width: 3px; height: auto; border-radius: 0 3px 3px 0; }

	.primary-nav__pages { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 20px 0 0; padding: 0; list-style: none; }
	.primary-nav__pages a { color: var(--muted); font-size: var(--fs-sm); }

	.menu-toggle { position: relative; z-index: 130; }
	.nav-scrim { position: fixed; inset: 0; z-index: 99; background: rgb(17 24 39 / 0.45); } /* below the header (z 100), which holds the drawer */
}

@media (max-width: 559px) {
	.search-trigger { width: 40px; padding: 0; justify-content: center; }
	.search-trigger__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	.brand__img, .custom-logo { height: 24px; }
}

/* 6. Search ---------------------------------------------------------------- */
.search-panel {
	display: none;
	position: fixed;
	inset: var(--header-h) 0 0;
	z-index: 90;
	padding-top: 16px;
	background: rgb(17 24 39 / 0.4);
}
.admin-bar .search-panel { top: calc(var(--header-h) + 32px); }
.search-panel.is-open { display: block; }

.search-box {
	max-width: 720px;
	margin-left: auto;
	padding: 20px;
	border-radius: var(--radius-lg);
	background: var(--white);
	box-shadow: var(--shadow);
}
.search-box__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.search-box__title { margin: 0; color: var(--midnight); font-weight: 700; }

.search-form { display: flex; gap: 8px; }
.search-form__field {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
}
.search-form__field .icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search-form__input {
	width: 100%;
	height: 48px;
	padding: 0 14px 0 44px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	background: var(--white);
}
.search-form__input:focus { outline: 2px solid var(--indigo-ink); outline-offset: 1px; border-color: transparent; }

/* 7. Buttons, labels, forms ------------------------------------------------ */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 46px;
	padding: 0 20px;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	font-weight: 650;
	font-size: 0.95rem;
	text-decoration: none;
	cursor: pointer;
}
.btn--primary { background: var(--indigo); color: var(--white); }
.btn--primary:hover { background: var(--indigo-ink); color: var(--white); }
.btn--ghost { border-color: var(--line-strong); background: var(--white); color: var(--midnight); }
.btn--ghost:hover { border-color: var(--indigo); color: var(--indigo-ink); }

.label, .kicker {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--indigo-tint);
	color: var(--indigo-ink);
	font-size: 0.75rem;
	font-weight: 650;
	line-height: 1.5;
	text-decoration: none;
}
a.label:hover, a.kicker:hover { background: var(--indigo); color: var(--white); }

.link-arrow {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--indigo-ink);
	font-weight: 650;
	font-size: 0.925rem;
	text-decoration: none;
}
.link-arrow:hover { color: var(--midnight); }
.link-arrow .icon { transition: transform 0.2s var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

.chips ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip {
	display: inline-block;
	padding: 6px 14px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	background: var(--white);
	color: var(--midnight);
	font-size: var(--fs-sm);
	font-weight: 550;
	text-decoration: none;
}
.chip:hover, .chip[aria-current] { border-color: var(--indigo); color: var(--indigo-ink); }

input[type="text"], input[type="email"], input[type="search"], select, textarea {
	max-width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	background: var(--white);
}

/* 8. Cards ------------------------------------------------------------------ */
.card { position: relative; min-width: 0; }
.card__media {
	display: block;
	overflow: hidden;
	border-radius: var(--radius-sm);
	background: var(--pale);
}
.card__img, .card__ph { display: block; width: 100%; height: 100%; object-fit: cover; }
.card__ph { min-height: 100%; background: linear-gradient(135deg, var(--indigo-tint), var(--cyan-tint)); }
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-4x3 { aspect-ratio: 4 / 3; }
.ratio-1x1 { aspect-ratio: 1; }
.ratio-4x5 { aspect-ratio: 4 / 5; }
.ratio-fill { height: 100%; }
.card__media .card__img { transition: transform 0.4s var(--ease); }
.card:hover .card__media .card__img { transform: scale(1.03); }

.card__body { min-width: 0; }
.card__badge { margin-bottom: 8px; }
.card__title {
	margin: 0 0 6px;
	font-size: var(--fs-md);
	font-weight: 700;
	line-height: 1.3;
}
.card__link { color: var(--text); text-decoration: none; }
.card__link:hover { color: var(--indigo-ink); }
.card__excerpt { margin: 0 0 10px; color: var(--muted); font-size: 0.95rem; line-height: 1.55; }
.card__num { display: block; color: var(--indigo-ink); font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 700; }

.card--stack .card__media { margin-bottom: 14px; }

.card--row {
	display: grid;
	grid-template-columns: var(--thumb, 180px) minmax(0, 1fr);
	align-items: start;
	gap: 18px;
}
@media (max-width: 599px) {
	.card--row { --thumb: 112px; gap: 14px; }
	.card--row .card__title { font-size: 1rem; }
	.card--row .card__excerpt { display: none; }
}

.card--mini .card__title { margin-bottom: 4px; font-size: 0.975rem; line-height: 1.35; }
.card--text .card__title { font-size: 1.0625rem; }

.feed { display: grid; }
.feed > .card { padding-block: 20px; border-bottom: 1px solid var(--line); }
.feed > .card:first-child { padding-top: 0; }
.feed__more { margin: 24px 0 0; }

.mini-list, .rank__list { margin: 0; padding: 0; list-style: none; }
.mini-list > li, .rank__list > li { padding-block: 12px; border-bottom: 1px solid var(--line); }
.mini-list > li:last-child, .rank__list > li:last-child { border-bottom: 0; }
.rank__list .card--mini { display: grid; grid-template-columns: 30px 1fr; }
.rank__note { color: var(--muted); font-size: var(--fs-sm); }

/* 9. Section heads ---------------------------------------------------------- */
.sec-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px 16px;
	margin-bottom: 24px;
}
.sec-head__kicker {
	order: -1;
	flex-basis: 100%;
	padding: 0;
	background: none;
	color: var(--muted);
	font-size: var(--fs-sm);
	font-weight: 600;
}
.sec-head__kicker::before {
	content: "";
	display: inline-block;
	width: 8px;
	height: 8px;
	margin-right: 8px;
	border-radius: 50%;
	background: var(--cyan);
	vertical-align: 1px;
}
.sec-head__title { margin: 0; font-size: var(--fs-2xl); }
.sec-head__more { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 0.925rem; text-decoration: none; }

/* 10. Side boxes (homepage desk + archives) -------------------------------- */
.side { display: grid; gap: 20px; align-content: start; }
.side-box {
	padding: 20px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--white);
}
.side-box--spotlight { background: linear-gradient(160deg, var(--indigo-tint), var(--white) 70%); border-color: #DAD6FF; }
.side-box__title {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 12px;
	color: var(--midnight);
	font-weight: 750;
}
.side-box__title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--cyan); }
.side-box__text { color: var(--muted); font-size: var(--fs-sm); }
.side-box .link-arrow { margin-top: 8px; }

.topic-list { margin: 0; padding: 0; list-style: none; }
.topic-list a {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--line);
	color: var(--midnight);
	font-weight: 600;
	font-size: 0.95rem;
	text-decoration: none;
}
.topic-list li:last-child a { border-bottom: 0; }
.topic-list a:hover { color: var(--indigo-ink); }
.topic-list__kicker { color: var(--muted); font-size: var(--fs-xs); font-weight: 500; text-align: right; }

.rail-widgets .widget { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); }

/* 11. Breadcrumbs & pagination --------------------------------------------- */
.breadcrumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 0 0 18px;
	padding: 0;
	list-style: none;
	font-size: var(--fs-sm);
}
.breadcrumbs li { color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line-strong); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--indigo-ink); text-decoration: underline; }
@media (max-width: 599px) { .article__head .breadcrumbs li:last-child { display: none; } } /* the H1 follows right below */
.breadcrumbs [aria-current] { display: inline-block; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; color: var(--body); }

.pagination { margin-top: 32px; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: 6px; }
.page-numbers {
	display: inline-grid;
	place-items: center;
	min-width: 42px;
	height: 42px;
	padding: 0 12px;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	color: var(--midnight);
	font-weight: 600;
	text-decoration: none;
}
.page-numbers.current { border-color: var(--indigo); background: var(--indigo); color: var(--white); }
a.page-numbers:hover { border-color: var(--indigo); color: var(--indigo-ink); }

/* 12. Footer ----------------------------------------------------------------- */
.site-footer {
	margin-top: var(--gap-lg);
	background: var(--midnight);
	color: var(--on-dark-muted);
	font-size: var(--fs-sm);
}
.site-footer a { color: var(--on-dark); text-decoration: none; }
.site-footer a:hover { color: var(--cyan); text-decoration: underline; }
.site-footer :focus-visible { outline-color: var(--cyan); }
.site-footer ul { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; padding: 0; list-style: none; }

.site-footer__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 40px; }
.site-footer__row--top { padding-block: 28px 22px; }
.site-footer__row--bottom { padding-block: 16px 22px; border-top: 1px solid rgb(255 255 255 / 0.12); }
.site-footer__brand { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; max-width: 640px; }
.site-footer__brand p { margin: 0; max-width: 46ch; }
.site-footer__brand .brand__img { height: 26px; }
.site-footer__sections a { font-weight: 600; }
.site-footer__social { gap: 10px; }
.site-footer__social a { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgb(255 255 255 / 0.08); }
.site-footer__copy { margin: 0; }

/* 13. Motion & print -------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
	.site-header, .site-footer, .share, .related, .side, .nav-scrim, .read-progress { display: none !important; }
	body { background: #fff; color: #000; }
}
