/* =====================================================================
   Site search: header search button + panel, instant suggestions, and the
   /search results page (AI overview, knowledge panel, tabs, results).
   Uses the colour and radius variables already defined in style.css.
   ===================================================================== */

.sx-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header: search button ---------- */
.header-tools { display: flex; align-items: center; gap: 10px; }

.search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, color 0.15s ease;
}
.search-toggle:hover,
.search-toggle[aria-expanded="true"] { background: var(--fb-blue); color: var(--white); }

/* ---------- Header: search panel ---------- */
.site-header .search-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  box-shadow: var(--shadow-md);
  border-top: 1px solid rgba(14, 26, 46, 0.06);
}
.site-header .search-panel[hidden] { display: none; }
.site-header .search-panel .container {
  display: block;
  padding-top: 18px;
  padding-bottom: 22px;
}

/* ---------- Search form (header panel + search page) ---------- */
.search-form,
.sx-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 760px;
  background: #fff;
  border: 1.5px solid rgba(27, 46, 79, 0.18);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow-sm);
}
.search-form:focus-within,
.sx-form:focus-within {
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 3px rgba(27, 46, 79, 0.12);
}
.search-form svg,
.sx-form-icon { flex-shrink: 0; color: var(--slate); }
.search-form input,
.sx-form input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  padding: 10px 0;
  -webkit-appearance: none;
  appearance: none;
}
.search-form input::-webkit-search-cancel-button,
.sx-form input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-form .btn,
.sx-form .btn { padding: 11px 22px; }
.sx-form { margin-top: 1.4em; }

/* ---------- Instant suggestions ---------- */
.search-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 70;
  background: #fff;
  border: 1px solid rgba(14, 26, 46, 0.1);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 70vh;
  padding: 6px 0;
}
.search-suggest[hidden] { display: none; }
.sg-label {
  padding: 8px 18px 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--slate);
}
.sg-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  color: var(--ink);
  cursor: pointer;
}
.sg-item:hover,
.sg-item[aria-selected="true"] { background: var(--fb-blue-light); }
.sg-thumb {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: cover;
  background: var(--fb-blue-light);
}
.sg-thumb-round { border-radius: 50%; }
.sg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--fb-blue-light);
  color: var(--fb-blue);
}
.sg-text { flex: 1; min-width: 0; display: block; }
.sg-title,
.sg-sub {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sg-title { font-weight: 700; font-size: 0.95rem; }
.sg-sub { font-size: 0.8rem; color: var(--slate); }
.sg-tag {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--fb-blue);
  background: var(--fb-blue-light);
  padding: 3px 9px;
  border-radius: 999px;
}

/* ---------- Search page ---------- */
.sx-hero { padding-bottom: 28px; }
.sx-section { padding-top: 24px; }
.sx-h2 { font-size: var(--step-1); margin: 8px 0 14px; }

.sx-pop { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 36px; }
.sx-pill {
  display: inline-flex;
  padding: 9px 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--fb-blue);
}
.sx-pill:hover { background: var(--fb-blue); color: var(--white); }

.sx-browse {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.sx-browse-card {
  display: block;
  padding: 18px 20px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.sx-browse-card:hover { box-shadow: var(--shadow-md); }
.sx-browse-card strong { display: block; color: var(--ink); font-size: 1.05rem; }
.sx-browse-card span { display: block; color: var(--slate); font-size: 0.88rem; margin-top: 4px; }

.sx-empty {
  max-width: 560px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px 30px;
}
.sx-empty h2 { font-size: var(--step-2); }
.sx-empty-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.sx-empty-actions .btn:not(.btn-primary) { background: var(--fb-blue-light); color: var(--fb-blue); }

.sx-dym { color: var(--fb-blue); font-weight: 800; text-decoration: underline; }

/* Layout: AI overview on top, knowledge panel on the right. */
.sx-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas:
    "overview panel"
    "results  panel";
  gap: 24px 36px;
  align-items: start;
}
.sx-layout.sx-nopanel {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "overview"
    "results";
}
.sx-overview { grid-area: overview; }
.sx-panel { grid-area: panel; position: sticky; top: 96px; }
.sx-results-wrap { grid-area: results; min-width: 0; }

/* AI overview */
.sx-overview {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(27, 46, 79, 0.1);
  padding: 20px 22px 18px;
}
.sx-overview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sx-overview-head svg {
  box-sizing: content-box;
  padding: 7px;
  border-radius: 50%;
  background: var(--fb-blue);
  color: var(--white);
}
.sx-overview-head h2 { margin: 0; font-size: 1.15rem; }
.sx-overview-body p,
.sx-overview-body li { color: var(--ink); line-height: 1.65; }
.sx-overview-body p { margin: 0 0 0.8em; }
.sx-overview-body ul { margin: 0 0 0.8em; padding-left: 1.2em; }
.sx-overview-body .sx-err { color: var(--slate); }
.sx-loading-text { font-size: 0.85rem; color: var(--slate); margin: 10px 0 0; }

.sx-skel span {
  display: block;
  height: 12px;
  border-radius: 6px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, #ECE3CC 25%, #F6F1E3 50%, #ECE3CC 75%);
  background-size: 200% 100%;
  animation: sx-shimmer 1.4s linear infinite;
}
.sx-skel span:nth-child(2) { width: 92%; }
.sx-skel span:nth-child(3) { width: 64%; }
@keyframes sx-shimmer { to { background-position: -200% 0; } }

.sx-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.sx-sources[hidden] { display: none; }
.sx-sources-label { font-size: 0.8rem; font-weight: 700; color: var(--slate); }
.sx-source {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fb-blue);
  background: var(--fb-blue-light);
  padding: 4px 11px;
  border-radius: 999px;
}
.sx-source:hover { background: var(--fb-blue); color: var(--white); }

/* Follow-up chat */
.sx-chat { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(14, 26, 46, 0.08); }
.sx-chat[hidden] { display: none; }
.sx-chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.sx-bubble {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.55;
}
.sx-bubble p { margin: 0 0 0.6em; }
.sx-bubble p:last-child { margin-bottom: 0; }
.sx-bubble ul { margin: 0 0 0.6em; padding-left: 1.2em; }
.sx-bubble-user { align-self: flex-end; background: var(--fb-blue); color: var(--white); border-bottom-right-radius: 4px; }
.sx-bubble-ai { align-self: flex-start; background: var(--bg); color: var(--ink); border-bottom-left-radius: 4px; }
.sx-bubble-ai p, .sx-bubble-ai li { color: var(--ink); }
.sx-bubble.is-thinking { color: var(--slate); font-style: italic; }
.sx-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sx-chip {
  border: 1px solid rgba(27, 46, 79, 0.22);
  background: #fff;
  color: var(--fb-blue);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
}
.sx-chip:hover { background: var(--fb-blue); color: var(--white); }
.sx-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px 4px 4px 16px;
}
.sx-chat-form:focus-within { box-shadow: 0 0 0 3px rgba(27, 46, 79, 0.15); }
.sx-chat-form input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  padding: 9px 0;
}
.sx-chat-form .btn { padding: 9px 20px; font-size: 0.9rem; }
.sx-chat-form .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.sx-note { font-size: 0.78rem; color: var(--slate); margin: 10px 0 0; }

/* Knowledge panel */
.sx-panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.sx-panel-img { width: 100%; height: 200px; object-fit: cover; background: var(--fb-blue-light); }
.sx-panel-img-person { height: 300px; object-position: center top; }
.sx-panel-body { padding: 18px 22px 24px; }
.sx-panel-body h2 { font-size: 1.5rem; margin: 2px 0 4px; }
.sx-panel-sub { color: var(--fb-blue); font-weight: 700; margin-bottom: 0.8em; }
.sx-facts { margin: 14px 0; display: grid; gap: 10px; }
.sx-facts div { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--bg); font-size: 0.9rem; }
.sx-facts dt { color: var(--slate); }
.sx-facts dd { margin: 0; font-weight: 700; text-align: right; }
.sx-contact { list-style: none; margin: 0 0 14px; padding: 0; font-size: 0.9rem; }
.sx-contact li { padding: 3px 0; }
.sx-contact a { color: var(--fb-blue); font-weight: 700; word-break: break-word; }
.sx-panel-cta { display: flex; justify-content: center; width: 100%; }

/* Result meta + tabs */
.sx-meta { font-size: 0.9rem; color: var(--slate); margin: 0 0 6px; }
.sx-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 12px 0 8px; padding-bottom: 4px; }
.sx-tabs[hidden] { display: none; }
.sx-tab {
  flex-shrink: 0;
  border: 1px solid rgba(27, 46, 79, 0.2);
  background: #fff;
  color: var(--fb-blue);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.sx-tab span { opacity: 0.7; margin-left: 4px; }
.sx-tab.is-active { background: var(--fb-blue); border-color: var(--fb-blue); color: var(--white); }

/* Tab filtering (driven by data-tab on #sxResults) */
.sx-results[data-tab="person"] .sx-group:not([data-type="person"]),
.sx-results[data-tab="project"] .sx-group:not([data-type="project"]),
.sx-results[data-tab="page"] .sx-group:not([data-type="page"]),
.sx-results[data-tab="gallery"] .sx-group:not([data-type="gallery"]) { display: none; }
.sx-results[data-tab="all"] .sx-more { display: none; }
.sx-showall { display: none; }
.sx-results[data-tab="all"] .sx-showall {
  display: inline-flex;
  margin-top: 4px;
  border: none;
  background: var(--fb-blue-light);
  color: var(--fb-blue);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.sx-results[data-tab="all"] .sx-showall:hover { background: var(--fb-blue); color: var(--white); }

/* Result rows */
.sx-group { margin-bottom: 26px; }
.sx-group-title { font-size: 1.1rem; margin: 12px 0 10px; color: var(--ink); }
.sx-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: inherit;
  transition: box-shadow 0.15s ease;
}
.sx-item:hover { box-shadow: var(--shadow-md); }
.sx-item-body { display: block; min-width: 0; }
.sx-item-body > span { display: block; }
.sx-thumb {
  width: 64px; height: 64px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
  background: var(--fb-blue-light);
}
.sx-thumb-round { border-radius: 50%; object-position: center top; }
.sx-thumb-page {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fb-blue);
}
.sx-kind { font-size: 0.75rem; font-weight: 700; color: var(--fb-blue); }
.sx-title { font-weight: 800; font-size: 1.05rem; color: var(--ink); line-height: 1.3; }
.sx-sub { font-size: 0.88rem; color: var(--slate); }
.sx-snippet { font-size: 0.9rem; color: var(--slate); margin-top: 4px; }
.sx-results mark,
.sx-item mark {
  background: #FFE9A8;
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.sx-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}
.sx-photo {
  display: block;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  color: inherit;
}
.sx-photo:hover { box-shadow: var(--shadow-md); }
.sx-photo img { width: 100%; height: 110px; object-fit: cover; }
.sx-photo span { display: block; padding: 8px 10px; font-size: 0.82rem; font-weight: 700; color: var(--ink); }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .sx-layout,
  .sx-layout.sx-nopanel {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .sx-layout { grid-template-areas: "overview" "panel" "results"; }
  .sx-layout.sx-nopanel { grid-template-areas: "overview" "results"; }
  .sx-panel { position: static; }
  .sx-panel-img-person { height: 260px; }
}

@media (max-width: 520px) {
  .search-form,
  .sx-form { padding-left: 14px; }
  .search-form .btn,
  .sx-form .btn { padding: 10px 16px; }
  .sx-overview { padding: 16px 16px 14px; }
  .sg-tag { display: none; }
}
