/*
 * Aiden UI · AI search — el CSS module de Arc Pro (ai-search-bar.module.css) traducido a clases planas
 * `aui-as-*`, con sus MISMAS variables de foundation. La fuente está en
 * direccion/diseno/arc-fuente/ai-search-bar/. No se reconstruye de memoria: se traduce de ahí.
 *
 * Diferencia de partida: el bloque de Arc trae su propio campo (`.field`) y aquí NO se porta — el campo
 * es el que ya tenga la página. Por eso la tarjeta empieza en el cuerpo, con su borde arriba.
 */

.aui-as {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: var(--radius-panel, 16px);
  background: var(--surface, #fff);
  color: var(--foreground, #141414);
  font-size: var(--text-sm, 14px);
  line-height: 20px;
}
/* Sin consulta no hay tarjeta: la página se queda como estaba. */
.aui-as[data-abierto="false"] { display: none; }

/* Cuerpo: alto fijo, como en Arc, para que la tarjeta no salte entre estados. */
.aui-as-body { position: relative; flex: 1 1 auto; min-height: 0; }
.aui-as-view { max-height: 400px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.aui-as-list { display: flex; flex-direction: column; }

/* Grupos y cabeceras */
.aui-as-group { display: flex; flex-direction: column; padding: 6px 0; }
.aui-as-group + .aui-as-group { border-top: 1px solid var(--border-subtle, #f0f0f0); }
.aui-as-grouphead {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 16px 4px; font-size: var(--text-xs, 12px); font-weight: 500;
  letter-spacing: .02em; text-transform: uppercase; color: var(--text-muted, #8a8a8a);
}

/* Filas */
.aui-as-row {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 16px;
  cursor: pointer; scroll-margin: 8px; background: transparent;
  transition: background-color 80ms var(--ease-standard, cubic-bezier(.22,1,.36,1));
}
.aui-as-row[data-active] { background: var(--surface-muted, #f5f5f5); }
.aui-as-row[data-hot] { background: color-mix(in oklab, var(--accent, #13967e) 10%, transparent); }
.aui-as-icon, .aui-as-sparkle { display: grid; flex: none; place-items: center; width: 16px; height: 16px; color: var(--text-secondary, #555); }
.aui-as-sparkle { color: var(--accent, #13967e); }
.aui-as-text { display: grid; flex: 1; min-width: 0; gap: 1px; }
.aui-as-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.aui-as-description { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs, 12px); color: var(--text-muted, #8a8a8a); }
.aui-as-quoted { color: var(--text-secondary, #555); font-weight: 400; }
.aui-as-right { display: flex; flex: none; align-items: center; gap: 8px; }
.aui-as-meta { font-size: var(--text-xs, 12px); font-variant-numeric: tabular-nums; color: var(--text-muted, #8a8a8a); }
.aui-as-hl { background: color-mix(in oklab, var(--accent, #13967e) 18%, transparent); color: inherit; border-radius: 3px; }

/* La chapa con el número de cita, en el resultado */
.aui-as-badge {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 999px;
  background: var(--surface-muted, #f0f0f0); color: var(--text-secondary, #555);
  font-size: 11px; font-variant-numeric: tabular-nums; line-height: 1;
  transition: background-color 120ms var(--ease-standard, cubic-bezier(.22,1,.36,1)), color 120ms var(--ease-standard, cubic-bezier(.22,1,.36,1));
}
.aui-as-badge[data-hot] { background: var(--accent, #13967e); color: #fff; }

/* Teclas */
.aui-as-kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--border, #e5e5e5); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface-muted, #fafafa); color: var(--text-secondary, #555);
  font-family: inherit; font-size: 11px; line-height: 1;
}

/* La respuesta */
.aui-as-answerslot { border-bottom: 1px solid var(--border-subtle, #f0f0f0); }
.aui-as-answer { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 14px; }
.aui-as-answerhead { display: flex; align-items: center; gap: 8px; }
.aui-as-mark { display: grid; place-items: center; width: 18px; height: 18px; flex: none; color: var(--accent, #13967e); }
.aui-as-answertitle { font-weight: 500; }
.aui-as-answerstatus { flex: 1; min-width: 0; font-size: var(--text-xs, 12px); color: var(--text-muted, #8a8a8a); }
.aui-as-answeractions { display: flex; flex: none; gap: 2px; }
.aui-as-iconbutton {
  display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-secondary, #555); cursor: pointer;
  transition: background-color 120ms var(--ease-standard, cubic-bezier(.22,1,.36,1));
}
.aui-as-iconbutton:disabled { opacity: .4; cursor: default; }
@media (hover: hover) and (pointer: fine) { .aui-as-iconbutton:not(:disabled):hover { background: var(--surface-muted, #f0f0f0); color: var(--foreground, #141414); } }
.aui-as-answertext { margin: 0; color: var(--foreground, #141414); }
/* El texto aparece como en el chat de Lunnar: palabra a palabra, saliendo de un desenfoque suave,
   y cada palabra nace con el degradado de la marca y se asienta en tinta. Con el desfase de 28 ms
   lo que se ve es una onda de color recorriendo la frase. El desfase lo pone el JS.
   (Antes entraba a tandas con un reloj propio: «aparece de forma muy fea y como vibrando».) */
.aui-as-w { display: inline; opacity: 0; filter: blur(4px); animation: aui-as-sale .42s cubic-bezier(.16,1,.3,1) forwards; }
.aui-as-link, .aui-as-code, .aui-as-cite { animation: aui-as-sale .42s cubic-bezier(.16,1,.3,1) both; }
@keyframes aui-as-sale { to { opacity: 1; filter: blur(0); } }
/* Dentro de @supports a propósito: si el navegador no sabe recortar el fondo al texto, el fallo
   sería texto TRANSPARENTE, o sea invisible. Y el degradado va en VERTICAL: uno horizontal se
   reinicia en cada palabra y el párrafo se lee a rayas. */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .aui-as-w {
    background-image: linear-gradient(180deg, var(--ia-1, #8E7FC9) 0%, var(--ia-2, #574A87) 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    animation: aui-as-sale-ia .74s cubic-bezier(.16,1,.3,1) forwards;
  }
  @keyframes aui-as-sale-ia {
    0%   { opacity: 0; filter: blur(4px); -webkit-text-fill-color: transparent; }
    40%  { opacity: 1; filter: blur(0);   -webkit-text-fill-color: transparent; }
    100% { opacity: 1; filter: blur(0);   -webkit-text-fill-color: var(--foreground, #141414); }
  }
}
/* El hueco entre párrafos: un <br> solo los pega demasiado. */
.aui-as-parrafo { display: block; height: 6px; }
.aui-as-link { color: var(--accent, #13967e); text-decoration: underline; text-underline-offset: 2px; }
.aui-as-code { padding: 1px 5px; border-radius: 5px; background: var(--surface-muted, #f0f0f0); font-family: ui-monospace, "JetBrains Mono", monospace; font-size: .92em; }

/* La cita: un número pequeño y pulsable dentro del texto */
.aui-as-cite {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; margin: 0 1px; padding: 0 3px;
  border: 0; border-radius: 4px; background: var(--surface-muted, #f0f0f0); color: var(--text-secondary, #555);
  font: inherit; font-size: 11px; line-height: 1; vertical-align: 2px; cursor: pointer;
  transition: background-color 120ms var(--ease-standard, cubic-bezier(.22,1,.36,1)), color 120ms var(--ease-standard, cubic-bezier(.22,1,.36,1));
}
.aui-as-cite[data-hot], .aui-as-cite:hover { background: var(--accent, #13967e); color: #fff; }

/* Mientras no hay nada escrito todavía */
.aui-as-placeholder { display: grid; gap: 6px; }
.aui-as-placeholder span { display: block; height: 10px; border-radius: 5px; background: var(--surface-muted, #f0f0f0); animation: aui-as-pulse 1.4s var(--ease-in-out, cubic-bezier(.65,0,.35,1)) infinite alternate; }
.aui-as-placeholder span:last-child { width: 62%; }
@keyframes aui-as-pulse { from { opacity: 1; } to { opacity: .55; } }

/* «Pensando» / «Escribiendo»: el text-shimmer de Arc, en pequeño */
.aui-as-shimmer[data-on] {
  background: linear-gradient(90deg, currentColor 20%, color-mix(in oklab, currentColor 35%, transparent) 50%, currentColor 80%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: aui-as-shine 1.6s linear infinite;
}
@keyframes aui-as-shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Error */
.aui-as-error { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text-secondary, #555); }
.aui-as-errorlabel { display: inline-flex; align-items: center; gap: 4px; color: var(--danger, #d8543f); }
.aui-as-retry {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px;
  border: 1px solid var(--border, #e5e5e5); border-radius: 999px; background: transparent;
  color: var(--foreground, #141414); font: inherit; font-size: var(--text-xs, 12px); cursor: pointer;
}
.aui-as-retry:hover { border-color: var(--foreground, #141414); }

/* Nada que encaje */
.aui-as-empty:not(:empty) { display: grid; gap: 4px; padding: 28px 16px; text-align: center; }
.aui-as-emptytitle { font-weight: 500; }
.aui-as-emptyhint { font-size: var(--text-xs, 12px); color: var(--text-muted, #8a8a8a); }

/* Pie */
.aui-as-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  height: 44px; padding: 0 16px; border-top: 1px solid var(--border-subtle, #f0f0f0);
  background: var(--surface-muted, #fafafa); font-size: var(--text-xs, 12px); color: var(--text-muted, #8a8a8a);
}
.aui-as-hints { display: flex; align-items: center; gap: 14px; }
.aui-as-hint { display: inline-flex; align-items: center; gap: 6px; }
.aui-as-model { display: inline-flex; align-items: center; gap: 6px; }
.aui-as-model svg { width: 14px; height: 14px; }
.aui-as-modelname { font-weight: 500; }

.aui-as-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* El anillo de foco solo con teclado, como en todo el kit. */
.aui-as-row:focus-visible, .aui-as-cite:focus-visible, .aui-as-iconbutton:focus-visible, .aui-as-retry:focus-visible {
  outline: 2px solid var(--accent, #13967e); outline-offset: -2px;
}

/* Estrecho: el pie se queda con lo imprescindible y las descripciones se van, como en Arc. */
@container (max-width: 520px) {
  .aui-as-hint:nth-child(1), .aui-as-hint:nth-child(2) { display: none; }
}
@container (max-width: 400px) {
  .aui-as-description { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  /* Sin animación, el texto se quedaría en el 0 % del fotograma, que es transparente: hay que
     devolverle el color a mano, no basta con quitar la animación. */
  .aui-as-w { opacity: 1; filter: none; animation: none; background-image: none;
    -webkit-text-fill-color: var(--foreground, #141414); }
  .aui-as-link, .aui-as-code, .aui-as-cite { animation: none; }
  .aui-as-placeholder span, .aui-as-shimmer[data-on] { animation: none; }
  .aui-as-row, .aui-as-badge, .aui-as-cite, .aui-as-iconbutton { transition: none; }
}
