/*
 * SleepBaby.org 2.5.7 article interaction hardening.
 *
 * This late, cache-safe layer retains the 2.5.6 editorial reset while making
 * reference links and wide data tables reliably usable on narrow screens.
 */

body.sleepbaby-single-post :is(
	.site-brand-logo-link--header,
	.site-brand-logo-link--footer
) {
	display: inline-flex !important;
	min-width: 44px !important;
	min-height: 44px !important;
	align-items: center;
	justify-content: center;
}

/*
 * Reference links are enhanced by article-v257.js. The real anchor box—not a
 * decorative pseudo-element—owns an explicit, non-overlapping 44px target.
 * Its inline footprint is reserved in layout so adjacent citations and the
 * following prose can never sit beneath an ambiguous hit area.
 */
body.sleepbaby-single-post .entry-content a[data-sb-article-reference-link] {
	display: inline-flex !important;
	min-width: 44px !important;
	min-height: 44px !important;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	margin-inline: 2px !important;
	padding-inline: 8px !important;
	border-radius: 6px;
	vertical-align: middle;
}

body.sleepbaby-single-post .entry-content sup > a[data-sb-article-reference-link] {
	width: 44px !important;
	height: 44px !important;
	margin: 0 2px !important;
	padding: 0 !important;
	line-height: 1 !important;
	vertical-align: middle;
}

/*
 * WordPress table figures and unwrapped legacy tables receive the same
 * keyboard-focusable region class from article-v257.js. The table itself
 * remains a semantic table; only its labeled parent owns horizontal scroll.
 */
body.sleepbaby-single-post .entry-content .sb-article-table-scroll {
	display: block !important;
	max-width: 100% !important;
	overflow-x: auto !important;
	overflow-y: hidden !important;
	overscroll-behavior-inline: contain;
	scrollbar-color: #725d7d #eee8f0;
	scrollbar-gutter: stable;
	scrollbar-width: auto;
	touch-action: pan-x;
	-webkit-overflow-scrolling: touch;
}

body.sleepbaby-single-post .entry-content .sb-article-table-scroll > table,
body.sleepbaby-single-post .entry-content .wp-block-table.sb-article-table-scroll > table {
	display: table !important;
	width: 100% !important;
	max-width: none !important;
	overflow: visible !important;
	border-collapse: collapse;
}

body.sleepbaby-single-post .entry-content .sb-article-table-scroll:focus-visible {
	outline: 3px solid var(--sb256-focus, #0b65b1) !important;
	outline-offset: 4px !important;
}

body.sleepbaby-single-post .entry-content .sb-article-table-scroll::-webkit-scrollbar {
	height: 11px;
}

body.sleepbaby-single-post .entry-content .sb-article-table-scroll::-webkit-scrollbar-track {
	border-radius: 999px;
	background: #eee8f0;
}

body.sleepbaby-single-post .entry-content .sb-article-table-scroll::-webkit-scrollbar-thumb {
	border: 2px solid #eee8f0;
	border-radius: 999px;
	background: #725d7d;
}

@media (max-width: 768px) {
	body.sleepbaby-single-post .entry-content > .sb-article-table-scroll,
	body.sleepbaby-single-post .entry-content > .wp-block-table.sb-article-table-scroll {
		width: 100% !important;
		max-width: 100% !important;
		margin: 32px 0 42px !important;
		padding: 0 0 3px !important;
		border: 1px solid var(--sb256-line, #d9cedd) !important;
		border-radius: 16px !important;
		background: var(--sb256-paper-bright, #fff) !important;
		box-shadow: 0 12px 28px rgba(54, 36, 61, .1) !important;
	}

	body.sleepbaby-single-post .entry-content .sb-article-table-scroll > table,
	body.sleepbaby-single-post .entry-content .wp-block-table.sb-article-table-scroll > table {
		width: max-content !important;
		min-width: 40rem !important;
		font-size: 16px !important;
		line-height: 1.4 !important;
	}

	body.sleepbaby-single-post .entry-content .sb-article-table-scroll :is(th, td) {
		min-width: 9.5rem;
		padding: 11px 12px !important;
		overflow-wrap: normal !important;
		word-break: normal !important;
	}
}

@media (forced-colors: active) {
	body.sleepbaby-single-post .entry-content :is(
		a[data-sb-article-reference-link],
		.sb-article-table-scroll
	) {
		border: 1px solid LinkText !important;
	}
}
