/*
 * kjrrp.github.io
 * Charcoal masthead, light grey paper, Cantata One headings, Helvetica body,
 * links that invert to charcoal on hover.
 */

/* Tokens
================================================== */
:root {
	--charcoal: #2b2b2b;
	--bg: var(--charcoal);
	--paper: #dddddd;
	--text: #333a40;
	--heading: #444444;
	--muted: #5c6166;
	--rule: #c4c4c4;
	--link: #333333;
	--link-hover-bg: var(--charcoal);
	--link-hover-text: #eeeeee;
	--masthead-text: #eeeeee;
	--masthead-muted: #b5b5b5;
	--shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.6);

	--font-body: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
	--font-display: "Cantata One", Georgia, serif;
	--measure: 44rem;
	--radius: 14px;
	--gutter: 16px;
	color-scheme: light;
}

/* Dark theme: follows the system unless the toggle (js/theme.js) sets
   data-theme on <html>. Keep the two blocks below identical. */
:root[data-theme="dark"] {
	color-scheme: dark;
	--bg: #1d1d1d;
	--paper: var(--charcoal);
	--text: #d4d4d4;
	--heading: #ececec;
	--muted: #a3a3a3;
	--rule: #444444;
	--link: #e6e6e6;
	--link-hover-bg: #dddddd;
	--link-hover-text: var(--charcoal);
	--shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--bg: #1d1d1d;
		--paper: var(--charcoal);
		--text: #d4d4d4;
		--heading: #ececec;
		--muted: #a3a3a3;
		--rule: #444444;
		--link: #e6e6e6;
		--link-hover-bg: #dddddd;
		--link-hover-text: var(--charcoal);
		--shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
	}
}

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

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

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: clamp(1rem, 0.94rem + 0.25vw, 1.125rem);
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4, h5 {
	color: var(--heading);
	font-family: var(--font-display);
	font-weight: 400;
	line-height: 1.2;
	margin: 2.2em 0 0.6em;
	text-wrap: balance;
}
h1 { font-size: clamp(2rem, 1.6rem + 1.8vw, 2.6rem); }
h2 { font-size: clamp(1.6rem, 1.35rem + 1.2vw, 2.1rem); }
h3 { font-size: clamp(1.25rem, 1.15rem + 0.6vw, 1.5rem); }
h4 { font-size: 1.15rem; }
h5 { font-size: 1rem; }

p { margin: 0 0 1.2em; }
em { font-style: italic; }
strong { font-weight: 700; }
small { font-size: 0.875em; }
xsmall { display: inline-block; font-size: 0.8em; color: var(--muted); letter-spacing: 0.02em; }

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

pre {
	overflow-x: auto;
	padding: 1rem;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.06);
	font-size: 0.9em;
}

/* Links: the signature inversion
================================================== */
a {
	color: var(--link);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	padding: 0.05em 0.15em;
	margin: 0 -0.15em;
	border-radius: 3px;
	transition: color 0.25s, background-color 0.25s;
}
a:hover, a:focus-visible {
	color: var(--link-hover-text);
	background: var(--link-hover-bg);
}
a:focus-visible, button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Image links should not get the inverted block behind them. */
a:has(> img), a.cube { padding: 0; margin: 0; background: none; }
a:has(> img):hover img, a.cube:hover img { opacity: 0.88; }

.skip-link {
	position: absolute;
	left: var(--gutter);
	top: -3rem;
	z-index: 10;
	background: var(--paper);
	color: var(--text);
}
.skip-link:focus { top: var(--gutter); }

/* Masthead
================================================== */
.masthead {
	position: relative;
	padding: clamp(2.5rem, 2rem + 3vw, 3.75rem) var(--gutter) 7.5rem;
	text-align: center;
	color: var(--masthead-text);
}
.brand {
	display: inline-block;
	font-family: var(--font-display);
	font-size: clamp(2.75rem, 2.2rem + 2.5vw, 3.5rem);
	line-height: 1;
	color: var(--masthead-text);
	text-decoration: none;
	padding: 0.1em 0.25em;
	margin: 0;
}
.brand:hover, .brand:focus-visible { background: var(--masthead-text); color: var(--charcoal); }

.site-nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.25rem 1.25rem;
	margin-top: 1.25rem;
	font-size: 0.78rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}
.site-nav a {
	color: var(--masthead-muted);
	text-decoration: none;
	padding: 0.2em 0.45em;
	margin: 0;
}
.site-nav a:hover, .site-nav a:focus-visible, .site-nav a[aria-current="page"] {
	color: var(--charcoal);
	background: var(--masthead-text);
}

/* Light/dark toggle, added to the masthead by js/theme.js */
.theme-toggle {
	position: absolute;
	top: var(--gutter);
	right: var(--gutter);
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 1px solid rgba(238, 238, 238, 0.25);
	border-radius: 50%;
	background: transparent;
	color: var(--masthead-muted);
	cursor: pointer;
	transition: color 0.25s, background-color 0.25s, border-color 0.25s;
}
.theme-toggle:hover, .theme-toggle:focus-visible {
	color: var(--charcoal);
	background: var(--masthead-text);
	border-color: var(--masthead-text);
}
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }

/* Paper card
================================================== */
.page {
	width: min(var(--measure), 100% - 2 * var(--gutter));
	margin: -5.5rem auto 0;
	padding: clamp(1.5rem, 1rem + 3.5vw, 3.5rem);
	background: var(--paper);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	overflow-wrap: break-word;
}
/* First heading of the card (bilingual posts start with a hidden FR title, so check the first two). */
.page > h1:first-child,
.page > :first-child > :is(h1, h2):nth-child(-n+2) { margin-top: 0; }

.back-link {
	margin: 3rem 0 0;
	padding-top: 1.5rem;
	border-top: 1px solid var(--rule);
	text-align: center;
	font-size: 0.9rem;
	letter-spacing: 0.04em;
}

/* Legacy layout helpers used inside posts */
.row-fluid, .row-fluid [class*="span"] { width: auto; margin: 0; float: none; }
.center { text-align: center; }
.justified { text-align: justify; }
.left { float: left; }
.right { float: right; }
.hidden { display: none; }
.remove-bottom { margin-bottom: 0 !important; }
.underline { border-bottom: 1px solid var(--rule); padding-bottom: 0.5em; }

/* Captions (posts use blockquote > cite under images)
================================================== */
blockquote {
	margin: 0.6rem auto 2rem;
	padding: 0;
	border: 0;
	color: var(--muted);
	font-size: 0.85rem;
	line-height: 1.5;
}
blockquote p { margin: 0; }
blockquote cite { font-style: italic; }
blockquote cite::before { content: "\2014\00a0"; }
blockquote cite p::before { content: none; }

/* Images
================================================== */
.page img { border-radius: 6px; vertical-align: middle; }
/* Set by header-footer.js when an image fails to load (404, host down). */
img.img-broken {
	box-sizing: border-box;
	min-width: min(240px, 100%);
	object-fit: contain;
	background: rgba(138, 143, 148, 0.12);
	border: 2px dashed var(--rule);
	border-radius: 6px;
}
img.cube { display: inline; max-width: 95%; margin: auto; }
img.cube1h { max-height: 100px; }
img.cube2h { max-height: 200px; }
img.cube3h { max-height: 300px; }
img.cube4h { max-height: 400px; }
img.cube5h { max-height: 500px; }
img.cube6h { max-height: 600px; }
img.cube7h { max-height: 700px; }
img.cube8h { max-height: 800px; }
img.cube1w, img.cube2w { display: block; max-width: min(200px, 100%); margin: auto; }
img.cube3w { display: block; max-width: min(300px, 100%); margin: auto; }
img.cube4w { display: block; max-width: min(400px, 100%); margin: auto; }
img.cube5w { display: block; max-width: min(500px, 100%); margin: auto; }
img.cube6w { display: block; max-width: min(600px, 100%); margin: auto; }
img.cube7w { display: block; max-width: min(700px, 100%); margin: auto; }
img.cube8w { display: block; max-width: min(800px, 100%); margin: auto; }
img.soc-m { display: none; }
img.soc { width: 24px; height: 24px; }
.img-circle, .avatar { border-radius: 50%; width: 50px; height: 50px; object-fit: cover; }

/* Language switch (EN / FR posts)
================================================== */
html:not([data-lang="fr"]) .fr,
html[data-lang="fr"] .en { display: none !important; }

.lang-switch {
	display: inline-flex;
	gap: 2px;
	margin: 0 0 1.5rem;
	padding: 3px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.08);
}
.lang-switch button {
	font: inherit;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	padding: 0.3em 0.9em;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
	transition: color 0.2s, background-color 0.2s;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--charcoal); color: #eeeeee; }
:root[data-theme="dark"] .lang-switch { background: rgba(255, 255, 255, 0.08); }
:root[data-theme="dark"] .lang-switch button[aria-pressed="true"] { background: #dddddd; color: var(--charcoal); }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .lang-switch { background: rgba(255, 255, 255, 0.08); }
	:root:not([data-theme="light"]) .lang-switch button[aria-pressed="true"] { background: #dddddd; color: var(--charcoal); }
}

/* Home page
================================================== */
.intro { font-size: 1.08em; }
.intro p:first-child { font-family: var(--font-display); font-size: 1.25em; color: var(--heading); line-height: 1.4; }

.section-title {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
}
.section-title a { font-family: var(--font-body); font-size: 0.85rem; white-space: nowrap; }

.post-list, .pub-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.post-list li {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.55rem 0;
	border-bottom: 1px solid var(--rule);
}
.post-list li:first-child { border-top: 1px solid var(--rule); }
.post-list time { flex: none; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.pub-list li { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.pub-list li:first-child { border-top: 1px solid var(--rule); }
.pub-title {
	display: block;
	width: fit-content;
	color: var(--heading);
	font-weight: 700;
	line-height: 1.4;
	text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}
.pub-authors, .pub-venue { display: block; font-size: 0.875rem; color: var(--muted); }
.pub-authors { font-style: italic; }

/* Footer
================================================== */
.site-footer {
	padding: 3.5rem var(--gutter) 3rem;
	text-align: center;
	color: var(--masthead-muted);
	font-size: 0.8rem;
	min-height: 12rem;
}
.site-footer a { color: var(--masthead-muted); }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--charcoal); background: var(--masthead-text); }
.social {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	list-style: none;
	margin: 1.25rem 0;
	padding: 0;
}
.social a {
	display: grid;
	place-items: center;
	width: 2.5rem;
	height: 2.5rem;
	margin: 0;
	padding: 0;
	border-radius: 50%;
	color: var(--masthead-muted);
}
.social svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }
.copyright { margin: 0; }

.visually-hidden {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Photo slideshows (js/lightbox.js)
================================================== */
a[data-lightbox] { cursor: zoom-in; }
.lightbox-thumb img { width: 100%; max-width: 200px; border-radius: 10px; }
html.lightbox-open { overflow: hidden; }

.lightbox {
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(17, 17, 17, 0.95);
	color: #eeeeee;
	font-family: var(--font-body);
}
.lightbox[open] {
	display: grid;
	grid-template-rows: minmax(0, 1fr) auto;
	animation: lightbox-in 0.2s ease-out;
}
.lightbox::backdrop { background: transparent; }

.lightbox-stage {
	position: relative;
	display: grid;
	place-items: center;
	min-height: 0;
	padding: 4rem 4.5rem 0.5rem;
	touch-action: pan-y pinch-zoom;
}
.lightbox-media {
	display: block;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.8);
	transition: opacity 0.2s;
}
video.lightbox-media { width: min(100%, 1100px); background: #000000; }
.lightbox-media.img-broken { width: min(100%, 400px); max-height: min(100%, 300px); background: #1d1d1d; }
.lightbox-stage.is-loading .lightbox-media { opacity: 0; }
.lightbox-stage.is-loading::after {
	content: "";
	position: absolute;
	width: 2rem;
	height: 2rem;
	border: 2px solid rgba(238, 238, 238, 0.2);
	border-top-color: #eeeeee;
	border-radius: 50%;
	animation: lightbox-spin 0.8s linear infinite;
}

.lightbox-bar {
	display: flex;
	align-items: baseline;
	gap: 1rem;
	width: min(60rem, 100%);
	margin: 0 auto;
	padding: 0.75rem var(--gutter) 1.25rem;
	font-size: 0.9rem;
	line-height: 1.5;
}
.lightbox-caption { margin: 0; }
.lightbox-counter {
	margin-left: auto;
	color: #9a9a9a;
	font-size: 0.78rem;
	letter-spacing: 0.14em;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.lightbox-btn {
	position: absolute;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid rgba(238, 238, 238, 0.25);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.4);
	color: #eeeeee;
	cursor: pointer;
	transition: color 0.25s, background-color 0.25s;
}
.lightbox-btn:hover, .lightbox-btn:focus-visible { background: #eeeeee; color: var(--charcoal); }
.lightbox-btn[hidden] { display: none; }
.lightbox-close { top: var(--gutter); right: var(--gutter); }
.lightbox-prev, .lightbox-next { top: calc(50% - 2rem); }
.lightbox-prev { left: var(--gutter); }
.lightbox-next { right: var(--gutter); }

@media (max-width: 640px) {
	.lightbox-stage { padding: 4rem 0.5rem 0.5rem; }
	.lightbox-prev, .lightbox-next { top: auto; bottom: 4.5rem; }
}

@keyframes lightbox-in { from { opacity: 0; } }
@keyframes lightbox-spin { to { transform: rotate(360deg); } }

/* 404
================================================== */
.not-found { text-align: center; }
.not-found h1 { margin-top: 0; }

/* Motion
================================================== */
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after { transition: none !important; }
}
