/*! accessibility-base.css v1.0.0 | MIT License | [your repo] */
/* WCAG 2.2 Level AA Compliance Layer */

/* Interactive Element Sizing (WCAG 2.5.8)
   ========================================================================== */

/**
 * Target Size Minimum Requirements
 *
 * All interactive elements must have a minimum touch/click target of 24x24 CSS pixels
 * OR have sufficient spacing (24px) between adjacent interactive elements.
 *
 * Exception: Links within paragraphs/blocks of text are exempt (constrained by line-height)
 *
 * Reference: https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html
 */

/* Buttons
 * Standard button elements and input buttons for form submission/actions */

button,
[type="button"],
[type="submit"],
[type="reset"],
[type="image"] {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block; /* Ensures min-width/height apply correctly */
}

/* Image buttons need explicit dimensions since padding may not apply */
[type="image"] {
  min-height: 24px;
  min-width: 24px;
}

/* Form Input Controls
 * Checkboxes, radio buttons, file uploads, color pickers, range sliders */

[type="checkbox"],
[type="radio"] {
  min-height: 24px;
  min-width: 24px;
  /* Remove default padding that could interfere with sizing */
  padding: 0;
}

[type="file"] {
  min-height: 24px;
  /* File inputs need block display for consistent sizing */
  display: inline-block;
}

[type="color"] {
  min-height: 24px;
  min-width: 24px;
  /* Color pickers often have default sizes that are too small */
  padding: 2px;
}

[type="range"] {
  min-height: 24px;
  /* Range sliders need sufficient thumb/track height */
  display: block;
}

/* Select/Dropdown Controls
 * Dropdown menus and custom select elements */

select {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
}

/* Multi-select listboxes */
select[multiple] {
  min-height: 24px;
  min-width: 24px;
  padding: 4px;
}

/* Custom dropdown elements (common ARIA pattern) */
[role="listbox"],
[role="combobox"] {
  min-height: 24px;
  min-width: 24px;
}

/* Dropdown options/items */
[role="option"] {
  min-height: 24px;
  padding: 4px 8px;
  display: block;
}

/* Links (Navigation & Lists)
 * Links in menus, lists, and standalone contexts (excludes inline paragraph links) */

/* Ensure uniform list item sizing whether links are present or not */
ul li,
ol li {
  min-height: 24px;
  padding: 4px 0;
}

/* Definition list terms and definitions */
dl dt,
dl dd {
  min-height: 24px;
  padding: 4px 0;
}

/* Links in lists fill their parent list item */
ul li a,
ol li a {
  display: block;
  padding: 0 8px;
  /* min-height inherited from parent li */
}

/* Links in definition lists */
dl dt a,
dl dd a {
  display: block;
  padding: 0 8px;
}

/* Links in navigation elements */
nav a {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
}

/* ARIA navigation roles */
[role="navigation"] a,
[role="menu"] a,
[role="menubar"] a {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
}

/* Image-based Interactive Elements
 * Image buttons, linked images, image map areas */

/* Linked images (images wrapped in anchor tags) */
a img {
  /* Ensure the link wrapper meets minimum size */
  min-height: 24px;
  min-width: 24px;
}

/* The anchor wrapping an image needs sizing too */
a:has(img) {
  display: inline-block;
  min-height: 24px;
  min-width: 24px;
}

/* Image map areas - create adequate click targets */
area {
  /* Note: Image map areas are defined by coordinates in HTML.
   * Ensure coords attribute creates regions at least 24x24 pixels.
   * This cannot be enforced via CSS alone - requires HTML validation */
}

/* Icon links (common pattern: SVG or icon font in link) */
a svg,
a [class*="icon"] {
  min-height: 24px;
  min-width: 24px;
  display: inline-block;
}

/* Ensure icon-only links have adequate padding */
a:has(svg):not(:has(text)),
a:has([class*="icon"]):not(:has(text)) {
  padding: 4px;
  min-height: 24px;
  min-width: 24px;
  display: inline-block;
}

/* Custom Interactive Controls (ARIA)
 * Script-generated controls with roles: button, link, menuitem, tab, switch, etc. */

/* Button-like roles */
[role="button"] {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
  cursor: pointer;
}

/* Link role */
[role="link"] {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
  cursor: pointer;
}

/* Menu items */
[role="menuitem"],
[role="menuitemcheckbox"],
[role="menuitemradio"] {
  min-height: 24px;
  padding: 4px 8px;
  display: block;
  cursor: pointer;
}

/* Tab controls */
[role="tab"] {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
  cursor: pointer;
}

/* Checkbox and radio roles */
[role="checkbox"],
[role="radio"] {
  min-height: 24px;
  min-width: 24px;
  display: inline-block;
  cursor: pointer;
}

/* Switch/toggle controls */
[role="switch"] {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
  cursor: pointer;
}

/* Generic interactive elements (anything with tabindex that's focusable) */
[tabindex]:not([tabindex="-1"]) {
  min-height: 24px;
  min-width: 24px;
}

/* Media & Modal Controls
 * Video/audio player buttons, close buttons, expand/collapse triggers */

/* Video and audio control buttons */
video::-webkit-media-controls-panel button,
audio::-webkit-media-controls-panel button {
  min-height: 24px;
  min-width: 24px;
}

/* Close buttons (common patterns) */
[aria-label*="close" i],
[aria-label*="dismiss" i],
.close,
.modal-close,
.dialog-close {
  min-height: 24px;
  min-width: 24px;
  padding: 4px;
  display: inline-block;
  cursor: pointer;
}

/* Expand/collapse/accordion triggers */
[aria-expanded],
[aria-controls],
.accordion-trigger,
.collapse-trigger,
.expand-trigger {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
  cursor: pointer;
}

/* Dialog/modal interactive elements */
[role="dialog"] button,
[role="alertdialog"] button {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
}

/* Disclosure widgets */
details summary {
  min-height: 24px;
  padding: 4px 8px;
  cursor: pointer;
}

/* Navigation Controls
 * Pagination, breadcrumbs, tabs, accordion headers, menu toggles */

/* Pagination links and buttons */
[role="navigation"] [aria-label*="page" i],
.pagination a,
.pagination button,
.pager a,
.pager button {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
}

/* Breadcrumb links */
[aria-label*="breadcrumb" i] a,
.breadcrumb a,
.breadcrumbs a {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
}

/* Tab navigation */
[role="tablist"] [role="tab"] {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
}

/* Accordion headers */
[role="heading"] button,
.accordion-header,
.accordion-button {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: block;
  cursor: pointer;
}

/* Menu toggle buttons (hamburger menus, etc.) */
[aria-label*="menu" i][aria-expanded],
.menu-toggle,
.nav-toggle,
.hamburger {
  min-height: 24px;
  min-width: 24px;
  padding: 4px;
  display: inline-block;
  cursor: pointer;
}

/* Skip links */
[href^="#"][class*="skip" i],
.skip-link,
.skip-to-content {
  min-height: 24px;
  min-width: 24px;
  padding: 4px 8px;
  display: inline-block;
}



/* Focus Indicators (WCAG 2.4.7, 2.4.11, 2.4.13)
   ========================================================================== */

/**
 * Focus Visible Requirements
 *
 * SC 2.4.7 (Level AA): All focusable elements must have a visible focus indicator
 * SC 2.4.11 (Level AA): Focused elements must not be completely obscured by other content
 * SC 2.4.13 (Level AAA): Focus indicators must be:
 *   - At least 2 CSS pixels thick
 *   - Have at least 3:1 contrast ratio with unfocused state
 *   - Cover sufficient area around the element
 *
 * Reference: https://www.w3.org/WAI/WCAG22/Understanding/focus-visible.html
 *            https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum.html
 *            https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance.html
 */

/* Default Focus Styles
 * Base visible outline for all interactive elements */

/* Universal focus indicator for all focusable elements */
*:focus {
  outline: 2px solid #0066cc; /* Blue outline, 2px minimum per WCAG 2.4.13 */
  outline-offset: 2px; /* Space between element and outline for clarity */
}

/* Ensure outline is never removed (common bad practice) */
*:focus:not(:focus-visible) {
  /* Allow focus-visible polyfill to work, but maintain baseline */
  outline: 2px solid #0066cc;
}

/* High contrast mode support - ensure focus visible in Windows High Contrast */
@media (prefers-contrast: high) {
  *:focus {
    outline: 3px solid; /* Browser will use system color */
    outline-offset: 2px;
  }
}

/* Prevent focus outline from being cropped by overflow */
*:focus {
  outline-style: solid; /* Solid is most reliably visible */
}

/* Form Control Focus
 * Text inputs, textareas, selects, checkboxes, radio buttons */

/* Text inputs and textareas */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="time"]:focus,
textarea:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Select dropdowns */
select:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Checkboxes and radio buttons */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* File upload inputs */
input[type="file"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Color picker */
input[type="color"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 3px; /* Extra offset for color swatches */
}

/* Range sliders */
input[type="range"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Link Focus
 * Anchor elements in all contexts */

/* All links */
a:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Links in navigation */
nav a:focus,
[role="navigation"] a:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Links in lists */
ul a:focus,
ol a:focus,
dl a:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Inline paragraph links */
p a:focus {
  outline: 2px solid #0066cc;
  outline-offset: 1px; /* Tighter offset for inline text links */
}

/* Links wrapping images */
a:has(img):focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Skip links - extra prominent for accessibility */
a[href^="#"]:focus,
.skip-link:focus {
  outline: 3px solid #0066cc;
  outline-offset: 3px;
  background-color: #ffffff;
  color: #000000;
}

/* Button Focus
 * All button types and input buttons */

/* Standard button elements */
button:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Input buttons */
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Image buttons */
input[type="image"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Disabled buttons - no focus indicator needed (not focusable) */
button:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled {
  outline: none;
}

/* Custom Interactive Control Focus
 * ARIA roles: button, link, tab, menuitem, checkbox, radio, switch */

/* Button-like roles */
[role="button"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Link role */
[role="link"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Tab controls */
[role="tab"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Menu items */
[role="menuitem"]:focus,
[role="menuitemcheckbox"]:focus,
[role="menuitemradio"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Checkbox and radio roles */
[role="checkbox"]:focus,
[role="radio"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Switch/toggle controls */
[role="switch"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Generic focusable elements with tabindex */
[tabindex="0"]:focus,
[tabindex]:not([tabindex="-1"]):focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Accordion/disclosure triggers */
[aria-expanded]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Media and Embedded Content Focus
 * Video, audio, iframes, embeds when focusable */

/* Video elements with controls */
video:focus,
video[controls]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Audio elements with controls */
audio:focus,
audio[controls]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Iframes (when focusable) */
iframe:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Embedded content */
embed:focus,
object:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Details/Summary (native disclosure widget) */
details:focus,
summary:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Dialog elements */
dialog:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Editable Content Focus
 * Elements with contenteditable attribute */

/* Contenteditable elements */
[contenteditable]:focus,
[contenteditable="true"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Contenteditable plaintext-only */
[contenteditable="plaintext-only"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Editable regions in rich text editors */
[role="textbox"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Multi-line editable text */
[role="textbox"][aria-multiline="true"]:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Focus-Visible Polyfill (Modern Approach)
 * Only show focus indicators for keyboard navigation, not mouse clicks */

/**
 * The :focus-visible pseudo-class allows showing focus indicators only when
 * the user is navigating via keyboard, not when clicking with a mouse.
 * This improves aesthetics while maintaining accessibility.
 *
 * Browser support: Chrome 86+, Firefox 85+, Safari 15.4+, Edge 86+
 * For older browsers, the standard :focus styles above will apply.
 */

/* Remove default focus for mouse users, but keep for keyboard users */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Show focus only for keyboard navigation */
*:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Form controls always show focus (override if needed) */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Buttons show focus only on keyboard nav */
button:focus-visible,
[type="button"]:focus-visible,
[type="submit"]:focus-visible,
[type="reset"]:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Links show focus only on keyboard nav */
a:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Custom controls show focus only on keyboard nav */
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[role="tab"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Color Contrast (WCAG 1.4.3, 1.4.11)
   ========================================================================== */

/**
 * Color Contrast Requirements
 *
 * SC 1.4.3 (Level AA) - Contrast (Minimum):
 *   - Normal text: 4.5:1 contrast ratio minimum
 *   - Large text (18pt+/14pt+ bold): 3:1 contrast ratio minimum
 *
 * SC 1.4.11 (Level AA) - Non-text Contrast:
 *   - UI components (buttons, form controls): 3:1 contrast ratio minimum
 *   - Graphical objects (icons, charts): 3:1 contrast ratio minimum
 *   - Focus indicators: 3:1 contrast ratio minimum
 *   - Active/hover states: 3:1 contrast ratio minimum
 *
 * NOTE: This section provides EXAMPLES of compliant color combinations.
 * Actual colors should be customized to match your brand while maintaining
 * minimum contrast ratios. Use a contrast checker tool to validate:
 * https://webaim.org/resources/contrastchecker/
 *
 * Reference: https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html
 *            https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html
 */

/* Text Contrast - Normal Text (4.5:1 minimum)
 * Body text, paragraphs, list items, labels, standard-size headings */

/**
 * Safe default: Black text on white background (21:1 ratio)
 * Customize these CSS variables to match your brand while maintaining 4.5:1 minimum
 */

:root {
  --text-color: #000000;           /* Black - safe on light backgrounds */
  --background-color: #ffffff;     /* White */
  --text-muted: #595959;           /* Dark gray - 7:1 on white */
}

/* Body text */
body {
  color: var(--text-color);
  background-color: var(--background-color);
}

/* Paragraphs and general text */
p,
li,
td,
th,
span {
  color: var(--text-color);
}

/* Labels for form controls */
label {
  color: var(--text-color);
}

/* Muted/secondary text (still meets 4.5:1 on white) */
.text-muted,
small {
  color: var(--text-muted);
}

/* Text Contrast - Large Text (3:1 minimum)
 * Headings 18pt+ (24px+), bold text 14pt+ (18.66px+) */

/**
 * Large text has relaxed contrast requirements (3:1 minimum vs 4.5:1)
 * Large text = 18pt (24px) or larger, OR 14pt (18.66px) bold or larger
 */

:root {
  --heading-color: #333333;        /* Dark gray - 12.6:1 on white (exceeds 3:1) */
  --large-text-color: #4d4d4d;     /* Medium gray - 9:1 on white (exceeds 3:1) */
}

/* Large headings (24px and above) */
h1,
h2 {
  color: var(--heading-color);
  /* Assuming these are 24px+ in your typography */
}

/* Medium headings (can use if 24px+) */
h3 {
  color: var(--heading-color);
}

/* Smaller headings (only if they meet size requirements) */
h4,
h5,
h6 {
  color: var(--heading-color);
}

/* Large body text (18pt/24px or larger) */
.lead,
.text-large {
  font-size: 24px;
  color: var(--large-text-color);
}

/* Bold text at 14pt/18.66px or larger */
strong,
b {
  font-weight: bold;
  /* Inherits color from parent, ensure parent meets 3:1 if 18.66px+ */
}

/* UI Component Contrast - Buttons (3:1 minimum)
 * Button borders, backgrounds, and their contrast with adjacent colors */

/**
 * Non-text contrast requirements (WCAG 1.4.11):
 * - Button border vs. adjacent background: 3:1 minimum
 * - Button background vs. page background: 3:1 minimum
 * - Button text vs. button background: 4.5:1 minimum (text contrast rule)
 */

:root {
  --button-bg: #0066cc;            /* Blue background - 4.6:1 vs white page */
  --button-text: #ffffff;          /* White text - 4.5:1 vs blue bg */
  --button-border: #004999;        /* Darker blue border - 8.6:1 vs white */
  --button-hover-bg: #0052a3;      /* Darker blue hover - 6.3:1 vs white */
  --button-disabled-bg: #cccccc;   /* Light gray - 2.8:1 vs white (disabled exempt) */
  --button-disabled-text: #666666; /* Dark gray - 5.7:1 vs light gray bg */
}

/* Primary buttons */
button,
[type="button"],
[type="submit"],
[type="reset"] {
  background-color: var(--button-bg);
  color: var(--button-text);
  border: 2px solid var(--button-border);
}

/* Button hover state (must maintain 3:1 contrast) */
button:hover,
[type="button"]:hover,
[type="submit"]:hover,
[type="reset"]:hover {
  background-color: var(--button-hover-bg);
  border-color: var(--button-border);
  /* Text color remains white for 4.5:1+ contrast */
}

/* Disabled buttons (contrast requirements relaxed per WCAG) */
button:disabled,
[type="button"]:disabled,
[type="submit"]:disabled,
[type="reset"]:disabled {
  background-color: var(--button-disabled-bg);
  color: var(--button-disabled-text);
  border-color: var(--button-disabled-bg);
  cursor: not-allowed;
}

/* Secondary/outline buttons */
.button-secondary {
  background-color: transparent;
  color: var(--button-bg);
  border: 2px solid var(--button-bg); /* 4.6:1 vs white */
}

.button-secondary:hover {
  background-color: var(--button-bg);
  color: var(--button-text);
}

/* UI Component Contrast - Form Controls (3:1 minimum)
 * Input borders, select borders, textarea borders, checkbox/radio borders */

/**
 * Form control borders must have 3:1 contrast against adjacent background
 * Form control text must have 4.5:1 contrast (covered under text contrast)
 */

:root {
  --input-border: #767676;         /* Medium gray - 4.5:1 vs white */
  --input-border-focus: #0066cc;   /* Blue - 4.6:1 vs white */
  --input-bg: #ffffff;             /* White background */
  --input-text: #000000;           /* Black text - 21:1 vs white bg */
  --input-disabled-bg: #f0f0f0;    /* Light gray background */
  --input-disabled-border: #cccccc; /* Light gray border - 2.8:1 (disabled exempt) */
  --input-disabled-text: #666666;  /* Dark gray - 5.7:1 vs light gray bg */
}

/* Text inputs and textareas */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"],
textarea {
  background-color: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
}

/* Focused inputs (border contrast must be maintained) */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="time"]:focus,
textarea:focus {
  border-color: var(--input-border-focus);
}

/* Select dropdowns */
select {
  background-color: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
}

select:focus {
  border-color: var(--input-border-focus);
}

/* Checkboxes and radio buttons */
input[type="checkbox"],
input[type="radio"] {
  border: 2px solid var(--input-border);
  background-color: var(--input-bg);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  border-color: var(--input-border-focus);
}

/* Checked state (ensure checkmark/dot has sufficient contrast) */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background-color: var(--input-border-focus);
  border-color: var(--input-border-focus);
}

/* Disabled form controls */
input:disabled,
textarea:disabled,
select:disabled {
  background-color: var(--input-disabled-bg);
  color: var(--input-disabled-text);
  border-color: var(--input-disabled-border);
  cursor: not-allowed;
}

/* File upload button portion */
input[type="file"] {
  color: var(--input-text);
}

/* Range sliders */
input[type="range"] {
  /* Track color */
  background-color: var(--input-border);
}

/* Color picker */
input[type="color"] {
  border: 2px solid var(--input-border);
}

/* UI Component Contrast - Links (3:1 or differentiation required)
 * Link text must have 4.5:1 contrast AND be distinguishable from surrounding text */

/**
 * WCAG requires links to be visually distinguishable from surrounding text by EITHER:
 * 1. 3:1 color contrast between link and surrounding text, OR
 * 2. Underline or other non-color indicator
 *
 * Additionally, link text must meet 4.5:1 contrast vs background
 */

:root {
  --link-color: #0066cc;           /* Blue - 4.6:1 vs white bg, 3.1:1 vs black text */
  --link-visited: #551a8b;         /* Purple - 8.3:1 vs white bg */
  --link-hover: #004999;           /* Darker blue - 8.6:1 vs white bg */
  --link-active: #003d7a;          /* Even darker blue - 10.7:1 vs white bg */
}

/* Default link styling - uses underline for differentiation */
a {
  color: var(--link-color);
  text-decoration: underline; /* Ensures differentiation without relying on color alone */
}

/* Visited links */
a:visited {
  color: var(--link-visited);
  text-decoration: underline;
}

/* Hover state */
a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Active state */
a:active {
  color: var(--link-active);
  text-decoration: underline;
}

/* Links in navigation (often styled without underlines) */
nav a,
[role="navigation"] a {
  color: var(--link-color);
  text-decoration: none; /* Can remove underline in nav if sufficient spacing/context */
}

nav a:hover,
[role="navigation"] a:hover {
  color: var(--link-hover);
  text-decoration: underline; /* Add underline on hover for feedback */
}

/* Links on dark backgrounds (inverse colors) */
.dark-bg a {
  color: #66b3ff; /* Light blue - 4.6:1 vs black bg */
  text-decoration: underline;
}

/* Ensure link color has 3:1 contrast with surrounding text */
/* Example: If body text is #000000, link must be different enough */
/* #0066cc (our link color) has 3.1:1 contrast vs #000000 ✓ */

/* Interactive State Contrast (3:1 minimum)
 * Hover states, active states, selected states, disabled states */

/**
 * All interactive states must maintain 3:1 contrast ratio with adjacent colors
 * This includes hover, active, focus, selected, and current states
 */

:root {
  --state-hover-bg: #e6f2ff;       /* Light blue hover - 1.2:1 vs white (use with border) */
  --state-hover-border: #0066cc;   /* Blue border - 4.6:1 vs white */
  --state-active-bg: #cce5ff;      /* Darker blue active - 1.4:1 vs white (use with border) */
  --state-selected-bg: #0066cc;    /* Blue selected - 4.6:1 vs white */
  --state-selected-text: #ffffff;  /* White text on selected */
  --state-current-indicator: #004999; /* Dark blue - 8.6:1 vs white */
}

/* Hover state for interactive elements */
button:hover,
[role="button"]:hover,
a:hover,
[role="link"]:hover {
  background-color: var(--state-hover-bg);
  border-color: var(--state-hover-border); /* Border provides 3:1 contrast */
}

/* Active/pressed state */
button:active,
[role="button"]:active,
a:active {
  background-color: var(--state-active-bg);
  border-color: var(--state-hover-border);
}

/* Selected state (tabs, menu items, list items) */
[role="tab"][aria-selected="true"],
[role="menuitem"][aria-current],
[aria-selected="true"] {
  background-color: var(--state-selected-bg);
  color: var(--state-selected-text);
  border-color: var(--state-selected-bg);
}

/* Current page/location indicator */
[aria-current="page"],
[aria-current="location"],
.active,
.current {
  border-left: 4px solid var(--state-current-indicator); /* 8.6:1 vs white */
}

/* Hover state for list items */
ul li:hover,
ol li:hover {
  background-color: var(--state-hover-bg);
  outline: 1px solid var(--state-hover-border); /* Outline provides contrast */
}

/* Checked checkbox/radio states */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background-color: var(--state-selected-bg); /* 4.6:1 vs white */
  border-color: var(--state-selected-bg);
}

/* Toggle switch states */
[role="switch"][aria-checked="true"] {
  background-color: var(--state-selected-bg);
}

/* Disabled state (exempt from 3:1 requirement per WCAG) */
button:disabled,
input:disabled,
[aria-disabled="true"] {
  opacity: 0.6; /* Visual indicator of disabled state */
  cursor: not-allowed;
}

/* Focus Indicator Contrast (3:1 minimum)
 * Focus outline color vs. background (already covered in Focus Indicators section) */

/**
 * Focus indicators must have 3:1 contrast ratio against adjacent colors
 * This reinforces/validates the focus styles from the Focus Indicators section
 *
 * NOTE: This section validates that our focus colors meet contrast requirements
 * The actual focus styles are defined in the Focus Indicators section above
 */

:root {
  --focus-outline-light-bg: #0066cc;  /* Blue on light bg - 4.6:1 vs white */
  --focus-outline-dark-bg: #66b3ff;   /* Light blue on dark bg - 4.6:1 vs black */
  --focus-outline-thickness: 2px;     /* Minimum per WCAG 2.4.13 */
}

/* Validate focus contrast on light backgrounds */
/* Our #0066cc focus color has 4.6:1 contrast vs white ✓ */
*:focus {
  outline: var(--focus-outline-thickness) solid var(--focus-outline-light-bg);
  outline-offset: 2px;
}

/* Focus on dark backgrounds requires different color */
.dark-bg *:focus,
[data-theme="dark"] *:focus {
  outline: var(--focus-outline-thickness) solid var(--focus-outline-dark-bg);
  outline-offset: 2px;
}

/* Two-color focus indicator for maximum contrast on any background */
/* Inner outline (white) + outer outline (dark) = works on any background */
.focus-ring-enhanced:focus {
  outline: 2px solid #ffffff;      /* White inner ring */
  outline-offset: 0;
  box-shadow: 0 0 0 4px #0066cc;   /* Blue outer ring - 4.6:1 vs white */
}

/* High contrast mode - browser handles color */
@media (prefers-contrast: high) {
  *:focus {
    outline: 3px solid; /* Browser provides high-contrast color automatically */
    outline-offset: 2px;
  }
}

/* Forced colors mode (Windows High Contrast) */
@media (forced-colors: active) {
  *:focus {
    outline: 3px solid; /* System color used automatically */
    outline-offset: 2px;
  }
}

/* Icon and Graphical Object Contrast (3:1 minimum)
 * Icons, SVG graphics, chart elements, data visualizations */

/**
 * Graphical objects and icons that convey information must have 3:1 contrast
 * against adjacent colors. This includes:
 * - Functional icons (must be understood to use the interface)
 * - Chart elements (bars, lines, data points)
 * - Infographic components
 * - UI icons (search, menu, close, etc.)
 *
 * Decorative graphics are exempt from contrast requirements
 */

:root {
  --icon-color: #000000;              /* Black - 21:1 vs white */
  --icon-color-interactive: #0066cc;  /* Blue - 4.6:1 vs white */
  --icon-bg: transparent;
  --chart-primary: #0066cc;           /* Blue - 4.6:1 vs white */
  --chart-secondary: #d62d20;         /* Red - 5.9:1 vs white */
  --chart-tertiary: #008744;          /* Green - 3.4:1 vs white */
  --chart-quaternary: #ffa700;        /* Orange - 2.1:1 vs white (needs border) */
}

/* SVG icons (functional) */
svg.icon {
  fill: var(--icon-color);
  stroke: var(--icon-color);
}

/* Interactive icons (buttons, links) */
button svg,
a svg,
[role="button"] svg {
  fill: var(--icon-color-interactive);
  stroke: var(--icon-color-interactive);
}

/* Icon fonts */
[class*="icon-"]::before,
.icon {
  color: var(--icon-color);
}

/* Interactive icon fonts */
button [class*="icon-"]::before,
a [class*="icon-"]::before {
  color: var(--icon-color-interactive);
}

/* Chart and data visualization colors */
.chart-bar,
.chart-primary {
  fill: var(--chart-primary);        /* 4.6:1 vs white ✓ */
  stroke: var(--chart-primary);
}

.chart-secondary {
  fill: var(--chart-secondary);      /* 5.9:1 vs white ✓ */
  stroke: var(--chart-secondary);
}

.chart-tertiary {
  fill: var(--chart-tertiary);       /* 3.4:1 vs white ✓ */
  stroke: var(--chart-tertiary);
}

.chart-quaternary {
  fill: var(--chart-quaternary);     /* 2.1:1 - needs border */
  stroke: #000000;                   /* Black border for contrast */
  stroke-width: 2px;
}

/* Ensure borders/outlines on graphical objects have 3:1 contrast */
.graphical-object {
  border: 2px solid #767676;         /* 4.5:1 vs white */
}

/* Infographic elements */
.infographic-element {
  fill: var(--chart-primary);
  stroke: #000000;                   /* Black stroke ensures visibility */
  stroke-width: 1px;
}

/* Icon hover states */
button:hover svg,
a:hover svg {
  fill: var(--state-hover-border);   /* Darker blue - 8.6:1 vs white */
}

/* Decorative graphics (exempt from contrast requirements) */
[role="presentation"] svg,
[aria-hidden="true"] svg,
.decorative-icon {
  /* No contrast requirements - purely decorative */
}

/* Placeholder Text Contrast
 * Placeholder text in form fields (often fails - needs careful attention) */

/**
 * CRITICAL: Placeholder text is NOT a replacement for labels
 * Placeholder text often fails to meet 4.5:1 contrast requirements
 *
 * Best practice: Use visible labels AND compliant placeholder text
 *
 * Browser default placeholder colors typically have ~2:1 contrast (FAILS WCAG)
 * This section overrides defaults to meet 4.5:1 minimum
 */

:root {
  --placeholder-color: #767676;      /* Medium gray - 4.5:1 vs white */
}

/* Standard placeholder styling (all browsers) */
::placeholder {
  color: var(--placeholder-color);
  opacity: 1; /* Firefox reduces opacity by default - override to maintain contrast */
}

/* Firefox (older versions) */
::-moz-placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

/* Internet Explorer 10-11 */
:-ms-input-placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

/* Microsoft Edge (legacy) */
::-ms-input-placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

/* Webkit browsers (Chrome, Safari, Edge Chromium) */
::-webkit-input-placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

/* Specific input types */
input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="tel"]::placeholder,
input[type="url"]::placeholder,
input[type="search"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

/* Placeholder on dark backgrounds */
.dark-bg input::placeholder,
.dark-bg textarea::placeholder,
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #b3b3b3; /* Light gray - 4.6:1 vs black */
  opacity: 1;
}

/* REMINDER: Always use visible labels */
/* Placeholder text disappears when user starts typing */
/* Screen readers may not announce placeholder text reliably */

/* Text Spacing & Reflow (WCAG 1.4.12, 1.4.10)
   ========================================================================== */

/**
 * Text Spacing Requirements (SC 1.4.12)
 *
 * Content must remain readable and functional when users adjust text spacing to:
 * - Line height (line spacing): at least 1.5 times the font size
 * - Paragraph spacing: at least 2 times the font size
 * - Letter spacing (tracking): at least 0.12 times the font size
 * - Word spacing: at least 0.16 times the font size
 *
 * Reflow Requirements (SC 1.4.10)
 *
 * Content must reflow to fit within 320 CSS pixels width without:
 * - Requiring horizontal scrolling (except for data tables, images, maps, diagrams)
 * - Loss of information or functionality
 * - Text truncation or clipping
 *
 * This is equivalent to 400% zoom or mobile viewport widths
 *
 * Reference: https://www.w3.org/WAI/WCAG22/Understanding/text-spacing.html
 *            https://www.w3.org/WAI/WCAG22/Understanding/reflow.html
 */

/* Base Text Spacing
 * Set default line-height, letter-spacing, word-spacing for all text elements */

/**
 * WCAG 1.4.12 requires content to support user adjustments to:
 * - Line height: 1.5x font size minimum
 * - Letter spacing: 0.12x font size minimum
 * - Word spacing: 0.16x font size minimum
 *
 * Setting these as defaults ensures compliance even before user adjustment
 */

:root {
  --base-line-height: 1.5;           /* 1.5x font size (WCAG minimum) */
  --base-letter-spacing: 0.12em;     /* 0.12x font size (WCAG minimum) */
  --base-word-spacing: 0.16em;       /* 0.16x font size (WCAG minimum) */
}

/* Apply base text spacing to all text elements */
html {
  line-height: var(--base-line-height);
}

body {
  line-height: var(--base-line-height);
  letter-spacing: 0; /* Start at 0, allow user adjustments up to 0.12em */
  word-spacing: 0;   /* Start at 0, allow user adjustments up to 0.16em */
}

/* All text elements inherit base spacing */
p,
li,
td,
th,
div,
span,
label,
legend,
caption {
  line-height: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
}

/* Ensure containers can expand to accommodate increased spacing */
* {
  box-sizing: border-box; /* Prevents overflow when padding is added */
}

/* Prevent fixed heights that could clip text with increased spacing */
p,
li,
div {
  min-height: auto; /* Allow height to grow with content */
}

/* Paragraph Spacing
 * Margin between paragraphs to meet 2x font-size minimum */

/**
 * WCAG 1.4.12 requires paragraph spacing to be at least 2x the font size
 * Using em units makes this proportional to the actual font size
 */

:root {
  --paragraph-spacing: 2em;  /* 2x font size (WCAG minimum) */
}

/* Paragraph spacing */
p {
  margin-top: 0;
  margin-bottom: var(--paragraph-spacing);
}

/* Last paragraph in a container shouldn't add bottom margin */
p:last-child {
  margin-bottom: 0;
}

/* Paragraphs in list items */
li p {
  margin-bottom: var(--paragraph-spacing);
}

li p:last-child {
  margin-bottom: 0;
}

/* Paragraphs in table cells */
td p,
th p {
  margin-bottom: var(--paragraph-spacing);
}

td p:last-child,
th p:last-child {
  margin-bottom: 0;
}

/* Paragraphs in blockquotes */
blockquote p {
  margin-bottom: var(--paragraph-spacing);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Paragraphs in form fields (help text, descriptions) */
fieldset p,
.form-group p,
.form-field p {
  margin-bottom: var(--paragraph-spacing);
}

fieldset p:last-child,
.form-group p:last-child,
.form-field p:last-child {
  margin-bottom: 0;
}

/* Heading Spacing
 * Line-height and spacing for heading elements (h1-h6) */

/**
 * Headings need appropriate line-height (1.5x minimum) and spacing
 * Larger headings may use slightly tighter line-height for aesthetics
 * while still meeting WCAG requirements
 */

:root {
  --heading-line-height: 1.2;        /* Tighter than body text (aesthetic choice) */
  --heading-margin-top: 2em;         /* Space before heading */
  --heading-margin-bottom: 0.5em;    /* Space after heading */
}

/* All headings */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--heading-line-height);
  margin-top: var(--heading-margin-top);
  margin-bottom: var(--heading-margin-bottom);
  letter-spacing: inherit;           /* Inherit from body */
  word-spacing: inherit;             /* Inherit from body */
}

/* First heading in a container has no top margin */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
  margin-top: 0;
}

/* Specific heading sizes can have adjusted spacing */
h1 {
  margin-top: 0;                     /* Main page heading - no top margin */
  margin-bottom: 1em;
  line-height: 1.2;
}

h2 {
  margin-top: 2em;
  margin-bottom: 0.75em;
  line-height: 1.3;
}

h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.4;
}

h4, h5, h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.5;                  /* Smaller headings use 1.5 line-height */
}

/* Headings immediately following other headings (subheadings) */
h1 + h2,
h2 + h3,
h3 + h4,
h4 + h5,
h5 + h6 {
  margin-top: 0.5em;                 /* Reduced spacing for subheadings */
}

/* List Spacing
 * Line-height and spacing for list items */

/**
 * Lists must support text spacing adjustments
 * Line-height 1.5x minimum for readability
 * Spacing between list items for clarity
 */

:root {
  --list-item-spacing: 0.5em;        /* Space between list items */
  --list-margin-bottom: 2em;         /* Space after entire list (2x font-size) */
  --list-padding-left: 2em;          /* Indent for list items */
}

/* Unordered and ordered lists */
ul, ol {
  margin-top: 0;
  margin-bottom: var(--list-margin-bottom);
  padding-left: var(--list-padding-left);
  line-height: var(--base-line-height); /* 1.5x minimum */
}

/* Definition lists */
dl {
  margin-top: 0;
  margin-bottom: var(--list-margin-bottom);
  line-height: var(--base-line-height);
}

/* List items */
li {
  margin-bottom: var(--list-item-spacing);
  line-height: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
}

/* Last list item has no bottom margin */
li:last-child {
  margin-bottom: 0;
}

/* Definition terms */
dt {
  margin-bottom: 0.25em;
  font-weight: bold;
  line-height: inherit;
}

/* Definition descriptions */
dd {
  margin-left: var(--list-padding-left);
  margin-bottom: var(--list-item-spacing);
  line-height: inherit;
}

dd:last-child {
  margin-bottom: 0;
}

/* Nested lists */
ul ul,
ul ol,
ol ul,
ol ol {
  margin-top: var(--list-item-spacing);
  margin-bottom: 0;
}

/* Lists in navigation (often tighter spacing) */
nav ul,
nav ol,
[role="navigation"] ul,
[role="navigation"] ol {
  margin-bottom: 0;
  padding-left: 0;
  list-style: none; /* Navigation lists typically have no bullets */
}

nav li,
[role="navigation"] li {
  margin-bottom: 0.25em; /* Tighter spacing for nav items */
}

/* Menu lists (ARIA) */
[role="menu"],
[role="menubar"] {
  margin: 0;
  padding: 0;
  list-style: none;
}

[role="menuitem"] {
  margin-bottom: 0;
  line-height: inherit;
}

/* Text in Buttons and Controls
 * Ensure interactive elements support text spacing adjustments */

/**
 * Buttons and form controls must accommodate increased text spacing
 * without clipping or breaking layout
 *
 * Key: Avoid fixed heights and allow elements to expand
 */

/* Buttons support text spacing */
button,
[type="button"],
[type="submit"],
[type="reset"],
[role="button"] {
  line-height: var(--base-line-height); /* 1.5x minimum */
  letter-spacing: inherit;              /* Allow user adjustments */
  word-spacing: inherit;                /* Allow user adjustments */
  white-space: normal;                  /* Allow text to wrap if needed */
  /* min-height: 24px already set in Interactive Element Sizing */
  /* padding: 4px 8px already set in Interactive Element Sizing */
}

/* Text inputs support spacing */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"] {
  line-height: var(--base-line-height);
  letter-spacing: inherit;
  word-spacing: inherit;
}

/* Textareas support spacing */
textarea {
  line-height: var(--base-line-height);
  letter-spacing: inherit;
  word-spacing: inherit;
}

/* Select dropdowns support spacing */
select {
  line-height: var(--base-line-height);
  letter-spacing: inherit;
  word-spacing: inherit;
}

/* Labels support spacing (already have inherits, but explicit for clarity) */
label {
  line-height: var(--base-line-height);
  letter-spacing: inherit;
  word-spacing: inherit;
  display: block;                       /* Labels typically block-level */
  margin-bottom: 0.5em;
}

/* Inline labels (radio/checkbox) */
input[type="checkbox"] + label,
input[type="radio"] + label {
  display: inline-block;
  margin-bottom: 0;
  margin-left: 0.5em;
}

/* Legend (fieldset labels) support spacing */
legend {
  line-height: var(--base-line-height);
  letter-spacing: inherit;
  word-spacing: inherit;
  margin-bottom: 1em;
}

/* Help text / descriptions under form fields */
.help-text,
.form-help,
[id$="-help"],
[id$="-description"] {
  line-height: var(--base-line-height);
  letter-spacing: inherit;
  word-spacing: inherit;
  margin-top: 0.25em;
  font-size: 0.875em; /* Typically smaller */
}

/* Error messages */
.error-message,
.form-error,
[role="alert"] {
  line-height: var(--base-line-height);
  letter-spacing: inherit;
  word-spacing: inherit;
  margin-top: 0.25em;
}

/* Responsive Reflow - Mobile First (320px base)
 * Ensure content reflows without horizontal scrolling at 320px viewport */

/**
 * WCAG 1.4.10 requires content to reflow at 320px width (equivalent to 400% zoom)
 * without requiring horizontal scrolling or losing information
 *
 * Mobile-first approach: styles here apply to 320px and up
 * Exception: Data tables, images, diagrams, maps can scroll horizontally
 */

/* Base mobile styles (320px and up) - DEFAULT */

/* Reset any fixed widths that could cause horizontal scroll */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

/* All containers use full width by default */
* {
  max-width: 100%;
}

/* Main content container */
main,
.content,
.container {
  width: 100%;
  max-width: 100%;
  padding-left: 1rem;   /* 16px breathing room */
  padding-right: 1rem;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* Sections and articles */
section,
article,
aside,
header,
footer,
nav {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Headings don't force width */
h1, h2, h3, h4, h5, h6 {
  max-width: 100%;
  overflow-wrap: break-word; /* Break long words to prevent overflow */
  word-wrap: break-word;     /* Legacy support */
  hyphens: auto;             /* Allow hyphenation */
}

/* Paragraphs and text blocks */
p,
li,
blockquote {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Buttons don't force width */
button,
[type="button"],
[type="submit"],
[type="reset"] {
  max-width: 100%;
  white-space: normal; /* Allow button text to wrap */
}

/* Form fields take full width on mobile */
input,
textarea,
select {
  max-width: 100%;
  box-sizing: border-box;
}

/* Links can break if too long */
a {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Pre-formatted text can scroll (exception allowed) */
pre,
code {
  max-width: 100%;
  overflow-x: auto; /* Horizontal scroll allowed for code */
  white-space: pre-wrap; /* Wrap where possible */
  word-wrap: break-word;
}

/* Navigation stacks vertically on mobile */
nav ul,
nav ol {
  flex-direction: column; /* Stack nav items */
  width: 100%;
}

nav li {
  width: 100%;
}

/* Responsive Reflow - Tablet (768px)
 * Progressive enhancement for larger viewports */

/**
 * At tablet breakpoint (768px), allow more horizontal space usage
 * while maintaining reflow principles
 *
 * Content can use multi-column layouts but must still reflow gracefully
 * if user zooms to 400% (reducing effective viewport to 192px)
 */

@media (min-width: 768px) {

  /* Container can have max-width but still fluid */
  main,
  .content,
  .container {
    max-width: 1200px; /* Reasonable max for readability */
    padding-left: 2rem;
    padding-right: 2rem;
  }

  /* Navigation can go horizontal on tablet */
  nav ul,
  nav ol {
    flex-direction: row; /* Horizontal nav */
    flex-wrap: wrap;     /* But wrap if needed */
  }

  nav li {
    width: auto;         /* Auto-width for horizontal layout */
  }

  /* Forms can use two-column layouts */
  .form-row {
    display: flex;
    flex-wrap: wrap;     /* Wrap to single column if zoomed */
    gap: 1rem;
  }

  .form-row > * {
    flex: 1 1 calc(50% - 0.5rem); /* Two columns with gap */
    min-width: 200px;   /* Collapse to single column if too narrow */
  }

  /* Grid layouts can appear (but must wrap) */
  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
  }

/* Responsive Reflow - Desktop (1024px and up)
 * Full desktop experience while maintaining reflow capability */

/**
 * Desktop breakpoint allows complex layouts, but all must still reflow
 * when user zooms to 400% (effective 256px viewport)
 *
 * Key principle: Use flexible units and wrapping, not fixed widths
 */

@media (min-width: 1024px) {

  /* Container can use full max-width */
  main,
  .content,
  .container {
    max-width: 1400px; /* Wider max for desktop */
    padding-left: 3rem;
    padding-right: 3rem;
  }

  /* Multi-column text layouts (must reflow at zoom) */
  .text-columns {
    column-count: 2;
    column-gap: 3rem;
    column-width: auto;
  }

  /* Note: columns automatically collapse at narrow widths */

  /* Complex grid layouts */
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
  }

  .grid-3-col {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .grid-4-col {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }

  /* Card grids */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
  }

  /* Three-column layouts with sidebar(s) */
  .layout-three-column {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(400px, 3fr) minmax(200px, 1fr);
    gap: 2rem;
  }

  /* But use mobile-first stacking order */
  @supports not (display: grid) {
    .layout-three-column {
      display: flex;
      flex-wrap: wrap;
    }
  }

  /* Navigation can have dropdowns */
  nav ul ul {
    position: absolute; /* Dropdowns can overlay */
    /* But parent nav still wraps if zoomed */
  }

  /* Form layouts can be more complex */
  .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
  }

  /* Specific field width controls (still flexible) */
  .field-small {
    grid-column: span 1;
    min-width: 150px;
  }

  .field-medium {
    grid-column: span 2;
    min-width: 250px;
  }

  .field-large {
    grid-column: span 3;
    min-width: 350px;
  }

  /* Full-width fields */
  .field-full {
    grid-column: 1 / -1; /* Span all columns */
  }

  /* Hero sections / featured content */
  .hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 3rem;
    align-items: center;
  }

  /* Footer multi-column */
  footer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
  }

  /* Sticky elements must not obscure content at zoom */
  .sticky-header,
  .sticky-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    /* Will scroll with content at high zoom - this is correct */
  }

  /* Allow more table columns */
  table {
    font-size: inherit; /* Full size */
  }

}

/* Container Width Constraints
 * Prevent content from becoming too wide for readability */

/**
 * WCAG 1.4.10 Reflow requires content to fit viewport width
 * Additionally, optimal line length for readability is 45-75 characters
 *
 * Constraints prevent content from stretching too wide on large monitors
 * while still allowing it to reflow narrow on small viewports/zoom
 */

/* Root container - absolute maximum */
.page-wrapper,
.site-wrapper {
  max-width: 1600px;  /* Beyond this, diminishing UX returns */
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Main content container - optimal reading width */
main,
.main-content,
article {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Text content - optimal line length */
.prose,
.text-content,
article > *:not(.wide):not(.full-width) {
  max-width: 65ch;     /* ~65 characters per line */
  margin-left: auto;
  margin-right: auto;
}

/* Alternative: pixel-based text width (less flexible) */
.text-narrow {
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.text-medium {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* Wide content (still constrained) */
.wide,
.content-wide {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* Full width content (within page wrapper max) */
.full-width,
.content-full {
  max-width: 100%;
  width: 100%;
}

/* Navigation containers */
nav {
  max-width: 100%;     /* Nav can span full width */
  width: 100%;
}

/* Header and footer can be full width */
header,
footer {
  max-width: 100%;
  width: 100%;
}

/* But header/footer inner content should be constrained */
header > .header-inner,
footer > .footer-inner {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Forms - moderate width for usability */
form {
  max-width: 800px;    /* Forms too wide = poor UX */
  margin-left: auto;
  margin-right: auto;
}

/* Exception: inline forms can be full width */
form.inline-form,
form.search-form {
  max-width: 100%;
}

/* Fieldsets inherit form constraints */
fieldset {
  max-width: 100%;     /* Don't exceed parent form */
  width: 100%;
}

/* Tables - special case */
.table-wrapper {
  max-width: 100%;
  width: 100%;
  overflow-x: auto;    /* Tables can scroll horizontally (WCAG exception) */
}

table {
  max-width: 100%;
  /* No width: 100% - let table be natural width */
}

/* Images and media */
img,
video,
iframe,
embed,
object {
  max-width: 100%;     /* Never exceed container */
  height: auto;        /* Maintain aspect ratio */
}

/* Figure elements */
figure {
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

figure.large {
  max-width: 1200px;
}

figure.medium {
  max-width: 800px;
}

figure.small {
  max-width: 600px;
}

/* Blockquotes - readable width */
blockquote {
  max-width: 60ch;
  margin-left: auto;
  margin-right: auto;
}

/* Lists within text content */
ul,
ol {
  max-width: 65ch;     /* Match prose width */
}

/* Definition lists can be wider */
dl {
  max-width: 800px;
}

/* Prevent nested containers from compounding */
.prose .prose,
.text-content .text-content {
  max-width: 100%;     /* Nested elements don't further constrain */
}

/* Utility classes for manual control */
.max-width-none {
  max-width: none !important;
}

.max-width-full {
  max-width: 100% !important;
}

/* Flexible Grid/Layout Systems
 * Reusable responsive grid and flexbox patterns that automatically reflow */

/**
 * All grid and flex systems must reflow at narrow viewports (320px)
 * and when users zoom to 400%
 *
 * Key techniques:
 * - auto-fit / auto-fill for grids
 * - flex-wrap for flexbox
 * - minmax() for flexible column widths
 * - No fixed column counts at small viewports
 */

/* === CSS GRID SYSTEMS === */

/* Basic responsive grid - auto-sizing columns */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  width: 100%;
}

/* Grid with different minimum column widths */
.grid-small {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.grid-medium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.grid-large {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
}

/* Card grid - common pattern */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

/* Dense grid for smaller items */
.grid-dense {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  grid-auto-flow: dense; /* Fill gaps */
}

/* Responsive columns by breakpoint */
.grid-responsive {
  display: grid;
  grid-template-columns: 1fr; /* Mobile: single column */
  gap: 1rem;
}

@media (min-width: 768px) {
  .grid-responsive {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .grid-responsive {
    gap: 2rem;
  }
}

/* === FLEXBOX SYSTEMS === */

/* Basic flex container - always wraps */
.flex {
  display: flex;
  flex-wrap: wrap; /* CRITICAL for reflow */
  gap: 1rem;
  width: 100%;
}

/* Flex row - items in a row that wrap */
.flex-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Flex column - stacks vertically */
.flex-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Equal-width flex items */
.flex-equal > * {
  flex: 1 1 0;           /* Grow equally */
  min-width: 200px;       /* But wrap if too narrow */
}

/* Auto-width flex items */
.flex-auto > * {
  flex: 0 1 auto;         /* Size to content */
}

/* Flex with specific item widths */
.flex-thirds > * {
  flex: 1 1 calc(33.333% - 1rem);
  min-width: 250px;       /* Wrap to single column if narrow */
}

.flex-halves > * {
  flex: 1 1 calc(50% - 0.5rem);
  min-width: 280px;
}

.flex-quarters > * {
  flex: 1 1 calc(25% - 1rem);
  min-width: 200px;
}

/* Flex alignment utilities */
.flex-start {
  justify-content: flex-start;
}

.flex-center {
  justify-content: center;
}

.flex-end {
  justify-content: flex-end;
}

.flex-between {
  justify-content: space-between;
}

.flex-around {
  justify-content: space-around;
}

.flex-evenly {
  justify-content: space-evenly;
}

/* Vertical alignment */
.flex-align-start {
  align-items: flex-start;
}

.flex-align-center {
  align-items: center;
}

.flex-align-end {
  align-items: flex-end;
}

.flex-align-stretch {
  align-items: stretch;
}

/* === LAYOUT PATTERNS === */

/* Sidebar layout - main content + sidebar */
.layout-sidebar {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  width: 100%;
}

.layout-sidebar > .main {
  flex: 1 1 60%;
  min-width: 300px; /* Wraps below sidebar when narrow */
}

.layout-sidebar > .sidebar {
  flex: 1 1 30%;
  min-width: 250px;
}

/* Reverse sidebar (sidebar on left) */
.layout-sidebar-left {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row-reverse; /* Sidebar first in DOM, right visually */
  gap: 2rem;
}

/* Holy grail layout - header, nav, main, sidebar, footer */
.layout-holy-grail {
  display: grid;
  grid-template-areas:
    "header"
    "nav"
    "main"
    "sidebar"
    "footer";
  gap: 1rem;
}

@media (min-width: 1024px) {
  .layout-holy-grail {
    grid-template-columns: 1fr 3fr 1fr;
    grid-template-areas:
      "header header header"
      "nav nav nav"
      "sidebar main aside"
      "footer footer footer";
    gap: 2rem;
  }
}

.layout-holy-grail > header { grid-area: header; }
.layout-holy-grail > nav { grid-area: nav; }
.layout-holy-grail > .main { grid-area: main; }
.layout-holy-grail > .sidebar { grid-area: sidebar; }
.layout-holy-grail > footer { grid-area: footer; }

/* Masonry-style layout (CSS Grid approximation) */
.layout-masonry {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  grid-auto-rows: 20px; /* Small row height */
  gap: 1rem;
}

.layout-masonry > * {
  /* Items should set grid-row-end based on content height */
  /* Example: grid-row-end: span 10; for taller items */
}

/* Split layout - 50/50 */
.layout-split {
  display: grid;
  grid-template-columns: 1fr; /* Mobile: stacked */
  gap: 2rem;
}

@media (min-width: 768px) {
  .layout-split {
    grid-template-columns: 1fr 1fr; /* Desktop: side-by-side */
  }
}

/* Pancake stack - header, flexible main, footer */
.layout-pancake {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.layout-pancake > header,
.layout-pancake > footer {
  flex: 0 0 auto; /* Fixed height */
}

.layout-pancake > main {
  flex: 1 0 auto; /* Grows to fill space */
}

/* === RESPONSIVE UTILITIES === */

/* Gap utilities */
.gap-none { gap: 0; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-xl { gap: 2rem; }

/* Mobile-specific layouts */
@media (max-width: 767px) {
  /* Force single column on mobile */
  .mobile-stack {
    grid-template-columns: 1fr !important;
  }

  .mobile-stack-flex {
    flex-direction: column !important;
  }
}

/* Desktop-specific layouts */
@media (min-width: 1024px) {
  /* Allow more complex grids on desktop */
  .desktop-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }

  .desktop-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

/* Images and Media Reflow
 * Ensure images, videos, and embedded media scale responsively */

/**
 * WCAG 1.4.10 Reflow allows images and media to be exceptions
 * (they can require horizontal scrolling), but best practice
 * is to make them responsive when possible
 *
 * All media should scale down to fit viewport width
 * while maintaining aspect ratios
 */

/* === IMAGES === */

/* All images responsive by default */
img {
  max-width: 100%;
  height: auto;        /* Maintain aspect ratio */
  display: block;      /* Remove inline spacing issues */
}

/* Inline images (in text) */
p img,
li img,
.inline-image {
  display: inline-block;
  vertical-align: middle;
}

/* Images with explicit dimensions preserve aspect ratio */
img[width],
img[height] {
  height: auto;        /* Override height attribute */
  max-width: 100%;
}

/* Decorative images */
img[role="presentation"],
img[alt=""],
.decorative-image {
  max-width: 100%;
  height: auto;
}

/* SVG images */
svg {
  max-width: 100%;
  height: auto;
}

/* Inline SVG with viewBox scales properly */
svg:not([width]):not([height]) {
  width: 100%;
  height: auto;
}

/* === PICTURE ELEMENT === */

picture {
  display: block;
  max-width: 100%;
}

picture img {
  width: 100%;         /* Fill picture container */
  height: auto;
}

/* === FIGURE ELEMENT === */

figure {
  max-width: 100%;
  margin: 2em auto;    /* Vertical spacing */
  padding: 0;
}

figure img,
figure video,
figure iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

figcaption {
  margin-top: 0.5em;
  font-size: 0.875em;
  line-height: var(--base-line-height);
  color: var(--text-muted);
  padding: 0 1rem;
}

/* === VIDEO === */

video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Video with controls */
video[controls] {
  width: 100%;         /* Use full width available */
  height: auto;
}

/* === AUDIO === */

audio {
  max-width: 100%;
  width: 100%;         /* Audio players use full width */
  display: block;
}

/* === IFRAME (embedded content) === */

iframe {
  max-width: 100%;
  border: 0;           /* Remove default border */
}

/* Responsive iframe wrapper (for maintaining aspect ratio) */
.iframe-wrapper,
.video-wrapper,
.embed-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
}

.iframe-wrapper iframe,
.video-wrapper iframe,
.embed-wrapper iframe,
.video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Alternative aspect ratios */
.iframe-wrapper.ratio-4-3 {
  padding-bottom: 75%;    /* 4:3 */
}

.iframe-wrapper.ratio-1-1 {
  padding-bottom: 100%;   /* 1:1 square */
}

.iframe-wrapper.ratio-21-9 {
  padding-bottom: 42.857%; /* 21:9 ultra-wide */
}

/* === EMBED AND OBJECT === */

embed,
object {
  max-width: 100%;
}

/* === CANVAS === */

canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* === BACKGROUND IMAGES === */

/* Background images on elements should use cover/contain */
.bg-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.bg-contain {
  background-size: contain;
}

/* === IMAGE GALLERIES === */

/* Grid-based gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  width: 100%;
}

.gallery img {
  width: 100%;
  height: auto;
  object-fit: cover;   /* Crop to fill grid cell */
  aspect-ratio: 1 / 1; /* Square thumbnails */
}

/* Flex-based gallery */
.gallery-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.gallery-flex img {
  flex: 1 1 calc(33.333% - 1rem);
  min-width: 200px;
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

/* === RESPONSIVE IMAGES WITH SRCSET === */

/* Let browser choose appropriate image size */
img[srcset] {
  width: 100%;
  height: auto;
}

/* === LAZY LOADED IMAGES === */

/* Images with loading="lazy" */
img[loading="lazy"] {
  max-width: 100%;
  height: auto;
}

/* Placeholder while loading */
img[loading="lazy"]:not([src]) {
  background: #f0f0f0;
  min-height: 200px;   /* Prevent layout shift */
}

/* === IMAGE ALIGNMENT === */

/* Floated images in text */
.align-left {
  float: left;
  margin: 0 1rem 1rem 0;
  max-width: 50%;      /* Don't take more than half on mobile */
}

.align-right {
  float: right;
  margin: 0 0 1rem 1rem;
  max-width: 50%;
}

.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Clear floats */
.clear {
  clear: both;
}

/* Mobile: force full width for floated images */
@media (max-width: 767px) {
  .align-left,
  .align-right {
    float: none;
    max-width: 100%;
    margin: 1rem 0;
    display: block;
  }
}

/* === MAPS === */

/* Embedded maps (Google Maps, etc.) */
.map-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 default */
  height: 0;
  overflow: hidden;
}

.map-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* === OBJECT-FIT UTILITIES === */

/* Control how images fill their containers */
.object-cover {
  object-fit: cover;
}

.object-contain {
  object-fit: contain;
}

.object-fill {
  object-fit: fill;
}

.object-scale-down {
  object-fit: scale-down;
}

/* === HIGH DPI / RETINA SUPPORT === */

/* Let srcset handle retina, but provide fallback */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  /* Retina-specific adjustments if needed */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* === PRINT MEDIA === */

@media print {
  img,
  video,
  iframe,
  embed,
  object {
    max-width: 100%;
    page-break-inside: avoid; /* Don't break images across pages */
  }
}

/* Tables Reflow (Exception)
 * Data tables are WCAG exception - can scroll horizontally */

/**
 * WCAG 1.4.10 explicitly allows data tables to require horizontal scrolling
 * However, we should still make tables as responsive as possible:
 *
 * 1. Simple tables can reflow on mobile (card layout)
 * 2. Complex data tables get horizontal scroll
 * 3. Always wrap tables in scrollable container
 * 4. Provide visual indication of scroll capability
 */

/* === DEFAULT TABLE STYLES === */

/* Basic table structure */
table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

/* Table cells */
th,
td {
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
  line-height: var(--base-line-height);
  border: 1px solid var(--input-border, #767676);
}

/* Table headers */
th {
  font-weight: bold;
  background-color: #f5f5f5;
}

/* Caption */
caption {
  padding: 0.75rem;
  caption-side: top;
  text-align: left;
  font-weight: bold;
  line-height: var(--base-line-height);
}

/* === SCROLLABLE TABLE WRAPPER === */

/* All tables should be wrapped for horizontal scroll */
.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;           /* WCAG exception: horizontal scroll allowed */
  overflow-y: visible;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  margin-bottom: 2rem;
}

/* Visual scroll indicator (optional shadow) */
.table-wrapper {
  position: relative;
}

/* Shadow to indicate more content to the right */
.table-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

/* Show shadow when table is scrollable */
.table-wrapper:not(.scrolled-right)::after {
  opacity: 1;
}

/* Table inside wrapper doesn't need max-width */
.table-wrapper > table {
  width: auto;              /* Let table be natural width */
  min-width: 100%;          /* But at least full wrapper width */
  margin-bottom: 0;
}

/* === RESPONSIVE TABLE TECHNIQUES === */

/* Simple tables: reflow to cards on mobile */
@media (max-width: 767px) {

  /* Apply to tables with class .table-responsive */
  .table-responsive {
    border: 0;
  }

  /* Hide table headers visually but keep for screen readers */
  .table-responsive thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Display rows as cards */
  .table-responsive tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid var(--input-border, #767676);
  }

  /* Display cells as rows within cards */
  .table-responsive td {
    display: block;
    text-align: right;
    border: none;
    border-bottom: 1px solid #ddd;
    padding: 0.75rem;
  }

  .table-responsive td:last-child {
    border-bottom: 0;
  }

  /* Add data labels before each cell */
  .table-responsive td::before {
    content: attr(data-label);
    float: left;
    font-weight: bold;
    text-align: left;
  }

  /* Example usage:
   * <td data-label="Name">John Doe</td>
   * Displays as:
   * Name          John Doe
   */
}

/* === FIXED HEADER TABLES === */

/* Sticky table headers (for long tables) */
.table-sticky-header {
  max-height: 500px;        /* Limit table height */
  overflow-y: auto;         /* Vertical scroll */
  overflow-x: auto;         /* Horizontal scroll */
}

.table-sticky-header thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f5f5f5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Visual separation */
}

/* === ZEBRA STRIPING (READABILITY) === */

/* Alternate row colors for easier scanning */
.table-striped tbody tr:nth-child(odd) {
  background-color: #f9f9f9;
}

.table-striped tbody tr:nth-child(even) {
  background-color: #ffffff;
}

/* === HOVER EFFECTS (INTERACTIVITY) === */

/* Highlight row on hover for easier scanning */
.table-hover tbody tr:hover {
  background-color: #f0f0f0;
  cursor: default;
}

/* === SORTABLE TABLES === */

/* Sortable column headers */
th[aria-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 2rem; /* Space for sort icon */
}

th[aria-sort="ascending"]::after {
  content: '▲';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

th[aria-sort="descending"]::after {
  content: '▼';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

th[aria-sort="none"]::after {
  content: '⇅';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.3;
}

/* === CELL ALIGNMENT === */

/* Text alignment utilities */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Numeric columns typically right-aligned */
td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums; /* Monospaced numbers */
}

/* === MINIMUM COLUMN WIDTHS === */

/* Prevent columns from becoming too narrow */
th,
td {
  min-width: 100px;         /* Reasonable minimum */
}

/* Specific column width classes */
.col-narrow {
  width: 100px;
  min-width: 100px;
}

.col-medium {
  width: 200px;
  min-width: 150px;
}

.col-wide {
  width: 300px;
  min-width: 200px;
}

/* Auto-width columns */
.col-auto {
  width: auto;
  min-width: 0;
}

/* === EMPTY CELLS === */

/* Style for empty cells */
td:empty::after,
th:empty::after {
  content: '—';             /* Em dash for empty cells */
  color: var(--text-muted, #767676);
}

/* === COMPLEX DATA TABLES === */

/* Tables with row and column headers */
table[role="grid"] th[scope="row"] {
  font-weight: bold;
  background-color: #f9f9f9;
}

/* === PRINT STYLES === */

@media print {
  table {
    border-collapse: collapse;
    width: 100%;
  }

  /* Don't break rows across pages */
  tr {
    page-break-inside: avoid;
  }

  /* Repeat headers on each page */
  thead {
    display: table-header-group;
  }

  /* Show all content (no scrolling in print) */
  .table-wrapper {
    overflow: visible;
  }
}

/* === FOCUS STYLES FOR TABLE CELLS === */

/* Interactive table cells (editable or clickable) */
td[tabindex],
th[tabindex] {
  cursor: pointer;
}

td[tabindex]:focus,
th[tabindex]:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: -2px;     /* Inside cell */
}

/* === RESPONSIVE BREAKPOINTS === */

/* Tablet: reduce padding slightly */
@media (max-width: 1023px) {
  th,
  td {
    padding: 0.5rem;
  }
}

/* Mobile: even less padding */
@media (max-width: 767px) {
  th,
  td {
    padding: 0.5rem 0.25rem;
  }

  /* Reduce minimum column width on mobile */
  th,
  td {
    min-width: 80px;
  }
}

/* === ACCESSIBILITY NOTES === */

/**
 * Required HTML attributes for accessible tables:
 *
 * 1. Simple tables:
 *    <table>
 *      <caption>Table description</caption>
 *      <thead><tr><th scope="col">Header</th></tr></thead>
 *    </table>
 *
 * 2. Complex tables (row AND column headers):
 *    <th scope="row">Row header</th>
 *    <th scope="col">Column header</th>
 *
 * 3. For responsive card layout:
 *    <td data-label="Column Name">Value</td>
 *
 * 4. Sortable tables:
 *    <th aria-sort="ascending">Column</th>
 *
 * 5. For very complex tables, use id/headers:
 *    <th id="q1">Q1</th>
 *    <td headers="q1 revenue">$100</td>
 */

/* Prevent Text Truncation
 * Ensure text is never cut off or hidden from users */

/**
 * WCAG 1.4.4 Resize Text and 1.4.10 Reflow require that text
 * remains visible and readable when:
 * - User increases font size up to 200%
 * - User zooms to 400%
 * - Viewport is as narrow as 320px
 *
 * Common causes of text truncation:
 * - Fixed heights on containers
 * - text-overflow: ellipsis without expansion mechanism
 * - Absolute positioning
 * - Hidden overflow
 */

/* === PREVENT FIXED HEIGHTS === */

/* Never use fixed height on text containers */
p,
div,
span,
li,
td,
th,
label,
button,
a {
  height: auto;             /* Never fixed height */
  min-height: 0;            /* Can shrink to content */
}

/* Allow containers to grow with content */
.content,
.wrapper,
.container,
.box,
.card {
  height: auto;
  min-height: 0;
}

/* === OVERFLOW HANDLING === */

/* Text containers should show overflow, not hide it */
p,
div,
span,
li,
blockquote {
  overflow: visible;        /* Show all text */
}

/* === WORD BREAKING === */

/* Long words must break to prevent horizontal overflow */
p,
li,
td,
th,
div,
span,
label {
  overflow-wrap: break-word; /* Break long words */
  word-wrap: break-word;     /* Legacy support */
  word-break: break-word;    /* Alternative breaking */
  hyphens: auto;             /* Enable hyphenation */
}

/* Headings also need word breaking */
h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* URLs and long strings */
a {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-all;    /* More aggressive for URLs */
}

/* === ELLIPSIS - USE CAREFULLY === */

/**
 * text-overflow: ellipsis is acceptable ONLY if:
 * 1. Full text is available on hover/focus, OR
 * 2. Full text is available via expansion mechanism, OR
 * 3. Truncated text is decorative/supplementary only
 *
 * NEVER use ellipsis for critical information
 */

/* Acceptable ellipsis pattern - expandable */
.truncate-expandable {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  cursor: pointer;
}

/* Show full text on hover/focus */
.truncate-expandable:hover,
.truncate-expandable:focus {
  overflow: visible;
  white-space: normal;
  word-wrap: break-word;
}

/* Alternative: tooltip shows full text */
.truncate-with-tooltip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.truncate-with-tooltip[title]:hover::after,
.truncate-with-tooltip[aria-label]:hover::after {
  /* Full text shown in browser tooltip via title attribute */
  /* Or custom tooltip implementation */
}

/* === LINE CLAMPING - USE CAREFULLY === */

/* Multi-line truncation (must have expansion mechanism) */
.line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;           /* Show 3 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Expandable line clamp */
.line-clamp-expandable {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.line-clamp-expandable.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

/* "Read more" button pattern */
.read-more-wrapper {
  position: relative;
}

.read-more-content.collapsed {
  max-height: 150px;              /* ~5 lines at 1.5 line-height */
  overflow: hidden;
  position: relative;
}

.read-more-content.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3em;
  background: linear-gradient(transparent, white);
}

.read-more-button {
  margin-top: 0.5rem;
  /* Button styling from previous sections */
}

/* === WHITE SPACE HANDLING === */

/* Never force nowrap without overflow handling */
.nowrap-safe {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* But prefer wrapping for accessibility */
.prefer-wrap {
  white-space: normal;
  overflow-wrap: break-word;
}

/* Pre-formatted text wraps where possible */
pre {
  white-space: pre-wrap;           /* Wrap long lines */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Code blocks wrap */
code {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Inline code can break */
p code,
li code {
  white-space: normal;
  word-break: break-all;
}

/* === BUTTONS AND CONTROLS === */

/* Button text must wrap, never truncate */
button,
[type="button"],
[type="submit"],
[type="reset"],
[role="button"] {
  white-space: normal;             /* Allow wrapping (set in earlier section) */
  overflow-wrap: break-word;
  height: auto;                    /* Grow with content */
}

/* Links in buttons */
a[role="button"] {
  white-space: normal;
  overflow-wrap: break-word;
}

/* === LABELS AND FORM TEXT === */

/* Labels must show full text */
label {
  white-space: normal;
  overflow-wrap: break-word;
  height: auto;
}

/* Placeholder text (never truncate critical info) */
::placeholder {
  white-space: normal;
  overflow: visible;
}

/* Help text and error messages */
.help-text,
.error-message,
[role="alert"] {
  white-space: normal;
  overflow-wrap: break-word;
  overflow: visible;
}

/* === NAVIGATION === */

/* Nav items wrap if needed */
nav a,
nav button {
  white-space: normal;
  overflow-wrap: break-word;
}

/* Breadcrumbs wrap */
.breadcrumb {
  white-space: normal;
  overflow-wrap: break-word;
}

.breadcrumb a {
  overflow-wrap: break-word;
  word-break: break-all;          /* URLs can break aggressively */
}

/* === TOOLTIPS AND POPOVERS === */

/* Tooltips must never truncate */
[role="tooltip"],
.tooltip {
  white-space: normal;
  max-width: 300px;                /* Reasonable max */
  overflow-wrap: break-word;
  overflow: visible;
}

/* === CARDS AND BOXES === */

/* Card titles and content */
.card-title,
.card-content,
.box-content {
  overflow-wrap: break-word;
  word-wrap: break-word;
  height: auto;
}

/* Card descriptions */
.card-description {
  white-space: normal;
  overflow: visible;
  overflow-wrap: break-word;
}

/* === AVOID PROBLEMATIC PATTERNS === */

/* BAD: Fixed height + hidden overflow = text loss */
/* NEVER do this:
.bad-example {
  height: 100px;
  overflow: hidden;
}
*/

/* GOOD: Let height grow with content */
.good-example {
  min-height: 100px;             /* Minimum, but can grow */
  max-height: none;              /* No maximum */
  overflow: visible;             /* Show all content */
}

/* BAD: Ellipsis without expansion mechanism */
/* AVOID this:
.bad-truncate {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
*/

/* GOOD: Ellipsis with hover expansion */
.good-truncate {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.good-truncate:hover,
.good-truncate:focus {
  white-space: normal;
  overflow: visible;
}

/* === ACCESSIBILITY FOR SCREEN READERS === */

/* Visually hidden text (still available to screen readers) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Full text for screen readers when using ellipsis */
.truncated-visible[aria-label] {
  /* Visual truncation */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* aria-label contains full text for screen readers */

/* === ZOOM AND FONT SIZE ADJUSTMENTS === */

/* Ensure containers grow when text size increases */
@media (min-resolution: 192dpi) {
  /* High DPI - text may render larger */
  * {
    height: auto;
  }
}

/* === FLEXBOX CONSIDERATIONS === */

/* Flex items with text must not shrink below content size */
.flex > * {
  min-width: 0;                   /* Allow shrinking */
  flex-shrink: 1;                 /* Can shrink */
  overflow-wrap: break-word;      /* But break words instead of overflow */
}

/* === GRID CONSIDERATIONS === */

/* Grid items with text */
.grid > * {
  min-width: 0;                   /* Allow shrinking */
  overflow-wrap: break-word;      /* Break words */
  overflow: visible;              /* Show all content */
}

/* === CRITICAL REMINDERS === */

/**
 * Text truncation checklist:
 *
 * ✓ Never use fixed heights on text containers
 * ✓ Never hide overflow without expansion mechanism
 * ✓ Always allow word breaking (overflow-wrap: break-word)
 * ✓ Use white-space: normal (not nowrap) by default
 * ✓ If using ellipsis, provide hover/focus expansion OR tooltip
 * ✓ If using line-clamp, provide "Read more" expansion
 * ✓ Test at 200% font size and 400% zoom
 * ✓ Ensure critical information is never truncated
 * ✓ Screen reader users get full text via aria-label if needed
 */

/* Avoid Absolute Positioning Issues
 * Prevent absolute positioning from causing content overlap or loss */

/**
 * WCAG 1.4.10 Reflow requires content to remain accessible at 320px width
 * and 400% zoom. Absolute positioning can cause:
 * - Content overlap (obscuring text)
 * - Content pushed off-screen
 * - Broken layouts at different viewport sizes
 *
 * Guidelines:
 * 1. Prefer normal flow (static/relative positioning)
 * 2. Use flexbox/grid instead of absolute positioning
 * 3. If absolute positioning required, ensure content reflows
 * 4. Test at multiple zoom levels and viewport sizes
 */

/* === PREFER NORMAL DOCUMENT FLOW === */

/* Default positioning for most elements */
* {
  position: static;              /* Default: normal flow */
}

/* Relative positioning is safe (stays in flow) */
.relative {
  position: relative;            /* Creates positioning context */
}

/* === SAFE ABSOLUTE POSITIONING PATTERNS === */

/* Absolutely positioned element within relative container */
.positioned-container {
  position: relative;            /* Positioning context */
  padding: 1rem;                 /* Space for absolute children */
}

.positioned-child {
  position: absolute;
  /* Must specify where positioned */
  top: 0;
  right: 0;
  /* Or bottom/left as needed */
}

/* Ensure absolute elements don't obscure content */
.positioned-container {
  padding-top: 3rem;             /* Make room if child is top-positioned */
  /* Adjust based on child size and position */
}

/* === ICON POSITIONING (COMMON USE CASE) === */

/* Icon inside button/link */
.button-with-icon {
  position: relative;
  padding-left: 2.5rem;          /* Space for icon */
}

.button-with-icon .icon {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);   /* Center vertically */
}

/* Close button on modals/alerts */
.modal,
.alert {
  position: relative;
  padding: 1rem;
  padding-top: 3rem;             /* Space for close button */
}

.close-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  /* min-height: 24px from Interactive Element Sizing */
}

/* === BADGE/NOTIFICATION POSITIONING === */

/* Badge on avatar or icon */
.badge-container {
  position: relative;
  display: inline-block;
}

.badge {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  min-width: 1.25rem;
  min-height: 1.25rem;
  border-radius: 50%;
  /* Badge is supplementary, not critical content */
}

/* === DROPDOWN MENUS === */

/* Dropdown wrapper */
.dropdown {
  position: relative;
}

/* Dropdown menu */
.dropdown-menu {
  position: absolute;
  top: 100%;                     /* Below trigger */
  left: 0;
  z-index: 1000;
  min-width: 200px;
  max-width: 100vw;              /* Don't exceed viewport */
  background: #ffffff;
  border: 1px solid var(--input-border, #767676);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Dropdown right-aligned */
.dropdown-menu-right {
  left: auto;
  right: 0;
}

/* Responsive: dropdowns go full-width on mobile */
@media (max-width: 767px) {
  .dropdown-menu {
    position: static;            /* Remove absolute positioning */
    width: 100%;
    max-width: 100%;
  }
}

/* === TOOLTIPS === */

/* Tooltip container */
.tooltip-container {
  position: relative;
  display: inline-block;
}

/* Tooltip */
.tooltip,
[role="tooltip"] {
  position: absolute;
  z-index: 1001;
  bottom: 100%;                  /* Above trigger */
  left: 50%;
  transform: translateX(-50%);   /* Center horizontally */
  max-width: 300px;
  min-width: 150px;
  padding: 0.5rem;
  background: #333333;
  color: #ffffff;
  border-radius: 4px;
  white-space: normal;           /* Allow wrapping */
  word-wrap: break-word;
}

/* Tooltip arrow */
.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #333333;
}

/* Tooltip adjusts position if off-screen */
.tooltip-bottom {
  bottom: auto;
  top: 100%;                     /* Below trigger instead */
}

.tooltip-bottom::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #333333;
}

/* Mobile: tooltips become static */
@media (max-width: 767px) {
  .tooltip,
  [role="tooltip"] {
    position: static;
    transform: none;
    display: block;
    margin-top: 0.5rem;
  }

  .tooltip::after {
    display: none;               /* No arrow needed */
  }
}

/* === MODALS AND OVERLAYS === */

/* Modal overlay (covers entire viewport) */
.modal-overlay {
  position: fixed;               /* Fixed is acceptable for overlays */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;              /* Allow scrolling if modal is tall */
}

/* Modal dialog */
.modal-dialog {
  position: relative;            /* Not absolute, positioned by flex parent */
  max-width: 600px;
  width: 90%;                    /* Responsive width */
  max-height: 90vh;              /* Don't exceed viewport */
  overflow-y: auto;              /* Scroll if content is tall */
  background: #ffffff;
  padding: 2rem;
  margin: 2rem auto;
}

/* Ensure modal is keyboard accessible */
.modal-dialog:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

/* === STICKY POSITIONING (SAFER ALTERNATIVE) === */

/* Sticky headers/navigation */
.sticky-header {
  position: sticky;              /* Sticky is safer than fixed */
  top: 0;
  z-index: 100;
  background: #ffffff;
}

/* Sticky navigation */
.sticky-nav {
  position: sticky;
  top: 0;
  z-index: 99;
}

/* Sticky sidebar */
.sticky-sidebar {
  position: sticky;
  top: 2rem;                     /* Offset from top */
  align-self: flex-start;        /* In flex container */
}

/* Mobile: remove sticky behavior */
@media (max-width: 767px) {
  .sticky-header,
  .sticky-nav,
  .sticky-sidebar {
    position: static;            /* Normal flow on mobile */
  }
}

/* === FIXED POSITIONING - USE SPARINGLY === */

/* Fixed position can obscure content at zoom */
/* Use only for critical UI elements */

/* Skip link (always visible) */
.skip-link {
  position: fixed;               /* Fixed is acceptable here */
  top: 0;
  left: 0;
  z-index: 9999;
  transform: translateY(-100%);  /* Off-screen by default */
}

.skip-link:focus {
  transform: translateY(0);      /* Visible on focus */
}

/* Floating action button */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  /* min-height: 24px from Interactive Element Sizing */
  /* Actually FABs are typically 48-56px for touch targets */
  min-width: 48px;
  min-height: 48px;
}

/* Mobile: fixed elements can be problematic */
@media (max-width: 767px) {
  .fab {
    bottom: 1rem;
    right: 1rem;
    /* Ensure doesn't obscure content */
  }
}

/* === PREVENT CONTENT OVERLAP === */

/* When using absolute positioning, parent must reserve space */
.has-absolute-child {
  position: relative;
  /* Add padding/margin to prevent overlap */
  padding-top: 3rem;             /* Example for top-positioned child */
}

/* Z-index layering (avoid conflicts) */
:root {
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-modal: 1030;
  --z-tooltip: 1040;
  --z-notification: 1050;
}

.dropdown-menu { z-index: var(--z-dropdown); }
.sticky-header { z-index: var(--z-sticky); }
.modal-overlay { z-index: var(--z-modal); }
.tooltip { z-index: var(--z-tooltip); }
.notification { z-index: var(--z-notification); }

/* === AVOID COMMON PITFALLS === */

/* BAD: Absolute positioning without relative parent */
/* NEVER do this:
.bad-absolute {
  position: absolute;
  top: 20px;
  right: 20px;
}
*/
/* This positions relative to viewport, breaks at different sizes */

/* GOOD: Absolute within relative parent */
.good-parent {
  position: relative;
}

.good-absolute {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

/* BAD: Fixed positioning that obscures content */
/* AVOID this:
.bad-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100px;
}
*/
/* Body content will be hidden under this */

/* GOOD: Sticky positioning or body padding */
.good-sticky {
  position: sticky;
  top: 0;
}

body.has-fixed-header {
  padding-top: 100px;            /* Make room for fixed header */
}

/* === FLEXBOX/GRID ALTERNATIVES === */

/* Instead of absolute positioning for layout, use flex/grid */

/* BAD: Absolute positioning for columns */
/* AVOID this pattern */

/* GOOD: Flexbox for columns */
.flex-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.flex-layout > .column {
  flex: 1 1 calc(50% - 0.5rem);
  min-width: 300px;
}

/* GOOD: Grid for layout */
.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

/* === RESPONSIVE CONSIDERATIONS === */

/* Absolute positioning often needs adjustment at different breakpoints */

@media (max-width: 767px) {
  /* Convert absolute to static on mobile when appropriate */
  .mobile-static {
    position: static !important;
  }

  /* Reduce z-index stacking on mobile */
  .modal-overlay {
    z-index: 999;
  }
}

/* === TESTING CHECKLIST === */

/**
 * When using absolute/fixed positioning:
 *
 * ✓ Test at 320px viewport width
 * ✓ Test at 400% zoom
 * ✓ Ensure no content is obscured or inaccessible
 * ✓ Check keyboard navigation still works
 * ✓ Verify focus indicators visible
 * ✓ Test with screen reader
 * ✓ Ensure positioned elements have proper contrast
 * ✓ Check that positioned elements don't break on text resize
 * ✓ Verify touch targets meet 24x24px minimum
 * ✓ Consider mobile-first approach (static → absolute)
 */

/* Motion & Animation (WCAG 2.3.3, 2.2.2)
 * Respect user motion preferences and provide controls */

/**
 * WCAG Requirements:
 * - 2.3.3 Animation from Interactions (AAA): Motion triggered by interaction
 *   can be disabled unless essential to functionality
 * - 2.2.2 Pause, Stop, Hide (A): Moving, blinking, scrolling content that
 *   lasts more than 5 seconds can be paused, stopped, or hidden
 * - Vestibular disorders: Motion can cause nausea, dizziness, headaches
 *
 * Subsections to cover:
 */

/* Prefers-Reduced-Motion Media Query
 * Primary mechanism for respecting user motion preferences */

/**
 * The prefers-reduced-motion media query detects OS-level accessibility settings:
 * - Windows: Settings > Ease of Access > Display > Show animations
 * - macOS: System Preferences > Accessibility > Display > Reduce motion
 * - iOS/Android: Similar accessibility settings
 *
 * When user enables "reduce motion", this media query matches and we should:
 * - Remove or significantly reduce animations
 * - Use instant state changes instead of transitions
 * - Provide static alternatives to animated content
 *
 * Default approach: Assume motion is OKAY, then override for reduced-motion
 */

/* === GLOBAL MOTION RESET === */

/**
 * Nuclear option: Disable ALL animations for reduced-motion users
 * This is the safest baseline approach
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/**
 * Why 0.01ms instead of 0s?
 * - Some browsers/libraries check for animation-duration: 0 as "no animation set"
 * - Using 0.01ms triggers the animation but completes essentially instantly
 * - Ensures JavaScript event listeners still fire (animationend, transitionend)
 */

/* === SELECTIVE MOTION PRESERVATION === */

/**
 * Alternative approach: Keep some subtle animations even in reduced-motion
 * Only use for truly essential or very subtle effects
 */

/* Safe animations that can remain (opacity, color) */
@media (prefers-reduced-motion: reduce) {
  .safe-fade {
    /* Opacity transitions are generally safe */
    transition: opacity 0.15s ease-in-out !important;
    /* But remove any transform/translate */
    transform: none !important;
  }

  .safe-color {
    /* Color transitions are safe */
    transition: color 0.15s ease-in-out,
                background-color 0.15s ease-in-out !important;
  }
}

/* === MOTION-SAFE MEDIA QUERY === */

/**
 * Modern alternative: Use @media (prefers-reduced-motion: no-preference)
 * to ONLY apply animations when motion is safe
 *
 * This is the "progressive enhancement" approach:
 * - Start with no animations (works for everyone)
 * - Add animations ONLY for users who are okay with motion
 */

/* Example: Only animate when motion is safe */
@media (prefers-reduced-motion: no-preference) {
  .animated-element {
    transition: transform 0.3s ease-in-out;
  }

  .animated-element:hover {
    transform: translateY(-4px);
  }
}

/* When motion should be reduced, no animation happens */
@media (prefers-reduced-motion: reduce) {
  .animated-element:hover {
    /* Instant state change, no animation */
    transform: none;
    /* Could apply other non-motion feedback like color change */
    background-color: #f0f0f0;
  }
}

/* === SCROLL BEHAVIOR === */

/**
 * Smooth scrolling can be problematic for vestibular disorders
 * Disable for reduced-motion users
 */

/* Enable smooth scroll by default */
html {
  scroll-behavior: smooth;
}

/* Disable smooth scroll for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* === ANIMATION PLAY STATE === */

/**
 * For CSS animations that are already running,
 * pause them when reduced-motion is preferred
 */

/* Running animation by default */
.animated-background {
  animation: background-shift 10s ease-in-out infinite;
}

/* Pause animation for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .animated-background {
    animation-play-state: paused;
    /* Or remove entirely */
    animation: none;
  }
}

/* === FOCUS INDICATORS === */

/**
 * Focus indicators should remain visible even with reduced-motion
 * But the transition to focus state can be instant
 */

/* Default: smooth transition to focus state */
a:focus,
button:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
  transition: outline-offset 0.15s ease-in-out;
}

/* Reduced motion: instant focus state */
@media (prefers-reduced-motion: reduce) {
  a:focus,
  button:focus {
    transition: none;
  }
}

/* === LOADING STATES === */

/**
 * Loading indicators need special handling
 * Provide static alternative for reduced-motion
 */

/* Animated spinner (default) */
.loading-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Static loading indicator for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
    /* Show pulsing opacity instead */
    animation: pulse-opacity 2s ease-in-out infinite;
  }

  @keyframes pulse-opacity {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
  }
}

/* Or completely static alternative */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner.static-only {
    animation: none;
    opacity: 0.7; /* Just show static dimmed state */
  }
}

/* === PARALLAX EFFECTS === */

/**
 * Parallax is a major vestibular trigger
 * MUST be disabled for reduced-motion
 */

/* Parallax enabled by default */
.parallax-layer {
  transform: translateY(var(--parallax-offset));
  transition: transform 0.1s linear;
}

/* Disable parallax for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .parallax-layer {
    transform: none !important;
    transition: none !important;
  }
}

/* === VIDEO AUTOPLAY === */

/**
 * Autoplaying video can be problematic
 * Consider pausing for reduced-motion users
 * Note: This requires JavaScript, but CSS can hide controls
 */

/* Show pause control prominently for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .video-pause-control {
    display: block !important;
    /* Make it very visible */
    font-size: 1.2em;
    font-weight: bold;
  }
}

/* === HOVER EFFECTS === */

/**
 * Subtle hover effects can remain, but remove motion components
 */

/* Default: lift effect on hover */
.card {
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

/* Reduced motion: only shadow change, no transform */
@media (prefers-reduced-motion: reduce) {
  .card {
    transition: box-shadow 0.2s ease-in-out;
  }

  .card:hover {
    transform: none;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  }
}

/* === TESTING SUPPORT === */

/**
 * Utility class to test reduced-motion styles
 * Can be toggled via JavaScript for testing
 */

/* Simulate reduced-motion for testing */
.force-reduced-motion,
.force-reduced-motion *,
.force-reduced-motion *::before,
.force-reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* === JAVASCRIPT DETECTION === */

/**
 * For cases where CSS alone isn't enough,
 * JavaScript can detect the preference:
 *
 * const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
 *
 * if (prefersReducedMotion.matches) {
 *   // User prefers reduced motion
 *   // Disable complex animations
 *   // Pause autoplaying content
 * }
 *
 * // Listen for changes
 * prefersReducedMotion.addEventListener('change', (e) => {
 *   if (e.matches) {
 *     // User just enabled reduced motion
 *   }
 * });
 */

/* === BROWSER SUPPORT === */

/**
 * Browser support (as of 2024):
 * - Chrome/Edge: 74+ (April 2019)
 * - Firefox: 63+ (October 2018)
 * - Safari: 10.1+ (March 2017)
 * - iOS Safari: 10.3+ (March 2017)
 *
 * Excellent support - safe to use without fallback
 * Older browsers ignore the media query (animations run normally)
 */

/* === BEST PRACTICES SUMMARY === */

/**
 * Recommended approach:
 *
 * 1. Use global reset (@media prefers-reduced-motion: reduce) for all animations
 * 2. OR use progressive enhancement (only animate with no-preference)
 * 3. Keep essential focus indicators (but instant transition)
 * 4. Provide static alternatives for loading indicators
 * 5. Remove all parallax and large motion effects
 * 6. Keep subtle color/opacity transitions if desired
 * 7. Test with OS motion settings enabled
 * 8. Use JavaScript for complex animation controls
 */

/* Safe Animation Defaults
 * Animations that are generally safe for all users */

/**
 * Not all animations trigger vestibular disorders
 * Safe animation types:
 * - Opacity changes (fade in/out)
 * - Color transitions
 * - Small scale changes (< 10% size change)
 * - Very short durations (< 0.2s)
 *
 * UNSAFE animation types (avoid or disable for reduced-motion):
 * - Large movements (sliding, flying in)
 * - Rotation (spinning, flipping)
 * - Parallax effects
 * - Continuous/infinite motion
 * - Scaling > 10%
 * - Any motion that simulates 3D space
 */

/* === OPACITY TRANSITIONS (SAFEST) === */

/**
 * Fading is the safest animation type
 * Causes minimal vestibular disruption
 */

/* Fade in/out - safe for all users */
.fade {
  transition: opacity 0.15s ease-in-out;
}

.fade-in {
  opacity: 0;
  animation: fadeIn 0.3s ease-in forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-out {
  opacity: 1;
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Cross-fade between states */
.cross-fade {
  transition: opacity 0.2s ease-in-out;
}

/* Subtle opacity pulse (very gentle) */
.pulse-subtle {
  animation: pulseSubtle 2s ease-in-out infinite;
}

@keyframes pulseSubtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* Even these safe animations should respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .fade-out {
    animation: none;
    opacity: 1; /* Show immediately */
  }

  .pulse-subtle {
    animation: none;
    opacity: 1; /* Static */
  }
}

/* === COLOR TRANSITIONS (SAFE) === */

/**
 * Color changes are generally safe
 * No spatial movement = no vestibular trigger
 */

/* Background color transition */
.color-transition {
  transition: background-color 0.2s ease-in-out,
              color 0.2s ease-in-out;
}

/* Border color transition */
.border-transition {
  transition: border-color 0.2s ease-in-out;
}

/* Safe for hover states */
.safe-hover {
  background-color: #ffffff;
  transition: background-color 0.15s ease-in-out;
}

.safe-hover:hover {
  background-color: #f0f0f0;
}

/* Color pulse (safe continuous animation) */
.color-pulse {
  animation: colorPulse 3s ease-in-out infinite;
}

@keyframes colorPulse {
  0%, 100% { background-color: #e3f2fd; }
  50% { background-color: #bbdefb; }
}

/* These are safe but still should be instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .color-transition,
  .border-transition,
  .safe-hover {
    transition-duration: 0.01ms;
  }

  .color-pulse {
    animation: none;
    background-color: #e3f2fd; /* Static color */
  }
}

/* === SMALL SCALE CHANGES (CAUTIOUS) === */

/**
 * Very small scale changes (< 1.1x) are generally acceptable
 * Larger scaling can trigger motion sensitivity
 */

/* Subtle scale on hover (< 10% change) */
.scale-subtle {
  transition: transform 0.15s ease-in-out;
}

.scale-subtle:hover {
  transform: scale(1.05); /* Only 5% larger */
}

/* Subtle shrink on active/click */
.scale-active {
  transition: transform 0.1s ease-in-out;
}

.scale-active:active {
  transform: scale(0.97); /* Slight press effect */
}

/* Remove all scaling for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .scale-subtle:hover,
  .scale-active:active {
    transform: none;
  }
}

/* === BOX SHADOW TRANSITIONS (SAFE) === */

/**
 * Shadow changes don't involve motion
 * Safe alternative to transform animations
 */

/* Shadow transition for depth */
.shadow-transition {
  transition: box-shadow 0.2s ease-in-out;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.shadow-transition:hover {
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

/* Glow effect (safe) */
.glow-transition {
  transition: box-shadow 0.2s ease-in-out;
}

.glow-transition:focus {
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Safe for reduced-motion (just make instant) */
@media (prefers-reduced-motion: reduce) {
  .shadow-transition,
  .glow-transition {
    transition-duration: 0.01ms;
  }
}

/* === BORDER TRANSITIONS (SAFE) === */

/**
 * Border width, style, color changes are safe
 */

/* Border width transition */
.border-grow {
  border: 1px solid #ccc;
  transition: border-width 0.15s ease-in-out;
}

.border-grow:hover {
  border-width: 2px;
}

/* Underline animation (border-bottom) */
.underline-transition {
  border-bottom: 2px solid transparent;
  transition: border-bottom-color 0.2s ease-in-out;
}

.underline-transition:hover {
  border-bottom-color: var(--link-color, #0066cc);
}

/* Safe for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .border-grow,
  .underline-transition {
    transition-duration: 0.01ms;
  }
}

/* === WIDTH/HEIGHT TRANSITIONS (CAUTIOUS) === */

/**
 * Width/height changes can be safe if:
 * - Change is small (< 20%)
 * - Duration is short (< 0.2s)
 * - Not continuous/looping
 */

/* Progress bar fill (safe horizontal growth) */
.progress-bar {
  width: 0;
  transition: width 0.3s ease-out;
}

.progress-bar.filled {
  width: 100%;
}

/* Expand/collapse content (vertical motion) */
.expandable {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

.expandable.expanded {
  max-height: 500px; /* Or auto with JavaScript */
}

/* Disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .expandable {
    transition: none;
  }

  .expandable.expanded {
    max-height: none; /* Show immediately */
  }
}

/* === SAFE TIMING FUNCTIONS === */

/**
 * Timing functions affect perception of motion
 * Linear feels more mechanical/harsh
 * Ease functions feel more natural
 */

:root {
  /* Safe easing curves */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Gentler easings for motion-sensitive users */
  --ease-gentle: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Use gentle easing by default */
.safe-animation {
  transition-timing-function: var(--ease-gentle);
}

/* === SAFE DURATION GUIDELINES === */

/**
 * Duration recommendations:
 * - 0.1s - 0.15s: Very quick (buttons, links)
 * - 0.15s - 0.3s: Standard (most transitions)
 * - 0.3s - 0.5s: Slower (complex state changes)
 * - > 0.5s: Avoid (feels sluggish, can trigger discomfort)
 *
 * Shorter is generally safer
 */

:root {
  --duration-instant: 0.1s;
  --duration-fast: 0.15s;
  --duration-normal: 0.2s;
  --duration-slow: 0.3s;
  --duration-slower: 0.5s;
}

/* Quick interactions */
.quick-transition {
  transition-duration: var(--duration-fast);
}

/* Standard transitions */
.normal-transition {
  transition-duration: var(--duration-normal);
}

/* === SAFE COMBINATION ANIMATIONS === */

/**
 * Combining safe animation types
 * Opacity + color = safe
 * Opacity + small scale = borderline (use cautiously)
 */

/* Fade + color change (safe) */
.fade-color {
  transition: opacity 0.2s ease-in-out,
              background-color 0.2s ease-in-out;
}

/* Fade + very small scale (use cautiously) */
.fade-scale-subtle {
  transition: opacity 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.fade-scale-subtle:hover {
  opacity: 0.9;
  transform: scale(1.03); /* Very subtle */
}

/* Remove transforms for reduced-motion, keep opacity/color */
@media (prefers-reduced-motion: reduce) {
  .fade-scale-subtle {
    transition: opacity 0.01ms,
                background-color 0.01ms;
  }

  .fade-scale-subtle:hover {
    transform: none;
  }
}

/* === SAFE LOADING ANIMATIONS === */

/**
 * Loading indicators that are relatively safe
 * Pulsing opacity > spinning
 */

/* Pulsing dots (safer than spinner) */
.loading-dots {
  display: inline-flex;
  gap: 0.5rem;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--button-bg, #0066cc);
  animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Static for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .loading-dots span {
    animation: none;
    opacity: 0.7; /* Static medium opacity */
  }
}

/* === SAFE FOCUS ANIMATIONS === */

/**
 * Focus indicators can use safe animations
 * But must remain visible even if animation is disabled
 */

/* Focus with outline growth (safe) */
.focus-safe {
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s ease-in-out;
}

.focus-safe:focus {
  outline-color: var(--button-bg, #0066cc);
}

/* Focus glow (safe) */
.focus-glow {
  transition: box-shadow 0.15s ease-in-out;
}

.focus-glow:focus {
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Instant for reduced-motion, but still visible */
@media (prefers-reduced-motion: reduce) {
  .focus-safe,
  .focus-glow {
    transition: none;
  }
}

/* === GUIDELINES SUMMARY === */

/**
 * Safe Animation Checklist:
 *
 * ✓ SAFE (minimal or no reduction needed):
 *   - Opacity changes (fade)
 *   - Color transitions
 *   - Box shadow changes
 *   - Border changes
 *   - Very small scale (< 1.1x)
 *
 * ⚠ CAUTIOUS (consider disabling for reduced-motion):
 *   - Small transforms (< 10px movement)
 *   - Moderate scale changes (1.1x - 1.3x)
 *   - Width/height transitions
 *   - Rotate < 45 degrees
 *
 * ✗ UNSAFE (must disable for reduced-motion):
 *   - Large movements (sliding, flying)
 *   - Spinning/rotation
 *   - Parallax
 *   - Continuous motion
 *   - 3D transforms
 *   - Scale > 1.3x
 *   - Anything > 0.5s duration
 *
 * Default stance: When in doubt, disable for reduced-motion
 */

/* Transition Properties
 * CSS transitions for interactive states and UI feedback */

/**
 * Transitions provide smooth state changes for interactive elements
 * Applied to: hover, focus, active, disabled states
 *
 * Best practices:
 * - Keep durations short (0.1s - 0.3s)
 * - Transition specific properties, not "all"
 * - Use appropriate easing functions
 * - Always respect reduced-motion preference
 */

/* === BASIC TRANSITION SYNTAX === */

/**
 * transition: property duration timing-function delay;
 *
 * Examples:
 * transition: background-color 0.2s ease-in-out;
 * transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
 * transition: opacity 0.15s ease-out, color 0.15s ease-out;
 */

/* === BUTTON TRANSITIONS === */

/* Standard button transitions */
button,
[type="button"],
[type="submit"],
[type="reset"],
[role="button"] {
  transition: background-color 0.15s ease-in-out,
              color 0.15s ease-in-out,
              border-color 0.15s ease-in-out,
              box-shadow 0.15s ease-in-out;
}

/* Button hover state */
button:hover {
  background-color: var(--button-hover-bg, #0052a3);
}

/* Button active/pressed state */
button:active {
  /* Instant feedback - very short duration */
  transition-duration: 0.1s;
}

/* Button focus state */
button:focus {
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Disabled buttons - no transition needed */
button:disabled {
  transition: none;
  cursor: not-allowed;
}

/* Remove transitions for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  button,
  [type="button"],
  [type="submit"],
  [type="reset"],
  [role="button"] {
    transition: none;
  }
}

/* === LINK TRANSITIONS === */

/* Link color and underline transitions */
a {
  transition: color 0.15s ease-in-out,
              background-color 0.15s ease-in-out,
              border-bottom-color 0.15s ease-in-out;
}

/* Link hover */
a:hover {
  color: var(--link-hover, #004999);
}

/* Link with underline animation */
a.underline-animate {
  border-bottom: 2px solid transparent;
  transition: border-bottom-color 0.2s ease-in-out;
}

a.underline-animate:hover {
  border-bottom-color: currentColor;
}

/* Remove for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  a,
  a.underline-animate {
    transition: none;
  }
}

/* === FORM INPUT TRANSITIONS === */

/* Text inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
textarea {
  transition: border-color 0.15s ease-in-out,
              box-shadow 0.15s ease-in-out,
              background-color 0.15s ease-in-out;
}

/* Input focus state */
input:focus,
textarea:focus {
  border-color: var(--input-border-focus, #0066cc);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* Input error state */
input.error,
textarea.error {
  border-color: #d32f2f;
}

input.error:focus,
textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

/* Select dropdowns */
select {
  transition: border-color 0.15s ease-in-out,
              background-color 0.15s ease-in-out;
}

/* Checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
  transition: background-color 0.15s ease-in-out,
              border-color 0.15s ease-in-out;
}

/* Remove for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  input,
  textarea,
  select {
    transition: none;
  }
}

/* === FOCUS INDICATOR TRANSITIONS === */

/* Universal focus transition */
*:focus {
  transition: outline-color 0.15s ease-in-out,
              outline-offset 0.15s ease-in-out,
              box-shadow 0.15s ease-in-out;
}

/* Focus visible (keyboard navigation only) */
*:focus-visible {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

/* Remove for reduced-motion but keep outline visible */
@media (prefers-reduced-motion: reduce) {
  *:focus,
  *:focus-visible {
    transition: none;
  }
}

/* === CARD AND BOX TRANSITIONS === */

/* Card hover effects */
.card {
  transition: box-shadow 0.2s ease-in-out,
              border-color 0.2s ease-in-out;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card:hover {
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

/* Interactive card (clickable) */
.card-interactive {
  transition: box-shadow 0.2s ease-in-out,
              background-color 0.2s ease-in-out;
  cursor: pointer;
}

.card-interactive:hover {
  background-color: #f9f9f9;
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.card-interactive:active {
  background-color: #f0f0f0;
}

/* Remove for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .card,
  .card-interactive {
    transition: none;
  }
}

/* === NAVIGATION TRANSITIONS === */

/* Nav link transitions */
nav a {
  transition: color 0.15s ease-in-out,
              background-color 0.15s ease-in-out;
}

nav a:hover {
  background-color: rgba(0, 102, 204, 0.1);
}

nav a.active {
  border-bottom: 2px solid var(--link-color, #0066cc);
}

/* Dropdown menu transitions */
.dropdown-menu {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out,
              visibility 0.2s ease-in-out;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
}

/* Remove for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  nav a {
    transition: none;
  }

  .dropdown-menu {
    transition: none;
    /* Show/hide instantly */
  }

  .dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
  }
}

/* === ACCORDION/COLLAPSIBLE TRANSITIONS === */

/* Accordion header */
.accordion-header {
  transition: background-color 0.15s ease-in-out;
}

.accordion-header:hover {
  background-color: #f5f5f5;
}

/* Accordion content */
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out,
              opacity 0.3s ease-in-out;
  opacity: 0;
}

.accordion-content.expanded {
  max-height: 1000px; /* Large enough for content */
  opacity: 1;
}

/* Instant expand/collapse for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .accordion-content {
    transition: none;
  }

  .accordion-content.expanded {
    max-height: none;
    opacity: 1;
  }
}

/* === TAB TRANSITIONS === */

/* Tab buttons */
.tab-button {
  transition: color 0.15s ease-in-out,
              border-bottom-color 0.15s ease-in-out,
              background-color 0.15s ease-in-out;
  border-bottom: 3px solid transparent;
}

.tab-button:hover {
  background-color: #f5f5f5;
}

.tab-button.active {
  border-bottom-color: var(--link-color, #0066cc);
  color: var(--link-color, #0066cc);
}

/* Tab panels (content) */
.tab-panel {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out,
              visibility 0.2s ease-in-out;
}

.tab-panel.active {
  opacity: 1;
  visibility: visible;
}

/* Remove for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .tab-button,
  .tab-panel {
    transition: none;
  }

  .tab-panel.active {
    opacity: 1;
    visibility: visible;
  }
}

/* === MODAL/DIALOG TRANSITIONS === */

/* Modal overlay fade */
.modal-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out,
              visibility 0.2s ease-in-out;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Modal dialog (no transform, just fade) */
.modal-dialog {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.modal-overlay.open .modal-dialog {
  opacity: 1;
}

/* Instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-dialog {
    transition: none;
  }

  .modal-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  .modal-overlay.open .modal-dialog {
    opacity: 1;
  }
}

/* === ALERT/NOTIFICATION TRANSITIONS === */

/* Alert fade in */
.alert {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.alert.show {
  opacity: 1;
}

/* Toast notification slide + fade */
.toast {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.toast.show {
  opacity: 1;
}

/* Remove slide for reduced-motion, keep fade */
@media (prefers-reduced-motion: reduce) {
  .alert,
  .toast {
    transition: opacity 0.01ms;
  }
}

/* === PROGRESS INDICATOR TRANSITIONS === */

/* Progress bar fill */
.progress-bar {
  transition: width 0.3s ease-out;
}

/* Progress ring/circle (SVG stroke) */
.progress-circle {
  transition: stroke-dashoffset 0.3s ease-out;
}

/* Instant progress for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .progress-bar,
  .progress-circle {
    transition: none;
  }
}

/* === TOOLTIP TRANSITIONS === */

/* Tooltip fade in */
.tooltip {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease-in-out,
              visibility 0.15s ease-in-out;
}

.tooltip-trigger:hover .tooltip,
.tooltip-trigger:focus .tooltip {
  opacity: 1;
  visibility: visible;
}

/* Instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .tooltip {
    transition: none;
  }

  .tooltip-trigger:hover .tooltip,
  .tooltip-trigger:focus .tooltip {
    opacity: 1;
    visibility: visible;
  }
}

/* === BADGE TRANSITIONS === */

/* Badge appearance */
.badge {
  transition: background-color 0.15s ease-in-out,
              color 0.15s ease-in-out;
}

/* Notification dot pulse */
.notification-dot {
  transition: opacity 0.15s ease-in-out;
}

/* Remove for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .badge,
  .notification-dot {
    transition: none;
  }
}

/* === SKELETON LOADING TRANSITIONS === */

/* Skeleton screen pulse */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  transition: opacity 0.3s ease-in-out;
}

.skeleton.loaded {
  opacity: 0;
}

/* Remove animation for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    background: #f0f0f0; /* Static color */
    transition: none;
  }
}

/* === IMAGE TRANSITIONS === */

/* Image lazy load fade in */
img {
  transition: opacity 0.3s ease-in-out;
}

img[loading="lazy"] {
  opacity: 0;
}

img[loading="lazy"].loaded {
  opacity: 1;
}

/* Instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  img {
    transition: none;
  }

  img[loading="lazy"].loaded {
    opacity: 1;
  }
}

/* === TRANSITION DELAY PATTERNS === */

/* Staggered transitions (use sparingly) */
.stagger-item:nth-child(1) { transition-delay: 0s; }
.stagger-item:nth-child(2) { transition-delay: 0.05s; }
.stagger-item:nth-child(3) { transition-delay: 0.1s; }
.stagger-item:nth-child(4) { transition-delay: 0.15s; }
.stagger-item:nth-child(5) { transition-delay: 0.2s; }

/* Remove stagger for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .stagger-item {
    transition-delay: 0s !important;
  }
}

/* === TRANSITION BEST PRACTICES === */

/**
 * Guidelines for transitions:
 *
 * ✓ DO:
 *   - Transition specific properties (background-color, opacity)
 *   - Keep durations short (0.1s - 0.3s)
 *   - Use ease-in-out for most cases
 *   - Provide instant feedback for active states
 *   - Always include reduced-motion override
 *
 * ✗ DON'T:
 *   - Use "transition: all" (performance issues)
 *   - Make transitions longer than 0.5s
 *   - Transition layout properties (width, height, margin) if avoidable
 *   - Forget to test with reduced-motion enabled
 *   - Transition properties that trigger reflow (position, float, display)
 *
 * Performance note:
 * Best properties to transition (GPU-accelerated):
 * - opacity
 * - transform
 *
 * Avoid transitioning (causes reflow/repaint):
 * - width, height
 * - margin, padding
 * - top, left, right, bottom (with absolute/fixed positioning)
 */

/* === TRANSITION PROPERTY PERFORMANCE === */

/* GOOD: GPU-accelerated properties */
.performant-transition {
  transition: opacity 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

/* ACCEPTABLE: Composite properties (some GPU acceleration) */
.acceptable-transition {
  transition: background-color 0.2s ease-in-out,
              color 0.2s ease-in-out,
              box-shadow 0.2s ease-in-out;
}

/* AVOID: Layout-triggering properties */
.avoid-transition {
  /* These cause expensive reflows */
  /* transition: width 0.2s, height 0.2s, margin 0.2s; */
}

/* CSS Animations and Keyframes
 * @keyframes animations for complex motion sequences */

/**
 * CSS animations use @keyframes to define multi-step animations
 * More complex than transitions, used for:
 * - Loading indicators
 * - Attention-seeking effects
 * - Entrance/exit animations
 * - Looping animations
 *
 * CRITICAL: All animations must respect prefers-reduced-motion
 */

/* === LOADING SPINNER ANIMATIONS === */

/* Rotating spinner (common loading indicator) */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--button-bg, #0066cc);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Static alternative for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--button-bg, #0066cc);
    border-right-color: var(--button-bg, #0066cc);
    /* Show static "loading" state */
  }
}

/* === PULSING ANIMATIONS (SAFER) === */

/* Pulse opacity (safe loading indicator) */
.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Allow gentle pulse for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .pulse {
    animation: none;
    opacity: 0.7; /* Static medium opacity */
  }
}

/* Pulse scale (use cautiously) */
.pulse-scale {
  animation: pulseScale 2s ease-in-out infinite;
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* Remove scale for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .pulse-scale {
    animation: none;
    transform: scale(1);
    opacity: 0.8;
  }
}

/* === BOUNCING ANIMATIONS (AVOID OR DISABLE) === */

/* Bounce animation - vestibular trigger */
.bounce {
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

/* MUST disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .bounce {
    animation: none;
    transform: translateY(0);
  }
}

/* === SHAKE ANIMATIONS (ATTENTION-SEEKING) === */

/* Shake for error feedback */
.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80% { transform: translateX(10px); }
}

/* Disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .shake {
    animation: none;
    /* Could use color change instead */
    border-color: #d32f2f;
  }
}

/* === FADE ANIMATIONS === */

/* Fade in (safe) */
.fade-in {
  animation: fadeIn 0.3s ease-in forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Fade out */
.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Keep fades but make instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .fade-out {
    animation-duration: 0.01ms;
  }
}

/* === SLIDE ANIMATIONS (USE CAUTIOUSLY) === */

/* Slide in from right */
.slide-in-right {
  animation: slideInRight 0.4s ease-out forwards;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide in from left */
.slide-in-left {
  animation: slideInLeft 0.4s ease-out forwards;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide in from top */
.slide-in-top {
  animation: slideInTop 0.4s ease-out forwards;
}

@keyframes slideInTop {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Disable slides for reduced-motion, keep fade */
@media (prefers-reduced-motion: reduce) {
  .slide-in-right,
  .slide-in-left,
  .slide-in-top {
    animation: fadeIn 0.01ms ease-out forwards;
  }
}

/* === SCALE ANIMATIONS (USE CAUTIOUSLY) === */

/* Scale up (zoom in) */
.scale-up {
  animation: scaleUp 0.3s ease-out forwards;
}

@keyframes scaleUp {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Scale down (zoom out) */
.scale-down {
  animation: scaleDown 0.3s ease-in forwards;
}

@keyframes scaleDown {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.8);
    opacity: 0;
  }
}

/* Remove scale for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .scale-up,
  .scale-down {
    animation: fadeIn 0.01ms ease-out forwards;
  }
}

/* === PROGRESS ANIMATIONS === */

/* Progress bar fill animation */
.progress-fill {
  animation: progressFill 2s ease-out forwards;
}

@keyframes progressFill {
  from { width: 0%; }
  to { width: 100%; }
}

/* Indeterminate progress bar */
.progress-indeterminate {
  position: relative;
  overflow: hidden;
}

.progress-indeterminate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 50%;
  height: 100%;
  background: var(--button-bg, #0066cc);
  animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
  0% { left: -50%; }
  100% { left: 100%; }
}

/* Static progress for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .progress-fill {
    animation: none;
    width: 100%;
  }

  .progress-indeterminate::before {
    animation: none;
    left: 0;
    width: 100%;
    opacity: 0.7;
  }
}

/* === SKELETON SCREEN ANIMATIONS === */

/* Skeleton loading shimmer */
.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Static skeleton for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .skeleton-shimmer {
    animation: none;
    background: #f0f0f0;
  }
}

/* === NOTIFICATION/TOAST ANIMATIONS === */

/* Toast slide in from bottom */
.toast-slide-up {
  animation: toastSlideUp 0.3s ease-out forwards;
}

@keyframes toastSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Toast slide out */
.toast-slide-down {
  animation: toastSlideDown 0.3s ease-in forwards;
}

@keyframes toastSlideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* Fade only for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .toast-slide-up {
    animation: fadeIn 0.01ms ease-out forwards;
  }

  .toast-slide-down {
    animation: fadeOut 0.01ms ease-in forwards;
  }
}

/* === ATTENTION-SEEKING ANIMATIONS === */

/* Heartbeat pulse (use very sparingly) */
.heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  10% { transform: scale(1.1); }
  20% { transform: scale(1); }
  30% { transform: scale(1.1); }
  40% { transform: scale(1); }
}

/* Wiggle (attention-seeking) */
.wiggle {
  animation: wiggle 0.5s ease-in-out;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

/* Flash background */
.flash {
  animation: flash 0.5s ease-in-out;
}

@keyframes flash {
  0%, 100% { background-color: transparent; }
  50% { background-color: #fff9c4; }
}

/* Disable attention-seeking for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .heartbeat,
  .wiggle {
    animation: none;
    transform: scale(1) rotate(0deg);
  }

  .flash {
    animation: none;
    /* Could use static highlight color */
    background-color: #fff9c4;
  }
}

/* === TYPING ANIMATION (CURSOR BLINK) === */

/* Blinking cursor */
.typing-cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Static cursor for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .typing-cursor {
    animation: none;
    opacity: 1;
  }
}

/* === DOTTED LOADING ANIMATION === */

/* Three dots loading */
.loading-dots {
  display: inline-flex;
  gap: 0.5rem;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--button-bg, #0066cc);
  animation: dotBounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Static dots for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .loading-dots span {
    animation: none;
    transform: scale(1);
    opacity: 0.7;
  }
}

/* === FLIP ANIMATIONS (AVOID) === */

/* Card flip - vestibular trigger */
.flip {
  animation: flip 0.6s ease-in-out;
}

@keyframes flip {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}

/* MUST disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .flip {
    animation: none;
    transform: rotateY(0deg);
  }
}

/* === ROTATION ANIMATIONS (AVOID) === */

/* Continuous rotation - NOT RECOMMENDED */
.rotate-continuous {
  animation: rotateContinuous 2s linear infinite;
}

@keyframes rotateContinuous {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Absolutely MUST disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .rotate-continuous {
    animation: none;
    transform: rotate(0deg);
  }
}

/* === ANIMATION CONTROL UTILITIES === */

/* Pause animation */
.animation-paused {
  animation-play-state: paused !important;
}

/* Resume animation */
.animation-running {
  animation-play-state: running;
}

/* Stop animation (remove it) */
.animation-none {
  animation: none !important;
}

/* === ANIMATION ITERATION CONTROL === */

/* Run once */
.animate-once {
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

/* Run twice */
.animate-twice {
  animation-iteration-count: 2;
  animation-fill-mode: forwards;
}

/* Loop forever (use sparingly) */
.animate-infinite {
  animation-iteration-count: infinite;
}

/* Remove infinite for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .animate-infinite {
    animation-iteration-count: 1;
  }
}

/* === ANIMATION DELAY PATTERNS === */

/* Staggered entrance animations */
.stagger-animate:nth-child(1) { animation-delay: 0s; }
.stagger-animate:nth-child(2) { animation-delay: 0.1s; }
.stagger-animate:nth-child(3) { animation-delay: 0.2s; }
.stagger-animate:nth-child(4) { animation-delay: 0.3s; }
.stagger-animate:nth-child(5) { animation-delay: 0.4s; }

/* Remove stagger for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .stagger-animate {
    animation-delay: 0s !important;
  }
}

/* === COMBINED ANIMATIONS === */

/* Fade + slide combo */
.fade-slide-up {
  animation: fadeSlideUp 0.4s ease-out forwards;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade only for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .fade-slide-up {
    animation: fadeIn 0.01ms ease-out forwards;
  }
}

/* === ANIMATION BEST PRACTICES === */

/**
 * Keyframe Animation Guidelines:
 *
 * ✓ SAFE to use (with reduced-motion override):
 *   - Fade in/out (opacity only)
 *   - Color changes
 *   - Small scale (< 1.1x)
 *   - Progress indicators (width/height)
 *   - Gentle pulse (opacity)
 *
 * ⚠ CAUTIOUS (disable for reduced-motion):
 *   - Slide animations (small distance)
 *   - Moderate scale (1.1x - 1.3x)
 *   - Shake/wiggle (error feedback)
 *   - Short rotations (< 45deg)
 *
 * ✗ UNSAFE (must disable for reduced-motion):
 *   - Spinning/continuous rotation
 *   - Large slides/movement
 *   - Bounce effects
 *   - Flip/3D transforms
 *   - Parallax
 *   - Infinite loops (except loading indicators)
 *
 * Duration guidelines:
 * - 0.1s - 0.3s: Quick animations
 * - 0.3s - 0.5s: Standard animations
 * - 0.5s - 1s: Slower animations (use rarely)
 * - > 1s: Loading loops only
 *
 * Always provide:
 * - Reduced-motion override (@media query)
 * - Static or fade-only alternative
 * - animation-fill-mode: forwards for entrance/exit
 * - Appropriate easing function
 */

/* Auto-playing Animations
 * Animations that start automatically without user interaction */

/**
 * WCAG 2.2.2 requires that moving, blinking, or scrolling content that:
 * - Starts automatically
 * - Lasts more than 5 seconds
 * - Is presented in parallel with other content
 *
 * Must provide a mechanism to pause, stop, or hide it.
 *
 * Best practices:
 * - Respect prefers-reduced-motion (auto-disable)
 * - Provide visible pause/play controls
 * - Don't auto-play by default (user initiates)
 * - If auto-play required, keep under 5 seconds OR provide controls
 */

/* === CAROUSEL/SLIDESHOW AUTO-PLAY === */

/**
 * Auto-advancing carousels are common accessibility issues
 * Must provide pause control
 */

/* Carousel container */
.carousel {
  position: relative;
}

/* Auto-play is controlled via JavaScript, but CSS can style states */
.carousel[data-autoplay="true"] {
  /* Visual indicator that auto-play is active */
}

.carousel[data-autoplay="false"] {
  /* Visual indicator that auto-play is paused */
}

/* Carousel slides transition */
.carousel-slide {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease-in-out,
              visibility 0.5s ease-in-out;
}

.carousel-slide.active {
  opacity: 1;
  visibility: visible;
}

/* Disable auto-play transitions for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-slide {
    transition: none;
  }

  /* Auto-play should be disabled via JavaScript */
  /* CSS can remove transition effects */
}

/* Pause/play control button (must be visible) */
.carousel-pause-button {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  /* Interactive element sizing from earlier sections */
  min-width: 44px;
  min-height: 44px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.carousel-pause-button:hover {
  background: rgba(0, 0, 0, 0.85);
}

.carousel-pause-button:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Show pause button prominently for reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  .carousel-pause-button {
    /* Make even more visible */
    background: rgba(0, 0, 0, 0.9);
    font-weight: bold;
  }
}

/* === ANIMATED BACKGROUNDS === */

/**
 * Background animations (gradient shifts, particle effects)
 * Should be disabled for reduced-motion
 */

/* Animated gradient background */
.animated-gradient-bg {
  background: linear-gradient(
    270deg,
    #0066cc,
    #00aaff,
    #0066cc
  );
  background-size: 400% 400%;
  animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Static background for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .animated-gradient-bg {
    animation: none;
    background: #0066cc; /* Static color */
  }
}

/* Particle background animation */
.particle-background {
  position: relative;
}

.particle-background::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: url('data:image/svg+xml,...'); /* Particle SVG */
  animation: particleFloat 20s linear infinite;
}

@keyframes particleFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-100%); }
}

/* Remove particles for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .particle-background::before {
    animation: none;
    opacity: 0.3; /* Faint static version */
  }
}

/* === PARALLAX SCROLLING === */

/**
 * Parallax is a MAJOR vestibular trigger
 * Must be completely disabled for reduced-motion
 */

/* Parallax layer (controlled by scroll JavaScript) */
.parallax-layer {
  transition: transform 0.1s linear;
  will-change: transform;
}

.parallax-layer[data-speed="0.5"] {
  /* Moves at half scroll speed */
}

/* Completely disable parallax for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .parallax-layer {
    transform: none !important;
    transition: none !important;
    will-change: auto !important;
  }
}

/* === VIDEO BACKGROUNDS === */

/**
 * Auto-playing video backgrounds
 * Must provide pause control
 */

/* Video background container */
.video-background {
  position: relative;
  overflow: hidden;
}

.video-background video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  z-index: -1;
}

/* Video pause control (must be visible) */
.video-pause-control {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  min-width: 44px;
  min-height: 44px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
}

.video-pause-control:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Show static poster image for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .video-background video {
    /* JavaScript should pause video */
    /* CSS can show poster frame */
    display: none;
  }

  .video-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--video-poster);
    background-size: cover;
    background-position: center;
  }
}

/* === ANIMATED GIFs === */

/**
 * Animated GIFs cannot be paused with CSS alone
 * Need JavaScript or static image alternative
 */

/* GIF container with pause overlay */
.gif-container {
  position: relative;
  display: inline-block;
}

.gif-container img {
  display: block;
  max-width: 100%;
}

/* Pause overlay (controlled by JavaScript) */
.gif-pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  cursor: pointer;
}

.gif-container.paused .gif-pause-overlay {
  display: flex;
}

/* Replace with static image for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .gif-container[data-static-src] img {
    /* JavaScript should swap src to static version */
    content: url(attr(data-static-src));
  }
}

/* === MARQUEE/SCROLLING TEXT === */

/**
 * Auto-scrolling text (ticker, news feed)
 * WCAG 2.2.2 requires pause control
 */

/* Scrolling marquee */
.marquee {
  overflow: hidden;
  white-space: nowrap;
}

.marquee-content {
  display: inline-block;
  animation: marqueeScroll 20s linear infinite;
}

@keyframes marqueeScroll {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

/* Pause on hover (partial solution) */
.marquee:hover .marquee-content {
  animation-play-state: paused;
}

/* Stop scrolling for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .marquee-content {
    animation: none;
    transform: translateX(0);
    /* Text may need overflow handling */
    white-space: normal;
  }
}

/* Marquee pause button */
.marquee-pause-button {
  margin-left: 1rem;
  min-width: 44px;
  min-height: 44px;
}

/* === ROTATING BANNERS === */

/**
 * Auto-rotating promotional banners
 * Must provide pause control
 */

/* Banner rotation */
.rotating-banner {
  position: relative;
  height: 400px;
}

.banner-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1s ease-in-out;
}

.banner-item.active {
  opacity: 1;
  z-index: 1;
}

/* Banner controls */
.banner-controls {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 1rem;
}

.banner-pause-button {
  min-width: 44px;
  min-height: 44px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: none;
  border-radius: 4px;
}

/* Stop rotation for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .banner-item {
    transition: none;
  }

  /* JavaScript should stop auto-rotation */
}

/* === INFINITE SCROLLING === */

/**
 * Auto-loading content on scroll
 * Should provide pause mechanism
 */

/* Infinite scroll container */
.infinite-scroll {
  /* Controlled primarily by JavaScript */
}

/* Loading indicator for new content */
.infinite-scroll-loader {
  text-align: center;
  padding: 2rem;
}

.infinite-scroll-loader .spinner {
  /* Use spinner from earlier section */
}

/* Pause infinite scroll button */
.infinite-scroll-pause {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  min-width: 44px;
  min-height: 44px;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* More prominent for reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  .infinite-scroll-pause {
    display: block !important;
    font-weight: bold;
  }
}

/* === AUTO-REFRESHING CONTENT === */

/**
 * Content that updates automatically (live feeds, dashboards)
 * Provide pause control
 */

/* Live update indicator */
.live-update-container {
  position: relative;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f0f0f0;
  border-radius: 4px;
}

.live-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00c853;
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Static indicator for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .live-indicator-dot {
    animation: none;
    opacity: 1;
  }
}

/* Pause updates button */
.pause-updates-button {
  margin-left: 1rem;
  min-width: 44px;
  min-height: 44px;
}

/* === NOTIFICATION ANIMATIONS === */

/**
 * Auto-appearing notifications
 * Should have dismiss control
 */

/* Notification slide in */
.notification-auto {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  animation: notificationSlideIn 0.3s ease-out;
}

@keyframes notificationSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Auto-dismiss after delay (via JavaScript) */
.notification-auto.dismissing {
  animation: notificationSlideOut 0.3s ease-in;
}

@keyframes notificationSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Instant appearance/dismissal for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .notification-auto {
    animation: fadeIn 0.01ms;
  }

  .notification-auto.dismissing {
    animation: fadeOut 0.01ms;
  }
}

/* === PAUSE/PLAY CONTROL PATTERNS === */

/**
 * Standard pause/play button styling
 * Should be consistent across all auto-play components
 */

/* Universal pause/play button */
.autoplay-control {
  /* Base sizing from Interactive Element Sizing */
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
}

.autoplay-control:hover {
  background: rgba(0, 0, 0, 0.9);
}

.autoplay-control:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Icon states (use SVG or icon font) */
.autoplay-control[aria-pressed="false"]::before {
  content: '▶'; /* Play icon */
}

.autoplay-control[aria-pressed="true"]::before {
  content: '⏸'; /* Pause icon */
}

/* Accessible label (screen reader only) */
.autoplay-control .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === JAVASCRIPT INTEGRATION === */

/**
 * Auto-play requires JavaScript coordination
 * CSS provides visual states, JS handles logic
 *
 * JavaScript should:
 * 1. Detect prefers-reduced-motion
 * 2. Disable auto-play if user prefers reduced motion
 * 3. Provide pause/play controls
 * 4. Stop animations after 5 seconds OR provide controls
 * 5. Pause on window blur/tab switch
 *
 * Example:
 *
 * const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
 *
 * if (prefersReducedMotion.matches) {
 *   // Disable all auto-play
 *   stopCarousel();
 *   pauseVideo();
 *   disableParallax();
 * }
 */

/* === WCAG 2.2.2 COMPLIANCE CHECKLIST === */

/**
 * For auto-playing animations:
 *
 * ✓ REQUIRED:
 *   - Provide pause/stop/hide mechanism
 *   - OR auto-play duration < 5 seconds
 *   - OR not in parallel with other content
 *   - Respect prefers-reduced-motion
 *   - Pause controls meet 24x24px minimum (prefer 44x44px)
 *   - Controls are keyboard accessible
 *   - Controls have visible focus indicators
 *   - ARIA labels for screen readers
 *
 * ✓ BEST PRACTICES:
 *   - Don't auto-play by default
 *   - Pause on hover (carousels)
 *   - Pause on window blur
 *   - Save user preference (paused state)
 *   - Provide visible "auto-play" indicator
 *   - Make pause button prominent
 *   - Use ARIA live regions for updates
 *
 * ✗ AVOID:
 *   - Auto-play without pause control
 *   - Hidden/difficult to find pause buttons
 *   - Auto-play that lasts forever
 *   - Multiple simultaneous auto-playing elements
 *   - Auto-play on mobile (bandwidth concerns)
 */

/* Scroll-triggered Animations
 * Animations activated by scrolling behavior */

/**
 * Scroll-triggered animations include:
 * - Fade-in on scroll (reveal animations)
 * - Parallax scrolling
 * - Sticky headers with animation
 * - Progress indicators
 * - Scroll-based transformations
 *
 * ALL must be disabled for prefers-reduced-motion users
 * These are particularly problematic for vestibular disorders
 */

/* === FADE-IN ON SCROLL === */

/**
 * Elements fade in as they enter viewport
 * Common pattern, but must respect reduced-motion
 * Requires Intersection Observer JavaScript
 */

/* Initial hidden state */
.fade-in-scroll {
  opacity: 0;
  transition: opacity 0.6s ease-out;
}

/* Visible state (applied via JavaScript when in viewport) */
.fade-in-scroll.is-visible {
  opacity: 1;
}

/* Instant visibility for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .fade-in-scroll {
    opacity: 1 !important;
    transition: none !important;
  }
}

/* === SLIDE-IN ON SCROLL === */

/**
 * Elements slide in from sides as viewport enters
 * Must be disabled for reduced-motion
 */

/* Slide from left */
.slide-in-left-scroll {
  opacity: 0;
  transform: translateX(-50px);
  transition: opacity 0.6s ease-out,
              transform 0.6s ease-out;
}

.slide-in-left-scroll.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Slide from right */
.slide-in-right-scroll {
  opacity: 0;
  transform: translateX(50px);
  transition: opacity 0.6s ease-out,
              transform 0.6s ease-out;
}

.slide-in-right-scroll.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Slide from bottom */
.slide-in-bottom-scroll {
  opacity: 0;
  transform: translateY(50px);
  transition: opacity 0.6s ease-out,
              transform 0.6s ease-out;
}

.slide-in-bottom-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Remove transforms for reduced-motion, keep fade */
@media (prefers-reduced-motion: reduce) {
  .slide-in-left-scroll,
  .slide-in-right-scroll,
  .slide-in-bottom-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* === PARALLAX SCROLLING === */

/**
 * CRITICAL: Parallax is a MAJOR vestibular trigger
 * MUST be completely disabled for reduced-motion
 * No exceptions
 */

/* Parallax container */
.parallax-container {
  position: relative;
  overflow: hidden;
  height: 500px;
}

/* Parallax layer (moves at different scroll speed) */
.parallax-layer {
  position: absolute;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  will-change: transform;
}

/* Foreground layer (normal scroll speed) */
.parallax-foreground {
  /* Scroll speed: 1.0 (normal) */
}

/* Midground layer (slower scroll) */
.parallax-midground {
  /* Scroll speed: 0.5 (half speed) */
}

/* Background layer (slowest scroll) */
.parallax-background {
  /* Scroll speed: 0.2 (very slow) */
}

/* COMPLETELY DISABLE parallax for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .parallax-layer {
    transform: none !important;
    position: relative !important;
    will-change: auto !important;
  }

  .parallax-container {
    height: auto;
  }
}

/* === SCROLL PROGRESS INDICATOR === */

/**
 * Progress bar showing scroll position
 * Generally safe, but make instant for reduced-motion
 */

/* Fixed progress bar at top */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 4px;
  background: var(--button-bg, #0066cc);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* Instant progress for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .scroll-progress {
    transition: none;
  }
}

/* === STICKY HEADER WITH ANIMATION === */

/**
 * Header that changes appearance on scroll
 * Safe if just color/shadow changes
 * Problematic if includes transforms
 */

/* Sticky header base */
.sticky-header-scroll {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  transition: box-shadow 0.3s ease-in-out,
              background-color 0.3s ease-in-out,
              padding 0.3s ease-in-out;
}

/* Scrolled state (applied via JavaScript) */
.sticky-header-scroll.scrolled {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  background-color: rgba(255, 255, 255, 0.95);
  padding: 0.5rem 1rem; /* Reduced padding */
}

/* Instant transitions for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .sticky-header-scroll {
    transition: none;
  }
}

/* === SCROLL-SNAP WITH ANIMATION === */

/**
 * Scroll snap points with transition effects
 * Snap is safe, but animations must respect reduced-motion
 */

/* Scroll snap container */
.scroll-snap-container {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 100vh;
}

/* Scroll snap sections */
.scroll-snap-section {
  scroll-snap-align: start;
  height: 100vh;
  opacity: 0.5;
  transition: opacity 0.3s ease-in-out;
}

/* Active section (in view) */
.scroll-snap-section.active {
  opacity: 1;
}

/* Instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .scroll-snap-section {
    opacity: 1 !important;
    transition: none !important;
  }
}

/* === STAGGERED SCROLL ANIMATIONS === */

/**
 * Multiple elements animate in sequence as scrolled into view
 * Must disable for reduced-motion
 */

/* Staggered fade-in items */
.stagger-scroll-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out,
              transform 0.5s ease-out;
}

.stagger-scroll-item.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays (applied via JavaScript based on index) */
.stagger-scroll-item:nth-child(1) { transition-delay: 0s; }
.stagger-scroll-item:nth-child(2) { transition-delay: 0.1s; }
.stagger-scroll-item:nth-child(3) { transition-delay: 0.2s; }
.stagger-scroll-item:nth-child(4) { transition-delay: 0.3s; }
.stagger-scroll-item:nth-child(5) { transition-delay: 0.4s; }

/* Remove all stagger and transforms for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .stagger-scroll-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    transition-delay: 0s !important;
  }
}

/* === ZOOM ON SCROLL === */

/**
 * Elements scale/zoom as they enter viewport
 * Should be disabled for reduced-motion
 */

/* Zoom in effect */
.zoom-in-scroll {
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.6s ease-out,
              transform 0.6s ease-out;
}

.zoom-in-scroll.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* Remove scale for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .zoom-in-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* === ROTATE ON SCROLL === */

/**
 * Elements rotate as they enter viewport
 * MUST be disabled for reduced-motion
 */

/* Rotate effect */
.rotate-in-scroll {
  opacity: 0;
  transform: rotate(-10deg);
  transition: opacity 0.6s ease-out,
              transform 0.6s ease-out;
}

.rotate-in-scroll.is-visible {
  opacity: 1;
  transform: rotate(0deg);
}

/* Remove rotation for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .rotate-in-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* === HORIZONTAL SCROLL ANIMATIONS === */

/**
 * Horizontal scrolling sections with animations
 * Can be disorienting, disable for reduced-motion
 */

/* Horizontal scroll container */
.horizontal-scroll {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}

.horizontal-scroll-item {
  flex: 0 0 80vw;
  scroll-snap-align: center;
  opacity: 0.5;
  transition: opacity 0.3s ease-in-out,
              transform 0.3s ease-in-out;
}

.horizontal-scroll-item.active {
  opacity: 1;
  transform: scale(1.05);
}

/* Remove smooth scroll and animations for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .horizontal-scroll {
    scroll-behavior: auto;
  }

  .horizontal-scroll-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* === SCROLL-BASED COUNTERS === */

/**
 * Numbers that count up when scrolled into view
 * Animation should be disabled for reduced-motion
 */

/* Counter element */
.counter-scroll {
  font-size: 3rem;
  font-weight: bold;
  /* Counting animation controlled by JavaScript */
}

.counter-scroll[data-counting="true"] {
  /* Visual indicator during count */
  color: var(--button-bg, #0066cc);
}

/* Instant final value for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .counter-scroll {
    /* JavaScript should skip animation, show final value */
  }
}

/* === SCROLL-TRIGGERED SVG DRAWING === */

/**
 * SVG paths that "draw" on scroll
 * Disable for reduced-motion
 */

/* SVG path animation */
.svg-draw-scroll path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 1s ease-out;
}

.svg-draw-scroll.is-visible path {
  stroke-dashoffset: 0;
}

/* Instant drawing for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .svg-draw-scroll path {
    stroke-dashoffset: 0 !important;
    transition: none !important;
  }
}

/* === SCROLL-BASED BACKGROUND COLOR CHANGE === */

/**
 * Background color changes as sections scroll into view
 * Generally safe, but make instant for reduced-motion
 */

/* Section with background transition */
.scroll-bg-section {
  min-height: 100vh;
  transition: background-color 0.5s ease-in-out;
}

.scroll-bg-section[data-bg="light"] {
  background-color: #ffffff;
}

.scroll-bg-section[data-bg="dark"] {
  background-color: #1a1a1a;
  color: #ffffff;
}

/* Instant color change for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .scroll-bg-section {
    transition: none;
  }
}

/* === INTERSECTION OBSERVER UTILITIES === */

/**
 * CSS classes applied by Intersection Observer JavaScript
 * Standard naming convention for scroll-triggered animations
 */

/* Before element enters viewport */
.before-enter {
  opacity: 0;
  transform: translateY(30px);
}

/* Element is entering viewport */
.is-entering {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out,
              transform 0.6s ease-out;
}

/* Element has entered viewport */
.has-entered {
  opacity: 1;
  transform: translateY(0);
}

/* Element is leaving viewport */
.is-leaving {
  transition: opacity 0.3s ease-in;
}

/* Element has left viewport */
.has-left {
  opacity: 0.7;
}

/* Reduced-motion overrides */
@media (prefers-reduced-motion: reduce) {
  .before-enter,
  .is-entering,
  .is-leaving {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .has-entered,
  .has-left {
    opacity: 1 !important;
  }
}

/* === SMOOTH SCROLL BEHAVIOR === */

/**
 * Smooth scrolling when clicking anchor links
 * Should be disabled for reduced-motion
 */

/* Smooth scroll on the root element */
html {
  scroll-behavior: smooth;
}

/* Instant scroll for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
}

/* Smooth scroll on specific containers */
.smooth-scroll-container {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .smooth-scroll-container {
    scroll-behavior: auto !important;
  }
}

/* === SCROLL-JACKING PREVENTION === */

/**
 * Avoid overriding native scroll behavior excessively
 * Users should maintain control
 */

/* Allow normal scrolling */
body {
  /* Don't override scroll behavior globally */
  overflow-y: auto;
  /* Never use overflow: hidden on body */
}

/* === JAVASCRIPT INTEGRATION === */

/**
 * Scroll animations require JavaScript coordination
 *
 * Example Intersection Observer:
 *
 * const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
 *
 * const observer = new IntersectionObserver((entries) => {
 *   entries.forEach(entry => {
 *     if (entry.isIntersecting) {
 *       if (!prefersReducedMotion.matches) {
 *         entry.target.classList.add('is-visible');
 *       } else {
 *         // Skip animation, show immediately
 *         entry.target.style.opacity = '1';
 *         entry.target.style.transform = 'none';
 *       }
 *     }
 *   });
 * }, {
 *   threshold: 0.1,
 *   rootMargin: '0px 0px -100px 0px'
 * });
 *
 * document.querySelectorAll('.fade-in-scroll').forEach(el => {
 *   observer.observe(el);
 * });
 */

/* === SCROLL-TRIGGERED ANIMATION GUIDELINES === */

/**
 * Best practices for scroll animations:
 *
 * ✓ DO:
 *   - Use Intersection Observer (performant)
 *   - Check prefers-reduced-motion before animating
 *   - Use fade effects (safest)
 *   - Keep animations subtle and brief
 *   - Provide instant alternative for reduced-motion
 *   - Animate only what's necessary
 *   - Use appropriate thresholds (trigger early)
 *
 * ⚠ CAUTIOUS:
 *   - Small slides/transforms (< 50px)
 *   - Color transitions on scroll
 *   - Progress indicators
 *   - Sticky header changes
 *
 * ✗ AVOID/DISABLE for reduced-motion:
 *   - Parallax (MAJOR trigger)
 *   - Large movements/slides
 *   - Rotation effects
 *   - Scale/zoom effects
 *   - Continuous scroll-based animation
 *   - Scroll-jacking (hijacking scroll)
 *   - Multiple simultaneous scroll animations
 *
 * Performance notes:
 *   - Use will-change sparingly (only during animation)
 *   - Prefer opacity/transform (GPU-accelerated)
 *   - Avoid animating layout properties
 *   - Use passive event listeners for scroll
 *   - Debounce scroll handlers if using them
 *   - Intersection Observer is preferred over scroll events
 *
 * Accessibility notes:
 *   - Animations shouldn't hide critical content
 *   - Content should be accessible even if JS fails
 *   - Don't rely on scroll animations for navigation
 *   - Provide alternative ways to access content
 *   - Test with keyboard navigation (no scroll)
 */

/* === SCROLL ANIMATION TRIGGERS === */

/**
 * Common trigger points for scroll animations
 */

/* Trigger when 10% of element is visible */
.trigger-10 {
  /* Applied via Intersection Observer with threshold: 0.1 */
}

/* Trigger when 50% of element is visible */
.trigger-50 {
  /* Applied via Intersection Observer with threshold: 0.5 */
}

/* Trigger when fully visible */
.trigger-100 {
  /* Applied via Intersection Observer with threshold: 1.0 */
}

/* Early trigger (before element enters viewport) */
.trigger-early {
  /* Applied via Intersection Observer with rootMargin: '100px' */
}

/* Loading and Progress Indicators
 * Visual feedback for loading states and progress */

/**
 * Loading indicators show that a process is happening
 * Progress indicators show how much of a process is complete
 *
 * Guidelines:
 * - Provide static alternative for reduced-motion
 * - Ensure sufficient color contrast
 * - Include text labels for screen readers
 * - Don't rely solely on animation to convey status
 */

/* === SPINNER LOADING INDICATORS === */

/**
 * Rotating spinners are common but problematic for reduced-motion
 * Provide static or pulsing alternative
 */

/* Standard circular spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--button-bg, #0066cc);
  border-radius: 50%;
  animation: spinRotate 1s linear infinite;
}

@keyframes spinRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Static spinner for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--button-bg, #0066cc);
    border-right-color: var(--button-bg, #0066cc);
    /* Show as partial circle (static) */
  }
}

/* Small spinner */
.spinner-small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* Large spinner */
.spinner-large {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

/* === DUAL RING SPINNER === */

/* Two-color rotating spinner */
.spinner-dual {
  width: 40px;
  height: 40px;
  border: 4px solid transparent;
  border-top: 4px solid var(--button-bg, #0066cc);
  border-bottom: 4px solid var(--button-bg, #0066cc);
  border-radius: 50%;
  animation: spinRotate 1.2s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spinner-dual {
    animation: none;
    border: 4px solid var(--button-bg, #0066cc);
    opacity: 0.7;
  }
}

/* === DOTS LOADING INDICATOR === */

/**
 * Animated dots - safer alternative to spinners
 * Uses opacity/scale instead of rotation
 */

/* Three dots container */
.dots-loader {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.dots-loader span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--button-bg, #0066cc);
  animation: dotPulse 1.4s ease-in-out infinite;
}

.dots-loader span:nth-child(1) { animation-delay: 0s; }
.dots-loader span:nth-child(2) { animation-delay: 0.2s; }
.dots-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Static dots for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .dots-loader span {
    animation: none;
    transform: scale(1);
    opacity: 0.7;
  }
}

/* === ELLIPSIS LOADER (TEXT-BASED) === */

/* Loading text with animated ellipsis */
.loading-text {
  font-size: 1rem;
}

.loading-text::after {
  content: '';
  animation: ellipsis 1.5s steps(4, end) infinite;
}

@keyframes ellipsis {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

/* Static ellipsis for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .loading-text::after {
    animation: none;
    content: '...';
  }
}

/* === PULSE LOADER === */

/**
 * Pulsing circle - generally safer than spinning
 */

.pulse-loader {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--button-bg, #0066cc);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* Static pulse for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .pulse-loader {
    animation: none;
    opacity: 0.7;
    transform: scale(1);
  }
}

/* === PROGRESS BAR (DETERMINATE) === */

/**
 * Bar showing percentage of completion
 * Generally safe, but make instant for reduced-motion
 */

/* Progress container */
.progress-bar-container {
  width: 100%;
  height: 20px;
  background: #f0f0f0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--input-border, #767676);
}

/* Progress fill */
.progress-bar-fill {
  height: 100%;
  background: var(--button-bg, #0066cc);
  border-radius: 10px;
  transition: width 0.3s ease-out;
  /* Width set via JavaScript or inline style */
}

/* Progress percentage text */
.progress-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  color: #000000;
  font-size: 0.875rem;
}

/* Instant progress for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .progress-bar-fill {
    transition: none;
  }
}

/* Progress bar variants */
.progress-bar-small {
  height: 8px;
}

.progress-bar-large {
  height: 30px;
}

/* === PROGRESS BAR (INDETERMINATE) === */

/**
 * Bar for unknown duration processes
 * Shows activity but not specific progress
 */

/* Indeterminate progress container */
.progress-indeterminate {
  width: 100%;
  height: 4px;
  background: #f0f0f0;
  position: relative;
  overflow: hidden;
}

/* Moving bar */
.progress-indeterminate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 50%;
  height: 100%;
  background: var(--button-bg, #0066cc);
  animation: indeterminateSlide 1.5s ease-in-out infinite;
}

@keyframes indeterminateSlide {
  0% { left: -50%; }
  100% { left: 100%; }
}

/* Static bar for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .progress-indeterminate::before {
    animation: none;
    left: 0;
    width: 100%;
    opacity: 0.5;
  }
}

/* === CIRCULAR PROGRESS (DETERMINATE) === */

/**
 * Circular/ring progress indicator
 * Uses SVG stroke-dashoffset
 */

/* SVG circular progress */
.circular-progress {
  width: 100px;
  height: 100px;
  transform: rotate(-90deg); /* Start at top */
}

.circular-progress-circle {
  fill: none;
  stroke: #f0f0f0;
  stroke-width: 8;
}

.circular-progress-bar {
  fill: none;
  stroke: var(--button-bg, #0066cc);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 283; /* 2 * PI * radius (45) */
  stroke-dashoffset: 283; /* Updated via JavaScript */
  transition: stroke-dashoffset 0.3s ease-out;
}

/* Instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .circular-progress-bar {
    transition: none;
  }
}

/* Progress percentage in center */
.circular-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: bold;
}

/* === SKELETON SCREENS === */

/**
 * Placeholder content while loading
 * Shimmer effect should be disabled for reduced-motion
 */

/* Skeleton element */
.skeleton {
  background: #f0f0f0;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

/* Shimmer effect */
.skeleton::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Static skeleton for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .skeleton::before {
    animation: none;
    display: none;
  }
}

/* Skeleton variants */
.skeleton-text {
  height: 1em;
  width: 100%;
  margin-bottom: 0.5em;
}

.skeleton-text-short {
  width: 60%;
}

.skeleton-heading {
  height: 2em;
  width: 80%;
  margin-bottom: 1em;
}

.skeleton-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
}

.skeleton-image {
  width: 100%;
  height: 200px;
}

.skeleton-button {
  width: 120px;
  height: 40px;
}

/* === LOADING OVERLAY === */

/**
 * Full-screen or container overlay during loading
 */

/* Overlay container */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Loading message */
.loading-message {
  margin-top: 1rem;
  font-size: 1.125rem;
  color: #333333;
}

/* Fade in overlay */
.loading-overlay {
  animation: fadeIn 0.2s ease-in;
}

@media (prefers-reduced-motion: reduce) {
  .loading-overlay {
    animation: none;
  }
}

/* === BUTTON LOADING STATE === */

/**
 * Button with inline loading indicator
 */

/* Button in loading state */
.button-loading {
  position: relative;
  color: transparent; /* Hide text */
  pointer-events: none;
  cursor: wait;
}

/* Spinner inside button */
.button-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spinRotate 0.8s linear infinite;
}

/* Static loading state for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .button-loading::after {
    animation: none;
    border: 2px solid currentColor;
    border-top-color: transparent;
  }
}

/* === LOADING STATES FOR IMAGES === */

/**
 * Placeholder while image loads
 */

/* Image placeholder */
.image-loading {
  background: #f0f0f0;
  position: relative;
  min-height: 200px;
}

.image-loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #999999;
  border-radius: 50%;
  animation: spinRotate 1s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .image-loading::before {
    animation: none;
    border: 4px solid #999999;
  }
}

/* Loaded state */
.image-loading.loaded {
  background: transparent;
}

.image-loading.loaded::before {
  display: none;
}

/* === STEP PROGRESS INDICATOR === */

/**
 * Multi-step process indicator
 * Shows current step and completion
 */

/* Steps container */
.steps-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2rem 0;
}

/* Individual step */
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

/* Step circle */
.step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0f0f0;
  border: 2px solid var(--input-border, #767676);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #666666;
  transition: background-color 0.3s ease-in-out,
              border-color 0.3s ease-in-out,
              color 0.3s ease-in-out;
  z-index: 1;
}

/* Completed step */
.step.completed .step-circle {
  background: var(--button-bg, #0066cc);
  border-color: var(--button-bg, #0066cc);
  color: #ffffff;
}

/* Active step */
.step.active .step-circle {
  background: #ffffff;
  border-color: var(--button-bg, #0066cc);
  border-width: 3px;
  color: var(--button-bg, #0066cc);
}

/* Step label */
.step-label {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  text-align: center;
  color: #666666;
}

.step.active .step-label {
  color: var(--button-bg, #0066cc);
  font-weight: bold;
}

/* Connector line between steps */
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 20px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: #e0e0e0;
  z-index: 0;
  transition: background-color 0.3s ease-in-out;
}

.step.completed:not(:last-child)::after {
  background: var(--button-bg, #0066cc);
}

/* Instant transitions for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .step-circle,
  .step::after {
    transition: none;
  }
}

/* === UPLOAD PROGRESS === */

/**
 * File upload progress indicator
 */

/* Upload progress container */
.upload-progress {
  padding: 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #f9f9f9;
}

/* File name */
.upload-filename {
  font-weight: bold;
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Progress bar */
.upload-progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.upload-progress-fill {
  height: 100%;
  background: var(--button-bg, #0066cc);
  transition: width 0.2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .upload-progress-fill {
    transition: none;
  }
}

/* Upload percentage */
.upload-percentage {
  font-size: 0.875rem;
  color: #666666;
  text-align: right;
}

/* === ACCESSIBILITY FEATURES === */

/**
 * Screen reader announcements for loading states
 */

/* Visually hidden text for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Loading announcement */
.loading-announcement {
  /* Use aria-live="polite" or "assertive" in HTML */
}

/* Example usage:
 * <div class="spinner" role="status" aria-live="polite">
 *   <span class="sr-only">Loading, please wait...</span>
 * </div>
 */

/* === LOADING STATES SUMMARY === */

/**
 * Loading indicator guidelines:
 *
 * ✓ REQUIRED:
 *   - Provide text alternative for screen readers
 *   - Use role="status" or aria-live for announcements
 *   - Ensure color contrast (3:1 minimum for UI components)
 *   - Static alternative for reduced-motion
 *   - Keyboard accessible (if interactive)
 *
 * ✓ BEST PRACTICES:
 *   - Use determinate progress when duration known
 *   - Show percentage/time remaining when possible
 *   - Provide cancel option for long processes
 *   - Use appropriate size for context
 *   - Don't block UI unnecessarily (inline vs overlay)
 *   - Remove loader when complete
 *
 * ⚠ REDUCED-MOTION ALTERNATIVES:
 *   - Spinners → Static partial circle or pulsing opacity
 *   - Animated dots → Static dots
 *   - Shimmer → Solid color
 *   - Indeterminate bar → Static bar with opacity
 *
 * ✗ AVOID:
 *   - Loading without any indicator
 *   - Animation-only communication (no text)
 *   - Blocking entire UI for small actions
 *   - Multiple simultaneous loading indicators
 *   - Infinite loading without timeout
 */

/* Blinking and Flashing
 * CRITICAL: Seizure prevention and photosensitivity */

/**
 * WCAG 2.3.1 Three Flashes or Below Threshold (Level A)
 * WCAG 2.3.2 Three Flashes (Level AAA)
 *
 * CRITICAL SAFETY RULES:
 * - NEVER flash more than 3 times per second (3 Hz)
 * - NEVER use large bright flashing areas
 * - AVOID red flashing (most dangerous)
 * - Flashing below general flash threshold or red flash threshold
 *
 * Flashing can trigger seizures in people with photosensitive epilepsy
 * This is a SERIOUS SAFETY ISSUE - violations can cause physical harm
 */

/* === BLINKING TEXT (DEPRECATED) === */

/**
 * The <blink> tag is deprecated, but CSS can recreate it
 * WCAG 2.2.2 requires blinking content to be stoppable
 *
 * AVOID blinking text - it's annoying and potentially harmful
 * If absolutely required, must provide stop mechanism
 */

/* Blinking text animation (NOT RECOMMENDED) */
.blink-text {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* DISABLE for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .blink-text {
    animation: none;
    opacity: 1;
  }
}

/* Better alternative: subtle pulse instead of blink */
.pulse-text {
  animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-text {
    animation: none;
    opacity: 1;
  }
}

/* === CURSOR BLINK === */

/**
 * Blinking text cursor (text input, typing effect)
 * This is acceptable but should be stoppable
 */

/* Standard blinking cursor */
.cursor-blink {
  animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Static cursor for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .cursor-blink {
    animation: none;
    opacity: 1;
  }
}

/* Typing effect cursor */
.typing-cursor::after {
  content: '|';
  animation: cursorBlink 1s step-end infinite;
}

@media (prefers-reduced-motion: reduce) {
  .typing-cursor::after {
    animation: none;
    opacity: 1;
  }
}

/* === SAFE FLASH PATTERNS === */

/**
 * If you MUST use flashing, follow these rules:
 *
 * 1. Frequency: < 3 flashes per second (< 3 Hz)
 * 2. Area: Small area only (< 25% of 10-degree visual field)
 * 3. Color: Avoid red flashing
 * 4. Contrast: Low contrast flashes safer than high
 * 5. Duration: Brief only (< 5 seconds)
 * 6. Control: Must be stoppable by user
 */

/* Safe notification flash (low frequency, brief) */
.notification-flash {
  animation: safeFlash 0.5s ease-in-out 2;
  /* Only flashes twice total = 4 transitions */
}

@keyframes safeFlash {
  0%, 100% { background-color: transparent; }
  50% { background-color: #fff9c4; /* Light yellow */ }
}

/* DISABLE for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .notification-flash {
    animation: none;
    background-color: #fff9c4;
    /* Show static highlight color */
  }
}

/* === ALERT/ERROR FLASH === */

/**
 * Brief flash to draw attention to errors
 * Must be low frequency and brief duration
 */

/* Error field flash */
.error-flash {
  animation: errorFlash 0.5s ease-in-out 2;
  /* 2 iterations = 4 state changes, under 3 Hz limit */
}

@keyframes errorFlash {
  0%, 100% {
    border-color: #d32f2f;
    background-color: transparent;
  }
  50% {
    border-color: #d32f2f;
    background-color: #ffebee; /* Light red background */
  }
}

@media (prefers-reduced-motion: reduce) {
  .error-flash {
    animation: none;
    border-color: #d32f2f;
    background-color: #ffebee;
  }
}

/* === ATTENTION INDICATOR (NON-FLASHING) === */

/**
 * Safer alternatives to flashing
 * Use pulse, fade, or color change instead
 */

/* Gentle pulse (safer than flash) */
.attention-pulse {
  animation: attentionPulse 2s ease-in-out infinite;
}

@keyframes attentionPulse {
  0%, 100% {
    background-color: transparent;
    opacity: 1;
  }
  50% {
    background-color: #fff9c4;
    opacity: 0.9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .attention-pulse {
    animation: none;
    background-color: #fff9c4;
  }
}

/* Breathing glow (very gentle) */
.breathing-glow {
  animation: breathingGlow 3s ease-in-out infinite;
}

@keyframes breathingGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(0, 102, 204, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 102, 204, 0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  .breathing-glow {
    animation: none;
    box-shadow: 0 0 10px rgba(0, 102, 204, 0.5);
  }
}

/* === LOADING/ACTIVITY INDICATORS === */

/**
 * Pulsing indicators are safer than rapid flashing
 * Keep frequency low (< 1 Hz preferred)
 */

/* Activity pulse dot */
.activity-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4caf50;
  animation: activityPulse 2s ease-in-out infinite;
}

@keyframes activityPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

@media (prefers-reduced-motion: reduce) {
  .activity-pulse {
    animation: none;
    opacity: 1;
    transform: scale(1);
  }
}

/* === STATUS INDICATORS === */

/**
 * Online/offline status, notifications
 * Gentle pulse acceptable, no rapid flashing
 */

/* Online status indicator */
.status-online {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4caf50;
  animation: statusPulse 3s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* New notification indicator */
.notification-badge {
  background: #d32f2f;
  color: #ffffff;
  border-radius: 50%;
  /* No animation needed - static is better */
}

/* If animation desired, use gentle pulse only */
.notification-badge.animated {
  animation: badgePulse 3s ease-in-out 3;
  /* Stops after 3 pulses - doesn't loop forever */
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  .status-online,
  .notification-badge.animated {
    animation: none;
    opacity: 1;
    transform: scale(1);
  }
}

/* === BANNED PATTERNS === */

/**
 * NEVER USE THESE PATTERNS - Seizure risks
 */

/* DANGEROUS - DO NOT USE */
/*
.rapid-flash {
  animation: rapidFlash 0.2s infinite;
}

@keyframes rapidFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
*/
/* This flashes 5 times per second - DANGEROUS */

/* DANGEROUS - DO NOT USE */
/*
.red-flash {
  animation: redFlash 0.3s infinite;
}

@keyframes redFlash {
  0%, 100% { background-color: #000000; }
  50% { background-color: #ff0000; }
}
*/
/* Red flashing is particularly dangerous */

/* DANGEROUS - DO NOT USE */
/*
.strobe-effect {
  animation: strobe 0.1s infinite;
}

@keyframes strobe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
*/
/* Strobe effect at 10 Hz - EXTREMELY DANGEROUS */

/* === SAFE ALTERNATIVE PATTERNS === */

/**
 * Instead of flashing, use these safer approaches
 */

/* Color shift (no flashing) */
.color-shift {
  animation: colorShift 3s ease-in-out infinite;
}

@keyframes colorShift {
  0%, 100% { background-color: #e3f2fd; }
  50% { background-color: #bbdefb; }
}

/* Opacity fade (no hard blink) */
.opacity-fade {
  animation: opacityFade 2s ease-in-out infinite;
}

@keyframes opacityFade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Border pulse (no flashing area) */
.border-pulse {
  animation: borderPulse 2s ease-in-out infinite;
}

@keyframes borderPulse {
  0%, 100% { border-color: var(--button-bg, #0066cc); }
  50% { border-color: #90caf9; }
}

/* Shadow pulse (subtle depth change) */
.shadow-pulse {
  animation: shadowPulse 2s ease-in-out infinite;
}

@keyframes shadowPulse {
  0%, 100% { box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
}

@media (prefers-reduced-motion: reduce) {
  .color-shift,
  .opacity-fade,
  .border-pulse,
  .shadow-pulse {
    animation: none;
  }
}

/* === VIDEO/MEDIA WARNINGS === */

/**
 * Videos with flashing content require warnings
 * CSS cannot control video content, but can style warnings
 */

/* Photosensitivity warning */
.photosensitivity-warning {
  background: #fff3cd;
  border: 2px solid #ffc107;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}

.photosensitivity-warning::before {
  content: '⚠ ';
  font-size: 1.5rem;
  margin-right: 0.5rem;
}

/* === USER CONTROLS === */

/**
 * Provide controls to stop/pause blinking/flashing
 */

/* Stop animation button */
.stop-animation-button {
  min-width: 44px;
  min-height: 44px;
  background: #d32f2f;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
}

.stop-animation-button:hover {
  background: #b71c1c;
}

.stop-animation-button:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Paused state class (applied via JavaScript) */
.animation-paused * {
  animation-play-state: paused !important;
}

/* Stopped state class (applied via JavaScript) */
.animation-stopped * {
  animation: none !important;
}

/* === GENERAL FLASH THRESHOLD === */

/**
 * WCAG defines two thresholds:
 *
 * 1. GENERAL FLASH THRESHOLD:
 *    - More than 3 flashes per second
 *    - Pair of opposing changes in relative luminance of 10% or more
 *    - Where relative luminance of darker image < 0.80
 *
 * 2. RED FLASH THRESHOLD:
 *    - Any pair of opposing transitions involving saturated red
 *
 * To be safe:
 * - Keep all flashing under 3 Hz (3 flashes per second)
 * - Avoid high-contrast flashing (especially white/black)
 * - Avoid red flashing entirely
 * - Use small areas only
 * - Provide stop mechanism
 * - Warn users before flashing content
 */

/* === ARIA LIVE ANNOUNCEMENTS === */

/**
 * For screen reader users, provide text alternative
 * Visual flashing doesn't work for blind users
 */

/* Example usage:
 * <div class="notification-flash" role="status" aria-live="polite">
 *   <span class="sr-only">New notification received</span>
 * </div>
 */

/* === CRITICAL SAFETY CHECKLIST === */

/**
 * Before deploying ANY flashing or blinking:
 *
 * ✓ REQUIRED CHECKS:
 *   [ ] Flashing frequency < 3 Hz (< 3 flashes per second)
 *   [ ] Duration < 5 seconds OR user can stop it
 *   [ ] Small area only (not full screen)
 *   [ ] NOT using saturated red flashing
 *   [ ] NOT high contrast (white/black rapid alternation)
 *   [ ] Disabled for prefers-reduced-motion
 *   [ ] Stop button provided if > 3 seconds
 *   [ ] Warning provided if unavoidable
 *   [ ] Tested with photosensitivity tools
 *
 * ✓ BEST PRACTICES:
 *   [ ] Use pulse/fade instead of blink
 *   [ ] Use color shift instead of flash
 *   [ ] Keep animations gentle and slow
 *   [ ] Limited to 2-3 iterations (not infinite)
 *   [ ] Provide text alternative for screen readers
 *
 * ✗ NEVER:
 *   [ ] Flash > 3 times per second
 *   [ ] Large area flashing (full screen, big sections)
 *   [ ] Red flashing at any frequency
 *   [ ] Strobe effects
 *   [ ] Rapid white/black alternation
 *   [ ] Infinite flashing without stop control
 *   [ ] Flashing triggered automatically
 */

/* === TESTING TOOLS === */

/**
 * Tools to test for seizure risks:
 *
 * - PEAT (Photosensitive Epilepsy Analysis Tool)
 * - Trace Center's Photosensitive Epilepsy Analysis Tool
 * - Harding Test (professional tool)
 *
 * If content fails these tests, it MUST be redesigned
 * This is not negotiable - seizure risk is a serious safety issue
 */

/* === ALTERNATIVES SUMMARY === */

/**
 * Instead of blinking/flashing, use:
 *
 * ✓ SAFE ATTENTION-GETTING:
 *   - Gentle pulse (opacity 1 → 0.7, 2s duration)
 *   - Color shift (blue → light blue, 3s duration)
 *   - Border glow (subtle shadow change)
 *   - Scale pulse (1 → 1.05, slow)
 *   - Static highlight color
 *   - Icon with animation-play-state control
 *
 * ✓ SAFE STATUS INDICATORS:
 *   - Static colored dot (no animation)
 *   - Badge with count (no animation)
 *   - Gentle breathing glow (3s cycle)
 *   - Opacity pulse (< 1 Hz)
 *
 * ✓ SAFE ERROR FEEDBACK:
 *   - Color change (instant or fade)
 *   - Border color change
 *   - Icon appearance
 *   - Text message
 *   - Sound (with volume control)
 */

/* Hover and Focus Animations
 * Interactive feedback for mouse and keyboard users */

/**
 * Hover and focus animations provide feedback for interactive elements
 *
 * Guidelines:
 * - Keep subtle (avoid large movements)
 * - Keep quick (0.1s - 0.3s)
 * - Disable transforms for reduced-motion
 * - ALWAYS keep focus indicators visible (even if animation disabled)
 * - Keyboard focus should have equal or better feedback than hover
 */

/* === LINK HOVER ANIMATIONS === */

/**
 * Links are the most common interactive element
 * Subtle animations enhance UX
 */

/* Basic link with color transition */
a {
  color: var(--link-color, #0066cc);
  text-decoration: underline;
  transition: color 0.15s ease-in-out;
}

a:hover {
  color: var(--link-hover, #004999);
}

a:focus {
  color: var(--link-hover, #004999);
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

/* Remove transition for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  a {
    transition: none;
  }
}

/* Underline animation (grow from center) */
.link-underline-animate {
  text-decoration: none;
  position: relative;
}

.link-underline-animate::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.3s ease-out, left 0.3s ease-out;
}

.link-underline-animate:hover::after,
.link-underline-animate:focus::after {
  width: 100%;
  left: 0;
}

/* Static underline for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .link-underline-animate::after {
    transition: none;
    width: 100%;
    left: 0;
  }
}

/* Underline slide from left */
.link-underline-slide {
  text-decoration: none;
  position: relative;
}

.link-underline-slide::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: currentColor;
  transition: width 0.3s ease-out;
}

.link-underline-slide:hover::after,
.link-underline-slide:focus::after {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .link-underline-slide::after {
    transition: none;
    width: 100%;
  }
}

/* === BUTTON HOVER ANIMATIONS === */

/**
 * Buttons should have clear interactive feedback
 * Avoid large movements - keep subtle
 */

/* Basic button hover */
button,
[type="button"],
[type="submit"],
[type="reset"] {
  background: var(--button-bg, #0066cc);
  color: #ffffff;
  transition: background-color 0.15s ease-in-out,
              transform 0.15s ease-in-out,
              box-shadow 0.15s ease-in-out;
}

button:hover {
  background: var(--button-hover-bg, #0052a3);
}

button:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

button:active {
  transform: scale(0.98); /* Slight press effect */
}

/* Remove transforms for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  button {
    transition: background-color 0.15s ease-in-out;
  }

  button:active {
    transform: none;
  }
}

/* Button with lift effect */
.button-lift {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: box-shadow 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.button-lift:hover,
.button-lift:focus {
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.button-lift:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

@media (prefers-reduced-motion: reduce) {
  .button-lift {
    transition: box-shadow 0.2s ease-in-out;
  }

  .button-lift:hover,
  .button-lift:focus,
  .button-lift:active {
    transform: none;
  }
}

/* Button with glow effect */
.button-glow {
  transition: box-shadow 0.3s ease-in-out;
}

.button-glow:hover,
.button-glow:focus {
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Glow is safe for reduced-motion */

/* === CARD HOVER ANIMATIONS === */

/**
 * Cards often have hover effects to show interactivity
 * Keep subtle - large movements can be disorienting
 */

/* Basic card hover */
.card {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
  transition: box-shadow 0.3s ease-in-out,
              transform 0.3s ease-in-out,
              border-color 0.3s ease-in-out;
}

.card:hover,
.card:focus-within {
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  transform: translateY(-4px);
  border-color: var(--button-bg, #0066cc);
}

@media (prefers-reduced-motion: reduce) {
  .card {
    transition: box-shadow 0.3s ease-in-out,
                border-color 0.3s ease-in-out;
  }

  .card:hover,
  .card:focus-within {
    transform: none;
  }
}

/* Card with scale effect */
.card-scale {
  transition: transform 0.3s ease-in-out,
              box-shadow 0.3s ease-in-out;
}

.card-scale:hover,
.card-scale:focus-within {
  transform: scale(1.02);
  box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

@media (prefers-reduced-motion: reduce) {
  .card-scale {
    transition: box-shadow 0.3s ease-in-out;
  }

  .card-scale:hover,
  .card-scale:focus-within {
    transform: none;
  }
}

/* === IMAGE HOVER ANIMATIONS === */

/**
 * Image hover effects for galleries, cards, etc.
 */

/* Image zoom on hover */
.image-zoom {
  overflow: hidden;
}

.image-zoom img {
  transition: transform 0.3s ease-in-out;
  display: block;
  width: 100%;
}

.image-zoom:hover img,
.image-zoom:focus-within img {
  transform: scale(1.1);
}

@media (prefers-reduced-motion: reduce) {
  .image-zoom img {
    transition: none;
  }

  .image-zoom:hover img,
  .image-zoom:focus-within img {
    transform: none;
  }
}

/* Image overlay on hover */
.image-overlay-container {
  position: relative;
  overflow: hidden;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.image-overlay-container:hover .image-overlay,
.image-overlay-container:focus-within .image-overlay {
  opacity: 1;
}

/* Instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .image-overlay {
    transition: none;
  }
}

/* === ICON HOVER ANIMATIONS === */

/**
 * Icon buttons and links
 */

/* Icon scale on hover */
.icon-button {
  transition: transform 0.2s ease-in-out,
              color 0.2s ease-in-out;
}

.icon-button:hover,
.icon-button:focus {
  transform: scale(1.2);
  color: var(--button-bg, #0066cc);
}

@media (prefers-reduced-motion: reduce) {
  .icon-button {
    transition: color 0.2s ease-in-out;
  }

  .icon-button:hover,
  .icon-button:focus {
    transform: none;
  }
}

/* Icon rotation on hover */
.icon-rotate {
  transition: transform 0.3s ease-in-out;
}

.icon-rotate:hover,
.icon-rotate:focus {
  transform: rotate(15deg);
}

@media (prefers-reduced-motion: reduce) {
  .icon-rotate:hover,
  .icon-rotate:focus {
    transform: none;
  }
}

/* === FORM INPUT FOCUS ANIMATIONS === */

/**
 * Form inputs need clear focus indicators
 * Animation enhances but must not replace focus outline
 */

/* Input focus glow */
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  border: 1px solid var(--input-border, #767676);
  transition: border-color 0.15s ease-in-out,
              box-shadow 0.15s ease-in-out;
}

input:focus,
textarea:focus {
  border-color: var(--input-border-focus, #0066cc);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
  outline: none; /* Custom focus indicator replaces default */
}

/* Instant for reduced-motion but keep focus visible */
@media (prefers-reduced-motion: reduce) {
  input,
  textarea {
    transition: none;
  }
}

/* Label animation on focus */
.floating-label-container {
  position: relative;
}

.floating-label {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: #666666;
  pointer-events: none;
  transition: top 0.2s ease-out,
              font-size 0.2s ease-out,
              color 0.2s ease-out;
}

.floating-label-container input:focus ~ .floating-label,
.floating-label-container input:not(:placeholder-shown) ~ .floating-label {
  top: -0.5rem;
  font-size: 0.75rem;
  color: var(--button-bg, #0066cc);
}

@media (prefers-reduced-motion: reduce) {
  .floating-label {
    transition: none;
  }
}

/* === NAVIGATION HOVER ANIMATIONS === */

/**
 * Navigation menus and items
 */

/* Nav link hover */
nav a {
  position: relative;
  padding: 0.5rem 1rem;
  color: #333333;
  text-decoration: none;
  transition: color 0.15s ease-in-out,
              background-color 0.15s ease-in-out;
}

nav a:hover,
nav a:focus {
  color: var(--button-bg, #0066cc);
  background-color: rgba(0, 102, 204, 0.1);
}

/* Active link indicator */
nav a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--button-bg, #0066cc);
}

@media (prefers-reduced-motion: reduce) {
  nav a {
    transition: none;
  }
}

/* Dropdown menu animation */
.dropdown-menu {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease-in-out,
              visibility 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .dropdown-menu {
    transition: opacity 0.01ms,
                visibility 0.01ms;
  }

  .dropdown:hover .dropdown-menu,
  .dropdown:focus-within .dropdown-menu {
    transform: none;
  }
}

/* === TOOLTIP HOVER ANIMATIONS === */

/**
 * Tooltips appear on hover/focus
 */

/* Tooltip container */
.tooltip-trigger {
  position: relative;
}

/* Tooltip */
.tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: #333333;
  color: #ffffff;
  padding: 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out,
              visibility 0.2s ease-in-out,
              transform 0.2s ease-in-out;
  pointer-events: none;
}

.tooltip-trigger:hover .tooltip,
.tooltip-trigger:focus .tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-10px);
}

@media (prefers-reduced-motion: reduce) {
  .tooltip {
    transition: opacity 0.01ms,
                visibility 0.01ms;
  }

  .tooltip-trigger:hover .tooltip,
  .tooltip-trigger:focus .tooltip {
    transform: translateX(-50%) translateY(-10px);
  }
}

/* === TAB HOVER ANIMATIONS === */

/**
 * Tab navigation
 */

/* Tab button */
.tab-button {
  padding: 0.75rem 1.5rem;
  border: none;
  background: transparent;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease-in-out,
              border-bottom-color 0.15s ease-in-out,
              background-color 0.15s ease-in-out;
}

.tab-button:hover {
  background-color: #f5f5f5;
}

.tab-button:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

.tab-button.active {
  color: var(--button-bg, #0066cc);
  border-bottom-color: var(--button-bg, #0066cc);
}

@media (prefers-reduced-motion: reduce) {
  .tab-button {
    transition: none;
  }
}

/* === CHECKBOX/RADIO HOVER ANIMATIONS === */

/**
 * Custom styled form controls
 */

/* Custom checkbox */
.custom-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--input-border, #767676);
  border-radius: 4px;
  transition: background-color 0.15s ease-in-out,
              border-color 0.15s ease-in-out,
              transform 0.15s ease-in-out;
}

.custom-checkbox:hover {
  border-color: var(--button-bg, #0066cc);
}

.custom-checkbox:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

.custom-checkbox:checked {
  background-color: var(--button-bg, #0066cc);
  border-color: var(--button-bg, #0066cc);
}

.custom-checkbox:active {
  transform: scale(0.95);
}

@media (prefers-reduced-motion: reduce) {
  .custom-checkbox {
    transition: background-color 0.15s ease-in-out,
                border-color 0.15s ease-in-out;
  }

  .custom-checkbox:active {
    transform: none;
  }
}

/* === FOCUS-VISIBLE PATTERN === */

/**
 * Modern approach: only show focus outline for keyboard users
 * Hide for mouse users (using :focus-visible)
 */

/* Remove default focus outline */
*:focus {
  outline: none;
}

/* Show focus outline only for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

/* Specific focus styles for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

/* === HOVER AFFORDANCE UTILITIES === */

/**
 * Visual cues that element is interactive
 */

/* Cursor change on hover */
.interactive {
  cursor: pointer;
}

.interactive:hover {
  opacity: 0.9;
}

/* Disabled state (no hover effects) */
.disabled,
[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* === HOVER AND FOCUS GUIDELINES === */

/**
 * Best practices:
 *
 * ✓ DO:
 *   - Provide both hover AND focus styles
 *   - Make focus indicators at least as prominent as hover
 *   - Keep animations quick (0.1s - 0.3s)
 *   - Use color, shadow, border changes (safe)
 *   - Maintain sufficient contrast (3:1 minimum)
 *   - Test with keyboard only
 *   - Disable transforms for reduced-motion
 *
 * ⚠ CAUTIOUS:
 *   - Small transforms (< 5px movement, < 1.1x scale)
 *   - Lift effects (translateY)
 *   - Gentle rotations (< 15deg)
 *
 * ✗ AVOID:
 *   - Hover-only interaction (must support keyboard)
 *   - Invisible focus indicators
 *   - Large movements (> 10px)
 *   - Rotation > 45deg
 *   - Animation-dependent functionality
 *   - Removing all visual feedback for reduced-motion
 *
 * Accessibility notes:
 *   - Focus indicators MUST be visible (even with reduced-motion)
 *   - Touch devices don't have hover (design for tap)
 *   - Keyboard users rely on focus indicators
 *   - Screen reader users need semantic HTML, not just visual cues
 *   - Color alone is insufficient (need shape/position/text)
 */

/* Transform and 3D Effects
 * CSS transforms including 3D transformations */

/**
 * CSS transforms can create dramatic effects but are MAJOR vestibular triggers
 *
 * Guidelines:
 * - 2D transforms (translate, scale, rotate) are cautiously acceptable
 * - 3D transforms (rotateX, rotateY, perspective) are HIGH RISK
 * - ALL transforms MUST be disabled for reduced-motion
 * - Keep movements small and brief
 * - Avoid continuous/infinite transform animations
 */

/* === 2D TRANSLATE (MOVEMENT) === */

/**
 * translateX() and translateY() move elements
 * Small movements acceptable, large movements problematic
 */

/* Small upward movement (button lift) */
.translate-up {
  transition: transform 0.2s ease-in-out;
}

.translate-up:hover,
.translate-up:focus {
  transform: translateY(-4px);
}

/* MUST disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .translate-up:hover,
  .translate-up:focus {
    transform: none;
  }
}

/* Slide in from side (entrance animation) */
.slide-in-x {
  transform: translateX(-50px);
  opacity: 0;
  transition: transform 0.4s ease-out,
              opacity 0.4s ease-out;
}

.slide-in-x.visible {
  transform: translateX(0);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .slide-in-x {
    transform: none;
    opacity: 0;
  }

  .slide-in-x.visible {
    opacity: 1;
  }
}

/* Large translation - DISABLE for reduced-motion */
.translate-large {
  transition: transform 0.3s ease-out;
}

.translate-large.moved {
  transform: translate(100px, 50px);
}

@media (prefers-reduced-motion: reduce) {
  .translate-large.moved {
    transform: none;
    /* Consider using position change instead */
  }
}

/* === 2D SCALE (ZOOM) === */

/**
 * scale() changes element size
 * Small scaling acceptable, large scaling problematic
 */

/* Subtle scale on hover (< 1.1x is safest) */
.scale-subtle {
  transition: transform 0.2s ease-in-out;
}

.scale-subtle:hover,
.scale-subtle:focus {
  transform: scale(1.05);
}

@media (prefers-reduced-motion: reduce) {
  .scale-subtle:hover,
  .scale-subtle:focus {
    transform: none;
  }
}

/* Moderate scale (1.1x - 1.2x - use cautiously) */
.scale-moderate {
  transition: transform 0.3s ease-in-out;
}

.scale-moderate:hover {
  transform: scale(1.15);
}

@media (prefers-reduced-motion: reduce) {
  .scale-moderate:hover {
    transform: none;
  }
}

/* Large scale (> 1.3x - AVOID) */
.scale-large {
  transition: transform 0.4s ease-in-out;
}

.scale-large.zoomed {
  transform: scale(1.5);
}

/* MUST disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .scale-large.zoomed {
    transform: none;
  }
}

/* Zoom in animation (entrance) */
.zoom-in {
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.4s ease-out,
              opacity 0.4s ease-out;
}

.zoom-in.visible {
  transform: scale(1);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .zoom-in {
    transform: scale(1);
    opacity: 0;
  }

  .zoom-in.visible {
    opacity: 1;
  }
}

/* Press effect (scale down) */
.scale-press {
  transition: transform 0.1s ease-in-out;
}

.scale-press:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  .scale-press:active {
    transform: none;
  }
}

/* === 2D ROTATE (SPIN) === */

/**
 * rotate() spins elements in 2D plane
 * Small rotations acceptable, continuous spinning problematic
 */

/* Small rotation on hover (< 15deg safer) */
.rotate-small {
  transition: transform 0.3s ease-in-out;
}

.rotate-small:hover,
.rotate-small:focus {
  transform: rotate(5deg);
}

@media (prefers-reduced-motion: reduce) {
  .rotate-small:hover,
  .rotate-small:focus {
    transform: none;
  }
}

/* Moderate rotation (15deg - 45deg) */
.rotate-moderate {
  transition: transform 0.3s ease-in-out;
}

.rotate-moderate:hover {
  transform: rotate(15deg);
}

@media (prefers-reduced-motion: reduce) {
  .rotate-moderate:hover {
    transform: none;
  }
}

/* Full rotation (spinner) - MUST DISABLE */
.rotate-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* CRITICAL: Disable for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .rotate-spinner {
    animation: none;
    /* Show static state */
  }
}

/* Icon flip (180deg) */
.rotate-flip {
  transition: transform 0.3s ease-in-out;
}

.rotate-flip.flipped {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .rotate-flip.flipped {
    transform: none;
    /* Consider using different icon instead */
  }
}

/* === SKEW TRANSFORMS === */

/**
 * skew() distorts elements
 * Generally should be avoided - disorienting
 */

/* Skew effect */
.skew-effect {
  transition: transform 0.3s ease-in-out;
}

.skew-effect:hover {
  transform: skewX(-5deg);
}

/* DISABLE for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .skew-effect:hover {
    transform: none;
  }
}

/* === COMBINED 2D TRANSFORMS === */

/**
 * Combining multiple transforms
 * More complex = more disorienting
 */

/* Scale + translate combo */
.transform-combo {
  transition: transform 0.3s ease-in-out;
}

.transform-combo:hover {
  transform: scale(1.05) translateY(-4px);
}

@media (prefers-reduced-motion: reduce) {
  .transform-combo:hover {
    transform: none;
  }
}

/* Rotate + scale combo */
.transform-rotate-scale {
  transition: transform 0.3s ease-in-out;
}

.transform-rotate-scale:hover {
  transform: rotate(5deg) scale(1.1);
}

@media (prefers-reduced-motion: reduce) {
  .transform-rotate-scale:hover {
    transform: none;
  }
}

/* === 3D TRANSFORMS (HIGH RISK) === */

/**
 * 3D transforms create depth perception
 * MAJOR VESTIBULAR TRIGGERS - use with extreme caution
 * MUST provide 2D fallback for reduced-motion
 */

/* Perspective container (enables 3D space) */
.perspective-container {
  perspective: 1000px;
}

/* 3D card flip */
.card-3d {
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.card-3d.flipped {
  transform: rotateY(180deg);
}

/* Front and back faces */
.card-face {
  backface-visibility: hidden;
}

.card-back {
  transform: rotateY(180deg);
}

/* CRITICAL: Disable 3D for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .perspective-container {
    perspective: none;
  }

  .card-3d {
    transform-style: flat;
  }

  .card-3d.flipped {
    transform: none;
    /* Use opacity or display change instead */
  }

  .card-face,
  .card-back {
    backface-visibility: visible;
  }
}

/* 3D rotate on hover */
.rotate-3d {
  transition: transform 0.4s ease-in-out;
  transform-style: preserve-3d;
}

.rotate-3d:hover {
  transform: rotateX(10deg) rotateY(10deg);
}

@media (prefers-reduced-motion: reduce) {
  .rotate-3d {
    transform-style: flat;
  }

  .rotate-3d:hover {
    transform: none;
  }
}

/* 3D tilt effect */
.tilt-3d {
  transition: transform 0.3s ease-out;
}

.tilt-3d:hover {
  transform: perspective(1000px) rotateX(5deg) rotateY(5deg);
}

@media (prefers-reduced-motion: reduce) {
  .tilt-3d:hover {
    transform: none;
  }
}

/* 3D parallax layers */
.parallax-3d {
  transform-style: preserve-3d;
  perspective: 1px;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.parallax-layer-3d {
  position: absolute;
  transform: translateZ(0);
}

.parallax-layer-far {
  transform: translateZ(-2px) scale(3);
}

.parallax-layer-near {
  transform: translateZ(-1px) scale(2);
}

/* ABSOLUTELY MUST DISABLE for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .parallax-3d {
    transform-style: flat;
    perspective: none;
  }

  .parallax-layer-3d,
  .parallax-layer-far,
  .parallax-layer-near {
    transform: none;
    position: relative;
  }
}

/* === TRANSFORM ORIGIN === */

/**
 * transform-origin changes the anchor point for transforms
 * Affects how scale and rotate behave
 */

/* Scale from center (default) */
.scale-center {
  transform-origin: center center;
  transition: transform 0.3s ease-in-out;
}

.scale-center:hover {
  transform: scale(1.1);
}

/* Scale from top-left */
.scale-top-left {
  transform-origin: top left;
  transition: transform 0.3s ease-in-out;
}

.scale-top-left:hover {
  transform: scale(1.1);
}

/* Rotate from corner */
.rotate-corner {
  transform-origin: bottom right;
  transition: transform 0.3s ease-in-out;
}

.rotate-corner:hover {
  transform: rotate(10deg);
}

@media (prefers-reduced-motion: reduce) {
  .scale-center:hover,
  .scale-top-left:hover,
  .rotate-corner:hover {
    transform: none;
  }
}

/* === MATRIX TRANSFORMS === */

/**
 * matrix() allows complex transforms
 * Very powerful but complex and potentially disorienting
 */

/* Complex transform using matrix */
.matrix-transform {
  transition: transform 0.4s ease-in-out;
}

.matrix-transform:hover {
  /* matrix(scaleX, skewY, skewX, scaleY, translateX, translateY) */
  transform: matrix(1.1, 0.1, -0.1, 1.1, 0, 0);
}

@media (prefers-reduced-motion: reduce) {
  .matrix-transform:hover {
    transform: none;
  }
}

/* === WILL-CHANGE OPTIMIZATION === */

/**
 * will-change hints to browser that element will animate
 * Improves performance but use sparingly
 */

/* Optimize transform performance */
.will-transform {
  will-change: transform;
}

/* Only use during animation, remove after */
.animating {
  will-change: transform;
}

.animation-complete {
  will-change: auto;
}

/* Don't overuse - can hurt performance */
/* WRONG: will-change: transform, opacity, left, top, width, height; */

/* === HARDWARE ACCELERATION === */

/**
 * Force GPU acceleration for smoother animations
 * translateZ(0) or translate3d(0,0,0) triggers it
 */

/* Force hardware acceleration */
.gpu-accelerated {
  transform: translateZ(0);
  /* Or: transform: translate3d(0, 0, 0); */
}

/* Use for smooth animations */
.smooth-animation {
  transform: translateZ(0);
  transition: transform 0.3s ease-out;
}

/* === TRANSFORM PERFORMANCE TIPS === */

/**
 * Best practices for performant transforms:
 *
 * - Prefer transform over position/margin/width changes
 * - Use translate instead of left/top
 * - Use scale instead of width/height
 * - Combine transforms in single property
 * - Use will-change sparingly (only during animation)
 * - Remove will-change after animation completes
 */

/* Good performance */
.performant {
  transform: translateX(100px);
  transition: transform 0.3s ease-out;
}

/* Poor performance */
.not-performant {
  left: 100px; /* Causes reflow */
  transition: left 0.3s ease-out;
}

/* === TRANSFORM GUIDELINES === */

/**
 * Safety and accessibility guidelines:
 *
 * ✓ GENERALLY SAFE (with reduced-motion override):
 *   - Small translate (< 10px)
 *   - Small scale (< 1.1x)
 *   - Small rotate (< 15deg)
 *   - Single transform property
 *   - Brief duration (< 0.3s)
 *
 * ⚠ USE WITH CAUTION (must disable for reduced-motion):
 *   - Medium translate (10px - 50px)
 *   - Medium scale (1.1x - 1.3x)
 *   - Medium rotate (15deg - 45deg)
 *   - Combined transforms (2 properties)
 *   - Longer duration (0.3s - 0.5s)
 *
 * ✗ HIGH RISK (avoid or strictly disable for reduced-motion):
 *   - Large translate (> 50px)
 *   - Large scale (> 1.3x)
 *   - Large rotate (> 45deg or continuous)
 *   - 3D transforms (rotateX, rotateY, rotateZ)
 *   - Perspective effects
 *   - Skew transforms
 *   - Complex matrix transforms
 *   - Parallax effects
 *   - Infinite animations
 *
 * ✗ NEVER (extreme vestibular triggers):
 *   - Continuous 3D rotation
 *   - 3D parallax scrolling
 *   - Rapid perspective changes
 *   - Multiple simultaneous 3D transforms
 *   - Strobe-like transform animations
 */

/* === TRANSFORM ALTERNATIVES === */

/**
 * Safer alternatives to transforms for reduced-motion
 */

/* Instead of translate, use opacity */
@media (prefers-reduced-motion: reduce) {
  .slide-in {
    /* Instead of translateX */
    opacity: 0;
  }

  .slide-in.visible {
    opacity: 1;
  }
}

/* Instead of scale, use border/shadow */
@media (prefers-reduced-motion: reduce) {
  .zoom-effect {
    transition: box-shadow 0.3s ease-in-out;
  }

  .zoom-effect:hover {
    /* Instead of scale(1.1) */
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
  }
}

/* Instead of rotate, use different icon/state */
@media (prefers-reduced-motion: reduce) {
  .chevron-down {
    /* Instead of rotate(180deg) for up state */
    content: url('chevron-up.svg');
  }
}

/* Instead of 3D flip, use fade/display change */
@media (prefers-reduced-motion: reduce) {
  .card-flip .front {
    opacity: 0;
    display: none;
  }

  .card-flip .back {
    opacity: 1;
    display: block;
  }
}

/* === TESTING CHECKLIST === */

/**
 * Before deploying transforms:
 *
 * ✓ Performance:
 *   [ ] Animations run at 60fps
 *   [ ] No jank or stuttering
 *   [ ] Tested on low-end devices
 *   [ ] will-change used appropriately
 *
 * ✓ Accessibility:
 *   [ ] All transforms disabled for reduced-motion
 *   [ ] Alternative provided (opacity, color, etc.)
 *   [ ] Tested with reduced-motion enabled
 *   [ ] No motion required for functionality
 *   [ ] Content accessible without transforms
 *
 * ✓ Safety:
 *   [ ] No continuous 3D rotation
 *   [ ] No parallax without disable option
 *   [ ] Transform magnitude appropriate
 *   [ ] Duration not too long (< 0.5s)
 *   [ ] User can control/stop animation
 */

/* === CRITICAL REMINDERS === */

/**
 * Transform safety hierarchy (most to least safe):
 *
 * 1. No transform (safest)
 * 2. Opacity change only
 * 3. Color/shadow change
 * 4. Small translate (< 5px)
 * 5. Small scale (< 1.05x)
 * 6. Small rotate (< 10deg)
 * 7. Medium transforms (10-50px, 1.1-1.3x, 10-45deg)
 * 8. Large 2D transforms
 * 9. 3D transforms (HIGH RISK)
 * 10. Continuous 3D animations (EXTREME RISK)
 *
 * ALWAYS provide reduced-motion fallback
 * NEVER use 3D transforms without testing for vestibular issues
 * When in doubt, use simpler alternatives
 */

/* Video and GIF Backgrounds
 * Autoplaying media backgrounds and controls */

/**
 * WCAG 2.2.2 requires that moving content that:
 * - Starts automatically
 * - Lasts more than 5 seconds
 * - Is presented in parallel with other content
 * Must have a mechanism to pause, stop, or hide it.
 *
 * Video and GIF backgrounds are common but problematic:
 * - Motion can trigger vestibular disorders
 * - Distracting from main content
 * - Accessibility and performance issues
 * - Must provide controls and static alternatives
 */

/* === VIDEO BACKGROUNDS === */

/**
 * Fullscreen or section background videos
 * MUST provide pause control and static alternative
 */

/* Video background container */
.video-background {
  position: relative;
  width: 100%;
  min-height: 500px;
  overflow: hidden;
  background-color: #000000; /* Fallback color */
}

/* Video element */
.video-background video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  z-index: -1;
  object-fit: cover;
}

/* Content overlay on top of video */
.video-background-content {
  position: relative;
  z-index: 1;
  padding: 4rem 2rem;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* === VIDEO PAUSE/PLAY CONTROL === */

/**
 * REQUIRED: Visible, accessible pause button
 */

/* Pause button */
.video-pause-button {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  min-width: 48px;
  min-height: 48px;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.video-pause-button:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.video-pause-button:focus {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

/* Button states (icons via pseudo-elements or SVG) */
.video-pause-button[aria-pressed="false"]::before {
  content: '▶'; /* Play icon */
  font-size: 1.25rem;
}

.video-pause-button[aria-pressed="true"]::before {
  content: '⏸'; /* Pause icon */
  font-size: 1.25rem;
}

/* Remove hover transform for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .video-pause-button:hover {
    transform: none;
  }
}

/* === STATIC POSTER/FALLBACK === */

/**
 * Show static image for reduced-motion users
 * Better UX than just pausing video
 */

/* Poster image (shown when video disabled) */
.video-background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: var(--poster-image);
  background-size: cover;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.3s ease-in-out;
}

/* Show poster for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .video-background video {
    opacity: 0;
    /* JavaScript should also pause the video */
  }

  .video-background::before {
    opacity: 1;
  }
}

/* Paused state (via JavaScript class) */
.video-background.paused video {
  opacity: 0;
}

.video-background.paused::before {
  opacity: 1;
}

/* === VIDEO BACKGROUND WITH OVERLAY === */

/**
 * Dark overlay to improve text readability
 */

/* Overlay layer */
.video-background::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 0;
}

/* Ensure content is above overlay */
.video-background-content {
  position: relative;
  z-index: 1;
}

/* === VIDEO SECTION (PARTIAL BACKGROUND) === */

/**
 * Video background in a section, not fullscreen
 */

/* Section with video background */
.section-video-bg {
  position: relative;
  min-height: 400px;
  overflow: hidden;
}

.section-video-bg video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
}

/* === ANIMATED GIF BACKGROUNDS === */

/**
 * GIFs cannot be paused with CSS alone
 * Need JavaScript or static image replacement
 */

/* GIF background container */
.gif-background {
  position: relative;
  min-height: 400px;
  background-image: var(--gif-url);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Static alternative for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .gif-background {
    background-image: var(--static-image-url);
    /* JavaScript should swap to static version */
  }
}

/* === GIF PAUSE MECHANISM === */

/**
 * Since CSS can't pause GIFs, use JavaScript
 * CSS provides styling for pause overlay
 */

/* Pause overlay (controlled by JavaScript) */
.gif-pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.gif-paused .gif-pause-overlay {
  display: flex;
}

/* Play button on paused GIF */
.gif-play-button {
  min-width: 60px;
  min-height: 60px;
  background: rgba(255, 255, 255, 0.9);
  color: #000000;
  border: none;
  border-radius: 50%;
  font-size: 2rem;
  cursor: pointer;
  transition: transform 0.2s ease-in-out;
}

.gif-play-button:hover {
  transform: scale(1.1);
}

.gif-play-button:focus {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .gif-play-button:hover {
    transform: none;
  }
}

/* === VIDEO BACKGROUND PERFORMANCE === */

/**
 * Optimize video backgrounds for performance
 */

/* Lazy load video (don't load on mobile by default) */
.video-background video {
  /* Use poster attribute in HTML */
  /* Load video via JavaScript on desktop only */
}

/* Hide video on mobile (bandwidth concerns) */
@media (max-width: 767px) {
  .video-background video {
    display: none;
  }

  .video-background::before {
    opacity: 1; /* Always show poster on mobile */
  }
}

/* === HERO SECTION WITH VIDEO === */

/**
 * Common pattern: fullscreen hero with video background
 */

/* Hero container */
.hero-video {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Video fills hero */
.hero-video video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
  z-index: -2;
}

/* Gradient overlay for text readability */
.hero-video::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.3),
    rgba(0, 0, 0, 0.6)
  );
  z-index: -1;
}

/* Hero content */
.hero-video-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #ffffff;
  max-width: 800px;
  padding: 2rem;
}

.hero-video h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.8);
}

/* === MULTIPLE VIDEO BACKGROUNDS === */

/**
 * AVOID: Multiple autoplaying videos
 * If necessary, only one should autoplay
 */

/* First video autoplays (via HTML autoplay attribute) */
.video-bg-1 video {
  /* autoplay muted loop playsinline */
}

/* Second video does NOT autoplay */
.video-bg-2 video {
  /* NO autoplay - user must play */
}

/* === VIDEO CONTROLS VISIBILITY === */

/**
 * Make controls obvious and accessible
 */

/* Show pause button prominently */
.video-background .video-pause-button {
  /* Always visible */
  opacity: 1;
}

/* Optional: fade in/out on hover */
.video-background:hover .video-pause-button {
  opacity: 1;
}

/* For reduced-motion users, keep controls very visible */
@media (prefers-reduced-motion: reduce) {
  .video-pause-button {
    background: rgba(0, 0, 0, 0.9);
    border-width: 3px;
    font-weight: bold;
  }
}

/* === ALTERNATIVE: BLUR EFFECT === */

/**
 * Subtle blur can reduce motion perception
 * But still should respect reduced-motion
 */

/* Subtle blur on video */
.video-background video.blurred {
  filter: blur(3px);
}

/* More blur for reduced-motion (less distracting) */
@media (prefers-reduced-motion: reduce) {
  .video-background video {
    filter: blur(10px);
    opacity: 0.3;
  }
}

/* === CANVAS-BASED ANIMATED BACKGROUNDS === */

/**
 * Canvas animations (particles, waves, etc.)
 * Must be disabled for reduced-motion
 */

/* Canvas background */
.canvas-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

/* Hide canvas for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .canvas-background {
    display: none;
  }
}

/* Static background alternative */
@media (prefers-reduced-motion: reduce) {
  .canvas-background-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
}

/* === LOTTIE/SVG ANIMATED BACKGROUNDS === */

/**
 * Animated SVG or Lottie backgrounds
 * Control via JavaScript, style with CSS
 */

/* Lottie container */
.lottie-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.3;
  z-index: -1;
}

/* Pause Lottie for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .lottie-background {
    display: none;
  }
}

/* === ACCESSIBILITY CONSIDERATIONS === */

/**
 * Screen reader announcements
 * Visual indicators
 * Keyboard controls
 */

/* Visually hidden text for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Example usage:
 * <button class="video-pause-button" aria-pressed="true">
 *   <span class="sr-only">Pause background video</span>
 * </button>
 */

/* === JAVASCRIPT INTEGRATION === */

/**
 * Video backgrounds require JavaScript for full control
 *
 * Essential JavaScript functionality:
 *
 * const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
 * const video = document.querySelector('.video-background video');
 * const pauseButton = document.querySelector('.video-pause-button');
 *
 * // Disable video for reduced-motion users
 * if (prefersReducedMotion.matches) {
 *   video.pause();
 *   video.style.display = 'none';
 * }
 *
 * // Pause button functionality
 * pauseButton.addEventListener('click', () => {
 *   if (video.paused) {
 *     video.play();
 *     pauseButton.setAttribute('aria-pressed', 'true');
 *   } else {
 *     video.pause();
 *     pauseButton.setAttribute('aria-pressed', 'false');
 *   }
 * });
 *
 * // Pause when tab not visible
 * document.addEventListener('visibilitychange', () => {
 *   if (document.hidden) {
 *     video.pause();
 *   }
 * });
 *
 * // Don't autoplay on mobile (save bandwidth)
 * if (window.innerWidth < 768) {
 *   video.removeAttribute('autoplay');
 *   video.pause();
 * }
 *
 * // GIF replacement for reduced-motion
 * if (prefersReducedMotion.matches) {
 *   const gifBg = document.querySelector('.gif-background');
 *   const staticUrl = gifBg.dataset.staticImage;
 *   gifBg.style.backgroundImage = `url(${staticUrl})`;
 * }
 */

/* === VIDEO ATTRIBUTES (HTML) === */

/**
 * Required HTML attributes for video backgrounds:
 *
 * <video autoplay muted loop playsinline poster="static-image.jpg">
 *   <source src="background.mp4" type="video/mp4">
 *   <source src="background.webm" type="video/webm">
 * </video>
 *
 * - autoplay: Start automatically
 * - muted: REQUIRED for autoplay to work
 * - loop: Repeat continuously
 * - playsinline: Prevent fullscreen on iOS
 * - poster: Static image while loading (and for no-JS fallback)
 */

/* === PERFORMANCE OPTIMIZATION === */

/**
 * Video backgrounds are resource-intensive
 */

/* Limit video quality on mobile */
@media (max-width: 767px) {
  .video-background video {
    /* Load lower resolution via JavaScript */
    /* Or don't load at all */
  }
}

/* Preload poster image */
.video-background {
  background-image: var(--poster-image);
  background-size: cover;
  background-position: center;
}

/* === VIDEO/GIF BACKGROUND GUIDELINES === */

/**
 * Best practices and requirements:
 *
 * ✓ REQUIRED:
 *   [ ] Pause/play control (48x48px minimum)
 *   [ ] Control is visible and accessible
 *   [ ] Static poster/fallback image
 *   [ ] Disabled for prefers-reduced-motion
 *   [ ] Video is muted (WCAG requirement for autoplay)
 *   [ ] ARIA labels for controls
 *   [ ] Keyboard accessible
 *   [ ] Pauses when tab not visible
 *
 * ✓ RECOMMENDED:
 *   [ ] Don't autoplay on mobile (bandwidth)
 *   [ ] Compressed/optimized video file
 *   [ ] Multiple formats (MP4, WebM)
 *   [ ] Short loop (< 30 seconds)
 *   [ ] Low motion in video content itself
 *   [ ] Sufficient text contrast over video
 *   [ ] Content readable even if video fails to load
 *
 * ⚠ USE WITH CAUTION:
 *   [ ] Multiple background videos on one page
 *   [ ] High-motion video content
 *   [ ] Videos > 5MB file size
 *   [ ] Videos on every page
 *
 * ✗ NEVER:
 *   [ ] Autoplay with sound (without user interaction)
 *   [ ] Video without pause control
 *   [ ] Video without static fallback
 *   [ ] Ignore reduced-motion preference
 *   [ ] Make critical content depend on video loading
 *   [ ] Use video for essential information (use text)
 */

/* === TESTING CHECKLIST === */

/**
 * Before deploying video/GIF backgrounds:
 *
 * ✓ Functionality:
 *   [ ] Video loads and plays
 *   [ ] Pause button works
 *   [ ] Poster image displays while loading
 *   [ ] Video loops correctly
 *   [ ] Works on all target browsers
 *
 * ✓ Accessibility:
 *   [ ] Prefers-reduced-motion disables video
 *   [ ] Keyboard can control pause button
 *   [ ] Focus indicator visible on pause button
 *   [ ] Screen reader announces button state
 *   [ ] Text readable over video
 *   [ ] Content accessible if video fails
 *
 * ✓ Performance:
 *   [ ] Video file size optimized
 *   [ ] Doesn't autoplay on mobile
 *   [ ] Page loads quickly
 *   [ ] No layout shift when video loads
 *   [ ] Doesn't block other content
 *
 * ✓ UX:
 *   [ ] Video enhances, not distracts
 *   [ ] Motion is subtle and slow
 *   [ ] Pause control is obvious
 *   [ ] Provides value (not just decoration)
 */

/* === ALTERNATIVES TO VIDEO BACKGROUNDS === */

/**
 * Consider these instead of video backgrounds:
 *
 * - Static image with subtle CSS animation
 * - Gradient background
 * - Illustrated background
 * - Pattern/texture
 * - Solid color with interesting typography
 * - CSS-only animations (if kept subtle)
 * - SVG illustrations
 *
 * These are:
 * - More accessible
 * - Better performance
 * - Less distracting
 * - Easier to implement
 * - More reliable
 */

/* Static alternative with subtle animation */
.alternative-background {
  background: linear-gradient(
    135deg,
    #667eea 0%,
    #764ba2 100%
  );
  /* Optional: very subtle movement */
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Disable even subtle animation for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .alternative-background {
    animation: none;
    background-size: 100% 100%;
  }
}

/* Carousel and Slideshow Controls
 * Auto-advancing content with user controls */

/**
 * WCAG 2.2.2 requires auto-advancing carousels to have pause controls
 *
 * Requirements:
 * - Pause/play button (visible and accessible)
 * - Keyboard navigation (arrow keys, tab)
 * - Stop auto-advance on hover/focus
 * - Disable auto-advance for reduced-motion
 * - Previous/next controls
 * - Indicators showing current position
 * - Screen reader announcements
 */

/* === BASIC CAROUSEL STRUCTURE === */

/**
 * Container and slides
 */

/* Carousel container */
.carousel {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #f5f5f5;
}

/* Slides container */
.carousel-slides {
  display: flex;
  transition: transform 0.5s ease-in-out;
}

/* Individual slide */
.carousel-slide {
  min-width: 100%;
  box-sizing: border-box;
  padding: 2rem;
}

/* Active slide */
.carousel-slide.active {
  /* Styling for current slide if needed */
}

/* Disable transitions for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-slides {
    transition: none;
  }
}

/* === CAROUSEL NAVIGATION BUTTONS === */

/**
 * Previous and Next buttons
 * REQUIRED for keyboard and accessibility
 */

/* Navigation button base */
.carousel-nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 48px;
  min-height: 48px;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.carousel-nav-button:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(-50%) scale(1.1);
}

.carousel-nav-button:focus {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.carousel-nav-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* Previous button */
.carousel-prev {
  left: 1rem;
}

.carousel-prev::before {
  content: '‹';
  font-size: 2rem;
  font-weight: bold;
}

/* Next button */
.carousel-next {
  right: 1rem;
}

.carousel-next::before {
  content: '›';
  font-size: 2rem;
  font-weight: bold;
}

/* Remove hover transform for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-nav-button:hover {
    transform: translateY(-50%);
  }
}

/* === PAUSE/PLAY CONTROL === */

/**
 * CRITICAL: Required for auto-advancing carousels
 */

/* Pause/play button */
.carousel-pause-button {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  min-width: 48px;
  min-height: 48px;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 4px;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.2s ease-in-out;
}

.carousel-pause-button:hover {
  background: rgba(0, 0, 0, 0.9);
}

.carousel-pause-button:focus {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

/* Button states */
.carousel-pause-button[aria-pressed="true"]::before {
  content: '⏸'; /* Pause icon - carousel is playing */
  font-size: 1.25rem;
}

.carousel-pause-button[aria-pressed="false"]::before {
  content: '▶'; /* Play icon - carousel is paused */
  font-size: 1.25rem;
}

/* Make pause button very prominent for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-pause-button {
    background: rgba(0, 0, 0, 0.9);
    border-width: 3px;
    font-weight: bold;
  }
}

/* === CAROUSEL INDICATORS (DOTS) === */

/**
 * Show current position and allow direct navigation
 */

/* Indicators container */
.carousel-indicators {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

/* Individual indicator dot */
.carousel-indicator {
  width: 12px;
  height: 12px;
  padding: 0;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.carousel-indicator:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: scale(1.2);
}

.carousel-indicator:focus {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

/* Active indicator */
.carousel-indicator.active {
  background: #ffffff;
  width: 16px;
  height: 16px;
}

.carousel-indicator[aria-current="true"] {
  background: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  .carousel-indicator:hover {
    transform: none;
  }
}

/* === CAROUSEL CAPTIONS === */

/**
 * Text overlays on slides
 */

/* Caption container */
.carousel-caption {
  position: absolute;
  bottom: 2rem;
  left: 2rem;
  right: 2rem;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border-radius: 4px;
}

.carousel-caption h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
}

.carousel-caption p {
  margin: 0;
  font-size: 1rem;
}

/* === PAUSE ON HOVER/FOCUS === */

/**
 * Auto-pause when user interacts
 * This is good UX but NOT sufficient alone
 */

/* Paused state via CSS (requires JavaScript coordination) */
.carousel:hover .carousel-slides,
.carousel:focus-within .carousel-slides {
  /* JavaScript should pause auto-advance */
  /* CSS provides visual feedback if desired */
}

/* === FADE CAROUSEL (ALTERNATIVE) === */

/**
 * Slides fade instead of sliding
 * Gentler animation
 */

/* Fade carousel slides */
.carousel-fade .carousel-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease-in-out,
              visibility 0.6s ease-in-out;
}

.carousel-fade .carousel-slide.active {
  opacity: 1;
  visibility: visible;
  position: relative;
}

/* Instant for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-fade .carousel-slide {
    transition: none;
  }

  .carousel-fade .carousel-slide.active {
    opacity: 1;
    visibility: visible;
  }
}

/* === VERTICAL CAROUSEL === */

/**
 * Slides move vertically instead of horizontally
 */

/* Vertical slides container */
.carousel-vertical .carousel-slides {
  flex-direction: column;
}

.carousel-vertical .carousel-slide {
  min-height: 400px;
  min-width: auto;
}

/* Adjust navigation for vertical */
.carousel-vertical .carousel-prev {
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
}

.carousel-vertical .carousel-prev::before {
  content: '‹';
  transform: rotate(90deg);
  display: inline-block;
}

.carousel-vertical .carousel-next {
  bottom: 1rem;
  top: auto;
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}

.carousel-vertical .carousel-next::before {
  content: '›';
  transform: rotate(90deg);
  display: inline-block;
}

/* === MULTI-ITEM CAROUSEL === */

/**
 * Shows multiple slides at once
 */

/* Show 3 slides at once */
.carousel-multi .carousel-slide {
  min-width: calc(100% / 3);
  padding: 1rem;
}

/* Responsive: 2 on tablet */
@media (max-width: 1023px) {
  .carousel-multi .carousel-slide {
    min-width: calc(100% / 2);
  }
}

/* Responsive: 1 on mobile */
@media (max-width: 767px) {
  .carousel-multi .carousel-slide {
    min-width: 100%;
  }
}

/* === THUMBNAIL NAVIGATION === */

/**
 * Small preview images for navigation
 */

/* Thumbnails container */
.carousel-thumbnails {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  overflow-x: auto;
  padding: 0.5rem 0;
}

/* Individual thumbnail */
.carousel-thumbnail {
  flex: 0 0 auto;
  width: 80px;
  height: 60px;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease-in-out,
              border-color 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.carousel-thumbnail:hover,
.carousel-thumbnail:focus {
  opacity: 1;
  border-color: var(--button-bg, #0066cc);
}

.carousel-thumbnail.active {
  opacity: 1;
  border-color: var(--button-bg, #0066cc);
  border-width: 3px;
}

.carousel-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .carousel-thumbnail:hover,
  .carousel-thumbnail:focus {
    transform: none;
  }
}

/* === PROGRESS BAR === */

/**
 * Shows time until next auto-advance
 */

/* Progress bar container */
.carousel-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  z-index: 9;
}

/* Progress fill */
.carousel-progress-bar {
  height: 100%;
  background: #ffffff;
  width: 0%;
  transition: width linear;
  /* Duration set via JavaScript based on auto-advance interval */
}

/* Hide progress for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .carousel-progress {
    display: none;
  }
}

/* === CAROUSEL CONTROLS SUMMARY BAR === */

/**
 * All controls grouped together
 */

/* Controls container */
.carousel-controls {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
}

/* Controls in one bar */
.carousel-controls .carousel-indicators {
  position: static;
  transform: none;
}

.carousel-controls .carousel-pause-button {
  position: static;
  margin-left: 1rem;
}

/* === ACCESSIBILITY FEATURES === */

/**
 * Screen reader support
 * Keyboard navigation
 * ARIA attributes
 */

/* Visually hidden but available to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Live region for announcements */
.carousel-announcer {
  /* Use aria-live="polite" in HTML */
  /* JavaScript updates with slide changes */
}

/* Example HTML:
 * <div class="carousel-announcer sr-only" aria-live="polite" aria-atomic="true">
 *   Slide 1 of 5
 * </div>
 */

/* === MOBILE OPTIMIZATIONS === */

/**
 * Touch-friendly controls on mobile
 */

/* Larger touch targets on mobile */
@media (max-width: 767px) {
  .carousel-nav-button {
    min-width: 56px;
    min-height: 56px;
  }

  .carousel-pause-button {
    min-width: 56px;
    min-height: 56px;
  }

  .carousel-indicator {
    width: 16px;
    height: 16px;
  }

  .carousel-indicator.active {
    width: 20px;
    height: 20px;
  }
}

/* Stack controls vertically on small screens */
@media (max-width: 479px) {
  .carousel-caption {
    bottom: 5rem; /* Make room for controls */
    left: 1rem;
    right: 1rem;
    padding: 1rem;
  }

  .carousel-controls {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* === SWIPE GESTURE SUPPORT === */

/**
 * Touch swipe for mobile (requires JavaScript)
 * CSS provides smooth transitions
 */

/* Disable transitions during swipe */
.carousel-swiping .carousel-slides {
  transition: none;
}

/* === AUTO-ADVANCE TIMING === */

/**
 * Controlled via JavaScript
 * CSS provides visual feedback
 */

/* Default interval: 5 seconds (set in JS) */
/* Progress bar animation duration matches */

/* === REDUCED-MOTION COMPLIANCE === */

/**
 * CRITICAL: Disable auto-advance for reduced-motion
 */

@media (prefers-reduced-motion: reduce) {
  /* Disable all carousel transitions */
  .carousel-slides,
  .carousel-slide,
  .carousel-fade .carousel-slide {
    transition: none !important;
  }

  /* JavaScript should also:
   * - Stop auto-advance
   * - Remove swipe animations
   * - Instant navigation only
   */
}

/* === JAVASCRIPT INTEGRATION === */

/**
 * Carousel requires JavaScript for full functionality
 *
 * Essential JavaScript:
 *
 * const carousel = document.querySelector('.carousel');
 * const slides = carousel.querySelectorAll('.carousel-slide');
 * const prevBtn = carousel.querySelector('.carousel-prev');
 * const nextBtn = carousel.querySelector('.carousel-next');
 * const pauseBtn = carousel.querySelector('.carousel-pause-button');
 * const indicators = carousel.querySelectorAll('.carousel-indicator');
 * const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
 *
 * let currentSlide = 0;
 * let autoAdvance = !prefersReducedMotion.matches;
 * let autoAdvanceInterval;
 *
 * // Disable auto-advance for reduced-motion
 * if (prefersReducedMotion.matches) {
 *   pauseBtn.setAttribute('aria-pressed', 'false');
 *   autoAdvance = false;
 * }
 *
 * // Navigation
 * function goToSlide(index) {
 *   slides[currentSlide].classList.remove('active');
 *   indicators[currentSlide].classList.remove('active');
 *   indicators[currentSlide].setAttribute('aria-current', 'false');
 *
 *   currentSlide = index;
 *
 *   slides[currentSlide].classList.add('active');
 *   indicators[currentSlide].classList.add('active');
 *   indicators[currentSlide].setAttribute('aria-current', 'true');
 *
 *   // Update screen reader announcement
 *   announcer.textContent = `Slide ${currentSlide + 1} of ${slides.length}`;
 * }
 *
 * // Auto-advance
 * function startAutoAdvance() {
 *   if (!autoAdvance) return;
 *
 *   autoAdvanceInterval = setInterval(() => {
 *     const next = (currentSlide + 1) % slides.length;
 *     goToSlide(next);
 *   }, 5000);
 * }
 *
 * function stopAutoAdvance() {
 *   clearInterval(autoAdvanceInterval);
 * }
 *
 * // Pause button
 * pauseBtn.addEventListener('click', () => {
 *   autoAdvance = !autoAdvance;
 *   pauseBtn.setAttribute('aria-pressed', autoAdvance.toString());
 *
 *   if (autoAdvance) {
 *     startAutoAdvance();
 *   } else {
 *     stopAutoAdvance();
 *   }
 * });
 *
 * // Pause on hover/focus
 * carousel.addEventListener('mouseenter', stopAutoAdvance);
 * carousel.addEventListener('mouseleave', () => {
 *   if (autoAdvance) startAutoAdvance();
 * });
 *
 * carousel.addEventListener('focusin', stopAutoAdvance);
 * carousel.addEventListener('focusout', () => {
 *   if (autoAdvance) startAutoAdvance();
 * });
 *
 * // Keyboard navigation
 * carousel.addEventListener('keydown', (e) => {
 *   if (e.key === 'ArrowLeft') {
 *     const prev = currentSlide === 0 ? slides.length - 1 : currentSlide - 1;
 *     goToSlide(prev);
 *   } else if (e.key === 'ArrowRight') {
 *     const next = (currentSlide + 1) % slides.length;
 *     goToSlide(next);
 *   }
 * });
 *
 * // Start auto-advance
 * startAutoAdvance();
 */

/* === CAROUSEL GUIDELINES === */

/**
 * Best practices and requirements:
 *
 * ✓ REQUIRED:
 *   [ ] Pause/play button (48x48px minimum)
 *   [ ] Previous/next navigation
 *   [ ] Keyboard support (arrow keys, tab)
 *   [ ] ARIA labels and roles
 *   [ ] Screen reader announcements
 *   [ ] Disable auto-advance for reduced-motion
 *   [ ] Pause on hover/focus
 *   [ ] Position indicators (dots/thumbnails)
 *   [ ] All controls keyboard accessible
 *   [ ] Focus indicators visible
 *
 * ✓ RECOMMENDED:
 *   [ ] Auto-advance interval: 5+ seconds
 *   [ ] Progress bar showing time remaining
 *   [ ] Thumbnail navigation
 *   [ ] Swipe support on mobile
 *   [ ] Larger touch targets on mobile (56x56px)
 *   [ ] Limit to 5-7 slides maximum
 *   [ ] Don't auto-start on page load (user initiates)
 *
 * ⚠ USE WITH CAUTION:
 *   [ ] Auto-advancing carousels at all
 *   [ ] More than one carousel per page
 *   [ ] Carousels with critical information
 *   [ ] Very fast auto-advance (< 5 seconds)
 *
 * ✗ NEVER:
 *   [ ] Auto-advance without pause control
 *   [ ] Auto-advance for reduced-motion users
 *   [ ] Navigation buttons only (no indicators)
 *   [ ] Essential content in carousel only
 *   [ ] Carousel as only way to access content
 *   [ ] Hover-only controls (need keyboard)
 */

/* === TESTING CHECKLIST === */

/**
 * Before deploying carousel:
 *
 * ✓ Functionality:
 *   [ ] Auto-advance works (if enabled)
 *   [ ] Pause button works
 *   [ ] Previous/next buttons work
 *   [ ] Indicators work
 *   [ ] Pauses on hover
 *   [ ] Pauses on focus
 *   [ ] Loops correctly
 *
 * ✓ Keyboard:
 *   [ ] Tab reaches all controls
 *   [ ] Arrow keys navigate slides
 *   [ ] Enter/Space activates buttons
 *   [ ] Focus indicators visible
 *   [ ] Focus not trapped
 *
 * ✓ Screen Reader:
 *   [ ] Announces slide changes
 *   [ ] Announces total count
 *   [ ] Button labels clear
 *   [ ] Current slide indicated
 *   [ ] Auto-advance status announced
 *
 * ✓ Reduced-Motion:
 *   [ ] Auto-advance disabled
 *   [ ] Transitions instant
 *   [ ] Still fully functional
 *   [ ] Pause button shows paused state
 *
 * ✓ Mobile:
 *   [ ] Touch targets large enough
 *   [ ] Swipe gestures work
 *   [ ] Controls don't overlap content
 *   [ ] Readable on small screens
 */

/* Infinite Scrolling and Auto-loading
 * Automatically loading content as user scrolls or content updates */

/**
 * WCAG 2.2.2 requires that auto-updating content can be paused/stopped
 *
 * Infinite scroll and auto-loading can be problematic:
 * - Keyboard users may never reach footer
 * - Screen readers struggle with dynamic content
 * - Loss of user control
 * - Performance issues
 * - Must provide pause mechanism
 *
 * Best practice: Provide "Load More" button as alternative
 */

/* === INFINITE SCROLL CONTAINER === */

/**
 * Container for infinitely scrolling content
 */

/* Content container */
.infinite-scroll-container {
  width: 100%;
  min-height: 100vh;
}

/* List of items */
.infinite-scroll-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  padding: 2rem;
}

/* Individual items */
.infinite-scroll-item {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
  transition: box-shadow 0.3s ease-in-out;
}

.infinite-scroll-item:hover,
.infinite-scroll-item:focus-within {
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* === LOADING INDICATOR === */

/**
 * Shows while new content is being loaded
 */

/* Loading spinner at bottom */
.infinite-scroll-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  min-height: 100px;
}

.infinite-scroll-loader.hidden {
  display: none;
}

/* Spinner */
.infinite-scroll-loader .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--button-bg, #0066cc);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Static loader for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .infinite-scroll-loader .spinner {
    animation: none;
    border: 4px solid var(--button-bg, #0066cc);
    opacity: 0.7;
  }
}

/* Loading text */
.infinite-scroll-loader-text {
  margin-left: 1rem;
  font-size: 1rem;
  color: #666666;
}

/* === PAUSE CONTROL === */

/**
 * REQUIRED: Button to pause infinite scrolling
 */

/* Pause/resume button (fixed position) */
.infinite-scroll-pause {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  min-width: 56px;
  min-height: 56px;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: background-color 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.infinite-scroll-pause:hover {
  background: rgba(0, 0, 0, 0.95);
  transform: scale(1.1);
}

.infinite-scroll-pause:focus {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

/* Button states */
.infinite-scroll-pause[aria-pressed="true"]::before {
  content: '⏸'; /* Pause icon - auto-loading active */
  font-size: 1.5rem;
}

.infinite-scroll-pause[aria-pressed="false"]::before {
  content: '▶'; /* Play icon - auto-loading paused */
  font-size: 1.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .infinite-scroll-pause {
    /* Make very prominent for reduced-motion users */
    background: rgba(0, 0, 0, 0.95);
    border-width: 3px;
  }

  .infinite-scroll-pause:hover {
    transform: none;
  }
}

/* === LOAD MORE BUTTON (ALTERNATIVE) === */

/**
 * Manual "Load More" button - better accessibility
 * Should be provided as alternative to infinite scroll
 */

/* Load more button */
.load-more-button {
  display: block;
  margin: 3rem auto;
  min-width: 200px;
  min-height: 48px;
  padding: 1rem 2rem;
  background: var(--button-bg, #0066cc);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out,
              transform 0.2s ease-in-out;
}

.load-more-button:hover {
  background: var(--button-hover-bg, #0052a3);
  transform: translateY(-2px);
}

.load-more-button:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 3px;
}

.load-more-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .load-more-button:hover {
    transform: none;
  }
}

/* Hide when infinite scroll is active */
.infinite-scroll-active .load-more-button {
  display: none;
}

/* === END OF CONTENT INDICATOR === */

/**
 * Shows when all content has been loaded
 */

/* End message */
.infinite-scroll-end {
  text-align: center;
  padding: 3rem 1rem;
  color: #666666;
  font-size: 1rem;
}

.infinite-scroll-end::before {
  content: '';
  display: block;
  width: 100px;
  height: 2px;
  background: #e0e0e0;
  margin: 0 auto 1rem;
}

/* === SKELETON LOADING STATES === */

/**
 * Placeholder items while content loads
 */

/* Skeleton item */
.skeleton-item {
  background: #f0f0f0;
  border-radius: 8px;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

/* Skeleton shimmer effect */
.skeleton-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  from { left: -100%; }
  to { left: 100%; }
}

/* Static skeleton for reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .skeleton-item::before {
    animation: none;
    display: none;
  }
}

/* Skeleton content placeholders */
.skeleton-title {
  height: 1.5rem;
  width: 70%;
  background: #e0e0e0;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.skeleton-text {
  height: 1rem;
  width: 100%;
  background: #e0e0e0;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
  width: 60%;
}

/* === AUTO-REFRESHING CONTENT === */

/**
 * Content that updates automatically (news feeds, live data)
 * Must provide pause control
 */

/* Auto-refresh container */
.auto-refresh-container {
  position: relative;
}

/* New content notification */
.new-content-notification {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 1rem 2rem;
  background: var(--button-bg, #0066cc);
  color: #ffffff;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 1000;
  cursor: pointer;
  transition: transform 0.3s ease-out,
              opacity 0.3s ease-out;
}

.new-content-notification.hidden {
  transform: translateX(-50%) translateY(-100px);
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .new-content-notification {
    transition: opacity 0.01ms;
  }

  .new-content-notification.hidden {
    transform: translateX(-50%);
  }
}

/* === LIVE UPDATE INDICATOR === */

/**
 * Shows that content is updating live
 */

/* Live indicator */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f5f5f5;
  border-radius: 4px;
  margin-bottom: 1rem;
}

/* Pulsing dot */
.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #00c853;
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot {
    animation: none;
    opacity: 1;
  }
}

/* Live text */
.live-text {
  font-size: 0.875rem;
  font-weight: bold;
  color: #333333;
}

/* Pause updates button */
.pause-updates-button {
  margin-left: auto;
  min-width: 44px;
  min-height: 32px;
  padding: 0.25rem 0.75rem;
  background: #ffffff;
  color: #333333;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

.pause-updates-button:hover {
  background: #f5f5f5;
}

.pause-updates-button:focus {
  outline: 2px solid var(--button-bg, #0066cc);
  outline-offset: 2px;
}

/* === SCROLL POSITION PRESERVATION === */

/**
 * Maintain scroll position when new content loads at top
 */

/* Anchor element for scroll preservation */
.scroll-anchor {
  position: relative;
}

/* === INTERSECTION OBSERVER SENTINEL === */

/**
 * Invisible element that triggers loading
 * Styled for debugging purposes
 */

/* Sentinel element */
.infinite-scroll-sentinel {
  height: 1px;
  width: 100%;
  /* Invisible in production */
  /* visibility: hidden; */

  /* Visible for debugging */
  /* background: red; */
  /* min-height: 50px; */
}

/* === FOOTER ACCESSIBILITY === */

/**
 * CRITICAL: Footer must be accessible with infinite scroll
 * Provide "Jump to Footer" link
 */

/* Skip to footer link */
.skip-to-footer {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 100;
  min-width: 44px;
  min-height: 44px;
  padding: 0.75rem 1.5rem;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 4px;
  text-decoration: none;
  font-weight: bold;
  transition: background-color 0.2s ease-in-out;
}

.skip-to-footer:hover,
.skip-to-footer:focus {
  background: rgba(0, 0, 0, 0.95);
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* === PAGINATION CONTROLS (HYBRID APPROACH) === */

/**
 * Combine infinite scroll with pagination
 * Best of both worlds
 */

/* Pagination container */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
}

/* Page number button */
.page-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 1rem;
  background: #ffffff;
  color: #333333;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out,
              border-color 0.2s ease-in-out;
}

.page-button:hover,
.page-button:focus {
  background: #f5f5f5;
  border-color: var(--button-bg, #0066cc);
}

.page-button.active {
  background: var(--button-bg, #0066cc);
  color: #ffffff;
  border-color: var(--button-bg, #0066cc);
}

/* === VIRTUAL SCROLLING === */

/**
 * Only render visible items (performance optimization)
 * CSS provides styling, JavaScript handles rendering
 */

/* Scroll container with fixed height */
.virtual-scroll-container {
  height: 600px;
  overflow-y: auto;
  position: relative;
}

/* Virtual spacer (maintains scroll height) */
.virtual-scroll-spacer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  /* Height set via JavaScript based on total items */
}

/* Viewport for visible items */
.virtual-scroll-viewport {
  position: relative;
  /* Transform set via JavaScript based on scroll position */
}

/* === SCREEN READER ANNOUNCEMENTS === */

/**
 * Announce when new content loads
 */

/* Live region for announcements */
.infinite-scroll-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Use aria-live="polite" in HTML */
/* JavaScript updates with: "Loaded 10 more items. Total: 50 items." */

/* === MOBILE OPTIMIZATIONS === */

/**
 * Touch-friendly controls
 */

@media (max-width: 767px) {
  /* Larger touch targets */
  .infinite-scroll-pause,
  .skip-to-footer {
    min-width: 60px;
    min-height: 60px;
  }

  /* Adjust positioning for thumbs */
  .infinite-scroll-pause {
    bottom: 1rem;
    right: 1rem;
  }

  .skip-to-footer {
    bottom: 1rem;
    left: 1rem;
  }

  /* Stack items single column */
  .infinite-scroll-list {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
  }
}

/* === REDUCED-MOTION COMPLIANCE === */

/**
 * Disable auto-loading for reduced-motion users
 */

@media (prefers-reduced-motion: reduce) {
  /* JavaScript should:
   * - Disable auto-loading
   * - Show "Load More" button instead
   * - Pause button shows paused state
   */

  /* Ensure pause button is visible and prominent */
  .infinite-scroll-pause {
    background: rgba(0, 0, 0, 0.95);
    border-width: 3px;
  }

  /* Show load more button by default */
  .load-more-button {
    display: block;
  }
}

/* === JAVASCRIPT INTEGRATION === */

/**
 * Infinite scroll requires JavaScript
 *
 * Essential functionality:
 *
 * const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
 * const container = document.querySelector('.infinite-scroll-container');
 * const sentinel = document.querySelector('.infinite-scroll-sentinel');
 * const pauseBtn = document.querySelector('.infinite-scroll-pause');
 * const loadMoreBtn = document.querySelector('.load-more-button');
 * const announcer = document.querySelector('.infinite-scroll-announcer');
 *
 * let isActive = !prefersReducedMotion.matches;
 * let isLoading = false;
 * let currentPage = 1;
 * let totalItems = 0;
 *
 * // Disable for reduced-motion
 * if (prefersReducedMotion.matches) {
 *   pauseBtn.setAttribute('aria-pressed', 'false');
 *   loadMoreBtn.style.display = 'block';
 *   isActive = false;
 * }
 *
 * // Intersection Observer for auto-loading
 * const observer = new IntersectionObserver((entries) => {
 *   entries.forEach(entry => {
 *     if (entry.isIntersecting && isActive && !isLoading) {
 *       loadMore();
 *     }
 *   });
 * }, {
 *   rootMargin: '200px' // Load before reaching sentinel
 * });
 *
 * if (isActive) {
 *   observer.observe(sentinel);
 * }
 *
 * // Load more function
 * async function loadMore() {
 *   isLoading = true;
 *   // Show loading indicator
 *
 *   const newItems = await fetchItems(currentPage);
 *   appendItems(newItems);
 *
 *   currentPage++;
 *   totalItems += newItems.length;
 *
 *   // Announce to screen readers
 *   announcer.textContent = `Loaded ${newItems.length} more items. Total: ${totalItems} items.`;
 *
 *   isLoading = false;
 * }
 *
 * // Pause button
 * pauseBtn.addEventListener('click', () => {
 *   isActive = !isActive;
 *   pauseBtn.setAttribute('aria-pressed', isActive.toString());
 *
 *   if (isActive) {
 *     observer.observe(sentinel);
 *     loadMoreBtn.style.display = 'none';
 *   } else {
 *     observer.unobserve(sentinel);
 *     loadMoreBtn.style.display = 'block';
 *   }
 * });
 *
 * // Load more button (fallback)
 * loadMoreBtn.addEventListener('click', loadMore);
 */

/* === INFINITE SCROLL GUIDELINES === */

/**
 * Best practices and requirements:
 *
 * ✓ REQUIRED:
 *   [ ] Pause control (visible, 56x56px)
 *   [ ] "Load More" button as alternative
 *   [ ] Keyboard accessible
 *   [ ] Screen reader announcements
 *   [ ] Disabled for reduced-motion
 *   [ ] Footer still accessible
 *   [ ] ARIA live regions
 *   [ ] Focus management
 *
 * ✓ RECOMMENDED:
 *   [ ] Skeleton loading states
 *   [ ] "Jump to Footer" link
 *   [ ] Pagination as alternative
 *   [ ] Load before reaching bottom (rootMargin)
 *   [ ] Preserve scroll position
 *   [ ] Show item count
 *   [ ] "End of content" indicator
 *   [ ] Virtual scrolling for large lists
 *
 * ⚠ USE WITH CAUTION:
 *   [ ] Infinite scroll on main navigation pages
 *   [ ] Auto-loading without pause
 *   [ ] Very frequent updates (< 5 seconds)
 *
 * ✗ NEVER:
 *   [ ] Infinite scroll without pause control
 *   [ ] No "Load More" alternative
 *   [ ] Inaccessible footer
 *   [ ] Auto-load for reduced-motion users
 *   [ ] No screen reader support
 *   [ ] Infinite scroll for critical content only
 */

/* === TESTING CHECKLIST === */

/**
 * Before deploying infinite scroll:
 *
 * ✓ Functionality:
 *   [ ] Auto-loads near bottom
 *   [ ] Pause button works
 *   [ ] Load more button works
 *   [ ] End of content shows
 *   [ ] Loading indicators appear
 *   [ ] No duplicate items
 *
 * ✓ Keyboard:
 *   [ ] Tab reaches all controls
 *   [ ] Can reach footer
 *   [ ] Focus visible
 *   [ ] Focus not lost after loading
 *
 * ✓ Screen Reader:
 *   [ ] Announces new items
 *   [ ] Announces item count
 *   [ ] Pause button labeled
 *   [ ] Loading state announced
 *
 * ✓ Reduced-Motion:
 *   [ ] Auto-loading disabled
 *   [ ] Load more button shown
 *   [ ] Still functional
 *   [ ] Transitions removed
 *
 * ✓ Performance:
 *   [ ] Smooth scrolling
 *   [ ] No jank during load
 *   [ ] Memory doesn't balloon
 *   [ ] Works on slow connections
 */

/* 14. Animation Duration and Timing
 * ========================================================================== */
/**
 * Timing best practices:
 * - Short durations (0.15-0.3s for most interactions)
 * - Longer durations (0.3-0.6s for complex animations)
 * - Ease-in-out for natural feel
 * Zero duration for reduced-motion
 */

/* 15. Reduced Motion Utilities
 * ========================================================================== */
/**
 * Helper classes and patterns:
 * - .no-motion class for manual control
 * - JavaScript detection support
 * - Fallback strategies
 */
