/* ==========================================================================
   MSCinteract · Interaction: Immune Cells

   Two columns: the settings on the left, the data on the right.
   ========================================================================== */

.ii {
  display: grid;
  grid-template-columns: minmax(258px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* ---------- left column: the settings ---------- */

/* the sidebar is a plain column: it holds two cards and sticks to the top of
   the page while the whole column fits into the viewport */
.ii-side {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* the card carries its own frame: the class panel brings the colours, this
   one brings the inner layout */
.ii-side__card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.ii-side__head { display: flex; flex-direction: column; gap: 8px; }

.ii-side__title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.ii-side__sub {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

/* the mode and the direction share the first card, each under its small label */
.ii-side__controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.ii-side__control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ii-side__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* the words under the direction button */
.ii-direction__text { display: flex; flex-direction: column; gap: 3px; }

.ii-direction__title {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}

.ii-direction__hint {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- right column: the data ---------- */

.ii-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- the direction button ---------- */

/* the frame, the colours and the hover of the direction button are the ones of
   the tabs of the site header: a soft track, a thin border, and a track that
   lightens under the pointer without moving */
.ii-toggle {
  position: relative;
  flex: none;
  width: 116px;
  height: 60px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--bg-soft);
  cursor: pointer;
  overflow: hidden;
  transition: background-color .15s ease, border-color .15s ease;
}

.ii-toggle:hover {
  background-image: linear-gradient(rgba(255, 255, 255, .7), rgba(255, 255, 255, .7));
}

.ii-toggle:active { transform: translateY(0) scale(.97); }

.ii-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ii-toggle__icon {
  position: absolute;
  top: 8px;
  left: 10px;
  width: 96px;
  height: 44px;
  display: block;
  pointer-events: none;
  transition: opacity .3s ease, transform .4s cubic-bezier(.34, 1.28, .64, 1);
}

/* the active icon is on top, the other one slides away */
.ii-toggle[data-dir="msc-to-immune"] .ii-toggle__icon--to-immune { opacity: 1; transform: none; }
.ii-toggle[data-dir="msc-to-immune"] .ii-toggle__icon--to-msc { opacity: 0; transform: translateX(14px) scale(.88); }
.ii-toggle[data-dir="immune-to-msc"] .ii-toggle__icon--to-msc { opacity: 1; transform: none; }
.ii-toggle[data-dir="immune-to-msc"] .ii-toggle__icon--to-immune { opacity: 0; transform: translateX(-14px) scale(.88); }

/* the arrow nudges to the right: it always points at the target */
.ii-arrow {
  transform-box: fill-box;
  transform-origin: center;
}

.ii-arrow--right { animation: ii-nudge-right 1.7s ease-in-out infinite; }

@keyframes ii-nudge-right {
  0%, 100% { transform: translateX(-1.4px); }
  50% { transform: translateX(1.4px); }
}

@media (prefers-reduced-motion: reduce) {
  .ii-toggle,
  .ii-toggle__icon { transition: none; }
  .ii-arrow { animation: none; }
}

/* ---------- the dot plot ---------- */

.ii-plot { display: flex; flex-direction: column; gap: 6px; }

.ii-plot__svg { display: block; overflow: visible; }

.ii-plot__gene {
  font-size: 11px;
  font-weight: 600;
  fill: var(--ink-soft);
}

/* the two lists of the marker file have their own colour */
.ii-plot__gene--top { fill: #a9631f; }
.ii-plot__gene--unique { fill: #0b7d74; }

.ii-dot { cursor: pointer; transition: r .12s ease; }
.ii-dot--other:hover { r: 5.2; fill: #8fa0c0; }
.ii-dot--selected:hover { r: 6.4; }

.ii-dot__value {
  font-size: 10.5px;
  font-weight: 650;
  pointer-events: none;
}

.ii-plot__missing {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ---------- the bubble plot of the partners ---------- */

.ii-bubble { display: flex; flex-direction: column; gap: 6px; }

/* one bubble: the partners of one gene in one immune cell */
.ii-bubble__cell { cursor: pointer; transition: opacity .12s ease; }
.ii-bubble__cell:hover { opacity: .74; stroke: var(--ink); stroke-width: 1.2; }

/* a cell in which nothing is expressed: a dot, and no tooltip */
.ii-bubble__cell--zero { cursor: default; }
.ii-bubble__cell--zero:hover { opacity: 1; stroke: none; }

/* the name of an immune cell: it stands above its column, and hovering it
   gives the full name of the cell */
.ii-bubble__cell-label {
  font-size: 10.5px;
  fill: var(--ink-soft);
  cursor: help;
}
.ii-bubble__cell-label:hover { fill: var(--ink); }

/* the two legends: the sizes and the colours */
.ii-bubble__legend {
  display: inline-block;
  vertical-align: middle;
  overflow: visible;
  margin-right: 2px;
}
.ii-bubble__legend-label { font-size: 9.5px; fill: var(--muted); }

/* the note at the bottom of the tooltip */
.tooltip .ii-note {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

/* the list of partners inside the tooltip */
.tooltip .ii-tt__list {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  color: #cfd9f2;
  word-break: break-word;
}

/* the name of a gene in a plot: hovering it shows its partners */
.ii-gene-hover { cursor: help; }
.ii-gene-hover:hover { text-decoration: underline; }

/* ---------- the legend ---------- */

.ii-legend { display: inline-flex; align-items: center; gap: 6px; }

.ii-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: #b4bfd4;
}

.ii-legend__dot--selected {
  background: var(--accent);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(47, 109, 246, .35);
}

/* the legend shows the gene names in the colour they have on the axis;
   the generic rule of .chart-legend would turn every <i> into a 10px square,
   so the chips of the two lists need their own size */
.chart-legend .ii-legend__gene {
  width: auto;
  height: auto;
  margin-right: 0;
  border-radius: 5px;
  padding: 1px 6px;
  font-style: normal;
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: .01em;
  vertical-align: 1px;
}

.chart-legend .ii-legend__gene--top { background: #fdf1e2; color: #a9631f; }
.chart-legend .ii-legend__gene--unique { background: #e2f7f4; color: #0b7d74; }

/* ---------- the two modes of the tab ---------- */

/* the mode switch uses the tabs of the site header (.tabs / .tab in base.css).
   It keeps the width of its buttons instead of stretching to the card: an
   align-self of flex-start stops the column from making it full width, and the
   wrap keeps the two buttons on separate lines in a narrow card */
.ii-modes {
  flex-wrap: wrap;
  align-self: flex-start;
  max-width: 100%;
}

/* ---------- the comparison mode of the bubble plot ---------- */

/* the pale band behind the bubbles of one row: it takes the colour of the
   group the gene belongs to (common, only in one of the two conditions) */
.ii-bubble__band { pointer-events: none; }

/* the bar of one group of genes, in the left margin: it runs along the rows of
   the group and takes the colour of the group */
.ii-bubble__group-bar { pointer-events: none; }

/* the name of the group, written along its bar */
.ii-bubble__group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  pointer-events: none;
}

/* ---------- the interaction partners ---------- */

.ii-partners { display: flex; flex-direction: column; gap: 14px; }

/* the counts of the card */
.ii-partners__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 11.5px;
  color: var(--muted);
}

.ii-partners__stats .is-warn { color: #a9631f; }

.ii-partners__section { display: flex; flex-direction: column; gap: 8px; }

.ii-partners__section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* one partner */
.ii-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* the entries that were taken out of the list */
.ii-partners__noise {
  padding: 9px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--muted);
}

.ii-partners__noise > summary { cursor: pointer; font-weight: 600; color: var(--ink-soft); }

.ii-partners__noise > summary::marker { color: var(--muted); }

.ii-partners__noise-list {
  margin: 9px 0 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ii-partners__noise-list dt { font-size: 11px; font-weight: 600; color: var(--ink-soft); }

.ii-partners__noise-list dd { margin: 0 0 5px; display: flex; flex-wrap: wrap; gap: 4px 12px; }

.ii-noise { display: inline-flex; gap: 2px; }

.ii-noise__id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #a9631f;
}

.ii-noise__genes { color: var(--muted); }

/* one row per marker gene */
.ii-partners__rows { display: flex; flex-direction: column; }

.ii-partners__row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.ii-partners__row:first-child { border-top: 0; padding-top: 2px; }

.ii-partners__gene {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

/* the two lists of the marker file have their own colour */
.ii-partners__badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 5px;
}

.ii-partners__badge--top { background: var(--amber-soft); color: #a9631f; }
.ii-partners__badge--unique { background: var(--teal-soft); color: #0b7d74; }

.ii-partners__list { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

.ii-partners__none { font-size: 11px; color: var(--muted); font-style: italic; }

.ii-partners__more-btn {
  padding: 2px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.ii-partners__more-btn:hover { background: var(--accent-soft); border-color: #cfe0ff; }

.ii-partners__more-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ii-partners__hidden { display: contents; }

.ii-partners__hidden[hidden] { display: none; }

/* ---------- narrow screens ---------- */

@media (max-width: 1080px) {
  .ii { grid-template-columns: minmax(0, 1fr); }
  .ii-side { position: static; }
}

@media (max-width: 620px) {
  .ii-side__controls { gap: 14px; }
  .ii-partners__row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
}
