/* Header alineado visualmente con la Guía de la Ley Europea de IA. */
header.top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 0;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

header.top::after {
  content: "";
  display: block;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #1e40af 0%, #7c3aed 45%, #f59e0b 100%);
}

.top-inner {
  max-width: 1180px;
  height: 72px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand .logo {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  flex: none;
  background: transparent;
  transform: scale(1.06);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  min-width: 0;
}

.brand .name {
  color: #0e2450;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.brand .tagline {
  color: #0e2450;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-top: 2px;
}

.brand .motto {
  color: rgba(14, 36, 80, 0.5);
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-top: 3px;
}

.header-meta {
  text-align: right;
  min-width: 0;
  flex-shrink: 1;
}

.header-title {
  color: #0e2450;
  font-weight: 600;
  font-size: 10px;
  line-height: 1.25;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.term-count {
  display: none;
  margin-top: 4px;
  color: rgba(14, 36, 80, 0.5);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .top-inner {
    height: 76px;
    padding: 0 32px;
  }

  .brand {
    gap: 14px;
  }

  .brand .name {
    font-size: 16.5px;
  }

  .brand .tagline {
    font-size: 11.5px;
  }

  .header-title {
    font-size: 11px;
    letter-spacing: 0.18em;
  }

  .term-count {
    display: block;
  }
}

@media (max-width: 767px) {
  .brand .motto {
    display: none;
  }

  .header-title {
    max-width: 126px;
  }
}


/* Navegación horizontal accesible de categorías en móvil. */
@media (max-width: 640px) {
  .chips {
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    display: flex;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    overflow-x: scroll !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scrollbar-width: thin !important;
    scrollbar-color: #7c3aed rgba(14, 36, 80, 0.10);
    scroll-snap-type: x proximity;
    padding-bottom: 10px !important;
  }

  .chips::-webkit-scrollbar {
    display: block !important;
    height: 5px;
  }

  .chips::-webkit-scrollbar-track {
    background: rgba(14, 36, 80, 0.10);
    border-radius: 999px;
  }

  .chips::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #2563a9, #7c3aed, #ec4899);
    border-radius: 999px;
  }

  .chip {
    flex: 0 0 auto !important;
  }

  .chip:last-child {
    margin-right: 16px;
  }
}


/* Evita que el acceso flotante tape el correo y el contenido del footer. */
.back-to-search {
  bottom: max(92px, calc(env(safe-area-inset-bottom) + 92px)) !important;
}

@media (max-width: 640px) {
  .back-to-search {
    right: 16px !important;
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px)) !important;
  }
}
