/*
 * A statement's table (companies/financials/show): the filed-period note,
 * the one lock column, the row's definition, the Advanced lines' chevron.
 */
@layer components {
  .statement-table {
    & .data-table__label {
      inline-size: clamp(9rem, 40vw, 18rem);
      white-space: normal;
    }

    & th:not(.data-table__label),
    & td:not(.data-table__label) {
      inline-size: 6rem;
    }
  }

  /* Under a column's date, while its figures are the filing's rather than
     Zacks' (tasks/growth/milestones/28, D8). */
  .statement-table__filed {
    display: block;
    font-weight: var(--weight-regular);
    font-size: var(--text-meta-xs);
    line-height: var(--leading-meta-xs);
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
  }

  /* The one lock column a statement carries (M04-D4, G2):
     a cell spanning every row at the older end of the periods, its lock held
     near the top where the sticky header leaves it in view. Wider than a
     period column, because it holds a sentence; wider again when it holds
     Powerpack's offer card (shared/_powerpack_offer). */
  .statement-table {
    & th.statement-table__lock-head,
    & td.statement-table__lock {
      inline-size: 12rem;
    }

    &:has(td.statement-table__lock .offer-card) :is(th.statement-table__lock-head, td.statement-table__lock) {
      inline-size: 20rem;
    }
  }

  .statement-table__lock {
    vertical-align: top;
    white-space: normal;
    background-color: var(--color-surface-sunken);

    & :is(.lock-panel, .offer-card) {
      position: sticky;
      inset-block-start: var(--space-2xl);
    }

    /* A table's cells set their figures to the end; the card reads as text. */
    & .offer-card {
      text-align: start;
    }
  }

  .statement-table__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
  }

  /* The name takes the room between the chevron and the wiki glyph. */
  .statement-table__name {
    flex: 1;
  }

  /* A row's definition (M09-D6) opens in the row rather than over the rows
     below it: the table scrolls inside its own box, which would clip a
     popover, and the pinned label cells stack over one another. */
  .statement-table .definition {
    display: block;

    /* The chevron, drawn rather than inlined a hundred times: two sides of
       a small square, turned to point down, and up once open. */
    & > .disclosure__summary::after {
      content: "";
      inline-size: 0.3125rem;
      block-size: 0.3125rem;
      margin-block-start: calc(-1 * var(--space-2xs));
      border-inline-end: var(--rule-width-strong) solid var(--color-ink-subtle);
      border-block-end: var(--rule-width-strong) solid var(--color-ink-subtle);
      rotate: 45deg;
      transition: rotate var(--duration-fast);
    }

    &[open] > .disclosure__summary::after {
      margin-block-start: var(--space-2xs);
      rotate: 225deg;
    }

    & > .disclosure__body {
      position: static;
      inline-size: auto;
      margin-block: var(--space-2xs);
      box-shadow: none;
      white-space: normal;
    }
  }

  /* The chevron that shows the Advanced lines folded under a line (M09-D5).
     It points right while they are hidden and down once they are shown —
     the state is the button's aria-expanded, which the row-group controller
     keeps. */
  .statement-table__toggle {
    flex: none;
    inline-size: 1.5rem;
    block-size: 1.5rem;

    @media (pointer: coarse) {
      inline-size: var(--target-min);
      block-size: var(--target-min);
    }

    & .icon {
      transition: rotate var(--duration-fast);
    }

    &[aria-expanded="true"] .icon {
      rotate: 90deg;
    }
  }

  /* "Show all line items": the same table unfolded on the server. */
  .statement-table__fold {
    padding: var(--space-sm) var(--space-md);
    border-block-start: var(--rule-width) solid var(--color-rule);
    font-size: var(--text-ui-sm);
  }
}
