/*
Theme Name: Jersey Regatta
Theme URI: https://www.jerseyregatta.com
Description: Child theme of Twenty Twenty-Five for the Butterfield Jersey Regatta, organised by the Combined Yacht Clubs of Jersey.
Template: twentytwentyfive
Version: 0.5.7
Requires at least: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: jersey-regatta
*/

/*
 * Colours, fonts, the heading scale (H2 22px, H3 18px) and buttons live in theme.json.
 * This file only holds what theme.json can't express. Sections:
 *   1. Header (over the photo)      5. Document rows + noticeboard sections
 *   2. Main menu                    6. Link cards (Sailor info)
 *   3. Hero and page banners        7. Footer
 *   4. Page content                 8. Utilities (incl. outline controls), reduced motion
 */

/* ---------- 1. Header ---------------------------------------------------------------------
   Where the page starts with the hero or a page banner, the header is laid transparently over
   the top of the photo. Pages without one (e.g. 404, search) keep the solid navy bar. */
:root {
	--jr-header-h: 93px; /* measured: logo 53px + header padding */
	--jr-speed: 0.15s;   /* every hover/focus transition; 0s for reduced motion (section 8) */
}
.wp-site-blocks {
	position: relative;
}
.wp-site-blocks:has(.jr-hero, .jr-page-banner) > header.wp-block-template-part {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 20;
}
.wp-site-blocks:has(.jr-hero, .jr-page-banner) .jr-site-header.has-background {
	background-color: transparent !important;
}
.jr-site-header a,
.jr-site-header .wp-block-navigation-item__content {
	text-decoration: none;
}

/* Header logo = the home link. Hidden on the home page, where the big hero logo does that job. */
.jr-header-logo {
	margin: 0;
	line-height: 0;
	flex-shrink: 0;
}
.jr-header-logo img {
	display: block;
	height: auto;
	transition: opacity var(--jr-speed);
}
.jr-header-logo a:is(:hover, :focus-visible) img {
	opacity: 0.8;
}
body.home .jr-header-logo {
	visibility: hidden;
}

@media (max-width: 599px) {
	:root {
		--jr-header-h: 81px; /* measured: logo 41px + header padding */
	}
	.jr-header-logo img {
		width: 140px !important; /* overrides the block's inline width on phones */
	}
}

/* ---------- 2. Main menu ------------------------------------------------------------------ */

/* Hover: a light-blue underline; the text stays white. */
.jr-main-nav .wp-block-navigation-item__label {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 6px;
	text-decoration-color: transparent;
	transition: text-decoration-color var(--jr-speed);
}
.jr-main-nav .wp-block-navigation-item__content:is(:hover, :focus-visible) .wp-block-navigation-item__label {
	text-decoration-color: var(--wp--preset--color--accent-1);
}

/* Desktop (960px+): dropdowns hang below their own item, sized to the years, and open on
   hover/keyboard focus as well as click. (openSubmenusOnClick is on for the ☰ accordion,
   which turns core's hover off.) */
@media (min-width: 960px) {
	.jr-main-nav .wp-block-navigation__responsive-container:not(.is-menu-open) .has-child > .wp-block-navigation__submenu-container {
		left: 0;
		right: auto;
		min-width: 8rem !important;
		width: max-content;
	}
}
@media (hover: hover) and (min-width: 960px) {
	.jr-main-nav .wp-block-navigation__responsive-container:not(.is-menu-open) .has-child:is(:hover, :focus-within) > .wp-block-navigation__submenu-container {
		visibility: visible;
		overflow: visible;
		opacity: 1;
		width: auto;
		height: auto;
		min-width: 200px;
	}
}

/* Below 960px use the ☰ overlay instead of wrapping onto two lines (core switches at 600px). */
@media (min-width: 600px) and (max-width: 959px) {
	.jr-main-nav .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}
	.jr-main-nav .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

/* ☰ overlay: keep the Race reports / Photos years folded until tapped.
   (Core always expands submenus in the overlay; assets/js/menu-accordion.js adds .jr-open.) */
.jr-main-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-submenu:not(.jr-open) > .wp-block-navigation__submenu-container.wp-block-navigation__submenu-container.wp-block-navigation__submenu-container {
	display: none;
}
.jr-main-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-submenu {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
}
.jr-main-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-submenu > .wp-block-navigation__submenu-container {
	flex-basis: 100%;
	flex-direction: column;
	align-items: flex-end;
	padding: 0.5em 1.4em 0.25em 0;
	gap: 0.6em;
	opacity: 0.85;
}
.jr-main-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-submenu__toggle {
	cursor: pointer;
}
.jr-main-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-icon {
	display: inline-block;
	margin-left: 0.4em;
	transition: transform var(--jr-speed);
	pointer-events: none;
}
.jr-main-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-submenu.jr-open > .wp-block-navigation__submenu-icon {
	transform: rotate(180deg);
}

/* No focus box when a menu item is tapped or clicked (WordPress draws one on any :focus);
   keyboard users still get it via :focus-visible. */
.jr-main-nav :is(a, button):focus:not(:focus-visible) {
	outline: none;
}

/* ---------- 3. Hero and page banners ------------------------------------------------------ */

/* Both leave room at the top for the header that sits over them. */
:is(.jr-hero, .jr-page-banner).wp-block-cover {
	padding-top: calc(var(--jr-header-h) + var(--wp--preset--spacing--20)) !important;
}
.jr-hero.wp-block-cover {
	/* Grows with the screen width so wide screens show more of the boats, not just a strip of sail. */
	min-height: clamp(420px, 32vw, 560px) !important;
}
@media (min-width: 600px) {
	/* On wide (letterbox) crops, sit lower in the photo so the hulls and crews stay in. */
	.jr-hero .wp-block-cover__image-background {
		object-position: 50% 82% !important;
	}
}
.jr-page-banner.wp-block-cover {
	padding-bottom: var(--wp--preset--spacing--50) !important;
}
.jr-page-banner .jr-page-banner__title {
	margin: 0;
	line-height: 1.15;
}
@media (max-width: 599px) {
	/* Phones: the header logo is hidden on the home page, so the hero logo moves up into the
	   header strip, level with the ☰ (narrowed so it clears the button); the hero is as tall
	   as its content rather than a fixed height. */
	.jr-hero.wp-block-cover {
		padding-top: calc(var(--jr-header-h) / 2 - 12px) !important;
		min-height: 0 !important;
	}
	.jr-hero .wp-block-image img {
		width: min(230px, 100%, 100vw - 150px) !important; /* keeps ~20px clear of the ☰ on narrow phones */
	}
	.jr-page-banner .jr-page-banner__title {
		font-size: var(--wp--preset--font-size--large);
	}
}

/* Regatta dates under the hero logo (filled from wp-admin › Regatta; hidden when empty). */
.jr-hero .jr-hero-dates {
	margin-block: var(--wp--preset--spacing--20) 0;
	color: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 500;
	letter-spacing: 0.02em;
}
@media (max-width: 1099px) {
	/* Phones and tablets: one size smaller, so the dates stay on one line and the hero stays short. */
	.jr-hero .jr-hero-dates {
		margin-top: var(--wp--preset--spacing--10, 0.5rem);
		font-size: var(--wp--preset--font-size--medium);
		letter-spacing: 0;
	}
}
@media (max-width: 479px) {
	.jr-hero .jr-hero-dates {
		font-size: 0.95rem;
	}
}
@media (max-width: 374px) {
	.jr-hero .jr-hero-dates {
		font-size: 0.875rem;
	}
}

/* Hero buttons: equal-width grid with labels on one line; 4 across from 1080px, 2 x 2 from
   560px, stacked below that. (The longest labels need ~210px.) */
.wp-block-buttons.jr-hero-buttons {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 15rem));
	justify-content: center;
}
@media (min-width: 1080px) {
	.wp-block-buttons.jr-hero-buttons {
		grid-template-columns: repeat(4, minmax(0, 15rem));
	}
}
@media (max-width: 559px) {
	.wp-block-buttons.jr-hero-buttons {
		grid-template-columns: minmax(0, 18rem);
	}
}
.jr-hero-buttons .wp-block-button {
	width: auto;
	margin: 0;
}

/* Colours and hover: see "Outline controls" in section 8. */
.jr-hero-buttons .wp-block-button.is-style-outline > .wp-block-button__link {
	display: block;
	width: 100%;
	height: 100%;
	padding: 0.75em 1em;
	white-space: nowrap;
}
.jr-hero-buttons .wp-block-button.is-style-outline > .wp-block-button__link:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-1);
	outline-offset: 3px;
}
@media (max-width: 599px) {
	.jr-hero-buttons .wp-block-button.is-style-outline > .wp-block-button__link {
		padding: 0.6em 1em;
	}
}

/* ---------- 4. Page content ---------------------------------------------------------------- */

/* Heading spacing (sizes are in theme.json). */
.wp-block-post-content h2 {
	margin-top: var(--wp--preset--spacing--50);
	margin-bottom: var(--wp--preset--spacing--20);
}
.wp-block-post-content h3 {
	margin-top: var(--wp--preset--spacing--40);
	margin-bottom: var(--wp--preset--spacing--10);
}
.wp-block-post-content > :is(h2, h3):first-child {
	margin-top: 0;
}

/* Links: a thin, soft underline set clear of the text; full colour and a bit bolder on hover.
   (Header, footer, buttons, link cards and document rows have their own styles.) */
:where(.wp-block-post-content) a:where(:not(.wp-element-button, .wp-block-button__link)) {
	text-decoration-line: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25em;
	text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
	transition: text-decoration-color var(--jr-speed), text-decoration-thickness var(--jr-speed);
}
.wp-block-post-content a:where(:not(.wp-element-button, .wp-block-button__link)):is(:hover, :focus-visible) {
	color: var(--wp--preset--color--accent-3);
	text-decoration-color: currentColor;
	text-decoration-thickness: 2px;
}

/* Flickr albums (photo pages): Flickr's player is a fixed 800 x 600; make it fit the column. */
.wp-block-embed-flickr :is(img, iframe) {
	width: 100%;
	max-width: 100%;
}
.wp-block-embed-flickr img {
	height: auto;
}
.wp-block-embed-flickr iframe {
	height: auto;
	aspect-ratio: 4 / 3;
}

/* Whole-row / whole-card links (document rows, link cards): the title link is stretched over
   its row or card, and turns blue while the row or card is hovered or focused. */
.jr-doc__body > a,
.jr-link-card__name a {
	color: var(--wp--preset--color--contrast);
	text-decoration: none !important;
}
.jr-doc__body > a::after,
.jr-link-card__name a::after {
	content: "";
	position: absolute;
	inset: 0;
}
:is(.jr-doc, .jr-link-card):is(:hover, :focus-within) :is(.jr-doc__body > a, .jr-link-card__name a) {
	color: var(--wp--preset--color--accent-3);
}

/* Long email addresses and web links wrap instead of pushing the page wider than a phone. */
.wp-block-post-content {
	overflow-wrap: break-word;
}

/* Tables (e.g. the privacy policy): on phones, tighter cells and smaller text so three columns
   fit without sideways scrolling (long words are hyphenated). */
@media (max-width: 599px) {
	.wp-block-post-content .wp-block-table table {
		font-size: var(--wp--preset--font-size--small);
		line-height: 1.4;
	}
	.wp-block-post-content .wp-block-table :is(th, td) {
		padding: 0.4em 0.45em;
		hyphens: auto;
	}
}

/* ---------- 5. Document rows (File blocks) and noticeboard sections ------------------------
   functions.php adds the file-type badge, the "size · date" line and the section counts. */
.wp-block-file.jr-doc {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.9rem;
	margin: 0;
	padding: 0.75rem 1rem;
	border: 1px solid var(--wp--preset--color--accent-2);
	border-bottom-width: 0;
	background: var(--wp--preset--color--base);
	transition: background-color var(--jr-speed);
}
.wp-block-file.jr-doc:is(:has(+ :not(.jr-doc)), :last-child) {
	border-bottom-width: 1px;
}
.wp-block-file.jr-doc:is(:hover, :focus-within) {
	background: var(--wp--preset--color--accent-5);
}
.jr-doc__icon {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 2rem;
	height: 2.4rem;
	padding-top: 0.35rem;
	clip-path: polygon(0 0, 70% 0, 100% 24%, 100% 100%, 0 100%); /* page with a folded corner */
	background: var(--wp--preset--color--accent-2);
	color: var(--wp--preset--color--accent-3);
	font-size: 0.56rem;
	font-weight: 700;
	letter-spacing: 0.05em;
}
.jr-doc__body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
}
.jr-doc__body > a {
	font-weight: 600;
	line-height: 1.35;
}
/* Small grey details: a row's "512 KB · 3 Sep 2026" and a section's "6 documents". */
.jr-doc__meta,
.jr-doc-heading__count {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--accent-4);
}
.jr-doc .wp-block-file__button {
	position: relative; /* sits above the row link */
	z-index: 1;
	flex: 0 0 auto;
	margin: 0 !important;
	padding: 0.45em 0.9em;
	font-size: 0.75rem;
}
@media (max-width: 599px) {
	.jr-doc .wp-block-file__button {
		display: none; /* tapping the row opens the PDF; phones handle download from there */
	}
}

/* Section heading over a run of rows: the normal H2 plus a rule that forms the list's top edge,
   and a "6 documents" count. */
.wp-block-post-content h2:has(+ .jr-doc) {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0.25rem 0.6rem;
	margin-bottom: 0;
	padding-bottom: 0.4rem;
	border-bottom: 2px solid var(--wp--preset--color--contrast);
}
.wp-block-post-content h2:has(+ .jr-doc) + .wp-block-file.jr-doc {
	border-top-width: 0;
}
.jr-doc-heading__count {
	font-weight: 400;
}

/* ---------- 6. Link cards (Sailor info): name + web address; the whole card is clickable ---- */
.jr-link-grid {
	gap: var(--wp--preset--spacing--20);
	margin-bottom: var(--wp--preset--spacing--40);
}
.jr-link-card {
	position: relative;
	padding: 0.9rem 1.1rem;
	background: var(--wp--preset--color--accent-5);
	border: 1px solid var(--wp--preset--color--accent-2);
	border-left: 3px solid var(--wp--preset--color--accent-3);
	border-radius: 0;
	transition: border-color var(--jr-speed), background-color var(--jr-speed);
}
.jr-link-card > * {
	margin: 0;
}
.jr-link-card__name {
	font-weight: 700;
	line-height: 1.3;
}
.jr-link-card__host {
	margin-top: 0.2em !important;
	color: var(--wp--preset--color--accent-4);
}
.jr-link-card:is(:hover, :focus-within) {
	background: var(--wp--preset--color--base);
	border-color: var(--wp--preset--color--accent-3);
}

/* ---------- 7. Footer: clubs and sponsors on one row, then a single slim bar --------------- */
.jr-footer-label { /* plain text, not headings, so they stay out of every page's heading outline */
	margin-bottom: var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--accent-1);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	line-height: 1.125;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}
@media (min-width: 782px) {
	.jr-footer .wp-block-column > .jr-footer-label {
		min-height: 2lh; /* the clubs label wraps onto two lines; keep all three columns' logos level */
	}
}
/* Social links: 40px circles, icon only. Colours and hover: see "Outline controls" in section 8.
   (The Facebook icon is swapped for a plain "f" in functions.php.) */
.jr-footer .jr-follow .wp-block-social-links .wp-social-link {
	border-radius: 50%;
}
.jr-footer .jr-follow .wp-block-social-links .wp-social-link:hover {
	transform: none; /* core grows the icon on hover */
}
.jr-footer .jr-follow .wp-block-social-links .wp-social-link a {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
}
.jr-footer .jr-follow .wp-block-social-links .wp-social-link svg {
	width: 20px;
	height: 20px;
}
.jr-footer .jr-logo-row {
	min-height: 70px; /* clubs (flag + initials) and sponsors share a band */
	align-items: center;
}
.jr-logo-row .wp-block-image img {
	max-width: 220px;
	width: auto;
	object-fit: contain;
}
.jr-sponsors .wp-block-image img {
	max-height: 36px;
}
.jr-clubs .wp-block-image {
	margin: 0;
	text-align: center;
}
.jr-clubs .wp-block-image img {
	height: 48px;
}
.jr-clubs .wp-element-caption {
	margin-top: 0.4em;
	color: var(--wp--preset--color--accent-1);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.12em;
}
.jr-footer-bar :is(p, ul) {
	margin: 0;
}
.jr-footer-bar a {
	text-decoration: none;
}
.jr-footer-bar a:is(:hover, :focus-visible) {
	text-decoration: underline;
	text-underline-offset: 4px;
}

/* ---------- 8. Utilities ------------------------------------------------------------------ */

/* Outline controls on the photo and the navy footer (hero buttons, social circles): a thin
   soft (85%) white ring and text; full white with a toned-down (translucent) white fill on hover/focus. */
.jr-hero-buttons .wp-block-button.is-style-outline > .wp-block-button__link,
.jr-footer .jr-follow .wp-block-social-links .wp-social-link {
	--jr-soft-white: color-mix(in srgb, var(--wp--preset--color--base) 85%, transparent);
	border: 1px solid var(--jr-soft-white);
	background-color: transparent;
	color: var(--jr-soft-white);
	transition: background-color var(--jr-speed), color var(--jr-speed), border-color var(--jr-speed);
}
.jr-hero-buttons .wp-block-button.is-style-outline > .wp-block-button__link:is(:hover, :focus-visible),
.jr-footer .jr-follow .wp-block-social-links .wp-social-link:is(:hover, :focus-within) {
	background-color: color-mix(in srgb, var(--wp--preset--color--base) 35%, transparent);
	border-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--base);
}

/* Turn a dark logo white for the navy footer (add class "jr-logo-white" to the image block). */
.jr-logo-white img {
	filter: brightness(0) invert(1);
}

/* Link lists without bullets; jr-inline-list lays them out in a row. */
.jr-plain-list {
	list-style: none;
	padding-left: 0;
}
.jr-inline-list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25em 1.25em;
}

/* Hidden from view but read by screen readers and search engines,
   e.g. the home page's main heading (the hero logo says it visually). */
.jr-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px !important;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}
.jr-visually-hidden + * {
	margin-block-start: 0 !important; /* the hidden heading shouldn't push the next block down */
}

/* No hover animations for people who ask their device for reduced motion. */
@media (prefers-reduced-motion: reduce) {
	:root {
		--jr-speed: 0s;
	}
}
