/* Unified search — Vellum & Rubric. Used by the hub and the investigation. */

.wis-launch {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 12px 0 12px;
  border: 1px solid var(--rule, #d8ccb6); border-radius: 999px;
  background: var(--card, #fbf7ef); color: var(--ink-2, #463f36);
  font: 500 .84rem var(--font-ui, system-ui, sans-serif);
  cursor: pointer; min-width: 42px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.wis-launch:hover, .wis-launch:focus-visible { border-color: var(--lapis, #22407a); color: var(--ink, #1f1b16); }
.wis-launch svg { width: 17px; height: 17px; flex: none; }
.wis-launch-label { white-space: nowrap; color: var(--ink-3, #6a6155); }
.wis-launch kbd {
  margin-left: 8px; padding: 2px 7px; border: 1px solid var(--rule, #d8ccb6); border-radius: 6px;
  font: 600 .68rem var(--font-ui, system-ui, sans-serif); color: var(--ink-3, #6a6155); background: var(--paper, #f3ecdf);
}
.wis-launch-icon { display: none; }

/* Thumb-zone search; sits opposite the back-to-top control */
.wis-fab {
  position: fixed; z-index: 45;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 48px; height: 48px; padding: 0;
  display: none; place-items: center;
  border: 1px solid var(--rule-strong, #bfb096); border-radius: 50%;
  background: var(--card, #fbf7ef); color: var(--ink, #1f1b16);
  box-shadow: 0 8px 28px -16px rgba(40, 24, 8, .55);
  cursor: pointer;
}
.wis-fab svg { width: 20px; height: 20px; }
.wis-fab:hover, .wis-fab:focus-visible { color: var(--rubric, #9a2b1d); border-color: var(--rubric, #9a2b1d); }

.wis-root[hidden] { display: none !important; }
.wis-root {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 24px;
  background: rgba(20, 14, 8, .42);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.wis-panel {
  display: flex; flex-direction: column;
  width: min(720px, 100%);
  max-height: min(80vh, 840px);
  border: 1px solid var(--rule-strong, #bfb096); border-radius: 16px;
  background: var(--paper, #f3ecdf);
  color: var(--ink, #1f1b16);
  box-shadow: 0 24px 60px -24px rgba(20, 10, 0, .55);
  overflow: hidden;
}
.wis-bar {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--rule, #d8ccb6);
  background: var(--card, #fbf7ef);
}
.wis-bar-icon { width: 18px; height: 18px; color: var(--ink-3, #6a6155); flex: none; }
.wis-input {
  flex: 1; min-width: 0; height: 44px; padding: 0;
  border: 0; background: transparent; color: inherit;
  font: 400 16px/1.4 var(--font-ui, system-ui, sans-serif);
}
.wis-input:focus, .wis-input:focus-visible { outline: none; box-shadow: none; }
.wis-input::placeholder { color: var(--ink-3, #6a6155); }
.wis-input::-webkit-search-cancel-button { display: none; }
.wis-clear, .wis-cancel {
  flex: none; height: 36px; min-width: 36px; padding: 0 12px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-2, #463f36); font: 600 .84rem var(--font-ui, system-ui, sans-serif);
  cursor: pointer;
}
.wis-clear:hover, .wis-cancel:hover { background: var(--paper-2, #ebe2d1); color: var(--ink, #1f1b16); }
.wis-clear[hidden] { display: none !important; }
.wis-cancel { display: none; }

.wis-meta {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--rule, #d8ccb6);
  font: 500 .78rem var(--font-ui, system-ui, sans-serif); color: var(--ink-3, #6a6155);
}
.wis-count { margin-right: 4px; }
.wis-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wis-chip {
  height: 28px; padding: 0 10px; border: 1px solid var(--rule, #d8ccb6); border-radius: 999px;
  background: var(--card, #fbf7ef); color: var(--ink-2, #463f36);
  font: 600 .72rem var(--font-ui, system-ui, sans-serif); cursor: pointer;
}
.wis-chip[aria-pressed="true"] { background: var(--ink, #1f1b16); color: var(--paper, #f3ecdf); border-color: var(--ink, #1f1b16); }

.wis-results {
  flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain;
  padding: 8px 8px 20px;
  -webkit-overflow-scrolling: touch;
}
.wis-group { margin: 8px 8px 4px; }
.wis-group-title {
  margin: 0 8px 6px;
  font: 600 .68rem var(--font-ui, system-ui, sans-serif);
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3, #6a6155);
}
.wis-hit {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px;
  width: 100%; padding: 10px 12px; margin: 0 0 4px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: inherit; text-align: left;
  font: inherit; cursor: pointer;
}
.wis-hit:hover, .wis-hit.is-active {
  background: var(--card, #fbf7ef); border-color: var(--rule, #d8ccb6);
}
.wis-hit.is-active { box-shadow: 0 0 0 2px color-mix(in srgb, var(--lapis, #22407a) 35%, transparent); }
.wis-kicker {
  grid-column: 1 / -1;
  font: 600 .66rem var(--font-ui, system-ui, sans-serif);
  letter-spacing: .08em; text-transform: uppercase; color: var(--rubric, #9a2b1d);
}
.wis-hit-title { font: 400 1.05rem/1.3 var(--font-display, Georgia, serif); color: var(--ink, #1f1b16); }
.wis-hit-snip { grid-column: 1 / -1; margin: 0; color: var(--ink-2, #463f36); font-size: .92rem; line-height: 1.45; }
.wis-hit mark {
  background: var(--ochre-wash, #f0e3bf); color: inherit; padding: 0 1px; border-radius: 2px;
  font: inherit;
}

.wis-empty, .wis-idle { padding: 18px 18px 28px; }
.wis-empty h3, .wis-idle h3 {
  margin: 0 0 8px; font: 400 1.2rem var(--font-display, Georgia, serif);
}
.wis-empty p, .wis-idle p { margin: 0 0 14px; color: var(--ink-2, #463f36); }
.wis-suggest, .wis-recent { display: flex; flex-wrap: wrap; gap: 8px; }
.wis-suggest button, .wis-recent button, .wis-didyou button {
  min-height: 36px; padding: 0 12px;
  border: 1px solid var(--rule, #d8ccb6); border-radius: 999px;
  background: var(--card, #fbf7ef); color: var(--ink, #1f1b16);
  font: 500 .84rem var(--font-ui, system-ui, sans-serif); cursor: pointer;
}
.wis-suggest button:hover, .wis-recent button:hover, .wis-didyou button:hover {
  border-color: var(--rubric, #9a2b1d); color: var(--rubric, #9a2b1d);
}
.wis-didyou { margin-top: 12px; }

.is-search-target {
  outline: 2px solid var(--ochre, #7f5e13);
  outline-offset: 4px;
  animation: wis-pulse 1.4s ease forwards;
}
@keyframes wis-pulse {
  0% { box-shadow: 0 0 0 0 var(--ochre-wash, #f0e3bf); }
  40% { box-shadow: 0 0 0 10px var(--ochre-wash, #f0e3bf); }
  100% { box-shadow: none; outline-color: transparent; }
}

html[data-theme="dark"] .wis-root { background: rgba(0, 0, 0, .55); }
html[data-theme="dark"] .wis-hit mark { background: var(--ochre-wash, #33290f); }

@media (max-width: 720px) {
  .wis-launch-label, .wis-launch kbd { display: none; }
  .wis-launch-icon { display: block; }
  .wis-launch { width: 42px; padding: 0; justify-content: center; }
  .wis-fab { display: grid; }
  .wis-root {
    padding: 0; align-items: stretch;
    background: var(--paper, #f3ecdf);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .wis-panel {
    width: 100%; max-height: none; height: 100%;
    height: 100dvh; height: var(--wis-vv, 100dvh);
    border: 0; border-radius: 0; box-shadow: none;
  }
  .wis-bar {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .wis-cancel { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; height: 44px; }
  .wis-clear { height: 44px; min-width: 44px; }
  .wis-hit { padding: 12px 14px; min-height: 44px; }
  .wis-chip { min-height: 36px; height: auto; padding: 6px 12px; }
  .wis-results { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

@media (min-width: 721px) {
  .wis-fab { display: none !important; }
}

@media print {
  .wis-root, .wis-fab, .wis-launch { display: none !important; }
}

.wis-idle-kicker { margin-top: 16px !important; }
.wis-root:not([hidden]) ~ .wis-fab { display: none !important; }
body:has(.wis-root:not([hidden])) .wis-fab,
body:has(.wis-root:not([hidden])) .float-top { visibility: hidden; }

/* Investigation masthead icon — only when the header field is hidden */
.mast-tools > .wis-launch { display: none; }
@media (max-width: 640px) {
  .mast-tools > .wis-launch {
    display: inline-flex; width: 42px; height: 42px; min-width: 42px;
    padding: 0; justify-content: center;
  }
  .mast-tools > .wis-launch .wis-launch-label,
  .mast-tools > .wis-launch kbd { display: none; }
  .mast-tools > .wis-launch .wis-launch-icon,
  .mast-tools > .wis-launch svg { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .is-search-target { animation: none; }
  .wis-hit { transition: none; }
}
.wis-more {
  display: inline-flex; align-items: center; min-height: 36px; margin: 4px 8px 10px;
  padding: 0 12px; border: 0; background: transparent; color: var(--ink-2, #463f36);
  font: 600 .82rem var(--font-ui, system-ui, sans-serif); cursor: pointer;
}
.wis-more:hover { color: var(--rubric, #9a2b1d); }


/* Hub header: replace the leftover native field with a single launch control.
   The wrap already has an input, icon, and ⌘K badge; JS prepends .wis-launch. */
.search-wrap.has-wis-launch,
.search-wrap:has(.wis-launch) {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.search-wrap.has-wis-launch:focus-within,
.search-wrap:has(.wis-launch):focus-within {
  border: 0;
  box-shadow: none;
  background: transparent;
}
.search-wrap.has-wis-launch > input,
.search-wrap.has-wis-launch > .search-icon,
.search-wrap.has-wis-launch > kbd,
.search-wrap:has(.wis-launch) > input,
.search-wrap:has(.wis-launch) > .search-icon,
.search-wrap:has(.wis-launch) > kbd {
  display: none !important;
}
.search-wrap > .wis-launch {
  width: 100%;
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
}
@media (max-width: 860px) {
  .search-wrap > .wis-launch kbd { display: none; }
}
@media (max-width: 720px) {
  /* Keep a labeled field in the hub header until the 640px icon breakpoint.
     The generic .wis-launch rule below this file's earlier 720px query
     would otherwise shrink the in-header button to an icon too soon. */
  .search-wrap > .wis-launch {
    width: 100%;
    padding: 0 12px;
    justify-content: flex-start;
  }
  .search-wrap > .wis-launch .wis-launch-label { display: inline; }
}
@media (max-width: 640px) {
  .search-wrap > .wis-launch {
    width: 100%;
    padding: 0;
    justify-content: center;
  }
  .search-wrap > .wis-launch .wis-launch-label,
  .search-wrap > .wis-launch kbd { display: none; }
  .search-wrap.has-wis-launch:focus-within,
  .search-wrap:has(.wis-launch):focus-within {
    position: relative;
    left: auto;
    right: auto;
    width: 42px;
    background: transparent;
  }
}
