/* Accessibility Stylesheet */

/* Themes */
body.theme-black-on-white {
  --bg-color: #ffffff;
  --text-color: #333333;
  --accent-color: #4a6fa5;
  --secondary-bg: #ffffff;
  --border-color: #dddddd;
  --input-bg: #ffffff;
  --success-color: #28a745;
  --error-color: #dc3545;
}

body.theme-black-on-cream {
  --bg-color: #FFFACD;
  --text-color: #000000;
  --accent-color: #4a6fa5;
  --secondary-bg: #FFFACD;
  --border-color: #444444;
  --input-bg: #FFFACD;
  --success-color: #28a745;
  --error-color: #dc3545;
}

body.theme-black-on-light-blue {
  --bg-color: #ADD8E6;
  --text-color: #000000;
  --accent-color: #4a6fa5;
  --secondary-bg: #ADD8E6;
  --border-color: #000000;
  --input-bg: #ADD8E6;
  --success-color: #28a745;
  --error-color: #dc3545;
}

body.theme-black-on-light-magenta {
  --bg-color: #EE82EF;
  --text-color: #000000;
  --accent-color: #4a6fa5;
  --secondary-bg: #EE82EF;
  --border-color: #000000;
  --input-bg: #EE82EF;
  --success-color: #28a745;
  --error-color: #dc3545;
}

body.theme-white-on-black {
  --bg-color: #000000;
  --text-color: #ffffff;
  --accent-color: #4a6fa5;
  --secondary-bg: #000000;
  --border-color: #ffffff;
  --input-bg: #000000;
  --success-color: #28a745;
  --error-color: #dc3545;
}

body.theme-yellow-on-blue {
  --bg-color: #1800CC;
  --text-color: #F5E728;
  --accent-color: #4a6fa5;
  --secondary-bg: #1800CC;
  --border-color: #F5E728;
  --input-bg: #1800CC;
  --success-color: #28a745;
  --error-color: #dc3545;
}

body.theme-gray-on-green {
  --bg-color: #A3AE9E;
  --text-color: #6E6E6E;
  --accent-color: #4a6fa5;
  --secondary-bg: #A3AE9E;
  --border-color: #6E6E6E;
  --input-bg: #A3AE9E;
  --success-color: #28a745;
  --error-color: #dc3545;
}

/* Apply theme variables to body */
body {
  background-color: var(--bg-color) !important;
  color: var(--text-color) !important;
  transition: background-color 0.3s, color 0.3s;
}

/* Apply to major components */
header, footer {
  background-color: var(--accent-color) !important;
}

.primary-btn {
  background-color: var(--accent-color) !important;
}

#test-container, 
#feedback-container, 
#results-summary, 
#results-details, 
.settings-group {
  background-color: var(--secondary-bg) !important;
  border-color: var(--border-color) !important;
}

.option, .response-input {
  background-color: var(--input-bg) !important;
  border-color: var(--border-color) !important;
  color: var(--text-color) !important;
}

.option.correct, .result-status.correct {
  color: var(--success-color) !important;
}

.option.incorrect, .result-status.incorrect {
  color: var(--error-color) !important;
}

/* Font sizes */
html {
  font-size: 16px; /* Base font size */
}

body.font-size-small {
  font-size: 0.875rem; /* 14px */
}

body.font-size-medium {
  font-size: 1rem; /* 16px */
}

body.font-size-large {
  font-size: 1.125rem; /* 18px */
}

body.font-size-xlarge {
  font-size: 1.25rem; /* 20px */
}

/* Reduced motion */
body.reduce-motion * {
  transition: none !important;
  animation: none !important;
}

/* Screen reader optimizations */
body.screen-reader-optimized .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

body.screen-reader-optimized a:focus,
body.screen-reader-optimized button:focus,
body.screen-reader-optimized input:focus,
body.screen-reader-optimized textarea:focus,
body.screen-reader-optimized select:focus {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* Focus states for all interactive elements */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 1px;
}

/* Improves text readability */
body.screen-reader-optimized {
  line-height: 1.8;
  letter-spacing: 0.5px;
}

/* Focus indicator for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* Additional theme-specific overrides for better contrast */
body.theme-white-on-black .question-text,
body.theme-white-on-black h1,
body.theme-white-on-black h2,
body.theme-white-on-black h3,
body.theme-white-on-black h4,
body.theme-white-on-black p {
  color: var(--text-color) !important;
}

body.theme-yellow-on-blue .question-text,
body.theme-yellow-on-blue h1,
body.theme-yellow-on-blue h2,
body.theme-yellow-on-blue h3,
body.theme-yellow-on-blue h4,
body.theme-yellow-on-blue p {
  color: var(--text-color) !important;
}

/* Make sure proper contrast for all themes */
body[class*="theme-"] .result-summary-text p,
body[class*="theme-"] .result-question,
body[class*="theme-"] .result-answer,
body[class*="theme-"] .result-explanation {
  color: var(--text-color) !important;
}

/* Score circle theming */
body[class*="theme-"] .score-circle {
  background-color: var(--accent-color) !important;
  color: white !important;
}

body[class*="theme-"] .score-circle-small {
  background-color: var(--accent-color) !important;
  color: white !important;
}

/* Magnifier Styles */
.magnifier-container {
  position: fixed;
  width: 200px;
  height: 200px;
  border: 3px solid var(--accent-color, #4a6fa5);
  background: white;
  cursor: move;
  z-index: 2000;
  display: none; /* Hidden by default */
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  user-select: none;
  top: 100px;
  left: 100px;
}

.magnifier-container.active {
  display: block !important;
}

.magnifier-content {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.magnifier-content > * {
  pointer-events: none !important;
  user-select: none !important;
}

/* Line Reader Mask Styles */
.line-reader-container {
  position: fixed;
  width: 400px;
  height: 200px;
  border: 2px solid var(--accent-color, #4a6fa5);
  border-radius: 4px;
  cursor: move;
  z-index: 1500;
  display: none; /* Hidden by default */
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  top: 200px;
  left: 100px;
  background: transparent;
}

.line-reader-container.active {
  display: block !important;
}

/* Create mask segments that surround the transparent window */
.line-reader-mask-top,
.line-reader-mask-bottom,
.line-reader-mask-left,
.line-reader-mask-right {
  position: absolute;
  background: #333333;
  pointer-events: none;
}

.line-reader-mask-top {
  top: 0;
  left: 0;
  right: 0;
  height: 50px; /* Above the window */
}

.line-reader-mask-bottom {
  bottom: 0;
  left: 0;
  right: 0;
  height: 90px; /* Below the window (200 - 50 - 60 = 90) */
}

.line-reader-mask-left {
  top: 50px; /* Start at window top */
  left: 0;
  width: 50px; /* Left of window */
  height: 60px; /* Window height */
}

.line-reader-mask-right {
  top: 50px; /* Start at window top */
  right: 0;
  width: 50px; /* Right of window (400 - 50 - 300 = 50) */
  height: 60px; /* Window height */
}

.line-reader-handle {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--accent-color, #4a6fa5);
  border-radius: 3px;
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: bold;
  z-index: 10;
  pointer-events: auto;
}

.line-reader-handle::before {
  content: '⋮⋮';
  letter-spacing: -2px;
}

.line-reader-window {
  position: absolute;
  width: 300px;
  height: 60px;
  top: 50px;
  left: 50px;
  background: transparent !important;
  border: 2px dashed var(--accent-color, #4a6fa5);
  border-radius: 2px;
  cursor: ns-resize; /* Vertical resize cursor */
  z-index: 1501;
  pointer-events: auto;
}

.line-reader-window-handle {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: var(--accent-color, #4a6fa5);
  border-radius: 2px;
  cursor: ns-resize; /* Vertical resize cursor */
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 8px;
  z-index: 10;
  pointer-events: auto;
}

.line-reader-window-handle::before {
  content: '⋮';
}

.line-reader-resize {
  position: absolute;
  background: var(--accent-color, #4a6fa5);
  opacity: 0.8;
  z-index: 10;
}

.line-reader-resize:hover {
  opacity: 1;
}

/* Only corner resize handles for mask */
.line-reader-resize-ne {
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  cursor: ne-resize;
}

.line-reader-resize-nw {
  top: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  cursor: nw-resize;
}

.line-reader-resize-se {
  bottom: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  cursor: se-resize;
}

.line-reader-resize-sw {
  bottom: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  cursor: sw-resize;
}

.line-reader-window-resize {
  position: absolute;
  background: var(--accent-color, #4a6fa5);
  opacity: 0.6;
  z-index: 10;
}

.line-reader-window-resize:hover {
  opacity: 0.9;
}

/* Only vertical resize handles for window */
.line-reader-window-resize-n {
  top: -3px;
  left: 8px;
  right: 8px;
  height: 6px;
  cursor: n-resize;
}

.line-reader-window-resize-s {
  bottom: -3px;
  left: 8px;
  right: 8px;
  height: 6px;
  cursor: s-resize;
}

/* Settings additions */
.accessibility-tool-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
  padding: 0.75rem;
  background-color: var(--input-bg, white);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
}

.accessibility-tool-option label {
  flex: 1;
  margin: 0;
  cursor: pointer;
}

.accessibility-tool-option input[type="checkbox"] {
  margin-left: 1rem;
  transform: scale(1.2);
}

.tool-description {
  font-size: 0.85rem;
  color: var(--text-color, #666);
  margin-top: 0.25rem;
}