/*
 * THE FOLLOW IS THE LAYOUT. A reversed column scrolls from its bottom, so a
 * browser paints every growth already pinned — no scroll-after-paint flash, no
 * offset arithmetic racing the content, and scrolling up releases the pin the
 * way any scroller does.
 *
 * Content shorter than the frame still reads top-down, from an auto margin on
 * the content part rather than any alignment on the port — the rule below says
 * why the obvious alignment does not work.
 *
 * The ROOT is the frame and the VIEWPORT is the scroll port, because the jump
 * disc has to stand still: an absolutely-positioned child of a scroll container
 * joins that container's scrollable overflow and travels with the content, so
 * the way back to the newest content scrolled away with the reason for it.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-follow-scroll {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    min-width: 0;
  }

  .lotics-follow-scroll__viewport {
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    justify-content: flex-start;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /*
   * The AUTO margin is what top-aligns short content, and it has to be a margin
   * rather than `justify-content: flex-end` on the port: aligning a reversed
   * column toward its main END pushes overflow past the start edge, where the
   * browser creates no scrollable region — measured, the feed simply ran off the
   * top with no scrollbar and no way back. An auto margin only absorbs free
   * space, so the moment the content overflows it resolves to zero and the
   * column packs from the bottom, which is the scrollable direction.
   */
  .lotics-follow-scroll__content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
    min-width: 0;
    margin-block-end: auto;
  }

  /* Always mounted, so the disc that returns the reader to the newest content
     keeps one box and one position whether or not it is showing.
     `visibility`, not `opacity` + `pointer-events`: a transparent button is
     still a TAB STOP and still in the accessibility tree, so the reader tabbed
     onto something that was not there. Hidden it keeps the box and leaves both. */
  .lotics-follow-scroll__jump {
    position: absolute;
    inset-inline: 0;
    bottom: var(--lotics-space-16);
    display: flex;
    flex-direction: row;
    justify-content: center;
    visibility: hidden;
  }

  .lotics-follow-scroll__jump[data-visible] {
    visibility: visible;
  }
}
