/* ============================================================
   NOVA — ASSISTANT ORBYA
   Palette fixe (indépendante du thème des planètes) pour rester
   lisible sur les escales claires comme sombres.
   ============================================================ */

.nova {
  --nova-bg: #080b1d;
  --nova-surface: rgba(255, 255, 255, .06);
  --nova-line: rgba(160, 185, 255, .22);
  --nova-ink: #f3f7ff;
  --nova-muted: rgba(243, 247, 255, .72);
  --nova-cyan: #28d8ff;
  --nova-violet: #5b3df5;
  --nova-magenta: #d62976;
  --nova-grad: linear-gradient(120deg, #28d8ff, #5b3df5 55%, #d62976);
  --nova-right: clamp(16px, 4vw, 40px);
  --nova-bottom: 24px;

  position: fixed;
  right: var(--nova-right);
  bottom: var(--nova-bottom);
  z-index: 58;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;

  color: var(--nova-ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  pointer-events: none;
}

/* Page d'accueil : au-dessus du bouton son et du compteur d'escales. */
.nova--raised {
  --nova-bottom: 124px;
}

.nova > * {
  pointer-events: auto;
}

/* Ouverte, la fenêtre passe au-dessus du bouton son (z-index 60),
   mais reste sous le menu mobile (70) et les fenêtres modales. */
.nova.is-open {
  z-index: 65;
}

.nova *,
.nova *::before,
.nova *::after {
  box-sizing: border-box;
}

.nova-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Bulle flottante ---------------- */

.nova-launcher {
  position: relative;

  display: inline-flex;
  align-items: center;
  gap: 9px;

  height: 52px;
  padding: 0 18px 0 8px;

  color: var(--nova-ink);
  background: var(--nova-bg);
  border: 1px solid var(--nova-line);
  border-radius: 40px;
  box-shadow:
    0 14px 34px rgba(0, 0, 0, .38),
    0 0 0 1px rgba(40, 216, 255, .08),
    0 0 26px rgba(91, 61, 245, .35);

  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .3px;

  cursor: pointer;
  transition: transform .25s cubic-bezier(.22, .61, .36, 1), box-shadow .25s;
}

.nova-launcher:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, .42),
    0 0 32px rgba(40, 216, 255, .4);
}

.nova-launcher:focus-visible,
.nova-close:focus-visible,
.nova-send:focus-visible,
.nova-chip:focus-visible,
.nova-link:focus-visible,
.nova-foot a:focus-visible,
.nova-log:focus-visible {
  outline: 2px solid var(--nova-cyan);
  outline-offset: 3px;
}

.nova-launcher__icon {
  display: grid;
  place-items: center;

  width: 36px;
  height: 36px;

  color: #fff;
  background: var(--nova-grad);
  border-radius: 50%;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .35);
}

.nova-launcher__icon svg,
.nova-avatar svg {
  width: 22px;
  height: 22px;
}

/* Satellite discret en orbite autour de l'icône (CSS seul, très léger). */
.nova-launcher__orbit {
  position: absolute;
  top: 50%;
  left: 26px;

  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;

  border: 1px dashed rgba(40, 216, 255, .28);
  border-radius: 50%;
  pointer-events: none;

  animation: nova-orbit 9s linear infinite;
}

.nova-launcher__orbit::after {
  content: "";

  position: absolute;
  top: -3px;
  left: 50%;

  width: 6px;
  height: 6px;
  margin-left: -3px;

  background: var(--nova-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--nova-cyan);
}

.nova.is-open .nova-launcher__orbit {
  animation-play-state: paused;
}

@keyframes nova-orbit {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------- Fenêtre ---------------- */

.nova-panel {
  display: flex;
  flex-direction: column;

  width: min(380px, calc(100vw - 32px));
  height: min(580px, calc(100vh - var(--nova-bottom) - 150px));
  height: min(580px, calc(100dvh - var(--nova-bottom) - 150px));
  min-height: 320px;

  overflow: hidden;

  background: var(--nova-bg);
  border: 1px solid var(--nova-line);
  border-radius: 22px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, .5),
    0 0 40px rgba(91, 61, 245, .22);

  transform-origin: bottom right;
  animation: nova-in .22s cubic-bezier(.22, .61, .36, 1);
}

.nova-panel[hidden] {
  display: none;
}

@keyframes nova-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.98);
  }
}

.nova-head {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 14px 14px 12px 16px;

  background:
    radial-gradient(circle at 0 0, rgba(40, 216, 255, .16), transparent 60%),
    radial-gradient(circle at 100% 0, rgba(214, 41, 118, .14), transparent 55%);
  border-bottom: 1px solid var(--nova-line);
}

.nova-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;

  width: 38px;
  height: 38px;

  color: #fff;
  background: var(--nova-grad);
  border-radius: 50%;
}

.nova-head__text {
  flex: 1 1 auto;
  min-width: 0;
}

.nova-title {
  margin: 0;

  color: var(--nova-ink);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .2px;
  line-height: 1.2;
}

.nova-sub {
  margin: 2px 0 0;

  color: var(--nova-muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.nova-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;

  width: 40px;
  height: 40px;
  padding: 0;

  color: var(--nova-ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;

  cursor: pointer;
  transition: background .2s, border-color .2s;
}

.nova-close:hover {
  background: var(--nova-surface);
  border-color: var(--nova-line);
}

.nova-close svg {
  width: 20px;
  height: 20px;
}

.nova-notice {
  margin: 0;
  padding: 9px 16px;

  color: var(--nova-muted);
  background: rgba(40, 216, 255, .06);
  border-bottom: 1px solid var(--nova-line);

  font-size: 11.5px;
  line-height: 1.45;
}

.nova-log {
  flex: 1 1 auto;

  display: flex;
  flex-direction: column;
  gap: 10px;

  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;

  scrollbar-width: thin;
  scrollbar-color: rgba(160, 185, 255, .3) transparent;
}

.nova-msg {
  max-width: 88%;
  padding: 11px 14px;

  border-radius: 16px;

  font-size: 14.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.nova-msg p {
  margin: 0;
}

.nova-msg p + p {
  margin-top: 7px;
}

.nova-msg--bot {
  align-self: flex-start;

  color: var(--nova-ink);
  background: var(--nova-surface);
  border: 1px solid var(--nova-line);
  border-bottom-left-radius: 5px;
}

.nova-msg--user {
  align-self: flex-end;

  color: #fff;
  background: linear-gradient(120deg, #3f2bd0, #5b3df5);
  border-bottom-right-radius: 5px;
}

.nova-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;

  margin-top: 11px;
}

.nova-link {
  display: inline-flex;
  align-items: center;

  min-height: 34px;
  padding: 6px 12px;

  color: #062431;
  background: var(--nova-cyan);
  border-radius: 30px;

  font-size: 13px;
  font-weight: 600;
  text-decoration: none;

  transition: background .2s;
}

.nova-link:hover {
  background: #7fe8ff;
}

.nova-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.nova-chip {
  min-height: 36px;
  padding: 7px 13px;

  color: var(--nova-ink);
  background: transparent;
  border: 1px solid rgba(40, 216, 255, .55);
  border-radius: 30px;

  font: inherit;
  font-size: 13px;
  line-height: 1.25;
  text-align: left;

  cursor: pointer;
  transition: background .2s, border-color .2s;
}

.nova-chip:hover {
  background: rgba(40, 216, 255, .14);
  border-color: var(--nova-cyan);
}

.nova-typing {
  display: flex;
  gap: 5px;

  margin: 0 16px 10px;
  padding: 12px 14px;
  width: max-content;

  background: var(--nova-surface);
  border: 1px solid var(--nova-line);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
}

.nova-typing[hidden] {
  display: none;
}

.nova-typing span {
  width: 7px;
  height: 7px;

  background: var(--nova-cyan);
  border-radius: 50%;

  animation: nova-dot 1s ease-in-out infinite;
}

.nova-typing span:nth-child(2) {
  animation-delay: .15s;
}

.nova-typing span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes nova-dot {
  0%, 80%, 100% {
    opacity: .3;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.nova-form {
  display: flex;
  gap: 8px;

  padding: 12px;

  border-top: 1px solid var(--nova-line);
}

.nova-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  padding: 0 16px;

  color: var(--nova-ink);
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--nova-line);
  border-radius: 30px;

  font: inherit;
  /* 16px minimum : évite le zoom automatique sur iOS. */
  font-size: 16px;
}

.nova-input::placeholder {
  color: rgba(243, 247, 255, .5);
}

.nova-input:focus {
  outline: none;
  border-color: var(--nova-cyan);
  box-shadow: 0 0 0 3px rgba(40, 216, 255, .22);
}

.nova-send {
  display: grid;
  flex: 0 0 auto;
  place-items: center;

  width: 46px;
  height: 46px;
  padding: 0;

  color: #fff;
  background: var(--nova-grad);
  border: 0;
  border-radius: 50%;

  cursor: pointer;
  transition: transform .2s;
}

.nova-send:hover {
  transform: scale(1.05);
}

.nova-send svg {
  width: 20px;
  height: 20px;
}

.nova-foot {
  margin: 0;
  padding: 0 16px 12px;

  color: var(--nova-muted);
  font-size: 12px;
  text-align: center;
}

.nova-foot a {
  color: var(--nova-cyan);
}

/* ---------------- Mobile ---------------- */

@media (max-width: 640px) {
  .nova {
    --nova-right: 16px;
  }

  .nova--raised {
    --nova-bottom: 120px;
  }

  /* Sur mobile, seule l'icône est visible pour ne pas masquer le contenu. */
  .nova-launcher {
    width: 52px;
    padding: 0;
    justify-content: center;
  }

  .nova-launcher__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .nova-launcher__orbit {
    left: 50%;
  }

  /* Fenêtre en panneau bas, au-dessus de tout le reste de l'interface Nova. */
  .nova.is-open {
    right: 8px;
    bottom: 8px;
    left: 8px;
  }

  .nova.is-open .nova-launcher {
    display: none;
  }

  .nova-panel {
    width: 100%;
    height: min(620px, calc(100vh - 86px));
    height: min(620px, calc(100dvh - 86px));
    border-radius: 20px;
  }
}

/* ---------------- Mouvement réduit ---------------- */

@media (prefers-reduced-motion: reduce) {
  .nova-launcher__orbit,
  .nova-typing span,
  .nova-panel {
    animation: none;
  }

  .nova-launcher,
  .nova-launcher:hover,
  .nova-send:hover {
    transition: none;
    transform: none;
  }
}

@media print {
  .nova {
    display: none;
  }
}
