/* ============================================
   Warigami Global Styles — design system v2
   Semantic tokens + light/dark. Legacy paper / text / primary variable names
   are kept as aliases so every existing scoped page style adapts to dark mode.
   ============================================ */

:root {
	color-scheme: dark; /* dark-only site — native controls & scrollbars follow */
	/* ---- brand ---- */
	--gold: #d4af37;
	--gold-deep: #b8941f;
	--gold-soft: #e7cf7e;

	/* ---- semantic surfaces (LIGHT) ---- */
	--bg: #faf8f2;
	--surface: #ffffff;
	--surface-2: #f6f3ec;
	--surface-3: #efeae0;
	--border: #e6dfd1;
	--border-strong: #d6ccb8;

	/* ---- semantic text (LIGHT) ---- */
	--text: #26313c;
	--text-2: #45586b;
	--text-3: #83919b;

	/* ---- accent + status ---- */
	--accent: var(--gold);
	--accent-strong: var(--gold-deep);
	--accent-contrast: #ffffff;
	--accent-red: #e05a44;

	/* ---- chrome ---- */
	--nav-bg: rgba(255, 255, 255, 0.9);
	--footer-bg: #26313c;
	--footer-fg: #cfd7de;
	--footer-head: #ffffff;

	/* ---- shadows ---- */
	--shadow-sm: 0 1px 3px rgba(40, 33, 18, 0.07);
	--shadow-md: 0 5px 18px rgba(40, 33, 18, 0.10);
	--shadow-lg: 0 16px 40px rgba(40, 33, 18, 0.15);

	/* ---- radii ---- */
	--radius-sm: 8px;
	--radius: 12px;
	--radius-lg: 18px;

	/* ---- fold / crease motif ---- */
	--crease: rgba(40, 33, 18, 0.045);

	/* ---- legacy aliases (do not remove — many pages reference these) ---- */
	--primary: var(--gold);
	--primary-dark: var(--gold-deep);
	--text-dark: var(--text);
	--text-medium: var(--text-2);
	--text-light: var(--text-3);
	--paper-white: var(--surface);
	--paper-cream: var(--surface-2);
	--paper-light: var(--surface-3);
	--paper-shadow: var(--border);
}

/* ---- DARK palette (system pref, unless the toggle forced light) ---- */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #16130e;
		--surface: #201c15;
		--surface-2: #26211a;
		--surface-3: #2f2820;
		--border: #3a3327;
		--border-strong: #4b4233;
		--text: #ece4d4;
		--text-2: #c4b9a4;
		--text-3: #948978;
		--gold: #e3bf4a;
		--gold-deep: #eccf6a;
		--gold-soft: #6a5a2c;
		--accent-contrast: #17140d;
		--accent-red: #f0705a;
		--nav-bg: rgba(28, 24, 18, 0.85);
		--footer-bg: #100e0a;
		--footer-fg: #b6ab98;
		--footer-head: #ece4d4;
		--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
		--shadow-md: 0 6px 22px rgba(0, 0, 0, 0.5);
		--shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.6);
		--crease: rgba(255, 255, 255, 0.04);
	}
}

/* ---- DARK palette (toggle forced) ---- */
:root[data-theme="dark"] {
	--bg: #16130e;
	--surface: #201c15;
	--surface-2: #26211a;
	--surface-3: #2f2820;
	--border: #3a3327;
	--border-strong: #4b4233;
	--text: #ece4d4;
	--text-2: #c4b9a4;
	--text-3: #948978;
	--gold: #e3bf4a;
	--gold-deep: #eccf6a;
	--gold-soft: #6a5a2c;
	--accent-contrast: #17140d;
	--accent-red: #f0705a;
	--nav-bg: rgba(28, 24, 18, 0.85);
	--footer-bg: #100e0a;
	--footer-fg: #b6ab98;
	--footer-head: #ece4d4;
	--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
	--shadow-md: 0 6px 22px rgba(0, 0, 0, 0.5);
	--shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.6);
	--crease: rgba(255, 255, 255, 0.04);
}

/* ============================================
   Reset
   ============================================ */
*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	scroll-behavior: smooth;
}

body {
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	background-color: var(--bg);
	color: var(--text);
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition: background-color 0.25s ease, color 0.25s ease;
}

img {
	max-width: 100%;
	height: auto;
	display: block;
}

ul,
ol {
	list-style: none;
}

/* ============================================
   Typography
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: Georgia, 'Times New Roman', Times, serif;
	color: var(--text);
	line-height: 1.18;
	margin-bottom: 0.5em;
	letter-spacing: -0.01em;
}

h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.4rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.9rem); }
h4 { font-size: clamp(1.1rem, 2.5vw, 1.45rem); }
h5 { font-size: clamp(1rem, 2vw, 1.2rem); }
h6 { font-size: clamp(0.9rem, 1.5vw, 1.05rem); }

p { margin-bottom: 1em; }

/* ============================================
   Links
   ============================================ */
a {
	color: var(--accent-strong);
	text-decoration: none;
	transition: color 0.2s ease;
}
a:hover {
	color: var(--accent);
	text-decoration: underline;
}

/* Visible keyboard focus ring (mouse clicks stay clean via :focus-visible) */
:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: 4px;
}

/* Honour reduced-motion: cut transitions, animations, and smooth scroll */
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
	}
}

/* ============================================
   Container + section rhythm
   ============================================ */
.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 1.5rem;
	width: 100%;
}
.container-tight { max-width: 900px; }

.section { padding: 4rem 0; }
.section-alt { background-color: var(--surface-2); }

/* Eyebrow / kicker label */
.eyebrow {
	display: inline-block;
	font-family: 'Segoe UI', Tahoma, sans-serif;
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	color: var(--accent-strong);
	margin-bottom: 0.6rem;
}

/* Section header block */
.section-head { text-align: center; max-width: 640px; margin: 0 auto 2.5rem; }
.section-head p { color: var(--text-3); font-size: 1.08rem; margin: 0.35rem 0 0; }

.section-subtitle { color: var(--text-3); max-width: 640px; margin: 0 auto 2.5rem; font-size: 1.08rem; }

/* ============================================
   Buttons
   ============================================ */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.7rem 1.6rem;
	border: 2px solid transparent;
	border-radius: 999px;
	font-size: 0.98rem;
	font-weight: 600;
	cursor: pointer;
	transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
	text-decoration: none;
	line-height: 1.4;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
	background-color: var(--accent);
	color: var(--accent-contrast);
	border-color: var(--accent);
	box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
	background-color: var(--accent-strong);
	border-color: var(--accent-strong);
	color: var(--accent-contrast);
	box-shadow: var(--shadow-md);
}
.btn-secondary {
	background-color: transparent;
	color: var(--accent-strong);
	border-color: var(--accent-strong);
}
.btn-secondary:hover {
	background-color: var(--accent);
	color: var(--accent-contrast);
	border-color: var(--accent);
}
.btn-outline {
	background-color: transparent;
	color: var(--text);
	border-color: var(--border-strong);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ============================================
   Cards
   ============================================ */
.card {
	background-color: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
	padding: 1.5rem;
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover {
	transform: translateY(-4px);
	box-shadow: var(--shadow-md);
	border-color: var(--border-strong);
}

/* ============================================
   Grid Utilities
   ============================================ */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
	.grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
	.grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================
   Utility
   ============================================ */
.sr-only {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
.text-center { text-align: center; }

/* Small pill badge */
.badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.12rem 0.55rem;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	background: var(--surface-3);
	color: var(--text-2);
	border: 1px solid var(--border);
}
.badge-gold { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--accent-strong); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }

/* ============================================
   Page content offset for fixed navbar
   ============================================ */
.page-content {
	min-height: calc(100vh - 70px);
	padding-top: 70px;
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
	position: fixed;
	top: 0; left: 0; right: 0;
	height: 70px;
	background: var(--nav-bg);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	box-shadow: var(--shadow-sm);
	border-bottom: 1px solid var(--border);
	z-index: 1000;
}
.navbar-inner { display: flex; align-items: center; height: 100%; gap: 2rem; }
.navbar-logo { flex-shrink: 0; }
.navbar-logo img { height: 46px; width: auto; }
.navbar-links { display: flex; align-items: center; gap: 1.4rem; margin-left: auto; }
.nav-link {
	font-weight: 500; color: var(--text-2); text-decoration: none;
	padding: 0.25rem 0; border-bottom: 2px solid transparent;
	transition: color 0.2s ease, border-color 0.2s ease;
}
.nav-link:hover { color: var(--accent-strong); text-decoration: none; }
.nav-link.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.nav-search {
	display: flex; align-items: center; background: var(--surface-2);
	border-radius: 999px; overflow: hidden; border: 1px solid var(--border);
	transition: border-color 0.2s ease;
}
.nav-search:focus-within { border-color: var(--accent); }
.nav-search input {
	border: none; background: transparent; padding: 0.4rem 0.85rem;
	font-size: 0.875rem; color: var(--text); width: 150px; outline: none;
}
.nav-search input::placeholder { color: var(--text-3); }
.search-btn {
	background: none; border: none; padding: 0.4rem 0.65rem; cursor: pointer;
	color: var(--text-3); display: flex; align-items: center;
	transition: color 0.2s ease;
}
.search-btn:hover { color: var(--accent-strong); }

.nav-actions { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

/* Back-to-top button */
.back-to-top {
	position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 900;
	width: 44px; height: 44px; border-radius: 999px;
	display: inline-flex; align-items: center; justify-content: center;
	background: var(--accent); color: var(--accent-contrast);
	border: none; cursor: pointer; box-shadow: var(--shadow-md);
	opacity: 0; visibility: hidden; transform: translateY(10px);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease, background 0.2s ease;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--accent-strong); }
@media (max-width: 600px) { .back-to-top { bottom: 1rem; right: 1rem; width: 40px; height: 40px; } }

.hamburger {
	display: none; flex-direction: column; justify-content: center; gap: 5px;
	background: none; border: none; cursor: pointer; padding: 0.5rem;
}
.hamburger span {
	display: block; width: 24px; height: 2px; background: var(--text);
	border-radius: 2px; transition: transform 0.3s ease, opacity 0.3s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
@media (max-width: 860px) {
	.hamburger { display: flex; }
	.nav-actions { margin-left: auto; }
	.navbar-links {
		display: none; position: absolute; top: 70px; left: 0; right: 0;
		flex-direction: column; align-items: flex-start; background: var(--surface);
		backdrop-filter: blur(12px); padding: 1rem 1.5rem;
		box-shadow: var(--shadow-md); gap: 0.75rem; border-bottom: 1px solid var(--border);
	}
	.navbar-links.open { display: flex; }
	.nav-link { padding: 0.5rem 0; font-size: 1.1rem; }
	.nav-search { width: 100%; }
	.nav-search input { width: 100%; }
}

/* ============================================
   Footer
   ============================================ */
.footer {
	background-color: var(--footer-bg); color: var(--footer-fg);
	border-top: 3px solid var(--accent); margin-top: 4rem;
}
.footer-main { padding: 3rem 1.5rem 2rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; }
.footer-brand h3 {
	font-family: Georgia, "Times New Roman", Times, serif;
	color: var(--accent); margin-bottom: 0.75rem; font-size: 1.5rem;
}
.footer-brand p { color: var(--footer-fg); opacity: 0.85; font-size: 0.95rem; line-height: 1.6; max-width: 280px; }
.footer-col h4 {
	font-family: Georgia, "Times New Roman", Times, serif;
	color: var(--footer-head); margin-bottom: 1rem; font-size: 1.1rem;
}
.footer-col ul { display: flex; flex-direction: column; gap: 0.5rem; list-style: none; padding: 0; margin: 0; }
.footer-col a { color: var(--footer-fg); opacity: 0.82; font-size: 0.9rem; transition: color 0.2s ease, opacity 0.2s ease; }
.footer-col a:hover { color: var(--accent); opacity: 1; text-decoration: none; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, 0.1); padding: 1rem 0; text-align: center; }
.footer-bottom p { color: var(--footer-fg); opacity: 0.7; font-size: 0.85rem; margin: 0; }
@media (max-width: 768px) {
	.footer-grid { grid-template-columns: 1fr 1fr; }
	.footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
	.footer-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Wiki
   ============================================ */
.wiki-categories {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 1.5rem; margin: 2rem 0;
}
.wiki-category-card {
	position: relative; display: block; padding: 1.5rem; background: var(--surface);
	border: 1px solid var(--border); border-radius: var(--radius);
	text-decoration: none; color: inherit; overflow: hidden;
	transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.wiki-category-card::before {
	content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
	background: var(--accent); opacity: 0; transition: opacity 0.15s ease;
}
.wiki-category-card:hover {
	transform: translateY(-3px); box-shadow: var(--shadow-md);
	border-color: var(--border-strong); text-decoration: none;
}
.wiki-category-card:hover::before { opacity: 1; }
.wiki-category-icon { font-size: 1.75rem; display: block; margin-bottom: 0.5rem; }
.wiki-category-card h3 { color: var(--accent-strong); margin: 0 0 0.5rem; font-size: 1.25rem; }
.wiki-category-card p { color: var(--text-2); font-size: 0.95rem; margin: 0 0 0.75rem; }
.wiki-category-count { font-size: 0.8rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }

.wiki-page-list {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 1rem; margin: 1.5rem 0; align-items: start;
}
.wiki-page-card {
	display: block; padding: 1.25rem; background: var(--surface);
	border: 1px solid var(--border); border-radius: var(--radius-sm);
	text-decoration: none; color: inherit;
	transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.wiki-page-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-sm); text-decoration: none; }
.wiki-page-card .icon { font-size: 1.25rem; margin-right: 0.5rem; }
.wiki-page-card h4 { display: inline; color: var(--accent-strong); margin: 0; font-size: 1.05rem; }
.wiki-page-card .excerpt { color: var(--text-2); font-size: 0.9rem; margin: 0.5rem 0 0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.wiki-breadcrumb { font-size: 0.875rem; color: var(--text-3); margin-bottom: 1rem; }
.wiki-breadcrumb a { color: var(--text-2); }
.wiki-breadcrumb a:hover { color: var(--accent-strong); }

.wiki-prose { max-width: 760px; }
.wiki-prose h1 { font-size: 2.25rem; color: var(--accent-strong); margin-bottom: 1rem; }
.wiki-prose h2 { position: relative; font-size: 1.6rem; color: var(--accent-strong); margin: 2.2rem 0 0.75rem; padding-bottom: 0.3rem; border-bottom: 2px solid var(--border); scroll-margin-top: 90px; }
.wiki-prose h3 { position: relative; font-size: 1.25rem; color: var(--accent-strong); margin: 1.5rem 0 0.5rem; scroll-margin-top: 90px; }
.heading-anchor { opacity: 0; margin-left: 0.4rem; color: var(--text-3); font-weight: 400; text-decoration: none; transition: opacity 0.15s ease, color 0.15s ease; }
.wiki-prose h2:hover .heading-anchor, .wiki-prose h3:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--accent); text-decoration: none; }
.wiki-prose p { line-height: 1.78; margin: 0.75rem 0; color: var(--text); }
.wiki-prose ul, .wiki-prose ol { margin: 0.75rem 0 0.75rem 1.5rem; line-height: 1.7; }
.wiki-prose ul { list-style: disc; }
.wiki-prose ol { list-style: decimal; }
.wiki-prose li { margin: 0.3rem 0; }
.wiki-prose a { text-decoration: underline; text-underline-offset: 2px; }
.wiki-prose strong { color: var(--text); }
.wiki-prose code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.9em; border: 1px solid var(--border); }
.wiki-prose pre { background: var(--surface-2); padding: 1rem; border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border); }
.wiki-prose pre code { background: none; border: none; padding: 0; }
.wiki-prose table {
	width: 100%; border-collapse: collapse; margin: 1.25rem 0;
	font-size: 0.95rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
}
.wiki-prose th, .wiki-prose td {
	text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border);
}
.wiki-prose th { background: var(--surface-2); color: var(--accent-strong); font-weight: 700; }
.wiki-prose tr:last-child td { border-bottom: none; }
.wiki-prose blockquote {
	border-left: 3px solid var(--accent); padding: 0.5rem 1rem; margin: 1rem 0;
	background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
	color: var(--text-2); font-style: italic;
}

.wiki-page-footer {
	margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
	display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;
	font-size: 0.875rem; color: var(--text-3);
}
