/* ---------------------------------------------------------------------------
   site.css — design tokens and the shared shell (header, nav, footer, prose).
   Calculator-specific styling lives in calculator.css.

   Theme: "Deep Mine". Dark by default because that is where the gemstones are.
   Light mode is a true inverse, not an afterthought. The five gem types carry
   their own accent colour so the calculator reads as five blocks, not a wall.

   Every foreground/background pair here clears WCAG AA on its own surface;
   see tools/contrast-check in the commit that introduced this file.
   --------------------------------------------------------------------------- */

:root {
	color-scheme: dark;

	--surface-0: #0e1014;
	--surface-1: #171a21;
	--surface-2: #1f232c;
	--border:    #2b313c;
	--border-hi: #646f7e;

	--text:       #e8ebf0;
	--text-soft:  #a8b0bd;
	--text-faint: #7b8493;

	--accent:     #ffb020;
	--accent-ink: #0e1014;
	--accent-dim: #3a2a08;

	--gem-topaz:    #ffc043;
	--gem-emerald:  #4ade80;
	--gem-sapphire: #60a5fa;
	--gem-ruby:     #fb7185;
	--gem-diamond:  #67e8f9;

	--danger: #fb7185;

	/* type */
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	--step--1: 0.833rem;
	--step-0:  1rem;
	--step-1:  1.2rem;
	--step-2:  1.44rem;
	--step-3:  1.728rem;
	--step-4:  2.074rem;
	--display: clamp(2.5rem, 1.8rem + 3.5vw, 4rem);

	/* space */
	--s1: 0.25rem; --s2: 0.5rem;  --s3: 0.75rem; --s4: 1rem;
	--s5: 1.5rem;  --s6: 2rem;    --s7: 3rem;    --s8: 4rem;

	/* shape */
	--r0: 0; --r1: 4px; --r2: 8px; --r3: 12px; --r-pill: 999px;

	--shadow-1: 0 1px 2px rgb(0 0 0 / 0.30);
	--shadow-2: 0 4px 12px rgb(0 0 0 / 0.35);
	--glow: 0 0 0 1px var(--accent), 0 0 28px -8px var(--accent);

	--wrap: 72rem;
	--prose: 42rem;
	--tap: 2.75rem;
}

/* Light mode: follows the system unless the reader has explicitly chosen dark. */
@media (prefers-color-scheme: light) {
	:root:not([data-theme="dark"]) {
		color-scheme: light;
		--surface-0: #ffffff;
		--surface-1: #f7f8fa;
		--surface-2: #eef0f4;
		--border:    #dde1e8;
		--border-hi: #7d8797;
		--text:       #14171c;
		--text-soft:  #4c535e;
		--text-faint: #6b7380;
		--accent:     #a84c08;
		--accent-ink: #ffffff;
		--accent-dim: #fdf2e0;
		--gem-topaz:    #a16207;
		--gem-emerald:  #15803d;
		--gem-sapphire: #1d4ed8;
		--gem-ruby:     #be123c;
		--gem-diamond:  #0e7490;
		--danger: #be123c;
		--shadow-1: 0 1px 2px rgb(16 20 28 / 0.06);
		--shadow-2: 0 4px 14px rgb(16 20 28 / 0.10);
	}
}

/* Explicit choice always wins over the system setting. */
:root[data-theme="light"] {
	color-scheme: light;
	--surface-0: #ffffff;
	--surface-1: #f7f8fa;
	--surface-2: #eef0f4;
	--border:    #dde1e8;
	--border-hi: #7d8797;
	--text:       #14171c;
	--text-soft:  #4c535e;
	--text-faint: #6b7380;
	--accent:     #a84c08;
	--accent-ink: #ffffff;
	--accent-dim: #fdf2e0;
	--gem-topaz:    #a16207;
	--gem-emerald:  #15803d;
	--gem-sapphire: #1d4ed8;
	--gem-ruby:     #be123c;
	--gem-diamond:  #0e7490;
	--danger: #be123c;
	--shadow-1: 0 1px 2px rgb(16 20 28 / 0.06);
	--shadow-2: 0 4px 14px rgb(16 20 28 / 0.10);
}

/* --- base --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--surface-0);
	color: var(--text);
	font-family: var(--font);
	font-size: var(--step-0);
	line-height: 1.65;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	overflow-x: clip;             /* clips without creating a scroll container,
	                                 which would break the sticky bars */
}

main { flex: 1 0 auto; }

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

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { text-decoration: none; }

:focus-visible {
	outline: 3px solid var(--accent);
	outline-offset: 2px;
	border-radius: var(--r1);
}

.num { font-variant-numeric: tabular-nums; }

.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;
}

.wrap {
	width: 100%;
	max-width: var(--wrap);
	margin-inline: auto;
	padding-inline: var(--s4);
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	background: var(--accent);
	color: var(--accent-ink);
	padding: var(--s3) var(--s4);
	font-weight: 700;
	text-decoration: none;
}
.skip-link:focus { left: 0; }

/* --- header ------------------------------------------------------------- */

.site-header {
	background: var(--surface-1);
	border-bottom: 1px solid var(--border);
}

.site-header__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s2) var(--s5);
	padding-block: var(--s3);
}

.brand {
	display: flex;
	align-items: center;
	min-height: var(--tap);
	gap: var(--s3);
	color: var(--text);
	text-decoration: none;
	line-height: 1.2;
	font-size: var(--step--1);
	margin-right: auto;
}
.brand__mark { width: 1.75rem; height: 1.75rem; image-rendering: pixelated; }
.brand__text { color: var(--text-faint); }
.brand__text strong {
	display: block;
	color: var(--text);
	font-size: var(--step-0);
	letter-spacing: -0.01em;
}

.site-header__tools {
	display: flex;
	align-items: center;
	gap: var(--s2);
}

.site-nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s1);
	list-style: none;
	margin: 0;
	padding: 0;
}
.site-nav a {
	display: flex;
	align-items: center;
	min-height: var(--tap);
	padding-inline: var(--s3);
	color: var(--text-soft);
	text-decoration: none;
	border-radius: var(--r1);
	font-weight: 500;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] {
	color: var(--accent);
	font-weight: 700;
	box-shadow: inset 0 -2px 0 var(--accent);
}

.theme-btn {
	min-width: var(--tap);
	min-height: var(--tap);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--s2);
	background: var(--surface-2);
	color: var(--text-soft);
	border: 1px solid var(--border);
	border-radius: var(--r1);
	cursor: pointer;
	font: inherit;
	font-size: var(--step--1);
	padding-inline: var(--s3);
}
.theme-btn:hover { color: var(--text); border-color: var(--border-hi); }
.theme-btn .theme-btn__dark  { display: none; }
.theme-btn .theme-btn__light { display: inline; }
@media (prefers-color-scheme: light) {
	:root:not([data-theme="dark"]) .theme-btn__dark  { display: inline; }
	:root:not([data-theme="dark"]) .theme-btn__light { display: none; }
}
:root[data-theme="light"] .theme-btn__dark  { display: inline; }
:root[data-theme="light"] .theme-btn__light { display: none; }

/* --- headings and prose -------------------------------------------------- */

.page-head { padding-block: var(--s6) var(--s4); }

.page-title {
	font-size: var(--step-4);
	line-height: 1.15;
	letter-spacing: -0.02em;
	margin: 0 0 var(--s3);
}

.lede {
	max-width: var(--prose);
	margin: 0 0 var(--s3);
	color: var(--text-soft);
	font-size: var(--step-1);
	line-height: 1.55;
}
.lede--small { font-size: var(--step-0); }

.prose {
	max-width: var(--prose);
	margin-inline: auto;
	padding-block: var(--s6) var(--s8);
}
.prose h1 {
	font-size: var(--step-4);
	line-height: 1.15;
	letter-spacing: -0.02em;
	margin: 0 0 var(--s4);
}
.prose h2 {
	font-size: var(--step-2);
	line-height: 1.25;
	margin: var(--s7) 0 var(--s3);
	padding-top: var(--s4);
	border-top: 1px solid var(--border);
}
.prose h3 { font-size: var(--step-1); margin: var(--s5) 0 var(--s2); }
.prose p, .prose ul, .prose ol { margin: 0 0 var(--s4); }
.prose li { margin-bottom: var(--s2); }
.prose code {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--r1);
	padding: 0.1em 0.35em;
	font-family: var(--font-mono);
	font-size: 0.9em;
}

.meta { color: var(--text-faint); font-size: var(--step--1); }

.callout {
	background: var(--surface-1);
	border: 1px solid var(--border);
	border-left: 3px solid var(--accent);
	border-radius: 0 var(--r2) var(--r2) 0;
	padding: var(--s4);
	margin: 0 0 var(--s5);
}
.callout p:last-child { margin-bottom: 0; }

/* --- forms and buttons --------------------------------------------------- */

.contact-form { margin: var(--s5) 0 var(--s6); }

.field { margin-bottom: var(--s4); }
.field label { display: block; font-weight: 600; margin-bottom: var(--s2); }
.field input, .field select, .field textarea {
	width: 100%;
	min-height: var(--tap);
	padding: var(--s2) var(--s3);
	font: inherit;
	color: var(--text);
	background: var(--surface-2);
	border: 1px solid var(--border-hi);
	border-radius: var(--r1);
}
.field textarea { min-height: 9rem; resize: vertical; }
.field__hint { margin: var(--s2) 0 0; font-size: var(--step--1); color: var(--text-faint); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--s2);
	min-height: var(--tap);
	padding-inline: var(--s5);
	font: inherit;
	font-weight: 600;
	border: 1px solid var(--border-hi);
	border-radius: var(--r1);
	background: var(--surface-2);
	color: var(--text);
	cursor: pointer;
	text-decoration: none;
}
.button:hover { border-color: var(--accent); color: var(--text); }
.button--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-ink);
}
.button--primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.button.is-flashing { border-color: var(--accent); color: var(--accent); }
.button--primary.is-flashing { color: var(--accent-ink); }

/* --- footer -------------------------------------------------------------- */

.site-footer {
	flex-shrink: 0;
	margin-top: var(--s8);
	background: var(--surface-1);
	border-top: 1px solid var(--border);
	padding-block: var(--s5) var(--s6);
	font-size: var(--step--1);
	color: var(--text-soft);
}
.footer-nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s1) var(--s2);
	list-style: none;
	margin: 0 0 var(--s3);
	padding: 0;
}
.footer-nav a {
	display: flex;
	align-items: center;
	min-height: var(--tap);
	padding-inline: var(--s3);
	color: var(--text-soft);
	border-radius: var(--r1);
	text-decoration: none;
}
.footer-nav a:hover { background: var(--surface-2); color: var(--text); }
.footer-note { margin: 0 0 var(--s2); max-width: 48rem; }
.footer-note--fine { color: var(--text-faint); }
.footer-note--fine a { color: inherit; }

/* At 320-360px the nav wrapped to two lines and stranded the theme button
   beside it. Trimming the link padding keeps all three on one row. */
@media (max-width: 26rem) {
	/* measured at 320px: links 232px + gaps + a 44px button overran the 288px
	   row by 4px, which wrapped the nav onto a second line */
	.site-nav a { padding-inline: var(--s2); }
	.site-nav ul { gap: 0; }
	.site-header__tools { gap: var(--s1); }
	.site-header__inner { gap: var(--s1) var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
