/* Distribution page — browse available nodes and send them work. */

.distribution-container {
  max-width: 1120px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.page-intro {
  margin-bottom: 1.5rem;
}

.page-intro h1 {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.page-intro p {
  margin: 0;
  max-width: 60ch;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.distribution-panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.panel-header h2 {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 1.2rem;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.panel-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- node cards --- */

.nodes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.node-item {
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition:
    transform var(--t) var(--ease),
    border-color var(--t) var(--ease),
    background-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}

.node-item:hover {
  transform: translateY(-3px);
  background-color: var(--surface-3);
  border-color: var(--accent-edge);
  box-shadow: var(--shadow-md);
}

.node-item:active {
  transform: translateY(-1px);
}

.node-item:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* The headline figure: what this machine actually contributes. */
.node-compute {
  display: block;
  margin-bottom: 0.9rem;
  color: var(--accent);
  font-size: 0.875rem;
  letter-spacing: -0.01em;
}

.node-compute strong {
  font-size: 1.45rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.node-cta {
  display: block;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 550;
  transition: color var(--t-fast) var(--ease);
}

.node-item:hover .node-cta,
.node-item:focus-visible .node-cta {
  color: var(--accent);
}

.node-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.node-id {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* .node-status colours come from the status pills in theme.css. */
.node-status {
  flex-shrink: 0;
}

.node-specs {
  display: grid;
  gap: 0.55rem;
}

.node-spec {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.875rem;
}

.spec-label {
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.node-spec > span:last-child {
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Without this the ellipsis above never happens. A flex item will not shrink
     below its content by default (min-width: auto), so a machine with four
     graphics cards pushed its own row 443px past the edge of the card and
     dragged the rows under it along. */
  min-width: 0;
}

.empty-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
  background-color: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}

.empty-message strong {
  display: block;
  color: var(--text);
  font-size: 0.9375rem;
  margin-bottom: 0.3rem;
}

.empty-message p {
  margin: 0;
  font-size: 0.875rem;
}

.empty-message.is-error {
  border-style: solid;
  border-color: rgba(248, 113, 113, 0.28);
  background-color: var(--danger-wash);
}

.empty-message.is-error strong {
  color: var(--danger);
}

/* A quiet pulse while the first request is in flight. */
.empty-message.is-loading {
  animation: node-list-pulse 1.4s var(--ease) infinite;
}

@keyframes node-list-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .empty-message.is-loading { animation: none; }
  .node-item:hover { transform: none; }
}

/* --- task form inside the node modal --- */

#taskDataInput {
  margin-top: 0.85rem;
}

#sendTaskButton {
  margin-top: 0.85rem;
}

#taskResponseMessage:not(:empty) {
  margin-top: 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-sm);
  background-color: var(--surface-2);
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .nodes-list {
    grid-template-columns: 1fr;
  }

  .distribution-panel {
    padding: 1.25rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
