/**
 * @file
 * RheumNow Discovery Engine – search results page.
 * Design language mirrors the header search modal:
 *   brand blue #1585fe · Poppins/Roboto · white cards · rounded corners.
 */

/* ==========================================================================
   Page wrapper
   ========================================================================== */
.rheumnow-discovery-search {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
  font-family: Poppins, Roboto, sans-serif;
}

/* ==========================================================================
   Page search bar  (mirrors the modal input)
   ========================================================================== */
.discovery-search-bar {
  margin-bottom: 2.5rem;
}

.discovery-search-bar__label {
  display: block;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #1585fe;
  margin-bottom: 14px;
}

.discovery-search-bar__wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid #e2e2e2;
  transition: border-color 0.2s ease;
}

.discovery-search-bar__wrap:focus-within {
  border-color: #1585fe;
}

.discovery-search-bar__icon {
  color: #c0c0c0;
  font-size: 17px;
  flex-shrink: 0;
  transition: color 0.2s;
}

.discovery-search-bar__wrap:focus-within .discovery-search-bar__icon {
  color: #1585fe;
}

.discovery-search-bar__input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 22px;
  font-weight: 300;
  color: #232323;
  padding: 10px 0 12px;
  caret-color: #1585fe;
}

.discovery-search-bar__input::placeholder {
  color: #c8c8c8;
  font-weight: 300;
}

.discovery-search-bar__input::-webkit-search-cancel-button {
  display: none;
}

.discovery-search-bar__submit {
  flex-shrink: 0;
  background: #1585fe;
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  padding: 10px 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, transform 0.12s;
}

.discovery-search-bar__submit:hover {
  background: #0d6fd6;
  transform: scale(1.05);
}

.discovery-search-bar__submit:focus-visible {
  outline: 2px solid #1585fe;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .discovery-search-bar__input {
    font-size: 18px;
  }
}

/* ==========================================================================
   Results meta line  ("42 results for "rheumatoid arthritis"")
   ========================================================================== */
.discovery-results__meta {
  font-family: Poppins, Roboto, sans-serif;
  font-size: 13px;
  color: #888;
  margin: 0 0 1.5rem;
  font-weight: 400;
}

.discovery-results__query {
  color: #232323;
  font-style: normal;
  font-weight: 500;
}

/* ==========================================================================
   AI summary card
   ========================================================================== */
.rheumnow-discovery-search .discovery-summary {
  background: #fff;
  border-radius: 4px;
  border-left: 4px solid #1585fe;
  box-shadow: 0 2px 16px rgba(21, 133, 254, 0.08), 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 1.5rem 1.75rem;
  margin-bottom: 2rem;
  max-height: 300px;
  overflow-y: auto;
  -webkit-mask-image: linear-gradient(to bottom, black 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 82%, transparent 100%);
}

.rheumnow-discovery-search .discovery-summary.is-scrolled-to-end {
  -webkit-mask-image: none;
  mask-image: none;
}

/* Header row: icon + "AI Summary" label */
.discovery-summary__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1rem;
}

.discovery-summary__icon {
  color: #1585fe;
  font-size: 14px;
  flex-shrink: 0;
}

.discovery-summary__heading {
  margin: 0;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #1585fe;
}

.rheumnow-discovery-search .discovery-summary .body {
  font-family: Poppins, Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.65;
  color: #333;
}

.rheumnow-discovery-search .discovery-summary .body ul.discovery-md-ul {
  margin: 0.5rem 0 1rem;
  padding-left: 1.35rem;
}

.rheumnow-discovery-search .discovery-summary .body ul.discovery-md-ul li {
  margin-bottom: 0.35rem;
}

/* Citation badges */
.rheumnow-discovery-search .discovery-summary .body a.discovery-citation-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15em;
  margin-left: 0.2em;
  margin-inline-end: 0.25em;
  padding: 0.08em 0.38em;
  font-size: 0.68em;
  font-weight: 600;
  line-height: 1.2;
  vertical-align: 0.35em;
  text-decoration: none;
  color: #1585fe;
  background: #e8f2ff;
  border: 1px solid #c5dcff;
  border-radius: 999px;
  letter-spacing: -0.02em;
}

.rheumnow-discovery-search .discovery-summary .body a.discovery-citation-badge:hover,
.rheumnow-discovery-search .discovery-summary .body a.discovery-citation-badge:focus {
  background: #d0e8ff;
  border-color: #a0caff;
  color: #0d5fb8;
}

/* ==========================================================================
   Cited-text highlight  (toggled by answer-loader.js)
   ========================================================================== */
.discovery-cited-text {
  border-radius: 2px;
  transition: background 0.1s ease;
}

.discovery-cited-text--active {
  background: rgba(21, 133, 254, 0.10);
  outline: 1px solid rgba(21, 133, 254, 0.22);
  outline-offset: 1px;
}

/* ==========================================================================
   Citation hover card  (injected into <body> by answer-loader.js)
   ========================================================================== */
.discovery-citation-card {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  line-height: 1.45;
  max-width: 300px;
  pointer-events: auto;
}

.discovery-citation-card[hidden] {
  display: none;
}

.discovery-citation-card__label {
  margin: 0 0 0.3rem;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1585fe;
}

.discovery-citation-card__title {
  margin: 0 0 0.45rem;
  font-weight: 600;
  font-size: 13px;
  color: #232323;
  line-height: 1.35;
}

.discovery-citation-card__title a {
  color: inherit;
  text-decoration: none;
}

.discovery-citation-card__title a:hover {
  text-decoration: underline;
  color: #1585fe;
}

.discovery-citation-card__snippet {
  margin: 0;
  font-size: 12px;
  color: #666;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Result cards
   ========================================================================== */
.rheumnow-discovery-search .discovery-results {
  margin-bottom: 2rem;
}

.rheumnow-discovery-search .discovery-hit {
  border-bottom: 1px solid #edf0f4;
  padding: 1.25rem 0;
  transition: background 0.15s ease;
}

.rheumnow-discovery-search .discovery-hit:last-child {
  border-bottom: none;
}

.rheumnow-discovery-search .discovery-hit:hover {
  background: none;
}

/* Two-column layout: thumbnail | content */
.rheumnow-discovery-search .discovery-hit__top {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

/* Left: thumbnail */
.rheumnow-discovery-search .discovery-hit__media {
  flex: 0 0 160px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.rheumnow-discovery-search .discovery-hit__media img {
  width: 160px;
  height: 112px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.rheumnow-discovery-search .discovery-hit__media-expand {
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 8px;
  line-height: 0;
  transition: opacity 0.15s;
}

.rheumnow-discovery-search .discovery-hit__media-expand:hover img,
.rheumnow-discovery-search .discovery-hit__media-expand:focus-visible img {
  opacity: 0.88;
}

.rheumnow-discovery-search .discovery-hit__media-expand:focus-visible {
  outline: 2px solid #1585fe;
  outline-offset: 2px;
}

.rheumnow-discovery-search .discovery-hit__media-link {
  display: block;
  line-height: 0;
  border-radius: 8px;
  overflow: hidden;
  transition: opacity 0.15s;
}

.rheumnow-discovery-search .discovery-hit__media-link:hover img {
  opacity: 0.88;
}

.rheumnow-discovery-search .discovery-hit__media-link:focus-visible {
  outline: 2px solid #1585fe;
  outline-offset: 2px;
}

/* Right: content */
.rheumnow-discovery-search .discovery-hit__meta {
  flex: 1 1 auto;
  min-width: 0;
}

/* Title */
.rheumnow-discovery-search .discovery-hit__title {
  margin: 0.3rem 0 0.2rem;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: #232323;
}

/* Keep old h3 selector too for infinite-scroll-injected cards */
.rheumnow-discovery-search .discovery-hit h3 {
  margin: 0.3rem 0 0.2rem;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: #232323;
}

.rheumnow-discovery-search .discovery-hit__title a,
.rheumnow-discovery-search .discovery-hit h3 a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}

.rheumnow-discovery-search .discovery-hit__title a:hover,
.rheumnow-discovery-search .discovery-hit h3 a:hover {
  color: #1585fe;
}

/* Snippet */
.rheumnow-discovery-search .discovery-hit__snippet {
  margin: 0.45rem 0 0;
  font-size: 13.5px;
  color: #666;
  line-height: 1.6;
  font-weight: 300;
}

.rheumnow-discovery-search .discovery-hit__tweet-content,
.rheumnow-discovery-search .discovery-hit__podcast-summary,
.rheumnow-discovery-search .discovery-hit__article-summary {
  white-space: pre-wrap;
}

/* Tweet article links */
.rheumnow-discovery-search .discovery-hit__tweet-links {
  margin: 0.45rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.rheumnow-discovery-search .discovery-hit__tweet-link {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  font-size: 12px;
  line-height: 1.5;
  color: #8a9199;
}

.rheumnow-discovery-search .discovery-hit__tweet-link .fa-newspaper {
  flex: 0 0 auto;
  margin-top: 0.18em;
  font-size: 10px;
  color: #bbb;
}

.rheumnow-discovery-search .discovery-hit__tweet-link a {
  color: inherit;
  text-decoration: none;
  word-break: break-word;
}

.rheumnow-discovery-search .discovery-hit__tweet-link a:hover {
  color: #1585fe;
  text-decoration: underline;
}

/* ==========================================================================
   Type badges  (pill shape, color-coded)
   ========================================================================== */
.rheumnow-discovery-search .discovery-type-badge {
  display: inline-block;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.28em 0.75em;
  border-radius: 3px;
  border: 1px solid transparent;
  align-self: flex-start;
  margin-bottom: 0.3rem;
  margin-right: 0.5rem;
}

.rheumnow-discovery-search .discovery-type-badge--article {
  background: #eaf7ee;
  color: #2e7d4f;
  border-color: #c5e8d0;
}

.rheumnow-discovery-search .discovery-type-badge--video {
  background: #e8f4fd;
  color: #1a6fa8;
  border-color: #b8d9f2;
}

.rheumnow-discovery-search .discovery-type-badge--podcast {
  background: #f0ebf9;
  color: #6b3fa0;
  border-color: #d5c5ee;
}

.rheumnow-discovery-search .discovery-type-badge--tweet {
  background: #e8f5fe;
  color: #1a8cd8;
  border-color: #b8dff8;
}

.rheumnow-discovery-search .discovery-type-badge--resource {
  background: #fff4e5;
  color: #a05c00;
  border-color: #f0d5a0;
}

/* ==========================================================================
   Byline / meta
   ========================================================================== */
.rheumnow-discovery-search .discovery-hit__byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0.1rem 0 0;
}

.rheumnow-discovery-search .discovery-meta {
  font-family: Poppins, Roboto, sans-serif;
  font-size: 12px;
  color: #888;
}

.rheumnow-discovery-search .discovery-author a {
  color: inherit;
  text-decoration: none;
}

.rheumnow-discovery-search .discovery-author a:hover {
  color: #1585fe;
  text-decoration: underline;
}

.rheumnow-discovery-search .discovery-byline-sep {
  color: #ccc;
  font-size: 12px;
  line-height: 1;
  user-select: none;
}

/* ==========================================================================
   Skeleton loading
   ========================================================================== */
.rheumnow-discovery-search .discovery-summary-skeleton {
  padding: 0.25rem 0;
}

.rheumnow-discovery-search .discovery-skeleton-line {
  height: 0.85rem;
  border-radius: 6px;
  margin-bottom: 0.65rem;
  background: linear-gradient(
    90deg,
    #e8edf5 0%,
    #f2f5fb 40%,
    #e8edf5 80%
  );
  background-size: 200% 100%;
  animation: discovery-skeleton-shimmer 1.3s ease-in-out infinite;
}

.rheumnow-discovery-search .discovery-skeleton-line.wide {
  width: 100%;
}

.rheumnow-discovery-search .discovery-skeleton-line.narrow {
  width: 42%;
  margin-bottom: 0;
}

@keyframes discovery-skeleton-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ==========================================================================
   No-results empty state
   ========================================================================== */
.discovery-no-results {
  text-align: center;
  padding: 3.5rem 2rem;
}

.discovery-no-results__icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f0f6ff;
  border: 1.5px solid #d0e4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 22px;
  color: #1585fe;
}

.discovery-no-results__heading {
  font-family: Poppins, Roboto, sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #232323;
  margin: 0 0 0.5rem;
}

.discovery-no-results__heading em {
  font-style: normal;
  color: #1585fe;
}

.discovery-no-results__tip {
  font-family: Poppins, Roboto, sans-serif;
  font-size: 14px;
  color: #888;
  margin: 0 0 1.25rem;
}

.discovery-no-results__chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.discovery-no-results__chip {
  display: inline-block;
  background: #f0f6ff;
  color: #1585fe;
  border: 1.5px solid #d0e4ff;
  border-radius: 20px;
  padding: 7px 16px;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none !important;
  transition: background 0.16s, color 0.16s, border-color 0.16s, transform 0.1s;
}

.discovery-no-results__chip:hover,
.discovery-no-results__chip:focus-visible {
  background: #1585fe;
  color: #fff !important;
  border-color: #1585fe;
  transform: scale(1.04);
  outline: none;
  text-decoration: none !important;
}

/* ==========================================================================
   Infinite scroll
   ========================================================================== */
.rheumnow-discovery-search .discovery-more-sentinel {
  height: 1px;
}

.rheumnow-discovery-search .discovery-more-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 0;
}

.rheumnow-discovery-search .discovery-more-loading[hidden] {
  display: none;
}

.rheumnow-discovery-search .discovery-more-spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid #e2e8f0;
  border-top-color: #1585fe;
  border-radius: 50%;
  animation: discovery-spin 0.7s linear infinite;
}

@keyframes discovery-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Error banners
   ========================================================================== */
.rheumnow-discovery-search .discovery-error {
  background: #fff3f3;
  border: 1px solid #fbc5c5;
  color: #c0392b;
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  font-family: Poppins, Roboto, sans-serif;
  font-size: 14px;
}

.rheumnow-discovery-search .discovery-error--soft {
  background: #fffbf0;
  border-color: #f5e0a0;
  color: #7a5500;
}

/* ==========================================================================
   Admin debug panel
   ========================================================================== */
.rheumnow-discovery-search details.discovery-debug {
  margin-top: 2.5rem;
  font-size: 0.8rem;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.rheumnow-discovery-search details.discovery-debug summary {
  cursor: pointer;
  font-weight: 600;
  color: #666;
}

.rheumnow-discovery-search details.discovery-debug pre {
  overflow: auto;
  max-height: 320px;
  background: #1a1e28;
  color: #cdd6f4;
  padding: 0.85rem;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
}

.rheumnow-discovery-search pre.discovery-debug-answer {
  margin-top: 0.5rem;
}

/* ==========================================================================
   Tweet image lightbox  (unchanged from original)
   ========================================================================== */
body.discovery-tweet-lightbox-open {
  overflow: hidden;
}

.discovery-tweet-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.discovery-tweet-lightbox[hidden] {
  display: none;
}

.discovery-tweet-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.84);
}

.discovery-tweet-lightbox__panel {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
}

.discovery-tweet-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.discovery-tweet-lightbox__close {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  transform: translateY(-100%);
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color 0.15s;
}

.discovery-tweet-lightbox__close:hover,
.discovery-tweet-lightbox__close:focus-visible {
  color: #ccc;
  outline: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 640px) {
  .rheumnow-discovery-search .discovery-hit__media {
    flex: 0 0 110px;
  }

  .rheumnow-discovery-search .discovery-hit__media img {
    width: 110px;
    height: 78px;
  }

  .rheumnow-discovery-search .discovery-hit__title,
  .rheumnow-discovery-search .discovery-hit h3 {
    font-size: 15px;
  }

  .rheumnow-discovery-search .discovery-summary {
    padding: 1.25rem 1.25rem;
  }
}

@media (max-width: 480px) {
  .rheumnow-discovery-search .discovery-hit__top {
    flex-direction: column;
    gap: 0.75rem;
  }

  .rheumnow-discovery-search .discovery-hit__media {
    flex: none;
    width: 100%;
  }

  .rheumnow-discovery-search .discovery-hit__media img {
    width: 100%;
    height: 180px;
    border-radius: 8px;
  }
}
