/* ==========================================================================
   Accessibility Widget - Self-contained styles
   Used by both Next.js (instacured.com) and Hugo blog (/health)
   Keep in sync with hugo/static/css/accessibility-widget.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Widget UI Styles (prefixed with .a11y-widget)
   -------------------------------------------------------------------------- */

.a11y-widget-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 61px;
  height: 61px;
  border-radius: 50%;
  background: #0071e3;
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 113, 227, 0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-widget-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(0, 113, 227, 0.5);
}

.a11y-widget-btn:focus-visible {
  outline: 3px solid #0071e3;
  outline-offset: 2px;
}

.a11y-widget-btn svg {
  width: 33px;
  height: 33px;
}

.a11y-widget-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 320px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px !important;
  line-height: 1.5;
  color: #1d1d1f;
}

.a11y-widget-panel--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.a11y-widget-panel-header {
  padding: 20px;
  border-bottom: 1px solid #f5f5f7;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.a11y-widget-panel-header h3 {
  font-size: 18px !important;
  font-weight: 600;
  margin: 0;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-widget-panel-close {
  background: #f5f5f7;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #515154;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
}

.a11y-widget-panel-close:hover {
  color: #1d1d1f;
}

.a11y-widget-panel-close:focus-visible {
  outline: 3px solid #0071e3;
  outline-offset: 2px;
}

.a11y-widget-panel-content {
  padding: 20px;
}

.a11y-widget-option {
  margin-bottom: 20px;
}

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

.a11y-widget-option label {
  display: block;
  font-size: 14px !important;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-widget-font-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.a11y-widget-font-controls button {
  width: 40px;
  height: 40px;
  border: 2px solid #d2d2d7;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px !important;
  font-weight: 600;
  transition: border-color 0.2s ease, color 0.2s ease;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-widget-font-controls button:hover {
  border-color: #0071e3;
  color: #0071e3;
}

.a11y-widget-font-controls button:focus-visible {
  outline: 3px solid #0071e3;
  outline-offset: 2px;
}

.a11y-widget-font-controls span {
  flex: 1;
  text-align: center;
  font-size: 14px !important;
  color: #515154;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-widget-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.a11y-widget-toggle span {
  font-size: 14px !important;
  color: #515154;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-widget-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.a11y-widget-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.a11y-widget-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d2d2d7;
  transition: background-color 0.3s;
  border-radius: 28px;
}

.a11y-widget-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: transform 0.3s;
  border-radius: 50%;
}

.a11y-widget-switch input:checked + .a11y-widget-slider {
  background-color: #0071e3;
}

.a11y-widget-switch input:checked + .a11y-widget-slider:before {
  transform: translateX(22px);
}

.a11y-widget-switch input:focus-visible + .a11y-widget-slider {
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.3);
}

.a11y-widget-reset {
  width: 100%;
  padding: 12px;
  background: #f5f5f7;
  border: none;
  border-radius: 8px;
  font-size: 14px !important;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-top: 16px;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-widget-reset:hover {
  background: #d2d2d7;
}

.a11y-widget-reset:focus-visible {
  outline: 3px solid #0071e3;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   2. Body Effect Classes (generic, work with any markup)
   -------------------------------------------------------------------------- */

/* High Contrast */
body.a11y-high-contrast {
  background: #ffffff !important;
}

body.a11y-high-contrast,
body.a11y-high-contrast p,
body.a11y-high-contrast li,
body.a11y-high-contrast span,
body.a11y-high-contrast h1,
body.a11y-high-contrast h2,
body.a11y-high-contrast h3,
body.a11y-high-contrast h4,
body.a11y-high-contrast h5,
body.a11y-high-contrast h6,
body.a11y-high-contrast label,
body.a11y-high-contrast td,
body.a11y-high-contrast th,
body.a11y-high-contrast div,
body.a11y-high-contrast blockquote {
  color: #000000 !important;
}

body.a11y-high-contrast a {
  color: #0000ff !important;
}

body.a11y-high-contrast button,
body.a11y-high-contrast .btn,
body.a11y-high-contrast [class*="btn"] {
  border: 2px solid #000000 !important;
}

body.a11y-high-contrast img {
  filter: contrast(1.2);
}

/* Highlight Links */
body.a11y-highlight-links a:not(.a11y-widget-btn):not(.a11y-widget-panel-close):not(.a11y-widget-reset) {
  background-color: #ffff00 !important;
  color: #000000 !important;
  text-decoration: underline !important;
  outline: 2px solid #000000;
  outline-offset: 1px;
}

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

/* Large Cursor */
body.a11y-large-cursor,
body.a11y-large-cursor * {
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="black"><path d="M4 4l16 8-8 2-2 8z"/></svg>') 0 0, auto !important;
}

/* --------------------------------------------------------------------------
   3. Font Size Scaling
   Applied to <html> so all rem-based sizes (Tailwind, etc.) scale automatically
   -------------------------------------------------------------------------- */

html.a11y-font-size-80 { font-size: 80% !important; }
html.a11y-font-size-90 { font-size: 90% !important; }
html.a11y-font-size-110 { font-size: 110% !important; }
html.a11y-font-size-120 { font-size: 120% !important; }
html.a11y-font-size-130 { font-size: 130% !important; }
html.a11y-font-size-140 { font-size: 140% !important; }
html.a11y-font-size-150 { font-size: 150% !important; }

/* Ensure widget panel text is never affected by font scaling */
.a11y-widget-panel { font-size: 14px !important; }
.a11y-widget-panel h3 { font-size: 18px !important; }
.a11y-widget-panel label { font-size: 14px !important; }
.a11y-widget-panel span { font-size: 14px !important; }
.a11y-widget-panel button { font-size: 14px !important; }
.a11y-widget-font-controls button { font-size: 18px !important; }

/* Mobile responsive */
@media (max-width: 400px) {
  .a11y-widget-panel {
    right: 12px;
    left: 12px;
    width: auto;
  }
  .a11y-widget-btn {
    right: 12px;
    bottom: 24px;
  }
}
