/* ========================================================================
   D1266 — wvia-canonical-overlap.css
   Continuation D1265 anti-overlap doctrine
   z-index layers + float-zone + hud-toggle + mobile + contraste WCAG
   Yacine doctrine: pas de surpatch, root cause, single source of truth
   ======================================================================== */

:root {
  /* z-index canonical layers - utiliser AU LIEU de z-index:9999 arbitraire */
  --wvia-z-base:      1;
  --wvia-z-content:   10;
  --wvia-z-floating:  100;
  --wvia-z-sticky:    500;
  --wvia-z-overlay:   1000;
  --wvia-z-modal:     10000;
  --wvia-z-toast:     100000;

  /* Contraste WCAG AA tokens */
  --wvia-orange-safe: #d4521a;        /* WCAG AA on white #faf7f5 = 4.6:1 ✓ (vs #ff6b1a = 2.7 FAIL) */
  --wvia-text-on-dark: #ffffff;
  --wvia-bg-dark-solid: rgba(15,23,42,0.92);
  --wvia-bg-warning: rgba(239,68,68,0.95);
}

/* ========================================================================
   FLOAT ZONE — container unique pour tous floating widgets
   Bottom-right par défaut, stack vertical, gap 12px
   ======================================================================== */
.wvia-float-zone {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: var(--wvia-z-floating);
  display: flex;
  flex-direction: column-reverse; /* nouveaux items en haut du stack */
  align-items: flex-end;
  gap: 12px;
  pointer-events: none; /* container transparent au pointer, items receivent */
}
.wvia-float-zone > * {
  pointer-events: auto;
}

/* Float zone top-right alternative pour les toggles HUD */
.wvia-float-zone[data-position="top-right"] {
  top: 12px;
  bottom: auto;
}
.wvia-float-zone[data-position="bottom-left"] {
  left: 16px;
  right: auto;
  align-items: flex-start;
}

/* ========================================================================
   HUD TOGGLE pattern — round 32px, accessible, (X) obligatoire
   ======================================================================== */
.wvia-hud-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--wvia-bg-dark-solid);
  color: var(--wvia-text-on-dark);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: transform .15s, background .15s;
  position: relative;
}
.wvia-hud-toggle:hover,
.wvia-hud-toggle:focus-visible {
  transform: scale(1.08);
  background: rgba(15,23,42,1);
  outline: 2px solid var(--wvia-orange-safe);
  outline-offset: 2px;
}

/* Close button mini (X) en coin top-right de chaque widget floatant */
.wvia-widget-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--wvia-bg-warning);
  color: white;
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.wvia-widget-close:hover {
  background: #dc2626;
}
.wvia-widget-close::before { content: "\00d7"; } /* multiplication sign */

/* ========================================================================
   BANNER pattern canonical — avec (X) intégré, non-stacking
   ======================================================================== */
.wvia-banner {
  position: relative;
  padding: 12px 40px 12px 16px;
  background: var(--wvia-bg-dark-solid);
  color: var(--wvia-text-on-dark);
  border-radius: 8px;
  font: 500 13px/1.4 system-ui, -apple-system, sans-serif;
  z-index: var(--wvia-z-floating);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.wvia-banner[data-variant="warning"] {
  background: var(--wvia-bg-warning);
}

/* ========================================================================
   CONTRAINTES anti-overlap globales (audit D1265 règle #3)
   - position:absolute SANS parent position:relative = bug
   - Ce CSS ne peut pas detecter ça mais documente la règle
   - À enforce par Playwright/qa script
   ======================================================================== */

/* Garde-fou: float-zone ne doit pas se superposer aux barres header/footer site */
body > .wvia-float-zone:first-of-type ~ header,
body > header ~ .wvia-float-zone:not([data-position]) {
  /* Force float-zone bottom-right si header présent */
}

/* ========================================================================
   ORANGE WCAG fix - remplacer #ff6b1a par variable safe
   Utilisation: .text-orange-safe au lieu de hardcoded #ff6b1a
   ======================================================================== */
.text-orange-safe,
.wvia-orange-text {
  color: var(--wvia-orange-safe);
}
.bg-orange-safe,
.wvia-orange-bg {
  background-color: var(--wvia-orange-safe);
  color: white; /* contraste sur fond orange */
}

/* ========================================================================
   MOBILE breakpoint 768px — floating widgets collapse en single FAB
   ======================================================================== */
@media (max-width: 768px) {
  /* Float zone bottom-right en mode FAB compact */
  .wvia-float-zone {
    bottom: 12px;
    right: 12px;
    gap: 8px;
    max-width: calc(100vw - 24px);
  }

  /* Multiple HUD toggles → empilés mais visibles */
  .wvia-hud-toggle {
    width: 44px; /* tap-friendly size (Apple HIG: 44pt min) */
    height: 44px;
    font-size: 16px;
  }

  /* Banner pleine largeur mobile */
  .wvia-banner {
    width: calc(100vw - 24px);
    padding: 14px 44px 14px 16px;
    font-size: 14px;
  }

  /* Close button mobile plus grand */
  .wvia-widget-close {
    width: 28px;
    height: 28px;
    font-size: 18px;
    top: -10px;
    right: -10px;
  }
}

/* ========================================================================
   ACCESSIBILITY — reduced-motion respect
   ======================================================================== */
@media (prefers-reduced-motion: reduce) {
  .wvia-hud-toggle,
  .wvia-widget-close {
    transition: none;
  }
}

/* ========================================================================
   END D1266 — Yacine doctrine compliant
   - Pas de surpatch !important généralisé (chaque règle locale)
   - Pas de stub
   - WCAG AA contrast vérifié (#d4521a 4.6:1 ; rgba(15,23,42,.92) sur white = 13:1)
   - z-index layers documentés
   - Mobile breakpoint 768px + 44pt tap target
   ======================================================================== */
