/* Search result cards, filters, sidebar, and people results.
   Loaded immediately after style.css to preserve the original cascade order. */

body.view-search #view-search .search-surface #searchResults>.post {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  border: 0;
  border-radius: 18px;
  box-shadow: none;
  padding: 14px 26px 0;
  transition: background-color 60ms linear;
}

body.view-search #view-search .search-surface #searchResults>.post::after {
  left: 26px;
  right: 26px;
}

body.view-search #view-search .search-surface #searchResults>.post:hover {
  background: #F4F6F8;
  box-shadow: none;
}

body.view-search #view-search .search-surface #searchResults>.post .p-head {
  margin-bottom: 8px;
}

body.view-search #view-search .search-surface #searchResults>.post .p-user {
  gap: 7px;
  align-items: center;
}

body.view-search #view-search .search-surface #searchResults>.post .avatar {
  width: 26px;
  height: 26px;
}

body.view-search #view-search .search-surface #searchResults>.post .who {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  flex-wrap: wrap;
  line-height: 1.2;
}

body.view-search #view-search .search-surface #searchResults>.post .who .name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: #0F1A1C;
}

body.view-search #view-search .search-surface #searchResults>.post .meta-line {
  font-size: 12px;
  font-weight: 400;
  gap: 5px;
  margin-top: 0;
  color: #576F76;
  line-height: 1.2;
}

body.view-search #view-search .search-surface #searchResults>.post .title {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: 0;
  color: #101214;
  margin: 0 0 8px 0 !important;
}

body.view-search #view-search .search-surface #searchResults>.post .desc {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 1.48;
  color: #1f2933;
  margin: 0 0 12px 0 !important;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.view-search #view-search .search-surface #searchResults>.post[data-has-media="true"] .desc {
  display: none;
}

body.view-search #view-search .search-surface #searchResults>.post .post-foot {
  justify-content: flex-start !important;
  gap: 12px;
  margin-left: -26px;
  margin-right: -26px;
  padding-left: 26px;
  padding-right: 26px;
}

body.view-search #view-search .search-surface #searchResults>.post .post-foot>div:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.view-search #view-search .search-surface #searchResults>.post .posts-card-actions {
  margin-left: auto;
}

body.view-search #view-search .search-surface #searchResults>.post .posts-card-actions--full {
  gap: 0;
}

/* Like / Views / Share / Comments styling lives in the single-source
   `.post-foot` block in posts-card.css — do not re-add per-surface copies. */

body.view-search #view-search .search-surface #searchResults>.post .posts-meta-chip,
body.view-search #view-search .search-surface #searchResults>.post .posts-recommendation-chip {
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}

body.view-search #view-search .search-surface #searchResults>.post .posts-recommendation-chip {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.12);
}

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

/* Sidebar Widget Styles */
/* Back to previous page — the nav rail is hidden on Search, so this is the
   return affordance in the left column. */
.search-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
  margin: 0 0 10px -4px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-back-btn:hover {
  background: #F1F5F9;
  color: var(--text);
}

/* Desktop: the top-bar search is the single search entry, so the in-page box
   is hidden (results still render below). Mobile web (<=720px): the top-bar
   search is hidden there, and this in-page box IS the full-page search sheet
   input (back button + focused field), so it must stay visible. */
@media (min-width: 721px) {
  #view-search .search-head {
    display: none;
  }

  /* The mobile filter row used to sit INSIDE .search-head, so hiding the head
     hid it too. It is now a sibling (see view.html — sticky needs it outside the
     bar), so it needs its own desktop hide. !important counters the existing
     `@media (max-width: 900px) { .mobile-filters { display: flex !important } }`
     rule, which otherwise shows this row between 721px and 900px alongside the
     desktop sidebar filters (same override-policy interop case as the
     entry/suggest hide above). */
  #view-search .search-mobile-filters {
    display: none !important;
  }
}

.search-sidebar-widget {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
}

.widget-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px 0;
}

.widget-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

/* Sidebar Specific Overrides */
.search-sidebar-widget .filter-input {
  width: 100%;
}

.search-sidebar-widget .date-picker-wrapper {
  width: 100%;
}

.search-sidebar-widget .date-picker-trigger {
  width: 100%;
  justify-content: space-between;
}

.search-sidebar-dynamic-filters {
  display: none;
  flex-direction: column;
  gap: 12px;
}

/* Sidebar Filters Visibility (moved from global style.css) */
.search-filters-sidebar {
  display: none;
}

body.view-search .search-filters-sidebar {
  display: block;
}

body.view-search .quick-links-widget {
  display: none;
}

/* Mobile Filters (moved from global style.css) */
.mobile-filters {
  display: none !important;
}

@media (max-width: 900px) {
  .mobile-filters {
    display: flex !important;
  }

  .search-surface {
    max-width: 100%;
  }

  .search-head {
    margin-bottom: 10px;
  }

  #view-search .input {
    /* 44px = the standard mobile tap target and close to Reddit/Google's search
       field. At the old 50px the app bar came to 71px tall, well above their
       56-60px. Must stay equal to .feed-home-search .input (feed/style.css). */
    min-height: 44px;
    /* Match the Home bar's Reddit-style pill shape. */
    border-radius: 999px;
  }

  body.view-search #view-search .search-surface #searchResults>.post {
    padding: 16px 16px 0;
  }

  body.view-search #view-search .search-surface #searchResults>.post::after {
    left: 16px;
    right: 16px;
  }

  body.view-search #view-search .search-surface #searchResults>.post .p-head {
    margin-bottom: 7px;
  }

  body.view-search #view-search .search-surface #searchResults>.post .p-user {
    gap: 7px;
    align-items: flex-start;
  }

  body.view-search #view-search .search-surface #searchResults>.post .who {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2px;
  }

  body.view-search #view-search .search-surface #searchResults>.post .who .name {
    font-size: 12px;
  }

  body.view-search #view-search .search-surface #searchResults>.post .meta-line {
    font-size: 12px;
    line-height: 1.4;
  }

  body.view-search #view-search .search-surface #searchResults>.post .title {
    font-size: 16.5px;
    font-weight: 600;
    line-height: 1.32;
  }

  body.view-search #view-search .search-surface #searchResults>.post .desc {
    font-size: 14.5px;
    line-height: 1.48;
    -webkit-line-clamp: 2;
  }

  body.view-search #view-search .search-surface #searchResults>.post .post-foot {
    gap: 8px;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Search view input needs room for clear button */
#view-search .input {
  padding-right: 40px;
}

/* Clear button for search input */
.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
}

.search-clear-btn:hover {
  background: #f1f5f9;
  color: #334155;
}

.search-clear-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

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

@media (prefers-reduced-motion: reduce) {
  .search-results-spinner {
    animation: none;
  }
}

/* Match the refined home-feed card rhythm for search results only. */
body.view-search #view-search .search-surface #searchResults>.post .title {
  margin-bottom: 6px !important;
}

body.view-search #view-search .search-surface #searchResults>.post .posts-card-desc-preview {
  display: -webkit-box !important;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 10px 0 !important;
  color: #0F1A1C;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.42;
  /* Keep the author's line breaks in the clamped long-post preview (tweet-style),
     matching the home feed. */
  white-space: pre-wrap;
}

body.view-search #view-search .search-surface #searchResults>.post .post-foot {
  margin-top: 8px !important;
  padding-top: 2px !important;
}

body.view-search #view-search .search-surface #searchResults>.post:hover {
  background: #F8FAFC !important;
  box-shadow: none !important;
}

@media (max-width: 900px) {
  body.view-search #view-search .search-surface #searchResults>.post .title {
    margin-bottom: 5px !important;
  }

  body.view-search #view-search .search-surface #searchResults>.post .posts-card-desc-preview {
    -webkit-line-clamp: 2;
    margin-bottom: 8px !important;
    /* 14px, not 13px: 13px body copy under a 16.5px title reads thin and faint on
       a phone. Reddit and Google both sit at ~14px for result preview text. The
       colour here is already near-black (#0F1A1C above), so size was the gap. */
    font-size: 14px;
    line-height: 1.45;
  }

  body.view-search #view-search .search-surface #searchResults>.post .post-foot {
    margin-top: 6px !important;
    padding-top: 2px !important;
  }
}

/* People results section (profiles), shown above post results. */
.search-people {
  margin: 0 0 18px;
}

.search-people[hidden] {
  display: none;
}

.search-people-heading {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
}

.search-people-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.search-person-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.search-person-card:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.search-person-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
}

.search-person-avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary, #0ba8d2);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.search-person-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.search-person-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
  color: var(--text, #0f172a);
}

.search-person-handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--muted, #64748b);
}

@media (max-width: 900px) {
  .search-people-list {
    grid-template-columns: 1fr;
  }
}
