/*
 * CMS content layouts (migration orders 8 and 9), moving to the design system: blank.php,
 * embeddedSearchPage.php, bookListCarousel.php, contentItems.php and the long-tail layouts (news, careers,
 * help, books of the week and others) put their content inside .cmsPage. Their links and buttons are steel
 * with the other migrated pages' (default.css).
 *
 * Loaded on every main-site page, like furniture.css. Unlayered, so these rules win over everything in the
 * legacy layer: keep selectors scoped and set only the properties that need to change.
 */

/* Links in running text are underlined, as in the style guide (.ds-link): steel is too close to the text
   colour for colour alone to show them (axe link-in-text-block, in dark). Not the search results, carousels
   and product listings these pages also show. */
.cmsPage :is(p, li, td, span) a:not(:where(#search, .searchBox, .productContainer, .swiper, .slick-slider) a) {
	text-decoration: underline;
}

/* And in headings from the editor ("Complete the official order form below…" on an order form, an <h5>).
   Not carousels' headings, whose links are titles. */
.cmsPage :is(h2, h3, h4, h5, h6) a:not(:where(#search, .searchBox, .productContainer, .swiper, .slick-slider, .recommendedSection) a) {
	text-decoration: underline;
}

/* Peters pink text from the editor (style="color: #da1e63", an order form's prices): 4.6:1 on white, but
   unreadable on the dark page. The pink text token is the same pink in light and a lighter one in dark.
   !important beats the inline style. */
.cmsPage :is([style*="color: #da1e63" i], [style*="color:#da1e63" i], [style*="color: rgb(218, 30, 99)"]) {
	color: var(--color-text-pink) !important;
}

/* Peters blue text in the content, from the editor (style="color: #2995d3") or the legacy heading classes:
   3.3:1 on white, too light for text smaller than a page title. It's the dark Peters blue, the website
   addition for text in Peters blue (brand-guidelines.md), and light blue in dark. !important beats the
   inline style. Page titles keep Peters blue (--color-title): they're large enough for 3:1. */
.cmsPage :is(.petersBlue, .smallHeading, [style*="color: #2995d3" i], [style*="color:#2995d3" i], [style*="color: rgb(41, 149, 211)"]):not(h1, .pageTitle) {
	color: var(--color-section-blue) !important;
}

/* CMS text coloured black or navy in the editor (<span style="color: #000000;">, inspire me's title in
   navy): unreadable on the dark page, so it takes the text colour there. !important beats the inline style.
   Furniture's headers over photos (.curatedListMediaHeaderText.petersNavy) set navy with a class, so they keep it. */
[data-theme="dark"] :is(.cmsPage, .furniturePage) :is(
	[style*="color: #000000" i], [style*="color:#000000" i], [style*="color: rgb(0, 0, 0)"], [style*="color: black" i],
	[style*="color: #1c2542" i], [style*="color:#1c2542" i], [style*="color: rgb(28, 37, 66)"]
) {
	color: var(--color-text) !important;
}

/* CMS tables and boxes given a white or light blue background in the editor (a news article's panels, an
   event's description): in dark their text is light, so they take the dark surfaces. !important beats the
   inline style. Coloured fills (navy, pink) keep theirs: their text is white in both themes. */
[data-theme="dark"] :is(.cmsPage, .furniturePage) :is(
	[style*="background-color: #ffffff" i], [style*="background-color:#ffffff" i], [style*="background-color: #fff;" i],
	[style*="background-color: white" i], [style*="background-color: rgb(255, 255, 255)"]
) {
	background-color: var(--color-surface) !important;
}

[data-theme="dark"] :is(.cmsPage, .furniturePage) :is(
	[style*="background-color: #e9f4fa" i], [style*="background-color:#e9f4fa" i],
	[style*="background-color: #e8f3fa" i], [style*="background-color: rgb(233, 244, 250)"]
) {
	background-color: var(--color-section-blue-bg) !important;
}

/* Partner pages' logos (partnershipPage.phtml) are drawn for a white background (Hampshire's is
   sls_for_white_bg…png): in dark they sit on a white panel, as the footer's partner logos do */
[data-theme="dark"] .partnersPage #partnerLogo {
	padding: var(--space-2);
	background: var(--color-image-panel);
}

/* The legacy jade, green and yellow text classes (help's headings): below 4.5:1 on white (jade 3.8:1, green
   2.5:1, yellow 1.7:1), so the section's dark shade, its lighter one in dark. Page titles keep theirs. */
.cmsPage .petersJade:not(h1, .pageTitle) {
	color: var(--color-section-jade);
}

.cmsPage .petersGreen:not(h1, .pageTitle) {
	color: var(--color-section-green);
}

.cmsPage .petersYellow:not(h1, .pageTitle) {
	color: var(--color-section-yellow);
}

/* Page titles on the light blue panel (careers, a vacancy, a news article, meet the team, an event): Peters
   blue was 2.9:1 on it, under 3:1 even at this size */
.cmsPage :is(.vacancyArea, .meetTheTeamArea, .eventEntryContainer) :is(h1, .pageTitle) {
	color: var(--color-section-blue);
}

/* The news filters' list titles on narrow screens (Categories, Archives), which open and close their list:
   a button, which takes the title's look rather than the legacy button's */
.cmsPage .dropListTitle button {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	height: auto;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-align: left;
	text-transform: none;
	cursor: pointer;
}

.cmsPage .dropListTitle button:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

/* Books of the week: the style guide's pagination (DsPagination) above and below the list, on the right
   (centred on phones); the author and publisher links at least 24px high to tap */
.botwPagination {
	margin: 20px 0;
}

.botwPagination .ds-pagination {
	justify-content: flex-end;
}

.librariansContentDetails > a[href^="/search-results"] {
	display: inline-block;
	min-height: 24px;
}

@media (max-width: 500px) {
	.botwPagination .ds-pagination {
		justify-content: center;
	}
}

/* Great School Libraries order form (partials/greatSchoolLibrariesOrder.html.twig): design system fields in
   rows on wider screens */
.gslOrderForm {
	max-width: 960px;
}

.gslOrder .gslMessage {
	margin-bottom: var(--space-4);
}

.gslOrder .gslMessage:focus {
	outline: none;
}

.gslOrder .gslMessage ul {
	margin: var(--space-1) 0 0;
	padding-left: var(--space-4);
}

.gslOrderForm .ds-fieldset {
	margin-bottom: var(--space-5);
}

.gslOrderForm .ds-fieldset legend {
	font-size: var(--font-size-md);
}

.gslOrderForm input[type="number"].ds-field {
	max-width: 8em;
}

/* Long checkbox labels: the box stays by the first line */
.gslOrderForm .ds-check {
	align-items: flex-start;
}

.gslOrderForm .ds-check input {
	margin-top: 3px;
}

.gslRow {
	display: grid;
	gap: 0 var(--space-4);
}

@media (min-width: 701px) {
	.gslRow--two {
		grid-template-columns: 1fr 1fr;
	}

	.gslRow--names {
		grid-template-columns: 1fr 2fr 2fr;
	}

	.gslRow--postcode {
		grid-template-columns: 1fr 3fr;
	}
}
