/*!
 * search.css v1.8.0
 * Full-site search overlay skin for search.js. The page behind blurs through
 * a frosted scrim; a search bar sits near the top with a results grid below
 * (image + title cards, matched text shown in bold — Ramp-style).
 *
 * Mobile (≤599px): the panel fills the whole viewport (100dvh, safe-area
 * aware) and the results card stretches to the bottom edge, scrolling
 * internally — no frosted gap under the last card.
 *
 * [data-search-source] visibility is intentionally NOT controlled here —
 * it can be an on-page (visible) Collection List that search.js reads from,
 * or a dedicated hidden one. Hide it yourself (Webflow "Hide" / display:none)
 * only if you don't want it visible on the page.
 *
 * Optional: add an element with [data-search-results-label] (e.g. a
 * "Resources" / "Blog" heading) right before [data-search-results] — it's
 * shown only while results are rendered.
 *
 * https://github.com/roicool/sestek
 */

/* CSS-only scroll lock fallback while the overlay is open */
html.search-lock { overflow: hidden; }

/* ── Trigger (icon button, lives anywhere on the page e.g. nav) ──────── */
[data-search-trigger] {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius--lg, 0.75rem);
  background: var(--surface--base, #fff);
  color: var(--color-text--base, #1a1a1a);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

[data-search-trigger] svg {
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
}

[data-search-trigger]:hover {
  border-color: rgba(0, 0, 0, 0.16);
}

[data-search-trigger]:focus-visible {
  outline: 2px solid var(--color-text--accent, #EC008C);
  outline-offset: 2px;
}

[data-search-trigger][aria-expanded="true"] {
  border-color: var(--color-text--accent, #EC008C);
  color: var(--color-text--accent, #EC008C);
}

@media (prefers-reduced-motion: reduce) {
  [data-search-trigger] { transition: none; }
}

/* ── Overlay (frosted scrim over the whole site) ─────────────────── */
[data-search-overlay] {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  padding: var(--spacing--6, 1.5rem) var(--spacing--4, 1rem);
  background: rgba(255, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  backdrop-filter: blur(20px) saturate(1.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

[data-search-overlay].is-open {
  opacity: 1;
  visibility: visible;
}

/* ── Panel ────────────────────────────────────────────────────────── */
[data-search-panel] {
  width: 100%;
  max-width: 48rem;
  margin-top: clamp(1.5rem, 6vw, 4rem);
  display: flex;
  flex-direction: column;
  transform: translateY(-0.75rem);
  transition: transform 0.3s ease;
}

[data-search-overlay].is-open [data-search-panel] {
  transform: translateY(0);
}

/* ── Search bar ───────────────────────────────────────────────────── */
[data-search-bar] {
  display: flex;
  align-items: center;
  gap: var(--spacing--3, 0.75rem);
  padding: var(--spacing--2, 0.5rem);
  padding-left: var(--spacing--6, 1.5rem);
  border-radius: var(--radius--xl, 0.75rem);
  background: var(--surface--base, #fff);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 28px -12px rgba(0, 0, 0, 0.12);
  margin-bottom: var(--spacing--4, 1rem);
}

[data-search-input] {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: var(--text--lg, 1.125rem);
  letter-spacing: -0.01em;
  color: var(--color-text--base, #1a1a1a);
}

[data-search-input]::placeholder {
  color: var(--color-text--muted, rgba(26, 26, 26, 0.45));
}

[data-search-close] {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius--lg, 0.75rem);
  background: transparent;
  color: var(--color-text--muted, rgba(26, 26, 26, 0.45));
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

[data-search-close]:hover {
  background: var(--brand-primary--100, #fde6f3);
  color: var(--color-text--accent, #EC008C);
  transform: scale(1.06);
}

[data-search-close]:focus-visible {
  outline: 2px solid var(--color-text--accent, #EC008C);
  outline-offset: 2px;
}

/* ── Results card — ONE shared background holding the label + grid ──── */
[data-search-results-label] {
  margin: 0;
  font-size: var(--text--sm, 0.875rem);
  font-weight: var(--font-weight--medium, 500);
  letter-spacing: 0.01em;
  color: var(--color-text--muted, rgba(26, 26, 26, 0.45));
}

[data-search-results] {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing--8, 2rem) var(--spacing--6, 1.5rem);
  overflow-y: auto;
  /* Leaves room for the bar + margins above so the panel never overflows
     the viewport; results scroll internally instead. */
  max-height: min(34rem, calc(100vh - 13rem));
  /* Reaching the end of the list must not hand the gesture to the (locked)
     page behind — matters with Lenis stopped + data-lenis-prevent. */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

[data-search-results]::-webkit-scrollbar {
  width: 6px;
}
[data-search-results]::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius--full, 9999px);
}
[data-search-results]::-webkit-scrollbar-track {
  background: transparent;
}

/* The white card surface. The label and the grid each get it, then the
   adjacency rule below stitches them into a single seamless card.
   (The panel's flex gap is cancelled between them so no scrim shows.) */
[data-search-results-label]:not([hidden]),
[data-search-results]:not(:empty) {
  background: var(--surface--base, #fff);
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 8px 28px -14px rgba(0, 0, 0, 0.14);
}
[data-search-results-label]:not([hidden]) {
  padding: var(--spacing--5, 1.25rem) var(--spacing--5, 1.25rem) var(--spacing--4, 1rem);
  border-radius: var(--radius--xl, 0.75rem) var(--radius--xl, 0.75rem) 0 0;
  border-bottom: 0;
}
[data-search-results]:not(:empty) {
  padding: var(--spacing--5, 1.25rem);
  border-radius: var(--radius--xl, 0.75rem);
}
/* when a visible label sits right above the grid, merge them into one card */
[data-search-results-label]:not([hidden]) + [data-search-results]:not(:empty) {
  padding-top: 0;
  border-top: 0;
  border-radius: 0 0 var(--radius--xl, 0.75rem) var(--radius--xl, 0.75rem);
}

[data-search-results]:empty {
  display: none;
}

[data-search-results-label][hidden] {
  display: none;
}

.search__result {
  display: flex;
  flex-direction: column;
  gap: var(--spacing--2, 0.5rem);
  text-decoration: none;
  color: var(--color-text--base, #1a1a1a);
  transition: transform 0.25s ease;
}

.search__result:hover,
.search__result.is-active {
  transform: translateY(-0.2rem);
}

/* Keyboard-highlighted result (↑/↓ navigation) */
.search__result.is-active .search__result-media {
  outline: 2px solid var(--color-text--accent, #EC008C);
  outline-offset: 2px;
}

.search__result-media {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius--xl, 0.75rem);
  overflow: hidden;
  background: var(--surface--muted, #f5f5f6);
}

.search__result-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search__result-title {
  font-size: var(--text--sm, 0.9375rem);
  font-weight: var(--font-weight--medium, 500);
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--color-text--base, #1a1a1a);
}

/* Matched substring — same color, just heavier (Ramp-style), no chip/background */
.search__result-title mark {
  background: none;
  color: inherit;
  font-weight: var(--font-weight--semibold, 600);
  padding: 0;
  border-radius: 0;
}

/* ── Empty state ──────────────────────────────────────────────────── */
[data-search-empty] {
  padding: var(--spacing--8, 2rem) 0;
  text-align: center;
  color: var(--color-text--muted, rgba(26, 26, 26, 0.5));
}

[data-search-empty][hidden] {
  display: none;
}

/* ── Responsive grid ──────────────────────────────────────────────── */
@media (max-width: 991px) {
  [data-search-results] { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile: full-height sheet ────────────────────────────────────── */
@media (max-width: 599px) {
  [data-search-overlay] {
    /* Fixed inset:0 already spans the viewport; the explicit height pins it
       to the *dynamic* viewport on iOS/Android (toolbars showing/hiding)
       and lets the panel below size itself against it. */
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;   /* padding below must not push past 100dvh */
    /* The panel owns the scroll on mobile — the overlay itself never scrolls,
       so a swipe that overshoots the results can't move the scrim. */
    overflow: hidden;
    overscroll-behavior: contain;
    padding: calc(var(--spacing--4, 1rem) + env(safe-area-inset-top, 0px))
             var(--spacing--3, 0.75rem)
             calc(var(--spacing--3, 0.75rem) + env(safe-area-inset-bottom, 0px));
  }
  [data-search-panel] {
    margin-top: 0;
    /* Fill the overlay top-to-bottom; children lay out in a column and the
       results grid takes whatever is left. */
    height: 100%;
    min-height: 0;
  }
  [data-search-bar] {
    flex: 0 0 auto;
    padding-left: var(--spacing--4, 1rem);
  }
  [data-search-results-label] { flex: 0 0 auto; }
  [data-search-results] {
    grid-template-columns: 1fr;
    /* Take the remaining height instead of a fixed cap — the white card
       reaches the bottom edge and scrolls inside. `align-content: start`
       keeps the cards packed at the top when there are only one or two. */
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    align-content: start;
  }
  [data-search-empty] { flex: 0 0 auto; }
  [data-search-input] { font-size: var(--text--lg, 1.125rem); }
}

/* ── Reduced motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  [data-search-overlay],
  [data-search-panel],
  .search__result,
  [data-search-close] {
    transition: none;
  }
}
