/*
 * Front-end styles of the ngheduoc/* blocks. Colours and sizes come from the active theme's
 * presets, with fallbacks so the blocks stay readable under any theme.
 */

/* Padding stays inside the reading column's max-width instead of widening the box past it. */
.ngheduoc-toc,
.ngheduoc-sources,
.ngheduoc-disclaimer,
.ngheduoc-expert-box,
.ngheduoc-expert-box__card,
.ngheduoc-legal-meta,
.ngheduoc-cta {
	box-sizing: border-box;
}

.ngheduoc-byline {
	color: var(--wp--preset--color--muted, #5b6b74);
	display: flex;
	flex-wrap: wrap;
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	gap: 0.25rem 1rem;
}

.ngheduoc-byline a {
	color: var(--wp--preset--color--primary, #075985);
	font-weight: 600;
}

/* Table of contents */
.ngheduoc-toc {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: var(--wp--custom--radius--card, 10px);
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	padding: 0.75rem 1rem;
}

.ngheduoc-toc summary {
	cursor: pointer;
	font-weight: 700;
	min-height: 44px;
	display: flex;
	align-items: center;
	color: var(--wp--preset--color--primary, #075985);
}

.ngheduoc-toc ol {
	margin: 0.25rem 0 0;
	padding-left: 1.25rem;
}

.ngheduoc-toc li {
	margin: 0;
}

/* NFR-3: each TOC link has a full-width 44px minimum tap target across all devices */
.ngheduoc-toc a {
	align-items: center;
	box-sizing: border-box;
	color: var(--wp--preset--color--primary, #075985);
	display: flex;
	min-height: 44px;
	padding: 0.375rem 0.5rem;
	text-decoration: none;
	width: 100%;
}

.ngheduoc-toc a:hover {
	text-decoration: underline;
}

/* Floating TOC Quick-jump Pill (Mobile & Tablet < 1200px) */
.ngheduoc-toc-pill {
	align-items: center;
	background: var(--wp--preset--color--surface, #f2f7f7);
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: 999px;
	bottom: 1.5rem;
	box-shadow: 0 4px 16px rgba(22, 49, 61, 0.14);
	box-sizing: border-box;
	color: var(--wp--preset--color--contrast, #16313d);
	cursor: pointer;
	display: inline-flex;
	font-family: var(--wp--preset--font-family--ui, "Be Vietnam Pro", sans-serif);
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	font-weight: 600;
	gap: 0.5rem;
	min-height: 44px;
	opacity: 0;
	padding: 0 1.125rem;
	pointer-events: none;
	position: fixed;
	right: 1.5rem;
	transform: translateY(20px);
	transition: opacity 0.25s ease, transform 0.25s ease;
	z-index: 90;
}

.ngheduoc-toc-pill.is-visible {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

.ngheduoc-toc-pill:hover,
.ngheduoc-toc-pill:focus-visible {
	background: var(--wp--preset--color--base, #fff);
	border-color: var(--wp--preset--color--primary, #075985);
	color: var(--wp--preset--color--primary, #075985);
}

.ngheduoc-toc-pill svg {
	flex-shrink: 0;
}

/* Floating TOC Mobile Drawer & Backdrop */
.ngheduoc-toc-backdrop {
	background: rgba(22, 49, 61, 0.45);
	inset: 0;
	opacity: 0;
	pointer-events: none;
	position: fixed;
	transition: opacity 0.25s ease;
	z-index: 98;
}

.ngheduoc-toc-backdrop.is-open {
	opacity: 1;
	pointer-events: auto;
}

.ngheduoc-toc-drawer {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border-radius: 16px 16px 0 0;
	border-top: 1px solid var(--wp--preset--color--border, #d5e1e3);
	bottom: 0;
	box-shadow: 0 -4px 24px rgba(22, 49, 61, 0.18);
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	left: 0;
	max-height: 75vh;
	pointer-events: none;
	position: fixed;
	right: 0;
	transform: translateY(100%);
	transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
	z-index: 99;
}

.ngheduoc-toc-drawer.is-open {
	pointer-events: auto;
	transform: translateY(0);
}

.ngheduoc-toc-drawer__header {
	align-items: center;
	border-bottom: 1px solid var(--wp--preset--color--border, #d5e1e3);
	box-sizing: border-box;
	display: flex;
	justify-content: space-between;
	padding: 0.75rem 1.25rem;
}

.ngheduoc-toc-drawer__title {
	color: var(--wp--preset--color--primary, #075985);
	font-family: var(--wp--preset--font-family--ui, "Be Vietnam Pro", sans-serif);
	font-size: var(--wp--preset--font-size--medium, 1.0625rem);
	font-weight: 700;
	margin: 0;
}

.ngheduoc-toc-drawer__close {
	align-items: center;
	background: transparent;
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: 999px;
	box-sizing: border-box;
	color: var(--wp--preset--color--muted, #5b6b74);
	cursor: pointer;
	display: inline-flex;
	font-size: 1.25rem;
	height: 44px;
	justify-content: center;
	line-height: 1;
	margin: 0;
	padding: 0;
	width: 44px;
}

.ngheduoc-toc-drawer__close:hover,
.ngheduoc-toc-drawer__close:focus-visible {
	border-color: var(--wp--preset--color--primary, #075985);
	color: var(--wp--preset--color--primary, #075985);
}

.ngheduoc-toc-drawer__body {
	-webkit-overflow-scrolling: touch;
	overflow-y: auto;
	padding: 0.5rem 1.25rem 2rem;
}

.ngheduoc-toc-drawer__body ol {
	list-style: decimal;
	margin: 0;
	padding-left: 1.25rem;
}

.ngheduoc-toc-drawer__body ol ol {
	padding-left: 1.25rem;
}

.ngheduoc-toc-drawer__body li {
	margin: 0;
}

.ngheduoc-toc-drawer__body a {
	align-items: center;
	border-bottom: 1px solid var(--wp--preset--color--border, #d5e1e3);
	box-sizing: border-box;
	color: var(--wp--preset--color--contrast, #16313d);
	display: flex;
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	min-height: 44px;
	padding: 0.5rem 0.25rem;
	text-decoration: none;
	width: 100%;
}

.ngheduoc-toc-drawer__body a:hover,
.ngheduoc-toc-drawer__body a:focus-visible {
	color: var(--wp--preset--color--primary, #075985);
	text-decoration: underline;
}

@media (min-width: 1200px) {
	.ngheduoc-toc-pill,
	.ngheduoc-toc-backdrop,
	.ngheduoc-toc-drawer {
		display: none !important;
	}
}

/*
 * NFR-3: on touch screens, links stacked in a list get a 44px tall target.
 */
@media (pointer: coarse) {
	.ngheduoc-expert-box__name a,
	.ngheduoc-expert-articles li > a {
		align-items: center;
		display: inline-flex;
		min-height: 44px;
	}
}

/* Headings jumped to from the table of contents clear the sticky header. */
:where(.wp-block-post-content) :is(h2, h3)[id] {
	scroll-margin-top: 6rem;
}

/* Sources */
.ngheduoc-sources {
	border-top: 1px solid var(--wp--preset--color--border, #d5e1e3);
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	padding-top: 1rem;
}

.ngheduoc-sources__heading {
	font-size: var(--wp--preset--font-size--medium, 1.0625rem);
}

.ngheduoc-sources__list li {
	margin: 0.375rem 0;
}

.ngheduoc-sources__detail {
	color: var(--wp--preset--color--muted, #5b6b74);
}

.ngheduoc-sources__tier {
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: 999px;
	color: var(--wp--preset--color--muted, #5b6b74);
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
	margin-left: 0.5rem;
	padding: 0 0.5rem;
	white-space: nowrap;
}

/* Disclaimer */
.ngheduoc-disclaimer {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border-left: 3px solid var(--wp--preset--color--primary, #075985);
	border-radius: 0 4px 4px 0;
	color: var(--wp--preset--color--contrast, #16313d);
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	line-height: 1.5;
	padding: 0.75rem 1rem;
}

.ngheduoc-disclaimer p {
	margin: 0;
}

/* Expert box */
.ngheduoc-expert-box {
	display: grid;
	gap: 1rem;
	grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.ngheduoc-expert-box__card {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: var(--wp--custom--radius--card, 10px);
	display: flex;
	gap: 1rem;
	padding: 1rem;
}

.ngheduoc-expert-box__card p {
	margin: 0 0 0.25rem;
}

.ngheduoc-expert-box__photo {
	border-radius: 50%;
	flex: none;
	height: 64px;
	object-fit: cover;
	width: 64px;
}

.ngheduoc-expert-box__role,
.ngheduoc-expert-box__title {
	color: var(--wp--preset--color--muted, #5b6b74);
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
}

.ngheduoc-expert-box__name {
	font-weight: 700;
}

.ngheduoc-expert-box__bio {
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
}

/* Legal document details */
.ngheduoc-legal-meta {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: var(--wp--custom--radius--card, 10px);
	display: grid;
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	gap: 0.5rem 1rem;
	grid-template-columns: minmax(8rem, max-content) 1fr;
	padding: 1rem;
}

.ngheduoc-legal-meta dt {
	color: var(--wp--preset--color--muted, #5b6b74);
}

.ngheduoc-legal-meta dd {
	font-weight: 600;
	margin: 0;
}

/* Semantic badges (DEC-10): red only for warnings, green only for a valid state. */
.ngheduoc-badge {
	border-radius: 999px;
	display: inline-block;
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
	font-weight: 600;
	padding: 0.125rem 0.625rem;
}

.ngheduoc-badge--positive {
	background: var(--wp--preset--color--positive, #15803d);
	color: var(--wp--preset--color--base, #fff);
}

.ngheduoc-badge--alert {
	background: var(--wp--preset--color--alert, #c62828);
	color: var(--wp--preset--color--base, #fff);
}

.ngheduoc-badge--neutral {
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	color: var(--wp--preset--color--contrast, #16313d);
}

/* Expert profile and article list */
.ngheduoc-expert-profile__title {
	color: var(--wp--preset--color--muted, #5b6b74);
	font-weight: 600;
}

.ngheduoc-expert-profile__label {
	color: var(--wp--preset--color--muted, #5b6b74);
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
	font-weight: 600;
	letter-spacing: 0.04em;
	margin: 1rem 0 0.25rem;
	text-transform: uppercase;
}

.ngheduoc-expert-profile__expertise,
.ngheduoc-expert-profile__profiles {
	margin: 0;
	padding-left: 1.25rem;
}

.ngheduoc-expert-articles ul {
	padding-left: 1.25rem;
}

.ngheduoc-expert-articles li {
	margin: 0.5rem 0;
}

.ngheduoc-expert-articles__meta {
	color: var(--wp--preset--color--muted, #5b6b74);
	display: block;
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
}

@media (max-width: 600px) {
	.ngheduoc-legal-meta {
		grid-template-columns: 1fr;
	}

	.ngheduoc-legal-meta dd {
		margin-bottom: 0.5rem;
	}
}

/* Section heading used by the related, featured, topics and pillar blocks. */
.ngheduoc-section-heading {
	font-size: var(--wp--preset--font-size--large, 1.375rem);
	margin: 0 0 1rem;
}

/* Article cards: a responsive grid; the "lead" variant is one large horizontal card. */
.ngheduoc-cards {
	display: grid;
	gap: 1.5rem;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	list-style: none;
	margin: 0;
	padding: 0;
}

.ngheduoc-card {
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
}

.ngheduoc-card__image img {
	aspect-ratio: 16 / 9;
	border-radius: var(--wp--custom--radius--card, 10px);
	display: block;
	height: auto;
	object-fit: cover;
	width: 100%;
}

.ngheduoc-card p,
.ngheduoc-card h3 {
	margin: 0;
}

.ngheduoc-card__kicker {
	color: var(--wp--preset--color--accent, #0a7a6f);
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
	font-weight: 600;
}

.ngheduoc-card__title {
	font-size: var(--wp--preset--font-size--medium, 1.0625rem);
	line-height: 1.35;
}

.ngheduoc-card__title a {
	color: var(--wp--preset--color--primary, #075985);
	text-decoration: none;
}

.ngheduoc-card__title a:hover {
	text-decoration: underline;
}

.ngheduoc-card__date {
	color: var(--wp--preset--color--muted, #5b6b74);
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
}

@media (min-width: 782px) {
	.ngheduoc-cards--lead {
		grid-template-columns: 1fr;
	}

	.ngheduoc-cards--lead .ngheduoc-card {
		align-items: center;
		display: grid;
		gap: 0.375rem 1.5rem;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	}

	.ngheduoc-cards--lead .ngheduoc-card__image {
		grid-row: span 3;
	}

	.ngheduoc-cards--lead .ngheduoc-card__title {
		font-size: var(--wp--preset--font-size--x-large, 1.875rem);
	}
}

/* Community CTA */
.ngheduoc-cta {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: var(--wp--custom--radius--card, 10px);
	padding: 1.5rem;
}

.ngheduoc-cta__heading {
	font-size: var(--wp--preset--font-size--large, 1.375rem);
	margin: 0 0 0.5rem;
}

.ngheduoc-cta__text {
	margin: 0 0 1rem;
}

.ngheduoc-cta__action {
	margin: 0;
}

.ngheduoc-cta__button {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	text-decoration: none;
}

/* Topic chips */
.ngheduoc-topic-chips ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.ngheduoc-topic-chips a {
	align-items: center;
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: 999px;
	display: inline-flex;
	gap: 0.375rem;
	min-height: 44px;
	padding: 0 1rem;
	text-decoration: none;
}

.ngheduoc-topic-chips__count {
	color: var(--wp--preset--color--muted, #5b6b74);
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
}


/* Trust links: DEC-10 muted token fallback (#5b6b74) and 44px touch targets (NFR-3) */
.ngheduoc-trust-links {
	align-items: center;
	color: var(--wp--preset--color--muted, #5b6b74);
	display: flex;
	flex-wrap: wrap;
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	gap: 0.5rem 1rem;
	margin: 0;
}

.ngheduoc-trust-links a {
	align-items: center;
	color: var(--wp--preset--color--muted, #5b6b74);
	display: inline-flex;
	min-height: 2.25rem;
	text-decoration: underline;
}

.ngheduoc-trust-links a:hover {
	color: var(--wp--preset--color--primary, #075985);
}

@media (pointer: coarse) {
	.ngheduoc-trust-links a {
		min-height: 44px;
	}
}

/*
 * Data Tables (NFR-2, NFR-3, DEC-10): Responsive horizontal scrolling and typography
 * for multi-column medical dosage and legal compliance tables.
 */
.wp-block-table {
	background:
		linear-gradient(to right, var(--wp--preset--color--base, #fff) 30%, rgba(255, 255, 255, 0)),
		linear-gradient(to right, rgba(255, 255, 255, 0), var(--wp--preset--color--base, #fff) 70%) 0 100%,
		radial-gradient(farthest-side at 100% 50%, rgba(22, 49, 61, 0.16), rgba(0, 0, 0, 0)) 100% 50%;
	background-attachment: local, local, scroll;
	background-repeat: no-repeat;
	background-size: 40px 100%, 40px 100%, 16px 100%;
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	border-radius: var(--wp--custom--radius--card, 10px);
	box-sizing: border-box;
	margin-block: var(--wp--preset--spacing--40, 1.5rem);
	max-width: 100%;
	min-width: 0;
	overflow-x: auto;
	position: relative;
	scrollbar-color: var(--wp--preset--color--border, #d5e1e3) var(--wp--preset--color--surface, #f2f7f7);
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}

.wp-block-table::-webkit-scrollbar {
	height: 6px;
}

.wp-block-table::-webkit-scrollbar-track {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border-radius: 3px;
}

.wp-block-table::-webkit-scrollbar-thumb {
	background: var(--wp--preset--color--border, #d5e1e3);
	border-radius: 3px;
}

.wp-block-table::-webkit-scrollbar-thumb:hover {
	background: var(--wp--preset--color--muted, #5b6b74);
}

.wp-block-table table {
	border-collapse: collapse;
	color: var(--wp--preset--color--contrast, #16313d);
	font-family: var(--wp--preset--font-family--ui, "Be Vietnam Pro", sans-serif);
	font-size: var(--wp--preset--font-size--small, 0.9375rem);
	line-height: 1.5;
	margin: 0;
	min-width: 32rem; /* 512px: Prevents multi-column clinical/dosage tables from crushing on mobile */
	width: 100%;
}

.wp-block-table thead th {
	background: var(--wp--preset--color--surface, #f2f7f7);
	border-bottom: 2px solid var(--wp--preset--color--border, #d5e1e3);
	color: var(--wp--preset--color--primary, #075985);
	font-weight: 700;
	letter-spacing: 0.02em;
	padding: 0.75rem 1rem;
	text-align: left;
}

.wp-block-table td,
.wp-block-table th {
	border: 1px solid var(--wp--preset--color--border, #d5e1e3);
	color: var(--wp--preset--color--contrast, #16313d);
	padding: 0.625rem 1rem;
	vertical-align: top;
}

.wp-block-table.is-style-stripes tbody tr:nth-child(odd),
.wp-block-table.is-style-stripes tbody tr:nth-child(2n+1) {
	background: var(--wp--preset--color--surface, #f2f7f7);
}

.wp-block-table figcaption {
	color: var(--wp--preset--color--muted, #5b6b74);
	font-size: var(--wp--preset--font-size--x-small, 0.8125rem);
	margin-top: 0.5rem;
	padding: 0 0.5rem;
	text-align: left;
}

