@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/popover/popover.css';
@layer cinder.components {
  .cinder-citation {
    /* A Citation can be a flex item in chat source rows. `inline` blockifies to a zero-width flex
     * item when combined with inline-size containment, leaving its marker painted offscreen. Keep
     * the inline flow contract while giving flex layout a measurable intrinsic width. */
    display: inline-block;
  }
  .cinder-citation__marker {
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-1);
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--cinder-accent-text);
    cursor: pointer;
    font: inherit;
    padding: 0;
    vertical-align: baseline;
    text-decoration: none;
    /* Anchors the hit area below. */
    position: relative;
  }

  /* A chip marker is a soft accent pill on the text line. Its label is cut with an ellipsis inside
   * the pill, so the frame is always whole, and it takes no height of its own: the line keeps its
   * rhythm and the hit area below still reaches the touch minimum. */
  .cinder-citation__marker[data-cinder-chip] {
    max-inline-size: 16ch;
    min-inline-size: 0;
    padding-inline: var(--cinder-space-1-5);
    border-radius: var(--cinder-radius-full);
    background: var(--cinder-accent-background);
    vertical-align: bottom;
  }

  .cinder-citation__chip-label {
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The marker is painted at its text height, but its hit area is at least 24px tall (and 44px on
   * a coarse pointer) without taking layout space, so a row of markers does not grow. */
  .cinder-citation__marker-hit-target {
    position: absolute;
    z-index: 0;
    pointer-events: auto;
    inset-block: min(0px, calc((100% - 24px) / 2));
    inset-inline: min(0px, calc((100% - 24px) / 2));
  }

  /* The ring wraps the marker with 2px of padding and the compact-control radius. */
  .cinder-citation__marker:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    border-radius: var(--cinder-radius-sm);
    box-shadow:
      0 0 0 2px var(--cinder-ring-offset-color),
      0 0 0 calc(2px + var(--cinder-ring-width)) var(--cinder-ring-color);
  }

  @media (forced-colors: active) {
    .cinder-citation__marker:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 2px;
      box-shadow: none;
    }
  }
  /* The panel is as tall as its rows up to about half the viewport, then the list scrolls inside
     it, so one source is a short sheet and a long list never covers the page. A list shown under
     its marker (`inPlace`) is part of the page and takes its natural height. `overflow-wrap:
     anywhere` keeps a long unbroken string inside the panel. */
  .cinder-citation__panel {
    min-width: 0;
    max-block-size: 50dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    text-align: start;
    overflow-wrap: anywhere;
    line-height: var(--cinder-leading-normal);
    /* The owning Popover/Drawer supplies the surface inset, so the panel adds no band of its own.
       A row's own inset (its padding and its 2px current-row edge) is pulled out of the surface's
       inset by the panel's margin: the words line up with the heading above the list and the hover
       face overhangs into the surface's padding. The margin is on the panel, not the list, so the
       list stays inside the panel and nothing scrolls sideways. */
    --_cinder-citation-row-inset: calc(var(--cinder-space-2) + 2px);
    margin-inline: calc(-1 * var(--_cinder-citation-row-inset));
    padding: 0;
  }

  .cinder-citation--in-place .cinder-citation__panel {
    max-block-size: none;
    overflow-y: visible;
  }

  /* Citation owns a compact sheet contract while Popover/Drawer continue to own modal focus,
     safe-area handling and dismissal. The drawer remains one raised surface; only its body carries
     the citation panel's shared 12px edge. */
  .cinder-popover__sheet:has(.cinder-citation__panel) .cinder-drawer__header {
    padding: var(--cinder-space-1) var(--cinder-space-3);
    border-block-end: 0;
    background: transparent;
  }

  .cinder-popover__sheet:has(.cinder-citation__panel) .cinder-drawer__title {
    font-size: var(--cinder-text-md);
  }

  .cinder-popover__sheet:has(.cinder-citation__panel) .cinder-drawer__body {
    padding: var(--cinder-space-2) var(--cinder-space-3);
    background: transparent;
  }
  /* One list of flat rows, however many sources there are. */
  .cinder-citation__list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .cinder-citation__item {
    min-width: 0;
    /* The foundation gives every list item a bottom margin; a row's own padding is its air, so
       the last row would otherwise end the panel on a gap and every row would stand further from
       the next than its padding says. */
    margin: 0;
  }
  /* A row is the source: its title, the domain (or the note that says why it has none) and the
     excerpt. With a safe address the whole row is the link and the open glyph ends it; the 2px
     start edge is transparent until the row is the cited one. */
  .cinder-citation__row {
    display: flex;
    align-items: flex-start;
    gap: var(--cinder-space-2);
    min-width: 0;
    padding-block: var(--cinder-space-2);
    padding-inline: var(--cinder-space-2);
    /* The row sets the title's size and leading, so `1lh` on the open glyph is the title's first
       line wherever the row stands. */
    font-size: var(--cinder-text-sm);
    line-height: var(--cinder-leading-normal);
    border-inline-start: 2px solid transparent;
    border-radius: var(--cinder-radius-sm);
    color: inherit;
    text-decoration: none;
  }
  a.cinder-citation__row:hover {
    background: var(--cinder-surface-hover);
  }
  a.cinder-citation__row:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow:
      0 0 0 2px var(--cinder-ring-offset-color),
      0 0 0 calc(2px + var(--cinder-ring-width)) var(--cinder-ring-color);
  }
  @media (forced-colors: active) {
    a.cinder-citation__row:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 2px;
      box-shadow: none;
    }
  }
  /* The cited row is marked by more than colour: an accent edge and a tinted face. */
  .cinder-citation__row[aria-current='true'] {
    border-inline-start-color: var(--cinder-accent-solid);
    background: var(--cinder-accent-background);
  }
  @media (forced-colors: active) {
    .cinder-citation__row[aria-current='true'] {
      border-inline-start-color: Highlight;
    }
  }
  .cinder-citation__row-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: var(--cinder-space-1);
    min-width: 0;
  }
  /* A title is clamped to two lines; its whole text stays in the DOM for assistive technology. */
  .cinder-citation__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    font-size: var(--cinder-text-sm);
    font-weight: var(--cinder-font-semibold);
    color: var(--cinder-text-default);
  }
  /* The domain, or the note on a source with no link or a refused one. */
  .cinder-citation__domain,
  .cinder-citation__note {
    font-size: var(--cinder-text-xs);
    color: var(--cinder-text-muted);
  }
  /* An excerpt reads as a quotation: the language's own quotation marks wrap it. */
  .cinder-citation__detail {
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-normal);
    color: var(--cinder-text-muted);
  }
  .cinder-citation__detail::before {
    content: open-quote;
  }
  .cinder-citation__detail::after {
    content: close-quote;
  }
  /* The open-in-new glyph is smaller than the title's line, so it never makes the row taller. */
  :is(.cinder-citation__row) > svg.cinder-citation__glyph {
    flex: none;
    inline-size: 0.875rem;
    block-size: 0.875rem;
    /* Centred on the title's first line: half of what that line has beyond the glyph. */
    margin-block-start: calc((1lh - 0.875rem) / 2);
    color: var(--cinder-text-muted);
  }
  @media (any-pointer: coarse) {
    .cinder-citation__marker-hit-target {
      inset-block: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
      inset-inline: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
    }
  }
}
