/* =========================================================================
   Chapterwright integration
   Loaded only on book views, after the plugin's own stylesheet.
   Maps the reader's --hsrtech-* colours onto this theme's --alok-* tokens
   so books follow the site toggle. Layout and type scale stay the plugin's.
   Variables are set on .hsrtech-page itself, which overrides the plugin's
   :root values (including its prefers-color-scheme fallback) by inheritance.
   ========================================================================= */

.hsrtech-page {
	--hsrtech-ink: var(--alok-ink);
	--hsrtech-paper: var(--alok-surface-soft);
	--hsrtech-surface: var(--alok-surface);
	--hsrtech-muted: var(--alok-body);
	--hsrtech-line: var(--alok-border);
	--hsrtech-code: var(--alok-code-bg);
	--hsrtech-code-ink: var(--alok-code-ink);
	color: var(--alok-ink);
	font-family: var(--alok-font);
}

/* Only the library archive adopts the site wrapper; book and chapter
   readers keep the plugin's own reading layout. */
.hsrtech-page.hsrtech-archive {
	max-width: 1330px;
	padding: clamp(42px, 6vw, 90px) var(--alok-gutter) 100px;
}

body:has(.hsrtech-page) {
	background: var(--alok-canvas);
}

/* Library header matches the inner hero. */
.hsrtech-archive__header {
	max-width: 950px;
	margin-bottom: 54px;
	text-align: left;
}

.hsrtech-archive__header .hsrtech-eyebrow,
.hsrtech-page .hsrtech-eyebrow {
	font-size: 0.875rem;
	line-height: 1.4;
	font-weight: 800;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--alok-muted);
}

.hsrtech-archive__header h1 {
	font-size: clamp(2.8rem, 6vw, 5.2rem);
	line-height: 1.05;
	letter-spacing: -0.065em;
	margin: 18px 0 14px;
	color: var(--alok-ink);
}

.hsrtech-archive__header p:not(.hsrtech-eyebrow) {
	font-size: clamp(1.1rem, 1.7vw, 1.32rem);
	line-height: 1.65;
	color: var(--alok-body);
	max-width: 760px;
	margin: 0;
}

/* Cards and covers use the bento radius. */
.hsrtech-book-card,
.hsrtech-toc,
.hsrtech-book-hero__cover img,
.hsrtech-book-card__cover {
	border-radius: var(--alok-card-radius);
}

/* Buttons follow the theme's button contract. */
.hsrtech-page .hsrtech-button {
	background: var(--alok-button-bg);
	border: 1px solid var(--alok-button-bg);
	border-radius: 6px;
	color: var(--alok-button-ink) !important;
	font-family: inherit;
	font-weight: 700;
	min-height: 46px;
}

.hsrtech-page .hsrtech-button:hover {
	background: var(--alok-button-hover);
	border-color: var(--alok-button-hover);
}

.hsrtech-page .hsrtech-button--outline {
	background: transparent;
	border-color: currentColor;
	color: var(--alok-ink) !important;
}

.hsrtech-page .hsrtech-button--outline:hover {
	background: var(--alok-surface-soft);
	border-color: currentColor;
}

.hsrtech-page .hsrtech-text-link {
	border-bottom-color: var(--alok-accent);
}

.hsrtech-page a:focus-visible,
.hsrtech-page button:focus-visible {
	outline: 3px solid var(--alok-focus);
	outline-offset: 4px;
}

.hsrtech-chapter__content a {
	color: var(--alok-article-link);
}

@media (max-width: 650px) {
	.hsrtech-archive__header {
		margin-bottom: 35px;
	}

	.hsrtech-archive__header h1 {
		font-size: clamp(2.25rem, 10vw, 3.5rem);
		letter-spacing: -0.045em;
	}
}

/* -----------------------------------------------------------------------
   Book accent colour (set per book in Chapterwright, brand yellow #f8d94a).
   Fills and borders use it as-is. Where the plugin uses the accent as
   TEXT colour, light mode gets a darkened mix so it stays readable on the
   light canvas; dark mode keeps the accent itself.
   ----------------------------------------------------------------------- */
.hsrtech-page {
	--ab-book-accent-text: color-mix(in srgb, var(--hsrtech-accent, #f8d94a) 38%, #20231f);
}

[data-theme="dark"] .hsrtech-page {
	--ab-book-accent-text: var(--hsrtech-accent, #f8d94a);
}

.hsrtech-page .hsrtech-badge,
.hsrtech-toc-section__link:hover,
.hsrtech-toc-row-link:not(.hsrtech-toc-row-link--draft):hover .hsrtech-toc-row span,
.hsrtech-toc-drawer .hsrtech-toc-section a[aria-current="page"] span:first-child {
	color: var(--ab-book-accent-text);
}

/* Code, inline code, notes, callouts, quotes and tables in chapters share the
   blog article styles: see "Article code" in components.css. */

.hsrtech-chapter__content li::marker {
	color: var(--ab-book-accent-text);
}

.hsrtech-toc-row-link:not(.hsrtech-toc-row-link--draft):hover .hsrtech-toc-row__leader {
	--hsrtech-toc-leader-color: var(--ab-book-accent-text);
}

/* Covers without an image sit on the accent colour: dark title text. */
.hsrtech-book-card__cover-label {
	color: #20231f;
	font-weight: 800;
	letter-spacing: -0.03em;
}

/* Book links: theme link colours, accent underline. */
.hsrtech-chapter__content a {
	color: var(--alok-article-link);
	text-decoration-color: var(--hsrtech-accent, #f8d94a);
}

.hsrtech-chapter__content a:hover {
	color: var(--alok-link-hover);
}
