/*
 * Barrierefreiheit / Accessibility UI
 *
 * Tokens (from theme _CONVENTIONS.md):
 *   --ink:    #17171c
 *   --accent: #33d4d6
 *   --paper:  #fff
 *
 * Sections:
 *  1. CSS custom properties
 *  2. Trigger button (fixed bottom-right)
 *  3. Panel (slide-in, brutalist, dark surface)
 *  4. Panel internals — header, grid, cards, toggles, shortcuts
 *  5. Effect classes applied to :root / html
 */

/* ------------------------------------------------------------------ */
/* 1. Custom properties                                                 */
/* ------------------------------------------------------------------ */
:root {
	--a11y-ink:    #17171c;
	--a11y-accent: #33d4d6;
	--a11y-paper:  #ffffff;
	--a11y-dark:   #1f1f24;
	--a11y-dark-2: #2e2e33;
	--a11y-border: #333338;
	--a11y-muted:  #808085;
	--a11y-light:  #c7c7cc;
}

/* ------------------------------------------------------------------ */
/* 2. Trigger button                                                    */
/* ------------------------------------------------------------------ */
.a11y-trigger {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 9998;

	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;

	background: var( --a11y-ink );
	color: #ffffff;
	border: 3px solid var( --a11y-ink );

	font-family: Inter, sans-serif;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	line-height: 1;
	white-space: nowrap;

	cursor: pointer;
	border-radius: 0; /* brutalist: square */
	transition: background 0.15s, color 0.15s;
}

.a11y-trigger:hover,
.a11y-trigger:focus-visible {
	background: var( --a11y-accent );
	color: var( --a11y-ink );
	border-color: var( --a11y-ink );
	outline: none;
}

.a11y-trigger:focus-visible {
	outline: 3px solid var( --a11y-accent );
	outline-offset: 2px;
}

.a11y-trigger__icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
}

/* ------------------------------------------------------------------ */
/* 3. Panel — fixed overlay, slides up from bottom-right               */
/* ------------------------------------------------------------------ */
.a11y-panel {
	position: fixed;
	bottom: 80px;
	right: 24px;
	z-index: 9999;

	width: min( 760px, calc( 100vw - 48px ) );
	max-height: calc( 100vh - 120px );
	overflow-y: auto;
	overflow-x: hidden;

	background: var( --a11y-ink );
	border: 3px solid var( --a11y-ink );

	font-family: Inter, sans-serif;
	color: #ffffff;

	/* Slide-in animation */
	transform: translateY( 12px );
	opacity: 0;
	transition: transform 0.2s ease, opacity 0.2s ease;
	pointer-events: none;
	border-radius: 0;
}

/* Shown state — JS removes [hidden] */
.a11y-panel:not( [hidden] ) {
	transform: translateY( 0 );
	opacity: 1;
	pointer-events: auto;
}

/* Inline variant (page-barrierefreiheit) — not fixed */
.a11y-panel--inline {
	position: static;
	bottom: auto;
	right: auto;
	width: 100%;
	max-height: none;
	transform: none;
	opacity: 1;
	pointer-events: auto;
}

.a11y-panel__inner {
	padding: 36px 32px 32px;
	display: flex;
	flex-direction: column;
	gap: 28px;
}

/* ------------------------------------------------------------------ */
/* 4. Panel internals                                                   */
/* ------------------------------------------------------------------ */

/* Header row */
.a11y-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.a11y-panel__title-row {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

.a11y-panel__title {
	font-size: 22px;
	font-weight: 900;
	letter-spacing: 2px;
	text-transform: uppercase;
	color: #ffffff;
	line-height: 1;
}

.a11y-panel__deco {
	font-size: 13px;
	font-weight: 700;
	color: rgba( 51, 212, 214, 0.5 );
	letter-spacing: 2px;
}

.a11y-panel__close {
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	background: transparent;
	border: 2px solid var( --a11y-border );
	color: var( --a11y-light );
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 0;
	transition: border-color 0.15s, color 0.15s;
}

.a11y-panel__close:hover,
.a11y-panel__close:focus-visible {
	border-color: var( --a11y-accent );
	color: var( --a11y-accent );
	outline: none;
}

/* Controls grid */
.a11y-panel__grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 280px, 1fr ) );
	gap: 0;
	border: 2px solid var( --a11y-border );
}

/* Individual control card */
.a11y-card {
	background: var( --a11y-dark );
	border: 2px solid var( --a11y-border );
	padding: 24px 28px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.a11y-card--reset {
	border-top: 2px solid var( --a11y-border );
}

.a11y-card__heading-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.a11y-card__dot {
	display: inline-block;
	width: 10px;
	height: 10px;
	background: var( --a11y-accent );
	border-radius: 50%;
	flex-shrink: 0;
}

.a11y-card__dot--muted {
	background: var( --a11y-muted );
}

.a11y-card__heading {
	font-size: 14px;
	font-weight: 800;
	letter-spacing: 1px;
	text-transform: uppercase;
	color: var( --a11y-accent );
	line-height: 1;
	white-space: nowrap;
}

.a11y-card__desc {
	font-size: 13px;
	font-weight: 400;
	color: var( --a11y-light );
	line-height: 1.55;
	margin: 0;
}

/* Toggle button */
.a11y-toggle {
	display: inline-flex;
	align-items: center;
	padding: 10px 18px;
	background: var( --a11y-dark-2 );
	border: 2px solid #404047;
	color: var( --a11y-muted );
	font-family: Inter, sans-serif;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	cursor: pointer;
	border-radius: 0;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
	position: relative;
}

.a11y-toggle__label-on {
	display: none;
}

.a11y-toggle[aria-pressed="true"] {
	background: var( --a11y-accent );
	border-color: var( --a11y-border );
	color: var( --a11y-ink );
}

.a11y-toggle[aria-pressed="true"] .a11y-toggle__label-off {
	display: none;
}

.a11y-toggle[aria-pressed="true"] .a11y-toggle__label-on {
	display: inline;
}

.a11y-toggle:hover,
.a11y-toggle:focus-visible {
	border-color: var( --a11y-accent );
	outline: none;
}

/* Reset button */
.a11y-reset {
	display: inline-flex;
	align-items: center;
	padding: 10px 18px;
	background: transparent;
	border: 2px solid var( --a11y-border );
	color: var( --a11y-muted );
	font-family: Inter, sans-serif;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	cursor: pointer;
	border-radius: 0;
	transition: border-color 0.15s, color 0.15s;
}

.a11y-reset:hover,
.a11y-reset:focus-visible {
	border-color: #ef4444;
	color: #ef4444;
	outline: none;
}

/* Keyboard shortcuts legend */
.a11y-panel__shortcuts {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 20px;
	padding-top: 8px;
}

.a11y-shortcuts__label {
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 2px;
	text-transform: uppercase;
	color: #ffffff;
}

.a11y-shortcuts__item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 1px;
	text-transform: uppercase;
	color: var( --a11y-light );
}

.a11y-shortcuts__item kbd {
	background: var( --a11y-dark-2 );
	border: 1px solid #4d4d52;
	padding: 3px 7px;
	font-family: Inter, monospace;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 1px;
	color: #d9d9e0;
	border-radius: 0;
}

/* ------------------------------------------------------------------ */
/* 5. Effect classes — robust overrides applied to <html>              */
/* ------------------------------------------------------------------ */

/* --- a. Large text (~125% base font size) --- */
html.a11y-large-text {
	font-size: 120% !important;
}

html.a11y-large-text body,
html.a11y-large-text p,
html.a11y-large-text li,
html.a11y-large-text span,
html.a11y-large-text div,
html.a11y-large-text td,
html.a11y-large-text th {
	font-size: max( 1em, 1rem ) !important;
}

/* --- b. High contrast --- */
html.a11y-contrast,
html.a11y-contrast body {
	background: #ffffff !important;
	color: #0a0a0a !important;
}

html.a11y-contrast *:not( .a11y-trigger ):not( .a11y-panel ):not( .a11y-panel * ) {
	background-color: #ffffff !important;
	color: #0a0a0a !important;
	border-color: #0a0a0a !important;
}

html.a11y-contrast a:not( .a11y-panel a ) {
	color: #00008b !important;
	text-decoration: underline !important;
}

html.a11y-contrast img,
html.a11y-contrast video {
	filter: contrast( 1.2 ) !important;
}

/* Preserve the trigger and panel appearance in high-contrast mode */
html.a11y-contrast .a11y-trigger {
	background: var( --a11y-ink ) !important;
	color: #ffffff !important;
	border-color: var( --a11y-ink ) !important;
}

html.a11y-contrast .a11y-panel,
html.a11y-contrast .a11y-card {
	background: var( --a11y-dark ) !important;
	color: #ffffff !important;
	border-color: var( --a11y-border ) !important;
}

html.a11y-contrast .a11y-card__desc,
html.a11y-contrast .a11y-card__heading,
html.a11y-contrast .a11y-panel__title,
html.a11y-contrast .a11y-shortcuts__label,
html.a11y-contrast .a11y-shortcuts__item {
	color: inherit !important;
}

/* --- c. Underline links --- */
html.a11y-underline a,
html.a11y-underline a:visited {
	text-decoration: underline !important;
	text-underline-offset: 2px !important;
}

/* --- d. Reduce motion --- */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
	animation-duration: 0.001ms !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0.001ms !important;
	scroll-behavior: auto !important;
}

/* Keep panel open/close working in reduce-motion */
html.a11y-reduce-motion .a11y-panel {
	transition: none !important;
}

/* --- e. Increased spacing --- */
html.a11y-spacing body,
html.a11y-spacing p,
html.a11y-spacing li,
html.a11y-spacing span,
html.a11y-spacing div,
html.a11y-spacing td,
html.a11y-spacing th {
	line-height: 1.85 !important;
	letter-spacing: 0.03em !important;
	word-spacing: 0.1em !important;
}

html.a11y-spacing p,
html.a11y-spacing li {
	margin-bottom: 1em !important;
}

/* ------------------------------------------------------------------ */
/* 6. Scrollbar styling for the panel                                  */
/* ------------------------------------------------------------------ */
.a11y-panel::-webkit-scrollbar {
	width: 6px;
}

.a11y-panel::-webkit-scrollbar-track {
	background: var( --a11y-dark );
}

.a11y-panel::-webkit-scrollbar-thumb {
	background: var( --a11y-border );
}

/* ------------------------------------------------------------------ */
/* 7. Responsive                                                        */
/* ------------------------------------------------------------------ */
@media ( max-width: 600px ) {
	.a11y-trigger {
		bottom: 16px;
		right: 16px;
		padding: 10px 12px;
	}

	.a11y-panel {
		bottom: 68px;
		right: 16px;
		width: calc( 100vw - 32px );
	}

	.a11y-panel__inner {
		padding: 24px 20px 20px;
	}

	.a11y-panel__grid {
		grid-template-columns: 1fr;
	}

	.a11y-panel__shortcuts {
		display: none; /* hide on small screens to save space */
	}
}
