@font-face {
	font-family: 'Baloo 2';
	src: url('./fonts/baloo2-bold-latin.woff2') format('woff2');
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

:root {
	--sj-orange: #de6a2b;
	--sj-orange-dark: #b84e18;
	--sj-orange-darker: #a8480f;
	--sj-orange-light: #fdead6;
	--sj-orange-glow: var(--sj-orange-light);
	--sj-green: #7c9a3d;
	--sj-green-dark: #5f7a2a;
	--sj-green-darker: #4a5f1f;
	--sj-green-light: #e9f0d9;
	--sj-gold: #cc9a34;
	--sj-red: #d9463a;
	--sj-blue: #1a5fb4;
	--sj-blue-visited: #660099;

	--text-primary: #2b2420;
	--text-secondary: #6b5f52;
	--text-tertiary: #7a6d5c;
	--text-link-green: var(--sj-green-dark);
	--text-link-orange: var(--sj-orange-darker);

	--bg: #fffdf9;
	--bg-card: #ffffff;
	--bg-subtle: #f6ede0;
	--border: #eee0c6;
	--border-hover: #ddc9a3;

	--stat-bar-bg: var(--sj-green-light);
	--stat-bar-text: var(--sj-green-darker);
	--sort-pill-bg: rgba(255, 255, 255, .5);
	--sort-pill-hover-bg: rgba(255, 255, 255, .85);

	--radius-full: 999px;
	--radius-md: 16px;
	--radius-lg: 24px;
	--shadow-sm: 0 3px 12px rgba(120, 72, 20, .10);
	--shadow-md: 0 8px 24px rgba(120, 72, 20, .16);

	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--font-script: Georgia, "Times New Roman", serif;
	--font-display: "Baloo 2", var(--font);
}

/* Dark theme: follows the OS/browser default automatically unless the
   visitor has explicitly overridden it with the toggle (data-theme,
   persisted in localStorage — see the inline script in <head>). */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--sj-orange-glow: #2e2016;
		--sj-blue: #7ab0f0;
		--sj-blue-visited: #c39bea;

		--text-primary: #f3ece1;
		--text-secondary: #cbbfa9;
		--text-tertiary: #9d9078;
		--text-link-green: #a9c96e;
		--text-link-orange: #f0975e;

		--bg: #17130f;
		--bg-card: #211a13;
		--bg-subtle: #2a2118;
		--border: #3a2f22;
		--border-hover: #4a3c2a;

		--stat-bar-bg: #26361a;
		--stat-bar-text: #dcedc0;
		--sort-pill-bg: rgba(0, 0, 0, .28);
		--sort-pill-hover-bg: rgba(0, 0, 0, .45);

		--shadow-sm: 0 3px 12px rgba(0, 0, 0, .35);
		--shadow-md: 0 8px 24px rgba(0, 0, 0, .5);
	}
}

:root[data-theme="dark"] {
	--sj-orange-glow: #2e2016;
	--sj-blue: #7ab0f0;
	--sj-blue-visited: #c39bea;

	--text-primary: #f3ece1;
	--text-secondary: #cbbfa9;
	--text-tertiary: #9d9078;
	--text-link-green: #a9c96e;
	--text-link-orange: #f0975e;

	--bg: #17130f;
	--bg-card: #211a13;
	--bg-subtle: #2a2118;
	--border: #3a2f22;
	--border-hover: #4a3c2a;

	--stat-bar-bg: #26361a;
	--stat-bar-text: #dcedc0;
	--sort-pill-bg: rgba(0, 0, 0, .28);
	--sort-pill-hover-bg: rgba(0, 0, 0, .45);

	--shadow-sm: 0 3px 12px rgba(0, 0, 0, .35);
	--shadow-md: 0 8px 24px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

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

body {
	font-family: var(--font);
	color: var(--text-primary);
	background: var(--bg);
	font-size: 15px;
	line-height: 1.5;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	transition: background-color .2s ease, color .2s ease;
}

a {
	color: var(--sj-blue);
	text-decoration: none;
}

a:visited { color: var(--sj-blue-visited); }
a:hover { text-decoration: underline; }
a img { border: none; }

img { max-width: 100%; }

.hero-logo {
	display: block;
	width: 100%;
	max-width: 460px;
	height: auto;
	margin-left: auto;
	margin-right: auto;
	position: relative;
	z-index: 1;
}

/* The homepage hero logo has a dark-mode-specific variant (logo-hero-dark.png)
   with just the "Malaysia" tagline recolored, since that text is baked into
   the raster artwork and can't be restyled with CSS. Swap it in the same way
   the theme-toggle sun/moon icons are swapped, below. */
.hero-logo-dark {
	display: none;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .hero-logo:not(.hero-logo-dark) { display: none; }
	:root:not([data-theme="light"]) .hero-logo-dark { display: block; }
}

:root[data-theme="dark"] .hero-logo:not(.hero-logo-dark) { display: none; }
:root[data-theme="dark"] .hero-logo-dark { display: block; }

.header-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: none;
}

.header-logo-link {
	display: inline-flex;
	align-items: center;
	text-decoration: none !important;
	flex: none;
}

.header-logo {
	display: block;
	height: 52px;
	width: auto;
}

@media (max-width: 640px) {
	.header-logo {
		height: 44px;
	}
}

.search-pill {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	border: 2.5px solid var(--sj-orange);
	border-radius: var(--radius-full);
	padding: 0 22px;
	height: 52px;
	background: var(--bg-card);
	box-shadow: 0 4px 0 rgba(184, 78, 24, .18);
	transition: box-shadow .15s ease, transform .12s ease;
}

.search-pill:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 0 rgba(184, 78, 24, .2), var(--shadow-md);
}

.search-pill:focus-within {
	transform: translateY(-1px);
	box-shadow: 0 6px 0 rgba(184, 78, 24, .2), var(--shadow-md);
}

.search-pill svg {
	flex: none;
	color: var(--sj-orange);
}

.search-pill input[type="text"] {
	flex: 1;
	min-width: 0;
	border: none;
	outline: none;
	background: transparent;
	font-size: 16px;
	font-family: var(--font);
	color: var(--text-primary);
	height: 100%;
}

/* Loading feedback: a search is a full page reload, so the goal is just to
   acknowledge the click instantly rather than let the page look frozen while
   the server responds. See the submit-handler script near the theme toggle. */
.search-icon-spinner {
	display: none;
	animation: ss-spin .8s linear infinite;
}

.search-pill.is-searching .search-icon { display: none; }
.search-pill.is-searching .search-icon-spinner { display: block; }

.search-pill.is-searching input[type="text"] {
	opacity: .7;
	pointer-events: none;
}

@keyframes ss-spin {
	to { transform: rotate(360deg); }
}

.btn:disabled {
	/* No opacity reduction: the button's orange only clears the WCAG 3:1
	   large-text minimum with white text at full strength (3.39:1) - dimming
	   it pushes that below the threshold. Cursor change is enough of a cue,
	   on top of the text/spinner/progress-bar changes already signaling it. */
	cursor: not-allowed;
}

#load-bar {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 3px;
	z-index: 60;
	pointer-events: none;
}

#load-bar::before {
	content: "";
	display: block;
	height: 100%;
	width: 0;
	background: linear-gradient(90deg, var(--sj-orange), var(--sj-green-dark));
}

#load-bar.is-active::before {
	width: 90%;
	transition: width 6s cubic-bezier(.15, .8, .3, 1);
}

@media (prefers-reduced-motion: reduce) {
	.search-icon-spinner { animation: none; }
	#load-bar.is-active::before { transition: none; width: 90%; }
}

.btn {
	display: inline-block;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	font-family: var(--font-display);
	font-size: 19px;
	line-height: 1;
	font-weight: 700;
	letter-spacing: .01em;
	border-radius: var(--radius-full);
	border: none;
	background: var(--sj-orange);
	color: #fff;
	padding: 11px 24px;
	cursor: pointer;
	box-shadow: 0 3px 0 var(--sj-orange-dark);
	transition: box-shadow .1s ease, transform .1s ease;
}

.btn:hover {
	background: var(--sj-orange-dark);
	text-decoration: none;
}

.btn:active {
	transform: translateY(2px);
	box-shadow: 0 1px 0 var(--sj-orange-dark);
}

.btn:focus-visible {
	outline: 2px solid var(--sj-blue);
	outline-offset: 2px;
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	background: var(--sj-orange);
	color: #fff;
	padding: 10px 16px;
	border-radius: 0 0 var(--radius-md) 0;
	font-weight: 700;
	font-size: 14px;
	text-decoration: none !important;
}

.skip-link:focus {
	left: 0;
}

.home-main {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px 120px;
	position: relative;
	overflow: hidden;
	background: radial-gradient(ellipse 1200px 700px at 50% 0%, var(--sj-orange-glow) 0%, var(--bg) 62%);
}

.home-wrap {
	width: 100%;
	max-width: 580px;
	text-align: center;
	position: relative;
	z-index: 1;
}

.home-wrap .hero-logo {
	margin-bottom: 36px;
	filter: drop-shadow(0 14px 28px rgba(120, 72, 20, .16));
}

.home-promo {
	margin-top: 24px;
	font-size: 13px;
	color: var(--text-tertiary);
	background: var(--bg-card);
	display: inline-block;
	padding: 8px 18px;
	border-radius: var(--radius-full);
	border: 1px solid var(--border);
}

.home-promo a { color: var(--text-link-green); text-decoration: underline; font-weight: 700; }

.page {
	min-height: 100vh;
}

.site-header {
	position: -webkit-sticky;
	position: sticky;
	top: 0;
	z-index: 20;
	background: linear-gradient(180deg, var(--bg-card), var(--sj-orange-glow) 260%);
	border-bottom: 1px solid var(--border);
	box-shadow: 0 2px 10px rgba(120, 72, 20, .08);
}

.site-header-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 28px;
	max-width: 1000px;
	margin: 0 auto;
	padding: 14px 24px;
}

.site-header-inner .search-pill {
	max-width: 620px;
	height: 46px;
	border-width: 2px;
}

.stat-bar {
	background: var(--stat-bar-bg);
	border-bottom: 1px solid var(--border);
}

.stat-bar-inner {
	max-width: 856px;
	margin: 0 auto;
	padding: 10px 24px;
	color: var(--stat-bar-text);
	font-weight: 600;
	font-size: 13px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px 16px;
}

.sort-control {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 600;
	flex: none;
	white-space: nowrap;
}

.sort-control-label {
	color: var(--stat-bar-text);
	opacity: .75;
}

.sort-control-options {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	background: var(--sort-pill-bg);
	border-radius: var(--radius-full);
	padding: 2px;
}

.sort-option {
	display: inline-flex;
	align-items: center;
	padding: 4px 12px;
	border-radius: var(--radius-full);
	color: var(--stat-bar-text);
	text-decoration: none !important;
	transition: background .15s ease, color .15s ease;
}

.sort-option:hover {
	background: var(--sort-pill-hover-bg);
}

.sort-option:focus-visible {
	outline: 2px solid var(--sj-blue);
	outline-offset: 1px;
}

.sort-option.active {
	background: var(--sj-green-dark);
	color: #fff;
	font-weight: 700;
}

.content-shell {
	width: 100%;
	max-width: 1000px;
	margin: 0 auto;
	padding: 28px 24px;
}

.results-col {
	min-width: 0;
	max-width: 808px;
	margin: 0 auto;
}

.result {
	margin-bottom: 16px;
	padding: 18px 20px 18px 22px;
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-left: 4px solid var(--sj-green);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	transition: border-left-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.result:hover {
	border-left-color: var(--sj-orange);
	transform: translateY(-2px) translateX(1px);
	box-shadow: var(--shadow-md);
}

.result .linkurl {
	display: block;
	font-size: 13px;
	color: var(--text-link-green) !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-decoration: none !important;
	margin-top: 4px;
	font-weight: 600;
}

.result .result-title {
	font-size: 19px;
	font-weight: 700;
	color: var(--sj-blue);
	font-family: var(--font-display);
}

.result .dtext {
	display: block;
	margin-top: 6px;
	font-size: 14px;
	line-height: 1.6;
	color: var(--text-secondary);
}

.highlight {
	background: transparent;
	color: var(--text-primary);
	font-weight: 700;
}

.result .dtext .highlight {
	background: #fde3ad;
	color: #2b2420;
	padding: 0 2px;
	border-radius: 3px;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .result .dtext .highlight {
		background: #6b4416;
		color: #fbe8c8;
	}
}

:root[data-theme="dark"] .result .dtext .highlight {
	background: #6b4416;
	color: #fbe8c8;
}

.navibar {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 6px 6px;
	margin-top: 28px;
	font-size: 13px;
}

.navibar .page-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	min-height: 36px;
	padding: 6px 12px;
	border-radius: var(--radius-full);
	color: var(--text-secondary);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none !important;
	background: transparent;
	transition: background .15s ease, color .15s ease;
}

.navibar .page-link:hover {
	color: var(--sj-orange-dark);
	background: var(--sj-orange-light);
}

.navibar .page-link:active {
	background: var(--border);
}

.navibar .page-link:focus-visible,
.navibar .highlight:focus-visible {
	outline: 2px solid var(--sj-blue);
	outline-offset: 2px;
}

.navibar .highlight {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 42px;
	min-height: 42px;
	padding: 8px 16px;
	border-radius: var(--radius-full);
	background: var(--sj-orange);
	color: #fff;
	font-weight: 800;
	font-size: 19px;
	box-shadow: 0 3px 0 var(--sj-orange-dark);
}

.prose {
	flex: 1;
	max-width: 640px;
	margin: 0 auto;
	padding: 40px 24px 80px;
}

.prose h1 {
	font-family: var(--font-display);
	font-size: 30px;
	color: var(--sj-orange-dark);
	margin: 0 0 20px;
}

.prose p {
	font-size: 15px;
	line-height: 1.7;
	color: var(--text-primary);
	margin: 0 0 16px;
}

.site-footer {
	border-top: 1px solid var(--border);
	background: var(--bg-subtle);
	padding: 18px 24px;
}

.site-footer ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0;
}

.site-footer li {
	font-size: 13px;
	color: var(--text-secondary);
	padding: 0 12px;
	border-right: 1px solid var(--border);
}

.site-footer li:last-child { border-right: none; }
.site-footer li a { color: var(--text-link-orange); font-weight: 700; }

.home-footer {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	background: transparent;
	border-top: none;
}

@media (max-width: 640px) {
	.site-header-inner {
		flex-wrap: wrap;
		gap: 12px;
		padding: 12px 16px;
	}

	.content-shell { padding: 20px 16px; }
	.stat-bar-inner { padding: 8px 16px; }
	.prose { padding: 28px 16px 60px; }
}

.theme-toggle {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 30;
	width: 44px;
	height: 44px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border);
	border-radius: var(--radius-full);
	background: var(--bg-card);
	color: var(--text-primary);
	box-shadow: var(--shadow-md);
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease, transform .12s ease;
}

.theme-toggle:hover {
	transform: translateY(-2px);
}

.theme-toggle:focus-visible {
	outline: 2px solid var(--sj-blue);
	outline-offset: 2px;
}

.theme-toggle svg {
	width: 20px;
	height: 20px;
}

.theme-toggle .icon-moon {
	display: none;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
	:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

@media (max-width: 640px) {
	.theme-toggle {
		right: 14px;
		bottom: 14px;
	}
}
