/*
 * Icon + text, centred and 4px apart, for every link, button, badge and label on the site and in AdminCP.
 *
 * An icon (Tabler .ti, Font Awesome, the Seoclerks .sci set, AdminCP .icon16, an svg) that is a direct child of one of
 * these elements sits on the text's centre line: the element becomes an inline flex row with its items centred and a 4px
 * gap. Flex centring does not depend on the icon font's metrics, so one rule serves every font.
 *
 * The rule has no specificity (:where) so a component that sets its own display, margin or alignment keeps it; the
 * component classes below (.btn, .badge, ...) are promoted to flex because their stock display is inline-block or block.
 * Tests/icon_alignment_crawler.cjs measures every icon+text pair (centre vs centre, 1px) and fails on a miss: fix a miss
 * in the component's own CSS, never by nudging an icon with a margin. Opt out with .icon-align-off.
 *
 * Loaded after the main stylesheet: views/header/view_header.php (site) and admincp/views/global/view_global-header.php.
 */
:where(a, button, label, summary, h1, h2, h3, h4, h5, h6, .btn, .badge, .nav-link, .dropdown-item, .page-link, .tag, .chip):where(:has(> :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"]))):not(.icon-align-off) {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

/* Components whose stock display is inline-block or block become flex rows: same row, same centring. */
:is(.btn, .badge, .page-link, .tag, .chip):has(> :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"])):not(.icon-align-off) {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}
:is(.nav-link, .dropdown-item):has(> :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"])):not(.icon-align-off) {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* The icon itself: a box that is not squeezed or shifted, so the flex row can centre it. */
:where(a, button, label, summary, h1, h2, h3, h4, h5, h6, .btn, .badge, .nav-link, .dropdown-item, .page-link, .tag, .chip) > :where(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"]) {
	flex: none;
	vertical-align: baseline;
}

/*
 * Components whose own rules (the AdminCP menu, Bootstrap list groups, stat labels, notes) set display or alignment with more
 * specificity than the rules above. !important is used on these two properties only, and only on a parent that has an icon as a
 * direct child; .icon-align-off opts out.
 */
:is(.list-group-item, .mainnav .sub li a, .stat-label, .guided-job-header strong):has(> :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"])):not(.icon-align-off) {
	display: flex !important;
	align-items: center !important;
	gap: 4px;
}
.grow-shelf-cashback:has(> :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"])), .pj-formnote:has(> :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"])) { display: inline-flex !important; }
:is(.list-group-item, .mainnav .sub li a, .stat-label, .guided-job-header strong) > :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg, [class^="icon-"], [class*=" icon-"]):not(.icon-align-off) {
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	vertical-align: baseline;
}

/* Notes whose text wraps: the icon is centred beside the whole text block. */
:is(.grow-shelf-cashback, .pj-formnote):has(> :is(.ti, .fa, .fas, .far, .fab, .fal, .fad, .sci, .icon16, .icon20, svg)) { align-items: center !important; }

/* A badge's icon: the text's line box is what the icon is measured against, so the icon's own box is the line. */
.badge > :is(.fa, .fas, .far, .fab, .fal, .fad):not(.icon-align-off) { line-height: 1; height: 1em; display: inline-flex; align-items: center; }
.badge.badge-default > :is(.fa, .fas, .far):not(.icon-align-off) { margin-top: 0.1px; }
