/*
 * Goals page. The tree is the page: company, role and employee are the same
 * shared disclosure at three depths, so everything below is a track declaration
 * and the spacing between the parts of one branch. The opened tint, the chevron,
 * the recessed body and the row surface all come from Stoneware — a goal node
 * that drew its own would look like a different product one level down.
 */

.company-goals__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--fs-space-4);
}

.company-goals__period {
  min-width: 160px;
}

/*
 * The summary body is prose, not tiles, so it takes the whole row instead of
 * one of its four columns. A goal is read as a line of text; the numbers that
 * would have gone here are already standing in the tree, counted per node.
 */
.company-goals__summary {
  display: grid;
  gap: var(--fs-space-2);
  grid-column: 1 / -1;
  min-width: 0;
}

.company-goals__summary-goal,
.company-goals__summary-empty {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.company-goals__summary-goal {
  position: relative;
  padding-left: var(--fs-space-4);
  color: var(--fs-color-text);
  font-weight: 600;
}

/* A quiet marker, not a list bullet: several goals must read as several lines. */
.company-goals__summary-goal::before {
  position: absolute;
  top: 0.62em;
  left: 0;
  width: 6px;
  height: 6px;
  background: var(--fs-color-primary);
  border-radius: 999px;
  content: "";
}

.company-goals__summary-empty {
  color: var(--fs-color-text-muted);
  font-size: var(--fs-text-sm);
}

/* Identity | count | add | chevron. Without the plus the row is three columns. */
.company-goals__node > summary {
  grid-template-columns: minmax(0, 1fr) auto auto 24px;
  gap: var(--fs-space-3);
}

.company-goals__node--read > summary {
  grid-template-columns: minmax(0, 1fr) auto 24px;
}

.company-goals__node-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--fs-space-2);
  min-width: 0;
}

.company-goals__node-identity > strong {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.company-goals__node-identity > small {
  color: var(--fs-color-text-secondary);
}

.company-goals__node-count {
  font-variant-numeric: tabular-nums;
}

/*
 * The panel and the people list already close themselves off. A trailing
 * hairline inside them draws a line under nothing.
 */
.company-goals__tree > .company-goals__node:last-child > summary,
.company-goals__tree > .company-goals__node:last-child > .fs-datalist__nested,
.company-goals__people > .company-goals__node:last-child > summary,
.company-goals__people > .company-goals__node:last-child > .fs-datalist__nested {
  border-bottom: 0;
}

.company-goals__branch {
  display: grid;
  gap: var(--fs-space-4);
}

.company-goals__subsection {
  display: grid;
  gap: var(--fs-space-2);
}

/* Copy | actions. The copy column carries the badges, the title and the note. */
.company-goals__goal {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.company-goals__goal-copy {
  display: grid;
  gap: var(--fs-space-1);
  min-width: 0;
}

.company-goals__goal-copy > strong {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.company-goals__goal-copy > p {
  margin: 0;
  color: var(--fs-color-text-secondary);
  white-space: pre-line;
}

.company-goals__goal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--fs-space-2);
}

/* Completion is a control, not a status: the badge above already says the state. */
.company-goals__done {
  display: inline-flex;
  align-items: center;
  gap: var(--fs-space-2);
  color: var(--fs-color-text-secondary);
  font-size: var(--fs-text-xs);
  white-space: nowrap;
  cursor: pointer;
}

.company-goals__done input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--fs-color-success-text);
  cursor: pointer;
}

/* Own goals first, then the branch below them. Two figures need to stay apart. */
.company-goals__node-counts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* The discussion sits inside its goal's row band, indented under the record. */
.company-goals__comments {
  padding: 0 var(--fs-space-3) var(--fs-space-3);
  border-top: 1px solid var(--fs-color-border-subtle);
  background: var(--fs-color-surface-subtle);
}

.company-goals__comments > * {
  padding-top: var(--fs-space-3);
}

.company-goals__empty {
  margin: 0;
  color: var(--fs-color-text-muted);
  font-size: var(--fs-text-sm);
}

.company-goals__form {
  width: min(680px, 100%);
}

@media (max-width: 760px) {
  .company-goals__header {
    align-items: stretch;
    flex-direction: column;
  }

  .company-goals__period {
    width: 100%;
  }

  /*
   * The node keeps one line on a phone rather than becoming a stacked card: it
   * carries a name, a number and two targets, and stacking those costs three
   * rows per branch in a view whose whole point is to be scanned as a tree.
   */
  .company-goals__node > summary {
    gap: var(--fs-space-2);
    padding-inline: var(--fs-space-3);
  }

  .company-goals__node-identity {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  /* The goal becomes a card: badges, title, note, then its actions on their own
     line at the right edge, which is where the mobile list puts row actions. */
  .company-goals__goal {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--fs-space-2);
  }

  .company-goals__goal .fs-datalist__row-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* The label loses its word on a phone; the checkbox keeps a full touch target. */
  .company-goals__done span {
    display: none;
  }

  .company-goals__done {
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
  }

  .company-goals__branch {
    gap: var(--fs-space-3);
  }
}
