/* ============================================================================
 * oak-search.css — styles for the OAK dashboard entity search.
 * Themed against the dashboard's existing CSS variables (with safe fallbacks)
 * so it tracks light/dark automatically. Shipped via the nginx _overrides layer.
 * ========================================================================== */

#oak-search {
  position: relative;
  flex: 1 1 320px;
  min-width: 0;
  max-width: 460px;
  margin: 0 18px;
  z-index: 9000;
  font: 400 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

/* visually-hidden live region for screen-reader result announcements */
.oks-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.oks-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  height: 40px;
  border-radius: 11px;
  background: var(--panel2, #141a2e);
  border: 1px solid var(--border, rgba(148, 163, 196, .18));
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
#oak-search.oks-open .oks-field,
.oks-field:focus-within {
  border-color: var(--accent, #4ea1ff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #4ea1ff) 18%, transparent);
  background: var(--panel, #0e1424);
}
.oks-ic { width: 17px; height: 17px; color: var(--muted, #9aa3c4); flex: none; }
#oks-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink, #eef2ff);
  font: inherit;
}
#oks-input::placeholder { color: var(--muted, #9aa3c4); opacity: .85; }
#oks-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.oks-kbd {
  flex: none;
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted, #9aa3c4);
  background: color-mix(in srgb, var(--muted, #9aa3c4) 14%, transparent);
  border: 1px solid var(--border, rgba(148, 163, 196, .18));
  border-radius: 6px;
  padding: 3px 6px;
}
@media (hover: none) { .oks-kbd { display: none; } }

/* ---- dropdown panel ---- */
.oks-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(64vh, 520px);
  overflow-y: auto;
  background: var(--panel, #0e1424);
  border: 1px solid var(--border, rgba(148, 163, 196, .22));
  border-radius: 13px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  padding: 6px;
  -webkit-overflow-scrolling: touch;
}
.oks-panel[hidden] { display: none; }

.oks-group {
  font: 700 10.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted, #9aa3c4);
  padding: 12px 10px 6px;
}
.oks-group:first-child { padding-top: 6px; }

.oks-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.oks-row:hover, .oks-row.active {
  background: color-mix(in srgb, var(--accent, #4ea1ff) 14%, transparent);
}
.oks-tag {
  flex: none;
  font: 700 9.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--bg, #0b1020);
  white-space: nowrap;
}
.oks-tag-a { background: #4ea1ff; }
.oks-tag-i { background: #5eead4; }
.oks-tag-s { background: #c4b5fd; }
.oks-tag-d { background: #fbbf77; }
.oks-tag-m { background: #f0a6c6; }

/* dissertation-title rows: let the (long) title wrap to two lines */
.oks-row-m { align-items: flex-start; }
.oks-row-m .oks-tag { margin-top: 2px; }
.oks-row-m .oks-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.oks-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.oks-name {
  color: var(--ink, #eef2ff);
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.oks-ctx {
  color: var(--muted, #9aa3c4);
  font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.oks-src {
  flex: none;
  color: var(--muted, #9aa3c4);
  text-decoration: none;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 6px;
}
.oks-src:hover { color: var(--accent, #4ea1ff); background: color-mix(in srgb, var(--accent, #4ea1ff) 18%, transparent); }

/* ---- messages / empty state ---- */
.oks-msg { padding: 18px 14px; color: var(--muted, #9aa3c4); text-align: center; }
.oks-empty { padding: 22px 16px; text-align: center; }
.oks-empty-q { color: var(--ink, #eef2ff); font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.oks-empty-t { color: var(--muted, #9aa3c4); margin-bottom: 4px; }
.oks-empty-h { color: var(--muted, #9aa3c4); font-size: 12.5px; opacity: .8; }

/* ---- floating search when the header scrolls away ---- */
body.oks-float #oak-search {
  position: fixed;
  top: 12px;
  right: 16px;
  left: auto;
  width: min(380px, calc(100vw - 32px));
  max-width: none;
  margin: 0;
  z-index: 9500;
  animation: oks-float-in .18s cubic-bezier(.16, 1, .3, 1);
}
body.oks-float #oak-search .oks-field {
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
@keyframes oks-float-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- mobile full-screen overlay (wins over the float pill when focused) ---- */
@media (max-width: 640px) {
  body.oks-mobile #oak-search {
    position: fixed;
    inset: 0;
    width: auto;
    z-index: 100000;
    margin: 0;
    max-width: none;
    background: var(--bg, #0b1020);
    padding: 12px;
    display: flex !important;
    flex-direction: column;
    animation: none;
  }
  body.oks-mobile .oks-field { height: 46px; }
  body.oks-mobile .oks-panel {
    position: static;
    margin-top: 10px;
    max-height: none;
    flex: 1 1 auto;
    border: 0;
    box-shadow: none;
    background: transparent;
    padding: 0;
  }
  body.oks-mobile { overflow: hidden; }
}
