/*
 * Compatibility layer for content written under antonio-trotta-2024.
 *
 * The case studies, Resume, Work and Writing pages still reference the 2024
 * theme's preset slugs and class names. This file maps them onto the Lines
 * tokens so the content renders without edits, which keeps the 2024 theme
 * usable for rollback (decision B in design/theme-build-plan-lines.md).
 *
 * After launch the content is migrated to the new slugs and this file is
 * deleted. Nothing new should depend on it.
 */

/* ── Old spacing slugs → Lines spacing ───────────────────────────── */
/* 2024 values: xs 12, sm 20, md 32, lg 48, xl 64, x-pad 48 (px). */

:root {
	--wp--preset--spacing--xs: var(--wp--preset--spacing--10);
	--wp--preset--spacing--sm: var(--wp--preset--spacing--20);
	--wp--preset--spacing--md: var(--wp--preset--spacing--40);
	--wp--preset--spacing--lg: var(--wp--preset--spacing--40);
	--wp--preset--spacing--xl: var(--wp--preset--spacing--50);
	--wp--preset--spacing--x-pad: var(--wp--custom--gutter);
}

/* ── Old colour slugs ────────────────────────────────────────────── */
/* "rule" and "pale" were light panel backgrounds in 2024. On the dark ground
   they become the step colour. Core prints palette classes with !important,
   so these need it to win. */

.has-rule-background-color,
.has-pale-background-color {
	background-color: var(--wp--preset--color--step) !important; /* Overrides core's palette class. */
}

.has-accent-color {
	color: var(--wp--preset--color--orange) !important; /* Overrides core's palette class. */
}

/* ── Labels above headings ───────────────────────────────────────── */
/* The Lines design has none (requirements 3.3). Hidden here until decision C's
   script removes them from the content. */

.is-style-section-label {
	display: none;
}

.is-style-standfirst {
	font-size: var(--wp--preset--font-size--standfirst);
	font-weight: 300;
	line-height: 1.45;
	color: var(--wp--preset--color--text-2);
}

/* ── Case study structure ────────────────────────────────────────── */
/* Top level of a case study: .article-body groups (the reading column) and
   .cs-image panels (images and Figma embeds), plus one flex group of facts. */

.single-case_study .wp-block-post-content > * + * {
	margin-block-start: var(--wp--preset--spacing--60);
}

.is-layout-constrained > .cs-image,
.is-layout-constrained > .wp-block-group.is-layout-flex.has-background:not(.cs-image) {
	max-width: var(--wp--style--global--wide-size);
}

/* Image rows sit on the ground with no panel, as in the Figma case study. */
.cs-image,
.cs-image.has-background {
	padding: 0 !important; /* Overrides inline padding from the 2024 content. */
	background: none !important; /* Overrides the palette class mapped above. */
}

/* A row of images is a group inside the panel, or in one case (the two wiki
   pages in Nadex mobile) the panel group itself. Both get the same gap, sizes
   and phone stacking. A vertical panel is not a row. */
.cs-image .is-nowrap,
.cs-image.is-nowrap:not(.is-vertical) {
	gap: 40px;
}

.cs-image .group-caption,
.cs-image figcaption,
.cs-content figure.cs-chart figcaption {
	max-width: 65ch; /* About 450px at caption size: a readable line. */
	margin-inline: auto; /* Centred under the image, text still left aligned. */
}

/* A row of images in the 2024 content starts at the left edge. With one image
   (the Jira and Trello screenshots in Nadex mobile) that leaves it off centre. */
.cs-image.is-layout-flex:not(.is-vertical) {
	justify-content: center;
}

.cs-image .wp-block-image,
.cs-image figure {
	margin: 0;
}

.cs-image img,
.cs-image iframe {
	display: block;
	width: 100%;
}

/* Figma embeds in a crop box (the figma-block skill, used in Platform Vision).
   As flex items the box and its group shrink to fit the iframe, which then
   falls back to its default 300px width. As blocks they fill the panel. The
   caption loses the flex gap, so it gets the same 24px as a margin. */
.cs-image:has(.at-figma-crop) {
	display: block;
}

.cs-image:has(.at-figma-crop) .group-caption {
	margin-top: 24px;
}

/* The crop box takes the 4px corner. The iframe inside has its own, but the
   box cuts it off at 450px, which left the bottom corners square. The box
   already hides its overflow (inline style in the content). */
.cs-image .at-figma-crop {
	border-radius: var(--wp--custom--radius);
}

/* Embeds have no border, like images. The content draws a 1px line at 10%
   black that cannot be seen on the dark ground, and on the iframes without a
   crop box it made them 2px wider than the panel. */
.cs-image iframe,
.cs-image .at-figma-crop {
	border: 0 !important; /* Overrides the inline border in the content. */
}

/* A single image (the 2024 content puts the caption class on its figure) fills
   the 1200px panel like the embeds, and is cut at the same 450px height with a
   fade that shows there is more. The image keeps its full size and is only
   clipped, because the lightbox sizes the enlarged view from the image on the
   page: an image shrunk to 450px would open cut off too. The grid row stops at
   450px so the caption sits under the visible part. Only images with the
   lightbox are cut, so every hidden part can still be opened. */
.single-case_study .cs-image {
	--cs-image-cap: 450px;
}

.single-case_study .cs-image figure.group-caption {
	width: 100%;
	max-width: none;
	flex: 1 1 100%;
}

.single-case_study .cs-image figure.group-caption img {
	width: 100% !important; /* Overrides the fixed 900px width on Red Routes in the 2024 content. */
	height: auto;
}

.single-case_study .cs-image figure.group-caption.wp-lightbox-container {
	display: grid;
	grid-template-rows: fit-content(var(--cs-image-cap)) auto;
}

.single-case_study .cs-image figure.group-caption.wp-lightbox-container img {
	align-self: start;
	min-height: 0; /* Lets the grid row stop at the cap, not at the image height. */
	clip-path: inset(0 0 max(0px, calc(100% - var(--cs-image-cap))) 0);
	/* The fade sits in the 96px above the cap, so an image shorter than that has none. */
	-webkit-mask-image: linear-gradient(to bottom, #000 calc(var(--cs-image-cap) - 96px), transparent var(--cs-image-cap));
	mask-image: linear-gradient(to bottom, #000 calc(var(--cs-image-cap) - 96px), transparent var(--cs-image-cap));
}

.cs-image .is-nowrap > *,
.cs-image.is-nowrap:not(.is-vertical) > * {
	flex: 1 1 0;
	min-width: 0;
}

.cs-image-placeholder:not(:has(img, iframe)) {
	aspect-ratio: 16 / 7;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--caption);
}

.group-caption,
.group-caption.has-text-align-center,
.group-caption figcaption {
	font-size: var(--wp--preset--font-size--caption);
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
	text-align: left;
}

/* Every case study caption sits 24px under its image, the gap the caption
   paragraphs already get from their group. A caption inside the figure would
   otherwise take the 12px from theme.json. */
.cs-image figure figcaption,
.cs-content figure.cs-chart figcaption {
	margin-top: 24px;
}

/* Captions are upright. The 2024 content wraps 15 of the 33 in italic tags. */
.cs-image :is(.group-caption, figcaption) :is(em, i),
.cs-content figure.cs-chart figcaption :is(em, i) {
	font-style: normal;
}

/* The facts group at the top of some case studies: three columns of
   heading and text on a panel. */
/* Even padding on all four sides, the same as the gap between the columns.
   The content sets 8px top and bottom and 40px at the sides inline. */
.wp-block-post-content > .wp-block-group.is-layout-flex.has-background:not(.cs-image) {
	padding: var(--wp--preset--spacing--40) !important; /* Overrides inline padding from the 2024 content. */
	gap: var(--wp--preset--spacing--40);
}

.wp-block-post-content > .wp-block-group.is-layout-flex.has-background:not(.cs-image) > * {
	flex: 1 1 0;
	min-width: 0;
	padding: 0 !important; /* Overrides inline padding from the 2024 content. */
}

/* The panel headings (Context, Problem, My role) are level 2 since 18 October
   2026, for screen readers; they keep the level 4 size from theme.json. */
.cs-content h2.panel-heading {
	font-size: 24px;
	line-height: 1.2;
	letter-spacing: -0.01em;
}

/* Buttons that sat on a "rule" background in 2024. */
.wp-block-button.is-style-fill .wp-block-button__link.has-background {
	color: var(--wp--preset--color--text);
	border: 1px solid var(--wp--preset--color--rule);
}

@media (max-width: 900px) {
	.wp-block-post-content > .wp-block-group.is-layout-flex.has-background:not(.cs-image) {
		flex-direction: column;
	}

	/* The content gives each heading a fixed 86px height so the columns line
	   up side by side. Stacked, that height only leaves a gap under it. */
	.wp-block-post-content > .wp-block-group.is-layout-flex.has-background:not(.cs-image) .wp-block-heading {
		flex-basis: auto !important; /* Overrides the generated flex-basis from the 2024 content. */
	}
}

@media (max-width: 600px) {
	.wp-block-post-content > .wp-block-group.is-layout-flex.has-background:not(.cs-image) {
		padding: var(--wp--preset--spacing--30) !important; /* Overrides inline padding from the 2024 content. */
	}

	.cs-image .is-nowrap,
	.cs-image.is-nowrap:not(.is-vertical) {
		flex-wrap: wrap;
	}

	.cs-image .is-nowrap > *,
	.cs-image.is-nowrap:not(.is-vertical) > * {
		flex-basis: 100%;
	}

	/* Buttons set to a quarter of the width in the content (the payments case
	   study) break their label one word per line on a phone. */
	.wp-block-buttons > .wp-block-button.has-custom-width {
		width: auto;
	}
}

/* ── Resume page ─────────────────────────────────────────────────── */

/* The Resume follows the Work page: the same 1312px container and left edge,
   and its header laid out like the Work header (patterns/work-header.php):
   the name on the left, the role line and contact line beside it, aligned to
   the name's baseline, then the orange motif. The text stays in the page
   content, which the 2024 theme also renders. */
.wp-block-post-content:has(> .resume-body) > * {
	max-width: 1312px;
}

.wp-block-post-content:has(> .resume-body) > .resume-body {
	margin-block-start: 0;
}

.wp-block-post-content:has(> .resume-body) > .page-header {
	padding: var(--wp--preset--spacing--60) 0 var(--wp--preset--spacing--50) !important; /* Overrides inline padding from the 2024 content. */
}

.page-header-inner {
	display: grid;
	grid-template-columns: 1fr minmax(0, 600px);
	grid-template-areas:
		"title role"
		"title contact"
		"rule  rule";
	column-gap: var(--wp--preset--spacing--40);
	align-items: end;
}

/* The same minimum height as .page-title__row (theme.css), on the name. */
.page-header-inner > .page-headline {
	min-height: calc(2 * 1.45 * var(--wp--preset--font-size--standfirst) + 12px + 1.55 * var(--wp--preset--font-size--body-s));
	display: flex;
	align-items: flex-end;
}

.page-header-inner > * {
	margin: 0;
}

.page-header-inner > .page-headline {
	grid-area: title;
	white-space: nowrap; /* The name on one line (Antonio, 18 October 2026). */
}

.page-header-inner > .is-style-standfirst {
	grid-area: role;
	color: var(--wp--preset--color--text);
}

.page-header-inner > p.resume-contact {
	grid-area: contact;
	margin-top: 12px;
	font-size: var(--wp--preset--font-size--body-s);
	color: var(--wp--preset--color--text-2);
}

.page-header-inner > .motif {
	grid-area: rule;
	opacity: 1; /* The content's rule carries core's has-css-opacity (0.4). */
}

@media (max-width: 900px) {
	.page-header-inner {
		grid-template-columns: 1fr;
		grid-template-areas: "title" "role" "contact" "rule";
	}

	.page-header-inner > .page-headline {
		min-height: 0;
	}

	/* The same 40px gap as .page-title__row on the Work page. */
	.page-header-inner > .is-style-standfirst {
		margin-top: var(--wp--preset--spacing--40);
	}
}

@media (max-width: 400px) {
	.page-header-inner > .page-headline {
		white-space: normal;
	}
}

p.resume-entry-title,
p.edu-degree {
	font-weight: 500;
	color: var(--wp--preset--color--text);
	margin-bottom: 4px;
}

p.resume-entry-meta,
p.edu-institution,
p.resume-contact,
p.testimonial-attribution {
	font-size: var(--wp--preset--font-size--caption);
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
	margin-top: 0;
}

p.resume-entry-desc,
.methods-list li {
	font-size: var(--wp--preset--font-size--body-s);
	line-height: 1.55;
	color: var(--wp--preset--color--text-2);
}

.methods-list {
	list-style: none;
	padding-left: 0;
}

.resume-divider {
	margin-block: var(--wp--preset--spacing--40);
}

.sidebar-section {
	margin-top: var(--wp--preset--spacing--40);
	padding-top: var(--wp--preset--spacing--40);
	border-top: 1px solid var(--wp--preset--color--rule);
}

p.testimonial-quote {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--title);
	line-height: 1.3;
	font-style: normal;
}

/* ── Nadex mobile adoption chart ─────────────────────────────────────
   An inline SVG in the post content, with its own <style> written for the
   2024 light theme (near-black text, Spectral and DM Sans). Recoloured here to
   the palette; these selectors are one class stronger than the SVG's own. */
.cs-content .adoption-chart .ttl {
	font-family: var(--wp--preset--font-family--display);
	fill: var(--wp--preset--color--text);
}

.cs-content .adoption-chart :is(.ylab, .xlab, .xover-lab, .lg) {
	font-family: var(--wp--preset--font-family--body);
}

.cs-content .adoption-chart :is(.ylab, .xlab) {
	fill: var(--wp--preset--color--muted);
}

.cs-content .adoption-chart :is(.xover-lab, .lg) {
	fill: var(--wp--preset--color--text-2);
}

.cs-content .adoption-chart .grid {
	stroke: var(--wp--preset--color--rule);
}

.cs-content .adoption-chart .native {
	stroke: var(--wp--preset--color--muted);
}

.cs-content .adoption-chart .pwa {
	stroke: var(--wp--preset--color--orange);
}

.cs-content .adoption-chart .xover-line {
	stroke: var(--wp--preset--color--text-2);
}

.cs-content .adoption-chart .xover-dot {
	fill: var(--wp--preset--color--orange);
	stroke: var(--wp--preset--color--ground);
}
