/*
 * Layer: components. Site chrome and the reading grid.
 * Colours read the piece slots so a story root re-colours what it wraps.
 */
@layer components {

	/* Masthead: lockup left, nav right, sits on the page's ground. */
	.vt-masthead {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		gap: var(--wp--preset--spacing--2) var(--wp--preset--spacing--6);
		max-inline-size: var(--wp--custom--layout--cover);
		margin-inline: auto;
		padding-block: 18px;
		padding-inline: var(--wp--preset--spacing--gutter);
	}

	/* Flex row, not flow: core's block gap would drop the nav 12px. */
	:where(.vt-masthead) > * {
		margin-block: 0;
	}

	.vt-wordmark {
		gap: 12px;
		color: var(--ink);
	}

	.vt-level-mark {
		display: block;
		flex: none;
	}

	.vt-level-mark__line {
		stroke: var(--mark);
	}

	.vt-level-mark__eye {
		fill: var(--paper);
	}

	.vt-wordmark__name {
		margin: 0;
		font-family: var(--wp--preset--font-family--display);
		font-size: 26px;
		line-height: 1;
		white-space: nowrap;
	}

	.vt-wordmark__name a {
		color: inherit;
		text-decoration: none;
	}

	.vt-site-nav,
	.vt-footer__nav,
	.vt-footer__label {
		font-family: var(--wp--preset--font-family--mono);
		font-size: var(--wp--preset--font-size--label);
		line-height: var(--wp--custom--lead--label);
		color: var(--ink-soft);
	}

	.vt-site-nav {
		column-gap: 28px;
	}

	.vt-site-nav a,
	.vt-footer__nav a,
	.vt-menu a {
		display: inline-flex;
		align-items: center;
		min-block-size: var(--wp--custom--touch);
		text-decoration: none;
	}

	.vt-footer__list a {
		color: inherit;
	}

	.vt-site-nav a:hover,
	.vt-footer__nav a:hover,
	.vt-menu a:hover {
		color: var(--mark);
	}

	/*
	 * Narrow screens: a native popover holds the same links. Its open and
	 * closed states are the browser's, so the end state needs no JS.
	 */
	.vt-menu-trigger {
		display: none;
		align-items: center;
		min-block-size: var(--wp--custom--touch);
		padding: 0;
		border: 0;
		background: none;
		font-family: var(--wp--preset--font-family--mono);
		font-size: var(--wp--preset--font-size--label);
		line-height: var(--wp--custom--lead--label);
		color: var(--ink-soft);
		cursor: pointer;
	}

	.vt-menu-trigger:hover {
		color: var(--mark);
	}

	/* A sheet under the masthead: top rule, 18px, touch row, 18px. */
	.vt-menu {
		--vt-masthead: calc(var(--wp--custom--touch) + 36px);

		inset: calc(var(--wp--custom--border--top-rule) + var(--vt-masthead)) 0 auto;
		inline-size: auto;
		margin: 0;
		padding: var(--wp--preset--spacing--2) var(--wp--preset--spacing--gutter);
		border: 0;
		border-block-end: var(--wp--custom--border--hair) solid var(--rule);
		background: var(--paper);
		color: var(--ink);
		font-family: var(--wp--preset--font-family--mono);
		font-size: var(--wp--preset--font-size--label);
		line-height: var(--wp--custom--lead--label);
	}

	.vt-menu ul {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	/* The kit's breakpoint: links fold into the Menu. */
	@media (width <= 880px) {

		.vt-site-nav {
			display: none;
		}

		.vt-menu-trigger {
			display: inline-flex;
		}
	}

	/* Reading grid: label column + text column inside the read width. */
	.vt-reading {
		--vt-label: var(--wp--custom--layout--label);
		--vt-gap: var(--wp--custom--layout--col-gap);
		--vt-text: var(--wp--custom--layout--text);
		--vt-wide: var(--wp--custom--layout--wide);
		--vt-read: var(--wp--custom--layout--read);
		--vt-gutter: var(--wp--preset--spacing--gutter);
		--vt-extra: calc(var(--vt-wide) - var(--vt-text));
		--vt-used: calc(var(--vt-label) + var(--vt-gap) + var(--vt-wide));
		--vt-rest: calc(var(--vt-read) - var(--vt-used));

		display: grid;
		grid-template-columns:
			[full-start] minmax(var(--vt-gutter), 1fr)
			[read-start label-start] minmax(0, var(--vt-label))
			[label-end] minmax(0, var(--vt-gap))
			[text-start] minmax(0, var(--vt-text))
			[text-end] minmax(0, var(--vt-extra))
			[wide-end] minmax(0, var(--vt-rest))
			[read-end] minmax(var(--vt-gutter), 1fr)
			[full-end];
		align-items: start;
	}

	:where(.vt-reading) > * {
		grid-column: text;
	}

	:where(.vt-reading) > :where(.vt-label) {
		grid-column: label;
	}

	/* A label opening its parent has no flow margin; neither has its partner. */
	:where(.vt-reading, .vt-ground) > :where(.vt-label:first-child + *) {
		margin-block-start: 0;
	}

	:where(.vt-reading) > :where(.alignwide) {
		grid-column: read;
	}

	:where(.vt-reading) > :where(.alignfull) {
		grid-column: full;
	}

	/* Phones: one column, the label stacks above its text. */
	@media (width <= 880px) {

		.vt-reading {
			grid-template-columns:
				[full-start] var(--vt-gutter)
				[read-start label-start text-start] minmax(0, 1fr)
				[label-end text-end wide-end read-end] var(--vt-gutter)
				[full-end];
		}
	}

	/* Apparatus beside the text: mono, soft, level with the first line. */

	/* Block-start margin left to the flow, so a label keeps its partner's row. */
	.vt-label {
		margin-inline: 0;
		margin-block-end: 0;
		padding-block-start: 0.75rem;
		font-family: var(--wp--preset--font-family--mono);
		font-size: var(--wp--preset--font-size--label);
		line-height: var(--wp--custom--lead--label);
		color: var(--ink-soft);
	}

	.vt-main {
		padding-block-end: var(--wp--preset--spacing--section);
	}

	/*
	 * A piece page's masthead sits on the story's cover ground, as the head
	 * does, so the first view is one envelope. The palette root wraps the
	 * masthead and main (custom properties never flow sideways).
	 */
	.vt-site-header--piece {
		--ink: var(--cover-ink);
		--ink-soft: var(--cover-soft);
		--paper: var(--cover);
		--mark: var(--cover-mark, var(--wp--custom--color--mark));

		background-color: var(--cover);
	}

	/* Flush under the masthead: drop the root blockGap strip above main. */
	.vt-piece-page > .vt-main {
		margin-block-start: 0;
	}

	/*
	 * The cover ground: the piece opens on its plate's colour. A dark cover
	 * gets --cover-mark (accent-on-dark) from the piece head rule; light
	 * covers keep the house mark. Never var(--mark) as the fallback: that
	 * is a cycle, which makes --mark invalid.
	 */
	.vt-piece__head {
		--ink: var(--cover-ink);
		--ink-soft: var(--cover-soft);
		--paper: var(--cover);
		--mark: var(--cover-mark, var(--wp--custom--color--mark));

		padding-block: var(--wp--preset--spacing--section);
		background-color: var(--cover);
		color: var(--ink);
	}

	.vt-piece__title {
		max-inline-size: 13ch;
	}

	/* Standing pages: short titles, one line where it fits, looser on wrap. */
	.vt-page .vt-piece__title {
		max-inline-size: 20ch;
		line-height: var(--wp--custom--lead--standing);
		text-wrap: balance;
	}

	/*
	 * Cover art, the plate shown whole: contained, anchored bottom-right,
	 * on its own ground. The scrim is the ground fading out, never grey.
	 */
	.vt-piece__art {
		position: relative;
		grid-column: full;
		margin: 0;
		overflow: clip;
	}

	.vt-piece__art img {
		display: block;
		inline-size: 100%;
		block-size: auto;
		aspect-ratio: 21 / 9;
		object-fit: contain;
		object-position: right bottom;
	}

	.vt-piece__art::after {
		--vt-veil: color-mix(in oklab, var(--cover) 40%, transparent) 55%;

		content: "";
		position: absolute;
		inset: 0 45% 0 0;
		background: linear-gradient(90deg, var(--cover), var(--vt-veil), transparent);
		pointer-events: none;
	}

	.vt-piece__credit {
		position: relative;
		z-index: 1;
		padding-block-start: 0.75rem;
		padding-inline: var(--wp--preset--spacing--gutter);
		font-family: var(--wp--preset--font-family--mono);
		font-size: var(--wp--preset--font-size--micro);
		line-height: 1.6;
		color: var(--ink-soft);
	}

	/* The plate settles in; it is visible from the first frame. */
	@media (prefers-reduced-motion: no-preference) {

		.vt-piece__art img {
			animation: vt-plate-settle 1400ms cubic-bezier(0.2, 0.7, 0.2, 1);
		}
	}

	@keyframes vt-plate-settle {

		from {
			transform: scale(1.03);
		}
	}

	/* Only the fallback head needs the gap; a cover block sits flush. */
	.vt-piece__head + .vt-piece__body {
		padding-block-start: var(--wp--preset--spacing--block);
	}

	:where(.vt-piece__body, .vt-ground) > p {
		max-inline-size: var(--wp--custom--measure--body);
	}

	/*
	 * Grounds: full-bleed sections that keep the reading grid's named
	 * lines (subgrid). Each ground re-points the reading slots, so text,
	 * labels and charts inside re-colour by inheritance.
	 */
	.vt-ground {
		grid-column: full;
		display: grid;
		grid-template-columns: subgrid;
		align-items: start;
		padding-block: var(--wp--preset--spacing--section);
		background-color: var(--paper);
		color: var(--ink);
	}

	:where(.vt-ground) > * {
		grid-column: text;
	}

	:where(.vt-ground) > :where(.vt-label) {
		grid-column: label;
	}

	:where(.vt-ground) > :where(.alignwide) {
		grid-column: read;
	}

	/*
	 * A spread brings its own label: first child in the label column, the
	 * rest in the text column, on the parent's lines (subgrid).
	 */
	.vt-reading > .vt-spread,
	.vt-ground > .vt-spread {
		grid-column: label-start / text-end;
		grid-template-columns: subgrid;
		column-gap: 0;
	}

	:where(.vt-spread) > * {
		grid-column: text;
	}

	:where(.vt-spread) > :first-child {
		grid-column: label;
		padding-block-start: 0.875rem;
	}

	/* Dark band: the immersive evidence. */
	.vt-ground--band {
		--paper: var(--band);
		--ink: var(--band-ink);
		--ink-soft: var(--band-soft);
		--rule: var(--band-rule);
		--mark: var(--band-accent, var(--band-mark));
	}

	/* Warm field: the standing view, the page's loudest moment. */
	.vt-ground--field {
		--paper: var(--field);
		--ink: var(--field-ink);
		--ink-soft: color-mix(in oklab, var(--field-ink) 80%, var(--field));
	}

	/*
	 * Cover ground: a section on the piece's cover colours. The cover's mark
	 * ink keeps 4.5:1 there; the house mark is the fallback, never --mark
	 * itself (a self-reference is a cycle, NRG-T2).
	 */
	.vt-ground--cover {
		--paper: var(--cover);
		--ink: var(--cover-ink);
		--ink-soft: var(--cover-soft);
		--rule: var(--cover-rule, var(--cover-soft));
		--mark: var(--cover-mark-text, var(--wp--custom--color--mark));
	}

	/*
	 * Hinge ground: the statement over a full-bleed plate. The house mark is
	 * 2.53:1 on the hinge sky, so --mark re-points to the hinge mark; --bone
	 * puts any bone-ground block on the hinge colour. The house soft ink is
	 * 4.1:1 there, so soft ink derives from the hinge ink as the field does.
	 */
	.vt-ground--hinge {
		--paper: var(--hinge, var(--paper-deep));
		--bone: var(--hinge, var(--paper-deep));
		--ink: var(--hinge-ink, var(--cover-ink));
		--ink-soft: color-mix(in oklab, var(--hinge-ink, var(--cover-ink)) 80%, var(--hinge, var(--paper-deep)));
		--mark: var(--hinge-mark, var(--wp--custom--color--mark));

		padding-block: 0;
	}

	:where(.vt-ground) > :where(.alignfull) {
		grid-column: full;
	}

	/* The plate fades in from the statement above it; a mask reads alpha only. */
	.vt-ground--hinge > .alignfull:last-child img {
		mask-image: linear-gradient(180deg, transparent, var(--ink) 22%);
	}

	/* The hinge sentence: one per piece, 20ch at most. */
	.vt-statement {
		grid-column: read;
		max-inline-size: 20ch;
		margin-block-end: 0;
		font-family: var(--wp--preset--font-family--display);
		font-size: clamp(2.25rem, 5vw, 4.5rem);
		line-height: 1.02;
		letter-spacing: -0.01em;
		text-wrap: balance;
	}

	/* Big numerals are evidence: tabular, tight, unit in soft ink. */
	.vt-numeral {
		margin-block-end: 0;
		font-family: var(--wp--preset--font-family--display);
		font-size: clamp(3rem, 7vw, 5.5rem);
		font-variant-numeric: tabular-nums;
		line-height: 0.95;
		letter-spacing: -0.03em;
	}

	.vt-numeral :where(small) {
		font-size: 0.4em;
		letter-spacing: 0;
		color: var(--ink-soft);
	}

	/* Story list: each entry lines up with the reading grid. */
	.vt-list {
		padding-block-start: var(--wp--preset--spacing--section);
	}

	.vt-list__items {
		grid-column: label-start / text-end;
		display: grid;
		grid-template-columns: subgrid;
		row-gap: var(--wp--preset--spacing--block);
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.vt-list__items > li {
		grid-column: 1 / -1;
		display: grid;
		grid-template-columns: subgrid;
		align-items: start;
	}

	.vt-list__items > li > * {
		grid-column: text;
	}

	.vt-list__items > li > .vt-label {
		grid-column: label;
	}

	.vt-list__title {
		margin-block: 0;
		line-height: var(--wp--custom--lead--standing);
	}

	.vt-list__excerpt {
		max-inline-size: var(--wp--custom--measure--standfirst);
		color: var(--ink-soft);
	}

	.vt-list__pagination {
		grid-column: text;
		font-family: var(--wp--preset--font-family--mono);
		font-size: var(--wp--preset--font-size--label);
	}

	.vt-empty {
		max-inline-size: var(--wp--custom--layout--read);
		margin-inline: auto;
		padding-block: var(--wp--preset--spacing--section);
		padding-inline: var(--wp--preset--spacing--gutter);
	}

	/* Footer: the last thing on any page. Nothing below it. */
	.vt-footer {
		padding-block: clamp(2.5rem, 5vw, 4rem) clamp(1.75rem, 4vw, 2.5rem);
		padding-inline: var(--wp--preset--spacing--gutter);
		background-color: var(--paper-deep);
		color: var(--ink);
	}

	.vt-footer .vt-level-mark__eye {
		fill: var(--paper-deep);
	}

	.vt-footer__main,
	.vt-footer__imprint {
		max-inline-size: var(--wp--custom--layout--read);
		margin-inline: auto;
	}

	/* One layout for every template and site (design/footer/). */
	.vt-footer__main {
		display: grid;
		grid-template-columns: minmax(0, 1fr) repeat(3, auto);
		align-items: start;
		gap: 2rem var(--wp--custom--layout--col-gap);
	}

	.vt-wordmark--small .vt-wordmark__name {
		font-size: 22px;
	}

	.vt-footer__tagline {
		margin-block: 18px 0;
		font-family: var(--wp--preset--font-family--display);
		font-size: 24px;
		line-height: 1.15;
	}

	.vt-footer__tagline em {
		color: var(--mark);
	}

	.vt-footer__note {
		max-inline-size: 40ch;
		margin-block: 8px 0;
		font-size: var(--wp--preset--font-size--note);
		line-height: 1.5;
		color: var(--ink-soft);
	}

	.vt-footer__nav {
		align-self: start;
		row-gap: 10px;
	}

	/*
	 * Kit Imprint column label: sits level with the first link row, and is
	 * quieter than the links it names.
	 */
	.vt-footer__label {
		display: flex;
		align-items: center;
		min-block-size: var(--wp--custom--touch);
		margin: 0;
		color: var(--ink-soft);
	}

	.vt-footer__imprint {
		margin-block-start: 2.5rem;
		padding-block-start: 1.25rem;
		border-block-start: var(--wp--custom--border--hair) solid var(--rule);
		font-family: var(--wp--preset--font-family--mono);
		font-size: var(--wp--preset--font-size--micro);
		line-height: 1.6;
		color: var(--ink-soft);
	}

	/* The reviewed mock's © line keeps a paragraph's 1em above and below. */
	.vt-footer__imprint > p {
		margin-block: 1em;
	}

	/* Grid cells of a flow-layout group: no flow margin. */
	.vt-footer__brand,
	.vt-footer__col {
		margin-block: 0;
	}

	.vt-footer__col {
		display: grid;
		align-content: start;
		row-gap: 10px;
	}

	.vt-footer__list {
		display: grid;
		margin: 0;
		padding: 0;
		list-style: none;
		color: var(--ink);
	}

	/*
	 * No label: the flags say it. Four of them match a label and its three
	 * links.
	 */
	.vt-footer__lang {
		gap: 10px;
	}

	/*
	 * Flags share one 21 by 13 box so the names align: 13 rows give the US
	 * stripes a pixel each, 21 columns give the tricolours exact thirds.
	 */
	.vt-flag {
		flex: none;
		inline-size: 21px;
		block-size: 13px;
		overflow: visible;
	}

	.vt-flag-defs {
		position: absolute;
	}

	/* Tablet: the brand takes its own row, the three lists share the next. */
	@media (width <= 880px) {

		.vt-footer__main {
			grid-template-columns: repeat(3, minmax(0, 1fr));
			column-gap: 2rem;
		}

		.vt-footer__brand {
			grid-column: 1 / -1;
		}
	}

	/* Phone: two lists side by side, then the languages two by two beneath. */
	@media (width <= 560px) {

		.vt-footer__main {
			grid-template-columns: repeat(2, minmax(0, 1fr));
			column-gap: 1.5rem;
		}

		.vt-footer__langs,
		.vt-footer__langs .vt-footer__list {
			grid-column: 1 / -1;
			grid-template-columns: subgrid;
		}
	}

	/*
	 * Standfirst: the opening paragraphs, set large. The drop cap is core's
	 * own paragraph toggle, restyled; ::first-letter keeps the word whole.
	 * Physical float: the computed value reads left, which the end-state
	 * check pins (a logical value computes as specified).
	 */
	.vt-standfirst > p {
		max-inline-size: 62ch;
		font-size: 20px;
		line-height: 1.55;
	}

	.vt-piece__body .has-drop-cap:not(:focus)::first-letter {
		float: left;
		margin: 0;
		padding: 8px 12px 0 0;
		font-family: var(--wp--preset--font-family--display);
		font-size: 5em;
		font-style: italic;
		font-weight: 400;
		line-height: 0.78;
		text-transform: none;
		color: var(--mark);
	}

	/* Evidence rows: a native disclosure, kind and date beside the claim. */
	.is-style-evidence {
		border-block-start: 1px solid var(--rule);
	}

	.is-style-evidence:not(:has(+ .is-style-evidence)) {
		border-block-end: 1px solid var(--rule);
	}

	.is-style-evidence > summary {
		display: grid;
		grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
		gap: 16px;
		align-items: start;
		padding: 16px 0;
		list-style: none;
		cursor: pointer;
	}

	.is-style-evidence > summary::-webkit-details-marker {
		display: none;
	}

	.is-style-evidence > summary > strong {
		font-family: var(--wp--preset--font-family--mono);
		font-size: 13px;
		font-weight: 400;
		line-height: 1.5;
		color: var(--ink-soft);
	}

	.is-style-evidence > p {
		margin: 0;
		padding-block-end: 16px;
		font-family: var(--wp--preset--font-family--mono);
		font-size: 12.5px;
		line-height: 1.6;
		color: var(--ink-soft);
	}

	/*
	 * Long evidence lists (assets/js/evidence.js): the fourth row shows its
	 * padding and one and a half lines, fading out. hidden="until-found"
	 * keeps the box, so the hidden rows drop their rule and gap.
	 */
	.is-style-evidence.is-evidence-peek {
		max-block-size: calc(16px + 1.5lh);
		overflow: clip;
		mask-image: linear-gradient(var(--ink) 25%, transparent);
	}

	.is-style-evidence[hidden] {
		margin-block: 0;
		border: 0;
	}

	.vt-evidence-more button {
		display: flex;
		gap: 0.5em;
		align-items: baseline;
		padding: 1rem 0;
		border: 0;
		background: none;
		font-family: var(--wp--preset--font-family--mono);
		font-size: 0.8125rem;
		color: var(--ink);
		cursor: pointer;
	}

	.vt-evidence-more button::before {
		content: "▶" / "";
		font-size: 0.75em;
	}

	.vt-evidence-more button[aria-expanded="true"]::before {
		content: "▼" / "";
	}

	.vt-evidence-more button:hover {
		text-decoration: underline;
		text-underline-offset: 0.2em;
	}

	/* Unknowns: unbulleted, each line led by a short rule. */
	.is-style-unknowns {
		display: grid;
		gap: 14px;
		max-inline-size: 60ch;
		margin: 0;
		padding: 0;
		list-style: none;
		font-size: 17px;
		font-weight: 300;
		line-height: 1.55;
		color: var(--ink-soft);
	}

	.is-style-unknowns > li {
		display: flex;
		gap: 14px;
	}

	.is-style-unknowns > li::before {
		content: "";
		flex: none;
		inline-size: 18px;
		block-size: 1px;
		margin-block-start: 13px;
		background: var(--ink-soft);
	}

	/*
	 * What this piece changes: a ruled block on the reading grid's lines,
	 * a heading row, then labelled rows. The verdict word is author bold.
	 */
	.vt-changes {
		grid-column: label-start / text-end;
		display: grid;
		grid-template-columns: subgrid;
	}

	.vt-changes > .wp-block-heading.vt-label {
		grid-column: label-start / text-end;
		margin: 0;
		padding-block: 0 14px;
		border-block-end: 1px solid var(--ink);
	}

	.vt-changes > .vt-spread {
		grid-column: label-start / text-end;
		display: grid;
		grid-template-columns: subgrid;
		margin: 0;
		padding-block: 24px;
		border-block-end: 1px solid var(--rule);
	}

	.vt-changes > .vt-spread > p {
		margin: 0;
	}

	.vt-changes p strong {
		font-weight: 600;
		color: var(--mark);
	}

	/* Terms used in the piece: a ruled three-column glossary. */
	.vt-terms {
		display: grid;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 20px clamp(16px, 2vw, 28px);
	}

	.vt-terms > .wp-block-group {
		margin: 0;
		padding-block-start: 12px;
		border-block-start: 1px solid var(--rule);
	}

	.vt-terms .vt-term {
		margin: 0;
		font-family: var(--wp--preset--font-family--display);
		font-size: 1.3rem;
		line-height: 1.1;
	}

	.vt-terms .vt-term + p {
		margin-block: 8px 0;
		font-size: 15px;
		line-height: 1.5;
		color: var(--ink-soft);
	}

	/* A paragraph with its margin note: a gloss in a narrow column beside it. */
	.vt-split {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 220px);
		gap: 24px 40px;
		align-items: start;
	}

	.vt-margin {
		margin-block: 6px 0;
		padding-inline-start: 14px;
		border-inline-start: 1px solid var(--rule);
		font-family: var(--wp--preset--font-family--mono);
		font-size: 12.5px;
		line-height: 1.55;
		color: var(--ink-soft);
	}

	/* Phones: one column; the gloss repeats the Terms, so it hides (M12). */
	@media (width <= 880px) {

		.vt-terms,
		.vt-split {
			grid-template-columns: minmax(0, 1fr);
		}

		.vt-margin {
			display: none;
		}
	}

	/* A standfirst paragraph keeps the standfirst size beside its note. */
	.vt-standfirst > .vt-split > p:not(.vt-margin) {
		max-inline-size: 62ch;
		font-size: 20px;
		line-height: 1.55;
	}
}
