/**
 * The OTA post card: one card design for every post grid on the site.
 *
 * Figma: Component/News 359:13125 for the card and its hover state, Related
 * groups 372:20803 for the three-up row this first shipped as, in the OTA
 * Design file iJIMvo6qjZanmK5Iza7bUs.
 *
 * WHY THIS FILE EXISTS. Elementor Pro's Posts widget draws a card of its own:
 * a drop shadow, an author avatar bubble, an uppercase read-more, a 45px void
 * between the photograph and the title, and the meta line as a grey bar
 * hanging off the bottom of the card. None of that is the OTA design. The
 * redress was written once for the Related groups row on the interest group
 * template and lived in ota-sig-page.css, scoped to that template's two
 * section classes, so the next post grid anybody built came out looking like
 * stock Elementor beside it. That is exactly what happened when the group
 * page's Resources band was built on 9 Sep 2026, and Bryce's instruction was
 * that every post widget on the site wears the same card. So the redress moved
 * here, keyed to a class any section or widget can opt in to, and this
 * stylesheet loads site-wide the way ota-buttons.css does.
 *
 * HOW TO USE IT. Put `ota-post-cards` in Elementor's Advanced > CSS Classes on
 * either the section holding a Posts widget or the widget itself, and set the
 * widget's skin to Cards. Both work: every selector below asks for the class on
 * an ancestor, and a widget is its own ancestor as far as a descendant
 * combinator is concerned.
 *
 * `.ota-sig-related` and `.ota-sig-archive` are named alongside it so the
 * interest group template keeps its look with no template edit at all. They are
 * aliases, not a second design. Anything built from now on uses the class.
 *
 * WHAT STAYS BEHIND IN ota-sig-page.css. The band padding, the section
 * headings, the eyebrow and the `--rows` variant that turns these cards into
 * full-width archive rows on the group sub-pages. Those are that template's
 * layout, not the card. The `--rows` overrides depend on loading after this
 * file, which is why ota-sig-page.css declares this stylesheet's handle as a
 * dependency rather than trusting enqueue order.
 *
 * Colours are theme roles with the frame's resolved value as the fallback,
 * same contract as every other block. The exception is the card surface, which
 * no role carries: see the comment above `--ota-post-card-bg` below.
 *
 * @package Agend\OTA
 */

/* --- The band, when there is nothing to put in it -------------------------- */

/*
 * NO POSTS, NO BAND
 *
 * Pro's Posts widget removes itself entirely when its query finds nothing: the
 * skin returns early from `render()` and `should_print_empty()` is false for a
 * widget, so not even an empty wrapper is printed. That leaves a band's
 * eyebrow, heading and View all button standing over an empty strip, which
 * reads as broken rather than empty. Most interest groups hit this: 16 of the
 * 26 published ones carry no tag, so Related groups has nothing to relate, and
 * a group with no resources filed under its category is the same case.
 *
 * `:has()` rather than a `should_render` filter on the section, which is the
 * obvious server-side answer and does not work here. Elementor's element cache
 * is on (`elementor_element_cache_ttl` unset means active, 24 hours), so
 * `Document::print_elements()` renders a template once and keeps the HTML in
 * post meta, with only the elements that report themselves as dynamic left
 * behind as `[elementor-element]` shortcodes to re-render per request. A
 * section is not one of them, so a filter there would work for one request
 * after a cache clear and then quietly stop. The widget inside it IS dynamic,
 * which is what makes this rule correct per request: the cards are expanded
 * fresh every time, so `.elementor-widget-posts` is present exactly when this
 * band has something to show.
 *
 * Qualified with `.elementor-section` on purpose. The class is also allowed on
 * the widget itself, and a widget never contains a `.elementor-widget-posts`
 * because it is one; without the qualifier this rule would hide every
 * widget-level use of the class outright.
 *
 * The band stays in the editor, where the widget always draws its placeholder.
 */
.elementor-section:is(.ota-post-cards, .ota-sig-related):not(:has(.elementor-widget-posts)) {
	display: none;
}

/* --- The band's measure, matched to the News and Events blocks -------------- */

/*
 * A BAND OF CARDS HAS ONE MEASURE ON THIS SITE, AND ELEMENTOR'S COLUMNS ARE NOT
 * IT
 *
 * The News Block and the Events Block are our own widgets, and both draw their
 * contents inside `padding-inline: 2rem` of a 1140 container with a 48px gap
 * between the header and the grid (`--onb-pad` / `--oeb-pad`, and the flex gap
 * on `.ota-news__inner` / `.ota-events__inner`). That is the site's band, and
 * every one of them lines up down the page.
 *
 * A band assembled from stock Elementor parts does not, because Elementor pads
 * its own columns: 10px on the outer column, and another 10px on the columns of
 * the inner section the header sits in. Measured on a group page at 1440px
 * before these rules, one page carried four different left edges:
 *
 *   News Block heading and cards      182
 *   Events Block heading and cards    182
 *   Related groups / Resources cards  160
 *   their eyebrow and heading         170
 *
 * So the heading did not line up with its own cards, and neither lined up with
 * the block above. Bryce caught it with the inspector open on
 * `.ota-events__inner` on 9 Sep 2026.
 *
 * These rules put a card band on the same measure: 2rem in from the container
 * on the outer column, nothing on the inner section's columns, which lands the
 * eyebrow, the heading, the button and the cards all on 182 and ends them all
 * on 1258. The cards come out 342 wide, which is also what the frame's own
 * ratio gives for a 1076 measure (371/1167 of the content width, 372:20803).
 *
 * The vertical padding goes with it. Elementor's 10px was adding to the band's
 * 96px and to the gap under the header; with it gone the band's own padding is
 * the whole story and the header gap is exactly the 48px the blocks use.
 *
 * Section-qualified, like the empty-band rule above: the class is also allowed
 * on a widget, and a widget has no columns of its own to pad.
 *
 * NOT `.ota-sig-archive`, which the rest of this file does carry. The interest
 * groups archive is a `--rows` layout drawn by this plugin rather than a band
 * inside a template, so it is already on its own measure; naming it here took
 * 2rem a side off each row card for nothing. Review on PR #29 caught it. The
 * archive keeps every rule below, which is the card itself.
 */
.elementor-section:is(.ota-post-cards, .ota-sig-related) > .elementor-container > .elementor-column > .elementor-widget-wrap.elementor-element-populated {
	padding: 0 2rem;
}

.elementor-section:is(.ota-post-cards, .ota-sig-related) .elementor-inner-section > .elementor-container > .elementor-column > .elementor-widget-wrap.elementor-element-populated {
	padding: 0;
}

/*
 * The gap under the header, the blocks' 48px.
 *
 * Adjacent sibling rather than a blanket margin on the widget: a band whose
 * grid is its only content, with the header somewhere else or absent, should
 * not gain a gap it never had.
 */
:is(.ota-post-cards, .ota-sig-related) .elementor-inner-section + .elementor-widget-posts {
	margin-top: 48px;
}

/* Both steps are the blocks' own: `--oeb-pad` drops to 1.1875rem and the inner
   gap to 32px at exactly this width, where the band padding also goes 96 to 64. */
@media (max-width: 1024px) {
	.elementor-section:is(.ota-post-cards, .ota-sig-related) > .elementor-container > .elementor-column > .elementor-widget-wrap.elementor-element-populated {
		padding: 0 1.1875rem;
	}

	:is(.ota-post-cards, .ota-sig-related) .elementor-inner-section + .elementor-widget-posts {
		margin-top: 32px;
	}
}

/* --- The grid -------------------------------------------------------------- */

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-grid {
	--grid-column-gap: 24px;
	--grid-row-gap: 24px;
}

/*
 * Two of Pro's card furnishings the design does not draw: the author avatar
 * bubble, which is meaningless on an interest group and on a resource, and the
 * uppercase it forces on the read-more label.
 *
 * The avatar is hidden rather than switched off in the widget because the
 * control is per widget instance and this has to hold for every card on the
 * site, including the ones somebody adds later without reading this file.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__avatar {
	display: none;
}

/* --- The card surface ------------------------------------------------------ */

/*
 * THE CARD HAS TO CONTRAST WITH ITS BAND, AND NO THEME ROLE CARRIES THAT
 *
 * The colour themes give a band `--ota-background` and the text roles that
 * read on it, but there is no card or surface role: measured on 9 Sep 2026,
 * an `ota-theme--white` band and an `ota-theme--ash` band resolve every
 * `--ota-*` role identically except the background itself. So a card painted
 * from a role would either match its band or need a role that does not exist.
 *
 * The design's own answer is the nested theme the News Block uses: the band is
 * one colour and the card is the next one along, white cards on the sand band
 * and sand cards on the white band. Pro's cards skin has no nested theme
 * picker, so it is expressed here as one token with a modifier:
 *
 *   default                white cards, which is the reading on every band
 *                          that is not white (ash, navy, teal)
 *   .ota-post-cards--ash   sand cards, for a band that is itself white
 *
 * Bryce asked for the sand reading on the group page's Resources band on
 * 9 Sep 2026, where white cards on a white band had no edge at all: the
 * photograph floated and the card was invisible.
 *
 * The two hexes are the frames' literal values (#FFFFFF, and #F0E7D8 which is
 * what `bar/background` resolves to on the ash theme), the same pair the News
 * Block's featured card switches between. One for the designer: bind the card
 * to a variable of its own and both of these follow it.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: 14px;
	background: var(--ota-post-card-bg, #ffffff);
	box-shadow: none;
}

.ota-post-cards--ash {
	--ota-post-card-bg: #f0e7d8;
}

/*
 * No lift and no shadow on hover either: the sitewide hover state is the ring
 * and the underline, nothing else. Pro's cards skin brings its own hover
 * shadow, named at hover here because that is where Pro applies it.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post:hover .elementor-post__card,
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card:hover {
	box-shadow: none;
	transform: none;
}

/*
 * The read-more rides the card's bottom edge whatever the excerpt runs to, the
 * same pinned-footer treatment as the news cards: the text column grows and
 * the read-more takes the leftover.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__text {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
}

/*
 * The sitewide card hover: 2px text-muted ring plus underlined title, from
 * Component/News 359:13125 variant 2, the same contract as the news and events
 * cards. A transparent `::before` pseudo-border rather than a real border,
 * which would resize the card and shift the row beside it, and rather than an
 * inset shadow, which paints under the image. On `::before` because Pro's
 * markup is not ours to wrap and `::after` belongs to the arrow dot below.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
	border: 2px solid transparent;
	border-radius: inherit;
	pointer-events: none;
	transition: border-color 150ms ease;
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post:hover .elementor-post__card::before {
	border-color: var(--ota-text-muted, #005361);
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post:hover .elementor-post__card .elementor-post__title {
	text-decoration: underline;
}

/* --- The image and its badge ----------------------------------------------- */

/*
 * Zero margins where the design butts the image straight onto the body: Pro's
 * cards skin spaces its furnishings apart (25px under the thumbnail, 20px above
 * the text) for the avatar bubble that this card hides, and together they
 * opened a 45px void between the photograph and the title.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__thumbnail__link {
	display: block;
	height: 170px;
	margin-bottom: 0;
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__thumbnail {
	height: 100%;
	padding: 0 !important;
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/*
 * The badge as the design's pill, in the image's top right corner. Which
 * taxonomy it reads is the widget's own Badge Taxonomy setting, so the same
 * pill carries an interest group's scope, a resource's type or a post's
 * category without a rule per content type.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__badge {
	position: absolute;
	top: 24px;
	right: 24px;
	left: auto;
	margin: 0;
	padding: 6px 16px;
	border-radius: 999px;
	background: var(--ota-cta-bg, #003038);
	color: var(--ota-cta-text, #ffffff);
	font-size: 11.5px;
	font-weight: 700;
	line-height: 1.65;
	letter-spacing: 0.69px;
	text-transform: capitalize;
}

/* --- The body -------------------------------------------------------------- */

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__text {
	margin-top: 0;
	padding: 24px;
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__title {
	margin: 0 0 8px;
	color: var(--ota-white-text, #003038);
	font-size: 22px;
	font-weight: 700;
	line-height: 1.4;
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__title a {
	color: inherit;
}

/*
 * Pro's own 25px sits under the excerpt; the design leaves the gap to the
 * footer flexible (the read-more's auto margin below), with the footer's
 * padding-top as the minimum.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__excerpt {
	margin-bottom: 0;
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__excerpt p {
	margin: 0;
	color: var(--ota-text, #003038);
	font-size: var(--e-global-typography-small-font-size, 15px);
	font-weight: var(--e-global-typography-small-font-weight, 300);
	line-height: var(--e-global-typography-small-line-height, 1.65);
}

/*
 * THE META LINE, WHICH IS A SIBLING OF THE BODY AND NOT PART OF IT
 *
 * `Skin_Cards::render_post()` calls `render_meta_data()` after
 * `render_text_footer()` has closed `.elementor-post__text`, so a card with
 * Meta Data switched on gets a `.elementor-post__meta-data` block outside the
 * body's padding, under the read-more, wearing Pro's own grey top border. It
 * reads as a stray bar stuck to the bottom of the card, which is how the
 * Resources band first rendered on 9 Sep 2026.
 *
 * No card in the design draws one, so the design's answer is to leave Meta
 * Data empty. This rule is here for the case where somebody switches it on
 * anyway: it pulls the line inside the card's padding and quiets it to the
 * small type, so the worst outcome is a plain date rather than a grey bar.
 * The border is Pro's, cleared here rather than in the widget because the
 * control that draws it is a per-instance colour.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__meta-data {
	margin: 0;
	padding: 0 24px 24px;
	border-top: 0;
	color: var(--ota-text-muted, #005361);
	font-size: var(--e-global-typography-small-font-size, 15px);
	font-weight: var(--e-global-typography-small-font-weight, 300);
	line-height: 1.4;
}

/* --- The read-more footer and its arrow dot -------------------------------- */

/*
 * The read-more, drawn as the card footer with the arrow dot on the right.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__read-more {
	display: flex;
	/*
	 * Full width, or there is nothing for space-between to distribute: the
	 * link is a flex item of the text column and shrank to its label, which
	 * parked the dot against the words instead of on the card's right edge.
	 */
	width: 100%;
	align-items: center;
	justify-content: space-between;
	margin-top: auto;
	padding-top: 16px;
	color: var(--ota-text, #003038);
	font-size: 17px;
	font-weight: 700;
	line-height: 1;
	text-transform: none;
	letter-spacing: 0;
}

/*
 * Dot and arrow are two layers of one pseudo-element: the circle is the
 * element itself, the arrow its background image. A mask cannot do this in
 * one: it would cut the circle away to the arrow's shape. The strokes are
 * literal colours because a data URI cannot read a custom property: they are
 * the shared glyph's ink, hard-coded here at the one value it takes.
 *
 * That was true of one surface when it was written and is true of two now, so
 * the reasoning is worth restating rather than the old claim. The card is
 * `--ota-post-card-bg`, white by default and sand under `--ash`, and the ink
 * is the same navy on both, which is why a fixed stroke still reads correctly.
 * A card surface dark enough to need light strokes would need this drawn some
 * other way, since the arrow cannot follow a variable.
 */
:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post__card .elementor-post__read-more::after {
	content: '';
	width: 30px;
	height: 30px;
	flex: none;
	border-radius: 999px;
	background-color: transparent;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13' fill='none'%3E%3Cpath d='M2.71 6.5h7.58' stroke='%23003038' stroke-width='1.35' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M7.04 3.25 10.29 6.5 7.04 9.75' stroke='%23003038' stroke-width='1.35' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-position: center;
	background-size: 13px 13px;
	background-repeat: no-repeat;
	transition: background-color 150ms ease;
}

:is(.ota-post-cards, .ota-sig-related, .ota-sig-archive) .elementor-posts .elementor-post:hover .elementor-post__card .elementor-post__read-more::after {
	background-color: var(--ota-cta-bg, #003038);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13' fill='none'%3E%3Cpath d='M2.71 6.5h7.58' stroke='%23ffffff' stroke-width='1.35' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M7.04 3.25 10.29 6.5 7.04 9.75' stroke='%23ffffff' stroke-width='1.35' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
