/**
 * A11yToolkit - Styles
 * Version 1.1.1
 * Zero-dependency, self-contained accessibility panel styles.
 */

/* ============================================
   CSS VARIABLES (prefixed to avoid collisions)
   ============================================ */
:root {
  --a11y-tk-accent: #e8c44a;
  --a11y-tk-bg: rgba(0, 0, 0, 0.82);
  --a11y-tk-text: #ffffff;
  --a11y-tk-radius: 12px;
  --a11y-tk-z: 100000;
  --a11y-tk-btn-size: 36px;
  --a11y-tk-btn-radius: 8px;
}

/* ============================================
   CONTAINER — positions panel + toggle
   ============================================ */
.a11y-tk-container {
  position: fixed;
  z-index: var(--a11y-tk-z);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.a11y-tk-container > * {
  pointer-events: auto;
}

/* --- Bottom positions (horizontal) --- */
.a11y-tk-pos-bottom {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
}

.a11y-tk-pos-bottom-left {
  bottom: 16px;
  left: 16px;
  flex-direction: column;
  align-items: flex-start;
}

.a11y-tk-pos-bottom-right {
  bottom: 16px;
  right: 16px;
  flex-direction: column;
  align-items: flex-end;
}

/* --- Top positions (horizontal) --- */
.a11y-tk-pos-top {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
}

.a11y-tk-pos-top-left {
  top: 16px;
  left: 16px;
  flex-direction: column;
  align-items: flex-start;
}

.a11y-tk-pos-top-right {
  top: 16px;
  right: 16px;
  flex-direction: column;
  align-items: flex-end;
}

/* --- Left positions (vertical) --- */
.a11y-tk-pos-left {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: row;
}

.a11y-tk-pos-left-top {
  left: 16px;
  top: 16px;
  flex-direction: row;
  align-items: flex-start;
}

.a11y-tk-pos-left-bottom {
  left: 16px;
  bottom: 16px;
  flex-direction: row;
  align-items: flex-end;
}

/* --- Right positions (vertical) --- */
.a11y-tk-pos-right {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: row-reverse;
}

.a11y-tk-pos-right-top {
  right: 16px;
  top: 16px;
  flex-direction: row-reverse;
  align-items: flex-start;
}

.a11y-tk-pos-right-bottom {
  right: 16px;
  bottom: 16px;
  flex-direction: row-reverse;
  align-items: flex-end;
}

/* ============================================
   TOGGLE BUTTON
   ============================================ */
.a11y-tk-toggle {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: var(--a11y-tk-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--a11y-tk-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: var(--cursor-yellow);
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  flex-shrink: 0;
  font-family: inherit;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.a11y-tk-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.7);
}

.a11y-tk-toggle:focus-visible {
  outline: 2px solid var(--a11y-tk-accent);
  outline-offset: 2px;
}

.a11y-tk-toggle[aria-expanded="true"] {
  background: var(--a11y-tk-accent);
  color: #000;
  border-color: var(--a11y-tk-accent);
}

/* ============================================
   PANEL
   ============================================ */
.a11y-tk-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-height: 0;
  overflow: hidden;
  padding: 0 12px;
  background: var(--a11y-tk-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: var(--a11y-tk-radius);
  border: 0.5px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.3s ease,
              border-color 0.3s ease,
              background 0.3s ease,
              box-shadow 0.3s ease;
  margin: 0;
}

/* Hidden state — truly invisible when collapsed */
.a11y-tk-panel[aria-hidden="true"] {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Horizontal panel (top/bottom positions) — open state */
.a11y-tk-pos-bottom .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-bottom-left .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-bottom-right .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-top .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-top-left .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-top-right .a11y-tk-panel[aria-hidden="false"] {
  max-height: 130px;
  padding: 14px 12px;
  overflow: visible;
  margin: 8px 0;
}

/* Vertical panel (left/right positions) */
.a11y-tk-pos-left .a11y-tk-panel,
.a11y-tk-pos-left-top .a11y-tk-panel,
.a11y-tk-pos-left-bottom .a11y-tk-panel,
.a11y-tk-pos-right .a11y-tk-panel,
.a11y-tk-pos-right-top .a11y-tk-panel,
.a11y-tk-pos-right-bottom .a11y-tk-panel {
  flex-direction: column;
  max-height: none;
  max-width: 0;
  padding: 12px 0;
}

.a11y-tk-pos-left .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-left-top .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-left-bottom .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-right .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-right-top .a11y-tk-panel[aria-hidden="false"],
.a11y-tk-pos-right-bottom .a11y-tk-panel[aria-hidden="false"] {
  max-width: 400px;
  padding: 12px 14px;
  overflow: visible;
  margin: 0 8px;
}

/* Vertical separators for vertical layouts become horizontal */
.a11y-tk-pos-left .a11y-tk-separator,
.a11y-tk-pos-left-top .a11y-tk-separator,
.a11y-tk-pos-left-bottom .a11y-tk-separator,
.a11y-tk-pos-right .a11y-tk-separator,
.a11y-tk-pos-right-top .a11y-tk-separator,
.a11y-tk-pos-right-bottom .a11y-tk-separator {
  width: 28px;
  height: 1px;
  margin: 4px 0;
}

/* ============================================
   PANEL BUTTONS
   ============================================ */
.a11y-tk-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--a11y-tk-btn-size);
  height: var(--a11y-tk-btn-size);
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--a11y-tk-btn-radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--a11y-tk-text);
  cursor: var(--cursor-yellow);
  flex-shrink: 0;
  font-family: inherit;
  /* Stagger animation: start hidden */
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease,
              background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.a11y-tk-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
}

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

.a11y-tk-btn[aria-pressed="true"],
.a11y-tk-btn.active {
  background: var(--a11y-tk-accent);
  color: #000;
  border-color: var(--a11y-tk-accent);
}

.a11y-tk-btn[aria-pressed="true"]:hover,
.a11y-tk-btn.active:hover {
  background: color-mix(in srgb, var(--a11y-tk-accent) 80%, #000);
}

/* Stagger visible class */
.a11y-tk-btn.a11y-tk-visible,
.a11y-tk-separator.a11y-tk-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   SEPARATOR
   ============================================ */
.a11y-tk-separator {
  display: block;
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.3);
  margin: 0 8px;
  flex-shrink: 0;
  /* Stagger animation */
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* ============================================
   FONT VALUE DISPLAY
   ============================================ */
.a11y-tk-font-value {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* ============================================
   TOOLTIPS
   ============================================ */
.a11y-tk-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.a11y-tk-btn[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.92);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.a11y-tk-btn[data-tooltip]:hover::after,
.a11y-tk-btn[data-tooltip]:hover::before {
  opacity: 1;
}

/* Vertical positions: tooltips go to the side instead of above */
.a11y-tk-pos-left .a11y-tk-btn[data-tooltip]::after,
.a11y-tk-pos-left-top .a11y-tk-btn[data-tooltip]::after,
.a11y-tk-pos-left-bottom .a11y-tk-btn[data-tooltip]::after {
  bottom: auto;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}

.a11y-tk-pos-left .a11y-tk-btn[data-tooltip]::before,
.a11y-tk-pos-left-top .a11y-tk-btn[data-tooltip]::before,
.a11y-tk-pos-left-bottom .a11y-tk-btn[data-tooltip]::before {
  bottom: auto;
  left: calc(100% + 3px);
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: rgba(0, 0, 0, 0.92);
}

.a11y-tk-pos-right .a11y-tk-btn[data-tooltip]::after,
.a11y-tk-pos-right-top .a11y-tk-btn[data-tooltip]::after,
.a11y-tk-pos-right-bottom .a11y-tk-btn[data-tooltip]::after {
  bottom: auto;
  left: auto;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}

.a11y-tk-pos-right .a11y-tk-btn[data-tooltip]::before,
.a11y-tk-pos-right-top .a11y-tk-btn[data-tooltip]::before,
.a11y-tk-pos-right-bottom .a11y-tk-btn[data-tooltip]::before {
  bottom: auto;
  left: auto;
  right: calc(100% + 3px);
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: rgba(0, 0, 0, 0.92);
}

/* ============================================
   CONTRAST BUTTONS
   ============================================ */
.a11y-tk-contrast-letter {
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}

.a11y-tk-contrast-none {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

.a11y-tk-contrast-bw {
  background: #FFFFFF !important;
  color: #000000 !important;
  border-color: #000000 !important;
}

.a11y-tk-contrast-by {
  background: #0000CC !important;
  color: #FFFF00 !important;
  border-color: #FFFF00 !important;
}

.a11y-tk-contrast-yb {
  background: #FFFF00 !important;
  color: #0000CC !important;
  border-color: #0000CC !important;
}

.a11y-tk-contrast-btn.active {
  outline: 2px solid var(--a11y-tk-accent);
  outline-offset: 2px;
}

/* ============================================
   RESET BUTTON
   ============================================ */
.a11y-tk-reset-btn {
  border-color: rgba(255, 80, 80, 0.4) !important;
  color: #ff8080 !important;
}

.a11y-tk-reset-btn:hover {
  background: rgba(255, 80, 80, 0.2) !important;
  border-color: #ff8080 !important;
}

/* ============================================
   ACCESSIBILITY EFFECTS — scoped to wrapper
   ============================================ */

/* --- Reading ruler --- */
#a11y-ruler {
  display: none;
  position: fixed;
  left: 0;
  width: 100vw;
  height: 40px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 2px solid rgba(0, 0, 0, 0.5);
  border-bottom: 2px solid rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 99999;
  transition: top 0.05s linear;
}

body.a11y-ruler #a11y-ruler {
  display: block;
}

/* --- Cursor highlight --- */
#a11y-cursor-highlight {
  display: none;
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 184, 0, 0.2);
  border: 2px solid rgba(255, 184, 0, 0.5);
  pointer-events: none;
  z-index: 99998;
  transform: translate(-50%, -50%);
  transition: top 0.05s linear, left 0.05s linear;
}

body.a11y-cursorHighlight #a11y-cursor-highlight {
  display: block;
}

/* --- Big cursor --- */
body.a11y-bigcursor,
body.a11y-bigcursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M8 2L40 28 22 31 30 47 24 50 16 34 8 42Z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 8 2, auto !important;
}

/* --- Highlight links --- */
#a11y-zoom-wrapper.a11y-links a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  color: #FFB800 !important;
}

#a11y-zoom-wrapper.a11y-links a:hover {
  color: #e0a200 !important;
}

/* --- Keyboard navigation --- */
body.a11y-keyboard *:focus-visible {
  outline: 3px solid var(--a11y-tk-accent) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 6px rgba(255, 184, 0, 0.3) !important;
}

/* --- Perception filters --- */
#a11y-zoom-wrapper.a11y-highcontrast {
  filter: contrast(1.5) !important;
}

#a11y-zoom-wrapper.a11y-grayscale {
  filter: grayscale(1) !important;
}

/* --- Contrast themes --- */
#a11y-zoom-wrapper.a11y-contrast-bw,
#a11y-zoom-wrapper.a11y-contrast-bw * {
  background-color: #FFFFFF !important;
  color: #000000 !important;
  border-color: #000000 !important;
}

#a11y-zoom-wrapper.a11y-contrast-bw img,
#a11y-zoom-wrapper.a11y-contrast-bw video,
#a11y-zoom-wrapper.a11y-contrast-bw iframe,
#a11y-zoom-wrapper.a11y-contrast-bw svg {
  background-color: transparent !important;
}

#a11y-zoom-wrapper.a11y-contrast-bw a {
  color: #000000 !important;
  text-decoration: underline !important;
}

#a11y-zoom-wrapper.a11y-contrast-by,
#a11y-zoom-wrapper.a11y-contrast-by * {
  background-color: #0000CC !important;
  color: #FFFF00 !important;
  border-color: #FFFF00 !important;
}

#a11y-zoom-wrapper.a11y-contrast-by img,
#a11y-zoom-wrapper.a11y-contrast-by video,
#a11y-zoom-wrapper.a11y-contrast-by iframe,
#a11y-zoom-wrapper.a11y-contrast-by svg {
  background-color: transparent !important;
}

#a11y-zoom-wrapper.a11y-contrast-by a {
  color: #FFFF00 !important;
  text-decoration: underline !important;
}

#a11y-zoom-wrapper.a11y-contrast-yb,
#a11y-zoom-wrapper.a11y-contrast-yb * {
  background-color: #FFFF00 !important;
  color: #0000CC !important;
  border-color: #0000CC !important;
}

#a11y-zoom-wrapper.a11y-contrast-yb img,
#a11y-zoom-wrapper.a11y-contrast-yb video,
#a11y-zoom-wrapper.a11y-contrast-yb iframe,
#a11y-zoom-wrapper.a11y-contrast-yb svg {
  background-color: transparent !important;
}

#a11y-zoom-wrapper.a11y-contrast-yb a {
  color: #0000CC !important;
  text-decoration: underline !important;
}

/* --- Zoom wrapper --- */
#a11y-zoom-wrapper {
  transform-origin: top center;
}

/* ============================================
   EFFETS A11Y SUR ELEMENTS EXCLUS (CTA)
   Permet d'appliquer les effets visuels aux
   éléments exclus du wrapper (ex: barre CTA)
   ============================================ */

/* Grayscale */
body:has(#a11y-zoom-wrapper.a11y-grayscale) #cta {
  filter: grayscale(1);
}

/* High contrast */
body:has(#a11y-zoom-wrapper.a11y-highcontrast) #cta {
  filter: contrast(1.5);
}

/* Contrast themes - Noir sur blanc */
body:has(#a11y-zoom-wrapper.a11y-contrast-bw) #cta {
  background-color: #000 !important;
  border-color: #fff !important;
}
body:has(#a11y-zoom-wrapper.a11y-contrast-bw) #cta * {
  color: #fff !important;
  background-color: transparent !important;
}
body:has(#a11y-zoom-wrapper.a11y-contrast-bw) #cta a,
body:has(#a11y-zoom-wrapper.a11y-contrast-bw) #cta button {
  border-color: #fff !important;
}

/* Contrast themes - Bleu sur jaune */
body:has(#a11y-zoom-wrapper.a11y-contrast-by) #cta {
  background-color: #0000CC !important;
  border-color: #FFFF00 !important;
}
body:has(#a11y-zoom-wrapper.a11y-contrast-by) #cta * {
  color: #FFFF00 !important;
  background-color: transparent !important;
}
body:has(#a11y-zoom-wrapper.a11y-contrast-by) #cta a,
body:has(#a11y-zoom-wrapper.a11y-contrast-by) #cta button {
  border-color: #FFFF00 !important;
}

/* Contrast themes - Jaune sur bleu */
body:has(#a11y-zoom-wrapper.a11y-contrast-yb) #cta {
  background-color: #FFFF00 !important;
  border-color: #0000CC !important;
}
body:has(#a11y-zoom-wrapper.a11y-contrast-yb) #cta * {
  color: #0000CC !important;
  background-color: transparent !important;
}
body:has(#a11y-zoom-wrapper.a11y-contrast-yb) #cta a,
body:has(#a11y-zoom-wrapper.a11y-contrast-yb) #cta button {
  border-color: #0000CC !important;
}

/* Highlight links - appliqué au CTA aussi */
body:has(#a11y-zoom-wrapper.a11y-links) #cta a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  color: #FFB800 !important;
}
body:has(#a11y-zoom-wrapper.a11y-links) #cta a:hover {
  color: #e0a200 !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .a11y-tk-panel {
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    padding: 0 8px;
  }

  .a11y-tk-pos-bottom .a11y-tk-panel[aria-hidden="false"],
  .a11y-tk-pos-bottom-left .a11y-tk-panel[aria-hidden="false"],
  .a11y-tk-pos-bottom-right .a11y-tk-panel[aria-hidden="false"],
  .a11y-tk-pos-top .a11y-tk-panel[aria-hidden="false"],
  .a11y-tk-pos-top-left .a11y-tk-panel[aria-hidden="false"],
  .a11y-tk-pos-top-right .a11y-tk-panel[aria-hidden="false"] {
    max-height: 200px;
    padding: 8px 8px 4px;
  }

  .a11y-tk-btn {
    width: 32px;
    height: 32px;
  }

  .a11y-tk-btn svg {
    width: 18px;
    height: 18px;
  }

  .a11y-tk-separator {
    height: 18px;
  }

  .a11y-tk-toggle {
    width: 40px;
    height: 40px;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .a11y-tk-panel,
  .a11y-tk-btn,
  .a11y-tk-separator,
  .a11y-tk-toggle {
    transition-duration: 0.01ms !important;
  }
}
