/* ──────────────────────────────────────────────────────────────
   PRIMORA: the Atlas page (atlas.html) and the charts of
   shared/atlasplots.js. Loaded after ui.css, on that page only.
   Every selector hangs on an at-* or ap-* class.
   ────────────────────────────────────────────────────────────── */

.at-head { padding-bottom: 0; border-bottom: 0; margin-bottom: 18px; }
.at-head .pm-lede { max-width: 820px; margin-top: 12px; }
.pm-shell.at { padding-top: 34px; }
.at-strips { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 16px 0 0; min-height: 17px; }

/* ── What to look up ── */
.at-search { padding: 18px 18px 16px; }
.at-modes { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 14px; background: var(--paper-2); border-radius: 999px; }
.at-mode {
  min-height: 32px; padding: 6px 16px; border-radius: 999px;
  font-family: var(--f-sans); font-size: 13px; font-weight: 600; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.at-mode:hover { color: var(--ink); }
.at-mode[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 34, 46, 0.14); }
.at-mode:focus-visible, .at-idchip:focus-visible, .at-gene-link:focus-visible, .at-suggest__item:focus-visible { outline: 2px solid var(--signal-fg); outline-offset: 2px; }

.at-form { display: flex; gap: 10px; align-items: stretch; }
.at-form[hidden] { display: none; }
.at-form--set { flex-wrap: wrap; }
.at-form--set .at-set-input { flex: 1 1 320px; min-height: 46px; font-family: var(--f-mono); font-size: 13px; }
.at-form--set .at-examples { flex-basis: 100%; }
.at-combo { position: relative; flex: 1 1 auto; min-width: 0; }
.at-combo > svg { position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--muted); pointer-events: none; }
.at-input {
  width: 100%; height: 48px; padding: 0 16px 0 46px;
  font: 500 17px var(--f-sans); letter-spacing: 0.01em; color: var(--ink);
  background: var(--card); border: 1px solid var(--pm-edge); border-radius: 999px;
  transition: border-color .15s, box-shadow .15s;
}
.at-input::placeholder { color: var(--muted); font-weight: 400; }
.at-input::-webkit-search-cancel-button { display: none; }
.at-input:hover { border-color: var(--ink); }
.at-input:focus { outline: 2px solid transparent; border-color: var(--signal-fg); box-shadow: var(--pm-ring); }
.at-form .pm-btn { min-height: 48px; padding-left: 26px; padding-right: 26px; }

.at-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  margin: 0; padding: 6px; list-style: none;
  background: var(--card); border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow-2);
  max-height: 340px; overflow-y: auto;
}
.at-suggest__item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 14.5px; }
.at-suggest__item:hover, .at-suggest__item.is-active { background: var(--signal-bg); }
.at-suggest__name { font-weight: 600; color: var(--ink); margin-right: auto; }

.at-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.at-examples .pm-filter { min-height: 28px; padding: 5px 12px; font-size: 11px; text-transform: none; letter-spacing: 0.04em; }

/* identity picker */
.at-idpicker { display: grid; gap: 8px; }
.at-idpicker[hidden] { display: none; }
.at-idgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.at-idgroup__label { flex: none; width: 118px; font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-strong); }
.at-idchip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 5px 12px;
  font-size: 13px; font-weight: 500; color: var(--ink);
  background: var(--card); border: 1px solid var(--pm-line); border-radius: 999px;
  transition: border-color .15s, background .15s;
}
.at-idchip:hover { border-color: var(--ink); }
.at-idchip[aria-pressed="true"] { background: var(--pm-teal); border-color: var(--pm-teal); color: #fff; }
.at-idchip__dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.at-idchip[aria-pressed="true"] .at-idchip__dot { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85); }

.at-status { margin-top: 14px; }
.at-status:empty { margin-top: 0; }
.at-body { margin-top: 22px; transition: opacity .15s; }
.at-body.is-stale { opacity: 0.5; pointer-events: none; }   /* a new answer is on its way: the frame stays */
.at-loading { display: flex; align-items: center; gap: 10px; padding: 28px 4px; font-size: 14px; color: var(--muted-strong); }

.at-welcome { display: grid; gap: 22px; padding: 8px 4px 0; max-width: 760px; }
.at-welcome__text { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); max-width: 640px; }

/* ── A gene (or an identity): its name and what is known at a glance ── */
.at-genehead { display: grid; gap: 14px 40px; align-items: end; padding: 0 2px 18px; }
.at-symbol { display: flex; align-items: center; gap: 12px; font-family: var(--f-display); font-weight: 400; font-size: clamp(38px, 5vw, 58px); line-height: 1; letter-spacing: -0.01em; color: var(--ink); overflow-wrap: anywhere; }
.at-symbol__dot { width: 16px; height: 16px; border-radius: 5px; flex: none; }
.at-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.at-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.04em; white-space: nowrap;
  color: var(--ink-2); background: var(--card); border: 1px solid var(--pm-line);
}
.at-badge--tf { color: var(--signal-fg); background: var(--signal-bg); border-color: #C3DCE9; }
.at-badge--program { color: var(--ok-fg); background: var(--ok-bg); border-color: #B7DACF; }
.at-badge--age { color: var(--coral-fg); background: var(--coral-bg); border-color: #EBC9BD; }

.at-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 28px; margin: 0; }
.at-facts > div { border-top: 1px solid var(--pm-line); padding-top: 9px; min-width: 0; }
.at-facts dt { font-family: var(--f-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-strong); }
.at-facts dd { margin: 5px 0 0; font-size: 17px; font-weight: 600; line-height: 1.25; letter-spacing: -0.005em; color: var(--ink); overflow-wrap: anywhere; }
.at-facts dd.at-facts__sub { margin-top: 2px; font-size: 12.5px; font-weight: 400; color: var(--ink-2); }
.at-facts--row { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px 22px; margin-bottom: 18px; }
.at-facts--row dd { font-size: 14.5px; }

.at-tabs { margin: 2px 0 20px; }
.at-tabs .pm-tab:disabled { color: var(--pm-edge); cursor: not-allowed; }

/* ── Controls: one row above what they scope ── */
.at-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 22px; margin-bottom: 14px; }
.at-controls--tight { margin-bottom: 12px; }
.at-ctl { display: grid; gap: 5px; }
.at-ctl__label { font-family: var(--f-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-strong); }
.at-select { min-height: 40px; height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; border-radius: 999px; padding-left: 16px; min-width: 180px; }
.at-ctl .pm-seg__item { font-family: var(--f-sans); font-size: 13px; font-weight: 600; letter-spacing: 0; }
.at-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.at-tools--below { margin: 14px 0 0; }

/* ── Cards that hold a chart ── */
.at-card { overflow: hidden; }
.at-card + .at-card, .at-card + .at-method, .at-figs { margin-top: 16px; }
.at-card__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 24px; align-items: end; padding: 18px 20px 0; }
.at-card__title { grid-column: 1; font-family: var(--f-sans); font-size: 15px; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; color: var(--ink); margin: 0; }
.at-card__note { grid-column: 1; margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted-strong); max-width: 780px; }
.at-card__head .at-ctl { grid-column: 2; grid-row: 1 / span 2; }
.at-card__body { padding: 14px 20px 20px; min-width: 0; }
.at-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 2px; min-width: 0; }
/* A chart with what explains it beside it; underneath it where there is no room. */
.at-chartrow { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 40px; }
.at-chartrow > .at-scroll { flex: 0 1 auto; max-width: 100%; }
.at-chartside { flex: 1 1 240px; max-width: 440px; padding-top: 20px; }
.at-chartside .at-foot { margin-top: 14px; }
.at-twin { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; align-items: start; }
.at-legendrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; margin: 6px 0 10px; }
.at-legend-note { font-size: 12px; color: var(--muted-strong); }
.at-foot { margin: 10px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--muted-strong); max-width: 780px; }
.at-empty { margin: 4px 0; font-size: 14px; line-height: 1.55; color: var(--ink-2); max-width: 640px; }
.at-method { margin: 16px 2px 0; padding: 12px 16px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); background: var(--paper-2); border-radius: var(--radius-sm); max-width: none; }
.at-method strong { color: var(--ink); font-weight: 600; }
.at-method code { font-size: 12px; padding: 1px 6px; background: var(--card); border: 1px solid var(--rule); border-radius: 5px; }
.at-sub { font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-strong); margin: 0 0 8px; }
.at-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 32px; align-items: start; }
.at-detail__wide { grid-column: 1 / -1; min-width: 0; }
.at-detail > div { min-width: 0; }
.at-coupled { margin: 0 0 8px; font-size: 13px; line-height: 1.7; }
.at-coupled__label { display: block; font-size: 12px; color: var(--muted-strong); }
.at-gene-link { font-family: var(--f-mono); font-size: 12.5px; font-weight: 500; color: var(--signal-fg); text-decoration: underline; text-decoration-color: #B5CFE0; text-underline-offset: 3px; }
.at-gene-link:hover { color: var(--coral-fg); text-decoration-color: var(--coral); }
.at-table { margin-top: 2px; overflow-x: auto; }
.at-table .pm-table { font-size: 13px; }
@media (min-width: 641px) {
  /* Short cells of names and numbers: a cell keeps to one line and the table scrolls if it must. */
  .at-table .pm-table td, .at-table .pm-table th { padding: 8px 12px; white-space: nowrap; overflow-wrap: normal; }
  .at-table .pm-table td:first-child, .at-table .pm-table th:first-child { padding-left: 14px; }
}

/* feature plots */
.at-features { display: flex; flex-wrap: wrap; gap: 16px; }
.at-feature { margin: 0; }
.at-feature figcaption { display: grid; gap: 1px; margin-bottom: 6px; }
.at-feature figcaption strong { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.at-feature figcaption span { font-size: 12px; color: var(--muted-strong); font-variant-numeric: tabular-nums; }
.ap-feature__canvas { display: block; border: 1px solid var(--rule); border-radius: 10px; background: #fff; max-width: 100%; height: auto; cursor: crosshair; }

/* publication figures */
.at-figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.at-fig { padding: 18px 20px; }
.at-fig__head { display: grid; gap: 4px; }
.at-fig__preview { margin-top: 12px; }
.at-fig__preview:empty { margin-top: 0; }
.at-fig__img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 8px; }

/* identity explorer */
.at-idgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; align-items: start; }
.at-idgrid > .at-card { grid-column: span 2; }
.at-idgrid > .at-idgrid__half { grid-column: span 3; }
.at-idgrid .at-card__head { padding-left: 20px; padding-right: 20px; }
.at-idgrid .at-card__body { padding-left: 20px; padding-right: 20px; }
.at-idgrid .at-card + .at-card { margin-top: 0; }
.at-idgrid > .at-idgrid__wide { grid-column: 1 / -1; }

/* ── Charts (shared/atlasplots.js) ── */
.ap-svg { display: block; max-width: none; overflow: visible; }
.ap-svg text { font-variant-numeric: tabular-nums; }
.ap-row:hover > rect:first-child { fill: #F2F5F4; }
.ap-row.is-selected:hover > rect:first-child { fill: #E6EFF5; }
.ap-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.ap-legend__item { display: inline-flex; align-items: center; gap: 7px; }
.ap-legend__key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ap-legend__key--dot { border-radius: 50%; }
.ap-tip {
  position: fixed; z-index: 90; display: none; pointer-events: none;
  min-width: 150px; max-width: 320px; padding: 9px 12px;
  background: var(--night-2); color: var(--on-night); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(10, 21, 31, 0.28);
  font-family: var(--f-sans); font-size: 12px; line-height: 1.45;
}
.ap-tip__title { font-weight: 600; margin-bottom: 4px; }
.ap-tip__row { display: flex; align-items: baseline; gap: 8px; }
.ap-tip__key { width: 10px; height: 3px; border-radius: 2px; flex: none; align-self: center; }
.ap-tip__label { color: var(--on-night-2); margin-right: auto; }
.ap-tip__value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ap-tip__note { margin-top: 5px; color: var(--on-night-2); }

@media (min-width: 641px) {
  .at-search { padding: 22px 26px 20px; }
  .at-card__head { padding: 20px 26px 0; }
  .at-card__body { padding: 14px 26px 24px; }
}
@media (min-width: 901px) {
  .at-genehead { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
}
@media (max-width: 1000px) {
  .at-idgrid { grid-template-columns: 1fr; }
  .at-idgrid > .at-card, .at-idgrid > .at-idgrid__half { grid-column: 1 / -1; }
  .at-figs, .at-detail, .at-twin { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .at-form { flex-wrap: wrap; }
  .at-form .pm-btn { width: 100%; }
  .at-idgroup__label { width: 100%; }
  .at-tools { margin-left: 0; }
  .at-select { min-width: 0; width: 100%; }
  .at-ctl { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .at-body { transition: none; } }
