/*
 * Accessibility Header Bar styles.
 *
 * These fall back to your theme's global-styles color palette
 * (set via the Site Editor / theme.json) automatically. Override any
 * of the variables below in your theme's stylesheet to restyle without
 * touching this plugin.
 */
:root {
	--ah-bg: var( --wp--preset--color--contrast, #1a1a1a );
	--ah-color: var( --wp--preset--color--base, #ffffff );
	--ah-link-hover: var( --wp--preset--color--accent, #99cfff );
	--ah-font-size: 0.8125rem;
}

.ah-bar {
	background: var( --ah-bg );
	color: var( --ah-color );
	font-size: var( --ah-font-size );
	line-height: 1.4;
	position: relative;
	z-index: 100;
}

.ah-container {
	max-width: 1200px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	flex-wrap: wrap;
	gap: 1.5rem;
	padding: 0.4rem 1rem;
}

.ah-secondary-links,
.ah-social-links {
	list-style: none;
	display: flex;
	align-items: center;
	gap: 1rem;
	margin: 0;
	padding: 0;
}

.ah-secondary-links li {
	display: flex;
	align-items: center;
}

/* Shortcode/HTML items (e.g. a Fire Danger pill) often bring their own
   styling — this just keeps them vertically centered in the bar. */
.ah-item-shortcode,
.ah-item-html {
	line-height: 1;
}

.ah-secondary-links a,
.ah-social-links a {
	color: var( --ah-color );
	text-decoration: none;
}

.ah-secondary-links a:hover,
.ah-secondary-links a:focus,
.ah-social-links a:hover,
.ah-social-links a:focus {
	color: var( --ah-link-hover );
	text-decoration: underline;
}

.ah-social-link .dashicons {
	width: 18px;
	height: 18px;
	font-size: 18px;
}

.ah-divider {
	width: 1px;
	height: 1.25rem;
	background: currentColor;
	opacity: 0.35;
	flex-shrink: 0;
}

/* Accessibility dropdown */
.ah-accessibility-nav {
	position: relative;
}

.ah-toggle {
	display: flex;
	align-items: center;
	background: transparent;
	border: 1px solid currentColor;
	color: inherit;
	font-size: inherit;
	border-radius: 4px;
	padding: 0.35rem;
	cursor: pointer;
}

/* Icon-only button: keep the label in the accessibility tree (screen
   readers still announce it) but hide it visually. */
.ah-toggle-label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

.ah-toggle:hover,
.ah-toggle:focus {
	background: rgba( 255, 255, 255, 0.15 );
}

.ah-menu {
	position: absolute;
	right: 0;
	top: 100%;
	margin-top: 0.35rem;
	width: max-content;
	background: #ffffff;
	color: #1a1a1a;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	box-shadow: 0 6px 16px rgba( 0, 0, 0, 0.18 );
	list-style: none;
	padding: 0.35rem 0;
	z-index: 9999;
}

.ah-menu[hidden] {
	display: none;
}

.ah-menu li {
	padding: 0;
}

.ah-menu button,
.ah-menu a {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 100% !important;
	box-sizing: border-box !important;
	margin: 0 !important;
	background: none !important;
	border: none !important;
	color: #1a1a1a !important;
	text-decoration: none !important;
	line-height: 1 !important;
	padding: 0.6rem 0.75rem !important;
	cursor: pointer;
}

/* The dropdown is meant to look identical regardless of theme (unlike
   the bar's own link colors, which follow the theme on purpose) —
   Contact Us is the only <a> among otherwise-<button> rows, so it's the
   only one exposed to global theme link styling (padding, underlines,
   an icon injected via ::before/::after for external links, etc). Strip
   that out explicitly. */
.ah-menu a::before,
.ah-menu a::after {
	content: none !important;
	display: none !important;
}

.ah-menu button:hover,
.ah-menu button:focus,
.ah-menu a:hover,
.ah-menu a:focus {
	background: #f0f0f0 !important;
	text-decoration: none !important;
	box-shadow: none !important;
}

/* Icon badges for menu items (A-/A/A+, O, D) — styled to match rather
   than pulled from an icon font, since these represent plugin-specific
   actions no icon set ships by default. */
.ah-icon-badge {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: 1px solid #b0b0b0;
	font-size: 0.8rem;
	font-weight: 700;
	line-height: 1;
	color: #1a1a1a;
	background: #f5f5f5;
}

/* The cream/black-on-creme scheme toggle gets a cream badge so it reads
   as a small color swatch for that mode. */
.ah-icon-badge-cream {
	background: #fdf6e3;
	border-color: #c9c1a4;
	color: #000000;
}

/* Uploaded icon images (font size decrease/normal/increase, contact) —
   these are self-contained glyphs, so no circular badge framing, just
   sized to match the badge height. */
.ah-icon-img {
	display: block;
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	object-fit: contain;
}

/* The OpenDyslexic badge previews the actual typeface, same trick
   doi.gov uses — the letter itself IS the icon. */
.ah-icon-badge-opendyslexic {
	font-family: 'OpenDyslexic', sans-serif;
	font-weight: 400;
	font-size: 0.85rem;
}

/* --- Accessibility feature effects (toggled via JS) --- */

@font-face {
	font-family: 'OpenDyslexic';
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url( https://cdn.jsdelivr.net/fontsource/fonts/opendyslexic@latest/latin-400-normal.woff2 ) format( 'woff2' );
}

/* Repeating the class (.ah-dyslexic.ah-dyslexic.ah-dyslexic) doesn't
   change what matches — one class on <body> still satisfies it — but it
   multiplies the selector's specificity. That's needed because some
   themes and page builders (Elementor, Divi, block-editor typography
   settings, etc.) apply their own font-family rules with !important on
   fairly specific selectors (e.g. ".entry-content h2"), and when two
   !important rules collide, specificity breaks the tie. A plain
   "body.ah-dyslexic *" can lose that fight; this version is much more
   likely to win it. */
body.ah-dyslexic.ah-dyslexic.ah-dyslexic,
body.ah-dyslexic.ah-dyslexic.ah-dyslexic * {
	font-family: 'OpenDyslexic', sans-serif !important;
}

body.ah-contrast.ah-contrast.ah-contrast,
body.ah-contrast.ah-contrast.ah-contrast * {
	background-color: #fdf6e3 !important;
	color: #000000 !important;
	border-color: #000000 !important;
}

/* doi.gov hides this bar entirely below a certain viewport width rather
   than wrapping it — this is what makes it "disappear" as you zoom the
   browser in (zooming shrinks the effective CSS viewport). 800px covers
   typical desktop widths at 175–200% zoom; adjust to taste. */
@media ( max-width: 800px ) {
	.ah-bar {
		display: none;
	}
}
