/*
 * Two beats, one per altitude, and each is a rung: the SECTION rung between
 * sections, the PEER rung between the groups inside one (`constitution.md` §2).
 *
 * The one boundary that takes NO rung is the one between two closed disclosures:
 * a closed disclosure is a line rather than a block (below).
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-section-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }

  .lotics-section-stack[data-altitude="section"] {
    gap: var(--lotics-space-48);
  }

  .lotics-section-stack[data-altitude="subsection"] {
    gap: var(--lotics-space-24);
  }

  /*
   * A CLOSED DISCLOSURE IS A LINE, NOT A BLOCK, so a run of them is a LIST: one
   * row each, the hairline between them, and the rung standing down — the beat
   * is spent on a block's CONTENT, and a closed one has none.
   *
   * Only BETWEEN two closed ones: the boundary onto anything else still takes
   * the rung, so the rung is spelled twice per altitude, the gap above and its
   * cancellation here.
   *
   * `[data-closed]` is the DISCLOSURE's own published state; the hairline is
   * this stack's own part, because a sheet selects its own anatomy.
   */
  .lotics-section-stack[data-altitude="section"]
    > [data-closed]
    + .lotics-section-stack__rule:has(+ [data-closed]) {
    margin-block: calc(var(--lotics-space-48) * -1);
  }

  .lotics-section-stack[data-altitude="subsection"]
    > [data-closed]
    + .lotics-section-stack__rule:has(+ [data-closed]) {
    margin-block: calc(var(--lotics-space-24) * -1);
  }
}
