/*
 * base.css — design tokens, layout scaffolding, header, footer, typography.
 *
 * Original design system for Ledgerwise. No web fonts are loaded: the system
 * stack renders immediately, which removes a render-blocking request and the
 * font-swap layout shift that comes with it. Numbers use tabular figures so
 * columns of currency line up.
 */

/* ---------- tokens ---------- */

:root {
	/* A cool slate ramp for structure, one deep navy for brand, one amber for
	   emphasis. Result colours are deliberately distinct from the brand so a
	   refund never reads as a button. */
	--c-ink: #14212e;
	--c-ink-soft: #43596d;
	--c-ink-faint: #6b8199;
	--c-line: #dde4ec;
	--c-line-strong: #c3cfdc;
	--c-surface: #ffffff;
	--c-canvas: #f5f7fa;
	--c-canvas-alt: #eef2f7;

	--c-brand: #0f3a5f;
	--c-brand-deep: #0a2942;
	--c-brand-tint: #e8f0f7;

	--c-accent: #b26206;
	--c-accent-tint: #fdf3e6;

	--c-positive: #0a6c4d;
	--c-positive-tint: #e6f4ef;
	--c-negative: #a32218;
	--c-negative-tint: #fbeceb;

	--c-focus: #1c6fb8;

	--r-sm: 6px;
	--r-md: 10px;
	--r-lg: 14px;

	--sp-1: 0.25rem;
	--sp-2: 0.5rem;
	--sp-3: 0.75rem;
	--sp-4: 1rem;
	--sp-5: 1.5rem;
	--sp-6: 2rem;
	--sp-7: 3rem;
	--sp-8: 4rem;

	--shadow-sm: 0 1px 2px rgba(20, 33, 46, 0.06), 0 1px 3px rgba(20, 33, 46, 0.04);
	--shadow-md: 0 2px 8px rgba(20, 33, 46, 0.07), 0 8px 24px rgba(20, 33, 46, 0.05);

	--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	--wrap: 1180px;
	--wrap-narrow: 760px;
	--header-h: 62px;
}

/* ---------- reset ---------- */

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

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

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

body {
	margin: 0;
	font-family: var(--font-sans);
	font-size: 1rem;
	line-height: 1.65;
	color: var(--c-ink);
	background: var(--c-canvas);
	-webkit-font-smoothing: antialiased;
}

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

/* ---------- typography ---------- */

h1,
h2,
h3,
h4 {
	margin: 0 0 var(--sp-3);
	line-height: 1.25;
	letter-spacing: -0.015em;
	font-weight: 650;
	color: var(--c-ink);
	text-wrap: balance;
}

h1 {
	font-size: clamp(1.7rem, 1.3rem + 1.9vw, 2.4rem);
}
h2 {
	font-size: clamp(1.3rem, 1.15rem + 0.75vw, 1.6rem);
	margin-top: var(--sp-6);
}
h3 {
	font-size: 1.12rem;
	margin-top: var(--sp-5);
}
h4 {
	font-size: 1rem;
}

p {
	margin: 0 0 var(--sp-4);
	text-wrap: pretty;
}

a {
	color: var(--c-brand);
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}
a:hover {
	color: var(--c-accent);
}

/* A visible focus ring everywhere, on the keyboard path only. */
:focus-visible {
	outline: 3px solid var(--c-focus);
	outline-offset: 2px;
	border-radius: var(--r-sm);
}

ul,
ol {
	margin: 0 0 var(--sp-4);
	padding-left: 1.35rem;
}
li {
	margin-bottom: var(--sp-2);
}

code {
	font-family: var(--font-mono);
	font-size: 0.9em;
	background: var(--c-canvas-alt);
	padding: 0.1em 0.35em;
	border-radius: var(--r-sm);
}

/* ---------- layout ---------- */

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

.wrap-narrow {
	max-width: var(--wrap-narrow);
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	background: var(--c-brand);
	color: #fff;
	padding: var(--sp-3) var(--sp-4);
	z-index: 100;
	border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus {
	left: 0;
	color: #fff;
}

main {
	display: block;
	padding-bottom: var(--sp-8);
}

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

.site-header {
	background: var(--c-surface);
	border-bottom: 1px solid var(--c-line);
	position: sticky;
	top: 0;
	z-index: 50;
}

.header-inner {
	display: flex;
	align-items: center;
	gap: var(--sp-4);
	min-height: var(--header-h);
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	font-weight: 700;
	font-size: 1.1rem;
	letter-spacing: -0.02em;
	color: var(--c-brand-deep);
	text-decoration: none;
	flex-shrink: 0;
}
.brand:hover {
	color: var(--c-brand-deep);
}

/* Wordmark glyph: stacked bars suggesting a ledger, drawn in CSS so there is
   no image request and nothing to shift when it paints. */
.brand-mark {
	width: 26px;
	height: 26px;
	border-radius: 7px;
	background: linear-gradient(150deg, var(--c-brand) 0%, var(--c-brand-deep) 100%);
	position: relative;
	flex-shrink: 0;
}
.brand-mark::before,
.brand-mark::after {
	content: "";
	position: absolute;
	left: 6px;
	height: 2px;
	border-radius: 1px;
	background: rgba(255, 255, 255, 0.9);
}
.brand-mark::before {
	top: 9px;
	width: 14px;
}
.brand-mark::after {
	top: 14px;
	width: 9px;
}

.brand-suffix {
	color: var(--c-accent);
}

.primary-nav {
	margin-left: auto;
}

.nav-list {
	display: flex;
	align-items: center;
	gap: var(--sp-1);
	list-style: none;
	margin: 0;
	padding: 0;
}
.nav-list li {
	margin: 0;
}

.nav-list a {
	display: block;
	padding: 0.5rem 0.7rem;
	border-radius: var(--r-sm);
	font-size: 0.925rem;
	font-weight: 500;
	color: var(--c-ink-soft);
	text-decoration: none;
	white-space: nowrap;
}
.nav-list a:hover {
	background: var(--c-brand-tint);
	color: var(--c-brand-deep);
}
.nav-list a[aria-current="page"] {
	color: var(--c-brand-deep);
	background: var(--c-brand-tint);
	font-weight: 600;
}

.nav-toggle {
	display: none;
	margin-left: auto;
	background: var(--c-surface);
	border: 1px solid var(--c-line-strong);
	border-radius: var(--r-sm);
	padding: 0.55rem 0.7rem;
	font: inherit;
	font-size: 0.9rem;
	color: var(--c-ink);
	cursor: pointer;
	min-height: 44px;
}

@media (max-width: 900px) {
	.nav-toggle {
		display: inline-flex;
		align-items: center;
		gap: 0.4rem;
	}
	.primary-nav {
		display: none;
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		background: var(--c-surface);
		border-bottom: 1px solid var(--c-line);
		box-shadow: var(--shadow-md);
		padding: var(--sp-3) var(--sp-4);
	}
	.primary-nav.is-open {
		display: block;
	}
	.nav-list {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}
	.nav-list a {
		padding: 0.8rem 0.6rem;
		border-radius: var(--r-sm);
		font-size: 1rem;
	}
}

/* ---------- breadcrumbs ---------- */

.breadcrumbs {
	font-size: 0.85rem;
	color: var(--c-ink-faint);
	padding: var(--sp-4) 0 0;
}
.breadcrumbs ol {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}
.breadcrumbs li {
	margin: 0;
	display: flex;
	align-items: center;
	gap: 0.4rem;
}
.breadcrumbs li + li::before {
	content: "›";
	color: var(--c-line-strong);
}
.breadcrumbs a {
	color: var(--c-ink-soft);
	text-decoration: none;
}
.breadcrumbs a:hover {
	text-decoration: underline;
}
.breadcrumbs [aria-current="page"] {
	color: var(--c-ink);
}

/* ---------- generic surfaces ---------- */

.card {
	background: var(--c-surface);
	border: 1px solid var(--c-line);
	border-radius: var(--r-lg);
	padding: var(--sp-5);
	box-shadow: var(--shadow-sm);
}

.prose {
	max-width: 70ch;
}
.prose h2 {
	padding-top: var(--sp-2);
}

/* ---------- buttons ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	min-height: 44px;
	padding: 0.65rem 1.2rem;
	border-radius: var(--r-md);
	border: 1px solid transparent;
	font: inherit;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
	background: var(--c-brand);
	color: #fff;
	border-color: var(--c-brand);
}
.btn-primary:hover {
	background: var(--c-brand-deep);
	border-color: var(--c-brand-deep);
	color: #fff;
}

.btn-secondary {
	background: var(--c-surface);
	color: var(--c-brand-deep);
	border-color: var(--c-line-strong);
}
.btn-secondary:hover {
	background: var(--c-brand-tint);
	border-color: var(--c-brand);
	color: var(--c-brand-deep);
}

.btn-quiet {
	background: transparent;
	color: var(--c-ink-soft);
	border-color: transparent;
	padding: 0.5rem 0.7rem;
	min-height: 40px;
	font-size: 0.875rem;
	font-weight: 500;
}
.btn-quiet:hover {
	background: var(--c-canvas-alt);
	color: var(--c-ink);
}

/* ---------- notices ---------- */

.notice {
	border: 1px solid var(--c-line);
	border-left: 4px solid var(--c-ink-faint);
	border-radius: var(--r-md);
	background: var(--c-surface);
	padding: var(--sp-4);
	font-size: 0.92rem;
	margin-bottom: var(--sp-4);
}
.notice p:last-child {
	margin-bottom: 0;
}
.notice-caution {
	border-left-color: var(--c-accent);
	background: var(--c-accent-tint);
}
.notice-legal {
	border-left-color: var(--c-ink-faint);
	background: var(--c-canvas-alt);
	color: var(--c-ink-soft);
	font-size: 0.875rem;
}

/* ---------- data provenance strip ---------- */

.provenance {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sp-2) var(--sp-4);
	align-items: center;
	font-size: 0.83rem;
	color: var(--c-ink-soft);
	padding: var(--sp-3) 0;
	border-top: 1px solid var(--c-line);
	border-bottom: 1px solid var(--c-line);
	margin-bottom: var(--sp-5);
}
.provenance > * {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
}
.tag {
	display: inline-block;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	padding: 0.18rem 0.45rem;
	border-radius: var(--r-sm);
}
.tag-official {
	background: var(--c-positive-tint);
	color: var(--c-positive);
}
.tag-partial {
	background: var(--c-accent-tint);
	color: var(--c-accent);
}
.tag-year {
	background: var(--c-brand-tint);
	color: var(--c-brand-deep);
}

/* ---------- card grids ---------- */

.grid {
	display: grid;
	gap: var(--sp-4);
	margin-bottom: var(--sp-5);
}
.grid-2 {
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.grid-3 {
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.grid-4 {
	grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.tile {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	background: var(--c-surface);
	border: 1px solid var(--c-line);
	border-radius: var(--r-md);
	padding: var(--sp-4);
	text-decoration: none;
	color: inherit;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover {
	border-color: var(--c-brand);
	box-shadow: var(--shadow-md);
	color: inherit;
}
.tile-title {
	font-weight: 650;
	color: var(--c-brand-deep);
	font-size: 1rem;
	line-height: 1.35;
}
.tile-desc {
	font-size: 0.875rem;
	color: var(--c-ink-soft);
	line-height: 1.5;
}
.tile-meta {
	margin-top: auto;
	padding-top: var(--sp-2);
	font-size: 0.78rem;
	color: var(--c-ink-faint);
}

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

.site-footer {
	background: var(--c-brand-deep);
	color: #c8d6e3;
	padding: var(--sp-7) 0 var(--sp-5);
	font-size: 0.9rem;
}
.site-footer h2 {
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: #ffffff;
	margin: 0 0 var(--sp-3);
}
.site-footer a {
	color: #c8d6e3;
	text-decoration: none;
}
.site-footer a:hover {
	color: #ffffff;
	text-decoration: underline;
}
.footer-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: var(--sp-5);
	margin-bottom: var(--sp-6);
}
.footer-grid ul {
	list-style: none;
	margin: 0;
	padding: 0;
}
.footer-grid li {
	margin-bottom: var(--sp-2);
}
.footer-bottom {
	border-top: 1px solid rgba(255, 255, 255, 0.15);
	padding-top: var(--sp-4);
	font-size: 0.82rem;
	color: #9fb3c8;
}
.footer-bottom p {
	margin-bottom: var(--sp-2);
	max-width: 80ch;
}

/* ---------- ad placeholders ---------- */

/*
 * Ad slots reserve their height up front so a late-loading (or blocked) ad
 * cannot push the calculator around. An empty slot renders as quiet neutral
 * space rather than a broken box.
 */
.ad-slot {
	display: flex;
	align-items: center;
	justify-content: center;
	margin: var(--sp-5) 0;
	border: 1px dashed var(--c-line-strong);
	border-radius: var(--r-md);
	background: var(--c-canvas-alt);
	color: var(--c-ink-faint);
	font-size: 0.75rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	contain: layout;
}
.ad-slot[hidden] {
	display: none;
}

/* ---------- utilities ---------- */

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.lede {
	font-size: 1.08rem;
	color: var(--c-ink-soft);
	max-width: 68ch;
}

.text-muted {
	color: var(--c-ink-soft);
}

.stack > * + * {
	margin-top: var(--sp-4);
}

@media print {
	.site-header,
	.site-footer,
	.ad-slot,
	.no-print {
		display: none !important;
	}
	body {
		background: #fff;
	}
	.card {
		box-shadow: none;
		border-color: #999;
	}
}
