/*
Theme Name: DLBC
Theme URI: https://dlbcnec.org.uk
Description: Block theme for Deeper Life Bible Church, North East & Cumbria Region — a regional site where every branch carries its own colour and identity.
Author: DLBC Newcastle UK Tech Team
Version: 0.4.2
Requires at least: 6.8
Tested up to: 7.1
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dlbc
*/

/* Branch colour defaults (regional sky). DLBC Core overrides these per branch. */
:root {
	/* The regional colours (branch pages override these); they follow the palette. */
	--dlbc-branch-fill: var(--wp--preset--color--sky);
	--dlbc-branch-deep: var(--wp--preset--color--sky-deep);
	--dlbc-branch-tint: var(--wp--preset--color--sky-tint);
}

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

/* Underline links in running text inside page content only (not header/footer). */
.wp-block-post-content p a:where(:not(.wp-element-button)),
.wp-block-post-content .wp-block-list li a:where(:not(.wp-element-button)) {
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

/* Footer links: quiet until hovered. */
footer.wp-block-template-part a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--slate);
}
footer.wp-block-template-part a:where(:not(.wp-element-button)):hover {
	color: var(--wp--preset--color--navy);
}

/* Links on navy stay readable on hover (the default hover colour is navy). */
.has-navy-background-color a:where(:not(.wp-element-button)):hover,
.has-navy-background-color a:where(:not(.wp-element-button)):focus-visible {
	color: var(--wp--preset--color--sky);
}

/* Visually hidden, still read by screen readers. */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   Sticky header: stays at the top, tightens and gains a shadow once you scroll.
   ========================================================================== */
header.wp-block-template-part {
	position: sticky;
	top: 0;
	z-index: 1000;
	transition: box-shadow 0.3s ease;
}
.admin-bar header.wp-block-template-part {
	top: var(--wp-admin--admin-bar--height, 32px);
}
header.wp-block-template-part > .wp-block-group:last-child {
	transition: padding 0.3s ease, background-color 0.3s ease;
}
.dlbc-scrolled header.wp-block-template-part {
	box-shadow: 0 8px 30px rgba(11, 27, 51, 0.1);
}
.dlbc-scrolled header.wp-block-template-part > .wp-block-group:last-child {
	position: relative;
	padding-top: 0.55rem !important;
	padding-bottom: 0.55rem !important;
	background-color: transparent !important;
}
/* The frosted glass sits on a separate layer: a backdrop-filter on the bar itself
   would trap the full-screen mobile menu inside the bar. */
.dlbc-scrolled header.wp-block-template-part > .wp-block-group:last-child::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: color-mix(in srgb, var(--wp--preset--color--white) 92%, transparent);
	-webkit-backdrop-filter: saturate(1.4) blur(12px);
	backdrop-filter: saturate(1.4) blur(12px);
}
/* While the menu is open it always covers the whole screen. */
.wp-block-navigation__responsive-container.is-menu-open {
	position: fixed !important;
	inset: 0 !important;
	height: 100dvh;
	overflow-y: auto;
	z-index: 100001 !important;
}
/* The branch strip slides out of view once you scroll (motion.js measures it). */
header.wp-block-template-part {
	transition: box-shadow 0.3s ease, top 0.3s ease;
}
.dlbc-scrolled header.wp-block-template-part:has(> .has-navy-background-color:first-child) {
	top: calc(-1 * var(--dlbc-strip-h, 0px));
}
.dlbc-scrolled.admin-bar header.wp-block-template-part:has(> .has-navy-background-color:first-child),
.dlbc-scrolled .admin-bar header.wp-block-template-part:has(> .has-navy-background-color:first-child) {
	top: calc(var(--wp-admin--admin-bar--height, 32px) - var(--dlbc-strip-h, 0px));
}
@media (max-width: 600px) {
	.admin-bar header.wp-block-template-part {
		top: 0;
	}
}

/* ==========================================================================
   Footer: a soft grey band, set apart from the page.
   ========================================================================== */
footer.wp-block-template-part {
	margin-top: 0;
	background: var(--wp--preset--color--mist);
	border-top: 1px solid var(--wp--preset--color--line);
}

/* Chips and pills size to their content. */
.is-style-chip {
	width: fit-content;
}

/* Hide secondary header actions on phones (the menu carries them). */
@media (max-width: 781px) {
	.dlbc-hide-mobile { display: none !important; }
}

/* Header navigation sits in a soft pill on wide screens. */
@media (min-width: 1000px) {
	.dlbc-nav-pill .wp-block-navigation__container {
		gap: 0.25rem;
		padding: 0.3rem;
		background: var(--wp--preset--color--white);
		border: 1px solid var(--wp--preset--color--line);
		border-radius: 999px;
	}
	.dlbc-nav-pill .wp-block-navigation-item__content {
		padding: 0.55rem 1rem;
		border-radius: 999px;
	}
	.dlbc-nav-pill .current-menu-item > .wp-block-navigation-item__content {
		background: var(--wp--preset--color--navy);
		color: var(--wp--preset--color--white);
	}
}

/* Live dot on the "Watch live" button. */
.dlbc-live .wp-block-button__link::before {
	content: "";
	display: inline-block;
	width: 0.5rem;
	height: 0.5rem;
	margin-right: 0.6rem;
	border-radius: 50%;
	background: currentColor;
	vertical-align: 0.1em;
}

/* Photo hero: white fades in from the left on desktop. On phones the photo is a
   band across the top and the words sit on white beneath it. */
@media (max-width: 781px) {
	.dlbc-hero-fade.wp-block-cover {
		align-items: flex-start;
		min-height: 0 !important;
		padding-top: calc(38vh + 1rem) !important;
	}
	.dlbc-hero-fade .wp-block-cover__image-background {
		height: 42vh;
		bottom: auto;
	}
	.dlbc-hero-fade .wp-block-cover__background.has-background-gradient {
		background: linear-gradient(180deg, transparent 0, transparent 26vh, var(--wp--preset--color--white) 42vh) !important;
	}
}

/* Floating "This Sunday" card on the hero, anchored to the whole hero. */
@media (min-width: 1100px) {
	.dlbc-hero-fade .wp-block-cover__inner-container {
		position: static;
	}
	.dlbc-hero-card {
		height: auto !important;
		position: absolute;
		right: clamp(1rem, 4vw, 3.5rem);
		bottom: clamp(1rem, 4vw, 3.5rem);
		width: 360px;
		margin: 0 !important;
		z-index: 2;
	}
}

/* Week strip: cards keep an even height. */
.dlbc-week .wp-block-group.is-style-card {
	height: 100%;
	box-sizing: border-box;
}

/* Photo inside a coloured banner hero. */
.dlbc-branch-banner .wp-block-post-featured-image img,
.dlbc-branch-banner .dlbc-photo-placeholder {
	border-radius: var(--wp--custom--radius--md);
}

/* Placeholder shown where a branch has no photo yet. */
.dlbc-photo-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	width: 100%;
	height: 100%;
	min-height: 260px;
	box-sizing: border-box;
	background: var(--dlbc-branch-tint);
	border: 2px dashed var(--dlbc-branch-fill);
	color: var(--dlbc-branch-deep);
	font-weight: 700;
	font-size: 0.9375rem;
	text-align: center;
}
.is-style-arch .dlbc-photo-placeholder {
	border-radius: 999px 999px 24px 24px;
}
.is-style-pill .dlbc-photo-placeholder {
	border-radius: 999px;
}

/* "Edit this page" button for signed-in editors. */
.dlbc-edit-fab {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 99999;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 1.1rem;
	border-radius: 999px;
	background: #0B1B33;
	color: #FFFFFF !important;
	font: 700 0.9375rem/1 Figtree, system-ui, sans-serif;
	text-decoration: none !important;
	box-shadow: 0 6px 24px rgba(11, 27, 51, 0.25);
}
.dlbc-edit-fab:hover,
.dlbc-edit-fab:focus-visible {
	background: #1A73C0;
}

@media print {
	.dlbc-edit-fab { display: none; }
}

/* Header "Log in" sits quietly beside "Watch live". */
.dlbc-login-btn .wp-block-button__link {
	padding-left: 1.25rem;
	padding-right: 1.25rem;
}

/* Header fits on one line: no wrapping buttons or title. */
header.wp-block-template-part .wp-block-buttons {
	flex-wrap: nowrap;
}
header.wp-block-template-part .wp-block-site-title,
header.wp-block-template-part .wp-block-button__link {
	white-space: nowrap;
}
header.wp-block-template-part .wp-block-site-logo {
	flex-shrink: 0;
}
/* 1240–1320px: the full menu fits only without "Log in" (it stays in the footer). */
@media (min-width: 1240px) and (max-width: 1320px) {
	header.wp-block-template-part .wp-block-buttons > .dlbc-login-btn {
		display: none;
	}
}
/* Below 1240px the menu folds into the tap-to-open button (core only does this below 600px). */
@media (max-width: 1239px) {
	header.wp-block-template-part .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}
	header.wp-block-template-part .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

/* ==========================================================================
   Phones and tablets
   ========================================================================== */

/* Nothing may cause sideways scrolling (clip keeps the sticky header working). */
html,
body {
	overflow-x: clip;
}

/* Comfortable tap targets. */
.wp-block-navigation__responsive-container-open,
.wp-block-navigation__responsive-container-close {
	width: 44px;
	height: 44px;
	justify-content: center;
	align-items: center;
	border-radius: 50%;
	background: var(--wp--preset--color--sky-tint);
}
.wp-block-navigation__responsive-container-open svg,
.wp-block-navigation__responsive-container-close svg {
	width: 26px;
	height: 26px;
}
footer.wp-block-template-part a,
.wp-block-query-pagination a,
.wp-block-query-pagination .page-numbers {
	display: inline-block;
	min-height: 44px;
	line-height: 44px;
}
.wp-block-query-pagination .page-numbers {
	min-width: 44px;
	text-align: center;
	border-radius: 999px;
}
.wp-block-query-pagination .page-numbers.current {
	background: var(--wp--preset--color--navy);
	color: var(--wp--preset--color--white);
}

/* The open menu on phones: big, clear, grouped. */
.wp-block-navigation__responsive-container.is-menu-open {
	padding: 1.25rem 1.5rem 2rem !important;
}
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: 3.5rem;
	gap: 0.25rem !important;
}
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	width: 100%;
}
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container,
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	align-items: flex-start !important;
	text-align: left;
}
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content {
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.6rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	padding: 0.35rem 0;
}
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-container {
	padding: 0 0 0.75rem 0 !important;
	gap: 0 !important;
}
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	padding: 0.45rem 0 !important;
	color: var(--wp--preset--color--slate);
	font-size: 1.05rem;
}

@media (max-width: 781px) {
	/* Decorative frames stay inside the screen. */
	.dlbc-arch-frame > .wp-block-post-featured-image::before,
	.dlbc-arch-frame > .wp-block-image::before {
		inset: -10px 10px 10px -10px;
	}
	.dlbc-arch-frame > .wp-block-post-featured-image::after,
	.dlbc-arch-frame > .wp-block-image::after {
		right: -8px;
		bottom: -12px;
	}
	/* Tighter sections and headings on small screens. */
	.dlbc-hero h1 {
		font-size: clamp(2.4rem, 11vw, 3.2rem) !important;
	}
	.dlbc-quote {
		font-size: 1.6rem;
	}
	.dlbc-latest {
		padding: 1rem;
	}
	.dlbc-latest__title {
		font-size: 2.1rem;
	}
	/* Header on phones: logo, name and the menu button only. */
	header.wp-block-template-part .wp-block-site-title {
		font-size: 1.05rem;
	}
	header.wp-block-template-part .wp-block-site-logo img {
		width: 42px !important;
	}
	/* Stack columns with breathing room. */
	.wp-block-columns {
		gap: var(--wp--preset--spacing--40) !important;
	}
}

/* Nothing floats over the open mobile menu. */
body:has(.wp-block-navigation__responsive-container.is-menu-open) .dlbc-consent,
body:has(.wp-block-navigation__responsive-container.is-menu-open) .dlbc-consent-fab,
body:has(.wp-block-navigation__responsive-container.is-menu-open) .dlbc-edit-fab {
	display: none !important;
}

/* Room below the last menu item (and the phone's home bar) so it scrolls fully into view. */
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px)) !important;
}

/* Centre the icons in the round menu buttons — only where they are meant to show:
   the open button on smaller screens, the close button inside the open menu. */
@media (max-width: 1239px) {
	header.wp-block-template-part .wp-block-navigation__responsive-container-open {
		display: flex !important;
		align-items: center;
		justify-content: center;
		padding: 0 !important;
	}
}
.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close {
	display: flex !important;
	align-items: center;
	justify-content: center;
	padding: 0 !important;
}

/* ==========================================================================
   Footer: 5 columns on desktop, brand row + 4 on small laptops, 2 per row on tablets
   and phones (brand block across the top).
   ========================================================================== */
.dlbc-footer__grid {
	display: grid;
	grid-template-columns: minmax(0, 1.35fr) repeat(4, minmax(0, 1fr));
	gap: var(--wp--preset--spacing--50) var(--wp--preset--spacing--40);
}
.dlbc-footer__grid > * {
	margin: 0 !important;
}
.dlbc-footer__tagline {
	margin: 0;
	max-width: 17rem;
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.2rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.2;
	color: var(--wp--preset--color--navy);
}
.dlbc-footer__links {
	margin: 0;
	font-size: 0.9375rem;
	line-height: 2.1;
}
footer.wp-block-template-part .dlbc-footer__links a {
	display: inline;
	min-height: 0;
	line-height: inherit;
}
footer.wp-block-template-part .dlbc-footer__col h3 {
	margin: 0;
}
footer.wp-block-template-part .dlbc-branch-list.is-layout-links li + li {
	margin-top: 0.15rem;
}
footer.wp-block-template-part .dlbc-branch-list.is-layout-links a {
	min-height: 0;
	line-height: 2.1;
	font-size: 0.9375rem;
}
footer.wp-block-template-part .dlbc-social {
	margin-top: 0.25rem;
}
@media (max-width: 1100px) {
	.dlbc-footer__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
	.dlbc-footer__brand {
		grid-column: 1 / -1;
	}
}
@media (max-width: 781px) {
	.dlbc-footer__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		row-gap: var(--wp--preset--spacing--50);
	}
	footer.wp-block-template-part .wp-block-group:has(> .has-small-font-size) {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.25rem;
	}
}

/* ==========================================================================
   Orientation: date panel, flyer, university logos, venue contacts
   ========================================================================== */
.dlbc-when {
	padding: 1.1rem 1.35rem;
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--white);
	border-left: 6px solid var(--dlbc-branch-deep, var(--wp--preset--color--sky-deep));
	box-shadow: 0 1px 2px rgba(11, 27, 51, 0.06), 0 14px 30px -20px rgba(11, 27, 51, 0.35);
}
.dlbc-when > * { margin: 0; }
.dlbc-when__date {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--wp--preset--color--navy);
}
.dlbc-when__times { margin-top: 0.35rem !important; color: var(--wp--preset--color--slate); line-height: 1.8; }
.dlbc-when__times strong { color: var(--wp--preset--color--navy); display: inline-block; min-width: 5.2rem; }

.dlbc-flyer img {
	border-radius: var(--wp--custom--radius--md);
	box-shadow: 0 2px 4px rgba(11, 27, 51, 0.08), 0 30px 60px -30px rgba(11, 27, 51, 0.45);
	transition: transform 0.3s;
}
.dlbc-flyer img { cursor: zoom-in; }
.dlbc-flyer:hover img { transform: scale(1.015); }

.dlbc-logo-strip {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 0.9rem;
}
.dlbc-logo-strip > .wp-block-image {
	margin: 0;
	display: grid;
	place-items: center;
	min-height: 96px;
	padding: 0.9rem 1rem;
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--white);
	border: 1px solid var(--wp--preset--color--line);
}
.dlbc-logo-strip img {
	width: auto;
	max-width: 100%;
	max-height: 58px;
	object-fit: contain;
}
@media (max-width: 1000px) {
	.dlbc-logo-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
	.dlbc-logo-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
	.dlbc-logo-strip > .wp-block-image { min-height: 80px; padding: 0.7rem; }
}

.dlbc-contacts { font-weight: 600; line-height: 2; }
.dlbc-contacts a { color: var(--dlbc-branch-deep, var(--wp--preset--color--sky-deep)); text-decoration: none; }
.dlbc-contacts a:hover { text-decoration: underline; }
/* Anchor jumps clear the sticky header. */
html { scroll-padding-top: 7.5rem; }
.dlbc-contacts a { white-space: nowrap; }

/* Colours saved inside page content follow the palette (so every colour
   scheme and design style works on existing pages). */
@media (min-width: 782px) {
.dlbc-hero-fade > .wp-block-cover__background.has-background-gradient {
	background: linear-gradient(90deg, var(--wp--preset--color--white) 0%, var(--wp--preset--color--white) 36%, color-mix(in srgb, var(--wp--preset--color--white) 86%, transparent) 48%, transparent 72%) !important;
}
}
.has-navy-background-color [style*="color:#c9d6ea"],
.has-navy-background-color [style*="color:#C9D6EA"] {
	color: var(--dlbc-band-soft) !important;
}

/* "Band" colours: dark panels (hero bands, the special-programme card, the
   voices band…). Light designs use the palette's navy; a dark design style
   sets its own. */
:root {
	--dlbc-band-bg: var(--wp--preset--color--navy);
	--dlbc-band-text: #fff;
	--dlbc-band-soft: #c9d6ea;
}

/* Buttons saved in page content with fixed navy/white colours follow the
   palette too, so they stay visible in every design (e.g. on a dark one). */
.wp-block-button__link[style*="background-color:#0B1B33"],
.wp-block-button__link[style*="background-color:#0b1b33"] {
	background-color: var(--wp--preset--color--navy) !important;
}
.wp-block-button__link[style*="background-color:#0B1B33"][style*="color:#FFFFFF"],
.wp-block-button__link[style*="background-color:#0b1b33"][style*="color:#ffffff"] {
	color: var(--wp--preset--color--white) !important;
}
