/* ==========================================================
   Theme switcher: light (original design) + dark.
   The light theme keeps the site's original colours.
   The dark theme is warm and low-glare: no pure white text,
   no pure black background.
   ========================================================== */

:root {
	color-scheme: light;
}

html[data-theme="dark"] {
	color-scheme: dark;
	--bg: #1e1d1b;
	--surface: #272521;
	--surface-2: #302d28;
	--text: #e2dbcf;
	--text-muted: #b0a798;
	--heading: #eee7da;
	--border: #47413a;
	--link: #9dbfe3;
	--link-hover: #c4dcf4;
	--link-visited: #b8a8d4;
	--accent: #3f6286;
	--accent-hover: #4b7299;
	--accent-text: #eef3f8;
	--warm: #c9a878;
	--footer-bg: #3a3129;
	--footer-text: #d8cdbd;
}

/* ---------- base ---------- */
html[data-theme="dark"],
html[data-theme="dark"] body {
	background-color: var(--bg);
	color: var(--text);
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4 {
	color: var(--heading) !important;
}

html[data-theme="dark"] p,
html[data-theme="dark"] li,
html[data-theme="dark"] td,
html[data-theme="dark"] th {
	color: var(--text);
}

html[data-theme="dark"] a,
html[data-theme="dark"] a:link {
	color: var(--link);
}
html[data-theme="dark"] a:visited {
	color: var(--link-visited);
}
html[data-theme="dark"] a:hover {
	color: var(--link-hover);
}

html[data-theme="dark"] hr {
	border-color: var(--border);
}
html[data-theme="dark"] .custom-hr-blue {
	border-color: #6f8fb3;
}
html[data-theme="dark"] .custom-hr-red {
	border-color: #b9786f;
}

/* ---------- main pages (index*.html) ---------- */
html[data-theme="dark"] .content-text {
	color: var(--text);
}
html[data-theme="dark"] .footer {
	background-color: var(--footer-bg);
	color: var(--footer-text);
}
html[data-theme="dark"] .footer a {
	color: var(--warm);
}
html[data-theme="dark"] .lang-btn {
	background: var(--surface);
	border-color: var(--border);
	color: var(--text);
	box-shadow: none;
}
html[data-theme="dark"] .lang-btn:hover {
	background: var(--surface-2);
	border-color: var(--warm);
}

/* ---------- articles (posts/*) ---------- */
html[data-theme="dark"] .meta,
html[data-theme="dark"] figcaption {
	color: var(--text-muted);
}
html[data-theme="dark"] .home-link a {
	color: var(--link);
}
html[data-theme="dark"] .back-to-home a {
	background-color: var(--accent);
	color: var(--accent-text);
}
html[data-theme="dark"] .back-to-home a:hover {
	background-color: var(--accent-hover);
}
html[data-theme="dark"] img {
	border-color: var(--border);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
	/* scans and maps are bright: dim them slightly, full brightness on hover */
	filter: brightness(0.88);
	transition: filter 0.2s;
}
html[data-theme="dark"] img:hover {
	filter: none;
}
html[data-theme="dark"] blockquote {
	background: var(--surface);
	border-left-color: var(--border);
	color: var(--text);
}
html[data-theme="dark"] .references {
	border-top-color: var(--border);
}
html[data-theme="dark"] .references h2 {
	color: var(--heading);
}
html[data-theme="dark"] .references li {
	color: var(--text);
}
html[data-theme="dark"] .references li:before {
	color: var(--text-muted);
}

/* ---------- support pages ---------- */
html[data-theme="dark"] .support-card {
	background: var(--surface);
	border-color: var(--border);
	box-shadow: none;
}
html[data-theme="dark"] .support-card:hover {
	border-color: var(--warm);
}
html[data-theme="dark"] .support-card h3 {
	color: var(--heading);
}
/* QR codes stay dark-on-white so phones can still scan them */
html[data-theme="dark"] .qr-code {
	background: #f4f1ea;
}
html[data-theme="dark"] .qr-code img {
	filter: none;
}
html[data-theme="dark"] .crypto-address {
	background: var(--surface-2);
	border-color: var(--border);
	color: var(--text);
}
html[data-theme="dark"] .btn {
	background: var(--surface-2);
	border-color: var(--border);
	color: var(--text);
}
html[data-theme="dark"] .btn:hover {
	background: #3a362f;
}
html[data-theme="dark"] .btn-primary {
	background: #775c3c;
	border-color: #a07d52;
	color: #f6efe4;
}
html[data-theme="dark"] .btn-primary:hover {
	background: #846843;
}
html[data-theme="dark"] .footer-note {
	color: var(--text-muted);
}
html[data-theme="dark"] .content > h1[style] {
	color: var(--heading) !important;
}

/* ---------- toggle button (both themes) ---------- */
.theme-toggle {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 1000;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid #bc9a6c;
	background: #f5f2e6;
	color: #4a2e1f;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
	transition: background 0.2s, transform 0.2s;
}
.theme-toggle:hover {
	background: #e8dfcf;
	transform: translateY(-2px);
}
.theme-toggle:focus-visible {
	outline: 2px solid #8b6946;
	outline-offset: 2px;
}
html[data-theme="dark"] .theme-toggle {
	background: var(--surface-2);
	border-color: var(--border);
	color: #f0d9a8;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .theme-toggle:hover {
	background: #3a362f;
}

@media print {
	.theme-toggle {
		display: none;
	}
}

/* note on the main pages */
html[data-theme="dark"] .site-note {
	color: var(--text-muted);
}
