/* ============================================================
 * ProTilo · Static Legal Pages — Petrol & Sand SSOT
 * Mirrors apps/mobile/src/theme/tokens.ts + Svelte src/app.css
 * Driven by html.dark class (set by legal-theme.js)
 * ============================================================ */

:root {
	/* Surfaces — LIGHT (default) */
	--bg-primary: #f1ece1;
	--bg-secondary: #f5f1e8;
	--bg-tertiary: #e6ddcb;
	--bg-card: #ffffff;
	--bg-elevated: #ffffff;

	/* Text */
	--text-primary: #1d3030;
	--text-secondary: #4a6363;
	--text-tertiary: #7a8c8c;
	--text-inverse: #f1ece1;

	/* Accents — deeper in light */
	--accent-primary: #1a6b6b;
	--accent-deep: #0d4848;
	--accent-secondary: #c98a3a;
	--accent-info: #2a8a8a;

	/* Borders */
	--border-primary: #d8cdb8;
	--border-secondary: #e6ddcb;

	/* Fonts */
	--font-sans: 'Urbanist', system-ui, -apple-system, sans-serif;
	--font-serif: 'Fraunces', Georgia, serif;
}

html.dark {
	/* Surfaces — DARK */
	--bg-primary: #0f1f1f;
	--bg-secondary: #142727;
	--bg-tertiary: #1a3232;
	--bg-card: #16292a;
	--bg-elevated: #1d3535;

	/* Text */
	--text-primary: #f1ece1;
	--text-secondary: #b3c4c4;
	--text-tertiary: #7d9494;
	--text-inverse: #0f1f1f;

	/* Accents — vibrant in dark */
	--accent-primary: #3aacac;
	--accent-deep: #1a6b6b;
	--accent-secondary: #e0a663;
	--accent-info: #7fc4c4;

	/* Borders */
	--border-primary: rgba(241, 236, 225, 0.12);
	--border-secondary: rgba(241, 236, 225, 0.06);
}

* {
	box-sizing: border-box;
}

html,
body {
	background: var(--bg-primary);
	color: var(--text-primary);
	transition: background-color 0.3s ease, color 0.3s ease;
}

body {
	font-family: var(--font-sans);
	max-width: 760px;
	margin: 0 auto;
	padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 24px) 64px;
	line-height: 1.7;
	font-size: 16px;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* ─── Headings (Fraunces serif) ─── */
h1,
h2,
h3,
h4 {
	font-family: var(--font-serif);
	font-weight: 400;
	color: var(--text-primary);
	line-height: 1.2;
}
h1 {
	font-size: clamp(1.9rem, 4.5vw, 2.6rem);
	margin: 0 0 0.6em;
	padding-bottom: 0.5em;
	border-bottom: 2px solid var(--accent-secondary);
}
h2 {
	font-size: clamp(1.4rem, 3vw, 1.8rem);
	color: var(--accent-secondary);
	margin: 2em 0 0.5em;
}
h3 {
	font-size: 1.2rem;
	margin: 1.5em 0 0.4em;
}

/* ─── Body text ─── */
p,
li {
	color: var(--text-secondary);
	margin: 0 0 0.85em;
}
strong {
	color: var(--text-primary);
	font-weight: 600;
}
em {
	color: var(--accent-secondary);
}

/* ─── Links ─── */
a {
	color: var(--accent-primary);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
	transition: color 0.2s ease;
}
a:hover {
	color: var(--accent-info);
}

/* ─── Inline code ─── */
code {
	background: var(--bg-tertiary);
	color: var(--accent-primary);
	padding: 0.15rem 0.45rem;
	border-radius: 6px;
	font-size: 0.9em;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ─── Horizontal rule ─── */
hr {
	border: 0;
	border-top: 1px solid var(--border-secondary);
	margin: 2.5em 0;
}

/* ─── Tables ─── */
table {
	border-collapse: collapse;
	width: 100%;
	margin: 1.2em 0;
	font-size: 0.95em;
}
th,
td {
	text-align: left;
	padding: 10px 14px;
	border-bottom: 1px solid var(--border-secondary);
	vertical-align: top;
}
th {
	background: var(--bg-tertiary);
	color: var(--text-primary);
	font-weight: 600;
}

/* ─── Nav (top of every legal page) ─── */
.nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1.2rem;
	margin-bottom: 2.5em;
	padding: 14px 18px;
	background: var(--bg-card);
	border: 1px solid var(--border-primary);
	border-radius: 14px;
	box-shadow: 0 2px 12px -4px rgba(0, 0, 0, 0.06);
}
.nav a {
	font-weight: 500;
	text-decoration: none;
	color: var(--text-secondary);
	padding: 4px 0;
}
.nav a:hover {
	color: var(--accent-primary);
}

/* ─── Callout boxes ─── */
.callout {
	background: var(--bg-card);
	border: 1px solid var(--border-primary);
	border-left: 4px solid var(--accent-secondary);
	padding: 14px 20px;
	border-radius: 8px;
	margin: 1.2em 0;
}
.callout strong {
	color: var(--accent-secondary);
}
.callout-future {
	background: var(--bg-card);
	border: 1px solid var(--border-primary);
	border-left: 4px solid var(--accent-primary);
	padding: 14px 20px;
	border-radius: 8px;
	margin: 1.2em 0;
}

/* ─── Table of contents ─── */
.toc {
	background: var(--bg-card);
	border: 1px solid var(--border-primary);
	padding: 16px 22px;
	border-radius: 10px;
	margin-bottom: 2.5em;
	box-shadow: 0 2px 12px -4px rgba(0, 0, 0, 0.05);
}
.toc strong {
	font-family: var(--font-serif);
	font-size: 1.05rem;
	display: block;
	margin-bottom: 6px;
}
.toc ol {
	margin: 8px 0 0;
	padding-left: 24px;
}
.toc li {
	margin: 4px 0;
}
.toc a {
	text-decoration: none;
}
.toc a:hover {
	text-decoration: underline;
}

/* ─── Footer ─── */
footer {
	margin-top: 4em;
	padding-top: 1.5em;
	border-top: 1px solid var(--border-secondary);
	color: var(--text-tertiary);
	font-size: 0.9em;
	text-align: center;
}
footer a {
	color: var(--text-tertiary);
}

/* ─── Theme toggle button (injected by legal-theme.js) ─── */
.theme-toggle {
	position: fixed;
	top: clamp(14px, 3vh, 22px);
	right: clamp(14px, 4vw, 24px);
	z-index: 60;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 1px solid var(--border-primary);
	background: var(--bg-card);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.25s ease;
	box-shadow: 0 2px 12px -2px rgba(0, 0, 0, 0.08);
}
.theme-toggle:hover {
	border-color: var(--accent-primary);
	transform: scale(1.05);
}
.theme-toggle svg {
	width: 18px;
	height: 18px;
	stroke: var(--text-secondary);
	fill: none;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}
