/* Spotlight, macOS Tahoe style. The dialog itself is an invisible full-screen layer;
   the glass lives in .sl-bar (capsule) and .sl-card (results). */

dialog.spotlight {
  --sl-bar-fill: rgba(247, 249, 253, .58);
  --sl-kbd: rgba(16, 24, 40, .08);
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; border-radius: 0; overflow: visible;
  background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  color: var(--lg-text); font-family: var(--lg-font);
}
body.dark-desktop dialog.spotlight { --sl-bar-fill: rgba(34, 36, 46, .46); --sl-kbd: rgba(255, 255, 255, .12); }
dialog.spotlight::backdrop { background: rgba(6, 10, 28, .1); -webkit-backdrop-filter: none; backdrop-filter: none; }

.spotlight .sl-stage {
  position: absolute; left: 50%; top: max(72px, 17vh); width: min(680px, calc(100vw - 32px));
  transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.spotlight .sl-stage > * { pointer-events: auto; }

/* ---------- Capsule ---------- */
.spotlight .sl-bar {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 12px 0 20px;
  border-radius: 999px; transform-origin: 50% 0;
}
.spotlight .sl-bar.lg-clear { background: var(--lg-sheen), var(--sl-bar-fill); box-shadow: var(--lg-rim-strong), var(--lg-shadow); }
.spotlight[open] .sl-bar { animation: sl-bar-in .46s var(--lg-spring) both; }
@keyframes sl-bar-in { from { opacity: 0; transform: scale(.96) translateY(-8px); } to { opacity: 1; transform: none; } }

.spotlight .sl-glyph { flex: none; width: 22px; height: 22px; color: var(--lg-text-2); }
.spotlight .sl-bar input {
  flex: 1; min-width: 0; width: auto; height: 100%; min-height: 0; padding: 0; border: 0; outline: 0;
  background: transparent; color: var(--lg-text); font: 400 22px/1.2 var(--lg-font); letter-spacing: -.012em;
  -webkit-appearance: none; appearance: none;
}
.spotlight .sl-bar input::placeholder { color: var(--lg-text-3); }
.spotlight .sl-bar input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.spotlight .sl-bar form { display: contents; }
.spotlight .search-close {
  position: static; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--lg-fill-control); color: var(--lg-text-2);
  font: 400 21px/1 var(--lg-font); cursor: pointer; visibility: hidden; opacity: 0;
  transition: opacity var(--lg-fast) var(--lg-ease), transform var(--lg-fast) var(--lg-ease);
}
.spotlight.has-query .search-close { visibility: visible; opacity: 1; }
.spotlight .search-close:hover { background: var(--lg-hover); }
.spotlight .search-close:active { transform: scale(.92); }

/* ---------- Results card ---------- */
.spotlight .sl-card {
  height: 0; overflow: hidden; border-radius: 28px; opacity: 0; transform: translateY(-8px) scale(.985); transform-origin: 50% 0;
  transition: height .42s var(--lg-ease), opacity .24s ease, transform .5s var(--lg-spring);
}
.spotlight .sl-card.is-shown { opacity: 1; transform: none; }
.spotlight .sl-inner { padding: 10px 10px 8px; }

.sl-chips { display: flex; gap: 6px; padding: 0 2px 8px; overflow-x: auto; scrollbar-width: none; }
.sl-chips::-webkit-scrollbar { display: none; }
.spotlight .sl-chip {
  flex: none; height: 28px; padding: 0 13px; border-radius: 999px; font: 500 12.5px/1 var(--lg-font);
  white-space: nowrap; cursor: pointer;
}

.sl-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
#spotlight #spotlight-results {
  padding: 0; max-height: min(430px, 52vh); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--lg-separator) transparent;
}
.sl-head { padding: 8px 10px 4px; font: 600 11.5px/1.2 var(--lg-font); color: var(--lg-text-3); }
.sl-empty { margin: 0; padding: 34px 12px; text-align: center; color: var(--lg-text-2); font-size: 13px; }

/* ---------- Rows ---------- */
.sl-row {
  display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 7px 10px; border-radius: 16px;
  color: var(--lg-text); cursor: default; user-select: none; -webkit-user-select: none;
}
.sl-row.is-selected { background: var(--lg-accent); color: #fff; box-shadow: 0 2px 10px rgba(10, 132, 255, .32), inset 0 1px 0 rgba(255, 255, 255, .3); }
.sl-row:focus-visible { outline-offset: -2px; }
.sl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sl-title, .sl-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-title { font: 500 14px/1.25 var(--lg-font); }
.sl-title b { font-weight: 700; }
.sl-sub { font: 400 12px/1.25 var(--lg-font); color: var(--lg-text-2); }
.sl-kind { flex: none; font: 400 11.5px/1 var(--lg-font); color: var(--lg-text-3); }
.sl-row.is-selected .sl-sub, .sl-row.is-selected .sl-kind { color: rgba(255, 255, 255, .8); }
.sl-row.is-top { min-height: 66px; padding: 10px 12px; border-radius: 20px; }
.sl-row.is-top .sl-title { font-size: 17px; font-weight: 600; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sl-row.is-top .sl-title b { font-weight: 800; }
.sl-row.is-top .sl-sub { font-size: 12.5px; }
.sl-row.is-top .sl-ico { --s: 44px; }

.sl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; padding-top: 2px; }
.sl-row.is-tile { flex-direction: column; justify-content: flex-start; gap: 7px; min-height: 0; padding: 10px 4px 8px; text-align: center; }
.sl-row.is-tile .sl-ico { --s: 52px; }
.sl-row.is-tile .sl-text { align-items: center; width: 100%; }
.sl-row.is-tile .sl-title { font-size: 11.5px; white-space: normal; text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sl-row.is-tile .sl-sub, .sl-row.is-tile .sl-kind { display: none; }

/* ---------- Icons ---------- */
.sl-ico {
  --s: 32px; position: relative; flex: none; width: var(--s); height: var(--s); border-radius: calc(var(--s) * .27);
  display: grid; place-items: center; overflow: hidden; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .14), 0 1px 2px rgba(0, 0, 0, .12);
}
.sl-ico.is-xl { --s: 84px; }
.sl-ico svg { width: 58%; height: 58%; }
.sl-ico img { width: 62%; height: 62%; object-fit: contain; }
.sl-ico.is-photo img, .sl-ico.is-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.sl-initials { font: 700 calc(var(--s) * .4)/1 var(--lg-font); letter-spacing: -.02em; }
.sl-mask { display: block; width: 56%; height: 56%; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }

/* ---------- Preview ---------- */
.sl-preview { display: none; }
.sl-preview { flex-direction: column; gap: 6px; padding: 12px; border-radius: 18px; overflow: hidden; background: var(--lg-fill-control); box-shadow: inset 0 0 0 .5px var(--lg-separator); }
.sl-pv-media { aspect-ratio: 4 / 3; margin-bottom: 4px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: rgba(120, 130, 150, .14); }
.sl-pv-media img { width: 100%; height: 100%; object-fit: contain; }
.sl-pv-media.is-cover img { object-fit: cover; object-position: top; }
.sl-pv-title { margin: 0; font: 600 15px/1.25 var(--lg-font); }
.sl-pv-meta { margin: 0; font: 400 12px/1.3 var(--lg-font); color: var(--lg-text-2); }
.sl-pv-lead { margin: 4px 0 0; font: 500 12.5px/1.3 var(--lg-font); }
.sl-pv-copy { margin: 0; font: 400 12px/1.4 var(--lg-font); color: var(--lg-text-2); display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.sl-pv-action { margin: auto 0 0; padding-top: 8px; font: 400 11.5px/1 var(--lg-font); color: var(--lg-text-3); }
@media (min-width: 900px) {
  .spotlight .sl-card[data-pv="1"] .sl-body { grid-template-columns: minmax(0, 1fr) 270px; }
  .spotlight .sl-card[data-pv="1"] .sl-preview { display: flex; }
}

/* ---------- Footer ---------- */
.sl-hint { display: flex; gap: 16px; margin: 0; padding: 10px 10px 2px; font: 400 11px/1 var(--lg-font); color: var(--lg-text-3); border-top: .5px solid var(--lg-separator); margin-top: 8px; }
.sl-hint kbd, .sl-pv-action kbd { font: 500 10.5px/1 var(--lg-font); padding: 2px 5px; margin-right: 3px; border-radius: 5px; background: var(--sl-kbd); color: var(--lg-text-2); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .spotlight .sl-stage { top: calc(env(safe-area-inset-top, 0px) + 58px); width: calc(100vw - 24px); gap: 8px; }
  .spotlight .sl-bar { height: 52px; padding-left: 16px; }
  .spotlight .sl-bar input { font-size: 18px; }
  .spotlight .search-close { visibility: visible; opacity: 1; }
  .sl-kind, .sl-hint, .sl-preview { display: none !important; }
  #spotlight #spotlight-results { max-height: calc(100svh - 270px); }
  .spotlight .sl-card { border-radius: 24px; }
  .sl-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Motion + transparency ---------- */
body.motion-reduced .spotlight .sl-bar { animation: none; }
body.motion-reduced .spotlight .sl-card { transition: opacity .01ms; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .spotlight[open] .sl-bar { animation: none; }
  .spotlight .sl-card { transition: opacity .01ms; transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .spotlight .sl-bar.lg-clear { background: var(--lg-fill-thick); }
}
