/*
 * Search -- the pieces shared by the homepage Search tab (home_search.css) and
 * the results page (search_results.css): design tokens, the two motion
 * primitives, and the person / mind / expression cards.
 *
 * Ported from the designer's prototype (styles.css) with its class names kept
 * byte-identical, like home_hero.css -- see the note at the top of that file for
 * why this is plain CSS and not Tailwind utilities.
 *
 * Do not rely on this file loading before or after its siblings: every
 * stylesheet in this directory is concatenated by `stylesheet_link_tag :app`,
 * so a rule here must win (or lose) on specificity, never on order. Anything a
 * sibling specialises uses a more specific selector.
 */

/* ---------------------------------------------------------------- tokens ---
 * home_hero.css scopes the prototype's colour tokens to .home-hero-root; the
 * results page is not inside it, so it declares the same set on its own root.
 * The motion tokens did not exist in the app at all -- and an undefined var()
 * inside a `transition` shorthand invalidates the whole declaration, so the
 * animation silently disappears instead of falling back.
 */
.search-results {
  --text-primary: #1c1917;
  --text-secondary: #57534d;
  --text-tertiary: #79716b;
  --text-quaternary: #a6a09b;
  --surface-subtle: #f3f3f2;
  --border: #f3f3f2;
  --border-secondary: #e7e5e4;
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --tabs-dur: 250ms;
}

.home-hero-root,
.search-results {
  --tabs-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --modal-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --resize-dur: 300ms;
  --resize-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dropdown-open-dur: 250ms;
  --dropdown-close-dur: 150ms;
  --dropdown-pre-scale: 0.97;
  --dropdown-closing-scale: 0.99;
  --dropdown-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* The same Inter the hero uses, for the search chrome and the cards below. NOT
 * applied to the reused Swizzel / learning-path cards: those must look the same
 * here as on Discover. */
.search-mind-card,
.search-person-card {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
}

/* ------------------------------------------------------ motion primitives ---
 * .t-resize: a container whose height JS pins and releases, so the page below
 * glides rather than jumps when the content inside changes size.
 */
.t-resize {
  transition:
    width var(--resize-dur) var(--resize-ease),
    height var(--resize-dur) var(--resize-ease);
  will-change: width, height;
}

/* .t-dropdown: a menu that scales in from its origin. Add `.is-open` to show;
 * to hide, swap it for `.is-closing` and remove that after --dropdown-close-dur.
 * Used by the home suggestions dropdown and the results page's sort menu. */
.t-dropdown {
  transform-origin: top left;
  transform: scale(var(--dropdown-pre-scale));
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--dropdown-open-dur) var(--dropdown-ease),
    opacity var(--dropdown-open-dur) var(--dropdown-ease);
  will-change: transform, opacity;
}

.t-dropdown[data-origin="top-right"] { transform-origin: top right; }
.t-dropdown[data-origin="top-center"] { transform-origin: top center; }
.t-dropdown[data-origin="bottom-left"] { transform-origin: bottom left; }
.t-dropdown[data-origin="bottom-center"] { transform-origin: bottom center; }
.t-dropdown[data-origin="bottom-right"] { transform-origin: bottom right; }

.t-dropdown.is-open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.t-dropdown.is-closing {
  transform: scale(var(--dropdown-closing-scale));
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--dropdown-close-dur) var(--dropdown-ease),
    opacity var(--dropdown-close-dur) var(--dropdown-ease);
}

/* ---------------------------------------------------------------- avatar ---
 * One letter on grey when a person has no picture (search_avatar). The 20px
 * variant sits in a learning path's byline; 40px is a person row / card.
 */
.search-avatar {
  display: block;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #e7e5e4;
  object-fit: cover;
}

.search-avatar--20 { width: 20px; height: 20px; }
.search-avatar--40 { width: 40px; height: 40px; }

.search-avatar--initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary, #79716b);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 500;
  user-select: none;
}

.search-avatar--40.search-avatar--initial { font-size: 16px; line-height: 24px; }
.search-avatar--20.search-avatar--initial { font-size: 11px; line-height: 20px; }

/* ------------------------------------------------- mind / expression card ---
 * A flat wash of the orb's colour at 5% (8% on hover) behind a 36px orb, a title
 * and three lines of description. The wash and the orb get the same inline
 * --orb-* properties; the wash only reads --orb-base.
 */
.search-mind-card {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  padding: 24px;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.search-mind-card-wash {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--orb-base);
  opacity: 0.05;
  pointer-events: none;
  transition: opacity 180ms var(--modal-ease, cubic-bezier(0.22, 1, 0.36, 1));
}

.search-mind-card:hover .search-mind-card-wash { opacity: 0.08; }

/* Expressions all share one warm grey, so they get a flat grey card instead of a
 * tint of it. More specific than the generic hover above (4 selectors' worth vs
 * 3), so it wins without depending on source order. */
.search-mind-card[data-kind="expression"] .search-mind-card-wash {
  background: #fafaf9;
  opacity: 1;
}

.search-mind-card[data-kind="expression"]:hover .search-mind-card-wash {
  background: #f3f3f2;
  opacity: 1;
}

.search-mind-card-orb,
.search-mind-card-copy {
  position: relative;
  z-index: 1;
}

.search-mind-card-orb {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
}

/* The orbs spin elsewhere; a grid of 24 spinning blurred conic-gradients is a
 * lot of paint for something you are scanning, so these hold still. */
.search-mind-card-orb::before { animation-play-state: paused; }

.search-mind-card-copy {
  display: flex;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
}

.search-mind-card-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.search-mind-card-copy strong {
  color: var(--text-primary, #1c1917);
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  letter-spacing: -0.2px;
}

.search-mind-card-desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-secondary, #57534d);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: -0.14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* "Popular Minds" only. Pushed to the bottom so the lines line up across a row
 * whose descriptions run to different lengths. */
.search-mind-card-category {
  margin-top: auto;
  overflow: hidden;
  color: var(--text-tertiary, #79716b);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: -0.14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-mind-card:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgb(0 147 255 / 30%);
}

/* --------------------------------------------------------- person card ---
 * White, hairline border, avatar / name / "N Swizzels" / bio, and a full-width
 * "View profile" button pinned to the bottom so a row of cards lines up.
 */
.search-person-card {
  display: flex;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--border-secondary, #e7e5e4);
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 180ms ease-out;
}

.search-person-card:hover { background: #fafaf9; }

.search-person-body {
  display: flex;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.search-person-avatar {
  display: block;
  border-radius: 50%;
  box-shadow:
    0 4px 6px -4px rgb(0 0 0 / 8%),
    0 8px 16px -3px rgb(0 0 0 / 4%);
}

.search-person-top {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
}

.search-person-identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.search-person-identity strong {
  overflow: hidden;
  color: var(--text-primary, #1c1917);
  font-size: 18px;
  font-weight: 600;
  line-height: 26px;
  letter-spacing: -0.18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-person-count {
  overflow: hidden;
  color: var(--text-secondary, #57534d);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: -0.14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-person-bio {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-secondary, #57534d);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: -0.14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.search-person-button {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 36px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border-secondary, #e7e5e4);
  border-radius: 10px;
  color: var(--text-primary, #1c1917);
  font-size: 14px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: -0.14px;
  text-align: center;
  transition: background-color 180ms ease-out;
}

.search-person-card:hover .search-person-button,
.search-person-button:hover { background: #fafaf9; }

.search-person-card:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgb(0 147 255 / 30%);
}

/* ------------------------------------------------------------- skeleton ---
 * The grey shimmer shown while the search feed loads. Geometry is set by the
 * caller; this is only the paint.
 */
@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.skeleton {
  pointer-events: none;
  background: linear-gradient(90deg, #f3f3f2 0%, #ebeae8 45%, #f3f3f2 90%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.15s ease-in-out infinite;
  border-radius: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .t-resize,
  .t-dropdown,
  .search-mind-card-wash,
  .search-person-card,
  .search-person-button { transition: none !important; }

  .skeleton {
    animation: none;
    background: #f3f3f2;
  }
}
