/* ==========================================================================
   Overgrowth — botanical layer for the Rae Writes block theme.
   The art in ../img is single-colour SVG used as CSS masks, so every vine,
   leaf and moss edge takes its colour from the palette (and style variation).
   ========================================================================== */

:root {
	--og-ink-soft: color-mix(in srgb, var(--wp--preset--color--contrast) 72%, var(--wp--preset--color--base));
	--og-leaf-radius: 26px 4px 26px 4px;
	--og-ease: cubic-bezier(.2, .7, .2, 1);
}

/* Paper grain over the whole page ---------------------------------------- */
body {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .15 .14 0 0 0 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

/* Fraunces' soft, slightly wonky cut makes headings feel hand-grown. */
h1, h2, h3, h4, h5, h6,
.wp-block-site-title,
.wp-block-pullquote,
.wp-block-quote,
.wp-block-query-pagination {
	font-variation-settings: "SOFT" 100, "WONK" 1;
}

::selection {
	background: var(--wp--preset--color--lichen);
	color: var(--wp--preset--color--canopy);
}

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

.og-hand,
.is-style-hand {
	font-family: var(--wp--preset--font-family--hand) !important;
	font-weight: 700;
	letter-spacing: 0;
	font-variation-settings: normal;
}

/* ==========================================================================
   Header — under the canopy, with ivy hanging over the page
   ========================================================================== */
.og-header {
	position: relative;
	z-index: 30;
}

.og-header::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% - 2px);
	height: 120px;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/hanging-ivy.svg") repeat-x left top / 480px 140px;
	mask: url("../img/hanging-ivy.svg") repeat-x left top / 480px 140px;
	transform-origin: 50% 0;
	animation: og-sway 11s ease-in-out infinite alternate;
	pointer-events: none;
}

/* a second, darker layer offset behind gives the ivy depth */
.og-header::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% - 4px);
	height: 90px;
	background: var(--wp--preset--color--canopy);
	-webkit-mask: url("../img/hanging-ivy.svg") repeat-x -190px top / 400px 117px;
	mask: url("../img/hanging-ivy.svg") repeat-x -190px top / 400px 117px;
	opacity: .85;
	transform-origin: 50% 0;
	animation: og-sway 14s ease-in-out -4s infinite alternate-reverse;
	pointer-events: none;
}

.og-header .wp-block-site-title a,
.og-header .wp-block-site-title {
	color: var(--wp--preset--color--lichen);
}

.og-header .wp-block-site-tagline {
	color: var(--wp--preset--color--accent-soft);
}

.og-header .wp-block-navigation a:where(:not(.wp-element-button)) {
	position: relative;
	padding-block: .3em;
}

.og-header .wp-block-navigation .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -2px;
	height: 12px;
	background: currentColor;
	-webkit-mask: url("../img/vine-rule.svg") repeat-x left center / 110px 12px;
	mask: url("../img/vine-rule.svg") repeat-x left center / 110px 12px;
	clip-path: inset(0 100% 0 0);
	transition: clip-path .5s var(--og-ease);
}

.og-header .wp-block-navigation .wp-block-navigation-item__content:hover::after,
.og-header .wp-block-navigation .wp-block-navigation-item__content:focus-visible::after,
.og-header .wp-block-navigation .current-menu-item > .wp-block-navigation-item__content::after {
	clip-path: inset(0 0 0 0);
}

.wp-block-navigation__responsive-container.is-menu-open {
	background-image:
		radial-gradient(ellipse at 100% 0%, color-mix(in srgb, var(--wp--preset--color--primary) 35%, transparent), transparent 60%);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--x-large);
	font-variation-settings: "SOFT" 100, "WONK" 1;
}

/* Main content needs to start below the hanging ivy. */
.og-main {
	position: relative;
	z-index: 1;
}

/* ==========================================================================
   Hero — ferns in the margins
   ========================================================================== */
.og-hero {
	position: relative;
	overflow: hidden;
	isolation: isolate;
}

.og-hero::before,
.og-hero::after {
	content: "";
	position: absolute;
	bottom: -40px;
	width: clamp(140px, 22vw, 300px);
	aspect-ratio: 220 / 520;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/fern.svg") no-repeat center / contain;
	mask: url("../img/fern.svg") no-repeat center / contain;
	z-index: -1;
	pointer-events: none;
	opacity: .5;
}

.og-hero::before {
	left: max(-40px, calc(50% - 760px));
	transform: rotate(-14deg);
	transform-origin: bottom center;
	animation: og-breathe 9s ease-in-out infinite alternate;
}

.og-hero::after {
	right: max(-30px, calc(50% - 740px));
	transform: scaleX(-1) rotate(-10deg);
	transform-origin: bottom center;
	opacity: .32;
	width: clamp(110px, 17vw, 240px);
	animation: og-breathe-flip 12s ease-in-out -3s infinite alternate;
}

.og-hero .og-kicker {
	color: var(--wp--preset--color--accent);
}

.og-hero h1 em,
.og-hero h2 em {
	color: var(--wp--preset--color--primary-deep);
	font-weight: 400;
}

/* A single little sprout above a heading */
.og-sprout {
	display: block;
	width: 44px;
	height: 44px;
	margin-inline: auto;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/sprout.svg") no-repeat center / contain;
	mask: url("../img/sprout.svg") no-repeat center / contain;
}

/* ==========================================================================
   Moss growing along section edges
   ========================================================================== */
.is-style-moss-edge,
.og-footer {
	position: relative;
}

.is-style-moss-edge::before,
.og-footer::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: calc(100% - 1px);
	height: 30px;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/moss-edge.svg") repeat-x left bottom / 240px 34px;
	mask: url("../img/moss-edge.svg") repeat-x left bottom / 240px 34px;
	pointer-events: none;
}

.is-style-moss-edge.has-background::before {
	background: inherit;
	background-image: none;
}

/* ==========================================================================
   Post cards — mossy stones that grow a vine when you linger
   ========================================================================== */
.og-cards .wp-block-post-template {
	gap: var(--wp--preset--spacing--40);
}

.og-card,
.is-style-mossy-stone {
	position: relative;
	background: var(--wp--preset--color--base);
	border-radius: var(--og-leaf-radius);
	box-shadow: var(--wp--preset--shadow--leaf-litter);
	transition: transform .5s var(--og-ease), box-shadow .5s var(--og-ease);
}

.og-card {
	height: 100%;
	display: flex;
	flex-direction: column;
}

.og-card > .wp-block-post-featured-image {
	margin: 0;
	overflow: hidden;
	border-radius: 26px 4px 0 0;
}

.og-card > .wp-block-post-featured-image img {
	transition: transform 1.2s var(--og-ease), filter 1.2s var(--og-ease);
	filter: saturate(.9) sepia(.08);
}

.og-card:hover > .wp-block-post-featured-image img {
	transform: scale(1.04);
	filter: none;
}

/* moss on the top edge of each stone */
.og-card::before,
.is-style-mossy-stone::before {
	content: "";
	position: absolute;
	top: -15px;
	left: 34%;
	right: 22px;
	height: 18px;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/moss-edge.svg") repeat-x left bottom / 160px 23px;
	mask: url("../img/moss-edge.svg") repeat-x left bottom / 160px 23px;
	pointer-events: none;
	z-index: 2;
}

/* vine that creeps over the corner on hover */
.og-card::after,
.is-style-mossy-stone::after {
	content: "";
	position: absolute;
	top: -10px;
	left: -10px;
	width: 130px;
	aspect-ratio: 1;
	background: var(--wp--preset--color--primary-deep);
	-webkit-mask: url("../img/vine-corner.svg") no-repeat left top / contain;
	mask: url("../img/vine-corner.svg") no-repeat left top / contain;
	transform: scale(.35);
	transform-origin: 0 0;
	opacity: 0;
	transition: transform .9s var(--og-ease), opacity .6s ease;
	pointer-events: none;
	z-index: 2;
}

.og-card:hover,
.og-card:focus-within,
.is-style-mossy-stone:hover {
	transform: translateY(-3px) rotate(-.3deg);
	box-shadow: 0 1px 0 rgba(28, 36, 27, .06), 0 22px 40px -18px rgba(28, 36, 27, .45);
}

.og-card:hover::after,
.og-card:focus-within::after,
.is-style-mossy-stone:hover::after {
	transform: scale(1);
	opacity: 1;
}

.og-card .og-card__body {
	flex: 1;
}

.og-card .wp-block-post-title a {
	background-image: linear-gradient(var(--wp--preset--color--lichen), var(--wp--preset--color--lichen));
	background-size: 0% .35em;
	background-position: 0 88%;
	background-repeat: no-repeat;
	transition: background-size .6s var(--og-ease);
}

.og-card:hover .wp-block-post-title a,
.og-card .wp-block-post-title a:focus-visible {
	background-size: 100% .35em;
}

.og-card .wp-block-post-excerpt__more-text {
	margin-top: .8em;
}

.og-card .wp-block-post-excerpt__more-link {
	font-family: var(--wp--preset--font-family--hand);
	font-size: 1.3rem;
	font-weight: 700;
	text-decoration: none;
	color: var(--wp--preset--color--accent);
}

.og-card .wp-block-post-excerpt__more-link::after {
	content: " ⟶";
}

/* ==========================================================================
   Overgrown block style — vines claim two corners
   ========================================================================== */
.is-style-overgrown:not(.wp-block-image) {
	position: relative;
	isolation: isolate;
}

.is-style-overgrown:not(.wp-block-image)::before,
.is-style-overgrown:not(.wp-block-image)::after {
	content: "";
	position: absolute;
	width: clamp(140px, 24vw, 260px);
	aspect-ratio: 1;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/vine-corner.svg") no-repeat left top / contain;
	mask: url("../img/vine-corner.svg") no-repeat left top / contain;
	pointer-events: none;
	z-index: 1;
}

.is-style-overgrown:not(.wp-block-image)::before {
	top: -14px;
	left: -14px;
}

.is-style-overgrown:not(.wp-block-image)::after {
	bottom: -14px;
	right: -14px;
	transform: rotate(180deg);
	background: var(--wp--preset--color--primary-deep);
	opacity: .85;
}

/* Images wrapped in a vine */
.wp-block-image.is-style-overgrown {
	position: relative;
}

.wp-block-image.is-style-overgrown img {
	border-radius: var(--og-leaf-radius);
}

.wp-block-image.is-style-overgrown::before {
	content: "";
	position: absolute;
	top: -18px;
	left: -18px;
	width: min(45%, 220px);
	aspect-ratio: 1;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/vine-corner.svg") no-repeat left top / contain;
	mask: url("../img/vine-corner.svg") no-repeat left top / contain;
	z-index: 1;
	pointer-events: none;
}

.wp-block-image.is-style-pebble img {
	border-radius: 58% 42% 52% 48% / 46% 56% 44% 54%;
}

.wp-block-image.is-style-pressed,
.is-style-pressed:not(.wp-block-image) {
	position: relative;
	background: color-mix(in srgb, var(--wp--preset--color--base) 70%, white);
	padding: 14px 14px 10px;
	box-shadow: var(--wp--preset--shadow--leaf-litter);
	transform: rotate(-1.2deg);
}

.wp-block-image.is-style-pressed::before,
.wp-block-image.is-style-pressed::after,
.is-style-pressed:not(.wp-block-image)::before,
.is-style-pressed:not(.wp-block-image)::after {
	content: "";
	position: absolute;
	width: 92px;
	height: 26px;
	background: color-mix(in srgb, var(--wp--preset--color--accent-soft) 55%, transparent);
	top: -10px;
	pointer-events: none;
}

.wp-block-image.is-style-pressed::before,
.is-style-pressed:not(.wp-block-image)::before {
	left: 12%;
	transform: rotate(-7deg);
}

.wp-block-image.is-style-pressed::after,
.is-style-pressed:not(.wp-block-image)::after {
	right: 10%;
	transform: rotate(5deg);
}

.wp-block-image.is-style-pressed figcaption {
	text-align: center;
	margin-bottom: 0;
}

/* ==========================================================================
   Separators, lists, quotes
   ========================================================================== */
.wp-block-separator.is-style-vine {
	border: 0 !important;
	height: 36px;
	width: min(100%, 640px) !important;
	max-width: none;
	background: var(--wp--preset--color--primary) !important;
	-webkit-mask: url("../img/vine-rule.svg") repeat-x center / 320px 36px;
	mask: url("../img/vine-rule.svg") repeat-x center / 320px 36px;
	opacity: 1;
	margin-inline: auto !important;
}

.wp-block-separator.is-style-vine.has-background {
	background: currentColor !important;
}

.wp-block-separator.is-style-sprout {
	border: 0 !important;
	height: 48px;
	width: 48px !important;
	background: var(--wp--preset--color--primary) !important;
	-webkit-mask: url("../img/sprout.svg") no-repeat center / contain;
	mask: url("../img/sprout.svg") no-repeat center / contain;
	margin-inline: auto !important;
	opacity: 1;
}

ul.is-style-leaves {
	list-style: none;
	padding-left: 1.8em;
}

ul.is-style-leaves li {
	position: relative;
}

ul.is-style-leaves li + li {
	margin-top: .35em;
}

ul.is-style-leaves li::before {
	content: "";
	position: absolute;
	left: -1.7em;
	top: .3em;
	width: 1.15em;
	height: 1.15em;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/leaf.svg") no-repeat center / contain;
	mask: url("../img/leaf.svg") no-repeat center / contain;
}

ul.is-style-leaves li:nth-child(3n+2)::before {
	transform: rotate(18deg);
	background: var(--wp--preset--color--sage);
}

ul.is-style-leaves li:nth-child(3n)::before {
	transform: rotate(-12deg) scaleX(-1);
	background: var(--wp--preset--color--primary-deep);
}

.wp-block-quote.is-style-fern {
	position: relative;
	border-left: 0 !important;
	padding-left: 3.2rem !important;
}

.wp-block-quote.is-style-fern::before {
	content: "";
	position: absolute;
	left: 0;
	top: -.3em;
	bottom: -.3em;
	width: 2.4rem;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url("../img/fern.svg") no-repeat center top / contain;
	mask: url("../img/fern.svg") no-repeat center top / contain;
}

.wp-block-pullquote {
	position: relative;
}

.wp-block-pullquote::before {
	content: "";
	display: block;
	height: 36px;
	width: min(70%, 420px);
	margin: 0 auto 1.2rem;
	background: var(--wp--preset--color--sage);
	-webkit-mask: url("../img/vine-rule.svg") repeat-x center / 320px 36px;
	mask: url("../img/vine-rule.svg") repeat-x center / 320px 36px;
}

/* ==========================================================================
   Reading — single posts and pages
   ========================================================================== */
.og-prose {
	font-size: clamp(1.08rem, 1rem + .3vw, 1.2rem);
}

.og-prose > p:first-of-type::first-letter,
.has-drop-cap:not(:focus)::first-letter {
	float: left;
	font-family: var(--wp--preset--font-family--display);
	font-variation-settings: "SOFT" 100, "WONK" 1;
	font-weight: 600;
	font-style: italic;
	font-size: 4.6em;
	line-height: .82;
	margin: .06em .12em 0 -.02em;
	color: var(--wp--preset--color--primary-deep);
	text-transform: none;
}

.og-prose a {
	text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
	text-underline-offset: .18em;
	text-decoration-thickness: 1px;
	transition: text-decoration-color .3s ease;
}

.og-prose a:hover {
	text-decoration-color: currentColor;
}

.og-entry-head {
	position: relative;
}

.og-entry-head .wp-block-post-terms a {
	color: var(--wp--preset--color--accent);
}

.og-featured img {
	border-radius: var(--og-leaf-radius);
}

/* Comments */
.wp-block-comments {
	border-top: 0;
}

.wp-block-comment-template li {
	list-style: none;
}

.wp-block-comment-template > li {
	padding: var(--wp--preset--spacing--30);
	background: var(--wp--preset--color--surface);
	border-radius: var(--og-leaf-radius);
	margin-bottom: var(--wp--preset--spacing--30);
}

.wp-block-post-comments-form input:not([type="submit"]):not([type="checkbox"]),
.wp-block-post-comments-form textarea,
.wp-block-search__input {
	background: color-mix(in srgb, var(--wp--preset--color--base) 60%, white);
	border: 1px solid var(--wp--preset--color--sage);
	border-radius: 14px 3px 14px 3px;
	padding: .7em .9em;
	color: var(--wp--preset--color--contrast);
}

.wp-block-search__input {
	border-radius: 22px 4px 22px 4px;
}

.wp-block-post-comments-form input[type="submit"] {
	border-radius: 22px 4px 22px 4px;
}

.wp-block-search__inside-wrapper {
	border: 0 !important;
	padding: 0 !important;
	gap: .5rem;
}

/* Pagination */
.wp-block-query-pagination a,
.wp-block-query-pagination .page-numbers {
	text-decoration: none;
}

.wp-block-query-pagination-numbers .page-numbers {
	display: inline-grid;
	place-items: center;
	min-width: 2.2em;
	height: 2.2em;
	border-radius: 50% 50% 50% 8%;
}

.wp-block-query-pagination-numbers .page-numbers.current {
	background: var(--wp--preset--color--primary-deep);
	color: var(--wp--preset--color--base);
}

/* Post navigation */
.og-post-nav a {
	font-family: var(--wp--preset--font-family--display);
	font-variation-settings: "SOFT" 100, "WONK" 1;
	text-decoration: none;
	font-size: 1.15rem;
}

/* ==========================================================================
   Footer — the forest floor, with fireflies
   ========================================================================== */
.og-footer {
	isolation: isolate;
	margin-top: 30px;
}

.og-footer::before {
	background: var(--wp--preset--color--canopy);
	height: 34px;
	-webkit-mask-size: 300px 42px;
	mask-size: 300px 42px;
}

.og-footer a {
	color: var(--wp--preset--color--lichen);
	text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
	text-underline-offset: .2em;
}

.og-footer a:hover,
.og-footer a:focus-visible {
	color: var(--wp--preset--color--accent-soft);
}

.og-footer .wp-block-site-title a {
	text-decoration: none;
}

.og-footer .wp-block-navigation a {
	text-decoration: none;
}

.og-fireflies {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: -1;
}

.og-fireflies span {
	position: absolute;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: #f4f7b5;
	box-shadow: 0 0 6px 2px rgba(232, 244, 140, .75), 0 0 18px 6px rgba(200, 230, 110, .25);
	opacity: 0;
	animation: og-firefly 9s ease-in-out infinite;
}

.og-fireflies span:nth-child(1) { left: 8%;  top: 30%; animation-delay: 0s; }
.og-fireflies span:nth-child(2) { left: 22%; top: 70%; animation-delay: -2.2s; animation-duration: 11s; }
.og-fireflies span:nth-child(3) { left: 38%; top: 20%; animation-delay: -5s; }
.og-fireflies span:nth-child(4) { left: 54%; top: 60%; animation-delay: -1s; animation-duration: 12s; }
.og-fireflies span:nth-child(5) { left: 67%; top: 35%; animation-delay: -7s; }
.og-fireflies span:nth-child(6) { left: 79%; top: 75%; animation-delay: -3.4s; animation-duration: 10s; }
.og-fireflies span:nth-child(7) { left: 90%; top: 25%; animation-delay: -6s; }
.og-fireflies span:nth-child(8) { left: 46%; top: 85%; animation-delay: -8s; animation-duration: 13s; }

/* ==========================================================================
   404
   ========================================================================== */
.og-lost {
	position: relative;
}

.og-lost .og-big {
	font-size: clamp(6rem, 22vw, 14rem);
	line-height: .9;
	color: var(--wp--preset--color--primary);
	font-variation-settings: "SOFT" 100, "WONK" 1;
	position: relative;
	display: inline-block;
}

/* ==========================================================================
   Motion
   ========================================================================== */
@keyframes og-sway {
	from { transform: skewX(-1.6deg); }
	to   { transform: skewX(1.6deg); }
}

@keyframes og-breathe {
	from { transform: rotate(-14deg); }
	to   { transform: rotate(-10deg); }
}

@keyframes og-breathe-flip {
	from { transform: scaleX(-1) rotate(-10deg); }
	to   { transform: scaleX(-1) rotate(-6deg); }
}

@keyframes og-firefly {
	0%, 100% { opacity: 0; transform: translate(0, 0); }
	20%      { opacity: .95; }
	45%      { opacity: .2; transform: translate(26px, -18px); }
	65%      { opacity: 1; transform: translate(-12px, -34px); }
	85%      { opacity: .1; transform: translate(10px, -10px); }
}

@media (prefers-reduced-motion: reduce) {
	.og-header::before,
	.og-header::after,
	.og-hero::before,
	.og-hero::after,
	.og-fireflies span {
		animation: none !important;
	}

	.og-fireflies span {
		opacity: .6;
	}

	.og-card,
	.og-card::after,
	.og-card img,
	.is-style-mossy-stone,
	.is-style-mossy-stone::after {
		transition: none !important;
	}
}

/* ==========================================================================
   Small screens
   ========================================================================== */
@media (max-width: 781px) {
	.og-header::after {
		height: 80px;
		-webkit-mask-size: 330px 96px;
		mask-size: 330px 96px;
	}

	.og-header::before {
		height: 60px;
		-webkit-mask-size: 280px 82px;
		mask-size: 280px 82px;
	}

	.og-hero::before {
		left: -70px;
		opacity: .28;
	}

	.og-hero::after {
		right: -60px;
		opacity: .2;
	}

	.is-style-overgrown:not(.wp-block-image)::before,
	.is-style-overgrown:not(.wp-block-image)::after {
		width: 120px;
	}
}

/* Keep the editor calm: no swaying while writing. */
.editor-styles-wrapper .og-header::before,
.editor-styles-wrapper .og-header::after,
.editor-styles-wrapper .og-hero::before,
.editor-styles-wrapper .og-hero::after {
	animation: none;
}
