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

/* ══════════════════════════════════════════
   LIGHT THEME (default)
   ══════════════════════════════════════════ */
:root {
	--font-display: 'EB Garamond', Garamond, Georgia, serif;
	--font-mono: 'Courier Prime', 'Courier New', monospace;

	--bg: #ffffff;
	--bg-card: transparent;
	--bg-card-hover: transparent;
	--ink: #0f0f0d;
	--ink-light: #4f4f4d;
	--muted: #5a5a55;
	--slate: #8a8a85;
	--accent: #0f0f0d;
	--accent-dim: #5a5a55;
	--accent-glow: transparent;
	--green: #3a7a5a;
	--wake: #d0d0c8;
	--rule: #e8e8e4;
	--code-bg: #f5f5f2;
	--grid-color: transparent;
	--grain-opacity: 0;
	--card-border: transparent;
	--card-border-hover: #d0d0c8;
	--marker-bg: transparent;
	--marker-hover: transparent;
	--compass-display: none;
}

/* ══════════════════════════════════════════
   DARK THEME
   ══════════════════════════════════════════ */
[data-theme="dark"] {
	--bg: #0a0e14;
	--bg-card: rgba(17, 24, 32, 0.15);
	--bg-card-hover: rgba(24, 32, 48, 0.2);
	--ink: #c8ccd4;
	--ink-light: #c8ccd4;
	--muted: #8a96a4;
	--slate: #5a6a7a;
	--accent: #d4a04a;
	--accent-dim: #8a6a30;
	--accent-glow: #d4a04a33;
	--green: #4a9a6a;
	--wake: #2a4a6a;
	--rule: #1e2a38;
	--code-bg: #111820;
	--grid-color: #1a2535;
	--grain-opacity: 0.03;
	--card-border: transparent;
	--card-border-hover: var(--accent);
	--marker-bg: var(--wake);
	--marker-hover: var(--accent);
	--compass-display: block;
}

/* ══════════════════════════════════════════
   BASE
   ══════════════════════════════════════════ */
html { scroll-behavior: smooth; }

body {
	font-family: var(--font-mono);
	background: var(--bg);
	color: var(--ink);
	min-height: 100vh;
	overflow-x: hidden;
	position: relative;
}

a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}

strong { color: var(--ink); }

/* ── Morph transition ── */
::view-transition-old(root),
::view-transition-new(root) {
	animation: none;
	mix-blend-mode: normal;
}

::view-transition-old(root) {
	z-index: 1;
}

::view-transition-new(root) {
	z-index: 9999;
	animation: morph-reveal 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes morph-reveal {
	from { clip-path: circle(0% at var(--toggle-x, 95%) var(--toggle-y, 3%)); }
	to   { clip-path: circle(150% at var(--toggle-x, 95%) var(--toggle-y, 3%)); }
}

/* ── Chart grid (dark mode, homepage) ── */
body::before {
	content: '';
	position: fixed;
	inset: 0;
	background:
		linear-gradient(var(--grid-color) 1px, transparent 1px),
		linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
	background-size: 60px 60px;
	opacity: 0.5;
	pointer-events: none;
	z-index: 0;
}

/* ── Grain texture ── */
body::after {
	content: '';
	position: fixed;
	inset: 0;
	background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
	opacity: var(--grain-opacity);
	pointer-events: none;
	z-index: 0;
}

/* ══════════════════════════════════════════
   THEME TOGGLE
   ══════════════════════════════════════════ */
.theme-toggle {
	position: fixed;
	top: 1.5rem;
	right: 1.5rem;
	z-index: 10;
	background: none;
	border: 1px solid var(--wake);
	border-radius: 50%;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: var(--muted);
	transition: color 0.3s ease, border-color 0.3s ease;
	opacity: 0;
	animation: plotIn 0.6s ease 1.2s forwards;
}

.theme-toggle:hover {
	color: var(--accent);
	border-color: var(--accent);
}

.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ══════════════════════════════════════════
   NAVIGATION
   ══════════════════════════════════════════ */
nav {
	font-family: var(--font-mono);
	font-size: 0.72rem;
	letter-spacing: 0.04em;
	color: var(--muted);
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
}

nav a,
nav span {
	text-decoration: none;
	color: var(--slate);
	transition: color 0.2s ease;
}

nav a:hover {
	color: var(--ink);
}

nav span {
	color: var(--muted);
	font-weight: 700;
}

nav > :not(:first-child)::before {
	content: '\00b7';
	margin: 0 0.6rem;
	color: var(--wake);
	font-weight: 400;
}

.site-nav {
	padding: 1.2rem 0 0;
	opacity: 0;
	animation: plotIn 0.6s ease 0.1s forwards;
}

.page-nav {
	padding: 0.3rem 0 0;
	margin-bottom: 3rem;
}

/* ══════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════ */
.chart-area {
	position: relative;
	z-index: 1;
	max-width: 680px;
	margin: 0 auto;
	padding: 0 2rem 6rem;
}

/* ══════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════ */
header {
	max-width: 640px;
	margin: 0 auto;
	padding: 0 0 1.3rem;
	position: relative;
	opacity: 0;
	animation: plotIn 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Homepage header (inside .chart-area) gets more vertical space */
.chart-area header {
	max-width: none;
	margin: 0;
	padding: 3.5rem 0 2.5rem;
}

.bearing {
	font-size: 0.65rem;
	font-weight: 500;
	letter-spacing: 0.25em;
	text-transform: uppercase;
	color: var(--accent-dim);
	margin-bottom: 1.5rem;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	opacity: 0;
	transition: opacity 0.4s ease;
}

[data-theme="dark"] .bearing { opacity: 1; }

.bearing::before {
	content: '';
	display: block;
	width: 8px;
	height: 8px;
	border: 1.5px solid var(--accent);
	border-radius: 50%;
	animation: pulse 3s ease-in-out infinite;
}

h1 {
	font-family: var(--font-display);
	font-size: clamp(2rem, 4vw, 3.5rem);
	font-weight: 600;
	line-height: 1.1;
	letter-spacing: -0.01em;
}

h1 em {
	font-style: italic;
	color: var(--ink);
	transition: color 0.4s ease;
}

[data-theme="dark"] h1 em {
	color: var(--accent);
}

.tagline {
	margin-top: 1.25rem;
	font-size: 0.85rem;
	font-weight: 400;
	line-height: 1.7;
	color: var(--slate);
}

/* ══════════════════════════════════════════
   CONTENT TYPOGRAPHY (app pages)
   ══════════════════════════════════════════ */
main {
	max-width: 640px;
	margin: 0 auto;
	padding: 1rem 0 5rem;
}

h2 {
	font-family: var(--font-display);
	font-size: 1.4rem;
	font-weight: 600;
	margin-top: 2.5rem;
	margin-bottom: 0.8rem;
}

h3 {
	font-size: 0.95rem;
	font-weight: 600;
	margin-top: 1.8rem;
	margin-bottom: 0.5rem;
}

p, li {
	font-size: 0.92rem;
	line-height: 1.65;
	color: var(--ink-light);
}

p + p { margin-top: 0.8rem; }

ul, ol {
	margin-top: 0.5rem;
	margin-bottom: 0.5rem;
	padding-left: 2.8rem;
}

li + li { margin-top: 0.3rem; }

code {
	font-family: var(--font-mono);
	font-size: 0.88rem;
	background: var(--code-bg);
	padding: 0.15rem 0.4rem;
	border-radius: 3px;
}

pre {
	background: var(--code-bg);
	padding: 1rem;
	border-radius: 4px;
	overflow-x: auto;
	margin: 0.8rem 0;
}

pre code {
	background: none;
	padding: 0;
}

table {
	width: 100%;
	border-collapse: collapse;
	margin: 1rem 0;
	font-size: 0.88rem;
}

th, td {
	text-align: left;
	padding: 0.5rem 0.8rem;
	border-bottom: 1px solid var(--rule);
}

th {
	font-weight: 600;
	color: var(--ink);
}

td { color: var(--ink-light); }

hr {
	border: none;
	border-top: 1px solid var(--rule);
	margin: 2.5rem 0;
}

/* ══════════════════════════════════════════
   HORIZON SEPARATOR
   ══════════════════════════════════════════ */
.horizon {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin: 0 0 0.5rem;
	opacity: 0;
	animation: plotIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
}

.horizon::after {
	content: '';
	flex: 1;
	height: 1px;
	background: linear-gradient(90deg, var(--wake), transparent);
}

.horizon span {
	font-size: 0.6rem;
	font-weight: 500;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	color: var(--slate);
	white-space: nowrap;
}

/* ══════════════════════════════════════════
   WAYPOINT CARDS
   ══════════════════════════════════════════ */
.waypoints {
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.waypoint {
	display: block;
	text-decoration: none;
	color: inherit;
	padding: 2rem 0;
	margin-left: -1rem;
	padding-left: 1rem;
	position: relative;
	background: var(--bg-card);
	border-left: 2px solid var(--card-border);
	transition:
		background 0.4s cubic-bezier(0.16, 1, 0.3, 1),
		border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
		transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
		padding 0.4s ease;
	opacity: 0;
	animation: plotIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="dark"] .waypoint {
	padding: 2rem 0 2rem 1rem;
}

.waypoint:hover {
	background: var(--bg-card-hover);
	border-left-color: var(--card-border-hover);
}

.waypoint:hover .wp-marker {
	background: var(--marker-hover);
	box-shadow: 0 0 12px var(--accent-glow);
}

.waypoint:hover .wp-name {
	color: var(--accent);
}

.wp-header {
	display: flex;
	align-items: baseline;
	gap: 0.75rem;
	margin-bottom: 0.5rem;
}

.wp-marker {
	display: none;
}

.wp-name {
	font-family: var(--font-display);
	font-size: 1.4rem;
	font-weight: 600;
	color: var(--ink-light);
	transition: color 0.3s ease, font-family 0.3s ease;
	letter-spacing: 0.01em;
}

[data-theme="dark"] .wp-name {
	color: var(--ink);
}

.wp-platform {
	font-size: 0.6rem;
	font-weight: 500;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: var(--slate);
	margin-left: auto;
}

.wp-desc {
	font-size: 0.85rem;
	font-weight: 400;
	line-height: 1.7;
	color: var(--muted);
	padding-left: 0;
}

/* Staggered entry */
.waypoint:nth-child(1) { animation-delay: 0.15s; }
.waypoint:nth-child(2) { animation-delay: 0.25s; }
.waypoint:nth-child(3) { animation-delay: 0.35s; }
.waypoint:nth-child(4) { animation-delay: 0.45s; }
.waypoint:nth-child(5) { animation-delay: 0.55s; }
.waypoint:nth-child(6) { animation-delay: 0.65s; }
.waypoint:nth-child(7) { animation-delay: 0.75s; }

/* ══════════════════════════════════════════
   ABOUT / POSITION FIX
   ══════════════════════════════════════════ */
.position-fix {
	margin-top: 3rem;
	padding: 1.8rem 0;
	border-left: 2px solid transparent;
	opacity: 0;
	animation: plotIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.9s forwards;
	transition: background 0.4s ease, border-color 0.4s ease, padding 0.4s ease;
}

[data-theme="dark"] .position-fix {
	padding: 2rem 0;
	background: var(--bg-card);
	border-left-color: transparent;
}

.fix-label {
	font-family: var(--font-mono);
	font-size: 0.6rem;
	font-weight: 500;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	color: var(--slate);
	margin-bottom: 1.5rem;
	display: flex;
	align-items: center;
	gap: 0.6rem;
	transition: color 0.4s ease;
}

[data-theme="dark"] .fix-label {
	color: var(--green);
}

.fix-label::before {
	content: none;
}

[data-theme="dark"] .fix-label::before {
	content: '';
	width: 6px;
	height: 6px;
	background: var(--green);
}

.position-fix p {
	font-size: 0.92rem;
	line-height: 1.5;
	color: var(--muted);
}

.position-fix p + p { margin-top: 0.75rem; }

.position-fix a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
	transition: color 0.3s ease, text-decoration-color 0.3s ease;
}

[data-theme="dark"] .position-fix a {
	color: var(--accent);
	text-decoration: none;
	border-bottom: 1px solid var(--accent-dim);
}

[data-theme="dark"] .position-fix a:hover {
	border-bottom-color: var(--accent);
}

/* ══════════════════════════════════════════
   COMPASS ROSE
   ══════════════════════════════════════════ */
.compass {
	position: fixed;
	bottom: 2rem;
	right: 2rem;
	width: 48px;
	height: 48px;
	color: var(--wake);
	display: none;
	opacity: 0;
	animation: plotIn 1s ease 1.5s forwards;
}

[data-theme="dark"] .compass {
	display: block;
}

.compass svg {
	width: 100%;
	height: 100%;
	animation: spin 120s linear infinite;
}

/* ══════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════ */
@keyframes plotIn {
	from { opacity: 0; transform: translateY(16px); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.3; }
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 540px) {
	.chart-area { padding: 0 1.25rem 4rem; }
	header { padding: 2.5rem 0 2rem; }
	main { padding-left: 1.25rem; padding-right: 1.25rem; }
	[data-theme="dark"] .waypoint { padding: 1.5rem 0; }
	.wp-desc { padding-left: 0; }
	.wp-header { flex-wrap: wrap; }
	.wp-platform { margin-left: 0; }
	.compass { display: none !important; }
	.theme-toggle { top: 1rem; right: 1rem; }
}

/* ══════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--wake); border-radius: 2px; }
