/* ==========================================================================
   Accessibility Toolbar — Full AudioEye Replacement
   Self-contained CSS: launcher, toolbar panel, tabs, 13 tool toggles,
   reading guide overlay, window focus overlay, page structure panel,
   report-an-issue form.
   ========================================================================== */

/* --- OpenDyslexic font --- */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('/assets/a11y/OpenDyslexic-Regular.woff2') format('woff');
  font-weight: normal; font-style: normal; font-display: swap;
}

/* ==========================================================================
   LAUNCHER BUTTON
   ========================================================================== */
#ae-launcher-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 2147483640;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: #1275B3; color: #fff; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
  padding: 0;
}
#ae-launcher-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#ae-launcher-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#ae-launcher-btn svg { width: 30px; height: 30px; fill: currentColor; pointer-events: none; }

/* ==========================================================================
   TOOLBAR PANEL
   ========================================================================== */
#ae-toolbar-panel {
  position: fixed; top: 0; right: -420px; z-index: 2147483641;
  width: 400px; max-width: 92vw; height: 100vh;
  background: #fff; color: #333;
  display: flex; flex-direction: column;
  box-shadow: -6px 0 30px rgba(0,0,0,.25);
  transition: right .35s cubic-bezier(.22,.61,.36,1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
}
#ae-toolbar-panel.ae-open { right: 0; }

/* backdrop */
#ae-toolbar-backdrop {
  position: fixed; inset: 0; z-index: 2147483639;
  background: rgba(0,0,0,.3);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
#ae-toolbar-backdrop.ae-open { opacity: 1; pointer-events: all; }

/* --- Header --- */
.ae-tb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: #f5f5f5; border-bottom: 1px solid #ddd;
  flex-shrink: 0;
}
.ae-tb-header h2 { margin: 0; font-size: 16px; font-weight: 600; color: #222; }
.ae-tb-close {
  appearance: none; border: none; background: transparent; cursor: pointer;
  color: #666; padding: 4px; line-height: 0;
}
.ae-tb-close:hover { color: #000; }
.ae-tb-close svg { width: 20px; height: 20px; }

/* --- Tabs --- */
.ae-tb-tabs {
  display: flex; border-bottom: 1px solid #ddd; flex-shrink: 0;
}
.ae-tb-tab {
  flex: 1; padding: 12px 8px; text-align: center; cursor: pointer;
  font-size: 13px; font-weight: 600; color: #666; border: none; background: transparent;
  border-bottom: 2px solid transparent; transition: color .2s, border-color .2s;
}
.ae-tb-tab:hover { color: #333; }
.ae-tb-tab.ae-active { color: #1275B3; border-bottom-color: #1275B3; }

/* --- Tab content --- */
.ae-tb-content { flex: 1; overflow-y: auto; }
.ae-tb-pane { display: none; padding: 16px 20px; }
.ae-tb-pane.ae-active { display: block; }

/* --- Tool grid --- */
.ae-tools-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.ae-tool-btn {
  appearance: none; border: 1px solid #ddd; border-radius: 8px;
  background: #fafafa; color: #444; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px; font-size: 12px; font-weight: 500;
  transition: background .2s, border-color .2s, color .2s;
  text-align: center; line-height: 1.3;
}
.ae-tool-btn:hover { background: #eef6fb; border-color: #aaa; color: #222; }
.ae-tool-btn.ae-on { background: #1275B3; border-color: #1275B3; color: #fff; }
.ae-tool-btn svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.ae-tool-btn .ae-tool-state {
  font-size: 10px; opacity: .7; margin-top: 2px;
}

/* --- Reset button --- */
.ae-reset-btn {
  display: block; width: 100%; margin-top: 16px; padding: 10px;
  border: 1px solid #ccc; border-radius: 6px; background: transparent;
  color: #555; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .2s, color .2s;
}
.ae-reset-btn:hover { background: #b00020; border-color: #b00020; color: #fff; }

/* ==========================================================================
   REPORT AN ISSUE FORM
   ========================================================================== */
.ae-report-form { display: flex; flex-direction: column; gap: 14px; }
.ae-rf-field { display: flex; flex-direction: column; gap: 4px; }
.ae-rf-field label { font-size: 12px; font-weight: 600; color: #555; }
.ae-rf-field input, .ae-rf-field textarea, .ae-rf-field select {
  background: #fff; border: 1px solid #ccc; border-radius: 4px;
  color: #333; padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.ae-rf-field input:focus, .ae-rf-field textarea:focus, .ae-rf-field select:focus {
  outline: none; border-color: #1275B3;
}
.ae-rf-field textarea { min-height: 100px; resize: vertical; }
.ae-rf-submit {
  padding: 12px; border: none; border-radius: 6px; background: #1275B3; color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s;
}
.ae-rf-submit:hover { background: #0d5f94; }
.ae-rf-submit:disabled { opacity: .5; cursor: wait; }
.ae-rf-success { text-align: center; padding: 24px 8px; color: #1275B3; font-size: 15px; line-height: 1.5; }
.ae-rf-success strong { display: block; font-size: 18px; margin-bottom: 6px; color: #222; }

/* ==========================================================================
   PAGE STRUCTURE PANEL (inside tools pane)
   ========================================================================== */
.ae-structure-list { max-height: 260px; overflow-y: auto; margin-top: 10px; }
.ae-structure-list a {
  display: block; padding: 8px 12px; color: #444; text-decoration: none;
  border-radius: 4px; font-size: 13px; transition: background .15s;
}
.ae-structure-list a:hover { background: #eef6fb; color: #1275B3; }
.ae-structure-list a[data-level="2"] { padding-left: 24px; }
.ae-structure-list a[data-level="3"] { padding-left: 36px; }
.ae-structure-list a[data-level="4"] { padding-left: 48px; }

/* ==========================================================================
   TOOL EFFECTS — applied as classes on <html>
   ========================================================================== */

/* Focus Indicator */
html.ae-focus *:focus { outline: 3px solid #4fc3f7 !important; outline-offset: 2px !important; }

/* Cursor */
html.ae-cursor-lg, html.ae-cursor-lg * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Cpath d='M5 2l18 14H13l6 12-4 2-6-12-4 8z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 5 2, auto !important;
}
html.ae-cursor-xl, html.ae-cursor-xl * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M7 3l27 21H19l9 18-6 3-9-18-6 12z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 7 3, auto !important;
}

/* Highlight Links */
html.ae-highlight-links a {
  text-decoration: underline !important;
  outline: 2px solid #ff0 !important; outline-offset: 2px !important;
  background: rgba(255,255,0,.15) !important;
}

/* Contrast */
html.ae-sharpen { filter: contrast(1.4) !important; }
html.ae-desaturate { filter: grayscale(1) !important; }
html.ae-invert { filter: invert(1) hue-rotate(180deg) !important; }
html.ae-invert img, html.ae-invert video, html.ae-invert iframe {
  filter: invert(1) hue-rotate(180deg) !important;
}

/* Color Shift */
html.ae-hue-1 { filter: hue-rotate(60deg) !important; }
html.ae-hue-2 { filter: hue-rotate(120deg) !important; }
html.ae-hue-3 { filter: hue-rotate(180deg) !important; }
html.ae-hue-4 { filter: hue-rotate(240deg) !important; }
html.ae-hue-5 { filter: hue-rotate(300deg) !important; }

/* Animation */
html.ae-pause-anim *, html.ae-pause-anim *::before, html.ae-pause-anim *::after {
  animation-duration: 0s !important; animation-delay: 0s !important;
  transition-duration: 0s !important; transition-delay: 0s !important;
}
html.ae-pause-anim *[style*="animation"], html.ae-pause-anim video, html.ae-pause-anim marquee {
  animation-play-state: paused !important;
}

/* Text Size */
html.ae-text-1 { font-size: 115% !important; }
html.ae-text-2 { font-size: 130% !important; }
html.ae-text-3 { font-size: 150% !important; }

/* Spacing */
html.ae-space-1 { word-spacing: 0.12em !important; letter-spacing: 0.03em !important; line-height: 1.8 !important; }
html.ae-space-2 { word-spacing: 0.24em !important; letter-spacing: 0.06em !important; line-height: 2.2 !important; }

/* Font (Dyslexia) */
html.ae-dyslexia-font, html.ae-dyslexia-font * {
  font-family: 'OpenDyslexic', sans-serif !important;
}

/* Reading Guide — horizontal bar following mouse */
#ae-reading-guide {
  display: none; position: fixed; left: 0; right: 0; height: 12px; z-index: 2147483630;
  background: rgba(255,255,0,.35); border-top: 2px solid rgba(255,200,0,.7);
  border-bottom: 2px solid rgba(255,200,0,.7); pointer-events: none;
  transition: top .08s linear;
}
html.ae-reading-guide #ae-reading-guide { display: block; }

/* Window Focus — dims outside a band */
#ae-window-focus-top, #ae-window-focus-bottom {
  display: none; position: fixed; left: 0; right: 0; z-index: 2147483629;
  background: rgba(0,0,0,.65); pointer-events: none;
  transition: height .08s linear, top .08s linear;
}
#ae-window-focus-top { top: 0; }
#ae-window-focus-bottom { bottom: 0; }
html.ae-window-focus #ae-window-focus-top,
html.ae-window-focus #ae-window-focus-bottom { display: block; }

/* Show Image Alt Text */
html.ae-show-alt img[alt]::after {
  content: attr(alt);
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.85); color: #ff0; font-size: 12px;
  padding: 4px 6px; z-index: 10;
}
html.ae-show-alt img[alt] { position: relative !important; }
.ae-alt-overlay {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
  background: rgba(0,0,0,.85); color: #ff0; font-size: 12px; padding: 4px 6px;
  pointer-events: none; word-break: break-word;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 480px) {
  #ae-toolbar-panel { width: 100vw; right: -100vw; }
  #ae-launcher-btn { width: 48px; height: 48px; bottom: 16px; right: 16px; }
  #ae-launcher-btn svg { width: 26px; height: 26px; }
  .ae-tools-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}
