/**
 * Beatrice and the London Bus — theme styles.
 *
 * theme.json carries the palette, the type scale and the block defaults.
 * This file adds the illustrated extras that a block theme cannot express in
 * JSON: the sticker cards, the cloud panels, the wavy section edges and the
 * sticky header behaviour. It is loaded on the front end and in the editor.
 */

:root {
	--blb-radius-card: 24px;
	--blb-radius-cloud: 46px;
	--blb-outline: 3px;
	--blb-header-height: 96px;
	--blb-transition: 0.2s cubic-bezier(0.2, 0.7, 0.3, 1);

	/*
	 * Banner veils.
	 *
	 * The Cover block can only lay a flat colour over its image at a chosen
	 * opacity, which would fog the whole illustration. These banners use a
	 * directional gradient instead — opaque where the words are, clear where
	 * the Bus and Beatrice are — so the block's own Opacity slider is overridden
	 * further down and does nothing.
	 *
	 * To make a banner show more of its illustration, lower these numbers from
	 * Appearance -> Editor -> Styles -> Additional CSS:
	 *
	 *     :root { --blb-hero-scrim: 0.7; --blb-page-header-scrim: 0.6; }
	 *
	 * 1 = solid white, 0 = no veil at all.
	 */
	--blb-hero-scrim: 0.94;
	--blb-hero-scrim-reach: 72%;
	--blb-page-header-scrim: 0.86;
}

/* ---------------------------------------------------------------- helpers */

.blb-skip-link:focus {
	z-index: 1000;
}

body {
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	overflow-x: hidden;
}

::selection {
	background: var(--wp--preset--color--sunshine);
	color: var(--wp--preset--color--contrast);
}

:where(a, button, .wp-block-button__link, input, select, textarea, summary):focus-visible {
	outline: 3px solid var(--wp--preset--color--secondary);
	outline-offset: 3px;
	border-radius: 6px;
}

/* ----------------------------------------------------------------- header */

.blb-header {
	position: sticky;
	top: 0;
	z-index: 90;
	background: var(--wp--preset--color--base);
	border-bottom: 3px solid var(--wp--preset--color--mint);
	transition: box-shadow var(--blb-transition), border-color var(--blb-transition);
}

.blb-header.is-scrolled {
	box-shadow: 0 6px 24px rgba(26, 26, 26, 0.09);
	border-bottom-color: transparent;
}

.blb-header .wp-block-site-logo img {
	max-height: 62px;
	width: auto;
	transition: max-height var(--blb-transition);
}

.blb-header.is-scrolled .wp-block-site-logo img {
	max-height: 48px;
}

/* Wordmark shown when no logo image is set. */
.blb-wordmark .wp-block-site-title a {
	letter-spacing: -0.02em;
}

/* Main navigation ---------------------------------------------------------*/

.blb-header .wp-block-navigation {
	--navigation-layout-align: center;
	font-weight: 500;
}

.blb-header .wp-block-navigation .wp-block-navigation-item__content {
	padding: 0.45rem 0.2rem;
	position: relative;
}

.blb-header .wp-block-navigation .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	left: 0.2rem;
	right: 0.2rem;
	bottom: 0.1rem;
	height: 3px;
	border-radius: 3px;
	background: var(--wp--preset--color--primary);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--blb-transition);
}

.blb-header .wp-block-navigation .wp-block-navigation-item__content:hover::after,
.blb-header .wp-block-navigation .current-menu-item > .wp-block-navigation-item__content::after,
.blb-header .wp-block-navigation .current-menu-ancestor > .wp-block-navigation-item__content::after {
	transform: scaleX(1);
}

.blb-header .wp-block-navigation .current-menu-item > .wp-block-navigation-item__content {
	color: var(--wp--preset--color--primary);
}

/* Sub-menus */
.wp-block-navigation .wp-block-navigation__submenu-container {
	border: 2px solid var(--wp--preset--color--mint);
	border-radius: 18px;
	box-shadow: var(--wp--preset--shadow--soft);
	padding: 0.4rem;
	overflow: hidden;
}

.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	border-radius: 12px;
	padding: 0.5rem 0.9rem;
}

/* The mobile overlay gets the brand green so it does not read as a bare sheet. */
.wp-block-navigation__responsive-container.is-menu-open {
	background-color: var(--wp--preset--color--mint) !important;
	padding-top: clamp(3rem, 12vw, 5rem);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--x-large);
}

.wp-block-navigation__responsive-container-open,
.wp-block-navigation__responsive-container-close {
	color: var(--wp--preset--color--primary);
}

/* ------------------------------------------------------------------- hero */

.blb-hero {
	position: relative;
	isolation: isolate;
}

.blb-hero .wp-block-cover__background {
	/* Keeps the left-hand copy readable over the illustration on every width. */
	background: linear-gradient(
		100deg,
		rgba(255, 255, 255, var(--blb-hero-scrim)) 0%,
		rgba(255, 255, 255, calc(var(--blb-hero-scrim) * 0.92)) 32%,
		rgba(255, 255, 255, calc(var(--blb-hero-scrim) * 0.32)) 55%,
		rgba(255, 255, 255, 0) var(--blb-hero-scrim-reach)
	) !important;
	opacity: 1 !important;
}

/*
 * The height of a Cover block is written inline by the editor, so it is left
 * alone here: whatever an editor sets under "Minimum height of cover" is what
 * the page uses. Only on small screens do we override it, because a banner
 * sized for a desktop leaves a phone scrolling through empty sky.
 */
@media (max-width: 781px) {
	.blb-hero.wp-block-cover {
		min-height: 520px !important;
	}
}

.blb-hero__inner {
	max-width: 620px;
	margin-inline-end: auto;
}

.blb-hero__eyebrow {
	display: inline-block;
	background: var(--wp--preset--color--sunshine);
	color: var(--wp--preset--color--contrast);
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	font-size: 0.8125rem;
	padding: 0.4rem 1rem;
	border-radius: 999px;
	transform: rotate(-1.5deg);
}

@media (max-width: 781px) {
	/* On a phone the copy sits above the illustration, so the veil turns vertical. */
	.blb-hero .wp-block-cover__background {
		background: linear-gradient(
			180deg,
			rgba(255, 255, 255, calc(var(--blb-hero-scrim) * 0.98)) 0%,
			rgba(255, 255, 255, calc(var(--blb-hero-scrim) * 0.85)) 46%,
			rgba(255, 255, 255, calc(var(--blb-hero-scrim) * 0.11)) 78%,
			rgba(255, 255, 255, 0) 100%
		) !important;
	}

	.blb-hero__inner {
		max-width: none;
	}
}

/* --------------------------------------------------------- section edges */

/* A hand-cut wavy edge along the top of a coloured section. */
.is-style-blb-wave-top {
	position: relative;
}

.is-style-blb-wave-top::before {
	content: "";
	position: absolute;
	inset-inline: 0;
	top: -1px;
	height: 46px;
	background-color: inherit;
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 46' preserveAspectRatio='none'%3E%3Cpath d='M0 46V16c60-14 120-16 180-6s120 20 180 10 120-26 180-24 120 22 180 26 120-6 180-16 120-14 180-2v42z' fill='%23000'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 46' preserveAspectRatio='none'%3E%3Cpath d='M0 46V16c60-14 120-16 180-6s120 20 180 10 120-26 180-24 120 22 180 26 120-6 180-16 120-14 180-2v42z' fill='%23000'/%3E%3C/svg%3E");
	-webkit-mask-size: 100% 100%;
	mask-size: 100% 100%;
	transform: translateY(-45px);
	pointer-events: none;
}

/* ------------------------------------------------------------------ cards */

/* Sticker card: white panel, ink outline, offset shadow. */
.is-style-blb-sticker {
	background: var(--wp--preset--color--base);
	border: var(--blb-outline) solid var(--wp--preset--color--contrast);
	border-radius: var(--blb-radius-card);
	box-shadow: 8px 8px 0 rgba(26, 26, 26, 0.12);
	transition: transform var(--blb-transition), box-shadow var(--blb-transition);
}

.is-style-blb-sticker:hover {
	transform: translate(-3px, -3px);
	box-shadow: 12px 12px 0 rgba(26, 26, 26, 0.16);
}

/* Cloud panel: the soft white speech-bubble shape from the book covers. */
.is-style-blb-cloud {
	background: var(--wp--preset--color--base);
	border-radius: var(--blb-radius-cloud);
	box-shadow: var(--wp--preset--shadow--soft);
}

/* Generic content card used by the book, character and news grids. */
.is-style-blb-card {
	background: var(--wp--preset--color--base);
	border-radius: var(--blb-radius-card);
	padding: clamp(1.25rem, 3vw, 1.75rem);
	box-shadow: 0 8px 26px rgba(26, 26, 26, 0.08);
	transition: transform var(--blb-transition), box-shadow var(--blb-transition);
}

.is-style-blb-card:hover {
	transform: translateY(-6px);
	box-shadow: 0 18px 42px rgba(26, 26, 26, 0.14);
}

.is-style-blb-card-row {
	align-items: stretch;
}

/* ------------------------------------------------------------ book covers */

.is-style-blb-book-cover img {
	border-radius: 10px;
	box-shadow: 0 16px 34px rgba(26, 26, 26, 0.24), -8px 0 0 -2px rgba(26, 26, 26, 0.10);
	transition: transform var(--blb-transition), box-shadow var(--blb-transition);
	aspect-ratio: 2 / 3;
	object-fit: cover;
	width: 100%;
}

.is-style-blb-book-cover:hover img {
	transform: translateY(-8px) rotate(-1.2deg);
	box-shadow: 0 26px 50px rgba(26, 26, 26, 0.28), -8px 0 0 -2px rgba(26, 26, 26, 0.12);
}

.is-style-blb-tilt img {
	transform: rotate(-2.5deg);
	box-shadow: var(--wp--preset--shadow--lifted);
}

/*
 * Author portrait. Capped deliberately small: the supplied photograph is only
 * 150x200px, and stretching it across a column makes it look broken. Once a
 * higher-resolution photo is available, raise or remove the max-width.
 */
.blb-portrait img {
	max-width: 320px;
	width: 100%;
	margin-inline: auto;
	display: block;
}

/* --------------------------------------------------------------- headings */

.is-style-blb-underline {
	position: relative;
	display: inline-block;
	padding-bottom: 0.35em;
}

.is-style-blb-underline::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 12px;
	background: no-repeat center / 100% 100%
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 12' preserveAspectRatio='none'%3E%3Cpath d='M3 8c48-6 96-7 144-3s96 6 150-2' stroke='%23D7262B' stroke-width='6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------- list */

.is-style-blb-ticks {
	list-style: none;
	padding-left: 0;
}

.is-style-blb-ticks li {
	position: relative;
	padding-left: 2.1rem;
	margin-bottom: 0.7rem;
}

.is-style-blb-ticks li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.15em;
	width: 1.4rem;
	height: 1.4rem;
	border-radius: 999px;
	background: var(--wp--preset--color--tertiary)
		no-repeat center / 0.8rem
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8' stroke='%23fff' stroke-width='2.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- buttons */

.is-style-blb-buttons-tight {
	gap: 0.6rem;
}

/* Outline variant for the secondary call to action. */
.wp-block-button.is-style-outline > .wp-block-button__link {
	border-width: 3px;
	font-weight: 600;
	box-shadow: none;
}

/* An "Amazon" flavoured button: same pill, brand-neutral warm tone. */
.wp-block-button.blb-amazon > .wp-block-button__link {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.wp-block-button.blb-amazon > .wp-block-button__link:hover {
	background: var(--wp--preset--color--secondary);
}

/* -------------------------------------------------------------- news grid */

.is-style-blb-news-grid {
	gap: clamp(1.5rem, 3vw, 2.5rem) !important;
}

.is-style-blb-news-grid > li {
	background: var(--wp--preset--color--base);
	border-radius: var(--blb-radius-card);
	overflow: hidden;
	box-shadow: 0 8px 26px rgba(26, 26, 26, 0.08);
	transition: transform var(--blb-transition), box-shadow var(--blb-transition);
	display: flex;
	flex-direction: column;
}

.is-style-blb-news-grid > li:hover {
	transform: translateY(-6px);
	box-shadow: 0 18px 42px rgba(26, 26, 26, 0.14);
}

.is-style-blb-news-grid > li .wp-block-post-featured-image {
	margin: 0;
	border-radius: 0;
}

.is-style-blb-news-grid > li .wp-block-post-featured-image img {
	border-radius: 0;
	aspect-ratio: 3 / 2;
	object-fit: cover;
	width: 100%;
	transition: transform 0.4s ease;
}

.is-style-blb-news-grid > li:hover .wp-block-post-featured-image img {
	transform: scale(1.04);
}

.is-style-blb-news-grid > li > :not(.wp-block-post-featured-image) {
	margin-inline: clamp(1.1rem, 2.5vw, 1.6rem);
}

.is-style-blb-news-grid > li > :first-child {
	margin-top: 0;
}

.is-style-blb-news-grid > li > :last-child {
	margin-bottom: clamp(1.25rem, 3vw, 1.75rem);
}

/* ------------------------------------------------------------ pill labels */

.blb-pill {
	display: inline-block;
	padding: 0.32rem 0.9rem;
	border-radius: 999px;
	font-family: var(--wp--preset--font-family--heading);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	background: var(--wp--preset--color--mint);
	color: var(--wp--preset--color--tertiary-dark);
}

.blb-pill--red { background: var(--wp--preset--color--primary); color: #fff; }
.blb-pill--blue { background: var(--wp--preset--color--secondary); color: #fff; }
.blb-pill--yellow { background: var(--wp--preset--color--sunshine); color: var(--wp--preset--color--contrast); }

.wp-block-post-terms a,
.taxonomy-category a {
	text-decoration: none;
	display: inline-block;
	padding: 0.28rem 0.8rem;
	border-radius: 999px;
	background: var(--wp--preset--color--mint);
	color: var(--wp--preset--color--tertiary-dark);
	transition: background var(--blb-transition), color var(--blb-transition);
}

.wp-block-post-terms a:hover {
	background: var(--wp--preset--color--primary);
	color: #fff;
}

/* Category list rendered as a row of pills (News page). */
.blb-category-pills.wp-block-categories-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.blb-category-pills.wp-block-categories-list li {
	margin: 0;
}

.blb-category-pills.wp-block-categories-list a {
	display: inline-block;
	padding: 0.35rem 0.95rem;
	border-radius: 999px;
	background: var(--wp--preset--color--mint);
	color: var(--wp--preset--color--tertiary-dark);
	text-decoration: none;
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
	font-size: 0.9rem;
	transition: background var(--blb-transition), color var(--blb-transition);
}

.blb-category-pills.wp-block-categories-list a:hover {
	background: var(--wp--preset--color--primary);
	color: #fff;
}

/* Illustrated page headers. Same rule as the hero: the editor owns the height. */
@media (max-width: 781px) {
	.blb-page-header.wp-block-cover {
		min-height: 320px !important;
	}
}

.blb-page-header .wp-block-cover__background {
	background: linear-gradient(
		180deg,
		rgba(255, 255, 255, calc(var(--blb-page-header-scrim) * 0.72)) 0%,
		rgba(255, 255, 255, var(--blb-page-header-scrim)) 100%
	) !important;
	opacity: 1 !important;
}

/* ----------------------------------------------------------- book details */

.blb-book-meta {
	display: grid;
	gap: 0.4rem 1.5rem;
	grid-template-columns: max-content 1fr;
	font-size: var(--wp--preset--font-size--small);
	margin: 0;
}

.blb-book-meta dt {
	font-weight: 700;
	color: var(--wp--preset--color--secondary);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 0.78rem;
	align-self: center;
}

.blb-book-meta dd {
	margin: 0;
}

.blb-badge-quote {
	border: 3px dashed var(--wp--preset--color--sunshine);
	border-radius: 20px;
	padding: 1rem 1.4rem;
	background: var(--wp--preset--color--cream);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--medium);
}

.blb-badge-quote cite {
	display: block;
	font-style: normal;
	font-size: 0.8rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wp--preset--color--contrast-soft);
	margin-top: 0.4rem;
}

/* ------------------------------------------------------------------ forms */

.blb-form {
	display: grid;
	gap: 1.1rem;
}

.blb-form__row {
	display: grid;
	gap: 0.4rem;
}

.blb-form__row--split {
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 1.1rem;
}

.blb-form label {
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
	font-size: 0.95rem;
}

.blb-form .blb-required {
	color: var(--wp--preset--color--primary);
}

.blb-form input[type="text"],
.blb-form input[type="email"],
.blb-form input[type="tel"],
.blb-form select,
.blb-form textarea {
	width: 100%;
	font: inherit;
	font-size: 1rem;
	padding: 0.8rem 1rem;
	border: 2px solid #d9e2dd;
	border-radius: 14px;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	transition: border-color var(--blb-transition), box-shadow var(--blb-transition);
}

.blb-form textarea {
	min-height: 160px;
	resize: vertical;
}

.blb-form input:focus,
.blb-form select:focus,
.blb-form textarea:focus {
	border-color: var(--wp--preset--color--secondary);
	box-shadow: 0 0 0 4px rgba(3, 109, 183, 0.14);
	outline: none;
}

.blb-form__consent {
	display: flex;
	gap: 0.7rem;
	align-items: flex-start;
	font-size: var(--wp--preset--font-size--small);
}

.blb-form__consent input {
	margin-top: 0.25rem;
	width: 1.15rem;
	height: 1.15rem;
	accent-color: var(--wp--preset--color--primary);
}

.blb-form button[type="submit"] {
	justify-self: start;
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
	font-size: 1.05rem;
	color: #fff;
	background: var(--wp--preset--color--primary);
	border: 0;
	border-radius: 999px;
	padding: 0.9rem 2.1rem;
	cursor: pointer;
	box-shadow: var(--wp--preset--shadow--soft);
	transition: transform var(--blb-transition), background var(--blb-transition);
}

.blb-form button[type="submit"]:hover {
	background: var(--wp--preset--color--primary-dark);
	transform: translateY(-2px);
}

/* Honeypot: hidden from people, visible to naive bots. */
.blb-form__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.blb-notice {
	border-radius: 16px;
	padding: 0.9rem 1.2rem;
	font-size: var(--wp--preset--font-size--small);
	border: 2px solid transparent;
}

.blb-notice--ok {
	background: var(--wp--preset--color--mint);
	border-color: var(--wp--preset--color--tertiary);
	color: var(--wp--preset--color--tertiary-dark);
}

.blb-notice--error {
	background: #fdecec;
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary-dark);
}

/* Newsletter sign-up, inline layout. */
.blb-newsletter {
	display: flex;
	flex-wrap: wrap;
	gap: 0.7rem;
	align-items: center;
}

.blb-newsletter input[type="email"] {
	flex: 1 1 260px;
	min-width: 0;
}

/* ----------------------------------------------------------------- footer */

.blb-footer {
	background: var(--wp--preset--color--secondary);
	color: #fff;
}

.blb-footer :where(h1, h2, h3, h4, h5, h6, p, li, .wp-block-site-title a) {
	color: #fff;
}

.blb-footer a:where(:not(.wp-element-button)) {
	color: #fff;
	text-decoration-color: rgba(255, 255, 255, 0.45);
}

.blb-footer a:where(:not(.wp-element-button)):hover {
	color: var(--wp--preset--color--sunshine);
	text-decoration-color: currentColor;
}

/* The logo sits on a white cloud so the red lettering keeps its contrast. */
.blb-footer__logo {
	background: #fff;
	border-radius: var(--blb-radius-cloud);
	padding: 1.1rem 1.6rem;
	display: inline-block;
}

.blb-footer__logo img {
	max-width: 260px;
	height: auto;
	display: block;
}

.blb-footer .wp-block-social-links .wp-social-link {
	background: rgba(255, 255, 255, 0.14);
	transition: transform var(--blb-transition), background var(--blb-transition);
}

.blb-footer .wp-block-social-links .wp-social-link:hover {
	background: var(--wp--preset--color--sunshine);
	transform: translateY(-3px);
}

.blb-footer .wp-block-social-links .wp-social-link:hover a {
	color: var(--wp--preset--color--contrast);
}

.blb-footer__legal {
	border-top: 1px solid rgba(255, 255, 255, 0.24);
	font-size: var(--wp--preset--font-size--small);
}

/* --------------------------------------------------------- misc polishing */

.wp-block-post-content > .alignwide,
.wp-block-post-content > .alignfull {
	margin-block: var(--wp--preset--spacing--40);
}

.wp-block-query-pagination {
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
}

.wp-block-query-pagination .page-numbers {
	display: inline-grid;
	place-items: center;
	min-width: 2.6rem;
	height: 2.6rem;
	padding-inline: 0.5rem;
	border-radius: 999px;
	text-decoration: none;
	background: var(--wp--preset--color--mint);
	color: var(--wp--preset--color--contrast);
}

.wp-block-query-pagination .page-numbers.current,
.wp-block-query-pagination .page-numbers:hover {
	background: var(--wp--preset--color--primary);
	color: #fff;
}

.wp-block-search__button,
.wp-block-file__button {
	border-radius: 999px;
}

.wp-block-post-comments-form input[type="submit"] {
	border-radius: 999px;
	background: var(--wp--preset--color--primary);
	border: 0;
	padding: 0.85rem 1.9rem;
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
}

/* Print: drop the decoration, keep the words. */
@media print {
	.blb-header,
	.blb-footer,
	.wp-block-navigation,
	.blb-hero {
		display: none !important;
	}
}

/* Respect a reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
