/* Buscador de la documentación (templates/_docs_search.html + static/js/docs-search.js).
   Fichero propio y no app.css/Tailwind: Tailwind v4 purga las clases nuevas y aquí no hay
   build que las regenere. Solo usa las variables de tema, así que sigue claro/oscuro. */

.dsearch { position: relative; max-width: 40rem; margin: 1.1rem 0 0; }

/* Solo para lectores de pantalla. */
.dsearch-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.dsearch-box {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0 0.75rem; height: 2.75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--muted);
  transition: border-color .12s, box-shadow .12s;
}
.dsearch-box:focus-within {
  border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dsearch-ico { flex: none; }

.dsearch-input {
  flex: 1; min-width: 0; height: 100%;
  font: inherit; font-size: 0.95rem; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
/* La caja de fuera ya es el campo (borde, radio y anillo de foco). `app.css` da a TODO
   `input[type="search"]` un borde violeta con `!important` y un resplandor al enfocar, y sin
   esto salía un segundo recuadro dentro del recuadro. Gana por especificidad, no por orden:
   (0,2,0) y (0,3,0) frente a (0,1,1) y (0,2,1) de las reglas globales. */
.dsearch .dsearch-input,
.dsearch .dsearch-input:focus {
  border: 0 !important; border-radius: 0 !important;
  outline: 0; box-shadow: none; background: transparent;
}
.dsearch-input { text-overflow: ellipsis; }
.dsearch-input::placeholder { color: var(--muted); }
.dsearch-input::-webkit-search-cancel-button { cursor: pointer; }

.dsearch-kbd {
  flex: none; font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.72rem;
  padding: 0.1rem 0.4rem; color: var(--muted);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px;
}
.dsearch-box:focus-within .dsearch-kbd { display: none; }
/* En táctil no hay tecla «/», y en pantallas estrechas el aviso le quita sitio al texto. */
@media (hover: none), (max-width: 640px) { .dsearch-kbd { display: none; } }

.dsearch-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 0.4rem);
  margin: 0; padding: 0.35rem; list-style: none;
  max-height: min(70vh, 32rem); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.dsearch-list[hidden] { display: none; }

.dsearch-item a {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.55rem 0.7rem; border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.docs-page .dsearch-item a { color: var(--text); }
.docs-page .dsearch-item a:hover { text-decoration: none; }
.dsearch-item.is-active a, .dsearch-item a:hover { background: var(--accent-soft); }

.dsearch-page {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.dsearch-title { font-size: 0.93rem; font-weight: 650; line-height: 1.35; }
.dsearch-snip { font-size: 0.82rem; line-height: 1.5; color: var(--text-2); overflow-wrap: anywhere; }

.dsearch-list mark {
  background: transparent; color: var(--accent); font-weight: 700;
  border-radius: 2px; text-decoration: underline; text-underline-offset: 2px;
}

.dsearch-empty { padding: 0.9rem 0.8rem; font-size: 0.88rem; color: var(--text-2); }

/* El texto de estado es para lectores de pantalla: la lista ya dice lo mismo a la vista. */
.dsearch-status {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Al saltar a un apartado, un destello para localizarlo en una página larga. */
@keyframes dsearch-flash { from { background: var(--accent-soft); } to { background: transparent; } }
.dsearch-target { animation: dsearch-flash 1.8s ease-out; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .dsearch-target { animation: none; } }
