/*
 * The site header (templates/peters/shell/header.html.twig), moving to the design system.
 * Unlayered, like components.css, so these rules win over everything in the legacy layer,
 * including legacy rules on IDs: set only the properties that need to change.
 */

/* The page's own colours, from the tokens so dark mode reaches them. Without a background, a
   dark page would show the browser's near-black instead of --color-bg. */
html {
	background-color: var(--color-bg);
	color: var(--color-text);
}

/* The main menu's list: basket.css (on the list pages) gives every .menu a background for its export
   menus, which would show behind the menu tabs in dark mode */
#mainMenuContainer > ul.menu {
	background-color: transparent;
}

/* Header logo: the inverse (white) one in dark mode */
.mainLogo--inverse,
[data-theme="dark"] .mainLogo--positive {
	display: none;
}

[data-theme="dark"] .mainLogo--inverse {
	display: inline;
}

/* Theme toggle's button (System, Light, Dark), last in the account bar and shown at every width.
   Legacy CSS puts a "|" after every item but the last, and colours the bar's items. The button is
   26px high against the bar's 25px, so it overlaps the space above and below instead of making
   the header taller. */
.userMenu .themeToggleItem {
	display: list-item;
	margin: -4px 0 -4px var(--space-2);
	line-height: 0;
}

/* Inside the panel, undo the account bar's line height and the legacy margin after its icons */
.userMenu .themeToggleItem .ds-theme-menu__panel {
	line-height: var(--line-height-body);
}

.userMenu .themeToggleItem .ds-theme-toggle span {
	margin-left: 0;
}

/* No "|" before or after the pill: after the account menu, the "|" would wrap below the name */
.userMenu .themeToggleItem::after,
.userMenu > li:has(+ .themeToggleItem)::after {
	content: none;
}

/* The header's text fields (search, and the drawer's new basket name) take the legacy colours of every
   text input (default.css), which don't switch in dark mode */
#headerSearch,
#newBasketName {
	border-color: var(--color-border);
	background-color: var(--color-surface);
	color: var(--color-text);
}

/* Basket drawer. Its basket name fields had no colours of their own, so dark mode gave them the
   browser's grey. "All baskets" and "Add new basket" were Peters blue (3.3:1 for their text, in
   both themes): the link colour and a steel button, as elsewhere in the header. */
#basketDraw input.basketName {
	border-color: var(--color-border-field);
	background-color: var(--color-surface);
}

#basketDraw a.simpleLink {
	color: var(--color-primary);
}

#basketDraw #addNewBasket {
	background-color: var(--color-primary);
	color: var(--color-on-primary);
}

#basketDraw.furnitureJade #addNewBasket {
	background-color: var(--color-furniture);
}

#basketDraw #addNewBasket:hover {
	background-color: var(--color-primary-hover);
}

/* The active basket's row: grey-200 in light (default.css); in dark the selected rows' colour, as the
   link colour on dark grey is 4.4:1 */
[data-theme="dark"] #basketDraw tr.active td {
	background-color: var(--color-bg-highlight);
}

/* Search with nothing to search for: pink in light (default.css), too dark on a dark field */
[data-theme="dark"] #headerSearch.error {
	border-color: var(--color-error);
}

[data-theme="dark"] #headerSearch.error::placeholder {
	color: var(--color-error);
}

/* The footer's partner logos (BA, BESA, BIC) are drawn for a white background */
[data-theme="dark"] .footerPartnerImages img {
	box-sizing: content-box;
	padding: 4px;
	border-radius: var(--radius-sm);
	background-color: var(--color-image-panel);
}

/* Keyboard focus. Legacy CSS removes the outline from the search fields. */
#header :focus-visible,
#footer :focus-visible,
#cookieBanner :focus-visible,
#returnToTop:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

/* Buttons that look like the text around them rather than like legacy buttons. Doesn't set
   display, which legacy rules control (the corporate menu label only shows on small screens). */
.shell-plain-button {
	background: none;
	border: 0;
	margin: 0;
	padding: 0;
	width: auto;
	font: inherit;
	color: inherit;
	text-transform: none;
	text-align: inherit;
	cursor: pointer;
}

#switchUserType {
	display: inline;
	padding-left: 3px;
}

/* Legacy button rules set a margin, font size and border the old <div> versions didn't have */
#headerSearchButton {
	margin: 0;
	border: 0;
	font: inherit;
}

.announcementBanner .closeAnnouncement {
	font-family: inherit;
}

/* Sentence case, as the style guide asks: legacy CSS capitalises every button and the Browse label */
#headerSearchButton,
#addNewBasket,
#mainMenu .hamburgerText,
.announcementBanner .closeAnnouncement,
#cookieBanner .acceptCookies,
#cookieBanner .button,
#deleteBasketPopup .button,
#errorPopup .button {
	text-transform: none;
}

/* Header text links that were Peters blue: steel, the link colour. The account bar's links keep
   their own colours in their dark shades (default.css). */
#corporateMenu a,
.corporateMenuLabel span,
.advancedSearchLink,
.helpContact a,
.manageBasketsLink a {
	color: var(--color-primary);
}

#corporateMenu a:hover,
.advancedSearchLink:hover,
.helpContact a:hover,
.manageBasketsLink a:hover {
	color: var(--color-primary-hover);
}

/* Main menu dropdown labels (megaMenuLabel() in menu.php): a link and a button inside the label,
   looking like the text and chevron they replaced */
.megaDropDownLabel > a {
	color: inherit;
	text-decoration: none;
}

.megaDropDownToggle {
	display: inline;
}

/* Basket drawer buttons (drawer.js), formerly <div>s and <span>s: undo what legacy and browser
   button styles add, without touching the legacy rules that place and colour them */
#openDrawButton {
	font: inherit;
	text-transform: none;
}

#addNewBasket {
	font-family: inherit;
}

/* Account menu: the name links to My settings, and each item is a link filling its row */
#userAccount > .graphicContainer {
	padding: 0;
	text-decoration: none;
}

#userOptionsDropdown > li {
	padding: 0;
}

#userOptionsDropdown a {
	display: block;
	padding: 4px 4px 4px 20px;
	color: inherit;
	text-decoration: none;
}

/*
 * Carousels (Swiper), starting with the landing pages: home, /primary and /secondary.
 * Behaviour is in assets/js/swiperA11y.js; the dots are drawn by homepage.js.
 */

/* Keyboard focus. Legacy CSS removes the outline from Previous and Next, which sit inside the
   carousel's clipped box, so their outline goes inside them. */
.swiper-container .swiper-button:focus-visible {
	outline: var(--focus-ring);
	outline-offset: -4px;
}

/* Pause/Play for carousels that play by themselves (swiperA11y.js): the style guide's icon-only
   button on a white circle, so it shows on photos and brand colours */
.carouselPause.ds-button--icon,
.carouselPause.ds-button--icon:hover {
	flex: none;
	border-radius: var(--radius-full);
	background: var(--color-surface);
	box-shadow: var(--shadow-sm);
	font-size: var(--font-size-xs);
}

.carouselPause:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

/* In a book carousel's header, to the left of its "See all" button */
.recommendedHeader .carouselPause {
	align-self: center;
	margin: 0 12px 0 auto;
}

.recommendedHeader .carouselPause + .viewDefaultBtn {
	margin-left: 0;
}

/* Over a carousel's top-left corner (the USP strip on phones) */
.carouselPause--overlay {
	position: absolute;
	top: 4px;
	left: 9px;
	z-index: 20;
}

/* In the testimonials' row of dots, before them */
.sliderPaginationContainer .carouselPause {
	margin-right: 8px;
}

/* Libraries home's books of the week: the button follows the carousel's link, in its column */
.botw {
	position: relative;
}

/* A book's title and author links are under 24px high, one above the other: 6px between them keeps
   each clear of the other's 24px target area (WCAG 2.5.8) */
.recommendedBookDetails .carouselBookAuthor {
	margin-top: 6px;
}

/* The header slider's and testimonials' dots, formerly <span>s: 24px buttons, so they're big enough
   to press, with the same 14px ring drawn inside. They sit on photos and brand colours, so focus
   shows as a white ring around a steel one. */
.homeTabContainer.customContent .swiper-pagination,
.sliderPaginationContainer > .swiper-pagination {
	gap: 0;
}

.homeTabContainer.customContent button.customSliderBullet,
.sliderPaginationContainer button.customSliderBullet,
.homeTabContainer.customContent button.customSliderBullet:hover,
.sliderPaginationContainer button.customSliderBullet:hover,
.homeTabContainer.customContent button.customSliderBullet.active,
.sliderPaginationContainer button.customSliderBullet.active {
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 24px;
	height: 24px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	transition: none;
}

.homeTabContainer.customContent button.customSliderBullet::before,
.sliderPaginationContainer button.customSliderBullet::before {
	content: "";
	box-sizing: border-box;
	width: 14px;
	height: 14px;
	border: 2px solid var(--color-on-primary);
	border-radius: 50%;
}

.homeTabContainer.customContent button.customSliderBullet.active::before,
.sliderPaginationContainer button.customSliderBullet.active::before {
	background: var(--color-on-primary);
}

.customSliderBullet:focus-visible {
	outline: var(--focus-ring);
	outline-offset: 0;
	box-shadow: 0 0 0 4px var(--color-on-primary);
}

/* Libraries home tiles (assets/components/bannerBlocks.php), and the same tiles on partner pages
   (partnershipPage.phtml) and book list carousel pages (.headerSection > .column): each link wraps the
   tile's <div>s, which are all positioned, so the link had no size for a focus outline to draw round. It
   now fills its column (which sets the tile's height), and the <div>s are placed against it instead, in
   the same place. The hover text shows on keyboard focus too. */
:is(.homeHeaderGrid, .headerSection) > .column > a {
	position: absolute;
	inset: 0;
}

:is(.homeHeaderGrid, .headerSection) > .column > a:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

:is(.homeHeaderGrid, .headerSection) > .column > a:focus-visible .headerHover {
	opacity: 1;
}
