/* =========================================================================
   Spotlight / Command Palette — Premium Frosted Glass Aesthetic
   Clean, smooth macOS / Raycast style. Zero harsh cyberpunk styling.
   ========================================================================= */

:root {
  --spot-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --spot-ease-spring: cubic-bezier(0.32, 1.25, 0.5, 1);
  --spot-ease-in: cubic-bezier(0.4, 0, 1, 1);
}

/* Backdrop overlay — closing state transition lives here, opening state in .is-open */
.spotlight-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 6, 10, 0.58);
  backdrop-filter: blur(5px) saturate(120%);
  -webkit-backdrop-filter: blur(5px) saturate(120%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: opacity;
  transition: opacity 180ms var(--spot-ease-in), visibility 0s linear 180ms;
}

.spotlight-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 260ms var(--spot-ease-out), visibility 0s;
}

/* Modal Window Container */
.spotlight-modal {
  position: fixed;
  top: 14vh;
  left: 50%;
  width: min(640px, calc(100vw - 28px));
  max-height: min(520px, calc(100dvh - 20vh));
  background: linear-gradient(180deg, rgba(22, 25, 32, 0.88) 0%, rgba(14, 16, 22, 0.94) 100%);
  backdrop-filter: blur(48px) saturate(150%);
  -webkit-backdrop-filter: blur(48px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow:
    0 32px 85px -10px rgba(0, 0, 0, 0.82),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-10px) scale(0.965);
  transform-origin: 50% 0%;
  will-change: transform, opacity;
  /* Close: short and decisive */
  transition: transform 160ms var(--spot-ease-in), opacity 140ms var(--spot-ease-in);
}

.spotlight-backdrop.is-open .spotlight-modal {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
  /* Open: soft spring with a tiny overshoot */
  transition: transform 420ms var(--spot-ease-spring), opacity 220ms var(--spot-ease-out);
}

/* Search Input Bar */
.spotlight-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.spotlight-search-icon {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 200ms ease, transform 260ms var(--spot-ease-out);
}

.spotlight-header:focus-within .spotlight-search-icon {
  color: rgba(255, 255, 255, 0.72);
}

.spotlight-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 450;
  letter-spacing: -0.01em;
  color: #ffffff;
  caret-color: rgba(255, 255, 255, 0.9);
  padding: 0;
  margin: 0;
}

.spotlight-input::placeholder {
  color: rgba(255, 255, 255, 0.32);
  font-weight: 400;
}

.spotlight-esc-pill {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.spotlight-esc-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.spotlight-esc-pill:active {
  transform: scale(0.94);
}

/* Results Section & List */
.spotlight-results {
  position: relative; /* anchor for the sliding highlight */
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.spotlight-results::-webkit-scrollbar {
  width: 6px;
}

.spotlight-results::-webkit-scrollbar-track {
  background: transparent;
}

.spotlight-results::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.spotlight-results::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Sliding selection highlight — glides between rows instead of jumping */
.spotlight-highlight {
  position: absolute;
  top: 0;
  left: 8px;
  right: 8px;
  height: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  will-change: transform;
  transition:
    transform 240ms var(--spot-ease-out),
    height 240ms var(--spot-ease-out),
    opacity 160ms ease,
    background-color 140ms ease;
}

.spotlight-highlight.is-visible {
  opacity: 1;
}

.spotlight-highlight.no-anim {
  transition: none;
}

.spotlight-highlight.is-activating {
  background: rgba(255, 255, 255, 0.14);
  transition-duration: 240ms, 240ms, 160ms, 60ms;
}

/* Group Headers */
.spotlight-group-title {
  position: relative;
  z-index: 1;
  padding: 10px 12px 5px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.36);
  user-select: none;
}

/* Result Items */
.spotlight-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: transform 140ms var(--spot-ease-out);
}

.spotlight-item.is-activating {
  transform: scale(0.985);
}

.spotlight-item-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13.5px;
  transition: transform 260ms var(--spot-ease-spring), background 200ms ease, border-color 200ms ease;
}

.spotlight-item.is-selected .spotlight-item-icon-box {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.14);
  transform: scale(1.05);
}

.spotlight-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.spotlight-item-title {
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(241, 245, 249, 0.86);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 180ms ease;
}

.spotlight-item.is-selected .spotlight-item-title {
  color: #ffffff;
}

.spotlight-item-desc {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  transition: color 180ms ease;
}

.spotlight-item.is-selected .spotlight-item-desc {
  color: rgba(255, 255, 255, 0.55);
}

.spotlight-item-action {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.34);
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  font-family: inherit;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 180ms ease, transform 220ms var(--spot-ease-out), color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.spotlight-item.is-selected .spotlight-item-action {
  opacity: 1;
  transform: translateX(0);
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.spotlight-action-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

/* Staggered entrance when the palette opens */
@keyframes spotItemIn {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
    filter: blur(4px);
  }
  60% {
    opacity: 0.95;
    filter: blur(0px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

@keyframes spotFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.spotlight-results.is-entering .spotlight-item,
.spotlight-results.is-entering .spotlight-group-title {
  animation: spotItemIn 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 44ms + 70ms);
  will-change: transform, opacity, filter;
}

.spotlight-results.is-entering .spotlight-highlight {
  animation: spotFadeIn 360ms ease 130ms both;
}

/* Empty State */
.spotlight-empty {
  padding: 38px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  animation: spotItemIn 280ms var(--spot-ease-out) both;
}

.spotlight-empty-icon {
  font-size: 26px;
  color: rgba(255, 255, 255, 0.22);
  margin-bottom: 4px;
}

.spotlight-empty-title {
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.spotlight-empty-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.36);
}

/* Footer Hints Bar */
.spotlight-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 12, 16, 0.45);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.spotlight-footer-shortcuts {
  display: flex;
  align-items: center;
  gap: 14px;
}

.spotlight-footer-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.spotlight-footer-hint kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease, transform 200ms var(--spot-ease-out);
}

/* Live key-press feedback in the footer */
.spotlight-footer-hint kbd.is-pressed {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
  transform: translateY(1px);
  transition-duration: 60ms;
}

.spotlight-footer-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.32);
}

/* Navbar Trigger Button */
.navbar-spotlight-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
  font-size: 11.5px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 260ms var(--spot-ease-spring);
  user-select: none;
}

.navbar-spotlight-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.navbar-spotlight-btn:active {
  transform: scale(0.95);
  transition-duration: 80ms;
}

/* Soft expanding ring when the shortcut fires */
.navbar-spotlight-btn::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.4);
  opacity: 0;
  pointer-events: none;
}

.navbar-spotlight-btn.is-pressed {
  animation: spotPillPress 440ms var(--spot-ease-out);
}

.navbar-spotlight-btn.is-pressed::after {
  animation: spotRing 560ms var(--spot-ease-out);
}

.navbar-spotlight-btn.is-pressed .spotlight-pill-key {
  animation: spotKeyPress 440ms var(--spot-ease-out);
}

@keyframes spotPillPress {
  0%   { transform: scale(1); }
  28%  { transform: scale(0.93); background-color: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.3); }
  100% { transform: scale(1); }
}

@keyframes spotRing {
  0%   { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12, 1.4); }
}

@keyframes spotKeyPress {
  0%   { transform: translateY(0); }
  28%  { transform: translateY(1.5px); background-color: rgba(255, 255, 255, 0.3); color: #ffffff; border-color: rgba(255, 255, 255, 0.35); }
  100% { transform: translateY(0); }
}

.spotlight-pill-text {
  font-weight: 450;
  font-size: 11.5px;
  letter-spacing: -0.01em;
}

.spotlight-pill-key {
  display: inline-block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.3;
}

/* Responsive Styles */
@media (max-width: 640px) {
  .spotlight-modal {
    top: 6vh;
    max-height: 80vh;
  }
  .spotlight-pill-text {
    display: none;
  }
  .spotlight-footer-shortcuts span:nth-child(2) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spotlight-backdrop,
  .spotlight-modal,
  .spotlight-backdrop.is-open .spotlight-modal {
    transition: opacity 120ms ease;
  }
  .spotlight-modal,
  .spotlight-backdrop.is-open .spotlight-modal {
    transform: translateX(-50%);
  }
  .spotlight-highlight,
  .spotlight-item,
  .spotlight-item-icon-box,
  .spotlight-item-action {
    transition: none;
  }
  .spotlight-results.is-entering .spotlight-item,
  .spotlight-results.is-entering .spotlight-group-title,
  .spotlight-results.is-entering .spotlight-highlight,
  .spotlight-empty,
  .navbar-spotlight-btn.is-pressed,
  .navbar-spotlight-btn.is-pressed::after,
  .navbar-spotlight-btn.is-pressed .spotlight-pill-key {
    animation: none;
  }
}
