/*
 * WParaby utilities for Elementor content (generated by wpa-convert).
 * Mirrors what core block styles do in the block version of a section.
 */

/* Text widgets: same vertical rhythm as blocks (spacing comes from container gaps). */
.elementor-widget-text-editor > :first-child,
.elementor-widget-text-editor .elementor-widget-container > :first-child { margin-block-start: 0; }
.elementor-widget-text-editor > :last-child,
.elementor-widget-text-editor .elementor-widget-container > :last-child { margin-block-end: 0; }
.elementor-widget-heading .elementor-heading-title { line-height: var(--wpa-line-height-tight, 1.3); }

/* Core blocks rendered by WParaby widgets (site title, navigation): no theme margins, like in block templates. */
.elementor-widget-wpa-site-title .wp-block-site-title,
.elementor-widget-wpa-nav-menu .wp-block-navigation { margin: 0; }
/* Elementor's kit button styles must not restyle the navigation's own buttons (open/close/submenu). */
.elementor-widget-wpa-nav-menu .wp-block-navigation button {
	background: transparent;
	color: inherit;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	font: inherit;
}

/* Post and archive fields of kit templates (wpa-post-block, wpa-post-content), as in block templates:
   no heading margins, no root padding on the content, nothing when a field is empty (e.g. no term description). */
.elementor-widget-wpa-post-block :is(.wp-block-post-title, .wp-block-post-date, .wp-block-post-terms, .wp-block-post-excerpt, .wp-block-post-author-name, .wp-block-query-title, .wp-block-term-description, .wp-block-post-featured-image) { margin-block: 0; }
.elementor-widget-wpa-post-block:not(:has([class*="wp-block-"])) { display: none; }
.elementor-widget-wpa-post-content .wp-block-post-content.has-global-padding { padding-inline: 0; }
/* The post body keeps the block layout's rhythm (Elementor's heading margins would replace it) and the theme's link style. */
/* (The selector outranks Elementor's ".elementor .elementor-widget:not(…) figure { margin: 0 }".) */
.elementor .elementor-element.elementor-widget.elementor-widget-wpa-post-content .wp-block-post-content > * { margin-block-start: var(--wp--style--block-gap, 1.5rem); margin-block-end: 0; }
.elementor .elementor-element.elementor-widget.elementor-widget-wpa-post-content .wp-block-post-content > :first-child { margin-block-start: 0; }
/* Images in the post body keep the theme's image radius (Elementor resets it on all images). */
.elementor-widget-wpa-post-content .wp-block-image img { border-radius: var(--wp--custom--radius--md, var(--wpa-radius-md)); }
:is(.elementor-widget-wpa-post-block, .elementor-widget-wpa-post-content) a:where(:not(.wp-element-button)) { text-decoration: underline; }

/* Posts grid: core's post-template uses container queries (container-type: inline-size); as an
   auto-width flex item Elementor would size it from its min-content height. */
.elementor-widget-wpa-posts { width: 100%; }

/* Image aspect ratios (core/image aspectRatio). */
.wpa-ar-1-1 img { aspect-ratio: 1 / 1; }
.wpa-ar-4-3 img { aspect-ratio: 4 / 3; }
.wpa-ar-3-4 img { aspect-ratio: 3 / 4; }
.wpa-ar-3-2 img { aspect-ratio: 3 / 2; }
.wpa-ar-2-3 img { aspect-ratio: 2 / 3; }
.wpa-ar-4-5 img { aspect-ratio: 4 / 5; }
.wpa-ar-5-4 img { aspect-ratio: 5 / 4; }
.wpa-ar-16-9 img { aspect-ratio: 16 / 9; }
.wpa-ar-9-16 img { aspect-ratio: 9 / 16; }
.wpa-ar-16-10 img { aspect-ratio: 16 / 10; }
.wpa-ar-21-9 img { aspect-ratio: 21 / 9; }
[class*="wpa-ar-"] img { width: 100%; height: auto; object-fit: cover; }
.wpa-fit-contain img { object-fit: contain; }

/* Icons (wpa/icon): no inline line box around the glyph, like the block. */
.wpa-icon .elementor-icon-wrapper { line-height: 0; }
.wpa-icon .elementor-icon { line-height: 0; }

/* Shadows (style.shadow). */
.wpa-shadow-soft { box-shadow: var(--wpa-shadow-soft); }
.wpa-shadow-strong { box-shadow: var(--wpa-shadow-strong); }

/* Lists and quotes (core/list, core/quote), matching core's rendering. */
.wpa-list { margin-block: 0; padding-inline-start: 40px; }
.wpa-quote {
	margin: 0;
	border-inline-start: 4px solid var(--wpa-color-primary);
	padding-inline-start: var(--wpa-space-30);
}
.wpa-quote > * { margin-block: 0; }
.wpa-quote > * + * { margin-block-start: var(--wpa-space-30); }
.wpa-quote cite { display: block; font-size: inherit; font-style: italic; }

/* Font weight and line height (style.typography); !important beats the global typography selectors. */
.wpa-fw-300 :is(.elementor-heading-title, p, li, .wp-block-site-title, .wp-block-navigation, .wpa-el) { font-weight: 300 !important; }
.wpa-fw-400 :is(.elementor-heading-title, p, li, .wp-block-site-title, .wp-block-navigation, .wpa-el) { font-weight: 400 !important; }
.wpa-fw-500 :is(.elementor-heading-title, p, li, .wp-block-site-title, .wp-block-navigation, .wpa-el) { font-weight: 500 !important; }
.wpa-fw-600 :is(.elementor-heading-title, p, li, .wp-block-site-title, .wp-block-navigation, .wpa-el) { font-weight: 600 !important; }
.wpa-fw-700 :is(.elementor-heading-title, p, li, .wp-block-site-title, .wp-block-navigation, .wpa-el) { font-weight: 700 !important; }
.wpa-fw-800 :is(.elementor-heading-title, p, li, .wp-block-site-title, .wp-block-navigation, .wpa-el) { font-weight: 800 !important; }
.wpa-fw-900 :is(.elementor-heading-title, p, li, .wp-block-site-title, .wp-block-navigation, .wpa-el) { font-weight: 900 !important; }
.wpa-lh-1 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1 !important; }
.wpa-lh-1-1 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.1 !important; }
.wpa-lh-1-2 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.2 !important; }
.wpa-lh-1-3 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.3 !important; }
.wpa-lh-1-4 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.4 !important; }
.wpa-lh-1-5 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.5 !important; }
.wpa-lh-1-6 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.6 !important; }
.wpa-lh-1-7 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.7 !important; }
.wpa-lh-1-8 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 1.8 !important; }
.wpa-lh-2 :is(.elementor-heading-title, p, li, .wpa-el) { line-height: 2 !important; }

/* Link colors (style.elements.link on a parent group); "body" outranks the Elementor kit link color whatever the CSS order. */
body .wpa-link-primary a { color: var(--wpa-color-primary); }
body .wpa-link-secondary a { color: var(--wpa-color-secondary); }
body .wpa-link-accent a { color: var(--wpa-color-accent); }
body .wpa-link-base a { color: var(--wpa-color-base); }
body .wpa-link-base-2 a { color: var(--wpa-color-base-2); }
body .wpa-link-contrast a { color: var(--wpa-color-contrast); }
body .wpa-link-contrast-2 a { color: var(--wpa-color-contrast-2); }
body .wpa-link-border a { color: var(--wpa-color-border); }
