/* ============================================
   Search modal — v9.28
   Smoother modal animation + sized to match header CTA
   ============================================ */

/* ===== Header layout adjustment =====
   pill-nav sits closer to the logo; actions group anchored right.
   Logo + actions are flex-shrink:0 — only pill-nav can compress. */
.header {
  justify-content: flex-start !important;
  gap: 20px;
}
.header .logo { flex-shrink: 0; }
.header .pill-nav {
  flex-shrink: 1;
  min-width: 0;
}
.header .header-actions-group {
  margin-left: auto;
  flex-shrink: 0;
}
.header .menu-toggle { margin-left: auto; }

@media (max-width: 1100px) {
  .header { gap: 14px; }
}
@media (max-width: 900px) {
  .header { gap: 12px; }
}

/* ===== Header actions group (search + CTA together) ===== */
.header-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== Trigger button — sized to match the .header-cta pill ===== */
.search-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 200px;
  flex-shrink: 1;
  min-width: 130px;
  height: 48px;        /* match .header-cta exact height (14px padding + 17px line + 3px border) */
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  color: rgba(26, 26, 77, 0.55);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;

  /* Dual background trick — solid card-bg inside, gradient on border */
  background:
    linear-gradient(var(--card-bg, #FFFFFF), var(--card-bg, #FFFFFF)) padding-box,
    linear-gradient(135deg, #5B4FCF 0%, #8C5FCF 25%, #C66FBF 55%, #FF8FAB 100%) border-box;
  background-size: 100% 100%, 200% 200%;
  animation: searchTriggerGradient 8s ease-in-out infinite;
  box-shadow: var(--shadow-sm, 0 4px 12px rgba(26, 26, 77, 0.04));

  transition: transform 200ms var(--ease, ease),
              box-shadow 200ms var(--ease, ease);
}
.search-trigger:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(91, 79, 207, 0.18);
  animation-duration: 4s;
}
.search-trigger:active {
  transform: translateY(0);
}

@keyframes searchTriggerGradient {
  0%, 100% { background-position: 0% 0%, 0%   50%; }
  50%      { background-position: 0% 0%, 100% 50%; }
}

.search-trigger svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--brand, #5B4FCF);
}
.search-trigger-label {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-trigger-kbd {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 7px;
  background: rgba(91, 79, 207, 0.08);
  border: 1px solid rgba(91, 79, 207, 0.15);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand, #5B4FCF);
  font-family: -apple-system, system-ui, sans-serif;
  letter-spacing: 0;
  flex-shrink: 0;
}

/* Tablet — narrow the trigger further */
@media (max-width: 1100px) {
  .search-trigger {
    width: 200px;
  }
}

/* Mobile — collapse to icon-only.
   NB: must reset min-width (base is 130px) or the trigger never shrinks. */
@media (max-width: 900px) {
  .search-trigger {
    width: 46px;
    height: 46px;
    min-width: 0;          /* was inheriting 130px → never collapsed */
    padding: 0;
    justify-content: center;
    gap: 0;
    margin-left: auto;     /* push search + hamburger group to the right edge */
  }
  .search-trigger-label,
  .search-trigger-kbd { display: none; }
  /* Hamburger sits right after the search icon (no extra auto gap) */
  .header .menu-toggle { margin-left: 10px; }
}

/* ===== Modal backdrop ===== */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 16px;
  background: rgba(13, 10, 50, 0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  opacity: 0;
  /* Slow, smooth backdrop reveal — no flash */
  transition: opacity 280ms ease,
              background 320ms ease,
              backdrop-filter 320ms ease,
              -webkit-backdrop-filter 320ms ease;
}
.search-modal.open {
  display: flex;
  opacity: 1;
  background: rgba(13, 10, 50, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media (max-width: 600px) {
  .search-modal {
    padding: 16px 14px;
    align-items: flex-start;
  }
}

/* ===== Modal card — smooth ease-out, no overshoot ===== */
.search-card {
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 100px);
  background: var(--card-bg, #FFFFFF);
  border-radius: 22px;
  box-shadow:
    0 32px 80px rgba(13, 10, 50, 0.32),
    0 0 0 1px rgba(91, 79, 207, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.97) translateY(-4px);
  opacity: 0;
  transform-origin: top center;
  /* Smooth deceleration, no bounce — Apple's standard ease-out */
  transition:
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 280ms ease;
}
.search-modal.open .search-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

@media (max-width: 600px) {
  .search-card {
    max-height: calc(100vh - 32px);
    height: auto;
    border-radius: 22px;
  }
}

/* ===== Search input row — gradient border on focus (subtle, no flash) ===== */
.search-input-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(26, 26, 77, 0.08);
  transition: border-color 200ms ease;
}
.search-input-row::before {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    #5B4FCF 20%,
    #C66FBF 50%,
    #FF8FAB 80%,
    transparent 100%);
  opacity: 0;
  transform: scaleX(0.4);
  transform-origin: center;
  /* Slower, more elegant — appears 200ms after modal opens */
  transition: opacity 400ms ease 100ms,
              transform 500ms cubic-bezier(0.22, 1, 0.36, 1) 100ms;
}
.search-card.has-focus .search-input-row::before {
  opacity: 1;
  transform: scaleX(1);
}

.search-input-row svg {
  width: 22px; height: 22px;
  color: var(--brand, #5B4FCF);
  flex-shrink: 0;
}
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font: inherit;
  font-size: 18px;
  color: var(--ink, #1A1A4D);
  padding: 4px 0;
}
.search-input::placeholder {
  color: rgba(26, 26, 77, 0.42);
}
.search-clear {
  display: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(26, 26, 77, 0.08);
  border: none;
  color: rgba(26, 26, 77, 0.6);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 150ms, transform 150ms;
  flex-shrink: 0;
}
.search-clear:hover {
  background: rgba(91, 79, 207, 0.15);
  color: var(--brand, #5B4FCF);
  transform: scale(1.05);
}
.search-clear svg {
  width: 14px; height: 14px;
  color: inherit;
}
.search-card.has-query .search-clear {
  display: inline-flex;
}

/* ===== Results body (scrolls) ===== */
.search-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 12px;
  scrollbar-width: thin;
}
.search-body::-webkit-scrollbar { width: 6px; }
.search-body::-webkit-scrollbar-thumb {
  background: rgba(26, 26, 77, 0.15);
  border-radius: 3px;
}

/* ===== Section heading ===== */
.search-section {
  margin: 8px 0 4px;
}
.search-section-title {
  padding: 8px 14px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(26, 26, 77, 0.5);
}

/* ===== Result row ===== */
.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 100ms;
}
.search-row:hover,
.search-row.selected {
  background: rgba(91, 79, 207, 0.08);
}
.search-row.selected {
  background: rgba(91, 79, 207, 0.12);
}
.search-row-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 77, 0.06);
  font-size: 14px;
  color: rgba(26, 26, 77, 0.6);
  overflow: hidden;
}
.search-row-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.search-row-icon-emoji {
  font-size: 18px;
}
.search-row-text {
  flex: 1;
  min-width: 0;
}
.search-row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #1A1A4D);
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-row-sub {
  font-size: 12px;
  color: rgba(26, 26, 77, 0.55);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-row-sub mark,
.search-row-title mark {
  background: rgba(91, 79, 207, 0.18);
  color: inherit;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 3px;
}
.search-row-arrow {
  width: 14px; height: 14px;
  color: rgba(26, 26, 77, 0.35);
  opacity: 0;
  transition: opacity 100ms, transform 100ms;
  flex-shrink: 0;
}
.search-row.selected .search-row-arrow,
.search-row:hover .search-row-arrow {
  opacity: 1;
  transform: translateX(2px);
}

/* ===== Badge for blog tags ===== */
.search-badge {
  display: inline-block;
  padding: 1px 7px;
  background: rgba(91, 79, 207, 0.10);
  color: var(--brand, #5B4FCF);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

/* ===== Empty state ===== */
.search-empty {
  padding: 60px 20px;
  text-align: center;
  color: rgba(26, 26, 77, 0.5);
  font-size: 14px;
}
.search-empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
  opacity: 0.6;
}

/* ===== Footer with keyboard hints ===== */
.search-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid rgba(26, 26, 77, 0.08);
  font-size: 11px;
  color: rgba(26, 26, 77, 0.5);
  flex-wrap: wrap;
}
.search-footer-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.search-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  background: rgba(26, 26, 77, 0.06);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(26, 26, 77, 0.7);
}

@media (max-width: 600px) {
  .search-footer { display: none; }
}
