/* =====================================================================
   Spotlight Search — spotlight.css
   Prefix: --sl-  (avoids conflicts with site variables)
   ===================================================================== */

/* ── Variables ──────────────────────────────────────────────────────── */
:root {
  --sl-bg-deep:         #0a0c10;
  --sl-bg-surface:      #12151c;
  --sl-bg-elevated:     #1a1e28;
  --sl-bg-hover:        #222836;
  --sl-border:          #2a3040;
  --sl-border-focus:    #4a5568;
  --sl-text:            #e8ecf4;
  --sl-text-secondary:  #8892a4;
  --sl-text-muted:      #5a6478;
  --sl-accent:          #6c8cff;
  --sl-highlight-bg:    rgba(212, 160, 23, 0.22);
  --sl-highlight-text:  #f0d060;
  --sl-cat-bayanat:     #d4a017;
  --sl-cat-sirens:      #e74c3c;
  --sl-cat-enemy:       #3498db;
  --sl-cat-iran:        #9b59b6;
  --sl-cat-videos:      #2ecc71;
  --sl-cat-allies:      #e67e22;
  --sl-radius:          16px;
  --sl-radius-sm:       10px;
  --sl-transition:      0.15s ease;
}

/* Light theme overrides — mirrors site light palette */
body.light {
  --sl-bg-deep:         #f5f5f0;
  --sl-bg-surface:      #ffffff;
  --sl-bg-elevated:     #f7f5ef;
  --sl-bg-hover:        #efece3;
  --sl-border:          #d4cfc4;
  --sl-border-focus:    #9a7b2d;
  --sl-text:            #1a1a1a;
  --sl-text-secondary:  #6b6b6b;
  --sl-text-muted:      #a0a0a0;
  --sl-accent:          #9a7b2d;
  --sl-highlight-bg:    rgba(154, 123, 45, 0.18);
  --sl-highlight-text:  #7a5f1f;
}
body.light #spotlightOverlay {
  background: rgba(20, 18, 10, 0.35);
}
body.light .sl-modal {
  box-shadow: 0 24px 64px rgba(40, 30, 10, 0.18), 0 4px 16px rgba(40, 30, 10, 0.10);
}

/* ── Animations ─────────────────────────────────────────────────────── */
@keyframes slFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Overlay ────────────────────────────────────────────────────────── */
#spotlightOverlay {
  display:         none;
  position:        fixed;
  inset:           0;
  background:      rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items:     flex-start;
  padding-top:     10vh;
  z-index:         99999;
  animation:       slFadeIn var(--sl-transition);
}

#spotlightOverlay.open {
  display: flex;
}

/* ── Modal ──────────────────────────────────────────────────────────── */
.sl-modal {
  max-width:    860px;
  width:        90vw;
  background:   var(--sl-bg-surface);
  border:       1px solid var(--sl-border);
  border-radius: var(--sl-radius);
  box-shadow:   0 24px 64px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.4);
  display:      flex;
  flex-direction: column;
  max-height:   75vh;
  overflow:     hidden;
  position:     relative; /* positioning context for mobile sheet */
  animation:    slSlideUp var(--sl-transition);
}

/* ── Search Row ─────────────────────────────────────────────────────── */
.sl-search-row {
  display:       flex;
  align-items:   center;
  gap:           10px;
  padding:       16px 20px;
  border-bottom: 1px solid var(--sl-border);
}

.sl-search-icon {
  font-size:  18px;
  color:      var(--sl-text-muted);
  flex-shrink: 0;
}

.sl-input {
  flex:       1;
  border:     none;
  background: transparent;
  color:      var(--sl-text);
  font:       inherit;
  font-size:  15px;
  direction:  rtl;
  outline:    none;
}

.sl-input::placeholder {
  color: var(--sl-text-muted);
}

.sl-date-chip {
  display:       none;
  font-family:   monospace;
  font-size:     11px;
  color:         var(--sl-accent);
  background:    rgba(108, 140, 255, 0.12);
  border:        1px solid rgba(108, 140, 255, 0.3);
  border-radius: 6px;
  padding:       2px 8px;
}

.sl-date-chip.visible {
  display: block;
}

.sl-lang-indicator {
  display:       none;
  font-size:     10px;
  color:         #2ecc71;
  background:    rgba(46, 204, 113, 0.12);
  border:        1px solid rgba(46, 204, 113, 0.3);
  border-radius: 6px;
  padding:       2px 8px;
}

.sl-lang-indicator.visible {
  display: block;
}

.sl-esc-badge {
  font-family:   monospace;
  font-size:     10px;
  color:         var(--sl-text-muted);
  background:    var(--sl-bg-elevated);
  border:        1px solid var(--sl-border);
  border-radius: 4px;
  padding:       2px 6px;
  flex-shrink:   0;
}

/* ── Info Bar ───────────────────────────────────────────────────────── */
.sl-info-bar {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  padding:         6px 20px;
  font-family:     monospace;
  font-size:       11px;
  color:           var(--sl-text-muted);
  border-bottom:   1px solid var(--sl-border);
}

.sl-stats-bar {
  display: flex;
  gap:     10px;
}

.sl-stat-item {
  display:     flex;
  align-items: center;
  gap:         4px;
}

.sl-stat-dot {
  width:         6px;
  height:        6px;
  border-radius: 50%;
  flex-shrink:   0;
}

/* ── Filter Pills ───────────────────────────────────────────────────── */
.sl-filters {
  display:      flex;
  gap:          6px;
  padding:      10px 20px;
  border-bottom: 1px solid var(--sl-border);
  overflow-x:   auto;
  scrollbar-width: none;
}

.sl-filters::-webkit-scrollbar {
  display: none;
}

.sl-filter-pill {
  padding:         0 16px;
  border-radius:   8px;
  font-size:       12px;
  font-weight:     500;
  font-family:     inherit;
  border:          1px solid var(--sl-border);
  background:      var(--sl-bg-elevated);
  color:           var(--sl-text-secondary);
  cursor:          pointer;
  white-space:     nowrap;
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             6px;
  width:           112px;
  height:          32px;
  flex:            0 0 auto;
  box-sizing:      border-box;
  transition:      border-color var(--sl-transition), background var(--sl-transition), color var(--sl-transition);
}

.sl-filter-pill.active {
  background:   var(--sl-accent);
  border-color: var(--sl-accent);
  color:        var(--sl-bg-deep);
  font-weight:  600;
}

.sl-filter-pill:hover:not(.active) {
  border-color: var(--sl-border-focus);
  background:   var(--sl-bg-hover);
  color:        var(--sl-text);
}

.sl-filter-count {
  font-family:  'JetBrains Mono', 'SF Mono', monospace;
  font-size:    10px;
  opacity:      0.6;
  background:   rgba(255, 255, 255, 0.08);
  padding:      1px 5px;
  border-radius: 4px;
  min-width:    18px;
  text-align:   center;
}

.sl-filter-pill.active .sl-filter-count {
  background:   rgba(0, 0, 0, 0.15);
  opacity:      0.85;
}

/* ── Split Pane ─────────────────────────────────────────────────────── */
.sl-split {
  display:    grid;
  grid-template-columns: 1fr 1.3fr;
  flex:       1;
  min-height: 0;
  overflow:   hidden;
}

/* ── Results List ───────────────────────────────────────────────────── */
.sl-results {
  overflow-y:   auto;
  border-left:  1px solid var(--sl-border);
  scrollbar-width: thin;
  scrollbar-color: var(--sl-border) transparent;
}

.sl-results::-webkit-scrollbar {
  width: 4px;
}

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

.sl-results::-webkit-scrollbar-thumb {
  background: var(--sl-border);
  border-radius: 2px;
}

.sl-result-item {
  display:       flex;
  align-items:   center;
  gap:           10px;
  padding:       10px 16px;
  cursor:        pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition:    background var(--sl-transition);
}

.sl-result-item:hover {
  background: var(--sl-bg-hover);
}

.sl-result-item.selected {
  background: var(--sl-bg-hover);
  box-shadow: inset -3px 0 0 var(--sl-accent);
}

.sl-result-dot {
  width:         8px;
  height:        8px;
  border-radius: 50%;
  flex-shrink:   0;
}

.sl-result-body {
  flex:      1;
  min-width: 0;
}

.sl-result-title {
  font-size:     12.5px;
  font-weight:   500;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
  line-height:   1.4;
  color:         var(--sl-text);
}

.sl-result-sub {
  display:     flex;
  gap:         6px;
  font-size:   10.5px;
  color:       var(--sl-text-muted);
  align-items: center;
}

.sl-result-cat {
  font-size:     10px;
  font-weight:   bold;
  padding:       1px 6px;
  border-radius: 4px;
}

.sl-result-time {
  font-family: monospace;
  font-size:   10px;
  color:       var(--sl-text-muted);
  direction:   ltr;
}

/* ── Detail Pane ────────────────────────────────────────────────────── */
.sl-detail {
  overflow-y:   auto;
  padding:      20px;
  display:      flex;
  flex-direction: column;
  gap:          14px;
  background:   var(--sl-bg-elevated);
  scrollbar-width: thin;
  scrollbar-color: var(--sl-border) transparent;
}

.sl-detail::-webkit-scrollbar {
  width: 4px;
}

.sl-detail::-webkit-scrollbar-track {
  background: transparent;
}

.sl-detail::-webkit-scrollbar-thumb {
  background: var(--sl-border);
  border-radius: 2px;
}

.sl-detail-empty {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  justify-content: center;
  flex:           1;
  color:          var(--sl-text-muted);
  font-size:      13px;
  text-align:     center;
  gap:            8px;
}

.sl-detail-empty-icon {
  font-size: 32px;
  opacity:   0.4;
}

.sl-detail-badge-row {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
}

.sl-detail-category {
  font-size:     11px;
  font-weight:   bold;
  padding:       4px 10px;
  border-radius: 6px;
}

.sl-detail-date {
  display:     flex;
  gap:         6px;
  font-family: monospace;
  font-size:   11px;
  color:       var(--sl-text-muted);
  direction:   ltr;
}

.sl-detail-title {
  font-size:   15px;
  font-weight: 600;
  line-height: 1.7;
  color:       var(--sl-text);
}

.sl-detail-divider {
  height:     1px;
  background: var(--sl-border);
}

.sl-detail-section-label {
  font-size:      10px;
  font-weight:    bold;
  color:          var(--sl-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sl-detail-full-text {
  font-size:   13px;
  line-height: 1.8;
  color:       var(--sl-text-secondary);
}

.sl-detail-meta-grid {
  display:               grid;
  grid-template-columns: auto 1fr;
  gap:                   5px 12px;
  font-size:             12px;
}

.sl-detail-meta-key {
  color:       var(--sl-text-muted);
  font-weight: 500;
}

.sl-detail-meta-val {
  color: var(--sl-text);
}

.sl-detail-tags {
  display:   flex;
  flex-wrap: wrap;
  gap:       6px;
}

.sl-detail-tag {
  font-size:     10px;
  padding:       3px 8px;
  border-radius: 6px;
  background:    rgba(255, 255, 255, 0.06);
  color:         var(--sl-text-secondary);
}

.sl-detail-open-btn {
  margin-top:    auto;
  padding:       10px;
  border-radius: 8px;
  border:        1px solid var(--sl-border);
  background:    var(--sl-bg-surface);
  color:         var(--sl-text-secondary);
  text-align:    center;
  cursor:        pointer;
  font:          inherit;
  transition:    background var(--sl-transition), color var(--sl-transition), border-color var(--sl-transition);
}

.sl-detail-open-btn:hover {
  background:   var(--sl-accent);
  color:        var(--sl-bg-deep);
  border-color: var(--sl-accent);
}

/* ── Related ────────────────────────────────────────────────────────── */
.sl-related {
  border-top:  1px solid var(--sl-border);
  padding-top: 12px;
}

.sl-related-label {
  font-size:      10px;
  font-weight:    bold;
  color:          var(--sl-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom:  6px;
}

.sl-related-item {
  display:     flex;
  gap:         8px;
  padding:     6px 0;
  cursor:      pointer;
  font-size:   11.5px;
  color:       var(--sl-text-secondary);
  align-items: center;
  transition:  color var(--sl-transition);
}

.sl-related-item:hover {
  color: var(--sl-text);
}

.sl-related-dot {
  width:         6px;
  height:        6px;
  border-radius: 50%;
  flex-shrink:   0;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.sl-footer {
  display:         flex;
  justify-content: center;
  align-items:     center;
  gap:             16px;
  padding:         10px 20px;
  border-top:      1px solid var(--sl-border);
  font-size:       10px;
  color:           var(--sl-text-muted);
}

.sl-footer kbd {
  font-family:   monospace;
  background:    var(--sl-bg-elevated);
  border:        1px solid var(--sl-border);
  padding:       1px 5px;
  border-radius: 3px;
  font-size:     9px;
}

/* ── Loading / Skeleton ─────────────────────────────────────────────── */
.sl-loading {
  display:        flex;
  flex-direction: column;
  gap:            8px;
  padding:        16px;
}

.sl-skeleton {
  height:     44px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--sl-bg-elevated) 25%,
    var(--sl-bg-hover)    50%,
    var(--sl-bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation:  slShimmer 1.5s infinite;
}

/* ── Empty State ────────────────────────────────────────────────────── */
.sl-empty {
  padding:    32px 20px;
  text-align: center;
  color:      var(--sl-text-muted);
}

.sl-empty-icon {
  font-size:     36px;
  margin-bottom: 12px;
  opacity:       0.4;
}

.sl-empty-title {
  font-size:   14px;
  font-weight: 500;
  color:       var(--sl-text-secondary);
}

/* ── Recent ─────────────────────────────────────────────────────────── */
.sl-recent {
  padding: 12px 20px;
}

.sl-recent-label {
  font-size:      10px;
  font-weight:    bold;
  color:          var(--sl-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom:  6px;
}

.sl-recent-item {
  display:       flex;
  gap:           8px;
  padding:       7px 12px;
  border-radius: 8px;
  cursor:        pointer;
  font-size:     12.5px;
  color:         var(--sl-text-secondary);
  align-items:   center;
  transition:    background var(--sl-transition), color var(--sl-transition);
}

.sl-recent-item:hover {
  background: var(--sl-bg-hover);
  color:      var(--sl-text);
}

.sl-recent-icon {
  font-size: 12px;
  color:     var(--sl-text-muted);
}

/* ── Highlight ──────────────────────────────────────────────────────── */
.sl-highlight {
  background:  var(--sl-highlight-bg);
  color:       var(--sl-highlight-text);
  padding:     0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* ── No Results ─────────────────────────────────────────────────────── */
.sl-no-results {
  padding:    32px 20px;
  text-align: center;
  color:      var(--sl-text-muted);
  font-size:  13px;
}

/* ── Mobile drag handle (bottom sheet) ──────────────────────────────── */
.sl-sheet-handle {
  display:        none;
  width:          100%;
  padding:        6px 0 8px;
  background:     transparent;
  border:         none;
  cursor:         grab;
  flex-shrink:    0;
  touch-action:   none;
}

.sl-sheet-handle::before {
  content:       "";
  display:       block;
  width:         38px;
  height:        4px;
  background:    var(--sl-border-focus);
  border-radius: 3px;
  margin:        0 auto;
  transition:    background 0.15s;
}

.sl-sheet-handle:hover::before,
.sl-sheet-handle:active::before {
  background: var(--sl-text-muted);
}

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  #spotlightOverlay {
    padding-top: 0;
    align-items: flex-start;
  }

  .sl-modal {
    width:         100vw;
    max-width:     100vw;
    max-height:    100vh;
    height:        100vh;
    border-radius: 0;
  }

  .sl-search-row {
    padding: 12px 14px;
    gap:     8px;
  }

  .sl-input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .sl-info-bar {
    padding: 5px 14px;
    font-size: 10px;
  }

  .sl-filters {
    padding: 8px 14px;
    gap:     5px;
  }

  .sl-filter-pill {
    padding:   0 12px;
    font-size: 11.5px;
    width:     92px;
    height:    30px;
  }

  /* Top bars stay above the backdrop and clickable at all times */
  .sl-search-row,
  .sl-info-bar,
  .sl-filters {
    position: relative;
    z-index:  11;
    background: var(--sl-bg-surface);
  }

  .sl-split {
    grid-template-columns: 1fr;
    /* NOTE: no position:relative — sheet positions relative to modal instead */
  }

  /* Backdrop dimmer — positions against modal (nearest positioned ancestor)
     so it covers the entire viewport including the top bars. Top bars have
     higher z-index so they remain bright; the sheet has an even higher
     z-index so it always sits above the backdrop. */
  .sl-split::after {
    content:         "";
    position:        absolute;
    inset:           0;
    background:      rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    opacity:         0;
    pointer-events:  none;
    transition:      opacity 0.2s ease;
    z-index:         10;
  }
  .sl-split.sheet-open::after {
    opacity:        1;
    pointer-events: auto;
  }

  .sl-detail {
    display: none;
    padding: 4px 16px 18px;
    gap:     11px;
  }

  .sl-detail.mobile-open {
    display:                  flex;
    position:                 absolute;
    left:                     0;
    right:                    0;
    bottom:                   0;
    top:                      auto;
    height:                   68vh;
    max-height:               100%;
    z-index:                  20; /* above backdrop (10) and top bars (11) */
    background:               var(--sl-bg-surface);
    border-top-left-radius:   22px;
    border-top-right-radius:  22px;
    box-shadow:               0 -14px 40px rgba(0, 0, 0, 0.6),
                              0 -2px 10px rgba(0, 0, 0, 0.4);
    animation:                slSlideUp 0.26s ease;
    transition:               height 0.26s cubic-bezier(0.22, 0.9, 0.3, 1),
                               border-top-left-radius 0.24s ease,
                               border-top-right-radius 0.24s ease;
    will-change:              height;
  }

  .sl-detail.mobile-open.expanded {
    height:                  100%;
    border-top-left-radius:  0;
    border-top-right-radius: 0;
  }

  .sl-sheet-handle { display: block; }

  .sl-detail-back { display: none; }

  .sl-detail-badge-row {
    flex-wrap: wrap;
    gap:       6px;
  }

  .sl-detail-title {
    font-size:   14px;
    line-height: 1.65;
  }

  .sl-detail-full-text {
    font-size:   12.5px;
    line-height: 1.75;
  }

  .sl-detail-meta-grid {
    font-size: 11.5px;
    gap:       4px 10px;
  }

  .sl-detail-open-btn {
    position:   sticky;
    bottom:     0;
    margin-top: 6px;
    padding:    12px;
    font-size:  13px;
    font-weight: 600;
    background: var(--sl-accent);
    color:      var(--sl-bg-deep);
    border-color: var(--sl-accent);
  }

  .sl-results {
    border-left: none;
  }

  .sl-result-item {
    padding: 12px 14px;
  }

  .sl-result-item.selected {
    box-shadow: none;
    background: transparent;
  }

  .sl-result-item:active {
    background: var(--sl-bg-hover);
  }

  .sl-footer {
    display: none;
  }
}
