/* ===== LIVE ORB — COMPAGNON KODAK EXPRESSIF + THINKING REASONING ===== */
/* Sphère WebGL pure (#F2C94C / #1E1B18) sans bordure parasite, dotée
   d'émotions GLSL, de petits Zzz endormis et d'une bulle de pensée type IA. */

.orb-companion {
  --orb-size: 56px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 990;
  width: var(--orb-size);
  height: var(--orb-size);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  transition: opacity 0.45s var(--ease-out);
}

.orb-companion.is-ready {
  opacity: 1;
}

body.has-open-media .orb-companion,
body.menu-open .orb-companion,
body.has-open-media .orb-speech,
body.menu-open .orb-speech {
  opacity: 0;
  pointer-events: none;
}

.orb-body {
  position: relative;
  width: 100%;
  height: 100%;
}

.orb-launcher {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  transition: transform 0.24s var(--ease-out);
}

.orb-launcher:hover {
  transform: scale(1.07);
}

.orb-companion.is-dragging .orb-launcher {
  cursor: grabbing;
  transform: scale(0.95);
}

.orb-launcher:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.orb-surface {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  overflow: visible;
  pointer-events: none;
}

.orb-companion.is-idle .orb-surface {
  animation: orb-idle-bob 3.6s ease-in-out infinite;
}

.orb-launcher:hover .orb-surface,
.orb-companion.is-dragging .orb-surface,
.orb-companion[data-mood="sleepy"] .orb-surface {
  animation: none;
}

@keyframes orb-idle-bob {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -4px, 0);
  }
}

.orb-surface::before {
  content: "";
  position: absolute;
  inset: -10%;
  top: 4%;
  bottom: -20%;
  border-radius: var(--radius-full);
  background: radial-gradient(
    circle at 50% 58%,
    rgb(0 0 0 / 0.4) 0%,
    rgb(0 0 0 / 0.14) 44%,
    transparent 70%
  );
  z-index: 0;
  pointer-events: none;
}

.orb-surface canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
}

.orb-fallback {
  position: absolute;
  inset: 3%;
  z-index: 1;
  overflow: hidden;
  border-radius: var(--radius-full);
  background-color: #F2C94C;
}

.orb-fallback-eye {
  position: absolute;
  width: 13%;
  height: 28%;
  top: 34%;
  border-radius: var(--radius-pill);
  background-color: #1E1B18;
}

.orb-fallback-eye--left {
  left: 31%;
}

.orb-fallback-eye--right {
  left: 56%;
}

/* Petits Z z z flottants lorsque l'orb s'endort */
.orb-zzz {
  position: absolute;
  top: -12px;
  right: -6px;
  z-index: 2;
  width: 34px;
  height: 40px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.orb-zzz span {
  position: absolute;
  right: 8px;
  bottom: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-light);
  text-shadow: 0 2px 6px rgb(0 0 0 / 0.75);
  opacity: 0;
  line-height: 1;
}

.orb-zzz span:nth-child(1) { font-size: 0.72rem; }
.orb-zzz span:nth-child(2) { font-size: 0.88rem; }
.orb-zzz span:nth-child(3) { font-size: 1.05rem; }

.orb-companion[data-mood="sleepy"] .orb-zzz {
  opacity: 1;
}

.orb-companion[data-mood="sleepy"] .orb-zzz span:nth-child(1) {
  animation: orb-zzz-float 2.7s ease-in-out infinite 0s;
}

.orb-companion[data-mood="sleepy"] .orb-zzz span:nth-child(2) {
  animation: orb-zzz-float 2.7s ease-in-out infinite 0.9s;
}

.orb-companion[data-mood="sleepy"] .orb-zzz span:nth-child(3) {
  animation: orb-zzz-float 2.7s ease-in-out infinite 1.8s;
}

@keyframes orb-zzz-float {
  0% {
    opacity: 0;
    transform: translate3d(0, 6px, 0) scale(0.72) rotate(-8deg);
  }
  22% {
    opacity: 0.95;
  }
  70% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: translate3d(16px, -32px, 0) scale(1.18) rotate(12deg);
  }
}

.orb-pulse {
  display: none;
}

/* ===== PENSÉE SOBRE : FOND LÉGER UNIQUEMENT SOUS LES MOTS ===== */
.orb-speech {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 989;
  width: min(304px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  text-shadow: 0 1px 4px rgb(0 0 0 / 0.85);
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 6px, 0);
  transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-out);
}

.orb-speech.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.orb-speech[hidden] {
  display: none;
}

/* Composant ThinkingReasoning fidèle, sobre et sans boîte globale */
.trr-root {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  animation: tr-block-in 0.24s var(--ease-out) both;
}

.trr-header {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.35rem;
  padding: 0.16rem 0.46rem;
  border: 0;
  border-radius: 5px;
  background: rgb(14 12 10 / 0.56);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  text-shadow: inherit;
  pointer-events: none;
  cursor: default;
}

.trr-header[hidden] {
  display: none;
}

.trr-header.trr-clickable {
  pointer-events: auto;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.trr-header.trr-clickable:hover {
  color: var(--text);
}

.trr-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.trr-label {
  display: inline-block;
}

.trr-verb {
  color: var(--text);
  font-weight: 600;
}

/* Shimmer sobre sur "Thinking…" / "Réflexion…" */
.trr-shimmer {
  background: linear-gradient(
    90deg,
    #857a70 0%,
    #857a70 35%,
    #ebe4dc 50%,
    #857a70 65%,
    #857a70 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: none;
  animation: tr-shine 1.9s linear infinite;
}

.trr-chevron {
  flex-shrink: 0;
  transition: transform 0.24s var(--ease-out);
  transform: rotate(180deg);
}

.trr-header[aria-expanded="true"] .trr-chevron {
  transform: rotate(0deg);
}

.trr-collapsible {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.32s var(--ease-out), opacity 0.24s ease;
  opacity: 1;
}

.trr-collapsible.trr-collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
}

.trr-inner {
  overflow: hidden;
}

.trr-viewport {
  position: relative;
  overflow: hidden;
  margin-top: 0.36rem;
  transition: height 0.28s var(--ease-out);
}

.trr-viewport.trr-scroll {
  pointer-events: auto;
  overflow-y: auto;
  scrollbar-width: none;
}

.trr-viewport.trr-scroll::-webkit-scrollbar {
  display: none;
}

.trr-stream {
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.32s var(--ease-out);
  will-change: transform;
}

.trr-sentence {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.62;
  color: var(--text-secondary);
  animation: tr-sentence-in 0.32s var(--ease-out) both;
}

.trr-text-bg {
  display: inline;
  padding: 0.14rem 0.42rem;
  border-radius: 5px;
  background: rgb(14 12 10 / 0.56);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Réponse finale directement dans le vide avec léger fond sous les mots */
.orb-answer {
  margin-top: 0.38rem;
  font-size: 0.86rem;
  line-height: 1.62;
  color: var(--text);
  animation: tr-sentence-in 0.35s var(--ease-out) both;
}

.orb-answer--direct {
  margin-top: 0;
}

.orb-answer[hidden] {
  display: none;
}

@keyframes tr-block-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes tr-sentence-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tr-shine {
  0%, 12% {
    background-position: 100% 0;
  }
  88%, 100% {
    background-position: 0% 0;
  }
}

@media (max-width: 640px) {
  .orb-companion {
    --orb-size: 48px;
  }

  .orb-speech {
    width: min(276px, calc(100vw - 24px));
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb-companion,
  .orb-launcher,
  .orb-surface,
  .orb-pulse,
  .orb-zzz span,
  .orb-speech,
  .trr-shimmer,
  .trr-collapsible,
  .trr-viewport,
  .trr-stream,
  .trr-sentence,
  .orb-answer {
    transition: none;
    animation: none !important;
  }

  .trr-shimmer {
    -webkit-text-fill-color: var(--text-secondary);
    color: var(--text-secondary);
    background: none;
  }
}
