/*
 * Finishing touches on the front end: how the site feels rather than how it is laid out.
 * Everything that moves is switched off for visitors who ask for reduced motion.
 */

/* Native controls, date inputs and scrollbars follow the chosen theme, not just the system */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
html { accent-color: var(--accent-color); scrollbar-color: var(--divider) transparent; }
::selection { background: color-mix(in srgb, var(--accent-color) 28%, transparent); color: inherit; }

/* Typography: balanced headings, no lonely last words, steady numbers */
h1, h2, h3, h4, .card-title, .hero-title, .featured-title { text-wrap: balance; }
p, li, figcaption, .card-excerpt, .hero-lead { text-wrap: pretty; }
time, th, td, .stat-value, .toc-list, .cal { font-variant-numeric: tabular-nums; }

/* The header gets a soft shadow once the page scrolls underneath it (class set in main.js) */
.site-header { transition: box-shadow .25s ease; }
.site-header.is-scrolled { box-shadow: 0 8px 24px -16px rgba(0, 0, 0, .3); }

/* Cards: the picture zooms slowly, the title underlines itself */
.card-media { overflow: hidden; }
.card-title a {
	background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}
@media (prefers-reduced-motion: no-preference) {
	.card-media img { transition: transform .7s cubic-bezier(.2, 0, 0, 1); }
	.card-title a { transition: background-size .35s ease; }
}
@media (hover: hover) {
	.card:hover .card-title a,
	.card-title a:focus-visible { background-size: 100% 2px; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.card:hover .card-media img { transform: scale(1.04); }
}

/* The picture at the top of a post stands out from the page a little */
.entry-media img { box-shadow: 0 24px 48px -28px rgba(0, 0, 0, .4); }

/* Moving between pages: a short cross-fade, with the header staying put (browsers without support just load the page) */
@media (prefers-reduced-motion: no-preference) {
	@view-transition { navigation: auto; }
	.site-header { view-transition-name: site-header; }
	::view-transition-old(root),
	::view-transition-new(root) { animation-duration: .2s; }
}

/* Reveal on scroll: assets/js/components.js adds .will-reveal to things below the fold and .is-revealed as they come into view */
@media (prefers-reduced-motion: no-preference) {
	.will-reveal { opacity: 0; transform: translateY(1.25rem); }
	.will-reveal.is-revealed {
		opacity: 1;
		transform: none;
		transition: opacity .6s ease, transform .7s cubic-bezier(.2, 0, 0, 1);
		transition-delay: var(--reveal-delay, 0ms);
	}

	/* Pictures that load late fade in instead of popping in */
	img.is-fading { opacity: 0; }
	img[loading="lazy"] { transition: opacity .5s ease; }
}
@media print {
	.will-reveal, img.is-fading { opacity: 1; transform: none; }
}
