/*
 * Feature hub_v2: the Help and resources hub, problem first.
 *
 * Loaded only while the hub_v2 switch is on, on the hub (inc/features/hub-v2.php), after base.css. Every rule sits under
 * body.cc-feature-hub_v2, which inc/features.php adds while the switch is on, so nothing here can touch a page with the switch
 * off. Tokens only (assets/css/tokens.css): square corners, one accent, no glow.
 *
 * Markup: patterns/hub-problem-first.php, blocks/hub-sections/render.php, blocks/hub-library/render.php.
 *   .cc-rc-sections > .cc-rc-shortcuts, .cc-rc-section--fix (ul.cc-rc-fix), --journeys (.cc-rc-journey), --tools (ul.cc-rc-tools)
 *   .cc-rc-library > nav.cc-rc-filter, ul.cc-rc-grid > li.cc-rc-grid__item > article.cc-post-card.cc-rc-card
 * Every link is a 44 px target. Nothing here needs a script; assets/js/features/hub-v2.js only makes the filter instant.
 */

/* ------------------------------------------------------------------ head: a tighter first screen */

body.cc-feature-hub_v2 .cc-rc-head > p {
	max-width: 40rem;
}

/* The search sits close under the introduction, and the sections follow it directly. */
body.cc-feature-hub_v2 .cc-rc-start {
	display: grid;
	gap: var(--cc-space-xl);
}

@media (max-width: 47.99em) {
	/* On a phone the hub opens with the search and the Something is not working tiles in the first screen. The banner picture is
	   decoration, so it goes; the introduction and breadcrumb stay. */
	body.cc-feature-hub_v2 .cc-rc-head .cc-page-banner,
	body.cc-feature-hub_v2 .cc-rc-head .wp-block-commcentre-page-banner {
		display: none;
	}

	body.cc-feature-hub_v2 .cc-rc-start {
		gap: var(--cc-space-l);
		padding-top: var(--cc-space-m);
	}

	/* A tighter top on a phone, so the search and the first tiles are in the first screen. */
	body.cc-feature-hub_v2 .cc-rc-head {
		padding-top: var(--cc-space-m);
		padding-bottom: var(--cc-space-m);
	}
}

/* ------------------------------------------------------------------ shortcuts */

body.cc-feature-hub_v2 .cc-rc-sections {
	display: grid;
	gap: var(--cc-space-xl);
}

body.cc-feature-hub_v2 .cc-rc-shortcuts {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--cc-space-xs) var(--cc-space-m);
}

body.cc-feature-hub_v2 .cc-rc-shortcuts__label,
body.cc-feature-hub_v2 .cc-rc-filter__count {
	font-size: var(--cc-font-size-xs);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--cc-color-secondary);
}

body.cc-feature-hub_v2 .cc-rc-shortcuts ul,
body.cc-feature-hub_v2 .cc-rc-filter ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--cc-space-xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

body.cc-feature-hub_v2 .cc-rc-shortcuts a,
body.cc-feature-hub_v2 .cc-rc-filter__chip {
	display: inline-flex;
	align-items: center;
	gap: var(--cc-space-xs);
	min-height: var(--cc-target-min);
	box-sizing: border-box;
	padding: 0 var(--cc-space-m);
	border: 1px solid var(--cc-color-line-strong);
	color: var(--cc-color-white);
	font-size: var(--cc-font-size-s);
	text-decoration: none;
}

body.cc-feature-hub_v2 .cc-rc-shortcuts a:hover,
body.cc-feature-hub_v2 .cc-rc-filter__chip:hover {
	border-color: var(--cc-color-action);
}

body.cc-feature-hub_v2 .cc-rc-filter__chip[aria-current="true"] {
	background: var(--cc-color-white);
	border-color: var(--cc-color-white);
	color: var(--cc-color-canvas);
}

body.cc-feature-hub_v2 .cc-rc-filter__chip[aria-current="true"] .cc-rc-filter__count {
	color: var(--cc-color-canvas);
}

body.cc-feature-hub_v2 .cc-rc-shortcuts a:focus-visible,
body.cc-feature-hub_v2 .cc-rc-filter__chip:focus-visible,
body.cc-feature-hub_v2 .cc-rc-fix__tile:focus-visible,
body.cc-feature-hub_v2 .cc-rc-tool:focus-visible,
body.cc-feature-hub_v2 .cc-rc-journey__steps a:focus-visible {
	outline: var(--cc-focus-width) solid var(--cc-color-focus);
	outline-offset: var(--cc-focus-offset);
}

/* ------------------------------------------------------------------ section titles */

body.cc-feature-hub_v2 .cc-rc-section {
	display: grid;
	gap: var(--cc-space-m);
}

body.cc-feature-hub_v2 .cc-rc-section__title {
	margin: 0;
	font-size: var(--cc-font-size-xl);
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

/* ------------------------------------------------------------------ Something is not working */

body.cc-feature-hub_v2 .cc-rc-fix,
body.cc-feature-hub_v2 .cc-rc-tools,
body.cc-feature-hub_v2 .cc-rc-grid {
	display: grid;
	gap: var(--cc-space-m);
	margin: 0;
	padding: 0;
	list-style: none;
}

body.cc-feature-hub_v2 .cc-rc-fix {
	grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
}

body.cc-feature-hub_v2 .cc-rc-fix > li,
body.cc-feature-hub_v2 .cc-rc-tools > li {
	min-width: 0;
}

body.cc-feature-hub_v2 .cc-rc-fix__tile,
body.cc-feature-hub_v2 .cc-rc-tool {
	display: grid;
	min-width: 0;
	overflow-wrap: anywhere;
	gap: var(--cc-space-xxs);
	align-content: start;
	height: 100%;
	box-sizing: border-box;
	min-height: var(--cc-target-min);
	padding: var(--cc-space-m) var(--cc-space-l);
	background: var(--cc-color-raised);
	border: 1px solid var(--cc-color-line);
	color: var(--cc-color-white);
	text-decoration: none;
}

body.cc-feature-hub_v2 .cc-rc-fix__tile {
	border-left: 3px solid var(--cc-color-action);
}

body.cc-feature-hub_v2 .cc-rc-fix__tile:hover,
body.cc-feature-hub_v2 .cc-rc-tool:hover {
	border-color: var(--cc-color-action);
}

body.cc-feature-hub_v2 .cc-rc-fix__title,
body.cc-feature-hub_v2 .cc-rc-tool__title {
	font-family: var(--cc-font-heading);
	font-size: var(--cc-font-size-l);
	font-weight: 700;
	line-height: 1.25;
}

body.cc-feature-hub_v2 .cc-rc-fix__text,
body.cc-feature-hub_v2 .cc-rc-tool__text {
	font-size: var(--cc-font-size-s);
	color: var(--cc-color-secondary);
}

@media (max-width: 47.99em) {
	/* Two to a row on a phone so more of them are in the first screen. */
	body.cc-feature-hub_v2 .cc-rc-fix {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--cc-space-s);
	}

	body.cc-feature-hub_v2 .cc-rc-fix__tile {
		padding: var(--cc-space-s) var(--cc-space-m);
	}

	body.cc-feature-hub_v2 .cc-rc-fix__title {
		font-size: var(--cc-font-size-m);
		overflow-wrap: break-word;
	}

	/* The short line under a tile title is left out on a phone to keep the tiles in the first screen, except on the Need a person
	   tile, whose line says who it is for. */
	body.cc-feature-hub_v2 .cc-rc-fix__tile:not(.cc-rc-fix__tile--person) .cc-rc-fix__text {
		display: none;
	}

	body.cc-feature-hub_v2 .cc-rc-fix__text {
		font-size: var(--cc-font-size-xs);
	}

}

/* ------------------------------------------------------------------ journeys */

body.cc-feature-hub_v2 .cc-rc-journeys {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
	gap: var(--cc-space-m);
}

body.cc-feature-hub_v2 .cc-rc-journey {
	display: grid;
	gap: var(--cc-space-s);
	align-content: start;
	padding: var(--cc-space-l);
	background: var(--cc-color-raised);
	border: 1px solid var(--cc-color-line);
	min-width: 0;
}

body.cc-feature-hub_v2 .cc-rc-journey__title {
	margin: 0;
	font-size: var(--cc-font-size-l);
}

body.cc-feature-hub_v2 .cc-rc-journey__steps {
	display: grid;
	gap: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: cc-rc-step;
}

body.cc-feature-hub_v2 .cc-rc-journey__steps li {
	counter-increment: cc-rc-step;
	display: grid;
	grid-template-columns: 1.75rem minmax(0, 1fr);
	gap: var(--cc-space-s);
	align-items: center;
	min-height: var(--cc-target-min);
	border-top: 1px solid var(--cc-color-line);
}

body.cc-feature-hub_v2 .cc-rc-journey__steps li:first-child {
	border-top: 0;
}

body.cc-feature-hub_v2 .cc-rc-journey__steps li::before {
	content: counter(cc-rc-step);
	content: counter(cc-rc-step) / "";
	display: grid;
	place-items: center;
	width: 1.75rem;
	height: 1.75rem;
	background: var(--cc-color-canvas);
	border: 1px solid var(--cc-color-line);
	color: var(--cc-color-action);
	font-family: var(--cc-font-heading);
	font-size: var(--cc-font-size-xs);
	font-weight: 700;
}

body.cc-feature-hub_v2 .cc-rc-journey__steps a {
	display: flex;
	align-items: center;
	min-height: var(--cc-target-min);
	padding-block: var(--cc-space-xxs);
	color: var(--cc-color-white);
	font-size: var(--cc-font-size-s);
	overflow-wrap: break-word;
}

/* ------------------------------------------------------------------ tools and downloads */

body.cc-feature-hub_v2 .cc-rc-tools {
	grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
}

body.cc-feature-hub_v2 .cc-rc-tool__kind {
	font-size: var(--cc-font-size-xs);
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--cc-color-action);
}

body.cc-feature-hub_v2 .cc-rc-tool__title {
	font-size: var(--cc-font-size-m);
}

/* ------------------------------------------------------------------ library */

body.cc-feature-hub_v2 .cc-rc-library {
	display: grid;
	gap: var(--cc-space-m);
}

body.cc-feature-hub_v2 .cc-rc-filter {
	padding-block: var(--cc-space-s);
	border-block: 1px solid var(--cc-color-line);
}

/* The library is a grid: without this a grid cell never gets narrower than its widest content, so on a phone the chip row sized itself to
   all its chips (about 800 px in a 343 px column) and was clipped by the page instead of scrolling inside itself. */
body.cc-feature-hub_v2 .cc-rc-library > * {
	min-width: 0;
}

body.cc-feature-hub_v2 .cc-rc-library__status {
	margin: 0;
	font-size: var(--cc-font-size-s);
	color: var(--cc-color-secondary);
}

body.cc-feature-hub_v2 .cc-rc-grid {
	grid-template-columns: repeat(auto-fill, minmax(min(19rem, 100%), 1fr));
	gap: var(--cc-space-l);
}

body.cc-feature-hub_v2 .cc-rc-grid__item {
	min-width: 0;
}

body.cc-feature-hub_v2 .cc-rc-grid__item[hidden] {
	display: none;
}

body.cc-feature-hub_v2 .cc-rc-card__meta {
	margin: 0;
	font-size: var(--cc-font-size-s);
	color: var(--cc-color-secondary);
}

body.cc-feature-hub_v2 .cc-rc-card__excerpt {
	margin: 0;
	font-size: var(--cc-font-size-s);
}

body.cc-feature-hub_v2 .cc-rc-card .wp-block-post-title {
	margin: 0;
	font-size: var(--cc-font-size-l);
	hyphens: manual;
	overflow-wrap: break-word;
}

/* The card title link colour. theme.json gives the core post title block white links, but WordPress only prints the styles of a
   block type that is rendered on the page, and this list is printed by PHP, not by the post title block, so without these two
   rules the titles fall back to the orange link colour. White, and the hover colour theme.json uses for the same links. */
body.cc-feature-hub_v2 .cc-rc-card .wp-block-post-title a {
	color: var(--cc-color-white);
	text-decoration: none;
}

body.cc-feature-hub_v2 .cc-rc-card .wp-block-post-title a:hover {
	color: var(--cc-color-action-hover);
	text-decoration: underline;
}

@media (max-width: 47.99em) {
	/* A chip row that runs past the screen scrolls inside itself, so the page never scrolls sideways. */
	/* Padding on every side of the scroller so the focus ring (width plus offset) is never clipped by it. */
	body.cc-feature-hub_v2 .cc-rc-filter ul {
		flex-wrap: nowrap;
		overflow-x: auto;
		padding: calc(var(--cc-focus-width) + var(--cc-focus-offset));
	}

	/* A chip keeps its own width and one line, so the row scrolls instead of squeezing the chips (the list item is the flex item). */
	body.cc-feature-hub_v2 .cc-rc-filter li {
		flex: none;
	}

	body.cc-feature-hub_v2 .cc-rc-filter__chip {
		flex: none;
		white-space: nowrap;
	}
}

/* Last, so it wins over the rules above at the same specificity. On a phone the shortcuts are left out (they repeat the tiles
   below them) so the tiles come straight after the search, and the sections sit closer together. */
@media (max-width: 47.99em) {
	body.cc-feature-hub_v2 .cc-rc-shortcuts {
		display: none;
	}

	body.cc-feature-hub_v2 .cc-rc-sections {
		gap: var(--cc-space-l);
	}
}

@media (prefers-reduced-motion: reduce) {
	body.cc-feature-hub_v2 .cc-rc-fix__tile,
	body.cc-feature-hub_v2 .cc-rc-tool,
	body.cc-feature-hub_v2 .cc-rc-filter__chip,
	body.cc-feature-hub_v2 .cc-rc-shortcuts a {
		transition: none;
	}
}

@media (forced-colors: active) {
	body.cc-feature-hub_v2 .cc-rc-filter__chip[aria-current="true"] {
		border-color: Highlight;
		outline: 2px solid Highlight;
	}
}
