/**
 * HealthSource Core blocks: map, hours today, reading time, table of contents.
 * Loaded only where one of these blocks renders. Every selector is wrapped in :where() (zero specificity),
 * so the theme restyles anything with a plain class selector. Colours come from the theme palette with
 * the HealthSource values as fallbacks.
 */
:where(.hsc-map, .hsc-hours-today, .hsc-read-time, .hsc-toc) {
	--hsc-red: var(--wp--preset--color--primary, #eb0045);
	--hsc-on-red: var(--wp--preset--color--on-primary, #fff);
	--hsc-navy: var(--wp--preset--color--secondary, #294065);
	--hsc-navy-deep: var(--hs-navy-deep, #172640);
	--hsc-ink: var(--wp--preset--color--contrast, #14243a);
	--hsc-muted: var(--wp--preset--color--muted, #5b6b82);
	--hsc-surface: var(--wp--preset--color--surface, #eef2f8);
	--hsc-border: var(--wp--preset--color--border, #dce3ee);
	--hsc-base: var(--wp--preset--color--base, #fff);
	--hsc-radius: var(--hs-radius-md, 16px);
	--hsc-shadow: var(--hs-shadow-md, 0 12px 32px rgba(20, 36, 58, 0.12));
}

:where(.hsc-icon) {
	flex: none;
	vertical-align: middle;
}

/* ---------------------------------------------------------------- map */
:where(.hsc-map) {
	position: relative;
}

:where(.hsc-map__frame) {
	position: relative;
	display: flex;
	overflow: hidden;
	border-radius: var(--hsc-radius);
	background:
		radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08) 0 2px, transparent 3px) 0 0 / 28px 28px,
		linear-gradient(135deg, var(--hsc-navy) 0%, var(--hsc-navy-deep) 100%);
	box-shadow: var(--hsc-shadow);
	color: #fff;
}

:where(.hsc-map__facade) {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	padding: 2rem 1.25rem;
	text-align: center;
}

:where(.hsc-map__facade) :where(.hsc-icon--pin) {
	width: 48px;
	height: 48px;
	padding: 10px;
	border-radius: 50%;
	background: var(--hsc-red);
	color: var(--hsc-on-red);
	box-shadow: 0 0 0 8px rgba(235, 0, 69, 0.18);
}

:where(.hsc-map__address) {
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.5;
}

:where(.hsc-map__load) {
	cursor: pointer;
	border: 0;
	border-radius: 999px;
	padding: 0.8rem 1.6rem;
	background: var(--hsc-red);
	color: var(--hsc-on-red);
	font-weight: 700;
}

:where(.hsc-map__load):where(:hover, :focus-visible) {
	background: var(--hs-red-dark, #c4003a);
}

:where(.hsc-map__load):focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

:where(.hsc-map__note) {
	max-width: 34ch;
	margin: 0;
	font-size: 0.85rem;
	opacity: 0.85;
}

:where(.hsc-map__note, .hsc-map__address) :where(a) {
	color: inherit;
}

:where(.hsc-map__iframe) {
	display: block;
	width: 100%;
	min-height: inherit;
	border: 0;
}

:where(.hsc-map__links) {
	margin: 0.75rem 0 0;
}

:where(.hsc-map__directions) {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-weight: 700;
}

/* ---------------------------------------------------------------- hours today */
:where(.hsc-hours-today__line) {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 600;
}

:where(.hsc-hours-today__line)::before {
	content: "";
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 50%;
	background: #1f9d55;
	box-shadow: 0 0 0 4px rgba(31, 157, 85, 0.18);
	flex: none;
}

:where(.hsc-hours-today__line.is-closed)::before {
	background: var(--hsc-muted);
	box-shadow: 0 0 0 4px rgba(91, 107, 130, 0.18);
}

/* With the clock icon, the icon carries the open/closed colour instead of the dot. */
:where(.hsc-hours-today__line:has(.hsc-icon))::before {
	display: none;
}

:where(.hsc-hours-today__line) :where(.hsc-icon) {
	color: #1f9d55;
}

:where(.hsc-hours-today__line.is-closed) :where(.hsc-icon) {
	color: var(--hsc-muted);
}

:where(.hsc-hours-today--week) {
	display: grid;
	gap: 0.75rem;
}

:where(.hsc-hours-today__status) {
	margin: 0;
}

:where(.hsc-hours-week) {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}

:where(.hsc-hours-week) :where(th, td) {
	padding: 0.55rem 0.75rem;
	border-bottom: 1px solid var(--hsc-border);
	text-align: left;
	font-weight: 400;
}

:where(.hsc-hours-week) :where(th) {
	font-weight: 600;
	white-space: nowrap;
}

:where(.hsc-hours-week) :where(tr.is-today) :where(th, td) {
	background: var(--hsc-surface);
	color: var(--hsc-navy);
	font-weight: 700;
}

:where(.hsc-hours-week) :where(tr.is-today) :where(th) {
	box-shadow: inset 4px 0 0 var(--hsc-red);
}

:where(.hsc-hours-week__note) {
	margin: 0;
	font-size: 0.9rem;
	color: var(--hsc-muted);
}

/* ---------------------------------------------------------------- reading time */
:where(.hsc-read-time) {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0;
	font-size: 0.9rem;
	font-weight: 600;
}

:where(.hsc-read-time) :where(.hsc-icon) {
	width: 1.1em;
	height: 1.1em;
}

/* ---------------------------------------------------------------- table of contents */
:where(.hsc-toc) {
	padding: 1.25rem 1.25rem 1rem;
	border: 1px solid var(--hsc-border);
	border-radius: var(--hsc-radius);
	background: var(--hsc-base);
	box-shadow: var(--hs-shadow-sm, 0 4px 14px rgba(20, 36, 58, 0.08));
}

:where(.hsc-toc__title) {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 0.75rem;
	font-weight: 800;
	font-size: 0.8rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--hsc-navy);
}

:where(.hsc-toc__title) :where(.hsc-icon) {
	color: var(--hsc-red);
}

:where(.hsc-toc__list) {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: hsc-toc;
}

:where(.hsc-toc__list) :where(li) {
	counter-increment: hsc-toc;
	border-top: 1px solid var(--hsc-border);
}

:where(.hsc-toc__list) :where(a) {
	display: flex;
	gap: 0.6rem;
	padding: 0.55rem 0;
	color: var(--hsc-ink);
	text-decoration: none;
	line-height: 1.35;
}

:where(.hsc-toc__list) :where(a)::before {
	content: counter(hsc-toc, decimal-leading-zero);
	flex: none;
	min-width: 1.6rem;
	font-weight: 800;
	color: var(--hsc-red);
}

:where(.hsc-toc__list) :where(a):where(:hover, :focus-visible) {
	color: var(--hsc-navy);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* Anchored headings clear a sticky header when jumped to. */
:where(.wp-block-post-content) :where(h2[id]) {
	scroll-margin-top: calc(var(--hs-header-h, 80px) + 1.5rem);
}

@media (prefers-reduced-motion: no-preference) {
	:where(.hsc-map__load) {
		transition: background-color 0.2s ease, transform 0.2s ease;
	}

	:where(.hsc-map__load):hover {
		transform: translateY(-1px);
	}
}
