/* =========================================================
   ST Abogados — buscador de páginas
   Prototipo home. Mantener después de /css/style.css.
   ========================================================= */

:root {
  --st-search-red: #b30000;
  --st-search-black: #111111;
  --st-search-border: #d8d8d8;
  --st-search-muted: #666666;
  --st-search-soft: #f5f5f5;
}


/* =========================================================
   BOTÓN DE LUPA EN LA NAVBAR
   ========================================================= */

.st-search-trigger {
  -webkit-tap-highlight-color: transparent;
  appearance: none;

  width: 44px;
  height: 40px;

  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);

  background: transparent;
  color: rgba(255, 255, 255, 0.94);

  cursor: pointer;
  line-height: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.st-search-trigger svg {
  display: block;
}

/* Hover con mouse: siempre debe iluminar */
.st-search-trigger:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

/* Focus accesible sólo para teclado */
.st-search-trigger:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

/*
  Después de un clic con mouse, quitar el highlight
  SOLO cuando el puntero ya no está encima.
*/
.st-search-trigger:focus:not(:focus-visible):not(:hover) {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  transform: none;
}

.st-search-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
}

@media (min-width: 992px) {
  .st-search-trigger {
    margin-top: -8px;
  }
}


/* =========================================================
   MOBILE: LUPA + HAMBURGUESA
   ========================================================= */

.st-nav-mobile-actions {
  margin-left: auto;

  display: flex;
  align-items: center;
  gap: 8px;

  flex: 0 0 auto;
}

.st-nav-mobile-actions .navbar-toggler {
  width: 40px;
  height: 40px;

  margin: 0 !important;
  padding: 0.35rem 0.45rem;

  flex: 0 0 auto;
}

@media (max-width: 991.98px) {
  .st-nav-mobile-actions .st-search-trigger {
    width: 40px;
    height: 40px;

    border: 0;
    border-radius: 0.375rem;

    background: transparent;
    color: rgba(255, 255, 255, 0.94);
  }

  .st-nav-mobile-actions .st-search-trigger:hover,
  .st-nav-mobile-actions .st-search-trigger:focus-visible {
    background: rgba(255, 255, 255, 0.07);
    transform: none;
  }

  .st-nav-mobile-actions .st-search-trigger:focus:not(:focus-visible):not(:hover) {
    background: transparent;
    box-shadow: none;
    transform: none;
  }
}
@media (max-width: 358px) {
  .st-nav-mobile-actions {
    gap: 5px;
  }

  .st-nav-mobile-actions .st-search-trigger,
  .st-nav-mobile-actions .navbar-toggler {
    width: 38px;
    height: 38px;
  }
}


/* =========================================================
   MODAL
   ========================================================= */

.st-search-modal .modal-content {
  overflow: hidden;

  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 18px;

  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

.st-search-modal .modal-header {
  padding: 1.15rem 1.35rem;

  color: #ffffff;
  background: var(--st-search-black);
}

.st-search-modal .modal-title {
  margin: 0;

  font-family: "Baskervville SC", serif;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.st-search-modal .st-search-subtitle {
  margin: 0.22rem 0 0;

  color: rgba(255, 255, 255, 0.72);

  font-size: 0.9rem;
  line-height: 1.35;
}

.st-search-modal .modal-body {
  padding: 1.25rem 1.35rem 1.35rem;

  background: #ffffff;
}


/* =========================================================
   CAJA DE BÚSQUEDA
   ========================================================= */

.st-search-box {
  position: relative;

  display: flex;
  align-items: center;
}


/*
   Lupa y X usan exactamente el mismo eje vertical.
   No dependen del baseline de la fuente ni del SVG.
*/
.st-search-box-icon,
.st-search-clear {
  position: absolute;
  top: 50%;

  margin: 0;

  transform: translateY(-50%);
}


/* Lupa */

.st-search-box-icon {
  left: 1rem;
  z-index: 2;

  width: 24px;
  height: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  color: #444444;

  line-height: 1;
  pointer-events: none;
}

.st-search-box-icon svg {
  display: block;

  width: 21px;
  height: 21px;

  max-width: none;
}


/* Input */

.st-search-input {
  width: 100%;
  min-height: 58px;
margin: 0 !important;
  /*
     Aire reservado a ambos iconos.
  */
  padding:
    0.8rem
    3.5rem
    0.8rem
    3.25rem;

  border: 2px solid var(--st-search-border);
  border-radius: 13px;

  color: #111111;
  background: #ffffff;

  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

  font-size: 1.05rem;

  outline: none;

  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.st-search-input:focus {
  border-color: var(--st-search-red);

  box-shadow: 0 0 0 4px rgba(179, 0, 0, 0.11);
}

.st-search-input::-webkit-search-cancel-button {
  display: none;
}


/* Botón X */

.st-search-clear {
  position: absolute;

  top: 50%;
  right: 0.65rem;

  width: 38px;
  height: 38px;

  margin: 0;
  padding: 0;

  border: 0;
  border-radius: 50%;

  color: #333333;
  background: transparent;

  cursor: pointer;

  transform: translateY(-50%);

  /*
    Ocultamos visualmente el carácter ×.
    El aria-label sigue intacto para accesibilidad.
  */
  font-size: 0;
}

.st-search-clear::before,
.st-search-clear::after {
  content: "";

  position: absolute;
  top: 50%;
  left: 50%;

  width: 16px;
  height: 2px;

  border-radius: 999px;

  background: currentColor;
}

.st-search-clear::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.st-search-clear::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.st-search-clear[hidden] {
  display: none !important;
}

.st-search-clear:hover,
.st-search-clear:focus-visible {
  background: #eeeeee;
  outline: none;
}


/* =========================================================
   ESTADO / INFORMACIÓN INICIAL
   ========================================================= */

.st-search-status {
  min-height: 1.35rem;

  margin: 0.55rem 0 0;

  color: var(--st-search-muted);

  font-size: 0.86rem;
}

.st-search-initial {
  padding-top: 0.25rem;
}

.st-search-initial-title {
  margin: 0 0 0.7rem;

  color: #444444;

  font-size: 0.92rem;
  font-weight: 700;
}


/* =========================================================
   CHIPS / TEMAS FRECUENTES
   ========================================================= */

.st-search-chips {
  display: flex;
  flex-wrap: wrap;

  gap: 0.5rem;
}

.st-search-chip {
  padding: 0.47rem 0.72rem;

  border: 1px solid #d2d2d2;
  border-radius: 999px;

  color: #222222;
  background: #ffffff;

  font-size: 0.86rem;
  line-height: 1.2;

  cursor: pointer;

  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.st-search-chip:hover,
.st-search-chip:focus-visible {
  border-color: var(--st-search-red);
  background: #faf3f3;

  outline: none;
}


/* =========================================================
   RESULTADOS
   ========================================================= */

.st-search-results {
  display: grid;

  gap: 0.6rem;

  max-height: min(58vh, 610px);

  overflow-y: auto;
  overscroll-behavior: contain;

  padding: 0.1rem 0.12rem 0.15rem 0;
}

.st-search-result {
  position: relative;

  display: flex;
  flex-direction: column;

  gap: 0.3rem;

  min-width: 0;

  padding: 0.82rem 3rem 0.86rem 0.95rem;

  border: 1px solid #dedede;
  border-left: 4px solid transparent;
  border-radius: 11px;

  color: #161616;
  background: #ffffff;

  text-decoration: none;

  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.st-search-result:hover,
.st-search-result:focus-visible {
  border-color: #c8c8c8;
  border-left-color: var(--st-search-red);

  color: #111111;
  background: var(--st-search-soft);

  outline: none;

  transform: translateY(-1px);
}

.st-search-result-top {
  display: flex;
  align-items: center;

  gap: 0.55rem;

  min-width: 0;
}

.st-search-result-section {
  flex: 0 0 auto;

  color: var(--st-search-red);

  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.st-search-result-path {
  min-width: 0;

  overflow: hidden;

  color: #858585;

  font-size: 0.73rem;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-search-result-title {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

  font-size: 1rem;
  font-weight: 750;
  line-height: 1.3;
}

.st-search-result-description {
  color: #555555;

  font-size: 0.87rem;
  line-height: 1.42;
}

.st-search-result-arrow {
  position: absolute;

  top: 50%;
  right: 1rem;

  color: #777777;

  font-size: 1.25rem;

  transform: translateY(-50%);
}


/* =========================================================
   SIN RESULTADOS / ERROR
   ========================================================= */

.st-search-empty,
.st-search-error {
  padding: 1rem;

  border: 1px solid #dddddd;
  border-radius: 11px;

  background: #f7f7f7;
}

.st-search-empty-title,
.st-search-error-title {
  margin: 0 0 0.35rem;

  color: #111111;

  font-weight: 750;
}

.st-search-empty p:not(.st-search-empty-title),
.st-search-error p:not(.st-search-error-title) {
  margin: 0 0 0.85rem;

  color: #555555;

  font-size: 0.9rem;
}

.st-search-footer-note {
  margin: 0.9rem 0 0;

  color: #777777;

  font-size: 0.76rem;
  line-height: 1.4;
}


/* =========================================================
   LOADER
   Visible sólo mientras se prepara el índice
   ========================================================= */

.st-search-modal.is-loading .st-search-box::after {
  content: "";

  position: absolute;

  top: 50%;
  right: 1.05rem;

  width: 20px;
  height: 20px;

  border: 2px solid #cccccc;
  border-top-color: var(--st-search-red);
  border-radius: 50%;

  transform: translateY(-50%);

  animation: st-search-spin-centered 0.7s linear infinite;
}

.st-search-modal.is-loading .st-search-clear {
  visibility: hidden;
}

@keyframes st-search-spin-centered {
  from {
    transform: translateY(-50%) rotate(0deg);
  }

  to {
    transform: translateY(-50%) rotate(360deg);
  }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 575.98px) {
  .st-search-modal .modal-header {
    padding:
      max(1rem, env(safe-area-inset-top))
      1rem
      0.95rem;
  }

  .st-search-modal .modal-body {
    padding: 1rem;
  }

  .st-search-modal .modal-content {
    border-radius: 0;
  }

  .st-search-results {
    max-height: none;
  }

  .st-search-result-path {
    display: none;
  }

  .st-search-result-description {
    display: -webkit-box;

    overflow: hidden;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}


/* =========================================================
   ACCESIBILIDAD — REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .st-search-trigger,
  .st-search-input,
  .st-search-chip,
  .st-search-result {
    transition: none !important;
  }

  .st-search-modal.is-loading .st-search-box::after {
    animation-duration: 1.5s;
  }
}