/*
Theme Name: Bridgend Centre
Author: MJ Creative
Description: Calm, accessible block theme for the Bridgend Centre, Bollington.
Version: 0.4.1
Requires at least: 6.5
Tested up to: 6.8
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: bridgend-centre
*/

/*
 * Only things theme.json cannot express live here.
 * Colours, fonts, sizes and spacing all come from theme.json via CSS variables.
 */

/* ---------- Focus: strong, visible ring on every interactive element ---------- */

/* Dark ring on light backgrounds by default. */
:root {
	--bc-focus-colour: var(--wp--preset--color--ink);
}

/* Light ring inside dark sections (hero, footer, green cards). Buttons are
   deliberately excluded so a dark-green button on cream keeps the dark ring. */
:where(.wp-block-cover, .wp-block-group, .wp-block-column, .wp-block-template-part).has-ink-background-color,
:where(.wp-block-cover, .wp-block-group, .wp-block-column, .wp-block-template-part).has-green-700-background-color,
:where(.wp-block-cover, .wp-block-group, .wp-block-column, .wp-block-template-part).has-green-600-background-color,
.wp-block-cover {
	--bc-focus-colour: var(--wp--preset--color--lime);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
.wp-element-button:focus-visible {
	outline: var(--wp--custom--focus-width) solid var(--bc-focus-colour);
	outline-offset: 3px;
	box-shadow: none;
}

/* ---------- Touch targets (WCAG 2.5.8): buttons at least 48px tall ---------- */

.wp-element-button,
.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	text-align: center;
}

/* Underline offset makes links easier to read for people with low vision. */
a {
	text-underline-offset: 0.18em;
	text-decoration-thickness: 0.08em;
}

/* Keep long words (e.g. URLs) from causing sideways scrolling at 360px / 200% zoom. */
body {
	overflow-wrap: break-word;
}

/* ---------- Header and navigation ---------- */

/* Menu items: comfortable 44px+ touch targets. */
.bc-header .wp-block-navigation-item__content {
	padding: 0.5rem 0.25rem;
}

/* Mobile "Menu" / "Close" buttons: visible text label, bordered, 48px. */
.wp-block-navigation__responsive-container-open,
.wp-block-navigation__responsive-container-close {
	min-width: 48px;
	min-height: 48px;
	padding: 0.5rem 1rem;
	border: 2px solid currentColor;
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
}

/* Overlay menu: large, well-spaced items. */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	font-size: var(--wp--preset--font-size--large);
}

/* Buttons with a palette colour can't change colour on hover (WordPress's
   colour classes win), so give every button an underline on hover instead. */
.wp-block-button__link:hover {
	text-decoration: underline;
}

/* ---------- Homepage sections ---------- */

/* Sections on the homepage sit flush against each other; each one has its
   own top and bottom padding. */
.wp-block-post-content > .alignfull {
	margin-block-start: 0;
	margin-block-end: 0;
}

/* Hero: gentle curved bottom edge, drawn as a cream ellipse over the bottom
   of the photo. It sits inside the hero's large bottom padding, so it can
   never overlap the text. Decorative only. */
.bc-hero {
	overflow: hidden;
}

.bc-hero::after {
	content: "";
	position: absolute;
	z-index: 2;
	left: -10%;
	right: -10%;
	bottom: -1px;
	height: clamp(1.5rem, 5vw, 4rem);
	background: var(--wp--preset--color--cream);
	border-radius: 50% 50% 0 0 / 100% 100% 0 0;
	pointer-events: none;
}

/* Hero text panel: dark green at 90% so a little of the photo shows through.
   White text on it measures at least 6.34:1 even over pure white, so it stays
   readable whatever photo is used. !important is needed to beat WordPress's
   colour class. Browsers without color-mix() fall back to solid green-700. */
.bc-hero-panel.has-green-700-background-color {
	background-color: color-mix(in srgb, var(--wp--preset--color--green-700) 90%, transparent) !important;
}

/* Desktop: the panel is wide (62rem, set on the Cover) and centred along the
   bottom, with tighter padding so it stays short and the faces stay clear. */
.bc-hero .bc-hero-panel {
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--50) !important;
}

/* Phones: show the photo uncovered (all the faces visible), with the panel
   just below it, slightly overlapping. !important beats the min-height,
   padding and focal point the Cover block sets inline. */
@media (max-width: 600px) {
	.bc-hero {
		display: block;
		min-height: 0 !important;
		padding: 0 0 var(--wp--preset--spacing--40) !important;
	}

	.bc-hero .wp-block-cover__image-background {
		position: static;
		display: block;
		width: 100%;
		height: auto;
		aspect-ratio: 3 / 2;
		object-position: 50% 30% !important;
	}

	.bc-hero .wp-block-cover__background,
	.bc-hero::after {
		display: none;
	}

	.bc-hero .wp-block-cover__inner-container {
		margin-top: calc(-1 * var(--wp--preset--spacing--40));
		padding-inline: var(--wp--preset--spacing--30);
	}

	.bc-hero .bc-hero-panel {
		padding: var(--wp--preset--spacing--40) !important;
	}
}

/* Cards: keep buttons lined up along the bottom when card text lengths differ. */
.bc-card {
	display: flex;
	flex-direction: column;
}

.bc-card > .wp-block-buttons {
	margin-top: auto;
	padding-top: var(--wp--preset--spacing--30);
}

/* ---------- Footer ---------- */

/* The logo file has a white background, so it sits on a small white panel
   that hugs the logo instead of stretching across the column. */
.bc-logo-panel {
	width: fit-content;
	max-width: 100%;
}

/* Logo on the right of the footer on wider screens. Below 782px (where
   WordPress stacks columns) it sits under the text, on the left. */
@media (min-width: 782px) {
	.bc-footer-logo .bc-logo-panel {
		margin-left: auto;
		margin-right: 0;
	}
}

.bc-logo-panel .wp-block-site-logo img {
	max-width: 100%;
	height: auto;
}

/* ---------- Reduced motion ---------- */

@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;
	}
}
