/*
Theme Name: Valiria
Text Domain: valiria
Version: 0.7.23
Description: Block theme for a reference publication on seller economics: a restrained ledger look, tabular figures, warm paper.
Requires PHP: 8.1
Requires at least: 7.0
Tested up to: 7.0
License: GNU General Public License v2 or later
Update URI: false
*/

:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--audit);
	outline-offset: 3px;
}

:where(h1, h2, h3, h4, h5, h6) {
	overflow-wrap: break-word;
	text-wrap: balance;
}

:where(.wp-block-post-content) > :where(.wp-block-table) {
	margin-block: var(--wp--preset--spacing--block);
}

.wp-block-site-title {
	font-family: var(--wp--preset--font-family--rowhead);
	font-size: var(--wp--preset--font-size--subtotal);
	font-weight: 700;
	letter-spacing: -0.02em;
}

.wp-block-site-title a,
.wp-block-post-title a {
	color: var(--wp--preset--color--net);
	text-decoration: none;
}

.wp-block-post-title a:hover {
	text-decoration: underline;
}

.wp-block-navigation {
	font-family: var(--wp--preset--font-family--rowhead);
	font-size: var(--wp--preset--font-size--footnote);
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.wp-block-navigation a {
	text-decoration: none;
}

.wp-block-post-terms,
.wp-block-post-date,
.valiria-byline {
	color: var(--wp--preset--color--accrual);
	font-size: var(--wp--preset--font-size--footnote);
}

/* Byline under the article text: core/post-author-name prints the author's display name ("Editorial team") with no prefix; same small type and colour as the dates, not upper-cased, so the visible text stays as the author wrote it. */
.valiria-byline {
	margin-block: var(--wp--preset--spacing--row) 0;
}

.wp-block-post-terms {
	font-family: var(--wp--preset--font-family--rowhead);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.wp-block-quote {
	padding-left: var(--wp--preset--spacing--gutter);
	border-left: 3px solid var(--wp--preset--color--fee);
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto !important;
		transition: none !important;
	}
}

.wp-site-blocks > main {
	margin-block-start: var(--wp--preset--spacing--block);
}

.valiria-masthead,
.valiria-colophon,
.valiria-feeband {
	padding-inline: var(--wp--style--root--padding-left);
}

.valiria-masthead {
	padding-top: var(--wp--preset--spacing--gutter);
}

.valiria-masthead-top {
	padding-bottom: var(--wp--preset--spacing--row);
}

.valiria-sections {
	border-top: var(--wp--custom--ledger--stroke--total) solid var(--wp--preset--color--net);
	border-bottom: var(--wp--custom--ledger--stroke--hair) solid var(--wp--preset--color--rule);
	padding-block: var(--wp--preset--spacing--cell);
}

.valiria-lead,
.valiria-hub,
.valiria-case {
	margin-bottom: var(--wp--preset--spacing--block);
}

.valiria-statement {
	margin-bottom: var(--wp--preset--spacing--block);
}

.valiria-line {
	padding-block: var(--wp--preset--spacing--row);
	border-bottom: var(--wp--custom--ledger--stroke--hair) solid var(--wp--preset--color--rule);
}

.valiria-feeband,
.valiria-colophon {
	padding-block: var(--wp--preset--spacing--block);
}

.valiria-colophon {
	margin-top: var(--wp--preset--spacing--section);
	border-top: var(--wp--custom--ledger--stroke--total) solid var(--wp--preset--color--net);
}

/* Case card: company or SKU on top; the weekly figure sits in a narrow rail. */
.valiria-subject {
	gap: var(--wp--preset--spacing--cell) var(--wp--preset--spacing--row);
	align-items: baseline;
}

.valiria-bottomline {
	font-size: var(--wp--preset--font-size--subtotal);
}

/* The deciding figure and the rail. */
.valiria-keyfigure {
	margin-top: var(--wp--preset--spacing--row);
	padding: var(--wp--preset--spacing--row) var(--wp--preset--spacing--gutter);
	border-left: var(--wp--custom--ledger--stroke--total) solid var(--wp--preset--color--fee);
	background: var(--wp--preset--color--gross);
}

.valiria-keyfigure .wp-block-post-excerpt {
	font-family: var(--wp--preset--font-family--rowhead);
	font-size: var(--wp--preset--font-size--total);
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
}

.valiria-count,
.valiria-facts {
	padding-top: var(--wp--preset--spacing--row);
	border-top: var(--wp--custom--ledger--stroke--total) solid var(--wp--preset--color--net);
}

.valiria-facts {
	display: grid;
	gap: var(--wp--preset--spacing--cell);
}

/* Dates in the facts column: the label is a real paragraph; when core prints no date (modified before published), the whole line goes. */
.wp-block-group.valiria-dated {
	gap: 0.35em;
	align-items: baseline;
}

.valiria-dated > p {
	margin: 0;
	color: var(--wp--preset--color--accrual);
}

.valiria-dated:not(:has(time)) {
	display: none;
}

/* Related entries close the article under a heavy rule, like a subtotal line. */
.valiria-related {
	margin-top: var(--wp--preset--spacing--section);
	padding-top: var(--wp--preset--spacing--row);
	border-top: var(--wp--custom--ledger--stroke--total) solid var(--wp--preset--color--net);
}

/* Archive rows stack the excerpt and the date under the title (one column at every width), so the cell reads from the left edge, not ragged to the right. */
.valiria-cell-figure {
	text-align: left;
	font-variant-numeric: tabular-nums;
}

.valiria-line .wp-block-post-excerpt {
	margin-block: 0;
}

@media (min-width: 782px) {
	.valiria-count {
		position: sticky;
		top: var(--wp--preset--spacing--gutter);
	}
}

::selection {
	background: var(--wp--preset--color--rebate);
	color: var(--wp--preset--color--net);
}

/* Readers print tables for the accountant: no chrome, links spelled out. */
@media print {
	.valiria-masthead,
	.valiria-colophon,
	.is-style-count-rail,
	.wp-block-search,
	.wp-block-query-pagination {
		display: none;
	}

	.wp-block-post-content a[href^="http"]::after {
		content: " (" attr(href) ")";
		font-size: var(--wp--preset--font-size--footnote);
	}
}

/* Brand mark in the masthead: the letterhead image, 30 px high (22 px on narrow screens). */
.valiria-brand {
	margin: 0;
}

.valiria-brand a {
	display: inline-block;
}

.valiria-brand img {
	display: block;
	height: 30px;
	width: auto;
	max-width: 100%;
}

@media (max-width: 720px) {
	.valiria-brand img {
		height: 22px;
	}
}

/* Featured images: cropped, never stretched; the block prints nothing when a post has no image. */
.valiria-figure {
	margin-block: 0 var(--wp--preset--spacing--row);
}

.valiria-figure img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.valiria-figure--hero {
	margin-block-end: var(--wp--preset--spacing--block);
}

.valiria-figure--line {
	max-width: 24rem;
}

/* The note that the picture was made by an AI sits under the picture of an article or a service page, small and plain; cards have none. */
.valiria-ai-note {
	margin-block: var(--wp--preset--spacing--cell) 0;
	font-size: var(--wp--preset--font-size--footnote);
	text-align: start;
}

/* Home: teardown rows keep the excerpt beside the title, left-aligned; the Count rail does not leave a blank column. */
.valiria-statement .valiria-cell-figure {
	text-align: left;
}

.valiria-statement .valiria-line {
	align-items: flex-start;
}

.valiria-feeband > * {
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
}

@media (max-width: 781px) {
	.valiria-statement .valiria-line > .wp-block-column {
		flex-basis: 100% !important;
	}
}

/* Header: comfortable tap targets for the section links. The box is 44px of content plus the 0.6rem padding (63 px on one line), as it always was; the label is centred by the padding. */
.valiria-sections .wp-block-navigation-item__content {
	box-sizing: border-box;
	display: inline-block;
	min-height: calc(44px + 1.2rem);
	padding-block: 0.6rem;
	padding-block: calc((44px + 1.2rem - 1lh) / 2);
}

.valiria-masthead-top .wp-block-search {
	max-width: 100%;
}

/* Breadcrumbs: the links reach 44px on a tablet and a phone; the row keeps its look. */
@media (max-width: 781px) {
	.wp-block-breadcrumbs a {
		box-sizing: border-box;
		display: inline-block;
		min-height: 44px;
		padding-block: 0.5rem;
		padding-block: calc((44px - 1lh) / 2);
	}
}

/* Related entries, 404 and search results: the date stays on one line beside the title. */
.valiria-related .valiria-line,
.valiria-line.wp-block-group {
	flex-wrap: nowrap;
	align-items: baseline;
	gap: var(--wp--preset--spacing--row);
}

.valiria-related .valiria-line .wp-block-post-title,
.valiria-line.wp-block-group > .wp-block-post-title {
	flex: 1 1 auto;
	min-width: 0;
}

.valiria-related .valiria-line .wp-block-post-date,
.valiria-line.wp-block-group > .wp-block-post-date {
	flex: 0 0 auto;
	white-space: nowrap;
}

/* Article: table text is body size. */
.valiria-case .wp-block-post-content .wp-block-table :is(th, td) {
	font-size: 1rem;
}

/* Tap targets: footer links, read-more and one-line list titles reach 44px. */
.valiria-colophon .wp-block-navigation-item__content,
.wp-block-post-excerpt__more-link,
.valiria-line .wp-block-post-title a {
	box-sizing: border-box;
	display: inline-block;
	min-height: 44px;
	padding-block: 0.5rem;
	padding-block: calc((44px - 1lh) / 2);
}

/* Colophon on a phone: the six About links sit in two columns (every link keeps its 44px box, a wrapped one too, centred by a grid, never a flex link), the blocks sit closer together; no link or line is removed, the desktop is untouched. */
@media (max-width: 599px) {
	.valiria-colophon {
		margin-top: var(--wp--preset--spacing--block);
		padding-block: var(--wp--preset--spacing--gutter);
	}

	.valiria-colophon .wp-block-columns {
		gap: var(--wp--preset--spacing--cell);
	}

	.valiria-colophon .wp-block-navigation__container {
		display: grid;
		gap: 0 var(--wp--preset--spacing--row);
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.valiria-colophon .wp-block-navigation-item__content {
		display: grid;
		align-content: center;
		padding-block: 0;
	}
}

/* List titles can wrap: a table cell gives 44px as a minimum and centres a one-line title; a wrapped title grows only by its own lines (padding would add 16px to each). */
.valiria-line .wp-block-post-title a {
	block-size: 2.75rem;
	display: table-cell;
	padding-block: 0;
	vertical-align: middle;
}

/* Rows stack the excerpt under the title; spacing before images; readable rail; fitting tables. */
.valiria-statement .valiria-line,
.wp-block-query .wp-block-columns.valiria-line {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
}

.wp-block-columns.valiria-line > .wp-block-column {
	flex-basis: auto !important;
}

.valiria-subject {
	margin-bottom: 0.75rem;
}

.valiria-casecard .wp-block-post-title {
	margin-bottom: 1.5rem;
}

.valiria-case .wp-block-post-title {
	margin-bottom: 1.5rem;
}

.valiria-bottomline {
	color: inherit;
}

.valiria-count h2.has-footnote-font-size {
	font-size: var(--wp--preset--font-size--subtotal) !important;
}

.valiria-count .has-footnote-font-size,
.valiria-count .wp-block-post-date {
	font-size: 0.9375rem !important;
}

@media (min-width: 782px) {
	.valiria-facts {
		position: sticky;
		top: var(--wp--preset--spacing--gutter);
		align-self: flex-start;
	}
}

@media (max-width: 781px) {
	.valiria-facts {
		display: flex;
		flex-wrap: wrap;
		gap: 0.25rem 1rem;
		border-top: 0;
		padding-top: 0;
	}

	/* Section label and tag links (the article, the cards and the lists): a 44px box in both directions on a tablet and a phone; the line keeps its look. */
	.wp-block-post-terms a {
		box-sizing: border-box;
		display: inline-block;
		min-height: 2.75rem;
		min-inline-size: 2.75rem;
		overflow-wrap: anywhere;
		padding-block: 0.5rem;
		padding-block: calc((2.75rem - 1lh) / 2);
	}

	.valiria-count {
		padding: var(--wp--preset--spacing--row) var(--wp--preset--spacing--gutter);
		background: var(--wp--preset--color--gross);
	}

	.valiria-case .wp-block-post-content .wp-block-table :is(th, td) {
		padding: 0.5rem 0.4rem;
		font-size: 0.875rem;
	}

	.valiria-case .wp-block-table table {
		min-width: 0;
		width: 100%;
	}
}

/* Header on a phone: one ledger line, brand on the left and the two-rule handle on the right. The handle opens a sheet with the sections and the search; from 600 px the old two-row masthead stays as it was. */
.valiria-ledger-find {
	display: none;
}

@media (max-width: 599px) {
	.wp-block-group.valiria-masthead {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--wp--preset--spacing--row);
		padding-block: 0.4375rem;
		border-top: var(--wp--custom--ledger--stroke--total) solid var(--wp--preset--color--net);
		border-bottom: var(--wp--custom--ledger--stroke--hair) solid var(--wp--preset--color--rule);
	}

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

	.valiria-masthead-top {
		flex-wrap: nowrap;
		padding-bottom: 0;
	}

	.valiria-masthead-top .valiria-desk-find,
	.valiria-masthead-top .wp-block-site-tagline {
		display: none;
	}

	.valiria-brand a {
		box-sizing: border-box;
		min-height: 44px;
		padding-block: calc((44px - 30px) / 2);
		vertical-align: top;
	}

	.valiria-sections {
		flex: 0 0 auto;
		padding: 0;
		border: 0;
	}

	/* The handle: a 44 px touch zone around a 24 px glyph; the glyph sits on the 22 px text edge. */
	.valiria-sections .wp-block-navigation__responsive-container-open {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 44px;
		min-height: 44px;
		margin-inline-end: -10px;
		padding: 0;
		color: var(--wp--preset--color--net);
	}

	/* The sheet: section lines ruled like the ledger, the search closing the page. */
	.valiria-sections .wp-block-navigation__responsive-container.is-menu-open {
		padding: var(--wp--preset--spacing--gutter);
	}

	.valiria-sections .is-menu-open .wp-block-navigation__responsive-container-content {
		padding-top: var(--wp--preset--spacing--block);
	}

	.valiria-sections .is-menu-open .wp-block-navigation__responsive-container-content,
	.valiria-sections .is-menu-open .wp-block-navigation__container {
		width: 100%;
		gap: 0;
		align-items: stretch;
	}

	.valiria-sections .is-menu-open .wp-block-navigation-item {
		width: 100%;
		border-bottom: var(--wp--custom--ledger--stroke--hair) solid var(--wp--preset--color--rule);
	}

	.valiria-sections .is-menu-open .valiria-ledger-find .wp-block-search__input {
		text-transform: none;
		letter-spacing: normal;
	}

	.valiria-sections .is-menu-open .wp-block-navigation-item__content {
		width: 100%;
	}

	.valiria-sections .is-menu-open .valiria-ledger-find {
		display: block;
		width: 100%;
		margin-top: var(--wp--preset--spacing--gutter);
		border-bottom: 0;
	}
}

/* Masthead caption: the line under the brand shares the brand row, so the header is exactly as tall as the row (the search field sets it) and the caption adds no height. The caption is the site tagline as it is, printed in full and wrapping inside 16rem beside the brand (no clamp, no ellipsis); below 900 px the row is too narrow for it and the caption is not printed (the phone header already hides it). */
.valiria-brandline {
	flex-wrap: nowrap;
	align-items: center;
	gap: var(--wp--preset--spacing--row);
	min-width: 0;
}

.valiria-brandline .wp-block-site-tagline {
	flex: 0 1 auto;
	min-width: 0;
	max-width: 16rem;
	margin: 0;
	line-height: 1.3;
	overflow-wrap: break-word;
}

@media (max-width: 899px) {
	.valiria-brandline .wp-block-site-tagline {
		display: none;
	}
}

/* Article: lead and body share one left edge, the edge of the title and the hero. The layout of the content block centres every child with !important margins, so the rule has to be !important too to win; wide and full blocks keep their own alignment. */
.valiria-case .wp-block-post-content.is-layout-constrained > :not(.alignwide, .alignfull) {
	margin-inline-start: 0 !important;
	margin-inline-end: auto !important;
}

/* Tap targets of the title links, the pagination and the section lists on a phone, a tablet and a coarse pointer.
   Title links (the cards on the home page, the search results) are inline: their box is the font's content area, 17 px for one line at 390 px. A block-end padding of 1.75rem (28 px) grows
   the box downwards to 45 px or more; padding on an inline box changes no line, wrap or gap, so nothing moves. Downwards only: the label links above are 44 px boxes of their own and a growth upwards would
   take their area. The date or the excerpt that follows a title directly holds text only (no link), so it lets taps through: a later box wins a hit test and would cut the lower part of the zone.
   List rows of the ledger keep their own table-cell box (more specific rule, padding 0). Pagination and the section lists become 44 px inline-blocks (never flex: a flex link breaks its children). */
@media (max-width: 781px), (pointer: coarse) {
	.wp-block-post-title a {
		padding-block-end: 1.75rem;
	}

	.wp-block-post-title + .wp-block-post-date,
	.wp-block-post-title + .wp-block-post-excerpt {
		pointer-events: none;
	}

	.wp-block-query-pagination a,
	main > .wp-block-list a {
		box-sizing: border-box;
		display: inline-block;
		min-block-size: 2.75rem;
		min-inline-size: 2.75rem;
		padding-block: 0.5rem;
		padding-block: calc((2.75rem - 1lh) / 2);
		text-align: center;
	}

	main > .wp-block-list a {
		text-align: start;
	}
}
