/**
 * ACAART Article Design - base layer.
 *
 * Container, typography, links, lists, media, back-to-contents, lightbox,
 * accessibility and print. Everything is scoped to `.acaart-pad-article`.
 *
 * Two rules govern this file:
 *
 * 1. Logical properties only. `padding-inline-start`, `border-inline-start`,
 *    `inset-inline-start` and `text-align: start` all follow the inherited
 *    direction, so the same stylesheet serves RTL and LTR without a single
 *    `direction` declaration and without an RTL override sheet.
 *
 * 2. Nothing the theme owns is set unconditionally. Font family inherits,
 *    font size and line height are only declared under `.has-custom-typography`,
 *    and a maximum width only under `.has-reading-width`.
 */

.acaart-pad-article {
	/* Colour tokens - real values are injected inline by ACAART_Themes. */
	--acaart-primary: #1f3d33;
	--acaart-secondary: #3f5f54;
	--acaart-accent: #a8823c;
	--acaart-text: inherit;
	--acaart-muted: #5f6b6d;
	--acaart-background: #ffffff;
	--acaart-surface: #f7f9f8;
	--acaart-border: #e3e7e5;
	--acaart-heading: #1f3d33;

	/* Typography tokens - only consumed when the site opts in. */
	--acaart-font-heading: inherit;
	--acaart-font-body: inherit;
	--acaart-font-size: 1rem;
	--acaart-line-height: 1.7;
	--acaart-paragraph-gap: 1.15em;
	--acaart-heading-space-before: 2.4em;
	--acaart-heading-space-after: 0.85em;
	--acaart-letter-spacing: normal;

	/* Layout tokens. */
	--acaart-measure: 72ch;
	--acaart-radius: 4px;
	--acaart-shadow: none;
	--acaart-gap: clamp(1.75rem, 1.2rem + 2vw, 3rem);
	--acaart-scroll-offset: 90px;

	font-family: var(--acaart-font-body);
	color: var(--acaart-text);
	overflow-wrap: break-word;
}

/* Opt-in typography. Without this class the theme keeps full control. */
.acaart-pad-article.has-custom-typography {
	font-size: var(--acaart-font-size);
	line-height: var(--acaart-line-height);
	letter-spacing: var(--acaart-letter-spacing, normal);
}

/* Opt-in measure. Without this class no width is forced on the article. */
.acaart-pad-article.has-reading-width {
	max-width: var(--acaart-measure);
	margin-inline: auto;
}

.acaart-pad-article *,
.acaart-pad-article *::before,
.acaart-pad-article *::after {
	box-sizing: border-box;
}

.acaart-pad-article > *:first-child {
	margin-block-start: 0;
}

.acaart-pad-article > *:last-child {
	margin-block-end: 0;
}

.acaart-pad-article .acaart-pad-module {
	margin-block: var(--acaart-gap);
}

.acaart-pad-article .acaart-pad-module__title {
	margin-block-start: 0;
}

/* --------------------------------------------------------------------------
 * Typography
 * ----------------------------------------------------------------------- */

.acaart-pad-article.has-custom-typography p {
	margin-block-end: var(--acaart-paragraph-gap);
}

.acaart-pad-article__content > p:first-of-type {
	font-size: 1.05em;
}

.acaart-pad-article h2,
.acaart-pad-article h3,
.acaart-pad-article h4 {
	font-family: var(--acaart-font-heading);
	color: var(--acaart-heading);
	scroll-margin-block-start: var(--acaart-scroll-offset);
}

.acaart-pad-article h2 {
	position: relative;
	font-size: clamp(1.45rem, 1.18rem + 1.1vw, 1.9rem);
	line-height: 1.3;
	margin-block: var(--acaart-heading-space-before) var(--acaart-heading-space-after);
	padding-block-end: 0.4em;
	border-block-end: 1px solid var(--acaart-border);
}

.acaart-pad-article h3 {
	font-size: clamp(1.18rem, 1.06rem + 0.48vw, 1.36rem);
	line-height: 1.35;
	margin-block: calc(var(--acaart-heading-space-before) * 0.75) calc(var(--acaart-heading-space-after) * 0.7);
}

.acaart-pad-article h4 {
	font-size: 1.02rem;
	line-height: 1.45;
	margin-block: calc(var(--acaart-heading-space-before) * 0.6) calc(var(--acaart-heading-space-after) * 0.55);
}

.acaart-pad-article strong,
.acaart-pad-article b {
	color: var(--acaart-primary);
}

.acaart-pad-article a {
	color: var(--acaart-primary);
	text-decoration: underline;
	text-decoration-color: var(--acaart-accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
	transition: color 0.18s ease, text-decoration-color 0.18s ease;
}

.acaart-pad-article a:hover,
.acaart-pad-article a:focus {
	color: var(--acaart-accent);
	text-decoration-color: currentColor;
}

/* Link style presets, applied by a class on the container. */
.acaart-pad-article.has-links-subtle .acaart-pad-article__content a {
	text-decoration: none;
}

.acaart-pad-article.has-links-subtle .acaart-pad-article__content a:hover,
.acaart-pad-article.has-links-subtle .acaart-pad-article__content a:focus-visible {
	text-decoration: underline;
	text-decoration-color: var(--acaart-accent);
}

.acaart-pad-article.has-links-bold .acaart-pad-article__content a {
	font-weight: 600;
	text-decoration: none;
}

.acaart-pad-article.has-links-bold .acaart-pad-article__content a:hover,
.acaart-pad-article.has-links-bold .acaart-pad-article__content a:focus-visible {
	color: var(--acaart-accent);
}

.acaart-pad-article hr {
	height: 0;
	border: 0;
	border-block-start: 1px solid var(--acaart-border);
	margin-block: var(--acaart-gap);
}

/* --------------------------------------------------------------------------
 * Lists, quotes, media
 * ----------------------------------------------------------------------- */

.acaart-pad-article__content ul,
.acaart-pad-article__content ol {
	padding-inline-start: 1.35em;
}

.acaart-pad-article__content li {
	margin-block-end: 0.5em;
}

.acaart-pad-article__content li::marker {
	color: var(--acaart-accent);
}

.acaart-pad-article blockquote {
	margin-block: 1.9em;
	padding-inline-start: 1.4em;
	padding-block: 0.2em;
	border-inline-start: 2px solid var(--acaart-accent);
	color: var(--acaart-primary);
	font-size: 1.06em;
	line-height: 1.6;
}

.acaart-pad-article blockquote p:last-child {
	margin-block-end: 0;
}

.acaart-pad-article img {
	max-width: 100%;
	height: auto;
	border-radius: var(--acaart-radius);
}

.acaart-pad-article figure {
	margin-block: 1.9em;
	max-width: 100%;
}

.acaart-pad-article figcaption,
.acaart-pad-article .wp-caption-text {
	margin-block-start: 0.7em;
	font-size: 0.85rem;
	line-height: 1.5;
	color: var(--acaart-muted);
	text-align: start;
}

.acaart-pad-article .acaart-pad-zoomable {
	cursor: zoom-in;
}

/* --------------------------------------------------------------------------
 * Back to contents
 * A quiet, low-contrast link. It must never make the heading look clickable,
 * so it sits on its own line under the heading rule.
 * ----------------------------------------------------------------------- */

/*
 * Inline placement. The link lives inside the heading and is positioned
 * against it, so the title keeps wrapping exactly as it would without the
 * link and nothing below moves. Only headings that actually carry a link
 * reserve room for it.
 */
.acaart-pad-article .acaart-pad-heading.has-acaart-backlink {
	padding-inline-end: 4.75rem;
}

.acaart-pad-article .acaart-pad-heading.has-acaart-backlink > .acaart-pad-backlink {
	position: absolute;
	inset-inline-end: 0;
	inset-block-start: 0.34em;
}

/*
 * Legacy placement, kept for sites that set the position to "below" and for
 * any CSS written against the 2.2 wrapper.
 */
.acaart-pad-article .acaart-pad-backlink-wrap {
	block-size: 0;
	margin: 0;
	line-height: 1;
	text-align: end;
	overflow: visible;
}

.acaart-pad-article .acaart-pad-backlink-wrap > .acaart-pad-backlink {
	position: relative;
	inset-block-start: -1.85em;
}

.acaart-pad-article .acaart-pad-backlink {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	color: var(--acaart-muted);
	font-size: 0.72rem;
	font-weight: 400;
	letter-spacing: 0.06em;
	line-height: 1;
	text-transform: uppercase;
	text-decoration: none;
	opacity: 0.6;
	transition: color 0.18s ease, opacity 0.18s ease;
}

.acaart-pad-article .acaart-pad-backlink:hover,
.acaart-pad-article .acaart-pad-backlink:focus-visible {
	color: var(--acaart-accent);
	opacity: 1;
	text-decoration: none;
}

/* Inline SVG: inherits currentColor and scales with the surrounding text. */
.acaart-pad-article .acaart-pad-backlink__icon {
	flex: 0 0 auto;
	inline-size: 1em;
	block-size: 1em;
	font-size: 1.05rem;
}

.acaart-pad-article .acaart-pad-backlink--icon {
	padding: 0.25em;
}

.acaart-pad-article .acaart-pad-heading.has-acaart-backlink:has(> .acaart-pad-backlink--icon) {
	padding-inline-end: 2.25rem;
}

/*
 * The icon reads as "return to the list". In a right-to-left article the
 * mirrored form is the natural one, and the arrow keeps pointing back towards
 * the reading origin.
 */
.acaart-pad-article .acaart-pad-backlink__icon {
	transform: scaleX(1);
}

[dir="rtl"] .acaart-pad-article .acaart-pad-backlink__icon,
.acaart-pad-article[dir="rtl"] .acaart-pad-backlink__icon {
	transform: scaleX(-1);
}

/* Icons used inside list modules. */
.acaart-pad-article .acaart-pad-icon {
	vertical-align: middle;
}

@media (max-width: 640px) {
	.acaart-pad-article .acaart-pad-heading.has-acaart-backlink {
		padding-inline-end: 2.1rem;
	}

	.acaart-pad-article .acaart-pad-backlink__label {
		display: none;
	}
}

/* --------------------------------------------------------------------------
 * Lightbox
 * ----------------------------------------------------------------------- */

/*
 * The closed overlay must not exist as far as the pointer is concerned.
 *
 * Until 2.3 the close routine only removed `is-open`, which took the opacity to
 * zero but left a fixed, full-viewport element at z-index 99999 sitting over
 * the article. It was invisible and it swallowed every click, which is why the
 * table of contents, the back links and the FAQ stopped responding once a
 * reader had opened and closed an image. `display: none` is the real fix:
 * three independent guards - the hidden attribute, the display switch and
 * pointer-events - now have to fail before a stray overlay can block anything.
 */
.acaart-pad-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: clamp(1rem, 4vw, 3rem);
	background: rgba(12, 16, 15, 0.92);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.acaart-pad-lightbox[hidden] {
	display: none;
}

.acaart-pad-lightbox.is-active {
	display: flex;
	pointer-events: auto;
}

.acaart-pad-lightbox.is-open {
	opacity: 1;
}

.acaart-pad-lightbox__image {
	max-inline-size: 100%;
	max-block-size: 88vh;
	inline-size: auto;
	block-size: auto;
	border-radius: 2px;
}

.acaart-pad-lightbox__close {
	position: absolute;
	inset-block-start: clamp(0.75rem, 2vw, 1.5rem);
	inset-inline-end: clamp(0.75rem, 2vw, 1.5rem);
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: 2.75rem;
	block-size: 2.75rem;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
}

.acaart-pad-lightbox__caption {
	position: absolute;
	inset-inline: 5%;
	inset-block-end: clamp(0.75rem, 2vw, 1.5rem);
	margin: 0;
	color: rgba(255, 255, 255, 0.82);
	font-size: 0.85rem;
	line-height: 1.5;
	text-align: center;
}

html.acaart-pad-lightbox-open,
body.acaart-pad-lightbox-open {
	overflow: hidden;
}

/* --------------------------------------------------------------------------
 * Accessibility and print
 * ----------------------------------------------------------------------- */

.acaart-pad-article a:focus-visible,
.acaart-pad-article button:focus-visible,
.acaart-pad-article summary:focus-visible,
.acaart-pad-article .acaart-pad-table-wrapper:focus-visible,
.acaart-pad-lightbox__close:focus-visible {
	outline: 2px solid var(--acaart-accent, #a8823c);
	outline-offset: 2px;
	border-radius: 1px;
}

.acaart-pad-article summary:focus:not(:focus-visible) {
	outline: none;
}

@media (prefers-reduced-motion: reduce) {
	.acaart-pad-article *,
	.acaart-pad-lightbox,
	.acaart-pad-lightbox * {
		animation-duration: 0.01ms;
		animation-iteration-count: 1;
		transition-duration: 0.01ms;
		scroll-behavior: auto;
	}
}

@media print {
	.acaart-pad-article .acaart-pad-toc,
	.acaart-pad-article .acaart-pad-cta,
	.acaart-pad-article .acaart-pad-backlink-wrap,
	.acaart-pad-lightbox {
		display: none;
	}

	.acaart-pad-article details:not([open]) > *:not(summary) {
		display: block;
	}

	.acaart-pad-article.has-reading-width {
		max-width: none;
	}
}
