/* Colibri · Autopilot flotante y su cápsula. Cargar después de components.css. Lo activa js/autopilot.js.
   Siempre abajo a la derecha. Una sola superficie cambia de forma entre los tres estados del manual:
   colapsada (botón redondo, quieta), revisando (tarjeta con halo) y abierta (diálogo). */

/* ───────────── Cápsula ───────────── */
q-capsule { display: inline-block; flex: none; line-height: 0; }
q-capsule svg { display: block; width: 100%; height: 100%; overflow: visible; }
q-capsule :is(.q-capsule__a, .q-capsule__b) { transform-box: view-box; transform-origin: 150px 210px; }

/* ───────────── Superficie ───────────── */
q-autopilot {
  --w: 64px; --h: 64px; --r: 32px; --edge: var(--q-space-6); --max: var(--q-layout-autopilot);
  --q-acento: var(--q-autopilot-color); --q-acento-texto: var(--q-autopilot-color-texto);
  --q-p-color: var(--q-autopilot-color); --q-p-color-texto: var(--q-autopilot-color-texto); --q-p-color-fondo: var(--q-autopilot-color-fondo);
  position: fixed; right: var(--edge); bottom: var(--edge); z-index: 45; width: 0; height: 0; display: block;
}
q-autopilot:not(:defined) { display: none; }
q-autopilot[data-state="revisando"] { --w: min(372px, calc(100vw - 2 * var(--edge))); --h: 116px; --r: var(--q-radius-hero); }
q-autopilot[data-state="abierta"] { --w: min(var(--max), calc(100vw - 2 * var(--edge))); --h: var(--ap-panel, 480px); --r: var(--q-radius-hero); }
.q-ap__shell, .q-ap__halo { position: absolute; right: 0; bottom: 0; width: var(--w); height: var(--h); }
.q-ap__shell {
  overflow: hidden; border-radius: var(--r); background: color-mix(in srgb, var(--q-lienzo) 94%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 1px solid var(--q-borde); box-shadow: var(--q-shadow-3);
}
[data-state="abierta"] > .q-ap__shell { background: color-mix(in srgb, var(--q-fondo) 94%, transparent); box-shadow: var(--q-shadow-4); }
.is-ready > :is(.q-ap__shell, .q-ap__halo) { transition: width .5s var(--q-motion-ease), height .5s var(--q-motion-ease), border-radius .5s var(--q-motion-ease), box-shadow .4s ease, background .4s ease; }

/* Halo: aparece al revisar; abierta, queda apenas. */
.q-ap__halo { pointer-events: none; }
.q-ap__halo::before {
  content: ""; position: absolute; inset: -34px; border-radius: 80px; filter: blur(30px); opacity: 0; transition: opacity .7s ease;
  background: radial-gradient(60% 90% at 30% 20%, var(--q-autopilot-grad-inicio), transparent 75%), radial-gradient(70% 90% at 75% 90%, var(--q-autopilot-grad-cierre), transparent 75%), var(--q-autopilot-grad-brillo);
}
[data-state="abierta"] > .q-ap__halo::before { opacity: .12; }
[data-state="revisando"] > .q-ap__halo::before { opacity: .42; animation: q-ap-halo 3.6s ease-in-out infinite alternate; }
@keyframes q-ap-halo { from { transform: scale(.97); } to { transform: scale(1.03); } }

/* La cápsula es una sola y viaja entre los estados. */
.q-ap__shell > q-capsule { position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; transform-origin: 0 0; transform: translate(19.5px, 11px) scale(.42); }
[data-state="revisando"] > .q-ap__shell > q-capsule { transform: translate(28px, 16px) scale(.86); }
[data-state="abierta"] > .q-ap__shell > q-capsule { transform: translate(20px, 14px) scale(.4); }
.is-ready > .q-ap__shell > q-capsule { transition: transform .5s var(--q-motion-ease); }

/* Colapsada */
.q-ap__launch { position: absolute; inset: 0; z-index: 3; border: 0; border-radius: inherit; background: none; visibility: hidden; }
.q-ap__launch:focus-visible { outline-offset: -4px; border-radius: 50%; }
[data-state="colapsada"] .q-ap__launch { visibility: visible; }
.q-ap__label {
  position: absolute; right: 74px; bottom: 14px; height: 36px; padding: 0 var(--q-space-2) 0 var(--q-space-3-5); display: inline-flex; align-items: center; gap: var(--q-space-2);
  border: 1px solid var(--q-borde); border-radius: var(--q-radius-pill); background: var(--q-lienzo); box-shadow: var(--q-shadow-1);
  font-size: var(--q-type-small-size); color: var(--q-texto-medio); white-space: nowrap;
  opacity: 0; visibility: hidden; translate: 8px 0; transition: opacity .2s ease, translate .35s var(--q-motion-ease), visibility 0s .2s;
}
[data-state="colapsada"] > .q-ap__label { opacity: 1; visibility: visible; translate: none; transition-delay: .25s, .25s, .25s; }
/* Al bajar por la página, la etiqueta se guarda. Vuelve al pasar el mouse por la cápsula o enfocarla. */
q-autopilot.is-low:not(:hover, :focus-within) > .q-ap__label { opacity: 0; visibility: hidden; translate: 8px 0; transition-delay: 0s; }
@media (hover: hover) {
  [data-state="colapsada"] > .q-ap__shell:hover { box-shadow: var(--q-shadow-4); }
  [data-state="colapsada"] > .q-ap__shell:hover > q-capsule { transform: translate(18.6px, 9.1px) scale(.46); }
  .q-ap__label:hover { color: var(--q-texto); border-color: var(--q-borde-fuerte); }
}

/* Revisando */
.q-ap__review { position: absolute; inset: 0 var(--q-space-5) 0 102px; display: flex; flex-direction: column; justify-content: center; gap: var(--q-space-1); opacity: 0; visibility: hidden; }
.q-ap__review b { font-size: var(--q-type-card-size); font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.q-ap__review > span { font-size: var(--q-type-small-size); color: var(--q-texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-ap__review .q-thinking { margin-left: var(--q-space-1-5); }
[data-state="revisando"] .q-ap__review { opacity: 1; visibility: visible; transition: opacity .3s ease .2s; }

/* Abierta */
.q-ap__panel {
  position: absolute; right: -1px; bottom: -1px; width: min(var(--max), calc(100vw - 2 * var(--edge))); max-height: calc(100vh - var(--q-layout-header) - 2 * var(--edge));
  display: flex; flex-direction: column; opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility 0s .15s;
}
[data-state="abierta"] .q-ap__panel { opacity: 1; visibility: visible; transition: opacity .3s ease .18s, visibility 0s; }
.q-ap__head { flex: none; display: flex; align-items: center; gap: 2px; height: 66px; padding: 0 var(--q-space-3-5) 0 56px; }
.q-ap__title { margin-right: auto; font-size: var(--q-type-card-size); font-weight: 500; letter-spacing: -0.01em; }
.q-ap__head .q-iconbtn { width: 34px; height: 34px; }
.q-ap__ctx { flex: none; display: flex; flex-wrap: wrap; gap: var(--q-space-1-5); padding: 0 var(--q-space-5) var(--q-space-3); }
.q-ap__body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: var(--q-space-2) var(--q-space-5) var(--q-space-4); display: flex; flex-direction: column; gap: var(--q-space-3); }
.q-ap__body:focus-visible { outline-offset: -3px; }
.q-ap__body > * { flex: none; }
.q-ap__body > p { margin: 0; }
.q-ap__body > [hidden], .q-suggest[hidden] { display: none; }
.q-ap__body > .q-trace { padding-left: var(--q-space-4); }
.q-ap__foot { flex: none; padding: 0 var(--q-space-4) var(--q-space-4); display: flex; flex-direction: column; gap: var(--q-space-3); }
.q-ap__foot > .q-suggest { padding: 0 var(--q-space-1); }
.q-ap__foot > .q-suggest:empty { display: none; }
.q-ap__foot .q-composer { align-items: center; margin: 0; border-radius: var(--q-radius-oscuro); padding: var(--q-space-2) var(--q-space-2) var(--q-space-2) var(--q-space-4-5); }
.q-ap__hint { padding: 0 var(--q-space-1); font-size: var(--q-type-label-size); color: var(--q-texto-suave); display: flex; gap: var(--q-space-1-5) var(--q-space-2-5); flex-wrap: wrap; }
.q-ap__in { animation: q-ap-in .5s var(--q-motion-ease) both; }
@keyframes q-ap-in { from { opacity: 0; transform: translateY(8px); } }
.q-ap__wait { padding: var(--q-space-3-5) var(--q-space-4-5); }

/* Con un panel lateral abierto, Autopilot se corre a su izquierda. Si no entra, se oculta hasta que se cierra. */
body > q-autopilot { transition: right .42s var(--q-motion-ease); }
body[data-peek="open"] > q-autopilot { right: calc(min(var(--q-layout-peek), 100vw) + var(--edge)); }
@media (max-width: 940px) { body[data-peek="open"] > q-autopilot { display: none; } }
@media (max-width: 680px) { q-autopilot { --edge: var(--q-space-4); } .q-ap__label { display: none; } }

/* Para mostrar un estado dentro de una página, como en la guía */
q-autopilot[inline] { position: relative; right: auto; bottom: auto; z-index: 0; width: 100%; height: var(--h); }

.q-quieto :is(q-autopilot, q-autopilot *, q-autopilot ::before) { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { :is(q-autopilot, q-autopilot *), .q-ap__halo::before { transition: none !important; animation: none !important; } }
