/* Standalone tool and browse pages: shared layout (.tool-page) and the
 * batch query form.
 *
 * index.html loads every stylesheet on every page, so the batch query,
 * browse, sequence search, identifier conversion, enrichment, condition
 * comparison and profile search pages share the rules in the first part of
 * this file through their .tool-page wrapper. The pages use their own class
 * names (tool-section, tool-table, tool-note, tool-about) so that the protein
 * entry styles do not apply to them. Colours come from the design tokens in
 * styles.css :root.
 */

/* ---------- page, sections, text ---------- */

.tool-page {
  min-width: 0;
  max-width: 100%;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.tool-page > * { min-width: 0; }
.tool-page h2 {
  margin: 0 0 12px;
  padding: 0 0 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}
.tool-page h3 {
  margin: 18px 0 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}
.tool-section { margin: 0 0 32px; min-width: 0; }
.tool-intro { max-width: 88ch; margin: 0 0 20px; color: var(--ink); }
.tool-note { max-width: 100ch; margin: 6px 0; color: var(--ink-soft); font-size: 12.5px; }
.tool-caption,
.tool-legend { margin: 6px 0 0; color: var(--ink-soft); font-size: 12px; }
.tool-back { margin: 0 0 14px; font-size: 13px; }
.tool-warn { color: var(--orange); }
.tool-error { color: var(--red); }
.tool-page code { font-family: var(--mono); font-size: 12.5px; }

/* ---------- forms: labels above controls, one control height ---------- */

.tool-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 18px;
  align-items: start;
  min-width: 0;
}
.tool-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tool-field-wide { grid-column: 1 / -1; }
.tool-page .tool-field > label,
.tool-page .tool-label,
.tool-page .tool-group > legend {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.tool-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.tool-group > legend { margin: 0 0 6px; padding: 0; }
/* Inside a group the legend is the heading; field labels are plain. */
.tool-page .tool-group .tool-field > label { color: var(--ink-soft); font-weight: 400; }
.tool-group-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 12px;
}
.tool-hint { margin: 2px 0 0; color: var(--ink-soft); font-size: 12.5px; }

.tool-page input[type="text"],
.tool-page input[type="number"],
.tool-page input[type="search"],
.tool-page select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 32px;
  padding: 0 8px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
}
.tool-page textarea {
  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 64px;
  padding: 6px 8px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}
.tool-page input:focus,
.tool-page select:focus,
.tool-page textarea:focus {
  border-color: var(--teal);
  outline: 2px solid color-mix(in srgb, var(--teal) 30%, transparent);
  outline-offset: 0;
}
.tool-page input[type="checkbox"],
.tool-page input[type="radio"] { accent-color: var(--teal); }
.tool-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
}
.tool-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

/* ---------- buttons: secondary by default, primary for the main action ---------- */

.tool-page button {
  box-sizing: border-box;
  height: 32px;
  padding: 0 12px;
  color: var(--teal);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  line-height: 30px;
  white-space: nowrap;
  cursor: pointer;
}
.tool-page button:hover:not(:disabled) {
  color: var(--teal-dark);
  border-color: var(--teal);
  background: var(--surface);
}
.tool-page button:disabled { color: var(--ink-soft); opacity: 0.6; cursor: default; }
.tool-page button:focus-visible,
.tool-page a:focus-visible,
.tool-page summary:focus-visible,
.tool-page th[tabindex]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--teal) 30%, transparent);
  outline-offset: 1px;
}
.tool-page button.tool-primary {
  min-width: 96px;
  margin: 0;
  color: var(--surface);
  border-color: var(--teal);
  background: var(--teal);
  font-weight: 600;
}
.tool-page button.tool-primary:hover:not(:disabled) {
  color: var(--surface);
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}
/* Inline actions that read as links (examples, presets, toggles). */
.tool-page button.tool-link,
.tool-page button.text-button {
  height: auto;
  padding: 0;
  color: var(--teal);
  border: 0;
  background: none;
  font-size: 13px;
  line-height: 1.5;
}
.tool-page button.tool-link:hover:not(:disabled),
.tool-page button.text-button:hover:not(:disabled) {
  color: var(--teal-dark);
  background: none;
  text-decoration: underline;
}
.tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 14px 0 0;
}
.tool-status { color: var(--ink-soft); font-size: 13px; }
.tool-status.tool-error { color: var(--red); }
.tool-examples { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; font-size: 13px; }
.tool-examples > span:first-child { color: var(--ink-soft); }

/* A filter bar is one plain row of labelled controls. */
.tool-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 16px;
  margin: 0 0 12px;
}

/* ---------- tables ---------- */

.tool-scroll { max-width: 100%; overflow-x: auto; }
.tool-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}
.tool-table th,
.tool-table td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.tool-table th {
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  font-weight: 600;
  white-space: nowrap;
}
.tool-table td { border-bottom: 1px solid var(--line-soft); }
.tool-table th.num,
.tool-table td.num { text-align: right; white-space: nowrap; }
.tool-table th[data-sort-key],
.tool-table th[data-key] { cursor: pointer; user-select: none; }
.tool-table th[data-sort-key]:hover,
.tool-table th[data-key]:hover { color: var(--teal-dark); }
.tool-table th[aria-sort="ascending"]::after { content: " \25B4"; color: var(--teal); }
.tool-table th[aria-sort="descending"]::after { content: " \25BE"; color: var(--teal); }
.tool-table td.wrap { min-width: 260px; max-width: 520px; white-space: normal; }
.tool-table .muted,
.tool-table .na { color: var(--ink-soft); font-size: inherit; line-height: inherit; }
.tool-facts { width: auto; min-width: min(100%, 640px); }
.tool-facts th[scope="row"] {
  color: var(--ink);
  background: none;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 400;
  white-space: normal;
}
.tool-tablebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 13px;
}
.tool-tablebar p { margin: 0; }
.tool-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}
.call-yes { color: var(--ink); font-weight: 600; }
.call-no { color: var(--ink-soft); }

/* ---------- collapsed method text ---------- */

.tool-about { margin: 14px 0 0; color: var(--ink-soft); font-size: 13px; }
.tool-about > summary { width: fit-content; color: var(--teal); cursor: pointer; }
.tool-about > summary:hover { text-decoration: underline; }
.tool-about[open] > summary { margin-bottom: 6px; }
.tool-about p { max-width: 100ch; margin: 0 0 6px; }
.tool-about .tool-scroll { margin-top: 8px; }

/* ---------- charts ---------- */

.tool-chart { max-width: 100%; overflow-x: auto; margin: 6px 0 4px; }
.tool-chart svg { display: block; max-width: none; }
.tool-chart text { font-family: inherit; fill: var(--ink-soft); }

/* ---------- batch query ---------- */

.batch-page .batch-form { display: grid; gap: 18px; }
.batch-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px 28px;
}
.batch-page .batch-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  max-height: 140px;
  overflow-y: auto;
}
.batch-page .batch-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.batch-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.batch-results { margin-top: 24px; }
.batch-columns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin: 0 0 8px;
  font-size: 13px;
}
.batch-columns strong { color: var(--ink); font-weight: 600; }
.batch-columns label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.batch-table td { max-width: 320px; overflow-wrap: break-word; }
.batch-table a { color: var(--teal); }
.batch-table a:hover { text-decoration: underline; }
/* Names and terms wrap between words, never inside a word. */
.batch-table td.batch-text { min-width: 200px; }
.batch-table thead th { position: sticky; top: 0; z-index: 1; }
/* The gene ID stays visible while the table scrolls sideways. */
.batch-table td:nth-child(1),
.batch-table th:nth-child(1) { position: sticky; left: 0; z-index: 2; white-space: nowrap; }
.batch-table td:nth-child(1) { background: var(--surface); }
.batch-table thead th:nth-child(1) { z-index: 3; background: var(--surface-soft); }
.batch-table th.batch-sorted { color: var(--teal-dark); }

/* Protein type criterion: label select and evidence classes in one row. */
.batch-page .batch-type-fields { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 24px; }
.batch-page .batch-type-fields .tool-field:first-child { flex: 1 1 26em; max-width: 44em; }
.batch-page .batch-type-fields select { width: 100%; }
.batch-page .batch-type-fields .tool-field:last-child { flex: 2 1 30em; }
.batch-page .batch-type-evidence { max-height: none; gap: 4px 16px; }
