/*
 * Authors: Nick, GitHub Copilot
 * Created: 2026-08-30
 * Last Modified: 2026-08-30
 */

:root {
	color-scheme: light;
	--forest: #183a33;
	--forest-deep: #102822;
	--paper: #f4f6f1;
	--white: #fcfdf9;
	--on-dark: #fcfdf9;
	--ink: #18201e;
	--muted: #66736f;
	--line: #cbd3cf;
	--heading: #183a33;
	--row-hover: #eef2ed;
	--map-grid: rgba(24, 58, 51, 0.08);
	--map-label: rgba(24, 58, 51, 0.45);
	--rust: #c45a35;
	--gold: #d5a63f;
	--sage: #b9d0c4;
	--content: 1240px;
	--gutter: clamp(1.25rem, 4vw, 4.5rem);
	--sans: "DM Sans", sans-serif;
	--serif: "Newsreader", Georgia, serif;
	--mono: "DM Mono", monospace;
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--paper: #111a17;
	--white: #19241f;
	--ink: #edf3ef;
	--muted: #aebbb5;
	--line: #425149;
	--heading: #c7d9cf;
	--row-hover: #23312b;
	--map-grid: rgba(199, 217, 207, 0.1);
	--map-label: rgba(199, 217, 207, 0.55);
	--rust: #e47b57;
	--gold: #e2b84f;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.55; }
button, input, select { font: inherit; }
a { color: inherit; }
.skip-link { position: fixed; z-index: 99; top: 0.5rem; left: 0.5rem; padding: 0.6rem 0.9rem; background: var(--white); transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.project-nav {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	height: 4.5rem;
	align-items: center;
	justify-content: space-between;
	padding: 0 var(--gutter);
	border-bottom: 1px solid rgba(244, 246, 241, 0.24);
	background: rgba(24, 58, 51, 0.96);
	color: var(--on-dark);
	backdrop-filter: blur(12px);
}
.project-nav a, .project-nav p { margin: 0; font-family: var(--mono); font-size: 0.7rem; text-decoration: none; text-transform: uppercase; }
.back-link { display: inline-flex; gap: 0.65rem; align-items: center; }
.project-nav a:hover { color: var(--gold); }
.project-actions { display: flex; align-items: center; gap: 1.25rem; }
.theme-toggle { position: relative; display: grid; width: 2.35rem; height: 2.35rem; padding: 0; place-items: center; border: 1px solid rgba(244, 246, 241, 0.35); border-radius: 50%; background: transparent; color: var(--on-dark); cursor: pointer; }
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: var(--gold); color: var(--gold); }
.theme-icon { grid-area: 1 / 1; font-size: 1.05rem; line-height: 1; transition: opacity 160ms ease, transform 160ms ease; }
.theme-icon-moon, [data-theme="dark"] .theme-icon-sun { opacity: 0; transform: rotate(-30deg) scale(0.6); }
[data-theme="dark"] .theme-icon-moon { opacity: 1; transform: none; }

.project-hero {
	display: grid;
	min-height: calc(92vh - 4.5rem);
	grid-template-columns: 1.35fr 0.65fr;
	gap: clamp(3rem, 8vw, 9rem);
	align-items: end;
	padding: clamp(5rem, 10vw, 9rem) var(--gutter) clamp(4rem, 8vw, 7rem);
	background:
		linear-gradient(rgba(244, 246, 241, 0.055) 1px, transparent 1px),
		linear-gradient(90deg, rgba(244, 246, 241, 0.055) 1px, transparent 1px),
		var(--forest);
	background-size: 32px 32px;
	color: var(--on-dark);
}
.hero-copy { max-width: 850px; justify-self: end; }
.eyebrow { margin: 0 0 1.4rem; color: var(--rust); font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; }
.project-hero .eyebrow { color: var(--gold); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0; }
h1 { margin: 0; font-size: clamp(4rem, 9vw, 9rem); line-height: 0.78; }
h1 em { color: var(--gold); font-style: normal; }
.lede { max-width: 680px; margin: 3rem 0 0; color: #d9e1dd; font-size: clamp(1.1rem, 2vw, 1.45rem); }
.system-map { max-width: 370px; padding-bottom: 0.5rem; }
.system-map p { display: grid; grid-template-columns: 3rem 1fr; margin: 0; padding: 1rem 0; border-bottom: 1px solid rgba(244, 246, 241, 0.25); font-size: 0.9rem; }
.system-map span { color: var(--gold); font-family: var(--mono); font-size: 0.68rem; }

.snapshot { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--forest); background: var(--white); }
.snapshot p { display: flex; min-height: 9rem; flex-direction: column; justify-content: center; margin: 0; padding: 1.5rem var(--gutter); border-right: 1px solid var(--line); }
.snapshot p:last-child { border: 0; }
.snapshot strong { color: var(--heading); font-family: var(--serif); font-size: clamp(2.2rem, 4vw, 4rem); line-height: 1; }
.snapshot span { margin-top: 0.5rem; color: var(--muted); font-family: var(--mono); font-size: 0.65rem; text-transform: uppercase; }

.deal-board, .underwriter, .method { padding: clamp(5rem, 10vw, 9rem) var(--gutter); }
.section-heading { display: grid; max-width: var(--content); grid-template-columns: 0.5fr 1fr 0.75fr; gap: clamp(2rem, 5vw, 5rem); margin: 0 auto 4rem; align-items: start; }
h2 { margin: 0; color: var(--heading); font-size: clamp(2.7rem, 5vw, 5rem); line-height: 0.98; }
.section-heading > p:last-child { margin: 0; color: var(--muted); }

.board-controls { display: grid; max-width: var(--content); grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0 auto 1px; background: var(--line); border: 1px solid var(--line); }
.board-controls label { display: flex; min-width: 0; flex-direction: column; gap: 0.75rem; padding: 1rem; background: var(--white); font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; }
.board-controls output { color: var(--rust); }
select, input[type="number"] { width: 100%; padding: 0.6rem; border: 1px solid var(--line); border-radius: 3px; background: var(--white); color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--rust); }

.board-layout { display: grid; max-width: var(--content); grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr); gap: 1px; margin: 0 auto; background: var(--line); border: 1px solid var(--line); }
.board-layout > div { min-width: 0; background: var(--white); }
.map-header, .shortlist-header { display: flex; min-height: 4.5rem; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.map-header h3, .shortlist-header h3 { margin: 0; color: var(--heading); font-size: 1.35rem; }
.map-header p, .shortlist-header p { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; }
.deal-map { position: relative; height: 520px; overflow: hidden; background: var(--paper); }
.deal-map .leaflet-tile { transition: filter 180ms ease; }
[data-theme="dark"] .deal-map .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.78) contrast(0.9); }
.deal-map .leaflet-control-attribution { background: color-mix(in srgb, var(--white) 88%, transparent); color: var(--muted); font-family: var(--mono); font-size: 0.55rem; }
.deal-map .leaflet-control-attribution a { color: var(--rust); }
.deal-map .leaflet-bar { overflow: hidden; border: 1px solid var(--line); border-radius: 3px; box-shadow: none; }
.deal-map .leaflet-bar a { border-color: var(--line); background: var(--white); color: var(--ink); }
.deal-map .leaflet-bar a:hover, .deal-map .leaflet-bar a:focus { background: var(--row-hover); color: var(--rust); }
.deal-marker { display: grid !important; place-items: center; border: 2px solid var(--on-dark); border-radius: 50%; background: var(--rust); color: var(--on-dark); box-shadow: 0 2px 12px rgba(16, 40, 34, 0.35); font-family: var(--mono); font-size: 0.58rem; transition: background 160ms ease, box-shadow 160ms ease; }
.deal-marker.high { background: var(--forest); }
.deal-marker:hover, .deal-marker:focus, .deal-marker.active { z-index: 1000 !important; background: var(--gold); color: var(--forest-deep); box-shadow: 0 0 0 3px var(--forest), 0 3px 14px rgba(16, 40, 34, 0.4); outline: 0; }
.deal-map .leaflet-tooltip { padding: 0.55rem 0.7rem; border: 1px solid var(--gold); border-radius: 3px; background: var(--forest-deep); color: var(--on-dark); box-shadow: 0 0.4rem 1.2rem rgba(16, 40, 34, 0.25); font-family: var(--sans); font-size: 0.75rem; line-height: 1.4; }
.deal-map .leaflet-tooltip::before { border-top-color: var(--gold); }
.map-fallback { display: grid; height: 100%; place-items: center; padding: 2rem; color: var(--muted); text-align: center; }
.map-key { display: flex; flex-wrap: wrap; gap: 1.25rem; padding: 0.8rem 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase; }
.map-key span { display: inline-flex; align-items: center; gap: 0.35rem; }
.map-key i { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--rust); }
.map-key i.high { background: var(--forest); }

.deal-list { max-height: 565px; overflow-y: auto; }
.deal-row { display: grid; width: 100%; grid-template-columns: 2rem 1fr auto; gap: 0.8rem; align-items: start; padding: 1rem 1.25rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.deal-row:hover, .deal-row:focus-visible, .deal-row.active { background: var(--row-hover); outline: 0; }
.deal-rank { color: var(--rust); font-family: var(--mono); font-size: 0.65rem; }
.deal-row strong { display: block; color: var(--heading); font-family: var(--serif); font-size: 1rem; line-height: 1.15; }
.deal-row small { display: block; margin-top: 0.35rem; color: var(--muted); font-family: var(--mono); font-size: 0.59rem; text-transform: uppercase; }
.deal-score { color: var(--heading); font-family: var(--serif); font-size: 1.45rem; }
.empty-state { padding: 2rem; color: var(--muted); }

.term { position: relative; color: inherit; text-decoration: underline dotted currentColor; text-decoration-thickness: 1px; text-underline-offset: 0.2em; cursor: help; }
.term::after { position: fixed; bottom: 1rem; left: 50%; z-index: 50; width: min(22rem, calc(100vw - 2rem)); padding: 0.7rem 0.8rem; border: 1px solid var(--gold); border-radius: 3px; background: var(--forest-deep); color: #f4f6f1; box-shadow: 0 0.5rem 1.5rem rgba(16, 40, 34, 0.25); content: attr(data-tooltip); font-family: var(--sans); font-size: 0.76rem; font-weight: 400; line-height: 1.4; text-align: left; text-transform: none; white-space: normal; opacity: 0; pointer-events: none; transform: translate(-50%, 0.35rem); transition: opacity 140ms ease, transform 140ms ease; visibility: hidden; }
.term:hover::after, .term:focus::after { opacity: 1; transform: translate(-50%, 0); visibility: visible; }
.term:focus { border-radius: 2px; outline: 2px solid var(--gold); outline-offset: 3px; }

.underwriter { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: clamp(3rem, 8vw, 8rem); background: var(--forest-deep); color: var(--on-dark); }
.underwriter-intro { max-width: 520px; justify-self: end; }
.underwriter h2 { color: var(--on-dark); }
.underwriter-intro > p:not(.eyebrow):not(.notice) { color: #c8d3cf; }
.notice { margin-top: 2rem; padding: 1rem; border-left: 4px solid var(--gold); background: rgba(213, 166, 63, 0.1); color: #e9dfc1; font-size: 0.82rem; }
.calculator { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; align-content: start; }
.calculator label { display: flex; flex-direction: column; gap: 0.45rem; color: #c8d3cf; font-family: var(--mono); font-size: 0.65rem; text-transform: uppercase; }
.calculator .wide { grid-column: 1 / -1; }
.calculator select, .calculator input[type="number"] { border-color: #597068; background: #16322c; color: var(--on-dark); }
.calculator input[type="range"] { accent-color: var(--gold); }
.results { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); margin-top: 1rem; border-top: 1px solid #597068; }
.results p { display: flex; flex-direction: column; margin: 0; padding: 1.25rem 1rem; border-right: 1px solid #597068; }
.results p:last-child { border: 0; }
.results span { color: #9eb0aa; font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase; }
.results strong { margin-top: 0.6rem; color: var(--gold); font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.5rem); line-height: 1; }

.method { display: grid; grid-template-columns: 0.75fr 1.25fr; gap: clamp(3rem, 8vw, 8rem); background: var(--white); }
.method > div { max-width: 500px; justify-self: end; }
.method ol { margin: 0; padding: 0; border-top: 1px solid var(--forest); list-style: none; }
.method li { display: grid; grid-template-columns: 6rem 1fr; gap: 1.5rem; padding: 1.5rem 0; border-bottom: 1px solid var(--line); }
.method li span { color: var(--rust); font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; }
.method li p { margin: 0; color: var(--muted); }

footer { display: flex; justify-content: space-between; padding: 1.5rem var(--gutter); background: var(--forest); color: var(--on-dark); font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; }
footer p { margin: 0; }

@media (max-width: 900px) {
	.project-hero, .section-heading, .board-layout, .underwriter, .method { grid-template-columns: 1fr; }
	.hero-copy, .underwriter-intro, .method > div { justify-self: stretch; }
	.snapshot { grid-template-columns: repeat(2, 1fr); }
	.snapshot p:nth-child(2) { border-right: 0; }
	.snapshot p:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
	.results { grid-template-columns: repeat(2, 1fr); }
	.results p:nth-child(2) { border-right: 0; }
	.results p:nth-child(-n + 2) { border-bottom: 1px solid #597068; }
}

@media (max-width: 620px) {
	.project-nav { height: 4rem; }
	.project-nav p { display: none; }
	.project-actions { gap: 0.75rem; }
	.project-actions > a { font-size: 0; }
	.project-actions > a::before { content: "Underwriter ↓"; font-size: 0.68rem; }
	.project-hero { min-height: auto; align-items: start; padding-top: 5rem; }
	.hero-copy { min-width: 0; }
	h1 { font-size: clamp(3rem, 15.5vw, 4.4rem); }
	.board-controls { grid-template-columns: 1fr; }
	.deal-map { height: 390px; }
	.calculator { grid-template-columns: 1fr; }
	.calculator .wide { grid-column: auto; }
	.results { grid-template-columns: 1fr 1fr; }
	.method li { grid-template-columns: 1fr; gap: 0.4rem; }
	footer { flex-direction: column; gap: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	* { transition-duration: 0.01ms !important; }
}
