/*
Theme Name: RacerPacer
Theme URI: https://builtby.racerpacer.com/kit/
Author: RacerPacer
Author URI: https://racerpacer.com
Description: A block theme for a running club's or a race organiser's site. The home page is the club's card with its next runs, upcoming events and news underneath, and every template can be changed in the Site Editor. Colours and fonts come from the RacerPacer plugin's style settings until you choose your own in Styles.
Version: 0.3.0
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.0
Update URI: https://builtby.racerpacer.com/kit/racerpacer-runs-blocks/
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: racerpacer-runs-blocks
Tags: one-column, full-site-editing, block-patterns, custom-logo, custom-menu, featured-images, blog, e-commerce
*/

/*
 * Almost everything is in theme.json. What is here is what theme.json can't say:
 * the page background pattern chosen in the plugin, and a few finishing touches.
 * Colours are the --rpkit-* custom properties functions.php writes onto :root.
 */

html {
	scrollbar-gutter: stable;
}
body {
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
}
body.rpkit-mode-dark {
	color-scheme: dark;
}

/* The page background, as chosen in Runs → Settings. */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
}
body.rpkit-bg-gradient::before {
	background: radial-gradient(120% 70% at 50% 0%, var(--rpkit-glow) 0%, var(--rpkit-bg) 70%);
}
body.rpkit-bg-contour::before {
	background: var(--rpkit-pattern);
	-webkit-mask: url("assets/img/contour.svg") center / cover no-repeat;
	mask: url("assets/img/contour.svg") center / cover no-repeat;
	/* Faint, so text over the lines stays easy to read. */
	opacity: 0.4;
}
body.rpkit-bg-dots::before {
	background-image: radial-gradient(var(--rpkit-pattern) 1.6px, transparent 1.8px);
	background-size: 22px 22px;
	-webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.35) 100%);
	mask-image: linear-gradient(180deg, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.35) 100%);
}

:focus-visible {
	outline: 3px solid var(--rpkit-accent-text);
	outline-offset: 3px;
}
h1,
h2,
h3 {
	text-wrap: balance;
}

/* Header and footer bands sit on the surface colour, above the pattern. */
.rprb-band {
	background: var(--rpkit-surface);
}
.rprb-header {
	border-bottom: 1px solid var(--rpkit-border);
}
.rprb-footer {
	border-top: 1px solid var(--rpkit-border);
}
.rprb-header .wp-block-navigation a:hover,
.rprb-header .wp-block-navigation .current-menu-item > a {
	color: var(--rpkit-accent-text);
	text-decoration: underline;
	text-underline-offset: 6px;
	text-decoration-thickness: 2px;
}

/* Cards for posts in a list, matching the run cards. */
.rprb-card {
	border-radius: 16px;
	background: var(--rpkit-surface);
	color: var(--rpkit-text);
	box-shadow: inset 0 0 0 1px var(--rpkit-border);
}
.rprb-card .wp-block-post-title a {
	text-decoration: none;
}
.rprb-card .wp-block-post-title a:hover {
	text-decoration: underline;
}
/* News cards in a grid: picture flush to the top, the rest padded, equal heights. */
.rprb-news-card {
	height: 100%;
	overflow: hidden;
}
/* One vertical gap between cards of every kind: runs, events (home grid and race finder) and news. */
.rprb {
	--rprb-card-gap-y: 28px;
}
.rprb .rpkit .rpkit-runs,
.rprb .rpkit-ev .grid-2,
.rprb .wp-block-post-template.is-layout-grid {
	row-gap: var(--rprb-card-gap-y);
}
/* News and run cards lift on hover, the same as the event cards. */
.rprb-news-card,
.rprb .rpkit .rpkit-run {
	transition: transform 0.12s, box-shadow 0.12s;
}
.rprb-news-card:hover,
.rprb .rpkit .rpkit-run:hover {
	transform: translateY(-3px);
	box-shadow: inset 0 0 0 1px var(--rpkit-border), 0 10px 0 -4px var(--rpkit-border);
}
@media (prefers-reduced-motion: reduce) {
	.rprb-news-card,
	.rprb .rpkit .rpkit-run {
		transition: none;
	}
}
.rprb-news-card .wp-block-post-featured-image {
	margin: 0;
}
.rprb-news-card .wp-block-post-featured-image img {
	border-radius: 0;
}
.rprb-news-meta {
	font-size: var(--wp--preset--font-size--small);
	color: var(--rpkit-muted);
}
.rprb-news-cat {
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 0.8125rem;
}
.rprb-news-cat a {
	color: var(--rpkit-accent-text);
	text-decoration: none;
}
.wp-block-post-featured-image img {
	border-radius: 16px;
}

/* The plugin's own chips keep their look inside the theme's button styles. */
.rpkit button.rpkit-chip {
	font-weight: 400;
}

/* The footer sits at the bottom of the window on a short page. */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}
.wp-site-blocks > main {
	flex: 1;
	width: 100%;
}
.wp-site-blocks > * {
	margin-block-start: 0;
}

/*
 * The events blocks keep to the same column as the header and footer: 1400px of
 * content plus the 16px root padding each side. Matched to the plugin's own
 * .rpkit.rpkit-ev rule and one class stronger, or the plugin's 1320px wins.
 */
.rprb .rpkit.rpkit-ev {
	--rpkit-ev-maxw: 1432px;
	--rpkit-ev-pad: 16px;
}
/*
 * A full-width events block paints the page colour by default, which hid the page
 * background (contour lines, dots, gradient) everywhere but the gap above the footer.
 * The body already paints that colour here, so let the background through.
 */
.rprb .rpkit.rpkit-ev.alignfull {
	background: transparent;
}
/* Event cards (home page, race finder) get the same rounded corners as the news and run cards. */
.rprb .rpkit-ev .card {
	border-radius: 16px;
}

/*
 * One type scale across the plugin's blocks and the theme's own, taken from theme.json:
 * page titles Huge, section headings Extra large, card titles Large, and one style for
 * the date line on every card. The plugin's events look (bigger, tighter headings,
 * capitals for dates) is left alone outside this theme.
 */
.rprb-layout-simple .rpkit .rpkit-name,
.rprb-layout-simple .rpkit-ev .page-head h1 {
	font-size: var(--wp--preset--font-size--xx-large);
	line-height: 1.1;
	letter-spacing: -0.02em;
}
.rprb-layout-simple .rpkit-ev .shead h2 {
	font-size: var(--wp--preset--font-size--x-large);
	line-height: 1.2;
	letter-spacing: -0.01em;
}
.rprb-layout-simple .rpkit .rpkit-run .rpkit-run-title,
.rprb-layout-simple .rpkit-ev .card h3,
.rprb-layout-simple .rprb-news-card .wp-block-post-title {
	/* Card titles are 120% of the body copy. */
	font-size: calc(var(--wp--preset--font-size--medium) * 1.2);
	line-height: 1.2;
	letter-spacing: -0.01em;
}
/* The first, wide card in the home page's event grid is the feature: one step up. */
.rprb-layout-simple .rpkit-ev .card.wide h3 {
	font-size: var(--wp--preset--font-size--x-large);
}
.rprb-layout-simple .rpkit .rpkit-run-when,
.rprb-layout-simple .rpkit-ev .card .when,
.rprb-layout-simple .rprb-news-card .wp-block-post-date {
	font-family: var(--rpkit-font-body);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	letter-spacing: normal;
	text-transform: none;
	color: var(--rpkit-muted);
}

/*
 * Body copy is 18px (theme.json Medium). The plugin's blocks follow it: runs sizes are
 * shares of --rpkit-em, events of --rpkit-ev-t-body. A size picked for a block in the
 * editor still wins (the plugin's own [style*="font-size"] rule sets --rpkit-em: 1em).
 */
.rprb .rpkit:not([class*="-font-size"]):not([style*="font-size"]) {
	--rpkit-em: var(--wp--preset--font-size--medium);
}
.rprb .rpkit.rpkit-ev {
	--rpkit-ev-t-body: var(--wp--preset--font-size--medium);
	--rpkit-ev-t-cap: 0.8125rem;
}
.rprb-news-card .wp-block-post-excerpt {
	font-size: var(--wp--preset--font-size--medium);
}
