/*
Theme Name: Wayfarer
Theme URI: https://travel.uudly.net/
Description: A photo-led travel blog theme, a child of Ipsum. Each post takes its colours from its featured image, and shows where its photos were taken on a map. Colour extraction and the map live in the Wayfarer Core plugin.
Author: UUDLY
Template: ipsum
Requires at least: 7.1
Tested up to: 7.1
Requires PHP: 8.1
Version: 0.2.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wayfarer
Domain Path: /languages
*/

/* Wayfarer additions go below. Ipsum's own style.css is loaded separately (see functions.php). */

/* ==========================================================================
   Accent. Ipsum defines theme-3 but never uses it; here it gets its jobs.
   On single posts the plugin sets theme-3 to a colour from the photo that
   reaches 4.5:1 on the page background, so these are safe for text too.
   ========================================================================== */

::selection {
	background: var(--wp--preset--color--theme-3);
	color: var(--wp--preset--color--theme-1);
}

:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--theme-3);
	outline-offset: 3px;
}

/* Links in the story: the dotted editorial underline, in the accent. */
.wp-block-post-content a:not(.wp-block-button__link) {
	text-decoration-color: var(--wp--preset--color--theme-3);
	text-decoration-thickness: 2px !important;
}

.wp-block-button .wp-block-button__link {
	transition: background-color 0.2s ease, color 0.2s ease;
}

.wp-block-button .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--theme-3);
	color: var(--wp--preset--color--theme-1);
}

.wp-block-quote.wp-block-quote {
	border-inline-start: 4px solid var(--wp--preset--color--theme-3);
	border-radius: 0 5px 5px 0;
}

.wp-block-quote.wp-block-quote::before {
	color: var(--wp--preset--color--theme-3);
}

.wp-block-post-terms.taxonomy-post_tag a {
	border: 1px solid var(--wp--preset--color--theme-4);
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.wp-block-post-terms.taxonomy-post_tag a:hover {
	background-color: var(--wp--preset--color--theme-3);
	border-color: var(--wp--preset--color--theme-3);
	color: var(--wp--preset--color--theme-1);
	text-decoration: none;
}

/* ==========================================================================
   Single post: hero photo, then eyebrow / title / byline
   ========================================================================== */

.wf-hero.wf-hero {
	/* The root padding would inset the photo; the hero bleeds to the edges. */
	padding-inline: 0;
}

.wf-hero .wp-block-post-featured-image {
	margin: 0;
	border-radius: 0 !important;
}

.wf-hero .wp-block-post-featured-image img {
	display: block;
	width: 100%;
	max-height: 72vh;
	border-radius: 0 !important;
	object-fit: cover;
}

@media (max-width: 600px) {
	/* A wide crop would be a sliver on a phone; give the photo real height. */
	.wf-hero .wp-block-post-featured-image img {
		aspect-ratio: 4 / 5 !important;
		max-height: 75vh;
	}
}

.wf-title-block {
	padding-top: var(--wp--preset--spacing--60);
	padding-bottom: var(--wp--preset--spacing--20);
}

.wf-title-block .wf-eyebrow-row {
	align-items: center;
	gap: var(--wp--preset--spacing--30);
}

.wf-title-block .wf-eyebrow-row::before {
	content: "";
	flex: none;
	width: 2.25rem;
	height: 3px;
	background: var(--wp--preset--color--theme-3);
}

.wf-title-block .wf-eyebrow {
	margin: 0;
	font-family: var(--wp--preset--font-family--manrope);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.wf-title-block .wf-eyebrow a {
	color: var(--wp--preset--color--theme-3);
	text-decoration: none !important;
}

.wf-title-block .wf-eyebrow a:hover {
	text-decoration: underline !important;
	text-decoration-thickness: 2px !important;
	text-underline-offset: 0.2em;
}

.wf-title-block .wf-title {
	font-family: var(--wp--preset--font-family--besley);
	font-size: clamp(2.25rem, 1.2rem + 4.6vw, 4.25rem);
	font-weight: 600;
	letter-spacing: -0.015em;
	line-height: 1.05;
	text-wrap: balance;
}

.wf-title-block .wf-meta {
	align-items: center;
	column-gap: var(--wp--preset--spacing--40);
	row-gap: var(--wp--preset--spacing--20);
}

.wf-title-block .wf-meta > * {
	margin: 0;
}

.wf-location {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	font-weight: 600;
}

.wf-location:empty {
	display: none;
}

.wf-location::before {
	content: "";
	flex: none;
	width: 1.1em;
	height: 1.1em;
	background: var(--wp--preset--color--theme-3);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5.25 7 13 7 13s7-7.75 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%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='M12 2a7 7 0 0 0-7 7c0 5.25 7 13 7 13s7-7.75 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ==========================================================================
   Cards (Keep Reading, home grid, archives): each in its own post's colours (--wf-card-* come from the
   Wayfarer Core plugin; without them a card falls back to the page's colours).
   ========================================================================== */

.wf-keep:not(:has(.wp-block-post)) {
	display: none;
}

.wf-cards .wp-block-post {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--wf-card-bg, var(--wp--preset--color--theme-5));
	color: var(--wf-card-fg, var(--wp--preset--color--theme-2));
	border: 1px solid var(--wf-card-border, var(--wp--preset--color--theme-4));
	border-radius: 12px;
	margin: 0;
}

.wf-cards .wp-block-post a {
	color: inherit;
}

.wf-cards .wp-block-post-title a:hover {
	text-decoration: underline !important;
	text-decoration-color: var(--wf-card-accent, var(--wp--preset--color--theme-3));
	text-decoration-style: solid !important;
	text-decoration-thickness: 2px !important;
}

.wf-cards .wp-block-post .wp-block-post-featured-image {
	margin: 0;
	border-radius: 0 !important;
}

.wf-cards .wp-block-post .wp-block-post-featured-image img {
	display: block;
	width: 100%;
	border-radius: 0 !important;
	object-fit: cover;
}

.wf-cards .wp-block-post-date {
	opacity: 0.75;
}

@media (prefers-reduced-motion: no-preference) {
	.wf-cards .wp-block-post {
		transition: transform 0.2s ease;
	}

	.wf-cards .wp-block-post:hover {
		transform: translateY(-3px);
	}
}

/* ==========================================================================
   Map section (the block and its pattern live in the Wayfarer Core plugin)
   ========================================================================== */

.wf-map-section {
	margin-top: var(--wp--preset--spacing--60);
}

.wf-map-section:not(:has(.wf-map)) {
	display: none;
}

.wf-map-section > h2 {
	margin-bottom: var(--wp--preset--spacing--30);
}

/* ==========================================================================
   Home and archives
   ========================================================================== */

.wf-home,
.wf-archive {
	padding-top: var(--wp--preset--spacing--50);
	padding-bottom: var(--wp--preset--spacing--70);
}

.wf-world:not(:has(.wf-map)) {
	display: none;
}

.wf-world > h2,
.wf-stories > h2 {
	margin-bottom: var(--wp--preset--spacing--30);
}

.wf-stories {
	margin-top: var(--wp--preset--spacing--70);
}

.wf-archive-head {
	padding-bottom: var(--wp--preset--spacing--50);
}

.wf-archive-title {
	margin: 0;
	font-family: var(--wp--preset--font-family--besley);
	font-size: clamp(2.25rem, 1.2rem + 4.6vw, 4rem);
	font-weight: 600;
	letter-spacing: -0.015em;
	line-height: 1.05;
	text-wrap: balance;
}

/* Card text: eyebrow, title, date and place. */
.wf-cards .wf-eyebrow {
	margin: 0;
	font-family: var(--wp--preset--font-family--manrope);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.wf-cards .wf-eyebrow a {
	color: var(--wf-card-accent, var(--wp--preset--color--theme-3));
	text-decoration: none !important;
}

.wf-cards .wp-block-post-title {
	margin: 0;
	font-family: var(--wp--preset--font-family--besley);
	line-height: 1.15;
	text-wrap: balance;
}

.wf-cards .wf-meta {
	align-items: center;
	column-gap: var(--wp--preset--spacing--30);
	row-gap: 0.15rem;
}

.wf-cards .wf-meta > * {
	margin: 0;
}

.wf-cards .wf-location::before {
	background: var(--wf-card-accent, var(--wp--preset--color--theme-3));
}

.wf-cards .wp-block-post-date {
	opacity: 0.8;
}

.wf-cards .wp-block-query-pagination {
	font-size: var(--wp--preset--font-size--small);
}

.wf-cards .wp-block-query-no-results {
	grid-column: 1 / -1;
}

/* Pagination: real tap targets, the current page in the accent. */
.wf-cards .wp-block-query-pagination-numbers {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem;
}

.wf-cards .wp-block-query-pagination-numbers .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	height: 2.5rem;
	padding: 0 0.6rem;
	border: 1px solid transparent;
	border-radius: 8px;
	text-decoration: none !important;
}

.wf-cards .wp-block-query-pagination-numbers a.page-numbers:hover {
	border-color: var(--wp--preset--color--theme-4);
}

.wf-cards .wp-block-query-pagination-numbers .page-numbers.current {
	background: var(--wp--preset--color--theme-3);
	color: var(--wp--preset--color--theme-1);
	font-weight: 700;
}

.wf-cards .wp-block-query-pagination-previous,
.wf-cards .wp-block-query-pagination-next {
	display: inline-flex;
	align-items: center;
	min-height: 2.5rem;
}

/* ==========================================================================
   Target size (WCAG 2.2 AA 2.5.8: standalone controls at least 24 x 24 px)
   ========================================================================== */

.wf-cards .wp-block-post-title a,
.wf-cards .wf-eyebrow a,
.wf-title-block .wf-eyebrow a,
.wp-block-post-author-name__link {
	display: inline-block;
	padding-block: 0.2rem;
}

.wp-block-social-links .wp-block-social-link-anchor {
	box-sizing: content-box;
	padding: 0.5rem;
}

/* ==========================================================================
   Shared photo transition (names come from the Wayfarer Core plugin)
   ========================================================================== */

::view-transition-group(*) {
	animation-duration: 0.35s;
	animation-timing-function: ease;
}

@media (prefers-reduced-motion: reduce) {
	::view-transition-group(*),
	::view-transition-old(*),
	::view-transition-new(*) {
		animation: none !important;
	}
}

/* ==========================================================================
   Motion (all of it off under prefers-reduced-motion)
   Native CSS scroll-driven animation where supported (runs off the main thread);
   motion.js in the Wayfarer Core plugin supplies the same effects elsewhere via
   html.wf-motion-js and the custom properties it sets.
   ========================================================================== */

.wf-hero .wp-block-post-featured-image {
	overflow: hidden;
}

/* The focus ring would be clipped by the hero's overflow; draw it inside. */
.wf-hero .wf-lb-open:focus-visible {
	outline-offset: -4px;
}

@keyframes wf-hero-drift {
	from {
		transform: scale(1.1) translateY(0);
	}

	to {
		transform: scale(1.1) translateY(4.5%);
	}
}

/* Text only moves (it stays fully opaque, so contrast is correct at every moment, for
   readers and for automated checkers); the photos themselves fade in. */
@keyframes wf-rise {
	from {
		transform: translateY(26px);
	}

	to {
		transform: none;
	}
}

@keyframes wf-fade-in {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.985);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@media (prefers-reduced-motion: no-preference) {
	/* Hero parallax: the photo is a little larger than its frame and drifts down slower than the page. */
	.wf-hero .wp-block-post-featured-image img {
		transform: scale(1.1);
	}

	@supports (animation-timeline: scroll()) {
		.wf-hero .wp-block-post-featured-image img {
			animation: wf-hero-drift linear both;
			animation-timeline: scroll(root block);
			animation-range: 0 90vh;
		}
	}

	html.wf-motion-js .wf-hero .wp-block-post-featured-image img {
		transform: scale(1.1) translateY(calc(var(--wf-hp, 0) * 4.5%));
	}

	/* Reveal: headings, quotes and tables rise into place; photos fade in as they enter the screen. */
	@supports (animation-timeline: view()) {
		.wp-block-post-content > :is(h2, h3, blockquote, .wp-block-table) {
			animation: wf-rise ease-out both;
			animation-timeline: view();
			animation-range: entry 0% entry 40%;
		}

		.wp-block-post-content :is(.wp-block-image, .wp-block-gallery) img {
			animation: wf-fade-in ease-out both;
			animation-timeline: view();
			animation-range: entry 0% entry 45%;
		}
	}

	html.wf-motion-js .wf-rise-pending {
		transform: translateY(26px);
		transition: transform 0.6s ease-out;
	}

	html.wf-motion-js .wf-rise-pending.is-in {
		transform: none;
	}

	html.wf-motion-js img.wf-fade-pending {
		opacity: 0;
		transform: translateY(20px) scale(0.985);
		transition: opacity 0.6s ease-out, transform 0.6s ease-out;
	}

	html.wf-motion-js img.wf-fade-pending.is-in {
		opacity: 1;
		transform: none;
	}
}

@media print {
	.wp-block-post-content > *,
	.wp-block-post-content img {
		animation: none !important;
		opacity: 1 !important;
		transform: none !important;
	}

	.wf-hero .wp-block-post-featured-image img {
		animation: none !important;
		transform: none !important;
	}
}
