/*
Theme Name: Hetton Chapel (Blocks)
Theme URI: https://hettonchapel.org.uk
Author: Tribus Digital
Author URI: https://tribusdigital.com
Description: Block (full site editing) theme for Hetton Chapel. Page sections are block patterns made from core blocks; colours, fonts and spacing live in theme.json. Replaces the classic "hettonchapel" theme and its ACF flexible layouts.
Requires at least: 6.9
Tested up to: 7.0
Requires PHP: 8.1
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: hettonchapel-blocks
*/

/* -------------------------------------------------------------------------
 * Headings: short accent bar under h1–h3 (ported from the classic theme).
 * Opt out per heading with the "Plain" block style.
 * ---------------------------------------------------------------------- */
:where(h1, h2, h3):not(.is-style-plain, .wp-block-site-title, .wp-block-post-title)::after {
	content: '';
	display: block;
	width: var(--wp--custom--accent-bar--width);
	height: var(--wp--custom--accent-bar--height);
	margin-top: 1rem;
	background-color: var(--wp--preset--color--primary);
}

:where(h1, h2, h3).has-text-align-center::after {
	margin-inline: auto;
}

:where(h1, h2, h3).has-text-align-right::after {
	margin-inline-start: auto;
}

/* -------------------------------------------------------------------------
 * Dark backgrounds: white text, underlined white links, gold accent bars.
 * Applies to any block given one of the dark palette colours as background.
 * ---------------------------------------------------------------------- */
:is(
	.has-primary-background-color,
	.has-secondary-background-color,
	.has-dark-teal-background-color,
	.has-dark-background-color,
	.has-black-background-color,
	.wp-block-cover.is-dark
):not(.has-text-color) {
	color: var(--wp--preset--color--white);
}

:is(
	.has-primary-background-color,
	.has-secondary-background-color,
	.has-dark-teal-background-color,
	.has-dark-background-color,
	.has-black-background-color,
	.wp-block-cover.is-dark
) a:where(:not(.wp-element-button)) {
	color: inherit;
	text-decoration: underline;
}

:is(
	.has-primary-background-color,
	.has-secondary-background-color,
	.has-dark-teal-background-color,
	.has-dark-background-color,
	.has-black-background-color,
	.wp-block-cover.is-dark
) :where(h1, h2, h3)::after {
	background-color: var(--wp--preset--color--gold);
}

/* -------------------------------------------------------------------------
 * Buttons: darken the fill on hover whatever colour the editor chose.
 * ---------------------------------------------------------------------- */
.wp-element-button,
.wp-block-button__link {
	transition: box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.wp-block-button:not(.is-style-outline) .wp-block-button__link:is(:hover, :focus-visible),
.wp-element-button:not(.wp-block-button__link):is(:hover, :focus-visible) {
	box-shadow: inset 0 0 0 100vmax rgb(0 0 0 / 20%);
}

.wp-block-button.is-style-outline > .wp-block-button__link {
	border-color: currentColor;
}

.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color) {
	color: var(--wp--preset--color--primary);
}

:is(.has-primary-background-color, .has-secondary-background-color, .has-dark-teal-background-color, .has-dark-background-color, .wp-block-cover.is-dark)
	.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color) {
	color: var(--wp--preset--color--white);
}

.wp-block-button.is-style-outline > .wp-block-button__link:is(:hover, :focus-visible) {
	background-color: color-mix(in srgb, currentColor 12%, transparent);
}

/* -------------------------------------------------------------------------
 * Skip link focus + focus rings.
 * ---------------------------------------------------------------------- */
:where(a, button, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--gold);
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Sections template: stack full-width sections with no gap between them.
 * Margins set in the editor (inline styles) still win.
 * ---------------------------------------------------------------------- */
.hc-sections > .wp-block-post-content > * {
	margin-block-start: 0;
}

/* No gap between header, main and footer. */
.wp-site-blocks > * + * {
	margin-block-start: 0;
}

/* -------------------------------------------------------------------------
 * Header
 * ---------------------------------------------------------------------- */
.hc-site-header .wp-block-site-logo img {
	max-height: 7.5rem;
	width: auto;
}

.hc-site-header .wp-block-navigation .wp-block-navigation-item__content {
	padding: 0.75rem 1rem;
}

.hc-site-header .wp-block-navigation .current-menu-item > .wp-block-navigation-item__content {
	font-weight: 700;
}

.hc-site-header .wp-block-navigation .wp-block-navigation-item__content:is(:hover, :focus) {
	text-decoration: underline;
}

.hc-site-header .wp-block-navigation__submenu-container {
	min-width: 12rem;
	box-shadow: 0 0.25rem 0.5rem rgb(0 0 0 / 10%);
	border: 0 !important;
}

/* -------------------------------------------------------------------------
 * Footer
 * ---------------------------------------------------------------------- */
.hc-site-footer :where(h1, h2, h3)::after {
	display: none;
}

.hc-site-footer .hc-footer-bottom {
	border-top: 1px solid rgb(255 255 255 / 20%);
}

.hc-site-footer a:is(:hover, :focus) {
	opacity: 0.8;
}

/* -------------------------------------------------------------------------
 * Block style: Group "Card".
 * ---------------------------------------------------------------------- */
.wp-block-group.is-style-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--dark);
	border: 1px solid rgb(0 0 0 / 12.5%);
	border-radius: 0.375rem;
}

.wp-block-group.is-style-card > .wp-block-image,
.wp-block-group.is-style-card > .wp-block-post-featured-image {
	margin: 0;
}

.wp-block-group.is-style-card img {
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
}

.wp-block-group.is-style-card > :not(.wp-block-image, .wp-block-post-featured-image) {
	margin-inline: 1.25rem;
}

.wp-block-group.is-style-card > :last-child {
	margin-block-end: 1.25rem;
}

.wp-block-group.is-style-card > :first-child:not(.wp-block-image, .wp-block-post-featured-image) {
	margin-block-start: 1.25rem;
}

.wp-block-group.is-style-card > .wp-block-buttons:last-child,
.wp-block-group.is-style-card > .wp-block-read-more:last-child {
	margin-block-start: auto;
	padding-block-start: 1rem;
}

.wp-block-group.is-style-card > .wp-block-read-more {
	align-self: flex-start;
}

/* Cards stay light even inside a dark section. */
.wp-block-group.is-style-card a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--primary);
}

.wp-block-group.is-style-card :where(h1, h2, h3)::after {
	background-color: var(--wp--preset--color--primary);
}

/* -------------------------------------------------------------------------
 * Details block (accordion rows): +/− marker, matches the classic accordion.
 * ---------------------------------------------------------------------- */
.wp-block-details > summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 0;
	font-weight: 700;
	list-style: none;
	cursor: pointer;
}

.wp-block-details > summary::-webkit-details-marker {
	display: none;
}

.wp-block-details > summary::after {
	content: '+';
	font-size: 1.5rem;
	line-height: 1;
}

.wp-block-details[open] > summary::after {
	content: '\2212';
}

.wp-block-details > :last-child {
	padding-block-end: 1.5rem;
}

/* -------------------------------------------------------------------------
 * Pattern helpers.
 * ---------------------------------------------------------------------- */

/* Image panels inside full-bleed columns stretch to the row height. */
.hc-fill-height,
.hc-fill-height > .wp-block-cover {
	height: 100%;
}

/*
 * Home hero: the welcome panel fills the image column (as in the classic theme).
 * Core sizes left-positioned cover content to fit (width: auto) and the cover's
 * constrained layout caps children at its contentSize, so undo both here.
 */
.wp-block-column > .wp-block-cover.hc-fill-height.has-custom-content-position.has-custom-content-position > .wp-block-cover__inner-container {
	width: 100%;
}

/* Capped so lines stay readable on very wide screens. */
.wp-block-cover.hc-fill-height > .wp-block-cover__inner-container > * {
	max-width: 60rem;
}

/* Home hero sidebar items: icon beside text. */
.hc-icon-item .wp-block-image {
	flex-shrink: 0;
	margin: 0;
}

.hc-icon-item .wp-block-image img {
	width: 2.5rem;
	height: 2.5rem;
}

.hc-icon-item p {
	margin: 0;
}

/* Quote panel on an image. */
.hc-quote-panel {
	font-family: var(--wp--preset--font-family--body);
	font-weight: 700;
	line-height: 1.4;
}

/* Media & Text: image fills its half on large screens. */
.wp-block-media-text.is-image-fill-element > .wp-block-media-text__media img {
	height: 100%;
}
