/* ==========================================================================
   MACRO REBORN — BUSCADOR GLOBAL
   Vive dentro de la navbar y reutiliza las variables de diseño definidas en
   inicio.css (paleta slate + dorado, tipografías Orbitron/Inter). Este
   archivo SOLO agrega estilos nuevos: no modifica ninguna regla existente.
   ========================================================================== */

.nav-buscador {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}

.buscador-caja {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--clasico-borde);
  border-radius: 999px;
  padding: 9px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.buscador-caja:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.15);
}

.buscador-icono {
  font-size: 14px;
  opacity: 0.8;
  flex-shrink: 0;
  line-height: 1;
}

.buscador-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13.5px;
}

.buscador-input::placeholder {
  color: var(--text-muted);
}

/* ---- Panel de resultados ---- */

.buscador-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 2px solid var(--clasico-borde);
  border-radius: var(--clasico-radio);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  max-height: min(430px, 70vh);
  overflow-y: auto;
  padding: 8px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 500;
}

.buscador-panel.abierto {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.buscador-panel::-webkit-scrollbar {
  width: 8px;
}

.buscador-panel::-webkit-scrollbar-thumb {
  background: var(--bg-panel-alt);
  border-radius: 999px;
}

.buscador-grupo {
  margin-bottom: 6px;
}

.buscador-grupo:last-child {
  margin-bottom: 0;
}

.buscador-grupo-titulo {
  display: block;
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold);
  padding: 8px 10px 4px;
}

.buscador-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.12s ease;
}

.buscador-item:hover,
.buscador-item:focus-visible {
  background: var(--bg-panel-alt);
}

.buscador-item-imagen {
  position: relative; /* FIX: sin esto, las capas del avatar
    (position:absolute, ver avatarMiniaturaHTML() en js/core.js) no
    tenían ningún ancestro posicionado cerca y terminaban ubicándose
    respecto al documento completo: por eso el avatar se veía gigante
    y tapaba el buscador. Con position:relative acá, las capas quedan
    contenidas dentro de esta caja de 38x38, igual que en
    .avatar-mini, .avatar-mini-ranking, etc. */
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel-alt);
  border: 1px solid var(--line);
  font-size: 17px;
}

.buscador-item-imagen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

/* Antes era un círculo (border-radius:50%). Ahora usa el mismo marco
   cuadrado ornamentado con destellos en las esquinas que el resto de
   los avatares del sitio (ver la misma idea en css/perfil.css,
   .avatar-mini). */
.buscador-item-avatar {
  position: relative;
  border-radius: 8px;
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 2px var(--gold-deep);
}

.buscador-item-avatar::before,
.buscador-item-avatar::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle at 35% 35%, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-deep) 100%);
  clip-path: polygon(50% 0%, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0% 50%, 39% 38%);
  filter: drop-shadow(0 0 2px rgba(240, 180, 41, .8));
  pointer-events: none;
  z-index: 2;
}
.buscador-item-avatar::before { top: 1px; left: 1px; }
.buscador-item-avatar::after { bottom: 1px; right: 1px; }

.buscador-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.buscador-item-nombre {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.buscador-item-categoria {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 999px;
  padding: 2px 8px;
  width: fit-content;
}

.buscador-vacio {
  padding: 26px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Resalte temporal al llegar a una noticia desde el buscador */
@keyframes buscadorResaltarNoticia {
  0%   { box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.65); }
  100% { box-shadow: 0 0 0 3px rgba(240, 180, 41, 0); }
}

.noticia-resaltada {
  animation: buscadorResaltarNoticia 2.2s ease;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 900px) {
  .nav-buscador {
    flex: 1 1 100%;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .buscador-panel {
    left: -6px;
    right: -6px;
  }

  .buscador-item-nombre {
    font-size: 13px;
  }
}

/* Evita el zoom automático de Safari/iOS al tocar el buscador (se activa
   cuando un input tiene font-size menor a 16px). Solo aplica en mobile. */
@media (max-width: 768px) {
  .buscador-input {
    font-size: 16px;
  }
}

.buscador-ver-todos { display:block; margin:6px 4px 2px; padding:10px 11px; border-top:1px solid var(--line); color:var(--gold-bright); font-size:12px; font-weight:800; }
.buscador-ver-todos:hover { background:var(--bg-panel-alt); border-radius:8px; }
