:root {
	--bg: #ffffff;
	--fg: #121212;
	--muted: #6b7280;
	--border: #e5e7eb;
	--accent: #2563eb;
	--hover-bg: #f3f4f6;
	--dot: #ef4444;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #121212;
		--fg: #f3f4f6;
		--muted: #9ca3af;
		--border: #2a2a2a;
		--accent: #60a5fa;
		--hover-bg: #1e1e1e;
		--dot: #fbbf24;
	}
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	background: var(--bg);
	color: var(--fg);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
		Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

.page {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

/* Header */
.site-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	padding: 1rem 1.5rem;
	border-bottom: 1px solid var(--border);
}

.brand {
	font-weight: 700;
	font-size: 1.05rem;
	color: var(--fg);
	text-decoration: none;
	letter-spacing: 0.01em;
}

.nav {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	flex-wrap: wrap;
}

.nav-link {
	color: var(--fg);
	text-decoration: none;
	font-size: 0.95rem;
	padding: 0.4rem 0.7rem;
	border-radius: 6px;
	transition: background-color 0.15s ease;
}

.nav-link:hover {
	background: var(--hover-bg);
}

.nav-link[aria-current='page'] {
	color: var(--accent);
	font-weight: 600;
}

/* Hero */
.hero {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 3rem 1.5rem;
	gap: 1rem;
}

.hero-logo {
	display: block;
	width: clamp(120px, 30vw, 200px);
	aspect-ratio: 90 / 55;
	margin: 0 auto 1.5rem;
	background-color: var(--fg);
	-webkit-mask: url(/amerharb-logo.svg) center / contain no-repeat;
	mask: url(/amerharb-logo.svg) center / contain no-repeat;
}

/* Self-hosted subset fonts so the hero-title script conversions (abjad-convert)
   render on devices lacking these scripts, instead of showing tofu boxes. One
   @font-face per at-risk script, all under 'hero-scripts', each scoped to its
   Unicode block via unicode-range — so a subset only loads when that script is
   shown, and anything outside these ranges (Latin, Arabic, Hebrew, Hangul, IPA)
   falls through to the system stack. Rebuild via scripts/build-hero-font.sh. */
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/ugaritic.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+10380-1039F;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/imperial-aramaic.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+10840-1085F;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/nabataean.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+10880-108AF;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/phoenician.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+10900-1091F;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/old-south-arabian.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+10A60-10A7F;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/hanifi-rohingya.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+10D00-10D3F;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/runic.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+16A0-16FF;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/tifinagh.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+2D30-2D7F;
}
@font-face {
	font-family: 'hero-scripts';
	src: url('/hero-fonts/syriac.woff2') format('woff2');
	font-display: swap;
	unicode-range: U+0700-074F;
}

.hero-title {
	margin: 0;
	font-family: 'hero-scripts', -apple-system, BlinkMacSystemFont, 'Segoe UI',
		Roboto, Helvetica, Arial, sans-serif;
	font-size: clamp(2.5rem, 8vw, 5rem);
	font-weight: 800;
	letter-spacing: 0.06em;
	line-height: 1;
	height: 1.5em;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	animation: card-flip 1s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes card-flip {
	0% {
		opacity: 0;
		transform: perspective(800px) rotateY(-180deg);
	}
	100% {
		opacity: 1;
		transform: perspective(800px) rotateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.hero-title {
		animation: none;
	}
}

.hero-subtitle {
	margin: 0;
	color: var(--muted);
	font-size: clamp(1rem, 3vw, 1.25rem);
	user-select: none;
	-webkit-user-select: none;
}

/* Social */
.social {
	list-style: none;
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
	justify-content: center;
	padding: 0;
	margin: 1.5rem 0 0;
}

.social-link {
	display: inline-block;
	color: var(--fg);
	text-decoration: none;
	user-select: none;
	-webkit-user-select: none;
	font-size: 0.95rem;
	padding: 0.5rem 1rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.social-link:hover {
	border-color: var(--accent);
	color: var(--accent);
}

/* Generic page body */
.page-body {
	flex: 1;
	width: 100%;
	max-width: 1100px;
	margin: 0 auto;
	padding: 2.5rem 1.5rem;
}

.visit-map-wrap {
	position: relative;
	width: 100%;
}

.visit-map {
	display: block;
	width: 100%;
	aspect-ratio: 2000 / 778;
	background-color: var(--fg);
	-webkit-mask: url(/world-equirect.svg) center / contain no-repeat;
	mask: url(/world-equirect.svg) center / contain no-repeat;
}

.visit-dots {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.visit-dots circle {
	fill: var(--dot);
}

@font-face {
	font-family: 'flags';
	src: url('/flags.woff2') format('woff2');
	font-display: swap;
}

.flag-row {
	list-style: none;
	margin: 1.5rem 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.flag-item {
	font-family: 'flags', 'Apple Color Emoji', 'Segoe UI Emoji',
		'Noto Color Emoji', sans-serif;
	font-size: 1.75rem;
	line-height: 1;
	cursor: default;
}

/* Page title */
.page-title {
	margin: 0 0 1.5rem;
	font-size: clamp(2rem, 6vw, 3rem);
	font-weight: 800;
	letter-spacing: 0.04em;
}

/* Open Source project cards */
.project-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1rem;
}

.project-card {
	display: flex;
	align-items: flex-start;
	gap: 1rem;
	height: 100%;
	padding: 1.25rem;
	border: 1px solid var(--border);
	border-radius: 12px;
	color: var(--fg);
	transition: border-color 0.15s ease;
}

.project-card:hover {
	border-color: var(--accent);
}

.project-icon {
	font-size: 2rem;
	line-height: 1;
}

.project-info {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.project-name {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	font-weight: 700;
	font-size: 1.05rem;
}

.project-kind {
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.1rem 0.5rem;
}

.project-desc {
	color: var(--muted);
	font-size: 0.9rem;
	line-height: 1.4;
}

.project-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.5rem;
}

.project-links a {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	color: var(--fg);
	text-decoration: none;
	font-size: 0.8rem;
	font-weight: 600;
	padding: 0.3rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.project-links a:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.pill-icon {
	width: 1.05em;
	height: 1.05em;
	flex-shrink: 0;
}

/* Footer */
.site-footer {
	position: relative;
	padding: 1.5rem;
	text-align: center;
	color: var(--muted);
	font-size: 0.85rem;
	border-top: 1px solid var(--border);
}

.footer-version {
	position: absolute;
	right: 1.5rem;
	bottom: 1.5rem;
	font-size: 0.75rem;
	opacity: 0.7;
}
