/**
 * Book Marketplace Toolkit — core design system
 * ------------------------------------------------------------------
 * Design tokens + shared components (buttons, cards, badges, forms,
 * modal shell) reused by every module. Loading this once and letting
 * feature stylesheets build on it is what keeps total CSS small even
 * though there are ten separate front-end features.
 *
 * Palette: the old snippets used #0072BC / #0071dc inconsistently
 * across different files — clearly one intended brand blue that drifted
 * from being hand-typed in different sessions. It's formalised here as
 * --bmtk-primary so the whole plugin (and the rest of the site, which
 * already uses that blue) stays visually consistent. The gold is the
 * one deliberate accent — used sparingly for ratings, credentials and
 * "featured" marks, nodding to foil lettering on a book spine.
 *
 * No external font requests: every typeface below is a system stack,
 * so there is zero added network cost for type.
 * ------------------------------------------------------------------
 */

.bmtk-scope {
	/* Colour */
	--bmtk-primary: #0072bc;
	--bmtk-primary-dark: #005a92;
	--bmtk-navy: #0a3d5c;
	--bmtk-gold: #b8862e;
	--bmtk-gold-light: #e9d2a3;
	--bmtk-ink: #1c2b36;
	--bmtk-ink-soft: #51606b;
	--bmtk-bg: #f7f8fa;
	--bmtk-surface: #ffffff;
	--bmtk-border: #e2e6ea;
	--bmtk-border-soft: #edf0f2;
	--bmtk-success: #2f8557;
	--bmtk-success-bg: #eaf5ef;
	--bmtk-danger: #c1442d;
	--bmtk-danger-bg: #fbece8;
	--bmtk-focus-ring: #0072bc;

	/* Type */
	--bmtk-font-display: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
	--bmtk-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--bmtk-font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;

	/* Scale */
	--bmtk-space-1: 4px;
	--bmtk-space-2: 8px;
	--bmtk-space-3: 12px;
	--bmtk-space-4: 16px;
	--bmtk-space-5: 24px;
	--bmtk-space-6: 32px;
	--bmtk-space-7: 48px;
	--bmtk-space-8: 64px;

	--bmtk-radius-sm: 8px;
	--bmtk-radius-md: 12px;
	--bmtk-radius-lg: 16px;
	--bmtk-radius-pill: 999px;

	--bmtk-shadow-sm: 0 1px 2px rgba(28, 43, 54, 0.06);
	--bmtk-shadow-md: 0 4px 16px rgba(28, 43, 54, 0.08);
	--bmtk-shadow-lg: 0 12px 32px rgba(28, 43, 54, 0.14);

	--bmtk-ease: cubic-bezier(0.4, 0, 0.2, 1);
	--bmtk-duration: 180ms;

	color: var(--bmtk-ink);
	font-family: var(--bmtk-font-body);
	-webkit-font-smoothing: antialiased;
}

/* Reset is scoped to .bmtk-scope only — never touches global elements,
   so it can't bleed into the surrounding theme. */
.bmtk-scope,
.bmtk-scope *,
.bmtk-scope *::before,
.bmtk-scope *::after {
	box-sizing: border-box;
}
.bmtk-scope img {
	max-width: 100%;
	display: block;
}
.bmtk-scope ul,
.bmtk-scope ol {
	margin: 0;
	padding: 0;
	list-style: none;
}
.bmtk-scope p {
	margin: 0 0 var(--bmtk-space-3);
}
.bmtk-scope a {
	color: inherit;
	text-decoration: none;
}
.bmtk-scope h1,
.bmtk-scope h2,
.bmtk-scope h3,
.bmtk-scope h4 {
	font-family: var(--bmtk-font-display);
	font-weight: 600;
	line-height: 1.25;
	color: var(--bmtk-navy);
	margin: 0 0 var(--bmtk-space-3);
}

/* Respect reduced-motion preferences everywhere in the plugin. */
@media (prefers-reduced-motion: reduce) {
	.bmtk-scope * {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}

/* Visible keyboard focus everywhere — no outline: none anywhere in this
   plugin without a replacement. */
.bmtk-scope :focus-visible {
	outline: 2px solid var(--bmtk-focus-ring);
	outline-offset: 2px;
	border-radius: var(--bmtk-radius-sm);
}

.bmtk-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                              */
/* ------------------------------------------------------------------ */
.bmtk-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--bmtk-space-2);
	font-family: var(--bmtk-font-body);
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	padding: 12px 20px;
	border-radius: var(--bmtk-radius-sm);
	border: 1px solid transparent;
	cursor: pointer;
	transition: background-color var(--bmtk-duration) var(--bmtk-ease),
		border-color var(--bmtk-duration) var(--bmtk-ease),
		color var(--bmtk-duration) var(--bmtk-ease),
		transform var(--bmtk-duration) var(--bmtk-ease);
}
.bmtk-btn:active {
	transform: translateY(1px);
}
.bmtk-btn--primary {
	background: var(--bmtk-primary);
	color: #fff;
}
.bmtk-btn--primary:hover {
	background: var(--bmtk-primary-dark);
}
.bmtk-btn--secondary {
	background: var(--bmtk-surface);
	color: var(--bmtk-navy);
	border-color: var(--bmtk-border);
}
.bmtk-btn--secondary:hover {
	border-color: var(--bmtk-primary);
	color: var(--bmtk-primary);
}
.bmtk-btn--ghost {
	background: transparent;
	color: var(--bmtk-ink-soft);
}
.bmtk-btn--ghost:hover {
	background: var(--bmtk-bg);
	color: var(--bmtk-ink);
}
.bmtk-btn--sm {
	padding: 8px 14px;
	font-size: 13px;
}
.bmtk-btn--block {
	width: 100%;
}
.bmtk-btn--icon {
	padding: 10px;
	border-radius: var(--bmtk-radius-pill);
}
.bmtk-btn[disabled],
.bmtk-btn[aria-disabled="true"] {
	opacity: 0.55;
	cursor: not-allowed;
}

/* ------------------------------------------------------------------ */
/* Cards                                                                */
/* ------------------------------------------------------------------ */
.bmtk-card {
	background: var(--bmtk-surface);
	border: 1px solid var(--bmtk-border-soft);
	border-radius: var(--bmtk-radius-md);
	box-shadow: var(--bmtk-shadow-sm);
	transition: box-shadow var(--bmtk-duration) var(--bmtk-ease),
		transform var(--bmtk-duration) var(--bmtk-ease),
		border-color var(--bmtk-duration) var(--bmtk-ease);
}
.bmtk-card--interactive:hover {
	box-shadow: var(--bmtk-shadow-md);
	border-color: var(--bmtk-border);
	transform: translateY(-2px);
}

/* ------------------------------------------------------------------ */
/* Badges — the gold variant is the plugin's one signature accent,     */
/* used only for ratings, credentials and "featured" marks.            */
/* ------------------------------------------------------------------ */
.bmtk-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	font-weight: 600;
	padding: 4px 10px;
	border-radius: var(--bmtk-radius-pill);
	line-height: 1.4;
	white-space: nowrap;
}
.bmtk-badge--neutral {
	background: var(--bmtk-bg);
	color: var(--bmtk-ink-soft);
}
.bmtk-badge--success {
	background: var(--bmtk-success-bg);
	color: var(--bmtk-success);
}
.bmtk-badge--danger {
	background: var(--bmtk-danger-bg);
	color: var(--bmtk-danger);
}
.bmtk-badge--gold {
	background: linear-gradient(135deg, #fbf2df, #f3e0b6);
	color: #7a5a17;
	border: 1px solid var(--bmtk-gold-light);
}
.bmtk-badge--removable {
	padding-right: 6px;
}
.bmtk-badge__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: rgba(28, 43, 54, 0.12);
	border: 0;
	cursor: pointer;
	color: inherit;
	font-size: 10px;
	line-height: 1;
}
.bmtk-badge__remove:hover {
	background: rgba(28, 43, 54, 0.22);
}

/* "Credential seal" — the signature motif: a small gold ring used on
   star ratings and qualification markers. */
.bmtk-seal {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: linear-gradient(135deg, #fbf2df, #f3e0b6);
	border: 1px solid var(--bmtk-gold-light);
	color: var(--bmtk-gold);
	flex-shrink: 0;
}
.bmtk-seal svg {
	width: 14px;
	height: 14px;
}

/* ------------------------------------------------------------------ */
/* Forms                                                                */
/* ------------------------------------------------------------------ */
.bmtk-field {
	display: block;
	width: 100%;
	font-family: var(--bmtk-font-body);
	font-size: 14px;
	color: var(--bmtk-ink);
	background: var(--bmtk-surface);
	border: 1px solid var(--bmtk-border);
	border-radius: var(--bmtk-radius-sm);
	padding: 10px 14px;
	transition: border-color var(--bmtk-duration) var(--bmtk-ease), box-shadow var(--bmtk-duration) var(--bmtk-ease);
}
.bmtk-field:focus {
	border-color: var(--bmtk-primary);
	box-shadow: 0 0 0 3px rgba(0, 114, 188, 0.15);
	outline: none;
}
/* Targets third-party form fields (Gravity Forms, CF7, etc.) that live
   outside .bmtk-scope, so tokens need literal fallbacks here. */
.bmtk-autofilled {
	background-color: var(--bmtk-bg, #f7f8fa) !important;
	cursor: not-allowed !important;
}
.bmtk-checkbox-row {
	display: flex;
	align-items: center;
	gap: var(--bmtk-space-2);
	padding: 7px 0;
	cursor: pointer;
	font-size: 14px;
}
.bmtk-checkbox-row input[type="checkbox"],
.bmtk-checkbox-row input[type="radio"] {
	width: 17px;
	height: 17px;
	accent-color: var(--bmtk-primary);
	cursor: pointer;
	flex-shrink: 0;
}
.bmtk-checkbox-row__count {
	margin-left: auto;
	font-family: var(--bmtk-font-mono);
	font-size: 12px;
	color: var(--bmtk-ink-soft);
}

/* Range slider, shared by the price filter widget */
.bmtk-range {
	width: 100%;
	height: 4px;
	border-radius: var(--bmtk-radius-pill);
	background: var(--bmtk-border);
	appearance: none;
	-webkit-appearance: none;
}
.bmtk-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--bmtk-primary);
	border: 3px solid #fff;
	box-shadow: var(--bmtk-shadow-sm);
	cursor: pointer;
}
.bmtk-range::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--bmtk-primary);
	border: 3px solid #fff;
	box-shadow: var(--bmtk-shadow-sm);
	cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Loading / empty / error states — shared microcopy patterns          */
/* ------------------------------------------------------------------ */
.bmtk-skeleton {
	background: linear-gradient(90deg, var(--bmtk-border-soft) 25%, var(--bmtk-border) 37%, var(--bmtk-border-soft) 63%);
	background-size: 400% 100%;
	animation: bmtk-skeleton-wave 1.4s ease infinite;
	border-radius: var(--bmtk-radius-sm);
}
@keyframes bmtk-skeleton-wave {
	0% {
		background-position: 100% 50%;
	}
	100% {
		background-position: 0 50%;
	}
}
.bmtk-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(0, 114, 188, 0.25);
	border-top-color: var(--bmtk-primary);
	border-radius: 50%;
	animation: bmtk-spin 0.7s linear infinite;
}
@keyframes bmtk-spin {
	to {
		transform: rotate(360deg);
	}
}
.bmtk-empty {
	text-align: center;
	padding: var(--bmtk-space-7) var(--bmtk-space-4);
	color: var(--bmtk-ink-soft);
}
.bmtk-empty__icon {
	width: 44px;
	height: 44px;
	margin: 0 auto var(--bmtk-space-3);
	color: var(--bmtk-border);
}
.bmtk-empty__title {
	font-weight: 600;
	color: var(--bmtk-ink);
	margin-bottom: 4px;
}

/* Applied to <html> while any bmtk modal is open, to stop background
   scroll. Scoped to a specific class rather than touching body styles
   globally so it can't conflict with the theme's own scroll-lock use. */
html.bmtk-modal-locked {
	overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Modal shell — shared by social share + book filter popup            */
/* ------------------------------------------------------------------ */
.bmtk-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(10, 23, 33, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--bmtk-space-4);
	z-index: 100000;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--bmtk-duration) var(--bmtk-ease), visibility var(--bmtk-duration) var(--bmtk-ease);
}
.bmtk-modal-overlay.is-open {
	opacity: 1;
	visibility: visible;
}
.bmtk-modal {
	background: var(--bmtk-surface);
	border-radius: var(--bmtk-radius-lg);
	box-shadow: var(--bmtk-shadow-lg);
	width: 100%;
	max-width: 480px;
	max-height: 88vh;
	overflow-y: auto;
	transform: translateY(12px) scale(0.98);
	transition: transform var(--bmtk-duration) var(--bmtk-ease);
}
.bmtk-modal-overlay.is-open .bmtk-modal {
	transform: translateY(0) scale(1);
}
.bmtk-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--bmtk-space-3);
	padding: var(--bmtk-space-4) var(--bmtk-space-5);
	border-bottom: 1px solid var(--bmtk-border-soft);
	position: sticky;
	top: 0;
	background: var(--bmtk-surface);
}
.bmtk-modal__title {
	margin: 0;
	font-size: 17px;
}
.bmtk-modal__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 0;
	background: var(--bmtk-bg);
	color: var(--bmtk-ink-soft);
	cursor: pointer;
	flex-shrink: 0;
}
.bmtk-modal__close:hover {
	background: var(--bmtk-border);
	color: var(--bmtk-ink);
}
.bmtk-modal__body {
	padding: var(--bmtk-space-5);
}
.bmtk-modal__footer {
	display: flex;
	justify-content: flex-end;
	gap: var(--bmtk-space-2);
	padding: var(--bmtk-space-4) var(--bmtk-space-5);
	border-top: 1px solid var(--bmtk-border-soft);
	position: sticky;
	bottom: 0;
	background: var(--bmtk-surface);
}

/* ------------------------------------------------------------------ */
/* Carousel shell — native scroll-snap, shared by any module that      */
/* needs a slider (currently the author directory).                    */
/* ------------------------------------------------------------------ */
.bmtk-slider {
	position: relative;
}
.bmtk-slider__track {
	display: flex;
	gap: var(--bmtk-space-4);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	padding-block: 4px;
}
.bmtk-slider__track::-webkit-scrollbar {
	display: none;
}
.bmtk-slider__slide {
	scroll-snap-align: start;
	flex: 0 0 auto;
}
.bmtk-slider__nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--bmtk-surface);
	border: 1px solid var(--bmtk-border);
	box-shadow: var(--bmtk-shadow-sm);
	color: var(--bmtk-navy);
	cursor: pointer;
	transition: background-color var(--bmtk-duration) var(--bmtk-ease), color var(--bmtk-duration) var(--bmtk-ease);
}
.bmtk-slider__nav:hover {
	background: var(--bmtk-primary);
	color: #fff;
	border-color: var(--bmtk-primary);
}
.bmtk-slider__nav svg {
	width: 18px;
	height: 18px;
}
.bmtk-slider__controls {
	display: flex;
	justify-content: flex-end;
	gap: var(--bmtk-space-2);
	margin-top: var(--bmtk-space-4);
}
.bmtk-slider__dots {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: var(--bmtk-space-4);
}
.bmtk-slider__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--bmtk-border);
	border: 0;
	padding: 0;
	cursor: pointer;
	transition: background-color var(--bmtk-duration) var(--bmtk-ease), width var(--bmtk-duration) var(--bmtk-ease);
}
.bmtk-slider__dot.is-active {
	background: var(--bmtk-primary);
	width: 22px;
	border-radius: var(--bmtk-radius-pill);
}

/* ------------------------------------------------------------------ */
/* Pagination — shared component                                       */
/* ------------------------------------------------------------------ */
.bmtk-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: var(--bmtk-space-2);
	margin-top: var(--bmtk-space-6);
}
.bmtk-pagination__nav {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 16px;
	border-radius: var(--bmtk-radius-sm);
	border: 1px solid var(--bmtk-border);
	background: var(--bmtk-surface);
	font-size: 14px;
	font-weight: 600;
	color: var(--bmtk-navy);
}
.bmtk-pagination__nav:hover {
	border-color: var(--bmtk-primary);
	color: var(--bmtk-primary);
}
.bmtk-pagination__nav svg {
	width: 14px;
	height: 14px;
}
.bmtk-pagination__pages {
	display: flex;
	align-items: center;
	gap: 4px;
}
.bmtk-pagination__page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	border-radius: var(--bmtk-radius-sm);
	font-size: 14px;
	font-weight: 600;
	color: var(--bmtk-ink-soft);
}
.bmtk-pagination__page:hover {
	background: var(--bmtk-bg);
	color: var(--bmtk-ink);
}
.bmtk-pagination__page.is-current {
	background: var(--bmtk-primary);
	color: #fff;
}
.bmtk-pagination__dots {
	padding: 0 4px;
	color: var(--bmtk-ink-soft);
}

/* ------------------------------------------------------------------ */
/* Layout utilities                                                     */
/* ------------------------------------------------------------------ */
.bmtk-container {
	max-width: 1240px;
	margin-inline: auto;
	padding-inline: var(--bmtk-space-4);
}
.bmtk-grid {
	display: grid;
	gap: var(--bmtk-space-5);
}
.bmtk-visually-hidden-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}
