/*
 * The planning page wrapper (/planning): holds the objective tree and, from
 * 012, an optional aside.tree-sidebar of unlinked grant objectives beside it.
 * .tree-page--with-sidebar adds the second column. .tree-page also resets the
 * "selected" counter, which the bulk toolbar counts checked items with in CSS.
 */
@layer components {
  .tree-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-8);
    align-items: start;
    counter-reset: selected;
  }

  .tree-page--with-sidebar {
    grid-template-columns: minmax(0, 1fr) 18rem;
  }

  /* Stays beside the tree while it scrolls, below the sticky banner and toolbar; scrolls itself when taller than the viewport. */
  .tree-sidebar {
    position: sticky;
    /* Right under the bar: its own top padding is the gap, stuck or not. */
    inset-block-start: calc(var(--app-header-height) + var(--planning-toolbar-height));
    max-block-size: calc(100vh - var(--app-header-height) - var(--planning-toolbar-height) - var(--space-4));
    overflow-y: auto;
    display: grid;
    gap: var(--space-3);
    /* The section's top padding, so its heading lines up with "Strategic objectives". */
    padding-block-start: var(--space-3);
    padding-inline-start: var(--space-6);
    border-inline-start: var(--border);

    & > * + * {
      margin-block-start: 0;
    }

    & > section {
      margin-block-start: var(--space-5);
    }
  }

  /* Each grant's unlinked objectives, under the grant's name. */
  .tree-sidebar__grant {
    display: grid;
    gap: var(--space-2);
  }

  .tree-sidebar__grant-name {
    margin: 0;
    font: var(--text-body-strong);
    color: var(--color-positive);
  }

  .tree-sidebar__list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .tree-sidebar__empty {
    margin: 0;
    font: var(--text-small);
    color: var(--color-muted);
  }

  /* A chip: card-like and draggable onto a plan objective to link it. */
  .grant-objective-chip {
    max-inline-size: none;
    padding: var(--space-2) var(--space-3);
    border: var(--border);
    border-inline-start: var(--space-1) solid var(--color-positive);
    border-radius: var(--radius-s);
    background: var(--color-positive-surface);
    font: var(--text-small);
    color: var(--color-text);
    cursor: grab;

    &:active {
      cursor: grabbing;
    }
  }

  .grant-objective-chip--dragging {
    opacity: 0.4;
  }
}
