/* site.mengkheang.com design system. Plain CSS, no framework.
   Light and dark via [data-theme] (set by site.js) with prefers-color-scheme fallback. */

:root {
	--bg: #fbfbfd;
	--bg-alt: #f5f5f7;
	--card: #ffffff;
	--fg: #1d1d1f;
	--muted: #6e6e73;
	--line: rgba(0, 0, 0, 0.1);
	--link: #0066cc;
	--accent: #0071e3;
	--accent-fg: #ffffff;
	--nav-bg: rgba(251, 251, 253, 0.72);
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 30px rgba(0, 0, 0, 0.06);
	--shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.06), 0 18px 44px rgba(0, 0, 0, 0.12);
	--radius: 22px;
	--font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
	--mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	--grad: linear-gradient(92deg, #0071e3 0%, #8e5af7 50%, #ff5e8a 100%);
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #000000;
		--bg-alt: #111113;
		--card: #1c1c1e;
		--fg: #f5f5f7;
		--muted: #a1a1a6;
		--line: rgba(255, 255, 255, 0.14);
		--link: #2997ff;
		--accent: #2997ff;
		--accent-fg: #000000;
		--nav-bg: rgba(0, 0, 0, 0.72);
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.35);
		--shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.5), 0 18px 44px rgba(0, 0, 0, 0.55);
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #000000;
	--bg-alt: #111113;
	--card: #1c1c1e;
	--fg: #f5f5f7;
	--muted: #a1a1a6;
	--line: rgba(255, 255, 255, 0.14);
	--link: #2997ff;
	--accent: #2997ff;
	--accent-fg: #000000;
	--nav-bg: rgba(0, 0, 0, 0.72);
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.35);
	--shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.5), 0 18px 44px rgba(0, 0, 0, 0.55);
	color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font: 400 17px/1.5 var(--font);
	letter-spacing: -0.011em;
	-webkit-font-smoothing: antialiased;
	transition: background-color 0.4s ease, color 0.4s ease;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); color: var(--fg); padding: 8px 14px; border-radius: 999px; z-index: 100; }
.skip:focus { left: 12px; }
.muted { color: var(--muted); }

/* ---- page transitions (cross-document view transitions) ---- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.28s; }

/* ---- navigation ---- */
.nav {
	position: sticky; top: 0; z-index: 50;
	background: var(--nav-bg);
	-webkit-backdrop-filter: saturate(180%) blur(20px);
	backdrop-filter: saturate(180%) blur(20px);
	border-bottom: 1px solid var(--line);
}
.nav-inner { max-width: 1080px; margin: 0 auto; padding: 0 22px; height: 52px; display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 600; font-size: 17px; color: var(--fg); margin-right: auto; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; }
.nav-links a { color: var(--fg); opacity: 0.8; font-size: 14px; padding: 6px 12px; border-radius: 999px; transition: opacity 0.2s, background-color 0.2s; }
.nav-links a:hover { opacity: 1; background: var(--bg-alt); text-decoration: none; }
.nav-links a[aria-current="page"] { opacity: 1; background: var(--bg-alt); font-weight: 500; }
.icon-btn { appearance: none; border: 0; background: transparent; color: var(--fg); width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; transition: background-color 0.2s; }
.icon-btn:hover { background: var(--bg-alt); }
.icon-btn svg { width: 18px; height: 18px; }
.nav-toggle { display: none; }
@media (max-width: 700px) {
	.nav-toggle { display: inline-grid; }
	.nav-links {
		position: absolute; left: 0; right: 0; top: 52px; flex-direction: column; gap: 0;
		background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 22px 16px;
		transform: translateY(-8px); opacity: 0; visibility: hidden; transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s;
	}
	.nav[data-open="true"] .nav-links { transform: none; opacity: 1; visibility: visible; }
	.nav-links a { font-size: 22px; padding: 12px 0; border-radius: 0; border-bottom: 1px solid var(--line); background: none !important; }
}

/* ---- layout ---- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 22px; }
.narrow { max-width: 720px; margin: 0 auto; padding: 0 22px; }
main { min-height: 60vh; }
.section { padding: clamp(56px, 9vw, 112px) 0; }
.band { background: var(--bg-alt); }
.eyebrow { color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; margin: 0 0 10px; }
h1, h2, h3 { letter-spacing: -0.03em; line-height: 1.08; margin: 0 0 0.4em; font-weight: 700; }
h1 { font-size: clamp(40px, 7vw, 72px); }
h2 { font-size: clamp(30px, 4.6vw, 48px); }
h3 { font-size: 24px; letter-spacing: -0.02em; }
.lead { font-size: clamp(19px, 2.4vw, 26px); line-height: 1.35; color: var(--muted); font-weight: 400; max-width: 34em; margin: 0 0 28px; letter-spacing: -0.015em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; background-size: 200% 100%; animation: shimmer 9s ease-in-out infinite alternate; }
@keyframes shimmer { to { background-position: 100% 0; } }

/* ---- hero ---- */
.hero { text-align: center; padding: clamp(72px, 14vw, 168px) 0 clamp(56px, 9vw, 112px); position: relative; overflow: hidden; }
.hero::before {
	content: ""; position: absolute; inset: -20% -10% auto -10%; height: 90%; z-index: -1;
	background: radial-gradient(60% 60% at 50% 0%, rgba(0, 113, 227, 0.16), transparent 70%),
		radial-gradient(40% 40% at 80% 20%, rgba(255, 94, 138, 0.14), transparent 70%);
}
.hero .lead { margin-left: auto; margin-right: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }

/* ---- buttons ---- */
.btn {
	appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	font: inherit; font-size: 17px; font-weight: 500; padding: 12px 24px; border-radius: 999px;
	background: var(--accent); color: var(--accent-fg); transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s;
}
.btn:hover { text-decoration: none; transform: scale(1.03); box-shadow: 0 8px 24px rgba(0, 113, 227, 0.3); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--link); box-shadow: inset 0 0 0 1.5px var(--link); }
.btn.ghost:hover { background: var(--bg-alt); box-shadow: inset 0 0 0 1.5px var(--link); }
.link-arrow::after { content: " \203A"; }

/* ---- cards ---- */
.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card {
	display: flex; flex-direction: column; gap: 10px; background: var(--card); border-radius: var(--radius);
	padding: 28px; color: var(--fg); box-shadow: var(--shadow); border: 1px solid var(--line);
	transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;
}
a.card:hover { transform: translateY(-6px) scale(1.01); box-shadow: var(--shadow-hover); text-decoration: none; }
.card h3 { margin: 0; }
.card p { margin: 0; color: var(--muted); }
.card .meta { font-size: 14px; color: var(--muted); }
/* long descriptions on summary cards: show 4 lines, full text lives on the detail page */
.card p.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .more { margin-top: auto; padding-top: 8px; color: var(--link); font-weight: 500; }
.card-thumb { margin: -28px -28px 6px; border-radius: var(--radius) var(--radius) 0 0; aspect-ratio: 16 / 9; object-fit: cover; width: calc(100% + 56px); max-width: none; background: var(--bg-alt); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg-alt); color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.section-head h2 { margin: 0; }

/* ---- article / prose ---- */
.article-head { padding: clamp(48px, 8vw, 96px) 0 24px; }
.prose { font-size: 19px; line-height: 1.6; letter-spacing: -0.01em; }
.prose h2 { margin-top: 1.6em; font-size: 32px; }
.prose h3 { margin-top: 1.4em; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose figure { margin: 0 0 1.2em; }
.prose img, .prose video { border-radius: 14px; display: block; margin: 1.4em auto; }
.prose blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 20px; color: var(--muted); font-size: 21px; }
.prose code { font-family: var(--mono); font-size: 0.88em; background: var(--bg-alt); padding: 2px 6px; border-radius: 6px; }
.prose pre { background: var(--bg-alt); padding: 18px 20px; border-radius: 14px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 1.2em; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; }

/* ---- forms ---- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.input, .field input[type="text"], .field input[type="email"], .field input[type="url"], .field input[type="number"], .field select, .field textarea {
	width: 100%; font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line);
	border-radius: 14px; padding: 13px 16px; transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { min-height: 170px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.2); }
.errors { background: rgba(255, 59, 48, 0.1); color: #d70015; border-radius: 14px; padding: 14px 18px 14px 36px; margin: 0 0 18px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .errors { color: #ff6961; } }
:root[data-theme="dark"] .errors { color: #ff6961; }
.hp { position: absolute; left: -9999px; }

/* ---- pager / footer ---- */
.pager { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 36px 0 0; }
.footer { border-top: 1px solid var(--line); background: var(--bg-alt); color: var(--muted); font-size: 13px; padding: 28px 0 40px; margin-top: 0; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }
.footer a { color: var(--muted); }

/* ---- scroll reveal (only hidden when JS is running) ---- */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); transition-delay: var(--d, 0s); }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
	.js .reveal { opacity: 1; transform: none; }
	@view-transition { navigation: none; }
}
