/* Concept 12: search the sheet (command bar). */

html.sx-lock { overflow: hidden; }

/* Header triggers */
.sx-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px 7px 12px; margin-left: 4px;
  font: inherit; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
  color: hsl(var(--muted-foreground)); background: transparent; border: 1px solid hsl(var(--border)); cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.sx-btn:hover { color: hsl(var(--foreground)); border-color: hsl(var(--foreground) / 0.5); }
.sx-btn svg, .sx-mob svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.sx-btn kbd { font: inherit; font-size: 10px; letter-spacing: 0.04em; padding: 1px 5px; border: 1px solid currentColor; opacity: 0.6; }
html.mf.mf-top header .sx-btn { color: hsl(0 0% 100% / 0.75); border-color: hsl(0 0% 100% / 0.25); }
html.mf.mf-top header .sx-btn:hover { color: #fff; border-color: hsl(0 0% 100% / 0.6); }

/* Narrower desktops: the nav is already full, so the button drops its label and the links close up. */
@media (max-width: 1439px) {
  .sx-btn-l { display: none; }
  .sx-btn { padding: 7px 8px; gap: 6px; }
  html.mf header nav[class*="lg:flex"] { column-gap: 22px; }
}
/* Small laptops (1024-1199px): seven nav items don't fit beside the logo, so use the menu button there too. */
@media (min-width: 1024px) and (max-width: 1199px) {
  header nav[class*="lg:flex"] { display: none !important; }
  header button.lg\:hidden, header nav.lg\:hidden { display: block !important; }
  header .sx-mob { display: inline-flex !important; }
}

.sx-mob { display: none; margin-left: auto; margin-right: 4px; padding: 8px; color: hsl(var(--foreground)); background: none; border: 0; cursor: pointer; }
.sx-mob svg { width: 20px; height: 20px; }
html.mf.mf-top header .sx-mob { color: #fff; }
@media (max-width: 1199px) { .sx-mob { display: inline-flex; } }

/* Overlay */
.sx { position: fixed; inset: 0; z-index: 90; }
.sx[hidden] { display: none; }
.sx-scrim { position: absolute; inset: 0; background: hsl(222 47% 6% / 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: sx-fade 0.18s ease; }
.sx-panel {
  position: relative; display: flex; flex-direction: column; width: min(720px, calc(100% - 32px)); max-height: min(640px, calc(100vh - 18vh));
  margin: 11vh auto 0; background: hsl(var(--background)); color: hsl(var(--foreground));
  box-shadow: 0 30px 80px -20px hsl(222 47% 6% / 0.55); animation: sx-in 0.2s ease;
}
@keyframes sx-fade { from { opacity: 0; } }
@keyframes sx-in { from { opacity: 0; transform: translateY(-8px) scale(0.99); } }

.sx-bar { display: flex; align-items: center; gap: 14px; padding: 20px 22px; border-bottom: 1px solid hsl(var(--foreground)); }
.sx-glass { flex: none; width: 20px; height: 20px; fill: none; stroke: hsl(var(--muted-foreground)); stroke-width: 1.5; stroke-linecap: round; }
.sx-input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: hsl(var(--foreground));
  /* Sans, not the serif: queries are full of figures ("10m", "2015") and the hosted serif's are old-style. */
  font-family: "DM Sans", system-ui, sans-serif; font-weight: 300; font-size: 24px; letter-spacing: -0.015em;
}
.sx-input::placeholder { color: hsl(var(--muted-foreground) / 0.6); }
.sx-esc { flex: none; padding: 3px 7px; font: inherit; font-size: 10.5px; letter-spacing: 0.08em; color: hsl(var(--muted-foreground)); background: none; border: 1px solid hsl(var(--border)); cursor: pointer; }

.sx-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 12px 22px 0; min-height: 12px; }
.sx-filters:empty { padding: 0; min-height: 0; }
.sx-try-l { margin-right: 4px; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mf-brass, #a88f5c); }
.sx-try, .sx-chip {
  padding: 4px 10px; font: inherit; font-size: 12px; color: hsl(var(--foreground)); background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border)); cursor: pointer;
}
.sx-chip { cursor: default; background: hsl(var(--foreground)); color: hsl(var(--background)); border-color: hsl(var(--foreground)); }
.sx-try:hover { border-color: hsl(var(--foreground) / 0.5); }

.sx-results { list-style: none; margin: 0; padding: 8px 10px 10px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sx-group { padding: 14px 12px 6px; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: hsl(var(--muted-foreground)); }
.sx-group span { margin-left: 6px; color: hsl(var(--foreground)); letter-spacing: 0.04em; }
.sx-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main side" "sub side";
  column-gap: 16px; row-gap: 2px; align-items: center; padding: 10px 12px; cursor: pointer; border-left: 2px solid transparent;
}
.sx-main { grid-area: main; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-sub { grid-area: sub; font-size: 12px; color: hsl(var(--muted-foreground)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-side { grid-area: side; font-size: 13.5px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sx-ref { margin-right: 10px; font-weight: 400; font-size: 10.5px; letter-spacing: 0.14em; color: var(--mf-brass, #a88f5c); }
.sx-item.is-active { background: hsl(var(--secondary)); border-left-color: hsl(var(--foreground)); }
.sx-item.is-source { margin-top: 8px; border-top: 1px solid hsl(var(--border)); }
.sx-item.is-source .sx-main { font-family: var(--mf-serif, serif); font-size: 18px; }
.sx-item.is-lead { margin-top: 4px; border-top: 0; padding: 18px 14px; background: hsl(var(--secondary)); }
.sx-item.is-lead .sx-main { font-size: 22px; white-space: normal; }
.sx-item.is-lead .sx-sub { white-space: normal; }

.sx-foot {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 11px 22px; border-top: 1px solid hsl(var(--border));
  font-size: 11px; color: hsl(var(--muted-foreground));
}
.sx-foot kbd { display: inline-block; min-width: 18px; margin-right: 3px; padding: 0 4px; font: inherit; font-size: 10.5px; text-align: center; border: 1px solid hsl(var(--border)); background: hsl(var(--secondary)); }
.sx-count { margin-left: auto; letter-spacing: 0.04em; }

@media (max-width: 640px) {
  .sx-panel { width: 100%; max-height: 100%; height: 100%; margin: 0; }
  .sx-bar { padding: 16px 16px; }
  .sx-input { font-size: 21px; }
  .sx-filters { padding: 10px 16px 0; }
  .sx-foot span:not(.sx-count) { display: none; }
  .sx-count { margin-left: 0; }
  .sx-item { padding: 11px 10px; }
}
@media (prefers-reduced-motion: reduce) { .sx-scrim, .sx-panel { animation: none; } }
