/**
 * Header layout: Library — .espt-block-header.is-preset-library
 *
 * A bookshop header on a warm cream band: the wordmark with the tagline
 * under it, sign-in / wishlist / bag as quiet text links, then a ruled
 * second row — a dark "browse by subject" button that drops the subject
 * index in columns (promo card last), a square-ish search and, from 1024px,
 * the menu as small links whose last item carries the brand colour.
 * Colours come from the --hd-* tokens unless the block sets its own.
 */

/* The band is the block's header colour, else a cream from the accent.
   --hd-bg is re-pointed so every base part that paints "the header's
   background" (the band, count-bubble rings, the index button's text)
   agrees with it. */
.espt-block-header.is-preset-library {
	--hd-bg: var(--header-bg, color-mix(in srgb, var(--hd-accent) 5%, #fff));
	--lib-deep: color-mix(in srgb, var(--hd-accent) 7%, var(--hd-bg));
	--lib-rule: color-mix(in srgb, var(--hd-ink) 13%, transparent);
}

/* "Bottom border line": a ledger-style double rule. */
.espt-block-header.is-preset-library.is-divider .esptb-hd { border-bottom: 3px double var(--lib-rule); }

.espt-block-header.is-preset-library .esptb-hd-topbar { font-size: var(--topbar-size, 12.5px); }

.espt-block-header.is-preset-library .esptb-hd-tb-l.is-running {
	flex: 1 1 0;
	justify-content: flex-start;
	min-width: 0;
}

/* ------------------------------------------------------------ main row */

.espt-block-header.is-preset-library .esptb-hd-lib-brand {
	display: block;
	flex: 0 1 auto;
	margin-right: auto;
	min-width: 0;
	order: 1;
}

.espt-block-header.is-preset-library .esptb-hd-lib-brand .esptb-hd-logo {
	margin: 0;
	max-width: 100%;
}

.espt-block-header.is-preset-library .esptb-hd-lib-brand .esptb-hd-logo-text {
	font-family: var(--hd-display);
	font-size: clamp(24px, 7.6vw, 30px);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.08;
}

.espt-block-header.is-preset-library .esptb-hd-lib-tag {
	color: var(--hd-muted);
	display: block;
	font-size: 11.5px;
	line-height: 1.35;
	margin-top: 3px;
	max-width: 44ch;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Quiet text links: sign-in (from 600px), wishlist, the bag. */
.espt-block-header.is-preset-library .esptb-hd-lib-links { gap: 4px; }

.espt-block-header.is-preset-library .esptb-hd-lib-link {
	align-items: center;
	color: var(--icons-color, var(--hd-link));
	display: inline-flex;
	flex: none;
	font-size: 14px;
	font-weight: 600;
	gap: 6px;
	justify-content: center;
	min-height: 40px;
	min-width: 40px;
	position: relative;
	text-decoration: none;
	text-underline-offset: 4px;
	transition: color 0.15s ease;
	white-space: nowrap;
}

.espt-block-header.is-preset-library .esptb-hd-lib-link:hover {
	color: var(--menu-hover, var(--hd-link-h));
	text-decoration: underline;
}

.espt-block-header.is-preset-library .esptb-hd-lib-link .espt-ic {
	display: inline-flex;
	font-size: var(--icons-size, 20px);
	line-height: 0;
}

.espt-block-header.is-preset-library .esptb-hd-lib-link .espt-ic svg { height: 1em; width: 1em; }

/* Phones: no sign-in words (the phone menu carries the account), and the
   wishlist is a heart whose words stay for screen readers. */
.espt-block-header.is-preset-library .esptb-hd-lib-acct { display: none; }

.espt-block-header.is-preset-library .esptb-hd-lib-wish .esptb-hd-lib-t {
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	height: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

/* The bag as a word + count: a 40px target, no grey hover box on the count. */
.espt-block-header.is-preset-library .esptb-hd-cart.is-cart-label { min-height: 40px; }

.espt-block-header.is-preset-library .esptb-hd-cart.is-cart-label .esptb-hd-cart-label {
	align-items: center;
	display: inline-flex;
	min-height: 40px;
	text-underline-offset: 4px;
}

.espt-block-header.is-preset-library .esptb-hd-cart.is-cart-label .espt-cart-btn { min-height: 40px; }
.espt-block-header.is-preset-library .esptb-hd-cart.is-cart-label .espt-cart-btn:hover { background: transparent; }

.espt-block-header.is-preset-library .esptb-hd-cart.is-cart-label:hover .esptb-hd-cart-label {
	color: var(--menu-hover, var(--hd-link-h));
	text-decoration: underline;
}

.espt-block-header.is-preset-library .esptb-hd-burger { height: 40px; width: 40px; }

/* The phone menu shares the band's paper. */
.espt-block-header.is-preset-library .esptb-hd-panel { background: var(--panel-bg, var(--hd-bg)); }

/* ------------------------------ row 2: subject button · search · links */

.espt-block-header.is-preset-library .esptb-hd-sub-index { border-top: 1px solid var(--lib-rule); }
.espt-block-header.is-preset-library .esptb-hd-sub-index.is-desk-only { display: none; }

.espt-block-header.is-preset-library .esptb-hd-sub-index .esptb-hd-bar {
	flex-wrap: wrap;
	gap: 8px;
	padding-bottom: calc(var(--row-pad, 10px) * 0.8);
	padding-top: calc(var(--row-pad, 10px) * 0.8);
}

.espt-block-header.is-preset-library .esptb-hd-lib-toggle {
	align-items: center;
	background: var(--hd-ink);
	border: 0;
	border-radius: var(--search-radius, 4px);
	box-shadow: inset 0 -3px 0 transparent;
	color: var(--header-bg, var(--hd-bg));
	cursor: pointer;
	display: inline-flex;
	flex: none;
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	gap: 10px;
	line-height: 1.2;
	margin: 0;
	min-height: 42px;
	padding: 0 16px;
	transition: background 0.15s ease, box-shadow 0.15s ease;
	white-space: nowrap;
}

.espt-block-header.is-preset-library .esptb-hd-lib-toggle:hover { background: var(--hd-dark); }
.espt-block-header.is-preset-library .esptb-hd-lib-toggle[aria-expanded="true"] { box-shadow: inset 0 -3px 0 var(--hd-brand); }

.espt-block-header.is-preset-library .esptb-hd-lib-toggle .espt-ic {
	display: inline-flex;
	font-size: 14px;
	transition: transform 0.2s ease;
}

.espt-block-header.is-preset-library .esptb-hd-lib-toggle .espt-ic svg { height: 1em; width: 1em; }
.espt-block-header.is-preset-library .esptb-hd-lib-toggle[aria-expanded="true"] .espt-ic { transform: rotate(180deg); }

/* The search: paper-white slip with square-ish corners; it wraps under
   the button on phones and fills what is left of the row elsewhere. */
.espt-block-header.is-preset-library .esptb-hd-lib-search {
	flex: 1 1 200px;
	min-width: 200px;
}

.espt-block-header.is-preset-library .esptb-hd-lib-search .espt-search-form input[type="search"] {
	background: var(--search-bg, #fff);
	border-color: var(--search-line, color-mix(in srgb, var(--hd-ink) 22%, transparent));
	border-radius: var(--search-radius, 4px);
	min-height: 42px;
}

.espt-block-header.is-preset-library .esptb-hd-lib-search .espt-search-form:not(.has-btn-text) .button {
	height: 40px;
	right: 1px;
	width: 40px;
}

/* ------------------------------------------ the subject index (panel) */

.espt-block-header.is-preset-library .esptb-hd-mega.is-index {
	background: var(--drop-bg, var(--lib-deep));
	border-bottom: 3px double var(--lib-rule);
	border-top: 1px solid var(--lib-rule);
	box-shadow: 0 22px 40px -26px rgba(15, 23, 42, 0.5);
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index > .esptb-hd-bar {
	gap: 22px 32px;
	padding-bottom: 24px;
	padding-top: 18px;
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-cols {
	gap: 18px 28px;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-col {
	border-left: 1px solid var(--lib-rule);
	min-width: 0;
	padding-left: 14px;
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-h {
	border-bottom: 1px solid var(--lib-rule);
	color: var(--hd-ink);
	font-family: var(--hd-display);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.25;
	margin-bottom: 4px;
	overflow-wrap: anywhere;
	padding: 11px 0 9px;
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-h:hover { color: var(--hd-brand); }
.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-col ul { gap: 0; }

/* Phones: every index line is a 40px target. */
.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-col li a {
	align-items: center;
	color: var(--drop-color, var(--hd-text));
	display: flex;
	font-size: 14px;
	line-height: 1.35;
	min-height: 40px;
	overflow-wrap: anywhere;
	text-underline-offset: 3px;
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-col li a:hover {
	color: var(--hd-brand);
	text-decoration: underline;
}

/* The promo card as a book cover: a brand-coloured spine down its left. */
.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-promo {
	border-radius: 4px 12px 12px 4px;
	box-shadow: inset 7px 0 0 var(--hd-brand), 0 14px 26px -18px rgba(15, 23, 42, 0.55);
	padding: 20px 20px 20px 27px;
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-promo-t {
	font-size: 19px;
	font-weight: 700;
}

.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-promo-b {
	align-items: center;
	border-radius: 4px;
	display: inline-flex;
	min-height: 40px;
	padding: 0 16px;
}

/* ============================================================== 600px + */

@media (min-width: 600px) {
	.espt-block-header.is-preset-library .esptb-hd-lib-links { gap: 18px; }
	.espt-block-header.is-preset-library .esptb-hd-lib-link { min-width: 0; }
	.espt-block-header.is-preset-library .esptb-hd-lib-acct { display: inline-flex; }
	.espt-block-header.is-preset-library .esptb-hd-lib-wish .espt-ic { display: none; }

	.espt-block-header.is-preset-library .esptb-hd-lib-wish .esptb-hd-lib-t {
		clip: auto;
		clip-path: none;
		height: auto;
		overflow: visible;
		position: static;
		width: auto;
	}

	/* A hairline between the text links. */
	.espt-block-header.is-preset-library .esptb-hd-lib-links > * + *::before {
		background: var(--lib-rule);
		content: "";
		height: 14px;
		left: -9px;
		pointer-events: none;
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		width: 1px;
	}

	.espt-block-header.is-preset-library .esptb-hd-lib-tag { font-size: 12px; }
}

/* ============================================================= 1024px + */

@media (min-width: 1024px) {
	.espt-block-header.is-preset-library .esptb-hd-main .esptb-hd-bar { gap: 24px; }
	.espt-block-header.is-preset-library .esptb-hd-lib-brand { order: 0; }
	.espt-block-header.is-preset-library .esptb-hd-lib-brand .esptb-hd-logo-text { font-size: 36px; }
	.espt-block-header.is-preset-library .esptb-hd-lib-tag { font-size: 12.5px; }

	.espt-block-header.is-preset-library .esptb-hd-sub-index.is-desk-only { display: block; }
	.espt-block-header.is-preset-library .esptb-hd-sub-index .esptb-hd-bar { flex-wrap: nowrap; gap: 16px; }

	/* The menu as small links after the search; a long menu wraps inside
	   its own box (never below its widest item) before the search gives
	   up its 200px. */
	.espt-block-header.is-preset-library .esptb-nav-lib {
		flex: 0 1 auto;
		margin-left: auto;
		min-width: auto;
		order: 0;
	}

	.espt-block-header.is-preset-library .esptb-nav-lib .espt-hd-menu {
		gap: 2px calc(var(--menu-gap, 24px) * 0.75);
		justify-content: flex-end;
	}

	.espt-block-header.is-preset-library .esptb-nav-lib .espt-hd-menu > li > a {
		font-size: calc(var(--menu-size, 15px) * 0.9);
		padding: 6px 0;
	}

	.espt-block-header.is-preset-library .esptb-nav-lib .espt-hd-menu > li:last-child > a {
		color: var(--hd-brand);
		font-weight: 700;
	}

	.espt-block-header.is-preset-library .esptb-nav-lib .espt-hd-menu > li:last-child > a:hover { color: var(--hd-brand-dark); }

	/* A hovered dropdown stays above an open subject index. */
	.espt-block-header.is-preset-library .esptb-nav-lib .sub-menu { z-index: 994; }

	/* Desktop index: compact lines under ruled headings. */
	.espt-block-header.is-preset-library .esptb-hd-mega.is-index > .esptb-hd-bar { padding-bottom: 28px; padding-top: 24px; }
	.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-cols { gap: 24px 32px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
	.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-h { margin-bottom: 8px; padding: 0 0 8px; }
	.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-col ul { gap: 2px; }
	.espt-block-header.is-preset-library .esptb-hd-mega.is-index .esptb-hd-mega-col li a { min-height: 0; padding: 4px 0; }
}

@media (prefers-reduced-motion: reduce) {
	.espt-block-header.is-preset-library .esptb-hd-lib-toggle,
	.espt-block-header.is-preset-library .esptb-hd-lib-toggle .espt-ic,
	.espt-block-header.is-preset-library .esptb-hd-lib-link { transition: none; }
}
