@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
/* A list placeholder's rows are a StackedListItem's own layout and status dot, in their classes. */
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/stacked-list-item/stacked-list-item.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/status-dot/status-dot.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/table/table.css';
@layer cinder.components {
  /* ========================================
 * SKELETON
 * ======================================== */

  /* The fill is a translucent step of the border ink, so a bar shows on whatever surface it sits on.
     The shimmer's highlight is the same ink at half its alpha: a lightness lift did nothing in dark,
     where the ink is already white. */
  .cinder-skeleton {
    display: block;
    width: 100%;
    height: 1em;
    border-radius: var(--cinder-radius-sm);
    background: linear-gradient(
      90deg,
      var(--cinder-skeleton-background) 0%,
      oklch(from var(--cinder-skeleton-background) l c h / calc(alpha * 0.5)) 50%,
      var(--cinder-skeleton-background) 100%
    );
    background-size: 200% 100%;
    animation: cinder-skeleton-shimmer 1.5s ease-in-out infinite;
  }

  .cinder-skeleton[data-cinder-holds] {
    height: auto;
    width: fit-content;
    max-inline-size: 100%;
  }

  .cinder-skeleton-held-content {
    display: flow-root;
    visibility: hidden;
    opacity: 0;
  }

  /* A group stacks several bars and, when asked, a "Still loading" status line. Only the bars
   * are decorative: the status sits outside the aria-hidden wrapper so it can be announced. */
  .cinder-skeleton-group {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-3);
    inline-size: 100%;
  }

  .cinder-skeleton-group[data-cinder-variant='custom'] {
    gap: 0;
  }

  /* A stack of bars stands for lines of text, so each bar is one line box of the surrounding text:
   * the bar is 1em tall and the margin makes up the rest of the line's own height (1lh), with no gap
   * between lines, as a paragraph of the same lines has none (COR-2449). */
  .cinder-skeleton-lines {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .cinder-skeleton-lines > .cinder-skeleton {
    margin-block: calc((1lh - 1em) / 2);
  }

  .cinder-skeleton-group > .cinder-skeleton-lines > .cinder-skeleton[data-cinder-last] {
    width: 60%;
  }

  /* The zero-width space supplies the same line box and baseline as a cell's text.
   * The bar paints inside that line without changing its size. */
  .cinder-skeleton-table-line {
    position: relative;
    display: inline-block;
    inline-size: min(60%, 10rem);
  }

  .cinder-skeleton-table-bar {
    position: absolute;
    inset-block-start: 50%;
    translate: 0 -50%;
    block-size: 0.65em;
  }

  .cinder-skeleton-table-bar:where(
    :not([dir='rtl'], [dir='rtl'] *),
    [dir='rtl'] [dir='ltr'],
    [dir='rtl'] [dir='ltr'] *
  ) {
    left: 0;
  }

  .cinder-skeleton-table-bar:where(
    :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
  ) {
    right: 0;
  }

  /* Form variant: a short label bar over a control bar, once per field, as FormField draws them: the
   * label's own line (the label's size and leading), the field's gap, the control's height, and the
   * form's gap between fields (the last field has none after it). The label bar sits in the
   * label's line box. */
  .cinder-skeleton-group[data-cinder-variant='form'] > .cinder-skeleton-lines {
    gap: var(--cinder-space-1-5);
  }

  .cinder-skeleton-group[data-cinder-variant='form'] > .cinder-skeleton-lines > .cinder-skeleton {
    margin-block: 0;
  }

  .cinder-skeleton-group[data-cinder-variant='form']
    > .cinder-skeleton-lines
    > .cinder-skeleton-field-label {
    inline-size: 20%;
    block-size: var(--cinder-space-2-5);
    margin-block: calc(
      (var(--cinder-text-xs) * var(--cinder-leading-snug) - var(--cinder-space-2-5)) / 2
    );
  }

  .cinder-skeleton-group[data-cinder-variant='form']
    > .cinder-skeleton-lines
    > .cinder-skeleton-field-control {
    inline-size: 100%;
    block-size: var(--cinder-control-height-md);
    margin-block-end: calc(var(--cinder-space-4) - var(--cinder-space-1-5));
  }

  .cinder-skeleton-group[data-cinder-variant='form']
    > .cinder-skeleton-lines
    > .cinder-skeleton-field-control:last-child {
    margin-block-end: 0;
  }

  /* Card variant: a Card's surface and body padding (the density's), a heading bar in the title's
   * line, then lines of text. */
  .cinder-skeleton-group[data-cinder-variant='card'] > .cinder-skeleton-lines {
    padding: var(--cinder-density-pad-card);
    border: var(--cinder-border-width) solid var(--cinder-border-muted);
    border-radius: var(--cinder-radius-surface);
    background: var(--cinder-surface);
  }

  /* List variant: the placeholder for a status-first list. Each row is a two-line StackedListItem's
   * own layout, in its own classes (the row, its status column, title, time and line two), with a
   * bar where each piece of text goes, so the placeholder is as tall as the row it stands for, and
   * takes its phone form at the row's own width, by construction. Nothing but the bars is the
   * placeholder's own: no frame, no divider, no margin of its own beyond the one the loaded row
   * gets from the page's list reset. A placeholder draws a frame only when the list it stands for
   * does, so the frame is the opt-in (`framed`). */
  .cinder-skeleton-list[data-cinder-framed] {
    overflow: hidden;
    border: var(--cinder-border-width) solid var(--cinder-border-muted);
    border-radius: var(--cinder-radius-lg);
    background: var(--cinder-surface);
  }

  .cinder-skeleton-day-band {
    padding-block: var(--cinder-space-2);
    padding-inline: var(--cinder-space-3-5);
    border-block-end: var(--cinder-border-width) solid var(--cinder-border-muted);
  }

  /* A known day and zone use the same group-label pattern as the loaded DataList. */
  .cinder-skeleton-day-band[data-cinder-day-band-text] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--cinder-space-3);
    line-height: var(--cinder-leading-normal);
  }

  .cinder-skeleton-day-detail {
    color: var(--cinder-text-subtle);
    font-weight: var(--cinder-font-normal);
    white-space: nowrap;
  }

  /* The row is a StackedListItem's, and a StackedListItem is a list item: the page's list reset
   * gives a loaded row this margin (foundation.css, `li`), so the placeholder row, a div, takes the
   * same one and the list is as tall. */
  .cinder-skeleton-row {
    margin-block-end: var(--cinder-space-1);
  }

  /* A bar stands in the line of the text it replaces, centred on its lowercase letters. */
  .cinder-skeleton-row .cinder-skeleton {
    display: inline-block;
    vertical-align: middle;
  }

  /* The bar sits in one line of the real band's text (DataList's group header: extra small, normal
   * leading), so the band is as tall as the real one. */
  .cinder-skeleton-day-bar {
    height: 0.625rem;
    width: 8.75rem;
    margin-block: calc((var(--cinder-text-xs) * var(--cinder-leading-normal) - 0.625rem) / 2);
  }

  .cinder-skeleton-status-bar {
    height: 0.625rem;
    width: 4rem;
  }

  /* A list whose rows lead with a status dot: a dot in the same column, so the text lines up with
   * the real rows. The cell centres it on the first line of the title. */
  .cinder-skeleton-status-bar[data-cinder-marker='dot'] {
    height: 0.5rem;
    width: 0.5rem;
    border-radius: var(--cinder-radius-full);
  }

  .cinder-skeleton-title-bar {
    height: 0.625rem;
    width: 55%;
  }

  .cinder-skeleton-meta-bar {
    height: 0.5rem;
    width: 80%;
  }

  .cinder-skeleton-time-bar {
    height: 0.625rem;
    width: 2.75rem;
  }

  /* Grouped variant: the placeholder for a grouped list. The same rounded raised surface the
   * list draws, no border, and rows whose separator is the bottom edge of their content, so it
   * starts at the text as the real rows' does. Each row holds two text bars and, for a list whose
   * rows end in text actions, a block the height of a small button where the button goes. */
  .cinder-skeleton-grouped {
    overflow: hidden;
    position: relative;
    border-radius: var(--cinder-radius-surface);
    background: var(--cinder-surface-raised);
  }

  /* The placeholder draws the GroupedList's page edge, so nothing changes when the list arrives
     (COR-2697). On an overlay, so it takes no layout. */
  .cinder-skeleton-grouped::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    border: var(--cinder-border-width) solid var(--_cinder-page-edge);
  }

  @media (forced-colors: active) {
    .cinder-skeleton-grouped {
      border: 1px solid CanvasText;
    }
  }

  .cinder-skeleton-grouped-row {
    padding-inline-start: var(--cinder-space-4);
  }

  .cinder-skeleton-grouped-content {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-3);
    min-block-size: 2.75rem;
    padding-block: var(--cinder-space-2-5);
    padding-inline-end: var(--cinder-space-2);
    border-block-end: var(--cinder-border-width) solid var(--cinder-border-faint);
  }

  .cinder-skeleton-grouped-row:last-child > .cinder-skeleton-grouped-content {
    border-block-end-color: transparent;
  }

  /* The text column of a grouped-list row: a title line and a subtitle line, each a line box in the
   * real row's own type (the title at base size and snug leading, the subtitle at small size and the
   * inherited leading), so the placeholder row is exactly as tall as the row it stands for. */
  .cinder-skeleton-grouped-text {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: var(--cinder-space-0-5);
    min-inline-size: 0;
  }

  .cinder-skeleton-grouped-line {
    display: flex;
    align-items: center;
    block-size: 1lh;
  }

  .cinder-skeleton-grouped-line--title {
    font-size: var(--cinder-text-base);
    line-height: var(--cinder-leading-snug, 1.35);
  }

  .cinder-skeleton-grouped-line--subtitle {
    font-size: var(--cinder-text-sm);
  }

  /* A row whose real rows lead with a glyph: the icon slot of a grouped-list row (a 28px column
   * with its 12px gap, the glyph centred on the title's first line), so the bars start where the
   * row's text does and nothing moves sideways when the rows arrive. */
  .cinder-skeleton-grouped-row--leading {
    display: flex;
  }

  .cinder-skeleton-grouped-row--leading > .cinder-skeleton-grouped-content {
    flex: 1 1 0;
    min-inline-size: 0;
  }

  .cinder-skeleton-grouped-leading {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-inline-size: 1.75rem;
    block-size: calc(
      var(--cinder-text-base) * var(--cinder-leading-snug, 1.35) + 2 * var(--cinder-space-2-5)
    );
    padding-block: var(--cinder-space-2-5);
    padding-inline-end: var(--cinder-space-3);
  }

  .cinder-skeleton-icon-block {
    flex: none;
    inline-size: 1rem;
    block-size: 1rem;
  }

  /* A trailing value's bar, such as a time: small text's height, at the end of the title's line. */
  .cinder-skeleton-trailing-bar {
    flex: none;
    inline-size: 3.5rem;
    block-size: 0.5rem;
    margin-inline-start: auto;
  }

  /* chevronColumn: the bar ends before a grouped-list row's chevron column (the 16px chevron and
   * its gap, GroupedListItem's own measure), where the real trailing value ends. */
  .cinder-skeleton-trailing-bar--chevron-column {
    margin-inline-end: calc(1rem + var(--cinder-space-3));
  }

  /* The button's painted height, not its control height: a coarse pointer raises the control
   * height to 44px while a Button is drawn 28px and reaches 44px through its hit area, so a 44px
   * block made the placeholder taller than the row it stands for (COR-2489: Home moved 32px on a
   * phone when its data arrived). */
  .cinder-skeleton-action-bar {
    flex: none;
    inline-size: 5.25rem;
    block-size: var(--_cinder-painted-height-sm);
    border-radius: var(--cinder-button-radius-sm);
  }

  /* A row narrower than 26rem drops its real buttons under the text at their own width, from the
   * text's leading edge (GroupedListItem's own container query), so the block does too: the text
   * takes the whole first line, and the block keeps its 5.25rem at the start of the next. */
  .cinder-skeleton-grouped-row--action {
    container: cinder-skeleton-grouped-row / inline-size;
  }

  @container cinder-skeleton-grouped-row (width < 26rem) {
    .cinder-skeleton-grouped-row--action > .cinder-skeleton-grouped-content {
      flex-wrap: wrap;
    }

    .cinder-skeleton-grouped-row--action .cinder-skeleton-grouped-text {
      flex-basis: 100%;
    }
  }

  /* The card's heading stands for its title: the bar sits in one line of the title's size. */
  .cinder-skeleton-lines > .cinder-skeleton-heading {
    height: 1.25em;
    width: 40%;
    font-size: var(--cinder-text-sm);
    margin-block: calc((1lh - 1.25em) / 2);
  }

  /* The status line leads its group, at the inline start: after a long wait it is the first thing
   * in view, never cut off below a page of placeholders. It takes the place of the group's first
   * placeholder rather than being inserted above it, so nothing moves when it appears or when the
   * data arrives (COR-2329). In a grouped or list placeholder it lies over the first row, whose bars
   * give way to it; in a page's own placeholder the block marked `holdsStatusLine` draws it in its
   * own box; in a group of bars, a card or a form it lies over the placeholder from its top and the
   * bars give way to it (COR-2489: the line used to be inserted above them and pushed the page
   * down). */
  .cinder-skeleton-group:is([data-cinder-variant='grouped'], [data-cinder-variant='list']) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .cinder-skeleton-group:is([data-cinder-variant='grouped'], [data-cinder-variant='list'])
    > :is(.cinder-skeleton-status, .cinder-skeleton-grouped, .cinder-skeleton-list) {
    grid-area: 1 / 1;
  }

  .cinder-skeleton-group:is([data-cinder-variant='grouped'], [data-cinder-variant='list'])
    > .cinder-skeleton-status {
    position: relative;
    z-index: 1;
    align-self: start;
    /* Little padding, so a line that wraps to two lines on a phone still fits the first row. */
    padding-block: var(--cinder-space-1);
  }

  .cinder-skeleton-group[data-cinder-variant='grouped'] > .cinder-skeleton-status {
    padding-inline: var(--cinder-space-4) var(--cinder-space-2);
  }

  .cinder-skeleton-group[data-cinder-variant='list'] > .cinder-skeleton-status {
    padding-inline: var(--cinder-space-3-5);
  }

  /* A list that leads with a day band keeps the band in view: the line lies over the first row,
   * under the band (one xs line box, its block padding and its rule), never over the day's words
   * (COR-2489: "Today, Monday, Nov 2" was painted over). */
  .cinder-skeleton-group[data-cinder-variant='list']:has(
      > .cinder-skeleton-list > .cinder-skeleton-day-band:first-child
    )
    > .cinder-skeleton-status {
    margin-block-start: calc(
      var(--cinder-text-xs) * var(--cinder-leading-normal) + 2 * var(--cinder-space-2) +
        var(--cinder-border-width)
    );
  }

  .cinder-skeleton-group[data-cinder-variant='grouped']:has(> .cinder-skeleton-status:not(:empty))
    .cinder-skeleton-grouped-row:first-child
    .cinder-skeleton,
  .cinder-skeleton-group[data-cinder-variant='list']:has(> .cinder-skeleton-status:not(:empty))
    :is(
      .cinder-skeleton-list > :first-child,
      .cinder-skeleton-list > .cinder-skeleton-day-band + .cinder-skeleton-row
    )
    .cinder-skeleton {
    visibility: hidden;
  }

  /* Bars, a card and a form: the line and the placeholder share one cell, so the line takes the
   * placeholder's place and the group is as tall as it was. A card keeps its surface and the line
   * sits inside its padding and border, where the heading bar was. */
  .cinder-skeleton-group:is(
    [data-cinder-variant='row'],
    [data-cinder-variant='card'],
    [data-cinder-variant='form']
  ) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .cinder-skeleton-group:is(
      [data-cinder-variant='row'],
      [data-cinder-variant='card'],
      [data-cinder-variant='form']
    )
    > :is(.cinder-skeleton-status, .cinder-skeleton-lines) {
    grid-area: 1 / 1;
  }

  .cinder-skeleton-group[data-cinder-variant='row'] > .cinder-skeleton[data-cinder-holds] {
    grid-area: 1 / 1;
    align-self: start;
  }

  .cinder-skeleton-group:is(
      [data-cinder-variant='row'],
      [data-cinder-variant='card'],
      [data-cinder-variant='form']
    )
    > .cinder-skeleton-status {
    position: relative;
    z-index: 1;
    align-self: start;
  }

  .cinder-skeleton-group[data-cinder-variant='card'] > .cinder-skeleton-status {
    padding: calc(var(--cinder-density-pad-card) + 1px);
  }

  .cinder-skeleton-group[data-cinder-variant='row']:has(> .cinder-skeleton-status:not(:empty))
    > .cinder-skeleton[data-cinder-holds],
  .cinder-skeleton-group:is(
      [data-cinder-variant='row'],
      [data-cinder-variant='card'],
      [data-cinder-variant='form']
    ):has(> .cinder-skeleton-status:not(:empty))
    > .cinder-skeleton-lines
    > .cinder-skeleton {
    visibility: hidden;
  }

  /* A page's own placeholder that holds the line: a box as tall as the placeholder, which shows
   * the bar until the line appears and then the line in its stead. */
  .cinder-skeleton-status-place {
    display: flex;
    align-items: center;
    min-inline-size: 0;
  }

  .cinder-skeleton-status-place:has(> .cinder-skeleton-status:not(:empty)) > .cinder-skeleton {
    display: none;
  }

  .cinder-skeleton-status {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    font-size: var(--cinder-text-sm);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-muted);
  }

  /* The words give way and wrap; Cancel, the one way out of a slow load, never shrinks, so it is
   * never cut to "Ca..." on a phone (COR-2489). */
  .cinder-skeleton-status-label {
    flex: 1 1 0;
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }

  .cinder-skeleton-status > .cinder-button {
    flex: none;
  }

  .cinder-skeleton-status:empty {
    display: none;
  }

  @keyframes cinder-skeleton-shimmer {
    0% {
      background-position: 200% 0;
    }
    100% {
      background-position: -200% 0;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    :root:not([data-cinder-reduced-motion='false']):not([data-reduced-motion='off'])
      .cinder-skeleton {
      animation: none;
      background: var(--cinder-skeleton-background);
    }
  }

  :root:is([data-cinder-reduced-motion='true'], [data-reduced-motion='on']) .cinder-skeleton {
    animation: none;
    background: var(--cinder-skeleton-background);
  }
}
