/* =============================================
   SEARCH — Premium Discovery Overlay
   shadesofshrey.com

   Design Tokens Used:
   φ spacing:    --space-xs(8) --space-sm(13) --space-md(21) --space-lg(34)
   φ type:       --text-xs(14-16) --body(16-18) --h3(20-26) --h2(26-42)
   Families:     --font-display (Playfair), --font-ui (system sans), JetBrains Mono
   Gold:         #c9a84c (dark), #a08232 (light)
   Easing:       cubic-bezier(0.16, 1, 0.3, 1)
   ============================================= */

/* ── 1. Trigger Button ── */
.search-trigger {
  position: relative;
  z-index: 1001;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color 0.35s ease,
              background-color 0.35s ease,
              box-shadow 0.35s ease,
              transform 0.2s ease;
}
.search-trigger:hover {
  border-color: rgba(201,168,76,0.5);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 12px rgba(201,168,76,0.08);
  transform: scale(1.06);
}
.search-trigger:active { transform: scale(0.95); }
.search-trigger svg {
  width: 15px;
  height: 15px;
  color: rgba(255,255,255,0.75);
  transition: color 0.35s ease;
}
.search-trigger:hover svg { color: rgba(255,255,255,0.95); }

/* Nav placement */
.nav .search-trigger { margin-left: var(--space-sm, 0.8rem); }
.site-nav .search-trigger { margin-left: 0.8rem; }

@media (max-width: 1024px) {
  .nav .search-trigger,
  .site-nav .search-trigger {
    margin-left: 0;
    margin-right: 6px;
    order: -1;
  }
}

/* ── 2. Overlay Backdrop ── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(32px) saturate(1.1);
  -webkit-backdrop-filter: blur(32px) saturate(1.1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.search-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/* ── 3. Container ── */
.search-box {
  width: 100%;
  max-width: 620px;
  padding: 0 var(--space-lg, 2rem);
  transform: translateY(-16px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.search-overlay.is-active .search-box {
  transform: translateY(0);
  opacity: 1;
}

/* ── 4. Close ── */
.search-close {
  position: absolute;
  top: var(--space-md, 1.2rem);
  right: var(--space-md, 1.2rem);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: border-color 0.3s, color 0.3s;
}
.search-close:hover {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.8);
}

/* ── 5. Mode Toggle ── */
.search-modes {
  display: flex;
  justify-content: center;
  gap: var(--space-xs, 8px);
  margin-bottom: var(--space-lg, 2rem);
}
.search-mode-btn {
  padding: 6px 16px;
  background: none;
  border: 1px solid transparent;
  border-radius: 100px;
  color: rgba(255,255,255,0.3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.search-mode-btn:hover {
  color: rgba(255,255,255,0.55);
}
.search-mode-btn.active {
  color: #c9a84c;
  border-color: rgba(201,168,76,0.3);
  background: rgba(201,168,76,0.06);
}

/* ── 6. Input ── */
.search-input-wrap {
  position: relative;
  margin-bottom: var(--space-md, 1.5rem);
}
.search-input {
  width: 100%;
  padding: 12px 56px 12px 0;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  font-family: var(--font-display, 'Playfair Display', Georgia, serif);
  font-size: clamp(1.3rem, 1vw + 1rem, 1.7rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  outline: none;
  caret-color: #c9a84c;
  transition: border-color 0.35s ease;
}
.search-input::placeholder {
  color: rgba(255,255,255,0.15);
  font-style: italic;
  font-weight: 400;
}
.search-input:focus {
  border-bottom-color: rgba(201,168,76,0.45);
}
.search-kbd {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 7px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: rgba(255,255,255,0.18);
  letter-spacing: 0.06em;
  pointer-events: none;
  white-space: nowrap;
}

/* ── 7. Tag Row ── */
.search-tags {
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-md, 1.2rem);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.search-tags::-webkit-scrollbar { display: none; }
.search-tag {
  padding: 4px 12px;
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 100px;
  color: rgba(255,255,255,0.3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.56rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.search-tag:hover {
  color: rgba(255,255,255,0.55);
  border-color: rgba(255,255,255,0.15);
}
.search-tag.active {
  color: #c9a84c;
  border-color: rgba(201,168,76,0.35);
  background: rgba(201,168,76,0.08);
}

/* ── 8. Status Label ── */
.search-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.56rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.15);
  margin-bottom: var(--space-sm, 0.8rem);
  display: block;
  min-height: 1em;
}

/* ── 9. Results ── */
.search-results {
  max-height: 48vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}
.search-results::-webkit-scrollbar { width: 3px; }
.search-results::-webkit-scrollbar-track { background: transparent; }
.search-results::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
}

/* ── 10. Result Cards ── */
.search-result {
  display: block;
  padding: 14px 14px;
  margin: 0 -14px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.25s ease;
}
.search-result:hover,
.search-result.is-focused {
  background: rgba(255,255,255,0.04);
}
.search-result + .search-result {
  border-top: 1px solid rgba(255,255,255,0.03);
}

/* Result header row: badge + tags */
.search-result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.search-result-badge {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(201,168,76,0.08);
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.52rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #c9a84c;
  line-height: 1.5;
}

/* Inline result tags */
.search-result-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.search-result-tag {
  padding: 1px 6px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.48rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.22);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.search-result-tag:hover {
  color: rgba(201,168,76,0.7);
  border-color: rgba(201,168,76,0.2);
}

.search-result-title {
  font-family: var(--font-display, 'Playfair Display', Georgia, serif);
  font-size: 0.98rem;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  margin-bottom: 3px;
  line-height: 1.35;
}

.search-result-sub {
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(255,255,255,0.25);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.search-result-desc {
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 0.76rem;
  color: rgba(255,255,255,0.32);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── 11. Keyword Highlight ── */
.search-hl {
  background: rgba(201,168,76,0.15);
  color: rgba(255,255,255,0.95);
  border-radius: 2px;
  padding: 0 1px;
}

/* ── 12. Empty State ── */
.search-empty {
  text-align: center;
  padding: var(--space-xl, 3rem) 0 var(--space-lg, 2rem);
}
.search-empty-rule {
  display: block;
  width: 32px;
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0 auto var(--space-md, 1rem);
}
.search-empty-text {
  color: rgba(255,255,255,0.22);
  font-size: 0.8rem;
  line-height: 1.7;
  font-style: italic;
}
.search-empty-action {
  display: inline-block;
  margin-top: var(--space-sm, 0.8rem);
  padding: 6px 16px;
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 100px;
  color: rgba(201,168,76,0.6);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.search-empty-action:hover {
  color: #c9a84c;
  border-color: rgba(201,168,76,0.4);
  background: rgba(201,168,76,0.06);
}

/* ── 13. Google Mode ── */
.search-google {
  text-align: center;
  padding: var(--space-lg, 2rem) 0;
  display: none;
}
.search-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 100px;
  background: none;
  color: rgba(255,255,255,0.7);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}
.search-google-btn:hover {
  border-color: rgba(255,255,255,0.3);
  color: #fff;
  background: rgba(255,255,255,0.04);
}
.search-google-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.5;
}
.search-google-scope {
  display: block;
  margin-top: var(--space-sm, 0.8rem);
  color: rgba(255,255,255,0.18);
  font-size: 0.7rem;
  font-style: italic;
}
.search-google-alt {
  display: inline-block;
  margin-top: var(--space-xs, 0.5rem);
  color: rgba(255,255,255,0.2);
  font-size: 0.65rem;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.25s, border-color 0.25s;
}
.search-google-alt:hover {
  color: rgba(255,255,255,0.45);
  border-bottom-color: rgba(255,255,255,0.2);
}

/* ── 14. Google Footer (in site mode) ── */
.search-google-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-sm, 0.8rem) 0;
  margin-top: var(--space-xs, 0.5rem);
  border-top: 1px solid rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.18);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.25s;
}
.search-google-footer:hover {
  color: rgba(255,255,255,0.4);
}
.search-google-footer svg {
  width: 10px;
  height: 10px;
  opacity: 0.4;
}

/* ── 15. Mobile ── */
@media (max-width: 640px) {
  .search-overlay { padding-top: 5vh; }
  .search-box { padding: 0 var(--space-md, 1rem); }
  .search-input { font-size: 1.2rem; padding-right: 0; }
  .search-close { top: 12px; right: 12px; width: 32px; height: 32px; font-size: 16px; }
  .search-results { max-height: 54vh; }
  .search-kbd { display: none; }
  .search-mode-btn { font-size: 0.58rem; padding: 5px 12px; }
  .search-result-tags { display: none; }
}

/* =============================================
   LIGHT THEME
   ============================================= */

[data-theme="light"] .search-trigger {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.2);
}
[data-theme="light"] .search-trigger:hover {
  border-color: rgba(160,130,50,0.45);
  background: rgba(0,0,0,0.07);
  box-shadow: 0 0 12px rgba(160,130,50,0.06);
}
[data-theme="light"] .search-trigger svg { color: rgba(0,0,0,0.55); }
[data-theme="light"] .search-trigger:hover svg { color: rgba(0,0,0,0.8); }

[data-theme="light"] .search-overlay {
  background: rgba(250,248,245,0.95);
}

[data-theme="light"] .search-close {
  border-color: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.3);
}
[data-theme="light"] .search-close:hover {
  border-color: rgba(0,0,0,0.2);
  color: rgba(0,0,0,0.7);
}

[data-theme="light"] .search-mode-btn {
  color: rgba(0,0,0,0.28);
}
[data-theme="light"] .search-mode-btn:hover {
  color: rgba(0,0,0,0.5);
}
[data-theme="light"] .search-mode-btn.active {
  color: #a08232;
  border-color: rgba(160,130,50,0.25);
  background: rgba(160,130,50,0.05);
}

[data-theme="light"] .search-input {
  color: #1a1a1f;
  border-bottom-color: rgba(0,0,0,0.07);
  caret-color: #a08232;
}
[data-theme="light"] .search-input::placeholder { color: rgba(0,0,0,0.15); }
[data-theme="light"] .search-input:focus { border-bottom-color: rgba(160,130,50,0.35); }
[data-theme="light"] .search-kbd { border-color: rgba(0,0,0,0.08); color: rgba(0,0,0,0.15); }

[data-theme="light"] .search-tag {
  border-color: rgba(0,0,0,0.06);
  color: rgba(0,0,0,0.28);
}
[data-theme="light"] .search-tag:hover {
  color: rgba(0,0,0,0.5);
  border-color: rgba(0,0,0,0.12);
}
[data-theme="light"] .search-tag.active {
  color: #a08232;
  border-color: rgba(160,130,50,0.3);
  background: rgba(160,130,50,0.06);
}

[data-theme="light"] .search-status { color: rgba(0,0,0,0.12); }

[data-theme="light"] .search-results::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.06); }

[data-theme="light"] .search-result:hover,
[data-theme="light"] .search-result.is-focused { background: rgba(0,0,0,0.025); }
[data-theme="light"] .search-result + .search-result { border-top-color: rgba(0,0,0,0.03); }

[data-theme="light"] .search-result-badge { background: rgba(160,130,50,0.07); color: #a08232; }
[data-theme="light"] .search-result-tag { border-color: rgba(0,0,0,0.05); color: rgba(0,0,0,0.2); }
[data-theme="light"] .search-result-tag:hover { color: rgba(160,130,50,0.65); border-color: rgba(160,130,50,0.18); }
[data-theme="light"] .search-result-title { color: #1a1a1f; }
[data-theme="light"] .search-result-sub { color: rgba(0,0,0,0.3); }
[data-theme="light"] .search-result-desc { color: rgba(0,0,0,0.38); }

[data-theme="light"] .search-hl { background: rgba(160,130,50,0.12); color: #1a1a1f; }

[data-theme="light"] .search-empty-rule { background: rgba(0,0,0,0.06); }
[data-theme="light"] .search-empty-text { color: rgba(0,0,0,0.2); }
[data-theme="light"] .search-empty-action { color: rgba(160,130,50,0.55); border-color: rgba(160,130,50,0.18); }
[data-theme="light"] .search-empty-action:hover { color: #a08232; border-color: rgba(160,130,50,0.35); background: rgba(160,130,50,0.04); }

[data-theme="light"] .search-google-btn { border-color: rgba(0,0,0,0.1); color: rgba(0,0,0,0.55); }
[data-theme="light"] .search-google-btn:hover { border-color: rgba(0,0,0,0.25); color: #1a1a1f; background: rgba(0,0,0,0.02); }
[data-theme="light"] .search-google-scope { color: rgba(0,0,0,0.15); }
[data-theme="light"] .search-google-alt { color: rgba(0,0,0,0.18); }
[data-theme="light"] .search-google-alt:hover { color: rgba(0,0,0,0.4); border-bottom-color: rgba(0,0,0,0.15); }

[data-theme="light"] .search-google-footer { color: rgba(0,0,0,0.15); border-top-color: rgba(0,0,0,0.03); }
[data-theme="light"] .search-google-footer:hover { color: rgba(0,0,0,0.35); }
