/* Reading & accessibility toolbar — elderly-first, opt-in.
   Launcher sits bottom-left (WhatsApp float owns bottom-right).
   Text-size and contrast classes are set on <html> early (no FOUC) and are
   scoped to reading containers so site chrome is never disturbed.
   The theme paints every <button> with the accent red, so the toolbar's own
   controls reset appearance and pin their fills with !important. */

.hong-a11y {
	--a11y-ink: oklch(22% 0.012 74);
	--a11y-paper: oklch(99% 0.006 82);
	--a11y-line: oklch(88% 0.02 78);
	--a11y-accent: oklch(46% 0.12 152);
	--a11y-accent-soft: oklch(95% 0.03 152);
	--a11y-accent-ink: oklch(30% 0.09 152);
	--a11y-muted: oklch(38% 0.014 74);
	position: fixed;
	left: clamp(12px, 2vw, 24px);
	bottom: clamp(12px, 2vw, 24px);
	z-index: 9990;
	font-family: var(--hong-sans, "Archivo", system-ui, sans-serif);
}

.hong-a11y *,
.hong-a11y *::before {
	box-sizing: border-box;
}

.hong-a11y button {
	appearance: none;
	-webkit-appearance: none;
	font-family: inherit;
	margin: 0;
}

/* Launcher */
.hong-a11y__toggle {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 56px;
	padding: 0 20px 0 16px;
	border: 2px solid var(--a11y-ink) !important;
	border-radius: 999px;
	background: var(--a11y-ink) !important;
	color: var(--a11y-paper) !important;
	font-size: 16px;
	font-weight: 800;
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: 0 10px 26px -14px oklch(22% 0.02 74 / 0.55);
	transition: transform 160ms ease, background-color 160ms ease;
}

.hong-a11y__toggle:hover,
.hong-a11y__toggle:focus-visible,
.hong-a11y[data-open="true"] .hong-a11y__toggle {
	transform: translateY(-2px);
	background: var(--a11y-accent) !important;
	border-color: var(--a11y-accent) !important;
	color: var(--a11y-paper) !important;
	outline: none;
}

.hong-a11y__toggle svg {
	width: 26px;
	height: 26px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.1;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.hong-a11y__toggle-label {
	white-space: nowrap;
}

/* Panel */
.hong-a11y__panel {
	position: absolute;
	left: 0;
	bottom: calc(100% + 12px);
	width: min(320px, calc(100vw - 24px));
	padding: 20px;
	border: 1px solid var(--a11y-line);
	border-radius: 18px;
	background: var(--a11y-paper);
	color: var(--a11y-ink);
	box-shadow: 0 22px 50px -26px oklch(22% 0.02 74 / 0.6);
	display: none;
}

.hong-a11y[data-open="true"] .hong-a11y__panel {
	display: block;
}

.hong-a11y__title {
	margin: 0 0 4px;
	font-size: 13px;
	font-weight: 800;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--a11y-accent);
	font-family: "JetBrains Mono", ui-monospace, monospace;
}

.hong-a11y__row {
	padding: 16px 0;
	border-bottom: 1px solid var(--a11y-line);
}

.hong-a11y__row:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.hong-a11y__row-label {
	display: block;
	margin-bottom: 10px;
	font-size: 15px;
	font-weight: 700;
	color: var(--a11y-ink);
}

/* Text-size segmented control */
.hong-a11y__sizes {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

.hong-a11y__size {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 52px;
	border: 2px solid var(--a11y-line) !important;
	border-radius: 12px;
	background: var(--a11y-paper) !important;
	color: var(--a11y-ink) !important;
	font-weight: 800;
	line-height: 1;
	cursor: pointer;
	transition: border-color 140ms ease, background-color 140ms ease;
}

.hong-a11y__size:nth-child(1) { font-size: 16px; }
.hong-a11y__size:nth-child(2) { font-size: 20px; }
.hong-a11y__size:nth-child(3) { font-size: 25px; }

.hong-a11y__size:hover,
.hong-a11y__size:focus-visible {
	border-color: var(--a11y-accent) !important;
	outline: none;
}

.hong-a11y__size[aria-pressed="true"] {
	border-color: var(--a11y-accent) !important;
	background: var(--a11y-accent-soft) !important;
	color: var(--a11y-accent-ink) !important;
}

/* Full-width toggle-style buttons (contrast + listen) */
.hong-a11y__btn {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 54px;
	padding: 0 16px;
	border: 2px solid var(--a11y-line) !important;
	border-radius: 12px;
	background: var(--a11y-paper) !important;
	color: var(--a11y-ink) !important;
	font-size: 16px;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
	transition: border-color 140ms ease, background-color 140ms ease;
}

.hong-a11y__btn:hover,
.hong-a11y__btn:focus-visible {
	border-color: var(--a11y-accent) !important;
	outline: none;
}

.hong-a11y__btn svg {
	width: 24px;
	height: 24px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.hong-a11y__btn-text {
	flex: 1;
}

.hong-a11y__btn-state {
	font-size: 13px;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--a11y-muted);
	font-family: "JetBrains Mono", ui-monospace, monospace;
}

.hong-a11y__btn[aria-pressed="true"] {
	border-color: var(--a11y-accent) !important;
	background: var(--a11y-accent-soft) !important;
	color: var(--a11y-accent-ink) !important;
}

.hong-a11y__btn[aria-pressed="true"] .hong-a11y__btn-state {
	color: var(--a11y-accent);
}

.hong-a11y__reset {
	margin-top: 14px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: none !important;
	border: 0 !important;
	padding: 4px 0;
	color: var(--a11y-muted) !important;
	font-size: 14px;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.hong-a11y__reset:hover,
.hong-a11y__reset:focus-visible {
	color: var(--a11y-accent) !important;
	outline: none;
}

/* ---- Applied reading modes ----
   Text size uses zoom on the article body so every element scales
   proportionally and nothing ever shrinks. Only one container zooms per page
   (v5-doc when present, otherwise entry-content); hub and tool pages are
   skipped so their near-full-width layouts never overflow horizontally. */
html.hong-a11y-t2 :is(.v5-doc, .entry-content:not(:has(.v5-doc)):not(:has(.hong-nav-hub)):not(:has(.hong-patient-tools))) {
	zoom: 1.12;
}

html.hong-a11y-t3 :is(.v5-doc, .entry-content:not(:has(.v5-doc)):not(:has(.hong-nav-hub)):not(:has(.hong-patient-tools))) {
	zoom: 1.25;
}

html.hong-a11y-contrast :is(.v5-doc, .entry-content, article) :is(p, li, dd, dt, blockquote, summary) {
	color: oklch(18% 0.012 74) !important;
}

html.hong-a11y-contrast :is(.v5-doc, .entry-content, article) :is(figcaption, small, time, .v5-meta) {
	color: oklch(32% 0.012 74) !important;
}

html.hong-a11y-contrast :is(.v5-doc, .entry-content, article) a:not([class*="cta"]):not([class*="button"]):not([class*="btn"]) {
	text-decoration: underline !important;
	text-underline-offset: 3px;
	text-decoration-thickness: 2px;
}

/* Currently-spoken paragraph highlight */
.hong-a11y-speaking {
	background: oklch(95% 0.05 152) !important;
	box-shadow: -6px 0 0 0 oklch(46% 0.12 152) !important;
	border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.hong-a11y__toggle,
	.hong-a11y__size,
	.hong-a11y__btn { transition: none; }
}

@media (max-width: 600px) {
	.hong-a11y__toggle-label { display: none; }
	.hong-a11y__toggle { padding: 0 15px; }
}

/* ---- Rail variant: docked into the V5 right sidebar ----------------------
   On V5 articles the controls render as the first card of
   <aside class="v5-aside"> (reading-toolbar.php) and the floating launcher is
   not emitted. The card follows the Swiss aside idiom (v5-layout.css author/
   trust cards): square, hairline border, surface-2 fill, mono kicker. The
   --v5-* tokens inherit from the enclosing .v5-article scope; fallbacks
   mirror v5-blocks.css. */
.hong-a11y--rail {
	position: static;
	left: auto;
	bottom: auto;
	z-index: auto;
}

.hong-a11y--rail .hong-a11y__panel {
	position: static;
	display: block;
	width: auto;
	padding: 20px 18px;
	border: 1px solid var(--v5-line, oklch(86.5% 0.005 95));
	border-radius: 0;
	background: var(--v5-surface-2, oklch(97% 0.004 95));
	box-shadow: none;
}

/* Title reads as a v5 aside kicker, not app-chrome. */
.hong-a11y--rail .hong-a11y__title {
	margin: 0;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.14em;
	color: var(--v5-text-2, oklch(51.5% 0.006 95));
}

/* Square controls; slightly tighter targets for the 280px column (≥44px). */
.hong-a11y--rail .hong-a11y__size,
.hong-a11y--rail .hong-a11y__btn { border-radius: 2px; }
.hong-a11y--rail .hong-a11y__size { min-height: 46px; }
.hong-a11y--rail .hong-a11y__btn { min-height: 48px; padding: 0 13px; gap: 10px; font-size: 15px; }
.hong-a11y--rail .hong-a11y__row { padding: 13px 0; }
.hong-a11y--rail .hong-a11y__row-label { font-size: 14px; margin-bottom: 8px; }

/* [hidden] must always hide: the module's own display rules (__reset is
   inline-flex) were silently beating the UA's [hidden]{display:none}. */
.hong-a11y [hidden] { display: none !important; }

/* The rail card sits inside .entry-content, where swiss-modern.css paints
   every <button> as a green-glow uppercase-mono CTA pill ((0,1,1) + later
   load beats the module's element-level `inherit`). Re-pin the properties
   the base module left to inheritance. The floating widget keeps its own
   look — these pins are rail-scoped. */
.hong-a11y--rail button {
	font-family: var(--hong-sans, "Archivo", system-ui, sans-serif) !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	box-shadow: none !important;
	max-width: none !important;
	white-space: normal !important;
}
.hong-a11y--rail .hong-a11y__reset { padding: 4px 0 !important; min-height: 0 !important; }
