/* First Blacks – Manuscripts grid (matches the old firstblacks.org layout) */
.fbmg-grid {
	--fbmg-accent: #d9862e;
	--fbmg-thumb: 150px;   /* thumbnail width – change with [fb_manuscripts_grid size="150"] */
	--fbmg-gap-x: 72px;  /* space between columns */
	--fbmg-gap-y: 56px;  /* space between rows */
	list-style: none;
	margin: 40px auto;
	padding: 0;
	max-width: calc(var(--fbmg-cols, 4) * (var(--fbmg-thumb) + var(--fbmg-gap-x)));
	display: grid;
	grid-template-columns: repeat(auto-fill, var(--fbmg-thumb));
	justify-content: center;
	gap: var(--fbmg-gap-y) var(--fbmg-gap-x);
}
.fbmg-item { position: relative; margin: 0; padding: 0; text-align: center; list-style: none; }
.fbmg-item[hidden] { display: none !important; }
.fbmg-pager.fbmg-grid-pager { max-width: 820px; margin: 0 auto 48px; }
.fbmg-item::before { content: none; }
.fbmg-link { display: block; color: #111; text-decoration: none; }
.fbmg-link:hover { color: #111; }

.fbmg-thumb {
	display: block;
	aspect-ratio: var(--fbmg-aspect, 11 / 16);
	border: 1px solid #8a8a8a;
	background: #eee;
	overflow: hidden;
	transition: box-shadow .2s;
}
.fbmg-thumb img.fbmg-img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; margin: 0; }
.fbmg-placeholder { display: block; width: 100%; height: 100%; background: repeating-linear-gradient(0deg, #ddd 0 6px, #eee 6px 12px); }
.fbmg-link:hover .fbmg-thumb,
.fbmg-link:focus-visible .fbmg-thumb { box-shadow: 0 0 0 3px var(--fbmg-accent); }

.fbmg-caption { display: block; margin-top: 8.8px; font-size: 14.4px; line-height: 1.3; }
.fbmg-parts { display: block; font-size: 12.8px; color: #555; }
.fbmg-date { display: block; font-size: 14.4px; line-height: 1.3; }

/* Hover box */
.fbmg-tip {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translate(-50%, -14px);
	width: 420px;
	max-width: 90vw;
	padding: 12.8px 17.6px;
	background: #fff;
	border: 2px solid var(--fbmg-accent);
	color: #000;
	text-align: left;
	font-size: 14.4px;
	font-weight: 700;
	line-height: 1.35;
	z-index: 100;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .15s, visibility .15s;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.fbmg-tip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -10px;
	border: 10px solid transparent;
	border-top-color: var(--fbmg-accent);
}
.fbmg-row { display: block; }
.fbmg-row strong { font-weight: 700; }
.fbmg-link:hover .fbmg-tip,
.fbmg-link:focus-visible .fbmg-tip { opacity: 1; visibility: visible; }

/* keep the box on screen at the edges (set by front.js) */
.fbmg-tip.is-left { left: 0; transform: translate(0, -14px); }
.fbmg-tip.is-left::after { left: calc(var(--fbmg-thumb) / 2); }
.fbmg-tip.is-right { left: auto; right: 0; transform: translate(0, -14px); }
.fbmg-tip.is-right::after { left: auto; right: calc(var(--fbmg-thumb) / 2 - 20px); }

@media (max-width: 600px) {
	.fbmg-grid { --fbmg-thumb: 130px; --fbmg-gap-x: 24px; --fbmg-gap-y: 36px; }
}
@media (max-width: 900px), (hover: none) {
	.fbmg-tip { display: none; }
}

/* =========================================================
 * Page navigation for long Transcription / Translation / Commentary text
 * ====================================================== */
.fbmg-pager {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 9.6px;
	margin: 28px 0;
	padding: 17.6px 0;
	border-top: 1px solid #e3e3e3;
	border-bottom: 1px solid #e3e3e3;
}
.fbmg-pager-top { margin-top: 0; }
.fbmg-pg {
	appearance: none;
	min-width: 49.6px;
	min-height: 49.6px;
	padding: 11.2px 19.2px;
	border: 2px solid #d0d0d0;
	border-radius: 6px;
	background: #fff;
	color: #333;
	font: inherit;
	font-size: 18.4px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background .15s, border-color .15s, color .15s;
}
.fbmg-pg:hover:not(:disabled) { border-color: #d9862e; color: #b86a17; }
.fbmg-pg.is-active { background: #d9862e; border-color: #d9862e; color: #fff; font-weight: 700; }
.fbmg-pg:disabled { opacity: .4; cursor: default; }
.fbmg-pg:focus-visible { outline: 3px solid #111; outline-offset: 2px; }
.fbmg-pg-status { flex-basis: 100%; margin-top: 5.6px; text-align: center; font-size: 16.8px; color: #555; }
@media (max-width: 600px) {
	.fbmg-pg { min-width: 41.6px; min-height: 41.6px; padding: 8.8px 13.6px; font-size: 16px; }
}
.fbmg-page[hidden] { display: none !important; }

/* Maps / images: hover box text comes from the old site */
.fbmg-tip-maps, .fbmg-tip-images { font-weight: 400; }
.fbmg-tip-maps p, .fbmg-tip-images p, .fbmg-tip-maps div, .fbmg-tip-images div { margin: 0 0 4.8px; text-align: left !important; }
.fbmg-tip-maps strong, .fbmg-tip-images strong { display: block; font-size: 16px; margin-bottom: 3.2px; }

/* "Maps related to: …" above a filtered grid */
.fbmg-filter {
	max-width: 900px;
	margin: 24px auto 0;
	padding: 16px 20px;
	background: #f6efe2;
	border-left: 4px solid #d9862e;
	font-size: 16.8px;
}
.fbmg-filter p { margin: 0; }
.fbmg-filter p + p { margin-top: 5.6px; font-size: 15.2px; }
.fbmg-filter a { color: #b86a17; }
.fbmg-empty { text-align: center; margin: 32px 0; }

/* =========================================================
 * Related resources box (topic pages) – as on the old site
 * ====================================================== */
.fbmg-related {
	float: right;
	width: 300px;
	max-width: 100%;
	margin: 0 0 24px 32px;
	position: relative; /* no z-index: the header's drop-down menus must open over it */
}
.fbmg-related-title {
	margin: 0 0 9.6px;
	padding: 12px 16px;
	border-radius: 999px;
	background: #3a1e10;
	color: #fff;
	font-size: 18.4px;
	font-weight: 700;
	letter-spacing: .03em;
	text-align: center;
	text-transform: uppercase;
}
.fbmg-related ul { list-style: none; margin: 0; padding: 0; }
.fbmg-related li { margin: 0 0 8.8px; padding: 0; list-style: none; }
.fbmg-related li::before { content: none; }
.fbmg-related li a {
	display: flex;
	align-items: center;
	gap: 11.2px;
	padding: 11.2px 22.4px;
	border-radius: 999px;
	background: #f3ead8;
	color: #2a160b;
	font-size: 16.8px;
	font-weight: 700;
	text-decoration: none;
	text-transform: uppercase;
	transition: background .15s;
}
.fbmg-related li a::before {
	content: "";
	width: 9.6px;
	height: 9.6px;
	border-radius: 50%;
	background: #d9862e;
	flex: none;
}
.fbmg-related li a:hover { background: #ead9b8; }
.fbmg-related-count {
	margin-left: auto;
	min-width: 28.8px;
	padding: 1.6px 8px;
	border-radius: 999px;
	background: #fff;
	color: #b86a17;
	font-size: 13.6px;
	text-align: center;
}
@media (max-width: 900px) {
	.fbmg-related { float: none; width: auto; margin: 0 0 24px; }
}

/* =========================================================
 * Single map / image / manuscript: ‹ Previous | All | Next ›
 * ====================================================== */
.fbmg-nav-band {
	background: #fcfcfc;
	padding: 28px 20px 4px;
}
.fbmg-nav-band-bottom { padding: 8px 20px 36px; }
.fbmg-item-nav {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 12px;
	max-width: 1140px;
	margin: 0 auto;
	padding: 12px 0;
	border-bottom: 1px solid #ece4d6;
	font-family: Poppins, sans-serif;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.3;
}
.fbmg-item-nav-bottom { border-bottom: 0; border-top: 1px solid #ece4d6; padding-top: 20px; }
.fbmg-item-nav a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #b86a17;
	text-decoration: none;
	padding: 7px 16px;
	border: 1px solid #e3d2b6;
	border-radius: 999px;
	background: #fff;
	transition: background .15s, color .15s, border-color .15s;
}
.fbmg-item-nav a:hover,
.fbmg-item-nav a:focus-visible { background: #c8742a; border-color: #c8742a; color: #fff; }
.fbmg-nav-prev { justify-self: start; }
.fbmg-nav-back { justify-self: center; }
.fbmg-nav-next { justify-self: end; }
.fbmg-nav-count { grid-column: 1 / -1; text-align: center; font-size: 12px; font-weight: 400; color: #9a9a9a; margin-top: -4px; letter-spacing: .04em; }
@media (max-width: 600px) {
	.fbmg-item-nav { grid-template-columns: 1fr 1fr; font-size: 13px; }
	.fbmg-item-nav a { padding: 6px 12px; }
	.fbmg-nav-back { grid-column: 1 / -1; grid-row: 2; }
}

/* Image pages */
.fbmg-media-image { margin: 24px 0; text-align: center; }
.fbmg-media-image img { max-width: 100%; height: auto; }

/* =========================================================
 * Single map / image page frame
 * ====================================================== */
.fbmg-single-media { padding: 40px 20px 48px; }
.fbmg-single-inner { max-width: 1100px; margin: 0 auto; }
.fbmg-single-title {
	margin: 0 0 8px;
	text-align: center;
	font-variant: small-caps;
	font-weight: 400;
	font-size: 33.6px;
	letter-spacing: .02em;
	color: #111;
}
.fbmg-single-content { font-size: 16.8px; line-height: 1.6; }
.fbmg-single-content > p:first-of-type strong:first-child { font-size: 19.2px; }
.fbmg-pdf { margin: 24px 0 0; background: #3a3a3a; }
.fbmg-pdf iframe { display: block; width: 100%; height: 85vh; min-height: 560px; border: 0; }
.fbmg-pdf-link { margin: 0; padding: 9.6px 16px; background: #f4f4f4; text-align: right; font-size: 15.2px; }
.fbmg-pdf-link a { color: #b86a17; }
/* Hide the PDF Embedder fallback link styling leftovers, if any */
.fbmg-media-page .pdfemb-viewer { display: none; }

/* Maps / images grid: show the whole picture inside the frame */
.fbmg-grid-maps .fbmg-thumb, .fbmg-grid-images .fbmg-thumb { background: #f3efe6; }
.fbmg-grid-maps .fbmg-thumb img.fbmg-img { object-fit: cover; object-position: center; }
.fbmg-grid-maps .fbmg-caption, .fbmg-grid-images .fbmg-caption { font-size: 16px; }

/* White page for maps / images (the theme paints single posts dark) */
body.fbmg-media-page { background: #fff !important; color: #222; }
.fbmg-single-media { background: #fff; color: #222; }
.fbmg-single-media h1.fbmg-single-title {
	font-family: "Times New Roman", Times, serif !important;
	font-size: 38.4px !important;
	line-height: 1.2 !important;
	font-weight: 400 !important;
	font-variant: small-caps;
	letter-spacing: .02em !important;
	color: #111 !important;
	margin: 0 0 16px !important;
}
.fbmg-single-media .fbmg-single-content,
.fbmg-single-media .fbmg-single-content p { color: #222; }
.fbmg-single-media .fbmg-single-content strong { color: #111; }

/* Related box placed inside the article text: text wraps around it */
.fbmg-related.is-placed { float: right; width: 300px; margin: 4px 0 24px 36px; }
.fbmg-related.is-placed .fbmg-related-title { line-height: 1.3; }
@media (max-width: 900px) {
	.fbmg-related.is-placed { float: none; width: auto; margin: 0 0 24px; }
}
/* Hide the box until it has been moved into place (avoids a jump) */
body:not(.fbmg-no-js) .fbmg-related:not(.is-placed) { visibility: hidden; }

/* Never show list bullets in the grids (some themes add them) */
ul.fbmg-grid, ul.fbmg-grid > li.fbmg-item { list-style: none !important; margin-left: 0; padding-left: 0; }
ul.fbmg-grid > li.fbmg-item::marker { content: none; }
ul.fbmg-grid > li.fbmg-item::before, ul.fbmg-grid > li.fbmg-item::after { content: none !important; display: none !important; }
.fbmg-related li::marker { content: none; }

/* =========================================================
 * Page not found
 * ====================================================== */
.fbmg-404-inner { max-width: 760px; text-align: center; padding: 40px 0 60px; }
.fbmg-404-code { margin: 0; font-family: "Times New Roman", Times, serif; font-size: 96px; line-height: 1; font-weight: 700; color: #d9862e; letter-spacing: 4px; }
.fbmg-404-text { margin: 16px auto 28px; max-width: 600px; font-size: 18px; line-height: 1.6; color: #333; }
.fbmg-404-search { display: flex; max-width: 520px; margin: 0 auto 32px; gap: 8px; }
.fbmg-404-search input[type="search"] { flex: 1; min-width: 0; padding: 12px 16px; border: 2px solid #e0d2b8; border-radius: 6px; font-size: 16px; }
.fbmg-404-search input[type="search"]:focus { outline: none; border-color: #d9862e; }
.fbmg-404-search button { padding: 12px 24px; border: 0; border-radius: 6px; background: #3a1e10; color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; }
.fbmg-404-search button:hover { background: #d9862e; }
.fbmg-404-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.fbmg-404-links li { margin: 0; list-style: none; }
.fbmg-404-links li::before, .fbmg-404-links li::marker { content: none; }
.fbmg-404-links a { display: inline-block; padding: 11px 22px; border-radius: 999px; background: #f3ead8; color: #2a160b; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; text-decoration: none; }
.fbmg-404-links a:hover { background: #ead9b8; }

/* =========================================================
 * PDF viewer (PDF.js) – manuscripts and maps
 * ====================================================== */
.fbmg-pdfv { margin: 8px 0 24px; border: 1px solid #d9d2c4; border-radius: 6px; background: #f2efe9; overflow: hidden; }
.fbmg-pdfv-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #3a1e10; color: #fff; font-size: 15px; }
.fbmg-pdfv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fbmg-pdfv-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.fbmg-pdfv-zoom { width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; background: transparent; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.fbmg-pdfv-zoom:hover { background: rgba(255,255,255,.15); }
.fbmg-pdfv-open { color: #fff !important; text-decoration: underline; font-size: 14px; padding: 0 4px; }
.fbmg-pdfv-pages { max-height: 85vh; overflow: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.fbmg-pdfv-pages.is-zoomed { overflow-x: auto; }
.fbmg-pdfv-page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.fbmg-pdfv-page canvas { display: block; max-width: none; }
.fbmg-pdfv-pages:not(.is-zoomed) .fbmg-pdfv-page canvas { max-width: 100%; height: auto !important; }
.fbmg-pdfv-pnum { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; }
.fbmg-pdfv-loading, .fbmg-pdfv-error { margin: 24px; text-align: center; color: #555; font-size: 16px; }
.fbmg-pdfv-actions { margin: 0; padding: 12px 14px; background: #fff; border-top: 1px solid #e6dfd2; text-align: center; }
.fbmg-pdfv-download { display: inline-block; padding: 11px 26px; border-radius: 6px; background: #d9862e; color: #fff !important; font-weight: 700; font-size: 16px; text-decoration: none !important; }
.fbmg-pdfv-download:hover { background: #b86a17; }
@media (max-width: 600px) {
	.fbmg-pdfv-pages { max-height: 75vh; padding: 6px; }
	.fbmg-pdfv-bar { font-size: 13px; padding: 8px 10px; }
}

/* Manuscript page title (H1) */
h1.fbmg-page-title { max-width: 1140px; margin: 0 auto 6px; text-align: center; font-family: Poppins, sans-serif; font-variant: normal; text-transform: none; letter-spacing: .01em; font-weight: 600; font-size: 30px; line-height: 1.25; color: #1d1d1d; }
@media (max-width: 600px) { h1.fbmg-page-title { font-size: 24px; } }
/* Site name in the header is no longer an H1 – keep its look */
p[data-fbmg-was="h1"] { margin: 0; }
.fbmg-single-media .fbmg-nav-band { background: transparent; padding-left: 0; padding-right: 0; }
