/* Search Modal — Start24 Smart Search */

/* Backdrop */
.s24-search-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(11, 17, 30, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.s24-search-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Modal container */
.s24-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  padding: 80px 24px 24px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.s24-search-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.admin-bar .s24-search-modal {
  padding-top: 112px;
}

/* Modal card */
.s24-search-card {
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 160px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}
.s24-search-modal.is-open .s24-search-card {
  transform: translateY(0) scale(1);
}

/* Search input row */
.s24-search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}
.s24-search-header svg {
  flex-shrink: 0;
  color: #718096;
}
.s24-search-header input {
  flex: 1;
  border: none;
  background: none;
  font-family: "DM Sans", sans-serif;
  font-size: 17px;
  color: #2d3748;
  outline: none;
  line-height: 1.5;
}
.s24-search-header input::placeholder {
  color: #a0aec0;
}
.s24-search-kbd {
  display: none;
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #a0aec0;
  background: #f7f8fc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1.4;
  flex-shrink: 0;
}
.s24-search-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  color: #718096;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.s24-search-close-btn:hover {
  background: #f7f8fc;
  color: #2d3748;
}

/* Results area */
.s24-search-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 12px;
  overscroll-behavior: contain;
}
.s24-search-body::-webkit-scrollbar {
  width: 6px;
}
.s24-search-body::-webkit-scrollbar-track {
  background: transparent;
}
.s24-search-body::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 3px;
}

/* Loading state */
.s24-search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  color: #a0aec0;
  font-size: 14px;
}
.s24-search-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e2e8f0;
  border-top-color: #0e7de5;
  border-radius: 50%;
  animation: s24-spin .6s linear infinite;
}
@keyframes s24-spin {
  to { transform: rotate(360deg); }
}

/* Section headers */
.s24-search-section {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Result items */
.s24-search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background .1s;
}
.s24-search-result:hover,
.s24-search-result.is-active {
  background: #f0f5ff;
}
.s24-search-result:hover .s24-sr-title,
.s24-search-result.is-active .s24-sr-title {
  color: #0e7de5;
}

/* Result thumbnail */
.s24-sr-img {
  width: 48px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f7f8fc;
}
.s24-sr-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  background: #f0f5ff;
}

/* Result text */
.s24-sr-text {
  flex: 1;
  min-width: 0;
}
.s24-sr-title {
  font-size: 15px;
  font-weight: 500;
  color: #2d3748;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .1s;
}
.s24-sr-meta {
  font-size: 13px;
  color: #a0aec0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Arrow indicator */
.s24-sr-arrow {
  flex-shrink: 0;
  color: #e2e8f0;
  transition: color .1s;
}
.s24-search-result:hover .s24-sr-arrow,
.s24-search-result.is-active .s24-sr-arrow {
  color: #0e7de5;
}

/* Popular / default state */
.s24-search-popular {
  padding: 4px 0;
}

/* No results */
.s24-search-empty {
  text-align: center;
  padding: 32px 16px;
}
.s24-search-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 4px;
}
.s24-search-empty-sub {
  font-size: 14px;
  color: #a0aec0;
  margin-bottom: 16px;
}

/* JoostBot answer section */
.s24-search-ai {
  margin: 4px 8px 8px;
  background: #f0f5fb;
  border: 1px solid #dce6f2;
  border-radius: 12px;
  padding: 16px;
  display: none;
}
.s24-search-ai.is-visible {
  display: block;
}
.s24-search-ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.s24-search-ai-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}
.s24-search-ai-label {
  font-size: 12px;
  font-weight: 600;
  color: #0e7de5;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.s24-search-ai-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #718096;
}
.s24-search-ai-loading .s24-search-loading-spinner {
  border-color: #dce6f2;
  border-top-color: #0e7de5;
}
.s24-search-ai-text {
  font-size: 14px;
  line-height: 1.7;
  color: #2d3748;
}
.s24-search-ai-text a {
  color: #0e7de5;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.s24-search-ai-text a:hover {
  color: #4ea2f2;
}
.s24-search-ai-text .s24-ai-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #0e7de5;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: s24-blink .6s step-end infinite;
}
@keyframes s24-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
.s24-search-ai-sources {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 10px;
}
.s24-search-ai-source {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  text-decoration: none !important;
  color: #4a5568 !important;
  font-size: 12px;
  transition: background .15s, color .15s;
}
.s24-search-ai-source:hover {
  background: rgba(14, 125, 229, 0.08);
  color: #0e7de5 !important;
}
.s24-search-ai-source-dot {
  width: 4px;
  height: 4px;
  background: #0e7de5;
  border-radius: 50%;
  flex-shrink: 0;
}
.s24-search-ai-rate {
  margin-top: 8px;
  font-size: 11px;
  color: #a0aec0;
  text-align: center;
}
.s24-search-ai-error {
  font-size: 13px;
  color: #718096;
  text-align: center;
  padding: 4px 0;
}

/* JoostBot CTA (no results) */
.s24-search-jb-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #0b111e;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  width: 100%;
  font-family: "DM Sans", sans-serif;
  text-align: left;
  transition: background .15s;
}
.s24-search-jb-cta:hover {
  background: #141c2e;
}
.s24-search-jb-cta-text {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}
.s24-search-jb-cta-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

/* Footer hint */
.s24-search-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid #eee;
  font-size: 12px;
  color: #a0aec0;
}
.s24-search-footer kbd {
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  background: #f7f8fc;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 1px 5px;
  color: #718096;
}

/* Kbd hint next to search icon in header */
.s24-search-btn-kbd {
  display: none;
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #c0c8d4;
  background: #f2f4f8;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 2px;
  line-height: 1.4;
}
/* Widen search button when kbd hint is visible */
@media (min-width: 769px) {
  .s24-search-btn {
    width: auto !important;
    gap: 2px;
  }
}

/* YouTube badge */
.s24-sr-yt {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.s24-sr-yt svg {
  width: 14px;
  height: 10px;
  color: #f00;
}

/* Turnstile container in search */
.s24-search-turnstile {
  display: flex;
  justify-content: center;
  padding: 0 16px 4px;
}

/* ── Mobile: full-screen overlay ── */
@media (max-width: 768px) {
  .s24-search-modal {
    padding: 0;
    align-items: stretch;
  }
  .s24-search-card {
    max-width: none;
    max-height: none;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .s24-search-modal.is-open .s24-search-card {
    transform: none;
  }
  .s24-search-modal-backdrop {
    display: none;
  }
  .s24-search-footer {
    display: none;
  }
  .s24-search-kbd {
    display: none !important;
  }
  .s24-search-header input {
    font-size: 16px; /* prevent iOS zoom */
  }
  .admin-bar .s24-search-modal {
    padding-top: 46px;
  }
}

/* Desktop: show kbd hint */
@media (min-width: 769px) {
  .s24-search-kbd {
    display: inline-block;
  }
  .s24-search-btn-kbd {
    display: inline-block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .s24-search-card,
  .s24-search-modal,
  .s24-search-modal-backdrop {
    transition: none;
  }
}
