/* ==========================================================================
   DNH — core block styles

   Design tokens live in theme.json. This file covers what theme.json cannot
   express well: prose rhythm, table behaviour, the section system, and the
   header/footer.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Base
   -------------------------------------------------------------------------- */

/* WordPress applies no global box-sizing reset, so `width: 100%` on anything
   padded overflows its container. Without this a full-width hero button was
   25px wider than the column holding it. */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

/* Header, main and footer sit flush against each other — each already carries
   its own padding. WordPress otherwise gives every top-level child of
   .wp-site-blocks the global blockGap as a margin, which put a 24px white strip
   under the header and above the footer. Core emits this inside :where(), so a
   plain class selector is enough to override it. */
.wp-site-blocks > * {
	margin-block-start: 0;
	margin-block-end: 0;
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

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

/* Visible focus everywhere — this site is used by people following links to a
   planning portal, often on phones, often in a hurry. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 3px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
	border-radius: 2px;
}

/* --------------------------------------------------------------------------
   2. Prose rhythm
   -------------------------------------------------------------------------- */

:where(.entry-content) > * + * {
	margin-block-start: var(--wp--preset--spacing--40);
}

:where(.entry-content) :where(h2, h3, h4) {
	margin-block-start: var(--wp--preset--spacing--60);
	margin-block-end: var(--wp--preset--spacing--30);
	text-wrap: balance;
}

:where(.entry-content) :where(h2, h3, h4):first-child {
	margin-block-start: 0;
}

:where(.entry-content) h1 {
	margin-block-end: var(--wp--preset--spacing--40);
	text-wrap: balance;
}

/* Keep body copy readable. Headings and full-width blocks are exempt. */
:where(.entry-content) > :where(p, ul, ol) {
	max-width: var(--wp--custom--measure);
}

:where(.entry-content) :where(ul, ol) {
	padding-inline-start: 1.4em;
}

:where(.entry-content) li + li {
	margin-block-start: 0.4em;
}

/* Component lists are laid out by grid or flex, so the prose rhythm above must
   not add margins between their items. It was giving every card after the first
   a 0.4em top margin, which pushed cards 2 and 3 down 7px and made the row look
   uneven. */
:where(.dnh-posts__list, .dnh-events__list, .dnh-hero__links, .dnh-dl-grid) > li + li {
	margin-block-start: 0;
}

:where(.entry-content) strong { font-weight: 600; }

:where(.entry-content) a {
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

/* Editors paste bare URLs as link text ("How to Object" has a 78-character
   Dorset Council link). Without this they push the page sideways on a phone. */
:where(.entry-content) :where(p, li, td, th, h1, h2, h3, h4, dd) {
	overflow-wrap: break-word;
	word-break: break-word;
}

:where(.entry-content) a[href^="http"] {
	overflow-wrap: anywhere;
}

:where(.entry-content) a:hover {
	text-decoration-thickness: 2px;
}

/* --------------------------------------------------------------------------
   3. Tables

   "How to Object" carries a five-row theme/description table. It must never
   push the page sideways on a phone.
   -------------------------------------------------------------------------- */

.wp-block-table,
.dnh-table-scroll,
:where(.entry-content) figure:has(> table) {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	max-width: 100%;
}

/* Hint that there is more to see when the table is wider than the screen. */
.dnh-table-scroll {
	background:
		linear-gradient(to right, var(--wp--preset--color--base) 30%, rgba(255, 255, 255, 0)) left / 3rem 100% no-repeat,
		linear-gradient(to left, var(--wp--preset--color--base) 30%, rgba(255, 255, 255, 0)) right / 3rem 100% no-repeat,
		radial-gradient(farthest-side at 0 50%, rgba(35, 31, 32, 0.16), transparent) left / 1rem 100% no-repeat,
		radial-gradient(farthest-side at 100% 50%, rgba(35, 31, 32, 0.16), transparent) right / 1rem 100% no-repeat;
	background-attachment: local, local, scroll, scroll;
}

:where(.entry-content) table {
	width: 100%;
	min-width: 34rem;
	border-collapse: collapse;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.55;
}

:where(.entry-content) :where(th, td) {
	padding: 0.85rem 1rem;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var(--wp--preset--color--line);
}

:where(.entry-content) thead :where(th, td) {
	background: var(--wp--preset--color--band);
	font-weight: 600;
	color: var(--wp--preset--color--ink);
	border-bottom-width: 2px;
}

:where(.entry-content) tbody tr:last-child :where(th, td) {
	border-bottom: 0;
}

:where(.entry-content) table p {
	margin: 0;
	max-width: none;
}

/* --------------------------------------------------------------------------
   4. Media
   -------------------------------------------------------------------------- */

img, svg, video { max-width: 100%; height: auto; }

.wp-block-image img { border-radius: 4px; }

figcaption {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--body);
	margin-block-start: 0.6rem;
}

/* --------------------------------------------------------------------------
   5. Quotes
   -------------------------------------------------------------------------- */

.wp-block-quote {
	border-left: 4px solid var(--wp--preset--color--accent);
	padding-left: var(--wp--preset--spacing--40);
	margin-inline: 0;
	font-size: var(--wp--preset--font-size--large);
}

.wp-block-quote cite {
	display: block;
	margin-block-start: var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--small);
	font-style: normal;
	color: var(--wp--preset--color--body);
}

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */

.dnh-btn,
.wp-block-button__link {
	display: inline-block;
	border-radius: var(--wp--custom--button--radius);
	padding: var(--wp--custom--button--padding--y) var(--wp--custom--button--padding--x);
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	border: 2px solid var(--wp--preset--color--primary);
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
	transition: background-color 0.18s ease, color 0.18s ease;
}

.dnh-btn:hover,
.wp-block-button__link:hover {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--primary);
}

/* --------------------------------------------------------------------------
   7. Section system

   Every DNH block renders through dnh_sec_attrs(), which emits these classes.
   -------------------------------------------------------------------------- */

.dnh-sec {
	padding-block: var(--wp--preset--spacing--70);
}

.dnh-pt-none  { padding-block-start: 0; }
.dnh-pt-s     { padding-block-start: var(--wp--preset--spacing--50); }
.dnh-pt-l     { padding-block-start: var(--wp--preset--spacing--80); }

.dnh-pb-none  { padding-block-end: 0; }
.dnh-pb-s     { padding-block-end: var(--wp--preset--spacing--50); }
.dnh-pb-l     { padding-block-end: var(--wp--preset--spacing--80); }

.dnh-bg-band    { background: var(--wp--preset--color--band); }
.dnh-bg-primary { background: var(--wp--preset--color--primary); color: var(--wp--preset--color--base); }
.dnh-bg-accent  { background: var(--wp--preset--color--accent); color: var(--wp--preset--color--ink); }

.dnh-bg-primary :where(h1, h2, h3, h4) { color: var(--wp--preset--color--base); }
.dnh-bg-primary a { color: var(--wp--preset--color--base); text-decoration: underline; }

.dnh-eyebrow {
	display: block;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary);
	margin-block-end: var(--wp--preset--spacing--20);
}

.dnh-block-placeholder {
	padding: var(--wp--preset--spacing--40);
	border: 1px dashed var(--wp--preset--color--line);
	border-radius: 4px;
	color: var(--wp--preset--color--body);
	font-size: var(--wp--preset--font-size--small);
	text-align: center;
}

/* --------------------------------------------------------------------------
   8. Header / footer
   -------------------------------------------------------------------------- */

.dnh-header {
	padding-block: var(--wp--preset--spacing--40);
	border-bottom: 1px solid var(--wp--preset--color--line);
}

/* The logo is an SVG carrying only a viewBox (85.1 × 85.1, square), so it has
   no intrinsic pixel size — give it explicit dimensions or it collapses. */
.dnh-header .wp-block-site-logo img,
.dnh-header .custom-logo {
	width: 92px;
	height: 92px;
	max-width: 92px;
}

@media (max-width: 39.99em) {
	.dnh-header .wp-block-site-logo img,
	.dnh-header .custom-logo {
		width: 76px;
		height: 76px;
		max-width: 76px;
	}
}

.dnh-header .wp-block-site-logo a {
	display: block;
	line-height: 0;
}

.dnh-nav a {
	text-decoration: none;
	font-weight: 500;
	color: var(--wp--preset--color--ink);
}

.dnh-nav a:hover,
.dnh-nav .current-menu-item > a {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
	text-underline-offset: 0.3em;
}

.dnh-footer {
	padding-block: var(--wp--preset--spacing--70);
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--base);
}

.dnh-footer a { color: var(--wp--preset--color--accent); }
.dnh-footer :where(h1, h2, h3, h4) { color: var(--wp--preset--color--base); }

.dnh-footer__brand {
	align-items: center;
	gap: var(--wp--preset--spacing--30);
	margin-bottom: var(--wp--preset--spacing--40);
}

.dnh-footer__logo { margin: 0; flex-shrink: 0; }
.dnh-footer__logo img { width: 64px; height: 66px; }

.dnh-footer__name { margin: 0; }

.dnh-footer__privacy { color: var(--wp--preset--color--line); }

.dnh-footer__social { margin-top: var(--wp--preset--spacing--40); }

.dnh-footer__navtitle { margin-top: 0; }

.dnh-footer__nav {
	gap: 0.45rem;
	font-size: var(--wp--preset--font-size--small);
}

.dnh-footer__nav a {
	color: var(--wp--preset--color--base);
	text-decoration: none;
}

.dnh-footer__nav a:hover {
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

.dnh-footer__rule {
	margin-block: var(--wp--preset--spacing--60);
	border: 0;
	border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.dnh-footer__base {
	gap: var(--wp--preset--spacing--30);
	color: var(--wp--preset--color--line);
}

.dnh-footer__base p { margin: 0; }

/* --------------------------------------------------------------------------
   9. Post lists
   -------------------------------------------------------------------------- */

.dnh-postmeta {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--body);
}

.wp-block-post-title a {
	text-decoration: none;
	color: inherit;
}

.wp-block-post-title a:hover {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
}

/* --------------------------------------------------------------------------
   10. Utilities
   -------------------------------------------------------------------------- */

.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip-path: inset(50%);
	white-space: nowrap; border: 0;
}

.skip-link:focus {
	position: fixed;
	top: 0.5rem; left: 0.5rem;
	z-index: 9999;
	width: auto; height: auto;
	clip-path: none;
	padding: 0.75rem 1rem;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--ink);
	border-radius: 4px;
}

@media print {
	.dnh-header, .dnh-footer, .dnh-nav { display: none; }
	body { font-size: 11pt; }
}

/* --------------------------------------------------------------------------
   11. Single post
   -------------------------------------------------------------------------- */

.dnh-backlink {
	margin-bottom: var(--wp--preset--spacing--30);
}

.dnh-backlink a {
	color: var(--wp--preset--color--body);
	text-decoration: none;
}

.dnh-backlink a:hover {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
}

.dnh-single__image img {
	border-radius: 6px;
}

.dnh-postnav {
	gap: var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--small);
}

.dnh-postnav .post-navigation-link-previous,
.dnh-postnav .post-navigation-link-next {
	max-width: 22rem;
}

.dnh-postnav a {
	text-decoration: none;
	font-weight: 500;
}

.dnh-postnav a:hover { text-decoration: underline; }

.dnh-single__cta {
	margin-top: var(--wp--preset--spacing--70);
	padding: var(--wp--preset--spacing--50);
	background: var(--wp--preset--color--band);
	border-radius: 6px;
}

.dnh-single__cta > :first-child { margin-top: 0; }
.dnh-single__cta > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   12. Content panels

   Single-column tables used as content boxes, not data. The PHP filter in
   inc/setup.php tags them so they escape the data-table treatment.
   -------------------------------------------------------------------------- */

.dnh-panels table,
.dnh-panels tbody,
.dnh-panels tr,
.dnh-panels td {
	display: block;
	width: 100%;
	min-width: 0;
	border: 0;
	padding: 0;
}

.dnh-panels td {
	margin-block-end: var(--wp--preset--spacing--40);
	padding: var(--wp--preset--spacing--50);
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--line);
	border-left: 4px solid var(--wp--preset--color--primary);
	border-radius: 6px;
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.65;
}

.dnh-panels tr:last-child td { margin-block-end: 0; }

.dnh-panels td > :first-child { margin-top: 0; }
.dnh-panels td > :last-child { margin-bottom: 0; }

/* The first line of each panel is the application reference — let it read as a
   label rather than body copy. */
.dnh-panels td p:first-child {
	font-weight: 600;
	color: var(--wp--preset--color--primary);
}
/* ==========================================================================
   Block style variations

   These are DEFAULTS, deliberately low-specificity and with no !important, so
   anything the editor sets in the native inspector (background, border colour,
   per-side border width, radius, padding) wins over them.
   ========================================================================== */

/* --------------------------------------------------------------------------
   core/group — Panel
   -------------------------------------------------------------------------- */

.wp-block-group.is-style-dnh-panel {
	padding: var(--wp--preset--spacing--50);
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--line);
	border-left: 4px solid var(--wp--preset--color--primary);
	border-radius: 6px;
}

.wp-block-group.is-style-dnh-panel-accent {
	padding: var(--wp--preset--spacing--50);
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--line);
	border-left: 4px solid var(--wp--preset--color--accent);
	border-radius: 6px;
}

.wp-block-group.is-style-dnh-note {
	padding: var(--wp--preset--spacing--50);
	background: var(--wp--preset--color--band);
	border: 0;
	border-radius: 6px;
}

/* First line of a panel reads as a label. */
.wp-block-group.is-style-dnh-panel > p:first-child strong,
.wp-block-group.is-style-dnh-panel-accent > p:first-child strong {
	color: var(--wp--preset--color--primary);
}

.is-style-dnh-panel > :first-child,
.is-style-dnh-panel-accent > :first-child,
.is-style-dnh-note > :first-child { margin-top: 0; }

.is-style-dnh-panel > :last-child,
.is-style-dnh-panel-accent > :last-child,
.is-style-dnh-note > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   core/list — Ticks
   -------------------------------------------------------------------------- */

.wp-block-list.is-style-dnh-ticks {
	list-style: none;
	padding-inline-start: 0;
}

.wp-block-list.is-style-dnh-ticks li {
	position: relative;
	padding-inline-start: 1.9em;
}

.wp-block-list.is-style-dnh-ticks li::before {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	top: 0.35em;
	width: 1.1em;
	height: 1.1em;
	background-color: var(--wp--preset--color--primary);
	-webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") no-repeat center / contain;
	mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* --------------------------------------------------------------------------
   core/table — Plain rows
   -------------------------------------------------------------------------- */

.wp-block-table.is-style-dnh-plain thead :where(th, td) {
	background: transparent;
	border-bottom-width: 2px;
}

.wp-block-table.is-style-dnh-plain :where(th, td) {
	padding-inline: 0 1.5rem;
}

/* --------------------------------------------------------------------------
   13. Mobile navigation overlay

   Core gives us two separate buttons — an "open" hamburger in the header and a
   "close" cross inside the overlay — and toggles the overlay with display,
   which cannot transition. This section:

     · fades the overlay in and out (@starting-style + allow-discrete handles
       the display:none → flex switch; older browsers simply snap, no harm)
     · replaces both icons with CSS lines so the hamburger reads as three bars
       and the cross animates in from flat
     · keeps the logo visible by lifting the header above the overlay, and lifts
       the cross above the header so it stays reachable
   -------------------------------------------------------------------------- */

/* Admin bar offsets everything for logged-in users; visitors get 0. */
:root { --dnh-admin-bar: 0px; }
body.admin-bar { --dnh-admin-bar: 32px; }
@media screen and (max-width: 782px) {
	body.admin-bar { --dnh-admin-bar: 46px; }
}

/* The overlay is a descendant of the header, so lifting the header lifts the
   overlay with it. The logo has to out-rank the overlay inside that same
   stacking context, which is what the z-index on the logo is for. */
.dnh-header {
	position: relative;
	z-index: 100;
	background: var(--wp--preset--color--base);
}

/* Core puts the open overlay at z-index 100000, so anything that must stay
   visible above it has to clear that number. */
.dnh-header .wp-block-site-logo {
	position: relative;
	z-index: 100001;
}

@media (max-width: 599px) {

	/* ---- the overlay itself ----
	   Core toggles this with display, which cannot transition. Rather than lean on
	   `transition-behavior: allow-discrete` (which left the container stuck at
	   display:flex after closing), keep it laid out permanently and drive it with
	   opacity + visibility. visibility:hidden also takes the closed menu out of
	   the accessibility tree, and pointer-events:none stops it swallowing clicks. */
	.dnh-nav .wp-block-navigation__responsive-container {
		display: flex;
		flex-direction: column;
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transition:
			opacity 0.28s ease,
			visibility 0s linear 0.28s;
	}

	.dnh-nav .wp-block-navigation__responsive-container.is-menu-open {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		padding-top: calc(var(--dnh-admin-bar) + 8.5rem);
		transition:
			opacity 0.28s ease,
			visibility 0s linear 0s;
	}

	/* ---- one control: three bars that fold into a cross ----
	   Core's close button stays in the DOM (nav.js delegates the close action to
	   it) but is never shown — the hamburger is the only control the user sees,
	   which is the only way the bars can actually animate into the cross. */
	.dnh-nav .wp-block-navigation__responsive-container-close { display: none; }

	.dnh-nav .wp-block-navigation__responsive-container-open svg { display: none; }

	.dnh-nav .wp-block-navigation__responsive-container-open {
		position: relative;
		z-index: 100002;
		width: 44px;
		height: 44px;
		margin-right: -9px;   /* keeps the bars on the content gutter */
		padding: 0;
		color: var(--wp--preset--color--ink);
		background: none;
		border: 0;
		cursor: pointer;
	}

	.dnh-nav .wp-block-navigation__responsive-container-open::before,
	.dnh-nav .wp-block-navigation__responsive-container-open::after,
	.dnh-nav .dnh-burger__bar {
		content: "";
		position: absolute;
		left: 9px;
		right: 9px;
		height: 2px;
		background: currentColor;
		border-radius: 2px;
		transition:
			transform 0.3s cubic-bezier(0.68, -0.4, 0.27, 1.4),
			opacity 0.16s ease;
	}

	.dnh-nav .wp-block-navigation__responsive-container-open::before { top: 13px; }
	.dnh-nav .wp-block-navigation__responsive-container-open::after  { bottom: 13px; }

	.dnh-nav .dnh-burger__bar {
		top: 50%;
		margin-top: -1px;
	}

	/* Open: the outer bars meet in the middle and cross; the centre bar goes. */
	.dnh-nav .wp-block-navigation__responsive-container-open.is-active::before {
		transform: translateY(8px) rotate(45deg);
	}

	.dnh-nav .wp-block-navigation__responsive-container-open.is-active::after {
		transform: translateY(-8px) rotate(-45deg);
	}

	.dnh-nav .wp-block-navigation__responsive-container-open.is-active .dnh-burger__bar {
		opacity: 0;
		transform: scaleX(0);
	}
	/* ---- menu items ---- */
	.dnh-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
		font-size: var(--wp--preset--font-size--heading-s);
		padding-block: 0.35rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dnh-nav .wp-block-navigation__responsive-container,
	.dnh-nav .wp-block-navigation__responsive-container-close::before,
	.dnh-nav .wp-block-navigation__responsive-container-close::after {
		transition: none;
	}
}

/* --------------------------------------------------------------------------
   14. Focus visibility on dark and green grounds

   The global focus ring is Parkland green, which measured 2.57:1 against the
   ink footer and is invisible on a green section. (WCAG 1.4.11 / 2.4.7)
   -------------------------------------------------------------------------- */

.dnh-footer :where(a, button, input, select, textarea, [tabindex]):focus-visible {
	outline-color: var(--wp--preset--color--accent);
}

.dnh-bg-primary :where(a, button, input, select, textarea, [tabindex]):focus-visible {
	outline-color: var(--wp--preset--color--base);
}