/*
 * scbt-blog.css — the category blog page as borderless cards, with circular
 * pagination. Part of plg_system_scbtbrand. Loaded only when the "Blog cards"
 * param is on; switch that off and every blog page returns to the template's
 * stock bordered boxes.
 *
 * ---------------------------------------------------------------------------
 * WHAT IT STYLES, AND WHY NO PHP WAS NEEDED
 *
 * Helix's blog_item.php renders the intro image BEFORE <div class="article-body">,
 * which holds the title and then .article-introtext. The DOM order the design
 * asks for — picture, then title, then text — is therefore already what Joomla
 * emits, so this is a restyle and not an override. The markup is:
 *
 *   <div class="article-list">
 *     <div class="row">
 *       <div class="col-md-4">                      round(12 / num_columns)
 *         <div class="article">
 *           <div class="article-intro-image float-none">
 *             <a href="…"><img src="…" alt=""></a>
 *           </div>
 *           <div class="article-body">
 *             <div class="article-header"><h2><a href="…">Title</a></h2></div>
 *             <div class="article-introtext"><p>…</p></div>
 *
 * How many cards sit across a row is NOT set here: it is the menu item's
 * # Columns setting, which decides the col-md-* class. This sheet only makes
 * one card look right at whatever width it is given.
 *
 * SCOPE
 *
 * Every rule is prefixed .view-category, the body class Helix builds from the
 * request's view (plugins/system/helixultimate/core/helixultimate.php:49). The
 * featured and archive views carry different classes and different wrappers, so
 * nothing else on the site can be reached from here. If that body class were
 * ever missing, none of this applies and the page renders exactly as it does
 * today — a visible-but-harmless failure, and the first thing to check in
 * view-source if the design does not appear.
 * ---------------------------------------------------------------------------
 */


/* ---------------------------------------------------------------------------
 * 1. The card, which is not a card
 *
 * template.css:334-338 gives .article-list .article 20px of padding and a
 * 1px #f5f5f5 border, and the image then bleeds back out of that padding with
 * negative margins. That box is the thing the design does not want. Undoing the
 * padding and the border is most of this file's job; the negative margins have
 * to go with them, or the picture hangs 20px outside the column.
 * ------------------------------------------------------------------------- */

.view-category .article-list .article {
	padding: 0;
	border: 0;
	border-radius: 0;
	margin-bottom: var(--scbt-blog-gap, 48px);
}


/* ---------------------------------------------------------------------------
 * 2. The picture, held at one ratio
 *
 * Every article's image is a different shape, and a grid of differently-shaped
 * pictures does not read as a grid. The box is given a height with padding-top,
 * as a percentage of its own width, and the image is stretched over it with
 * object-fit: cover.
 *
 * padding-top, not aspect-ratio: the percentage resolves against the element's
 * own width, so each card's height is reserved BEFORE its picture has loaded and
 * the grid does not reflow as images arrive. aspect-ratio on an unpositioned
 * <img> hands the height back to template.css:56-60's `img { height: auto }`
 * and the reservation disappears. Same reasoning as mod_scbt_news.
 *
 * height:100% and max-width:none on the image exist purely to beat that same
 * `img` rule — a class selector against an element selector, so no !important.
 *
 * float:none IS !important, and has to be: the div carries Bootstrap's
 * .float-none / .float-left / .float-right, which are themselves !important, and
 * a floated ratio box collapses out of the card.
 * ------------------------------------------------------------------------- */

.view-category .article-list .article .article-intro-image {
	position: relative;
	float: none !important;
	width: 100%;
	margin: 0;
	padding: 0;
	padding-top: var(--scbt-blog-ratio, 62.5%);
	border: 0;
	border-radius: var(--scbt-blog-radius, 24px);
	overflow: hidden;

	/* Safari paints a transformed or scaled child outside a rounded
	   overflow:hidden parent. Inert everywhere else. */
	-webkit-mask-image: -webkit-radial-gradient(#fff, #000);
}

/* Two authoring routes reach this markup and they nest differently. With the
   article's own Intro Image (what this site uses) the <a> is INSIDE the box; with
   Helix's article image field the <a> WRAPS the box. The first rule fills the box
   in the first case, the second stops the wrapper collapsing in the second. */
.view-category .article-list .article .article-intro-image > a {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.view-category .article-list .article > a {
	display: block;
}

/*
 * object-fit is the whole difference between the two Picture fit settings.
 * `cover` fills the shape and crops whatever does not fit; `contain` shrinks the
 * picture until all of it is inside, leaving the rest of the box empty — which is
 * what a poster or a flyer needs, where cropping the top off is the same as
 * losing the headline.
 *
 * Both still resolve against the SAME padding-top box, so the cards line up
 * either way. That is the point of putting the choice here rather than removing
 * the ratio box for `contain`.
 */
.view-category .article-list .article .article-intro-image img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	border-radius: 0;
	object-fit: var(--scbt-blog-fit, cover);
}


/* ---------------------------------------------------------------------------
 * 3. Title and intro text
 *
 * template.css:349-357 colours the title #252525 at (0,3,2) and its hover
 * #044cd0. The .view-category prefix puts these at (0,4,2), which wins without
 * !important — and this sheet loads after the merged bundle anyway.
 *
 * The title colour falls through two levels: the administrator's own choice
 * first, then the plugin's brand colour, then a literal. Leave "Title colour"
 * empty in the params and the headings follow any future rebrand on their own.
 * ------------------------------------------------------------------------- */

.view-category .article-list .article .article-header {
	margin: 1.125rem 0 0.5rem;
}

.view-category .article-list .article .article-header h1,
.view-category .article-list .article .article-header h2 {
	margin: 0;
	font-size: var(--scbt-blog-title-size, 1.25rem);
	font-weight: 700;
	line-height: 1.25;
	color: var(--scbt-blog-title-color, var(--scbt-brand, #E6007E));
}

.view-category .article-list .article .article-header h1 a,
.view-category .article-list .article .article-header h2 a {
	color: var(--scbt-blog-title-color, var(--scbt-brand, #E6007E));
}

.view-category .article-list .article .article-header h1 a:hover,
.view-category .article-list .article .article-header h2 a:hover,
.view-category .article-list .article .article-header h1 a:focus,
.view-category .article-list .article .article-header h2 a:focus,
.view-category .article-list .article .article-header h1 a:active,
.view-category .article-list .article .article-header h2 a:active {
	color: var(--scbt-brand-hover, #B3005F);
}

.view-category .article-list .article .article-introtext {
	color: var(--scbt-blog-text-color, #555555);
	line-height: 1.6;
}

.view-category .article-list .article .article-introtext p:last-child {
	margin-bottom: 0;
}


/* ---------------------------------------------------------------------------
 * 4. Circular pagination
 *
 * The rendering logic is untouched: which numbers appear, and how many, is
 * still Joomla's. Only the shape changes.
 *
 * What renders this row is templates/shaper_helixultimate/html/pagination.php —
 * the deprecated chrome file, which Pagination::getPagesLinks() checks BEFORE
 * any layout (libraries/src/Pagination/Pagination.php:335-365). The three
 * layouts/joomla/pagination/*.php overrides in the template never run on this
 * site, so their markup is not what is being styled here. The chrome emits:
 *
 *   <nav class="d-flex pagination-wrapper">
 *     <div class="mr-auto">
 *       <ul class="pagination">
 *         <li class="page-item"><a class="page-link " href="…" title="10">10</a></li>
 *         <li class="page-item active"><a class="page-link">11</a></li>   ← current, no href
 *     <div class="pagination-counter">Страница 11 од 20</div>
 *
 * Note that the current page is an <a> WITHOUT an href, which is why hover keys
 * on a[href] and the filled state keys on li.active.
 *
 * ONE RULE SET SERVES BOTH SHAPES. A page number is narrower than the min-width,
 * so it fills a box whose width equals its height: a circle. Почеток / Пред /
 * Следна / Крај are words — the chrome's JText::_('Next') comparisons never
 * match the Macedonian strings, so they are never swapped for « and » — and they
 * simply stretch the same 999px pill wider. Nothing has to tell them apart.
 * ------------------------------------------------------------------------- */

.view-category .pagination-wrapper {
	flex-wrap: wrap;
	align-items: center;
}

.view-category .pagination-wrapper .pagination {
	flex-wrap: wrap;
	margin: 0;
	padding: 0;
	list-style: none;
	border-radius: 0;
}

/* Margins rather than `gap`, which needs Safari 14.1+. The same choice
   scbt-pill-menu.css makes, for the same reason. The trailing margin on the last
   circle is invisible in a left-aligned row. */
.view-category .pagination-wrapper .pagination > li.page-item {
	margin: 0 var(--scbt-blog-pag-gap, 10px) var(--scbt-blog-pag-gap, 10px) 0;
}

.view-category .pagination-wrapper .pagination > li.page-item > .page-link {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: var(--scbt-blog-pag-size, 44px);
	height: var(--scbt-blog-pag-size, 44px);
	padding: 0 0.85em;
	margin: 0;
	border: 0;
	border-radius: 999px;
	background-color: transparent;
	color: var(--scbt-brand, #E6007E);
	font-weight: 700;
	line-height: 1;
	text-decoration: none;
}

.view-category .pagination-wrapper .pagination > li.page-item > a[href].page-link:hover,
.view-category .pagination-wrapper .pagination > li.page-item > a[href].page-link:focus {
	background-color: var(--scbt-brand-wash, rgba(230, 0, 126, 0.1));
	color: var(--scbt-brand, #E6007E);
}

.view-category .pagination-wrapper .pagination > li.page-item.active > .page-link,
.view-category .pagination-wrapper .pagination > li.page-item.active > .page-link:hover,
.view-category .pagination-wrapper .pagination > li.page-item.active > .page-link:focus {
	background-color: var(--scbt-brand, #E6007E);
	color: #ffffff;
}

.view-category .pagination-wrapper .pagination > li.page-item.disabled > .page-link {
	opacity: 0.45;
	cursor: default;
}

/*
 * Hiding Почеток / Пред / Следна / Крај, without knowing what language they are
 * in and without touching the rendering logic.
 *
 * There is no class to key on. html/pagination.php means to add one — it sets
 * $cls to "next", "previous", "first" or "last" — but it decides by comparing
 * $item->text against JText::_('Next') and JText::_('Prev'), untranslated keys
 * the real strings (JNEXT, JPREV) can never equal, so $cls is always empty and
 * every item ships as a bare li.page-item. See §8.14.
 *
 * What the chrome does emit on every link is title="<its own text>". A page
 * number's title is therefore digits; an end button's title never contains one.
 * The ten :not()s below say exactly that — "this title has no digit in it" — so
 * the rule finds the end buttons in Macedonian, in English, or in any language
 * the site is ever translated into.
 *
 * [title] is not decoration: the CURRENT page is rendered as an <a> with no title
 * attribute at all, and without that requirement it would match all ten :not()s
 * and disappear.
 *
 * The property carries a display keyword rather than a boolean because CSS has no
 * way to switch a rule off from a custom property — `display: var(…, flex)` is
 * how the param reaches this selector at all.
 */
.view-category .pagination-wrapper .pagination > li.page-item > a.page-link[title]:not([title*="0"]):not([title*="1"]):not([title*="2"]):not([title*="3"]):not([title*="4"]):not([title*="5"]):not([title*="6"]):not([title*="7"]):not([title*="8"]):not([title*="9"]) {
	display: var(--scbt-blog-ends, flex);
}

/* Hiding the <a> leaves its <li> in the row, still contributing its own gap —
   two of them before the first number and two after the last. Hiding the li takes
   the margins with it. :has() is unsupported before Safari 15.4, which drops this
   rule as an invalid selector; there the labels still go and the only cost is
   that stray gap at each end, so the fallback degrades rather than breaks. */
.view-category .pagination-wrapper .pagination > li.page-item:has(> a.page-link[title]:not([title*="0"]):not([title*="1"]):not([title*="2"]):not([title*="3"]):not([title*="4"]):not([title*="5"]):not([title*="6"]):not([title*="7"]):not([title*="8"]):not([title*="9"])) {
	display: var(--scbt-blog-ends, flex);
}

/* The counter is a sibling of the links' .mr-auto div, so on an unwrapped flex
   row it sits to their right. flex-basis:100% is what drops it onto its own line
   underneath, and .mr-auto keeps the numbers to the left of theirs. */
.view-category .pagination-wrapper .pagination-counter {
	flex: 0 0 100%;
	margin-top: 0.5rem;
	color: var(--scbt-brand, #E6007E);
	font-weight: 700;
}
