/*
Theme Name: Fenecor
Description: Block theme for a register-led reporting site: dated ledger rows, entry sheets and wide tables.
Text Domain: fenecor
Requires at least: 7.0
Requires PHP: 8.1
Version: 0.1.30
Update URI: false
*/

:focus-visible {
	outline: 3px solid var(--wp--preset--color--plumb);
	outline-offset: 2px;
}

.wp-site-blocks > * + * {
	margin-block-start: 0;
}

h1,
h2,
h3 {
	text-wrap: balance;
}

a:where(:not(.wp-element-button)) {
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

abbr[title] {
	text-decoration: underline dotted var(--wp--preset--color--plinth);
	cursor: help;
}

.wp-block-post-date,
.wp-block-post-terms {
	font-variant-numeric: lining-nums tabular-nums;
}

.wp-block-post-content > p:first-of-type {
	font-size: var(--wp--preset--font-size--preamble);
	line-height: 1.5;
}

/* The mark of the site title (core__site-title.css sizes it): the url is here because block sheets are inlined and lose relative paths. Relative to this file. */
.wp-block-site-title a::before {
	background-image: url("assets/brand/plumb.svg");
}

.wp-block-heading.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Featured image: core/post-featured-image prints nothing without an image, so there is no placeholder. 16:9 everywhere (a 3:2 crop of a 16:9 source loses a fifth of the frame, tools/card-aspect-check.sh); the ratio is the block's aspectRatio, the crop is cover. */
.wp-block-post-featured-image {
	margin-block: 0 var(--wp--preset--spacing--entry);
}

.wp-block-post-featured-image a {
	display: block;
}

.wp-block-post-featured-image img {
	width: 100%;
	max-width: 100%;
	object-fit: cover;
}

/* The picture in the head of a piece: the head's own padding closes the gap under it. */
.entry-head .wp-block-post-featured-image {
	max-width: 48rem;
	margin-block: var(--wp--preset--spacing--bank) 0;
}

/* On an article the picture runs the width of the head, as the title does: its right edge is the right edge of the text column below it
   (the text fills the column beside the side card, it is not stopped at 42rem any more). */
.single .entry-head .wp-block-post-featured-image {
	max-width: none;
}

/* Nothing in the text is wider than its column: a long address or word breaks, pictures and embeds shrink to the column,
   a preformatted block scrolls on its own (a table has its own scroll wrapper in core__table.css). */
.entry-body .wp-block-post-content {
	overflow-wrap: break-word;
}

/* The line length of an article (issue #349, about 65-75ch): beside the side card the column is about 974px at 1440px and up,
   about 120 characters a line, so the text stops at 72ch. Below that width the column is narrower than 72ch and nothing changes. */
.single .entry-body .wp-block-post-content {
	max-width: 72ch;
}

.entry-body .wp-block-post-content :is(img, video, canvas, svg) {
	max-width: 100%;
	height: auto;
}

.entry-body .wp-block-post-content :is(iframe, embed, object) {
	box-sizing: border-box;
	max-width: 100%;
}

.entry-body .wp-block-post-content pre {
	max-width: 100%;
	overflow-x: auto;
}

/* The note under a picture made by an AI: printed by inc/class-ai-figure.php on a single page only. */
.wp-block-post-featured-image figcaption.fenecor-ai-mark,
.wp-block-image figcaption.fenecor-ai-mark {
	margin-block-start: var(--wp--preset--spacing--cell);
	font-family: var(--wp--preset--font-family--register-sans);
	font-size: var(--wp--preset--font-size--footing);
	color: var(--wp--preset--color--margin-note);
	text-align: start;
}

@media print {
	header.wp-block-template-part,
	footer.wp-block-template-part,
	.wp-block-query-pagination {
		display: none;
	}

	body {
		background: #fff;
	}

	.wp-block-post-content a[href^="http"]::after {
		content: " (" attr(href) ")";
		font-size: 0.8em;
		word-break: break-all;
	}

	.wp-block-table {
		overflow: visible;
	}

	.wp-block-table table {
		min-width: 0;
	}
}

/* Tap targets: title, term and strip heading links are at least 24px high. */
.wp-block-post-title a, .wp-block-post-terms a, .wp-block-site-title a, .wp-block-query-pagination-numbers .page-numbers { display: inline-block; min-height: 1.5rem; padding-block: 0.1875rem; box-sizing: border-box; }
.wp-block-heading a { display: inline-block; min-height: 1.5rem; padding-block: 0.1875rem; box-sizing: border-box; }

/* Phone and touch screens: the same links are 44px targets (WCAG 2.5.8 / the design system). The 24px rule above stays for a mouse on a wide screen. The .wp-site-blocks prefix lifts the specificity over the block sheets (core__site-title.css, core__query-pagination.css), so the result does not depend on which sheet is printed last. Title, term, heading, page-number and site title links can hold markup (em, mark, strong, span) or be given some later, so they are inline-block, never flex (a flex display makes every child and every text run its own flex item: the spaces are lost and the children become narrow columns). The box is a real 44px box: border-box, min-block-size and min-inline-size 2.75rem (a one-digit page number is narrower than 44px), text centred by padding-block ((2.75rem - 1lh) / 2; .5rem for a browser without lh), overflow-wrap:anywhere keeps a long word or address inside the screen. The site title keeps its inline-block (its ::before mark is not shown, a flex display would reveal it). Inline links in running text are exempt and are not touched. */
@media (max-width: 599px), (pointer: coarse) {
	.wp-site-blocks .wp-block-post-title a,
	.wp-site-blocks .wp-block-post-terms a,
	.wp-site-blocks .wp-block-heading a,
	.wp-site-blocks .wp-block-query-pagination-numbers .page-numbers,
	.wp-site-blocks .wp-block-site-title a {
		display: inline-block;
		box-sizing: border-box;
		min-block-size: 2.75rem;
		min-inline-size: 2.75rem;
		padding-block: 0.5rem;
		padding-block: calc((2.75rem - 1lh) / 2);
		overflow-wrap: anywhere;
	}
}

/* Short pages: the footer sits at the bottom of the viewport, no bare strip under it. */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.wp-site-blocks > main {
	flex: 1 0 auto;
}

/* Menu toggle: a 44px tap target. */
.rubrics .wp-block-navigation__responsive-container-open {
	align-items: center;
	justify-content: center;
	min-height: 2.75rem;
	min-width: 2.75rem;
}

/* Phone header (below 600px): one row at most 64px high. The mark and the title stand on the left, the menu button on the right (its icon reaches the frame edge, the 44px target overhangs the gutter); the open menu is the core overlay. From 600px the stacked header is unchanged. The core sets the auto side margins of a constrained group child with !important, hence the !important here. */
@media (max-width: 599px) {
	.wp-block-group.masthead {
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: space-between;
		padding-block: 0.25rem;
	}

	.wp-block-group.masthead > * {
		margin-block: 0;
		margin-inline: 0 !important;
		max-width: none;
	}

	.wp-block-group.masthead .rubrics {
		padding-block: 0;
	}

	.wp-block-group.masthead .rubrics .wp-block-navigation__responsive-container-open {
		margin-inline-end: -0.625rem;
	}
}

/* The home page carries the site title as its one h1 (parts/header-home.html); on every other template the same title is a paragraph. A heading brings its own line height, margin and balanced wrapping, so the three are set back to what the paragraph had: the masthead looks the same on every template. The margin is 1em from 600px (the paragraph's own margin); below that the phone header rule above already zeroes it. */
.wp-block-group.masthead > h1.wp-block-site-title {
	line-height: inherit;
	text-wrap: wrap;
}

@media (min-width: 600px) {
	.wp-block-group.masthead > h1.wp-block-site-title {
		margin-block: 1em;
	}
}

/* Home page intro (the publication description under the masthead, before the lead story): a reading measure of 48rem on the left axis of the page (the left edge of the 76rem column of main, where the lead story starts), not a narrow centred island. The constrained layout of main sets the auto side margins of its children with !important, hence the !important here; the start margin is what auto would give a 76rem child. */
.home-intro {
	max-width: 48rem;
	margin-inline: calc((100% - min(100%, 76rem)) / 2) auto !important;
	margin-block-end: var(--wp--preset--spacing--entry);
	text-wrap: pretty;
}

/* Close button of the open menu overlay (the overlay exists only below 600px): core draws it 24px (the icon, no padding) and pins it absolute at top/right. Padding 0.625rem (10px, a whole number of pixels) on every side makes the box 44px, and the equal negative margin keeps the icon where it was: for an absolute box pinned at the top and the right edge the negative margin moves the edges outward, so the box grows around the same centre, nothing in the overlay moves and the open button (already 44px) is untouched. The .wp-site-blocks prefix lifts the specificity over the core rule that sets margin and padding to 0. No flex, no min-size (the button is as tall as its 24px icon plus the padding). */
@media (max-width: 599px) {
	.wp-site-blocks .wp-block-navigation__responsive-container-close {
		margin: -0.625rem;
		padding: 0.625rem;
	}
}

/* Author name link in the article side sheet: core draws it as plain inline text, 102x17px. As an inline grid with a 2.75rem (44px) minimum height the box is 44px tall and keeps its text width (over 44px), and the text stays vertically centred; a grid, not a flex container, so the link keeps its block behaviour for the text (no flex links). */
.wp-block-post-author-name__link {
	display: inline-grid;
	align-content: center;
	min-height: 2.75rem;
}

/* Search button: the palette colour, not the core default grey. */
.wp-block-search .wp-block-search__button {
	background: var(--wp--preset--color--sepia);
	color: var(--wp--preset--color--deed);
}
