/* ============================================================
   SCREENING TOOL — 2-column input/output panels
   ============================================================ */

.screening {
  padding: var(--sp-4xl) var(--sp-xl);
  background: var(--color-bg);
}

.screening__header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: var(--sp-3xl);
  gap: var(--sp-lg);
}

.screening__panes {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: var(--sp-xl);
  align-items: stretch;
}

/* Input pane: flex column so the Run button can stick to the bottom */
.screening__panes > .surface--padded {
  display: flex;
  flex-direction: column;
}

.screening__panes > .surface--padded > #run-prediction-btn {
  margin-top: auto;
  font-size: calc(var(--fs-caption) * 1.2);
  font-weight: var(--fw-medium);
}

#run-prediction-btn .btn__arrow {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
}

/* Pipeline-info: stretch data-list to fill the card height,
   distribute rows evenly so the table fills vertically. */
.screening__card[data-card="pipeline"] {
  display: flex;
  flex-direction: column;
}

.screening__card[data-card="pipeline"] .data-list {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screening__card[data-card="pipeline"] .data-row {
  flex: 1;
  /* keep opacity + transform transitions (entrance animation),
     drop the background transition (hover flicker) */
  transition: opacity 600ms cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 600ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.screening__card[data-card="pipeline"] .data-row:hover {
  background: transparent !important;
}

.screening__output {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-xl);
}

.screening__output > .screening__placeholder {
  grid-column: 1 / -1;
  height: 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-surface);
}

.screening__placeholder .pathway-graph-canvas {
  flex: 1;
  min-height: 0;   /* allow flex child to shrink below content size */
}

/* ============================================================
   INTERACTIVE FLOW — idle / loading / revealed states
   Driven by js/screening-flow.js
   ============================================================ */
.screening__card {
  position: relative;
  transition: opacity 300ms ease, filter 300ms ease;
}

/* IDLE — content hidden, "Run prediction…" placeholder shown */
.screening__card.is-idle {
  pointer-events: none;
}

.screening__card.is-idle > * {
  visibility: hidden;
}

.screening__card.is-idle::before {
  content: 'Run prediction to see result';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-meta);
  text-transform: uppercase;
  color: var(--color-secondary);
  text-align: center;
  padding: var(--sp-md);
  pointer-events: none;
}

/* LOADING — content hidden, only spinner visible */
.screening__card.is-loading {
  pointer-events: none;
}

.screening__card.is-loading > * {
  visibility: hidden;
}

.screening__card.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-mint);
  border-radius: 50%;
  animation: screening-spin 800ms linear infinite;
  z-index: 10;
}

@keyframes screening-spin {
  to { transform: rotate(360deg); }
}

/* REVEALED — smooth fade-slide-scale, opacity 0→1 throughout */
.screening__card.is-revealed {
  opacity: 1;
  filter: none;
  animation: screening-reveal 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Pipeline-info rows reveal one-by-one with fade-slide-scale (matches card) */
.screening__card .data-row {
  transition: opacity 600ms cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 600ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.screening__card .data-row.is-hidden {
  opacity: 0;
  transform: translateY(14px) scale(0.985);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .screening__card .data-row { transition: none; }
}

/* Score-bar fill animation: the coloured overlay (::before) on each
   active segment fades opacity 0→1 with a stagger delay set inline by JS
   (--seg-delay). The grey base bar stays full-length the whole time. */
.screening__card[data-card="output"].is-revealed .segbar > i.is-on::before,
.screening__card[data-card="output"].is-revealed .segbar > i.is-peak::before {
  animation: segbar-fill 600ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
  animation-delay: var(--seg-delay, 0ms);
}

@keyframes segbar-fill {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .screening__card[data-card="output"].is-revealed .segbar > i.is-on::before,
  .screening__card[data-card="output"].is-revealed .segbar > i.is-peak::before {
    animation: none;
  }
}

@keyframes screening-reveal {
  0%   { opacity: 0; transform: translateY(14px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .screening__card.is-loading::after { animation: none; }
  .screening__card.is-revealed { animation: none; }
}

/* Pathway graph node hover — gentle zoom-in */
.pathway-node {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
}
.pathway-node:hover {
  transform: scale(1.08);
}

@media (prefers-reduced-motion: reduce) {
  .pathway-node { transition: none; }
  .pathway-node:hover { transform: none; }
}

.score {
  padding: 8px 0;
}

.score__display {
  font-family: var(--font-sans);
  font-size: 120px;
  color: var(--color-mint);
  line-height: 0.9;
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-tight);
  margin-bottom: var(--sp-md);
}

.score__caption {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
}

.score__caption-strong {
  font-weight: var(--fw-bold);
  color: var(--color-mint-deep);
  letter-spacing: var(--ls-mono-cap);
}

.score__caption-soft { color: var(--color-mint-soft); }
.score__caption-mid  { color: var(--color-mint-mid); letter-spacing: 0.06em; }

.score__bar { margin-top: var(--sp-xl); }

/* ───── Mobile (≤ 720px) ───── */
@media (max-width: 720px) {
  .screening {
    padding: 80px var(--sp-md);
  }

  .screening__header {
    margin-bottom: var(--sp-xl);
  }

  /* Input pane on top, output pane stacked below */
  .screening__panes {
    grid-template-columns: 1fr;
    gap: var(--sp-md);
  }

  /* Output cards stack vertically: Score → Pipeline → Pathway */
  .screening__output {
    grid-template-columns: 1fr;
    gap: var(--sp-md);
  }

  /* Pathway no longer needs to span 2 columns */
  .screening__output > .screening__placeholder {
    grid-column: auto;
  }

  /* Score number — 120px is too large for mobile */
  .score__display {
    font-size: 72px;
  }

  /* Before the user clicks "Run prediction" only the score card is shown.
     Pipeline-info and Pathway graph stay hidden until the state flips
     out of `is-idle` (which `screening-flow.js` does on button click). */
  .screening__card.is-idle[data-card="pipeline"],
  .screening__card.is-idle[data-card="graph"] {
    display: none;
  }
}
