/* Species type-ahead (#372). The panel belongs to the catalogue's search field
   on a desktop; on a phone the open list is the screen, because a dropdown
   under a field that the keyboard covers is not a list anyone can read. */

.species-suggest-box {
  position: relative;
  flex: 1;
  min-width: 0;
}

.species-suggest-esc {
  display: none;
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
}
.species-suggest-field input[aria-expanded="true"] ~ .species-suggest-esc { display: block; }

.species-suggest-cancel { display: none; }

/* The endpoint answers with up to twenty rows, which is taller than the fold
   under a field this high on the page. The panel keeps its own scroll so the
   page behind it stays where the reader left it. */
.species-suggest {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 8px);
  z-index: 30;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.species-suggest-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 7px 16px;
  border: 0;
  border-radius: var(--radius-thumbnail);
  background: transparent;
  color: var(--text-primary);
  text-align: start;
  cursor: pointer;
}
.species-suggest-row:hover,
.species-suggest-row[aria-selected="true"] {
  background: color-mix(in srgb, var(--surface-sky) 20%, var(--surface-page));
}
.species-suggest-name { flex: 1; min-width: 0; }
.species-suggest-pl { font-size: 14.5px; font-weight: 700; }
.species-suggest-la {
  margin-inline-start: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.species-suggest-note {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  color: var(--text-muted);
}
.species-suggest-group {
  flex: none;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--text-muted);
}

/* The return key is drawn on the highlighted row only: on every row it would
   stop saying which one Enter takes. */
.species-suggest-key {
  display: none;
  flex: none;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  font-size: 11px;
  color: var(--text-muted);
}
.species-suggest-row[aria-selected="true"] .species-suggest-key { display: grid; }

/* The line that says the answer was capped closes the result list and separates
   its keyboard hint from the rows above. */
.species-suggest-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 6px 8px 0;
  padding: 10px 10px 14px;
  background: var(--surface-card);
  border-top: 1px solid var(--border-subtle);
}
.species-suggest-foot p { margin: 0; font-size: 12.5px; color: var(--text-secondary); }
.species-suggest-enter { flex: none; font-weight: 600; color: var(--text-primary); }

.species-suggest-none { padding: 14px; }
.species-suggest-none-title { margin: 0; font-size: 14.5px; font-weight: 700; }
.species-suggest-none-text {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.species-suggest-none-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: 14px;
  padding: 0 18px;
  border-radius: var(--radius-control);
  background: var(--surface-warm);
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 899px) {
  .species-suggest-esc { display: none; }

  .species-suggest-box.is-suggesting {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    padding: 10px 12px 0;
    background: var(--surface-page);
  }
  .species-suggest-box.is-suggesting .species-suggest-field {
    min-height: 46px;
    background: var(--surface-card);
    border-color: var(--text-primary);
  }
  .species-suggest-box.is-suggesting .species-suggest-cancel {
    display: inline-flex;
    align-items: center;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-control);
    background: var(--surface-card);
    font-size: 13px;
    font-weight: 600;
  }
  .species-suggest-box.is-suggesting .species-suggest {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
    overflow-y: auto;
    padding: 8px 0 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .species-suggest-row { gap: 10px; min-height: 52px; padding: 6px 12px; }
  .species-suggest-pl { display: block; font-size: 14px; }
  .species-suggest-la { display: block; margin-inline-start: 0; font-size: 12px; }
  .species-suggest-note { font-size: 11px; }
  .species-suggest-group { font-size: 10.5px; }
  .species-suggest-row[aria-selected="true"] .species-suggest-key { display: none; }
  .species-suggest-foot {
    position: static;
    display: block;
    margin: 8px 12px 0;
    padding: 0;
    background: transparent;
    border-top: 0;
  }
  .species-suggest-enter { margin-top: 4px; }
  .species-suggest-none {
    padding: 20px 18px;
    border-radius: var(--radius-multiline);
    background: var(--surface-card);
  }
}
