/*
 * The accent word in headings: *zadel* → orange.
 *
 * 1. On entering the viewport (JS adds .is-in) the colour animates from ink to
 *    orange: 1s, standard easing, 0.3s delay.
 * 2. On hover the letters hop one after another, like a horse over a pole.
 * 3. Reduced motion, or no JS: the word is simply orange.
 *
 * Markup comes from rbnl_heading(): .accent > .accent__w (one per word, plain text).
 * While the letters hop, accent.js swaps each word for .accent__l letters (hidden
 * from screen readers, with a hidden copy of the phrase) and swaps it back after.
 * On dark surfaces add .on-dark to a parent so the colour starts from white.
 */

.accent {
	color: var(--rbnl-orange-text);
	/* Single letters cannot kern or join: switched off at rest too, so nothing shifts. */
	font-kerning: none;
	font-variant-ligatures: none;
}

/*
 * One word. It stays in one piece: an atomic inline box moves to the next line as a
 * whole and never breaks between its letters. Some Safari versions do break inside
 * such a box although the word fits (the letters end up stacked until a hover makes
 * Safari lay the line out again), so breaking is switched off here.
 * Only a word that is really wider than its line gets .is-long from accent.js and may
 * then break like normal text, instead of pushing the page wider. Without JS it may
 * always break.
 */
.accent__w {
	display: inline-block;
	max-width: 100%;
	-webkit-hyphens: manual;
	hyphens: manual;
}

.js .accent__w {
	white-space: nowrap;
}

.js .accent__w.is-long {
	white-space: normal;
}

/*
 * The title of the text pages (Privacy, Toegankelijkheid) keeps the old behaviour for now, so
 * no existing page looks different. At 320px "Toegankelijkheid" is 7px wider than its column;
 * remove this rule to let it break like the other headings.
 */
.doc-head__title .accent__w {
	max-width: none;
	white-space: nowrap;
}

.accent__l {
	display: inline-block;
}

@keyframes rbnl-accent-colour {
	from {
		color: var(--accent-from, var(--rbnl-ink));
	}
	to {
		color: var(--rbnl-orange-text);
	}
}

/* If the script never runs, the word turns orange by itself after 4s. */
@keyframes rbnl-accent-failsafe {
	to {
		color: var(--rbnl-orange-text);
	}
}

@keyframes rbnl-accent-jump {
	0%,
	100% {
		transform: translateY(0);
	}
	40% {
		transform: translateY(-0.22em) rotate(-4deg);
	}
	70% {
		transform: translateY(0.02em);
	}
}

.on-dark {
	--accent-from: var(--rbnl-white);
}

@media (prefers-reduced-motion: no-preference) {
	.js .accent {
		color: var(--accent-from, var(--rbnl-ink));
		animation: rbnl-accent-failsafe 1ms 4s forwards;
	}

	.js .accent.is-in {
		animation: rbnl-accent-colour 1s var(--rbnl-ease) 0.3s both;
	}

	.accent:hover .accent__l {
		animation: rbnl-accent-jump 0.55s var(--rbnl-ease) both;
		animation-delay: calc(var(--i, 0) * 0.04s);
	}
}
