/* Fonts, served from src/fonts (SIL Open Font License; see the OFL-*.txt files there). Latin characters only. */
@font-face {
	font-family: 'Orbitron';
	src: url('../fonts/orbitron-latin-700-normal.woff2') format('woff2');
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

:root {
	--primary: #7f9bff;
	--primary-strong: #a9bcff;
	--secondary: #ff8a3d;
	--secondary-text: #ff9a55;
	--bg: #0e1320;
	--bg-alt: #131a2b;
	--surface: #172036;
	--card-bg: var(--surface);
	--text: #e6e9f2;
	--text-muted: #a3acc2;
	--border: #263252;
	--on-accent: #0e1320;

	--font-brand: 'Orbitron', system-ui, sans-serif;    /* the header's "PlanetScope" */
	--font-body: system-ui, sans-serif;
	--gutter: 24px;
	color-scheme: dark;
}

/* Light theme (set on <html> by theme.js) */
:root[data-theme="light"] {
	--primary: #3d5cc4;
	--primary-strong: #2c4499;
	--secondary: #e06a1b;
	--secondary-text: #b9530c;
	--bg: #f6f7fb;
	--bg-alt: #e7eaf3;
	--surface: #ffffff;
	--text: #161c2e;
	--text-muted: #586180;
	--border: #d4d9e6;
	--on-accent: #ffffff;
	color-scheme: light;
}

html, body {
	height: 100%;
	margin: 0;
	padding: 0;
}

/* Header on top, the solar system fills the rest of the window */
body {
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	overflow: hidden;
}

/* ----- Site header ----- */
.site-header {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 10px var(--gutter);
	padding-top: max(10px, env(safe-area-inset-top));
	background: color-mix(in srgb, var(--bg) 85%, transparent);
	border-bottom: 1px solid var(--border);
	backdrop-filter: saturate(1.6) blur(12px);
	-webkit-backdrop-filter: saturate(1.6) blur(12px);
}
.site-header .brand {
	display: flex;
	align-items: center;
	text-decoration: none;
	border-radius: 8px;
}
.site-header .brand-logo { display: block; width: 32px; height: 32px; }
.site-header .brand-name {
	font: 700 1.5rem/1 var(--font-brand);
	letter-spacing: 0.04em;
}
.brand-logo + .brand-name {
	margin-left: 10px;
}
.site-header .brand-name.primary {
	color: var(--primary);
}
.site-header .brand-name.secondary {
	color: var(--secondary);
}
.site-header .brand:hover .brand-name { color: var(--secondary-text); }

/* Icon buttons: no border, primary color, a soft background and secondary color on hover (same as the control bar's buttons) */
.icon-button {
	display: inline-grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--primary);
	cursor: pointer;
}
.icon-button:hover { background: var(--bg-alt); color: var(--secondary-text); }
.site-header a:focus-visible, .icon-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.header-actions { display: flex; align-items: center; gap: 4px; }
.icon-button[hidden] { display: none; }

/* Fullscreen button: the expand icon normally, the collapse icon while in full screen */
.fullscreen-toggle .icon-collapse { display: none; }
:root.is-fullscreen .fullscreen-toggle .icon-expand { display: none; }
:root.is-fullscreen .fullscreen-toggle .icon-collapse { display: block; }

/* Show the moon in light mode (switch to dark) and the sun in dark mode (switch to light) */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

@media (max-width: 560px) {
	:root { --gutter: 16px; }
	.site-header .brand-name { font-size: 1.1rem; }
}

/* Solar system (orrery) filling the home page's main area, between the header and footer. */
.orrery-main,
.orrery-page {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

/* Solar system (orrery) embedded on the home page. Adapted from the standalone full-screen version:
   everything is scoped to .orrery, and the canvas and control bar are positioned inside the box instead of the viewport.
   The scene's background is the page's background color. */
.orrery {
	--ink: #e9ecf6;
	--dim: #8b93b3;
	--line: rgba(160, 172, 220, 0.18);
	--panel: rgba(14, 19, 40, 0.72);
	/* controls are styled like the header's buttons and use the site's font (--font-body) and colors */
	position: relative;
	flex: 1;
	min-height: 200px;    /* low enough for phones held sideways, so the scene fits below the header without scrolling */
	overflow: hidden;
	/* Scene colors, read each frame by main.js (readSceneColors and the label colors); light theme values below */
	--space: #0e1320;                          /* sky */
	--scene-label: #7f9bff;                    /* planet labels (see SOLAR_DATA.labels in data.js) */
	--scene-label-hover: #ff8a3d;              /* hovered planet labels and the Sun's label */
	--scene-star: rgb(220, 228, 255);
	--scene-star-opacity: 1;
	--scene-orbit: rgba(150, 165, 220, 0.16);
	--scene-belt: rgb(196, 182, 160);
	--scene-glow-blend: lighter;               /* glows add light on the dark sky */
	background: var(--space);
	color: var(--ink);
	-webkit-font-smoothing: antialiased;
}
/* Light theme: a pale sky with faint slate "stars", darker orbit lines and rocks, and glows painted normally
   (adding light would wash out to white on a light background) */
:root[data-theme="light"] .orrery {
	--space: var(--bg);
	--ink: var(--text);
	--scene-label: var(--primary);
	--scene-label-hover: var(--secondary-text);
	--scene-star: rgb(110, 125, 170);
	--scene-star-opacity: 0.45;
	--scene-orbit: rgba(60, 80, 150, 0.22);
	--scene-belt: rgb(135, 115, 90);
	--scene-glow-blend: source-over;
}
.orrery *, .orrery *::before, .orrery *::after { box-sizing: border-box; }
.orrery [hidden] { display: none !important; }

.orrery .stage { position: absolute; inset: 0; }
.orrery canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.orrery canvas.dragging { cursor: grabbing; }
.orrery canvas.hovering { cursor: pointer; }

/* Title at the top left; uses the site's h1 font and heading color. Clicks and drags pass through to the canvas. */
.orrery .orrery-title {
	position: absolute; top: 20px; left: var(--gutter); right: var(--gutter); z-index: 1; margin: 0;
	font-size: 1.5rem; text-align: left;    /* left edge lines up with the header's logo */
	pointer-events: none;
}

.orrery .hud { position: absolute; left: 0; right: 0; pointer-events: none; padding-inline: 16px; }
.orrery .hud > * { pointer-events: auto; }
.orrery .bottom { bottom: 0; padding-bottom: 18px; display: flex; justify-content: center; }

.orrery .bar {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px;
	border-radius: 999px; padding: 8px 10px;

	/* same background, blur and border as the site header (follows the light / dark theme) */
	background: color-mix(in srgb, var(--bg) 85%, transparent); border: 1px solid var(--border);
	backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
	max-width: 100%;
}
/* Like the header's icon buttons: no border, primary text, a soft background and secondary text on hover */
.orrery .bar button {
	font: 600 0.95rem/1 var(--font-body);    /* same as the header links */ color: var(--primary); background: transparent;
	border: 0; border-radius: 999px; padding: 0.6rem 0.9rem; cursor: pointer; margin: 0;
}
.orrery .bar button:hover { background: var(--bg-alt); color: var(--secondary-text); }
.orrery .bar button[aria-pressed="true"] { background: color-mix(in srgb, var(--primary) 22%, transparent); }

/* Play / Pause works like the Labels toggle: tinted while the animation is running (aria-pressed, set by main.js), plain when paused */
.orrery .bar button.play { min-width: 74px; }
.orrery .speed { display: flex; align-items: center; gap: 10px; font: 0.8rem var(--font-body); color: var(--text-muted); margin: 0; }
.orrery .speed output { font-family: var(--font-body); color: var(--text); min-width: 10ch; font-variant-numeric: tabular-nums; }
.orrery .date { font: 500 0.9rem var(--font-body); color: var(--text); min-width: 11ch; text-align: center; font-variant-numeric: tabular-nums; padding-left: 6px; }
.orrery input[type="range"] { width: 130px; accent-color: var(--primary); margin: 0; }
.orrery .bar button.hide { color: var(--text-muted); }
.orrery .bar button.hide:hover { color: var(--secondary-text); }

/* Same look as the control bar's buttons: no border, primary text, a soft background and secondary text on hover */
.orrery .show-hud {
	font: 600 0.95rem/1 var(--font-body);    /* same as the header links */ color: var(--primary);
	border-radius: 999px; padding: 0.6rem 0.9rem; cursor: pointer; margin: 0;
	/* same background as the control bar, so it reads over the dark scene in both themes */
	background: color-mix(in srgb, var(--bg) 85%, transparent); border: 1px solid var(--border);
	backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
}
.orrery .show-hud:hover { background: var(--bg-alt); color: var(--secondary-text); }
.orrery button:focus-visible, .orrery input:focus-visible, .orrery canvas:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.orrery canvas:focus-visible { outline-offset: -2px; }

/* Before main.js has run (it adds .hud-ready), show the controls' default state so they don't flash:
   the bar on desktop, just the Controls button on phones (narrow or touch-only screens). Matches isMobile in main.js. */
.orrery:not(.hud-ready) .show-hud { display: none; }
@media (max-width: 560px), (hover: none) and (pointer: coarse) {
	.orrery:not(.hud-ready) .bar { display: none; }
	.orrery:not(.hud-ready) .show-hud { display: inline-block; }
}

@media (max-width: 560px) {
	.orrery .orrery-title { top: 14px; }
	.orrery .bar { border-radius: 18px; }
	.orrery .bar { gap: 8px 10px; }
	.orrery input[type="range"] { width: 90px; }
	.orrery .speed output { min-width: 0; }
}
