/**
 * Automated Living Accessibility Widget Styles v2
 * Matches the automated.la design language
 */

/* Brand Tokens */
:root {
  --al-primary: #1d3557;
  --al-accent: #f4a261;
  --al-surface: #ffffff;
  --al-surface-muted: #f4f5f7;
  --al-text: #1e1e1e;
  --al-text-muted: #4b5563;
  --al-border: rgba(15,23,42,0.06);
  --al-surface-dark: #0f172a;
  --al-text-dark: #e2e8f0;
  
  /* Widget specific tokens */
  --a11y-panel-width: 380px;
  --a11y-panel-max-height: 85vh;
  --a11y-launcher-size: 56px;
  --a11y-z-index: 999999;
  --a11y-shadow: 0 10px 40px rgba(0,0,0,0.15);
  --a11y-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Launcher Button */
.a11y-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--a11y-launcher-size);
  height: var(--a11y-launcher-size);
  border-radius: 50%;
  background: var(--al-primary);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(29, 53, 87, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--a11y-z-index);
  transition: var(--a11y-transition);
}

.a11y-launcher:hover {
  background: #2a4873;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(29, 53, 87, 0.4);
}

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

.a11y-launcher svg {
  width: 28px;
  height: 28px;
}

/* Main Panel */
.a11y-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: var(--a11y-panel-width);
  max-height: var(--a11y-panel-max-height);
  background: var(--al-surface);
  box-shadow: var(--a11y-shadow);
  border-radius: 1.25rem 0 0 0;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: calc(var(--a11y-z-index) - 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.a11y-panel.open {
  transform: translateX(0);
}

.a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  background: var(--al-surface-muted);
  border-bottom: 1px solid var(--al-border);
}

.a11y-panel-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--al-text);
  margin: 0;
}

.a11y-panel-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--al-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--a11y-transition);
}

.a11y-panel-close:hover {
  background: rgba(0,0,0,0.05);
  color: var(--al-text);
}

.a11y-panel-close:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: -2px;
}

.a11y-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
}

/* Sections */
.a11y-section {
  margin-bottom: 1rem;
}

.a11y-section:last-child {
  margin-bottom: 0;
}

/* Action buttons section */
.a11y-action-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.a11y-action-buttons button {
  flex: 1;
}

.a11y-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--al-text);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Statement Button */
.a11y-statement-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: white;
  border: 2px solid var(--al-border);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--al-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--a11y-transition);
}

.a11y-statement-btn:hover {
  background: var(--al-surface-muted);
  border-color: var(--al-primary);
  color: var(--al-primary);
}

.a11y-statement-btn:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: 2px;
}

.a11y-statement-btn svg {
  width: 20px;
  height: 20px;
}

/* Modal Styles */
.a11y-modal {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.a11y-modal.open {
  display: flex;
}

.a11y-modal-content {
  background: var(--al-surface);
  border-radius: 0.75rem;
  width: 100%;
  max-width: 100%;
  max-height: 70%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.a11y-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--al-surface-muted);
  border-bottom: 1px solid var(--al-border);
}

.a11y-modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--al-primary);
  margin: 0;
}

.a11y-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--al-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--a11y-transition);
}

.a11y-modal-close:hover {
  background: rgba(0,0,0,0.05);
  color: var(--al-text);
}

.a11y-modal-close:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: -2px;
}

.a11y-modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.a11y-modal-body p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--al-text);
  margin: 0 0 0.75rem 0;
}

.a11y-modal-body p:last-child {
  margin-bottom: 0;
}

.a11y-modal-body a {
  color: var(--al-primary);
  text-decoration: underline;
}

/* Dark mode modal */
html.dark-mode .a11y-modal-content {
  background: var(--al-surface-dark);
  color: var(--al-text-dark);
}

html.dark-mode .a11y-modal-header {
  background: rgba(255,255,255,0.05);
  border-bottom-color: rgba(255,255,255,0.1);
}

html.dark-mode .a11y-modal-header h3 {
  color: var(--al-text-dark);
}

html.dark-mode .a11y-modal-body p {
  color: var(--al-text-dark);
}

html.dark-mode .a11y-modal-body a {
  color: var(--al-accent);
}

/* Reset Button */
.a11y-reset-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: white;
  border: 2px solid var(--al-border);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--al-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--a11y-transition);
}

.a11y-reset-btn:hover {
  background: var(--al-surface-muted);
  border-color: var(--al-primary);
  color: var(--al-primary);
}

.a11y-reset-btn:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: 2px;
}

.a11y-reset-btn svg {
  width: 20px;
  height: 20px;
}

/* Profile Cards */
.a11y-profiles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.a11y-profile-card {
  background: var(--al-surface);
  border: 2px solid var(--al-border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: var(--a11y-transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
}

.a11y-profile-card:hover {
  background: var(--al-surface-muted);
  border-color: rgba(29, 53, 87, 0.2);
}

.a11y-profile-card.active {
  background: linear-gradient(135deg, rgba(29, 53, 87, 0.1), rgba(244, 162, 97, 0.1));
  border-color: var(--al-accent);
}

.a11y-profile-card:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: -1px;
}

.a11y-profile-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.a11y-profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--al-text);
}

.a11y-profile-desc {
  font-size: 0.7rem;
  color: var(--al-text-muted);
  line-height: 1.2;
}

/* Controls */
.a11y-controls {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.a11y-control {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.a11y-control label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--al-text);
  cursor: pointer;
}

.a11y-control label span {
  flex: 1;
}

/* Toggle Switches */
.a11y-control input[type="checkbox"] {
  appearance: none;
  width: 44px;
  height: 24px;
  background: #e5e7eb;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: var(--a11y-transition);
}

.a11y-control input[type="checkbox"]:before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: var(--a11y-transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.a11y-control input[type="checkbox"]:checked {
  background: var(--al-accent);
}

.a11y-control input[type="checkbox"]:checked:before {
  left: 23px;
}

.a11y-control input[type="checkbox"]:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: 2px;
}

/* Sliders */
.a11y-slider-control label {
  font-size: 0.9rem;
  color: var(--al-text);
  margin-bottom: 0.5rem;
}

.a11y-slider-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.a11y-slider-wrapper input[type="range"] {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}

.a11y-slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--al-accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: var(--a11y-transition);
}

.a11y-slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.a11y-slider-wrapper input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--al-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.a11y-slider-wrapper input[type="range"]:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: 4px;
}

.a11y-slider-value {
  min-width: 45px;
  font-size: 0.85rem;
  color: var(--al-text-muted);
  text-align: right;
}

/* Button Groups */
.a11y-button-group {
  display: flex;
  gap: 0.5rem;
  border: 1px solid var(--al-border);
  border-radius: 0.5rem;
  padding: 0.25rem;
  background: var(--al-surface-muted);
}

.a11y-align-btn {
  flex: 1;
  padding: 0.5rem;
  background: transparent;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--a11y-transition);
  color: var(--al-text-muted);
}

.a11y-align-btn:hover {
  background: white;
  color: var(--al-text);
}

.a11y-align-btn.active {
  background: white;
  color: var(--al-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.a11y-align-btn:focus {
  outline: 2px solid var(--al-accent);
  outline-offset: -2px;
}

/* Accessibility Feature Classes */

/* Readable Font */
html.a11y-readable-font {
  font-family: 'Atkinson Hyperlegible', 'Arial', sans-serif !important;
}

html.a11y-readable-font * {
  font-family: inherit !important;
}

/* Highlight Titles */
html.a11y-highlight-titles h1,
html.a11y-highlight-titles h2,
html.a11y-highlight-titles h3,
html.a11y-highlight-titles h4,
html.a11y-highlight-titles h5,
html.a11y-highlight-titles h6 {
  background: linear-gradient(90deg, rgba(244, 162, 97, 0.2), transparent);
  padding: 0.25em 0.5em;
  border-left: 4px solid var(--al-accent);
  margin-left: -0.5em;
}

/* Highlight Links - Enhanced with subtle background and improved contrast */
html.a11y-highlight-links a:not([href^="tel:"]) {
  background-color: rgba(255, 235, 59, 0.1) !important; /* Much lighter yellow background */
  padding: 2px 4px !important;
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 2px !important;
  text-decoration-color: #1976d2 !important;
  border-radius: 2px !important;
  box-shadow: 0 0 0 1px rgba(25, 118, 210, 0.2) !important; /* Subtle blue outline */
  color: #1565c0 !important; /* Ensure readable blue text color */
}

html.a11y-highlight-links a:not([href^="tel:"]):hover {
  background-color: rgba(255, 235, 59, 0.15) !important; /* Slightly more visible on hover */
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.3) !important; /* Stronger outline on hover */
  color: #0d47a1 !important; /* Darker blue on hover for better contrast */
}

html.dark-mode.a11y-highlight-links a:not([href^="tel:"]) {
  background-color: rgba(255, 235, 59, 0.08) !important; /* Even lighter in dark mode */
  color: #64b5f6 !important; /* Light blue for dark mode */
  text-decoration-color: #64b5f6 !important;
  box-shadow: 0 0 0 1px rgba(100, 181, 246, 0.3) !important;
}

html.dark-mode.a11y-highlight-links a:not([href^="tel:"]):hover {
  background-color: rgba(255, 235, 59, 0.12) !important;
  box-shadow: 0 0 0 2px rgba(100, 181, 246, 0.4) !important;
  color: #90caf9 !important; /* Lighter blue on hover in dark mode */
}

/* Special handling for telephone links when highlight-links is enabled */
html.a11y-highlight-links a[href^="tel:"] {
  color: #000000 !important;
  background-color: var(--al-accent) !important;
  padding: 8px 16px !important;
  text-decoration: none !important;
  font-weight: bold !important;
  border-radius: 4px !important;
  display: inline-block !important;
}

html.a11y-highlight-links a[href^="tel:"]:hover {
  background-color: #e09020 !important;
  color: #000000 !important;
}

html.dark-mode.a11y-highlight-links a[href^="tel:"] {
  color: #000000 !important;
  background-color: var(--al-accent) !important;
}

html.dark-mode.a11y-highlight-links a[href^="tel:"]:hover {
  background-color: #e09020 !important;
  color: #000000 !important;
}

/* Vision Impaired Profile Fixes */
/* Fix Call Us button contrast when Vision Impaired is active */
html.a11y-highlight-links a.btn-primary,
html.a11y-highlight-links .call-btn,
html.a11y-highlight-links button[onclick*="tel:"] {
  color: #000000 !important;
  background-color: var(--al-accent) !important;
  padding: 8px 16px !important;
  font-weight: bold !important;
}

html.a11y-highlight-links a.btn-primary:hover,
html.a11y-highlight-links .call-btn:hover,
html.a11y-highlight-links button[onclick*="tel:"]:hover {
  background-color: #e09020 !important;
  color: #000000 !important;
}

/* Ensure dark mode button icon remains visible */
html.a11y-readable-font #dark-mode-toggle i,
html.a11y-highlight-links #dark-mode-toggle i,
html.a11y-highlight-titles #dark-mode-toggle i {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Fix icon visibility for all buttons when Vision Impaired features are active */
html.a11y-readable-font button i,
html.a11y-highlight-links button i,
html.a11y-highlight-titles button i,
html.a11y-readable-font button svg,
html.a11y-highlight-links button svg,
html.a11y-highlight-titles button svg {
  visibility: visible !important;
  opacity: 1 !important;
  display: inline-block !important;
}

/* Ensure Call Us buttons maintain proper contrast in all Vision Impaired scenarios */
html.a11y-readable-font a[href^="tel:"],
html.a11y-highlight-links a[href^="tel:"],
html.a11y-highlight-titles a[href^="tel:"] {
  color: #000000 !important;
  background-color: var(--al-accent) !important;
  padding: 8px 16px !important;
  font-weight: bold !important;
  border-radius: 4px !important;
}

/* Dark mode + Vision Impaired: ensure proper contrast */
html.dark-mode.a11y-highlight-links a[href^="tel:"],
html.dark-mode.a11y-readable-font a[href^="tel:"],
html.dark-mode.a11y-highlight-titles a[href^="tel:"] {
  color: #000000 !important;
  background-color: var(--al-accent) !important;
}

/* Ensure navbar Call Us button maintains visibility */
.nav-links html.a11y-highlight-links a[href^="tel:"],
header html.a11y-highlight-links a[href^="tel:"],
html.a11y-highlight-links .nav-links a[href^="tel:"],
html.a11y-highlight-links header a[href^="tel:"] {
  color: #000000 !important;
  background-color: var(--al-accent) !important;
  padding: 8px 16px !important;
  font-weight: bold !important;
}

/* Text Magnifier - Feature removed due to usability issues */

/* Text Alignment */
html.a11y-align-left * {
  text-align: left !important;
}

html.a11y-align-center * {
  text-align: center !important;
}

html.a11y-align-right * {
  text-align: right !important;
}

html.a11y-align-justify * {
  text-align: justify !important;
}

/* Color Adjustments */

/* Dark Mode Integration */
html.dark-mode {
  background: var(--al-surface-dark) !important;
  color: var(--al-text-dark) !important;
}

html.dark-mode .a11y-panel {
  background: var(--al-surface-dark);
  color: var(--al-text-dark);
}

html.dark-mode .a11y-panel-header {
  background: rgba(255,255,255,0.05);
  border-bottom-color: rgba(255,255,255,0.1);
}

html.dark-mode .a11y-panel-title {
  color: var(--al-text-dark);
}

html.dark-mode .a11y-section-title {
  color: var(--al-text-dark);
}

html.dark-mode .a11y-control label {
  color: var(--al-text-dark);
}

html.dark-mode .a11y-profile-name {
  color: var(--al-text-dark);
}

html.dark-mode .a11y-reset-btn {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
  color: var(--al-text-dark);
}

html.dark-mode .a11y-reset-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* High Contrast Mode - Improved */
html.a11y-high-contrast {
  background: #ffffff !important;
  color: #000000 !important;
}

html.a11y-high-contrast * {
  background-color: transparent !important;
  color: #000000 !important;
  border-color: #000000 !important;
}

/* Fix navbar transparency in dark mode + high contrast */
html.dark-mode.a11y-high-contrast {
  background: #000000 !important;
  color: #ffffff !important;
}

html.dark-mode.a11y-high-contrast * {
  color: #ffffff !important;
  border-color: #ffffff !important;
}

/* Ensure navbar has background in dark mode + high contrast */
html.dark-mode.a11y-high-contrast header,
html.dark-mode.a11y-high-contrast nav,
html.dark-mode.a11y-high-contrast .nav-links {
  background: #000000 !important;
}

/* Ensure header always has background in high contrast */
html.a11y-high-contrast header {
  background: #ffffff !important;
}

html.a11y-high-contrast a {
  color: #0000ff !important;
  text-decoration: underline !important;
  font-weight: bold !important;
}

html.dark-mode.a11y-high-contrast a {
  color: #00ffff !important;
}

html.a11y-high-contrast button,
html.a11y-high-contrast input,
html.a11y-high-contrast select,
html.a11y-high-contrast textarea {
  border: 2px solid #000000 !important;
  background: #ffffff !important;
  color: #000000 !important;
}

html.dark-mode.a11y-high-contrast button,
html.dark-mode.a11y-high-contrast input,
html.dark-mode.a11y-high-contrast select,
html.dark-mode.a11y-high-contrast textarea {
  border: 2px solid #ffffff !important;
  background: #000000 !important;
  color: #ffffff !important;
}

html.a11y-high-contrast button:hover {
  background: #000000 !important;
  color: #ffffff !important;
}

html.dark-mode.a11y-high-contrast button:hover {
  background: #ffffff !important;
  color: #000000 !important;
}

/* Fix radio button visibility in high contrast modes */
html.a11y-high-contrast input[type="radio"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  width: 20px !important;
  height: 20px !important;
  border: 2px solid #000000 !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  position: relative !important;
  cursor: pointer !important;
  display: inline-block !important;
  vertical-align: middle !important;
  margin-right: 8px !important;
}

html.a11y-high-contrast input[type="radio"]:checked::after {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  background: #000000 !important;
}

html.dark-mode.a11y-high-contrast input[type="radio"] {
  border: 2px solid #ffffff !important;
  background: #000000 !important;
}

html.dark-mode.a11y-high-contrast input[type="radio"]:checked::after {
  background: #ffffff !important;
}

html.a11y-high-contrast input[type="radio"]:focus {
  outline: 3px solid #0000ff !important;
  outline-offset: 2px !important;
}

html.dark-mode.a11y-high-contrast input[type="radio"]:focus {
  outline: 3px solid #00ffff !important;
  outline-offset: 2px !important;
}

html.a11y-high-contrast .a11y-panel {
  background: #ffffff !important;
  border: 2px solid #000000 !important;
}

html.dark-mode.a11y-high-contrast .a11y-panel {
  background: #000000 !important;
  border: 2px solid #ffffff !important;
}

html.a11y-high-contrast .a11y-launcher {
  background: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #000000 !important;
}

html.dark-mode.a11y-high-contrast .a11y-launcher {
  background: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
}

html.a11y-high-contrast .a11y-profile-card.active {
  background: #000000 !important;
  color: #ffffff !important;
}

html.a11y-high-contrast .a11y-profile-card.active * {
  color: #ffffff !important;
}

html.dark-mode.a11y-high-contrast .a11y-profile-card.active {
  background: #ffffff !important;
  color: #000000 !important;
}

html.dark-mode.a11y-high-contrast .a11y-profile-card.active * {
  color: #000000 !important;
}

/* Low Saturation */
html.a11y-low-saturation {
  filter: saturate(0.5);
}

/* Monochrome */
html.a11y-monochrome {
  filter: grayscale(100%);
}

/* Orientation Features */

/* Hide Images - More comprehensive */
html.a11y-hide-images img,
html.a11y-hide-images video,
html.a11y-hide-images svg,
html.a11y-hide-images picture,
html.a11y-hide-images canvas,
html.a11y-hide-images embed,
html.a11y-hide-images object,
html.a11y-hide-images iframe[src*="youtube"],
html.a11y-hide-images iframe[src*="vimeo"] {
  opacity: 0 !important;
  visibility: hidden !important;
}

html.a11y-hide-images img::before,
html.a11y-hide-images img::after {
  content: "Image hidden" !important;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  background: #f0f0f0 !important;
  color: #666 !important;
  padding: 0.5rem !important;
  text-align: center !important;
  font-size: 0.875rem !important;
}

/* Read Mode */
html.a11y-read-mode {
  max-width: 800px !important;
  margin: 0 auto !important;
  padding: 2rem !important;
}

html.a11y-read-mode * {
  background: white !important;
  color: black !important;
}

html.a11y-read-mode main,
html.a11y-read-mode article {
  font-size: 1.1em !important;
  line-height: 1.8 !important;
}

/* Reading Mask/Guide - Fixed implementation */
.a11y-reading-mask-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: calc(var(--a11y-z-index) - 2);
}

.a11y-reading-mask-overlay {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5); /* Semi-transparent dark overlay */
  pointer-events: none;
}

.a11y-reading-mask-top {
  top: 0;
  height: 0; /* Will be set dynamically */
}

.a11y-reading-mask-bottom {
  bottom: 0;
  top: 0; /* Will be set dynamically */
}

.a11y-reading-guide-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 100px;
  border-top: 2px solid rgba(244, 162, 97, 0.8); /* Orange guide line */
  border-bottom: 2px solid rgba(244, 162, 97, 0.8);
  background: transparent; /* Clear reading area */
  pointer-events: none;
}

/* Big Cursor */
html.a11y-big-cursor * {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><circle cx="16" cy="16" r="14" fill="%231d3557" opacity="0.8"/><circle cx="16" cy="16" r="3" fill="white"/></svg>') 16 16, auto !important;
}

/* Additional Vision Impaired fixes for specific elements */
/* Fix for FontAwesome icons in buttons when Vision Impaired is active */
html.a11y-readable-font .fa,
html.a11y-readable-font .fas,
html.a11y-readable-font .far,
html.a11y-readable-font .fab,
html.a11y-highlight-links .fa,
html.a11y-highlight-links .fas,
html.a11y-highlight-links .far,
html.a11y-highlight-links .fab {
  font-family: "Font Awesome 5 Free", "Font Awesome 5 Brands" !important;
}

/* Ensure dark mode toggle maintains its styling */
#dark-mode-toggle {
  font-family: inherit !important;
}

#dark-mode-toggle i {
  font-family: "Font Awesome 5 Free" !important;
}

/* Stop Animations */
html.a11y-stop-animations *,
html.a11y-stop-animations *:before,
html.a11y-stop-animations *:after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* Navigation Features */

/* Highlight Focus */
html.a11y-highlight-focus *:focus {
  outline: 3px solid var(--al-accent) !important;
  outline-offset: 2px !important;
}

/* Skip Link */
.a11y-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--al-primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  z-index: calc(var(--a11y-z-index) + 2);
}

.a11y-skip-link:focus {
  top: 0;
}

/* Focus Indicators */
html.a11y-focus-indicators *:focus {
  box-shadow: 0 0 0 3px rgba(244, 162, 97, 0.5) !important;
}

/* Simplified Navigation */
html.a11y-simplified-nav nav ul {
  list-style: none !important;
  padding: 0 !important;
}

html.a11y-simplified-nav nav li {
  display: block !important;
  margin: 0.5rem 0 !important;
}

html.a11y-simplified-nav nav a {
  display: block !important;
  padding: 0.5rem 1rem !important;
  background: var(--al-surface-muted) !important;
  text-decoration: none !important;
  border-radius: 0.25rem !important;
}

/* Mobile Responsive - Enhanced for better touch experience */
@media (max-width: 768px) {
  :root {
    --a11y-panel-width: 100%;
    --a11y-panel-max-height: 80vh; /* Reduced from 85vh for better mobile view */
    --a11y-launcher-size: 48px; /* Meets 44x44px touch target requirement */
  }
  
  /* Launcher button - better positioning for thumb reach */
  .a11y-launcher {
    bottom: 20px;
    right: 20px;
    /* Ensure it's easily tappable */
    min-width: 48px;
    min-height: 48px;
  }
  
  /* Main panel - full width with better mobile layout */
  .a11y-panel {
    width: 100%;
    max-width: 100%;
    border-radius: 1.25rem 1.25rem 0 0;
    bottom: 0;
    left: 0;
    right: 0;
    /* Prevent panel from being too tall on mobile */
    max-height: var(--a11y-panel-max-height);
  }
  
  /* Header adjustments for mobile */
  .a11y-panel-header {
    padding: 1rem;
    /* Make header sticky for easier access to close button */
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--al-surface-muted);
  }
  
  /* Panel title - better size for mobile */
  .a11y-panel-title {
    font-size: 1rem;
  }
  
  /* Close button - ensure minimum touch target */
  .a11y-panel-close {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  
  /* Content area - better padding and scrolling */
  .a11y-panel-content {
    padding: 1rem;
    padding-bottom: 2rem; /* Extra bottom padding for easier scrolling */
    /* Ensure smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
    /* Prevent horizontal scroll */
    overflow-x: hidden;
    overflow-y: auto;
  }
  
  /* Section spacing */
  .a11y-section {
    margin-bottom: 1.5rem;
  }
  
  /* Action buttons - stack vertically on very small screens */
  @media (max-width: 380px) {
    .a11y-action-buttons {
      flex-direction: column;
    }
    
    .a11y-action-buttons button {
      width: 100%;
    }
  }
  
  /* Statement and Reset buttons - ensure touch targets */
  .a11y-statement-btn,
  .a11y-reset-btn {
    min-height: 48px;
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
  }
  
  /* Profile cards - single column with better touch targets */
  .a11y-profiles-grid {
    grid-template-columns: 1fr;
    gap: 0.625rem;
  }
  
  .a11y-profile-card {
    min-height: 60px;
    padding: 1rem;
    /* Better touch feedback */
    -webkit-tap-highlight-color: rgba(244, 162, 97, 0.2);
  }
  
  .a11y-profile-icon {
    font-size: 1.75rem;
  }
  
  .a11y-profile-name {
    font-size: 0.9rem;
  }
  
  .a11y-profile-desc {
    font-size: 0.75rem;
    line-height: 1.3;
  }
  
  /* Controls - better spacing and touch targets */
  .a11y-controls {
    gap: 1rem;
  }
  
  .a11y-control label {
    font-size: 0.95rem;
    padding: 0.25rem 0;
    /* Increase tap area */
    margin: -0.25rem 0;
  }
  
  /* Toggle switches - ensure minimum touch target */
  .a11y-control input[type="checkbox"] {
    min-width: 48px;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
  }
  
  .a11y-control input[type="checkbox"]:before {
    width: 20px;
    height: 20px;
  }
  
  .a11y-control input[type="checkbox"]:checked:before {
    left: 25px;
  }
  
  /* Sliders - better for touch interaction */
  .a11y-slider-control label {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
  }
  
  .a11y-slider-wrapper {
    gap: 0.75rem;
  }
  
  .a11y-slider-wrapper input[type="range"] {
    height: 8px; /* Slightly thicker for easier touch */
    /* Increase touch target area */
    padding: 10px 0;
    margin: -10px 0;
  }
  
  .a11y-slider-wrapper input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
    /* Easier to grab on touch */
    -webkit-tap-highlight-color: transparent;
  }
  
  .a11y-slider-wrapper input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }
  
  .a11y-slider-value {
    font-size: 0.9rem;
    min-width: 50px;
  }
  
  /* Button groups - better touch spacing */
  .a11y-button-group {
    gap: 0.375rem;
    padding: 0.375rem;
  }
  
  .a11y-align-btn {
    min-height: 44px;
    padding: 0.625rem;
    font-size: 0.9rem;
  }
  
  /* Modal adjustments for mobile */
  .a11y-modal {
    padding: 0.5rem;
  }
  
  .a11y-modal-content {
    max-height: 90vh;
    margin: 0.5rem;
    border-radius: 1rem;
  }
  
  .a11y-modal-header {
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--al-surface-muted);
  }
  
  .a11y-modal-header h3 {
    font-size: 0.95rem;
  }
  
  .a11y-modal-close {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  
  .a11y-modal-body {
    padding: 1rem;
    padding-bottom: 2rem;
    /* Smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
  }
  
  .a11y-modal-body p {
    font-size: 0.95rem;
    line-height: 1.7;
  }
}

/* Very small mobile devices (iPhone SE, etc.) */
@media (max-width: 375px) {
  :root {
    --a11y-panel-max-height: 75vh;
  }
  
  .a11y-launcher {
    bottom: 15px;
    right: 15px;
    width: 44px;
    height: 44px;
  }
  
  .a11y-launcher svg {
    width: 24px;
    height: 24px;
  }
  
  .a11y-panel-header {
    padding: 0.875rem;
  }
  
  .a11y-panel-title {
    font-size: 0.95rem;
  }
  
  .a11y-panel-content {
    padding: 0.75rem;
    padding-bottom: 1.5rem;
  }
  
  .a11y-section-title {
    font-size: 0.8rem;
  }
  
  .a11y-control label {
    font-size: 0.9rem;
  }
  
  .a11y-slider-value {
    font-size: 0.85rem;
  }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  :root {
    --a11y-panel-max-height: 90vh;
  }
  
  .a11y-panel {
    max-width: 480px;
    right: 0;
    left: auto;
  }
  
  .a11y-profiles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .a11y-panel-content {
    padding: 0.75rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase all interactive element sizes for touch */
  /* Removed global checkbox/radio sizing - too aggressive */
  /* Only apply to accessibility widget controls */
  .a11y-panel button,
  .a11y-panel a,
  .a11y-panel input[type="checkbox"],
  .a11y-panel input[type="radio"],
  .a11y-panel select,
  .a11y-launcher {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .a11y-launcher:hover {
    transform: none;
    background: var(--al-primary);
  }
  
  .a11y-profile-card:hover {
    background: var(--al-surface);
  }
  
  .a11y-statement-btn:hover,
  .a11y-reset-btn:hover {
    background: white;
  }
  
  /* Add active states for better touch feedback */
  .a11y-launcher:active {
    transform: scale(0.95);
  }
  
  .a11y-profile-card:active {
    background: var(--al-surface-muted);
  }
  
  button:active {
    opacity: 0.8;
  }
}

/* Prevent horizontal scrolling on mobile */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }
  
  .a11y-panel,
  .a11y-panel-content {
    max-width: 100vw;
  }
}

/* Print styles */
@media print {
  .a11y-launcher,
  .a11y-panel {
    display: none !important;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* High contrast media query support */
@media (prefers-contrast: high) {
  .a11y-panel {
    border: 2px solid currentColor;
  }
  
  .a11y-control input[type="checkbox"],
  .a11y-reset-btn,
  .a11y-profile-card {
    border-width: 2px;
  }
}