/* Updated CSS - Applies global font size to site, fixes popup size */

:root {
  --bg-color: #ffffff;
  --text-color: #333333;
  --popup-bg: #ffffff;
  --popup-text: #333333;
  --button-bg: #f5f5f5;
  --button-hover: #e8e8e8;
  --option-header-bg: #f5f5f5;
  --option-header-hover: #e8e8e8;
  --border-color: #e0e0e0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --primary-color: #4285f4;
  --primary-hover: #3367d6;
  --secondary-color: #34a853;
  --secondary-hover: #2e7d32;
  --tertiary-color: #ea4335;
  --tertiary-hover: #c62828;
  --disabled-color: #9e9e9e;
  --disabled-bg: #f5f5f5;
  --slider-track: #e0e0e0;
  --slider-thumb: #4285f4;
  --transition-speed: 0.2s;
}

.dark-theme,
[data-theme="dark"] {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --popup-bg: #1e1e1e;
  --popup-text: #ffffff;
  --button-bg: #2a2a2a;
  --button-hover: #3a3a3a;
  --option-header-bg: #2a2a2a;
  --option-header-hover: #3a3a3a;
  --border-color: #3a3a3a;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --primary-color: #4285f4;
  --primary-hover: #5c9eff;
  --secondary-color: #34a853;
  --secondary-hover: #46c76c;
  --tertiary-color: #ea4335;
  --tertiary-hover: #ff6659;
  --disabled-color: #757575;
  --disabled-bg: #2a2a2a;
  --slider-track: #3a3a3a;
  --slider-thumb: #4285f4;
}

/* Apply global font size variable to the root element (affects main page content) */
html {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* THIS LINE CONTROLS THE MAIN SITE FONT SIZE via the JS */
  font-size: var(--global-font-size, 16px);
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: filter 0.3s ease;
  transition: background-color var(--transition-speed),
    color var(--transition-speed);
}

/* Styles for elements OUTSIDE the popup will use the html font-size */
body {
  /* Example: Ensure body text scales with html */
  font-size: 1rem; /* 1rem = current value of --global-font-size */
  /* line-height: 1.6; */
}

/* Other elements on the main page (headings, paragraphs, lists, etc.) */
/* will inherit from body/html or should use 'rem' units if you want them */
/* to scale with the global font size setting. */
h1, h2, h3, p, li, a, /* etc. */ {
    /* Example: Let them inherit, or use rem units like: */
    /* font-size: 1.5rem; */
}


/* --- Accessibility Popup Specific Styles --- */

#toggle-popup {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--primary-color);
  border: none;
  cursor: pointer;
  padding: 10px !important;
  border-radius: 50%;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: transform var(--transition-speed),
    background-color var(--transition-speed);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px; /* Fixed size for the toggle button */
}

#toggle-popup:hover {
  transform: scale(1.1);
  background: var(--primary-hover);
}

#toggle-popup:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

#toggle-popup svg {
  width: 30px !important;
  height: 30px !important;
}

/* --- KEY FIX: Set a fixed base font size for the popup --- */
#accessibility-popup {
  position: fixed;
  /* Using rem for position means the popup *might* shift slightly */
  /* when global font size changes. Use px if that's an issue. */
  /* bottom: 6rem; */
  bottom: 96px; /* Alternative fixed position */
  right: 20px;
  background: var(--popup-bg);
  color: var(--popup-text);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow-color);
  width: 320px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 10000;
  transition: opacity 0.3s, transform 0.3s;
  border: 1px solid var(--border-color);
  filter: none !important;

  /* --- THIS IS THE FIX --- */
  /* Set a fixed font size. This overrides the font-size inherited from <html> */
  /* and prevents the popup UI from scaling with the main page content. */
  /* Use 16px, or 1rem (which equals the *initial* html size), or your preferred base size. */
  font-size: 16px;
}

#accessibility-popup.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}


.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

#popup-title {
  /* Use 'em' relative to #accessibility-popup's fixed size */
  font-size: 1.2em; /* 1.2 * 16px = 19.2px */
  font-weight: 600;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#reset-all-settings,
#collapse-popup {
  background: transparent;
  border: none;
  color: var(--popup-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 4px;
  transition: background-color var(--transition-speed);
  /* Ensure these inherit the popup's base font size (1em = 16px) */
  font-size: 1em;
}

#reset-all-settings:hover,
#collapse-popup:hover {
  background-color: var(--button-hover);
}

#reset-all-settings svg {
  width: 20px;
  height: 20px;
}

#collapse-popup {
  /* Use 'em' relative to popup's fixed size */
  font-size: 1.5em; /* 1.5 * 16px = 24px */
}

.option-section {
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: var(--popup-bg);
  color: var(--popup-text);
}

.option-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--option-header-bg);
  border: none;
  color: var(--popup-text);
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-speed);
  text-align: left;
  /* Use popup's base font size */
  font-size: 1em;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-content span {
    /* Use popup's base font size */
    font-size: 1em;
}


.option-header:hover {
  background: var(--option-header-hover);
}

.option-header svg {
  transition: transform var(--transition-speed);
}

.option-header[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

.option-content {
  padding: 16px;
  background-color: var(--popup-bg);
  border-top: 1px solid var(--border-color);
  /* Use popup's base font size */
  font-size: 1em;
}

.option-content.hidden {
  display: none;
}

/* Ensure common elements inside popup use the popup's base font size */
#accessibility-popup button,
#accessibility-popup span,
#accessibility-popup label,
#accessibility-popup select,
#accessibility-popup p,
#accessibility-popup div:not(#accessibility-popup):not(.option-section):not(.option-content)
 {
    /* Inherit from #accessibility-popup's 16px */
    font-size: 1em;
}

.font-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-button {
  background: var(--button-bg);
  border: none;
  color: var(--popup-text);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-speed);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Use popup's base font size */
  font-size: 1em;
}

.control-button:hover {
  background: var(--button-hover);
}

.font-size-display {
  display: flex;
  align-items: baseline;
  font-weight: 500;
  /* Use popup's base font size */
  font-size: 1em;
}
/* Ensure the number itself uses the base size */
#font-size-display {
    font-size: 1em !important; /* Use !important if needed to override other rules */
}

.unit {
  /* Use 'em' relative to parent (.font-size-display) */
  font-size: 0.8em; /* 0.8 * 16px = 12.8px */
  margin-left: 2px;
  opacity: 0.7;
}

/* ... (rest of your CSS for contrast, display mode, etc.) ... */
/* Make sure any font-size declarations within these sections */
/* also use 'px' or 'em', NOT 'rem' */

.contrast-info {
  margin: 15px 0;
  font-weight: 500;
  font-size: 1em; /* Use popup base size */
}

.action-button {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: background-color var(--transition-speed);
  font-size: 1em; /* Use popup base size */
}

.display-option {
  /* ... other styles ... */
  font-size: 1em; /* Use popup base size */
}

/* Tooltip styles */
.accessibility-tooltip {
  position: fixed;
  background-color: var(--option-header-hover);
  color: var(--popup-text);
  padding: 8px 12px;
  border-radius: 6px;
  /* Use 'em' relative to popup's fixed size */
  font-size: 0.85em; /* 0.85 * 16px = 13.6px */
  line-height: 1.4;
  max-width: 220px;
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  white-space: normal;
}

.accessibility-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.accessibility-tooltip::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent var(--option-header-hover) transparent transparent;
}

.tooltip-title {
  font-size: 13px; /* Fixed px size is fine */
  font-weight: 600;
  display: block;
  margin-bottom: 3px;
}

.tooltip-desc {
  font-size: 10px; /* Fixed px size is fine */
  display: block;
  color: var(--popup-text);
}


/* --- Media Queries --- */
/* These are generally fine, as they adjust layout, not base font size */
@media (max-width: 768px) {
  #accessibility-popup {
    /* width: calc(100% - 40px); */
    max-height: 70vh;
    /* Consider using px for bottom if rem causes unwanted shifting */
    /* bottom: 70px; */
  }
  /* ... other media query styles ... */
}

@media (max-width: 480px) {
    /* ... other media query styles ... */
}




.color-option {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  margin: 3px;
  cursor: pointer;
  display: inline-block;
  border-radius: 4px;
}

.color-option.selected {
  scale: 1.5;
  border-color: #333
}