/* ============ ADVANCED HUNTING PAGE — builds on css/styles.css theme tokens ============ */
body { display: flex; flex-direction: column; min-height: 100vh; }
.hunt-main { flex: 1; padding: 32px 0 64px; }

/* ---- page header ---- */
.page-head { margin-bottom: 22px; }
.page-head h1 {
  font-size: 32px; font-weight: 800; letter-spacing: -0.025em;
  background: var(--accent-gradient);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.page-head p { font-size: 14px; color: var(--text-muted); margin-top: 8px; max-width: 760px; }

/* ============ QUERY BUILDER ============ */
.hunt-builder {
  position: relative;
  background:
    radial-gradient(90% 100% at 0% 0%, rgba(253, 29, 96, 0.06), transparent 48%),
    radial-gradient(70% 90% at 100% 0%, rgba(255, 168, 7, 0.05), transparent 52%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px 24px 22px;
  margin-bottom: 28px;
  box-shadow: 0 24px 60px -42px rgba(0, 0, 0, 0.85);
}
/* gradient hairline along the top edge, like the active nav link */
.hunt-builder::before {
  content: ""; position: absolute;
  top: -1px; left: 28px; right: 28px; height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(253, 29, 96, 0.55), rgba(255, 168, 7, 0.55), transparent);
}

/* ---- builder header ---- */
.hb-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 18px;
}
.hb-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 700; color: var(--text);
}
.hb-title svg { color: var(--brand-bright); filter: drop-shadow(0 0 10px rgba(255, 168, 7, 0.45)); }
.hb-count {
  min-width: 22px; height: 22px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-subtle);
  border: 1px solid var(--border);
  transition: 150ms;
}
/* JS adds .on while at least one complete filter is set */
.hb-count.on {
  background: var(--brand-dim); color: var(--brand-bright);
  border-color: rgba(255, 168, 7, 0.3);
}
.hb-clear {
  padding: 7px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-subtle);
  transition: 150ms;
}
.hb-clear:hover { color: var(--danger-bright); background: var(--danger-bg); }

/* ---- filter rows ---- */
.hb-rows { display: flex; flex-direction: column; gap: 22px; }
.hx-row {
  position: relative;
  display: grid;
  grid-template-areas: "filter value remove";
  grid-template-columns: minmax(190px, 320px) minmax(0, 1fr) 38px;
  gap: 10px; align-items: center;
  animation: hx-in 180ms ease-out;
}
@keyframes hx-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
/* every extra condition narrows the hunt — make the AND explicit */
.hx-row:not(:first-child)::before {
  content: "AND";
  position: absolute; top: -19px; left: 14px;
  padding: 1px 7px; border-radius: 5px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--brand-dim); color: var(--brand-bright);
  border: 1px solid rgba(255, 168, 7, 0.2);
  pointer-events: none;
}
.hx-cell-filter { grid-area: filter; min-width: 0; }
.hx-cell-value  { grid-area: value;  min-width: 0; }
.hx-remove      { grid-area: remove; }

/* ---- controls ---- */
.hx-filter, .hx-val, .hb-mod select, .hb-mod input {
  width: 100%;
  padding: 10px 13px;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  outline: none;
  color-scheme: dark;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
select.hx-filter, select.hx-val, .hb-mod select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A7AABB' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  cursor: pointer;
}
.hx-filter option, .hx-val option, .hb-mod option { background: var(--surface-2); color: var(--text); }
.hx-filter optgroup { background: var(--surface); color: var(--text-subtle); font-style: normal; }
.hx-filter:hover, .hx-val:hover, .hb-mod select:hover, .hb-mod input:hover { border-color: var(--border-strong); }
.hx-filter:focus, .hx-val:focus, .hb-mod select:focus, .hb-mod input:focus {
  border-color: rgba(253, 29, 96, 0.45);
  box-shadow: 0 0 0 3px rgba(253, 29, 96, 0.07);
}
.hx-val::placeholder, .hb-mod input::placeholder { color: var(--text-subtle); }

.hx-remove {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-subtle);
  border: 1px solid transparent;
  transition: 150ms;
}
.hx-remove:hover {
  color: var(--danger-bright);
  background: var(--danger-bg);
  border-color: rgba(253, 29, 96, 0.25);
}

/* ---- actions row ---- */
.hb-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-top: 18px;
}
.hb-add {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted); font-size: 13.5px; font-weight: 600;
  transition: 150ms;
}
.hb-add:hover {
  color: var(--brand-bright);
  border-color: rgba(255, 168, 7, 0.45);
  background: rgba(255, 168, 7, 0.05);
}
.hb-add:disabled { opacity: 0.4; cursor: not-allowed; }

.hb-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-left: auto; }
.hb-mod {
  display: flex; align-items: center; gap: 9px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-subtle);
}
.hb-mod select, .hb-mod input { width: auto; padding: 8px 12px; font-size: 13px; }
.hb-mod select { padding-right: 32px; }
.hb-mod input[type="number"] { width: 76px; font-family: var(--mono); }
/* similarity distance — only relevant (and shown) when a similarity filter is set */
.hb-mod-distance { display: none; }
.hb-mod-distance.show { display: flex; animation: hx-in 180ms ease-out; }
.hb-run { padding: 11px 26px; font-size: 14.5px; }

/* ---- quick-start presets ---- */
.hb-presets {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border-faint);
}
.hb-presets-label {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-subtle);
  margin-right: 2px;
}
.hb-preset {
  padding: 7px 13px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: 150ms;
}
.hb-preset:hover {
  color: var(--brand-bright);
  border-color: rgba(255, 168, 7, 0.4);
  background: var(--brand-dim);
  transform: translateY(-1px);
}

/* ============ RESULTS ============ */

/* intro (no query yet) + no-matches empty state */
.hunt-intro, .hunt-empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 64px 24px;
}
.hunt-intro {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(60% 70% at 50% 0%, rgba(255, 168, 7, 0.05), transparent 60%),
    var(--bg-soft);
}
.hunt-intro svg {
  color: var(--brand-bright);
  filter: drop-shadow(0 0 18px rgba(255, 168, 7, 0.35));
  margin-bottom: 16px;
}
.hunt-empty svg { color: var(--text-subtle); margin-bottom: 16px; }
.hunt-intro .big, .hunt-empty .big {
  font-size: 17px; font-weight: 700; color: var(--text);
  margin-bottom: 6px;
}
.hunt-intro .small, .hunt-empty .small {
  font-size: 13.5px; color: var(--text-muted);
  max-width: 460px;
}
.hunt-empty { display: none; }
.hunt-empty.show { display: flex; }

/* upstream / validation error */
.hunt-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 16px; border-radius: 12px;
  background: var(--danger-bg); color: var(--danger-bright);
  border: 1px solid rgba(253, 29, 96, 0.25);
  font-size: 13.5px; line-height: 1.5;
}
.hunt-alert svg { flex-shrink: 0; margin-top: 1px; }

/* ---- results header ---- */
.results-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 12px;
}
.results-count { font-size: 14px; color: var(--text-muted); }
.results-count strong { color: var(--text); font-weight: 700; font-size: 16px; }

/* ---- applied-filter chips (each removable) ---- */
.hunt-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.hchip {
  display: inline-flex; align-items: stretch; overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
}
.hchip-k {
  display: flex; align-items: center;
  padding: 5px 9px;
  background: var(--surface-2); color: var(--text-subtle);
  font-weight: 600; white-space: nowrap;
  border-right: 1px solid var(--border-faint);
}
.hchip-v {
  display: flex; align-items: center;
  padding: 5px 10px;
  color: var(--brand-bright);
  font-family: var(--mono); font-size: 12px;
  max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hchip-x {
  display: flex; align-items: center;
  padding: 5px 9px;
  color: var(--text-subtle);
  border-left: 1px solid var(--border-faint);
  font-size: 15px; line-height: 1;
  transition: 130ms;
}
.hchip-x:hover { color: var(--danger-bright); background: var(--danger-bg); }
.hchip-clear {
  padding: 5px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-subtle);
  transition: 130ms;
}
.hchip-clear:hover { color: var(--danger-bright); background: var(--danger-bg); }

/* ---- result rows ---- */
.results-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.hr-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 15px; align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--border-faint);
  transition: background-color 140ms ease;
}
.hr-row:first-child { border-top: none; }
a.hr-row:hover { background: var(--surface-2); }
.hr-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.hr-icon.bad {
  background: var(--danger-bg); border-color: rgba(253, 29, 96, 0.22);
  color: var(--danger-bright);
  box-shadow: 0 0 16px -6px rgba(253, 29, 96, 0.55);
}
.hr-icon.warn {
  background: var(--warning-bg); border-color: rgba(255, 168, 7, 0.24);
  color: var(--brand-bright);
  box-shadow: 0 0 16px -6px rgba(255, 168, 7, 0.45);
}
.hr-icon.ok {
  background: var(--success-bg); border-color: rgba(77, 216, 156, 0.22);
  color: var(--success);
}
.hr-body { min-width: 0; }
.hr-host {
  font-family: var(--mono); font-size: 14px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hr-host.bad { color: var(--danger-bright); }
.hr-dim { color: var(--text-subtle); font-style: italic; }
.hr-title {
  font-size: 12.5px; color: var(--text-muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hr-meta {
  font-family: var(--mono); font-size: 11.5px;
  color: var(--text-subtle); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hr-side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.hr-brand {
  padding: 3px 9px; border-radius: 5px;
  font-size: 11.5px; font-weight: 700;
  background: var(--brand-dim); color: var(--brand-bright);
  border: 1px solid rgba(255, 168, 7, 0.22);
  max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hr-score {
  width: 32px; text-align: right;
  font-family: var(--mono); font-size: 15px; font-weight: 700;
}
.hr-score.bad  { color: var(--danger-bright); }
.hr-score.warn { color: var(--brand-bright); }
.hr-score.ok   { color: var(--success); }
.hr-go { color: var(--text-subtle); transition: transform 150ms ease, color 150ms ease; }
a.hr-row:hover .hr-go { color: var(--text-muted); transform: translateX(3px); }

/* ---- keyset pager ---- */
.hunt-pager { display: flex; justify-content: center; margin-top: 20px; }

/* ---- responsive ---- */
@media (max-width: 860px) {
  .hx-row {
    grid-template-areas:
      "filter remove"
      "value  value";
    grid-template-columns: minmax(0, 1fr) 38px;
  }
  .hb-right { margin-left: 0; width: 100%; justify-content: space-between; }
}
@media (max-width: 640px) {
  .hunt-builder { padding: 18px 16px; }
  .hb-run { flex: 1; justify-content: center; }
  .results-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .hr-row { grid-template-columns: 40px minmax(0, 1fr); row-gap: 10px; }
  .hr-icon { grid-row: span 2; align-self: start; }
  .hr-side { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; gap: 10px 14px; }
  .hr-score { width: auto; text-align: left; }
  .hr-go { display: none; }
  .hchip-v { max-width: 160px; }
}
