/* ========================================
   ACCES IA — Widget Léa (assistante vocale IA)
   Orbe flottant bas-droite + panneau intégré.
   Vanilla CSS, palette « Terre cuite », GPU-only
   (transform / opacity), prefers-reduced-motion safe.
   ======================================== */

/* ----- Racine ----- */
.lea-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--font-sans, 'Work Sans', sans-serif);
}

.lea-root [hidden] { display: none !important; }

/* ========================================
   LANCEUR — pastille label + orbe
   ======================================== */

.lea-launcher {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 9px 8px 20px;
  border: 1px solid var(--grey-soft, #E8DDCD);
  border-radius: var(--radius-pill, 999px);
  background: var(--ivory-soft, #F7EEDC);
  box-shadow: 0 6px 24px rgba(26, 22, 18, 0.14);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform .25s cubic-bezier(.22,.61,.36,1),
              box-shadow .25s ease;
}

.lea-launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(26, 22, 18, 0.2);
}

.lea-launcher:focus-visible {
  outline: 2px solid var(--orange, #E8461F);
  outline-offset: 3px;
}

/* Nudge d'attention : petite oscillation toutes les ~14 s,
   uniquement tant que le panneau n'a jamais été ouvert */
.lea-root:not(.lea-opened) .lea-launcher {
  animation: lea-nudge 14s ease-in-out 8s infinite;
}

@keyframes lea-nudge {
  0%, 91%, 100% { transform: rotate(0); }
  93%  { transform: rotate(-2.4deg); }
  95%  { transform: rotate(2deg); }
  97%  { transform: rotate(-1.2deg); }
}

.lea-launcher-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--ink, #1A1612);
}

.lea-launcher-label strong {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink, #1A1612);
}

.lea-launcher-label strong em {
  font-family: var(--font-italic, 'Crimson Pro', serif);
  font-style: italic;
  font-size: 17px;
}

.lea-launcher-label small {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--sepia, #7A4936);
}

/* ========================================
   ORBE — sphère vivante « terre cuite »
   ======================================== */

.lea-orb-wrap {
  position: relative;
  display: block;
  flex-shrink: 0;
  width: 58px;
  height: 58px;
}

/* Halo qui respire derrière l'orbe */
.lea-orb-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(232, 70, 31, 0.45);
  animation: lea-halo 3.4s cubic-bezier(.22,.61,.36,1) infinite;
}

@keyframes lea-halo {
  0%   { transform: scale(1);    opacity: .7; }
  70%  { transform: scale(1.45); opacity: 0;  }
  100% { transform: scale(1.45); opacity: 0;  }
}

.lea-orb {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 32% 28%, #FF8A5C 0%, var(--orange, #E8461F) 46%, #8C3218 100%);
  box-shadow:
    0 6px 18px rgba(232, 70, 31, 0.4),
    inset 0 -6px 12px rgba(90, 26, 8, 0.35);
  animation: lea-breathe 4.4s ease-in-out infinite;
}

@keyframes lea-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

/* Nappes de couleur en mouvement lent (façon lave douce) */
.lea-orb i {
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  will-change: transform;
}

.lea-orb .lea-blob-a {
  width: 78%;
  height: 78%;
  left: -14%;
  top: -10%;
  background: radial-gradient(circle, #FFE3B8 0%, rgba(255, 227, 184, 0) 70%);
  animation: lea-drift-a 9s ease-in-out infinite alternate;
}

.lea-orb .lea-blob-b {
  width: 88%;
  height: 88%;
  right: -22%;
  bottom: -18%;
  background: radial-gradient(circle, #B55B47 0%, rgba(122, 36, 18, 0) 72%);
  animation: lea-drift-b 12s ease-in-out infinite alternate;
}

.lea-orb .lea-blob-c {
  width: 62%;
  height: 62%;
  left: 18%;
  bottom: -26%;
  background: radial-gradient(circle, #F2E6D0 0%, rgba(242, 230, 208, 0) 68%);
  animation: lea-drift-c 7.5s ease-in-out infinite alternate;
}

@keyframes lea-drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(34%, 26%, 0) scale(1.25); }
}

@keyframes lea-drift-b {
  from { transform: translate3d(0, 0, 0) rotate(0)      scale(1); }
  to   { transform: translate3d(-30%, -24%, 0) rotate(40deg) scale(1.15); }
}

@keyframes lea-drift-c {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-16%, -38%, 0) scale(1.35); }
}

/* Reflet « verre » fixe, en haut à gauche */
.lea-orb::after {
  content: "";
  position: absolute;
  width: 46%;
  height: 34%;
  left: 12%;
  top: 8%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.75) 0%, rgba(255,255,255,0) 70%);
  transform: rotate(-18deg);
}

/* Variante réduite (en-tête de panneau, chargement) */
.lea-orb-wrap--mini {
  width: 34px;
  height: 34px;
}

.lea-orb-wrap--mini::before { display: none; }
.lea-orb-wrap--mini .lea-orb i { filter: blur(5px); }

/* ========================================
   TEASER — bulle d'invitation
   ======================================== */

.lea-teaser {
  position: relative;
  max-width: 262px;
  padding: 14px 38px 14px 16px;
  background: var(--ivory-soft, #F7EEDC);
  border: 1px solid var(--grey-soft, #E8DDCD);
  border-radius: 14px 14px 2px 14px;
  box-shadow: 0 10px 30px rgba(26, 22, 18, 0.16);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .45s cubic-bezier(.22,.61,.36,1),
              transform .45s cubic-bezier(.22,.61,.36,1),
              visibility 0s linear .45s;
}

.lea-teaser.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0s;
}

.lea-teaser p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink, #1A1612);
}

.lea-teaser p + p {
  margin-top: 4px;
  font-family: var(--font-italic, 'Crimson Pro', serif);
  font-style: italic;
  font-size: 15.5px;
  color: var(--sepia, #7A4936);
}

.lea-teaser-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--sepia, #7A4936);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

/* La pastille reste visuellement a 26 px, mais sa zone cliquable est portee a
   44 px par un calque invisible centre : on gagne la cible tactile sans
   alourdir le teaser. */
.lea-teaser-close::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}

.lea-teaser-close:hover {
  background: rgba(26, 22, 18, 0.08);
  color: var(--ink, #1A1612);
}

.lea-teaser-close:focus-visible {
  outline: 2px solid var(--orange, #E8461F);
  outline-offset: 1px;
}

/* ========================================
   PANNEAU — conversation intégrée
   ======================================== */

.lea-backdrop {
  position: fixed;
  inset: 0;
  z-index: 88;
  background: rgba(26, 22, 18, 0.4);
  opacity: 0;
  transition: opacity .3s ease;
}

.lea-backdrop.is-open { opacity: 1; }

.lea-panel {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 92;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 130px));
  min-height: 400px;
  background: var(--ivory, #F2E6D0);
  border: 1px solid var(--grey-soft, #E8DDCD);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(26, 22, 18, 0.3);
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .32s cubic-bezier(.22,1.1,.36,1),
              transform .32s cubic-bezier(.22,1.1,.36,1);
}

.lea-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* En-tête */
.lea-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  background: var(--ivory-soft, #F7EEDC);
  border-bottom: 1px solid var(--grey-soft, #E8DDCD);
}

.lea-panel-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lea-panel-titles strong {
  font-family: var(--font-serif, 'Playfair Display', serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink, #1A1612);
}

.lea-panel-titles span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--sepia, #7A4936);
}

.lea-panel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grey-soft, #E8DDCD);
  flex-shrink: 0;
}

.lea-panel.is-loaded .lea-panel-dot {
  background: var(--orange, #E8461F);
  animation: lea-dot 1.6s ease-in-out infinite;
}

@keyframes lea-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

.lea-panel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--sepia, #7A4936);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.lea-panel-btn:hover {
  background: rgba(26, 22, 18, 0.07);
  color: var(--ink, #1A1612);
}

.lea-panel-btn:focus-visible {
  outline: 2px solid var(--orange, #E8461F);
  outline-offset: 1px;
}

.lea-panel-btn svg { display: block; }

/* Corps : iframe + état de chargement */
.lea-panel-body {
  position: relative;
  flex: 1;
  background: var(--ivory, #F2E6D0);
}

.lea-panel-body iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ivory, #F2E6D0);
}

.lea-panel-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--ivory, #F2E6D0);
  transition: opacity .35s ease, visibility 0s linear .35s;
}

.lea-panel-loading p {
  margin: 0;
  font-family: var(--font-italic, 'Crimson Pro', serif);
  font-style: italic;
  font-size: 17px;
  color: var(--sepia, #7A4936);
}

.lea-panel.is-loaded .lea-panel-loading {
  opacity: 0;
  visibility: hidden;
}

/* ----- Mobile : pastille compacte + panneau plein écran ----- */
@media (max-width: 519px) {
  .lea-root {
    right: 16px;
    bottom: 16px;
  }

  .lea-launcher {
    padding: 6px;
  }

  .lea-launcher-label { display: none; }

  .lea-orb-wrap:not(.lea-orb-wrap--mini) {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 639px) {
  .lea-panel {
    right: 12px;
    left: 12px;
    top: max(12px, env(safe-area-inset-top));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    border-radius: 16px;
  }
}

@media (min-width: 640px) {
  .lea-backdrop { display: none; }
}

/* Verrouillage du scroll quand le panneau couvre l'écran (mobile) */
html.lea-no-scroll,
html.lea-no-scroll body {
  overflow: hidden;
}

/* ----- Accessibilité : mouvement réduit ----- */
@media (prefers-reduced-motion: reduce) {
  .lea-launcher,
  .lea-orb,
  .lea-orb i,
  .lea-orb-wrap::before,
  .lea-panel-dot {
    animation: none !important;
  }

  .lea-teaser,
  .lea-panel,
  .lea-backdrop {
    transition: none !important;
  }

  .lea-panel {
    transform: none;
  }
}
