/* Wayfarer interactions: photo links, lightbox, reading progress, reading-mode toggle.
   Colours come from the page's palette (the --wp--preset--color--theme-* properties). */

/* ---------- photo links (the affordance that a photo opens) ---------- */
.wf-lb-open {
	position: relative;
	display: block;
	cursor: zoom-in;
	border-radius: inherit;
}

.wf-lb-open::after {
	content: "";
	position: absolute;
	top: 0.6rem;
	right: 0.6rem;
	width: 2.25rem;
	height: 2.25rem;
	border-radius: 50%;
	background-color: color-mix(in srgb, var(--wp--preset--color--theme-1, #fff) 88%, transparent);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7'/%3E%3C/svg%3E");
	background-position: center;
	background-repeat: no-repeat;
	background-size: 1.1rem;
	box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
	opacity: 0;
	transition: opacity 0.2s ease;
	pointer-events: none;
}

.wf-lb-open:hover::after,
.wf-lb-open:focus-visible::after {
	opacity: 1;
}

@media (hover: none) {
	.wf-lb-open::after {
		opacity: 0.85; /* No hover on touch screens: show the hint all the time. */
	}
}

/* The hero is full width and tall; keep its hint clear of the edge on phones. */
.wf-hero .wf-lb-open::after {
	top: 1rem;
	right: 1rem;
}

html.wf-lb-open {
	overflow: hidden;
	scrollbar-gutter: stable;
}

/* ---------- the lightbox ---------- */
dialog.wf-lightbox {
	box-sizing: border-box;
	width: 100vw;
	max-width: none;
	height: 100dvh;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	color: #f6f6f6;
	background: color-mix(in oklab, var(--wp--preset--color--theme-6, #000) 12%, #060606);
	overflow: hidden;
}

dialog.wf-lightbox::backdrop {
	background: transparent;
}

dialog.wf-lightbox[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
}

.wf-lb__top {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 1rem;
}

.wf-lb__count {
	margin: 0 auto 0 0;
	font-size: 0.9rem;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.04em;
	opacity: 0.85;
}

.wf-lb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	min-width: 44px;
	min-height: 44px;
	padding: 0 0.9rem;
	font: inherit;
	font-size: 0.9rem;
	color: inherit;
	text-decoration: none;
	background: rgb(255 255 255 / 0.12);
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.wf-lb__btn[hidden] {
	display: none;
}

.wf-lb__btn:hover:not(:disabled) {
	background: rgb(255 255 255 / 0.24);
}

.wf-lb__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.wf-lb__btn:disabled {
	opacity: 0.3;
	cursor: default;
}

.wf-lb__icon {
	padding: 0;
	width: 44px;
}

.wf-lb__stage {
	position: relative;
	min-height: 0;
	touch-action: pan-y pinch-zoom;
}

/* An absolutely positioned box has a definite size, so the photo's percentage max-height
   resolves and it always fits, whatever the caption below it needs. */
.wf-lb__figure {
	position: absolute;
	inset: 0 4rem;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
}

.wf-lb__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	border-radius: 6px;
	-webkit-user-drag: none;
	user-select: none;
}

.wf-lb__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 1;
}

.wf-lb__prev {
	left: 0.75rem;
}

.wf-lb__next {
	right: 0.75rem;
}

.wf-lb__caption {
	min-height: 3.25rem;
	padding: 0.5rem 1.25rem 1rem;
	text-align: center;
}

.wf-lb__cap,
.wf-lb__meta {
	max-width: 60ch;
	margin: 0 auto;
}

.wf-lb__cap {
	font-size: 1rem;
	line-height: 1.4;
}

.wf-lb__meta {
	margin-top: 0.15rem;
	font-size: 0.82rem;
	opacity: 0.7;
}

@media (max-width: 640px) {
	.wf-lb__figure {
		inset: 0 0.25rem;
	}

	.wf-lb__nav {
		top: auto;
		bottom: 0.5rem;
		transform: none;
		background: rgb(0 0 0 / 0.45);
	}

	.wf-lb__btn span {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%); /* Icon-only buttons on a phone; the names stay for screen readers. */
	}

	.wf-lb__full,
	.wf-lb__map {
		padding: 0;
		width: 44px;
	}
}

/* ---------- reading progress ---------- */
.wf-progress {
	position: fixed;
	z-index: 100001;
	top: var(--wp-admin--admin-bar--height, 0);
	left: 0;
	right: 0;
	height: 3px;
	background: var(--wp--preset--color--theme-3, #3355ff);
	transform-origin: 0 50%;
	transform: scaleX(var(--wf-p, 0));
	pointer-events: none;
}

@keyframes wf-progress-fill {
	to {
		transform: scaleX(1);
	}
}

@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: scroll()) {
		.wf-progress {
			transform: scaleX(0);
			animation: wf-progress-fill linear both;
			animation-timeline: scroll(root block);
		}
	}
}

@media (prefers-reduced-motion: reduce), print {
	.wf-progress {
		display: none;
	}
}

/* ---------- reading-mode toggle ---------- */
.wf-tone-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	margin-inline-start: auto;
	min-height: 2rem;
	padding: 0.15rem 0.8rem 0.15rem 0.6rem;
	font: inherit;
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 600;
	color: var(--wp--preset--color--theme-2, #333);
	background: transparent;
	border: 1px solid var(--wp--preset--color--theme-4, #ccc);
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

.wf-tone-toggle:hover {
	background: var(--wp--preset--color--theme-5, #f2f2f2);
}

.wf-tone-toggle[aria-pressed="true"] {
	border-color: var(--wp--preset--color--theme-3, #3355ff);
}

.wf-tone-toggle__icon {
	width: 1.1em;
	height: 1.1em;
	background: var(--wp--preset--color--theme-3, #3355ff);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.5 14.5A8.5 8.5 0 0 1 9.5 3.5a8.5 8.5 0 1 0 11 11z'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.5 14.5A8.5 8.5 0 0 1 9.5 3.5a8.5 8.5 0 1 0 11 11z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.wf-tone-toggle[aria-pressed="true"] .wf-tone-toggle__icon {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Cpath d='M12 1.5v3M12 19.5v3M1.5 12h3M19.5 12h3M4.6 4.6l2.1 2.1M17.3 17.3l2.1 2.1M4.6 19.4l2.1-2.1M17.3 6.7l2.1-2.1' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Cpath d='M12 1.5v3M12 19.5v3M1.5 12h3M19.5 12h3M4.6 4.6l2.1 2.1M17.3 17.3l2.1 2.1M4.6 19.4l2.1-2.1M17.3 6.7l2.1-2.1' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

@media print {
	.wf-tone-toggle,
	.wf-lb-open::after {
		display: none;
	}
}
