/* styles/sections/annotated-ticket.css
 * A Jira ticket transcribed as live HTML, sliced into rows, with margin notes joined to the rows
 * they explain. Frames: Annotated Ticket mZ3mQ (1440), qx1FN (390), xrO5l (1920).
 *
 * <figure class="aticket">
 *   <div class="aticket__row aticket__row--head">
 *     <div class="aticket__cell aticket__head">.artifact-bar, .aticket__body</div>
 *     <div class="aticket__note" style="position-anchor:--aticket-note-1;--note-top:197px">label, text</div>
 *   </div>
 *   <ol class="aticket__list"><li class="aticket__row"><div class="aticket__cell aticket__criterion">...</div>[note]</li></ol>
 * </figure>
 *
 * From D each cell is 800 wide (62.5% of the row below 1280) and the note (432 text after a 48px
 * connector) sits beside it, level with the chips row it points at: CSS anchor positioning where
 * supported (the chips row carries the matching anchor-name inline), else the frame's offset
 * (--note-top). On M the note follows its cell in flow, behind a 2px rule, and the card resumes
 * under it, as qx1FN draws it. Strokes are drawn inside each cell as Pencil draws them. */
@layer sections {
  .aticket {
    --cell-w: 100%;
    --cell-pad: var(--space-20);
    --cell-edge: var(--rule-edge);
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
  }

  .aticket p { margin: 0; }

  .aticket__list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .aticket__row { position: relative; }

  .aticket__cell {
    width: var(--cell-w);
    background: var(--white);
    box-shadow: inset 1px 0 var(--cell-edge), inset -1px 0 var(--cell-edge);
  }

  /* Head: the Jira bar, title row, status line and the criteria label */
  .aticket__head {
    overflow: hidden;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: inset 1px 0 var(--cell-edge), inset -1px 0 var(--cell-edge), inset 0 1px var(--cell-edge);
  }

  .aticket__head .artifact-bar {
    --artifact-bar-pad: var(--space-20);
    --artifact-bar-app-weight: 600;
    box-shadow: inset 1px 0 var(--cell-edge), inset -1px 0 var(--cell-edge), inset 0 1px var(--cell-edge);
    line-height: 16px;
  }

  .aticket__head .artifact-bar > span { white-space: pre-wrap; }

  .aticket__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-20);
    padding: 28px var(--cell-pad) var(--space-8);
  }

  .aticket__title-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-24);
  }

  .aticket__ticket-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 21px;
    letter-spacing: -0.38px;
  }

  .aticket__status {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--space-6);
    padding: 5px 9px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: var(--paper);
    font-size: 13px;
    font-weight: 600;
    line-height: 16px;
  }

  .aticket__status-line {
    display: flex;
    flex-direction: column;
    gap: var(--space-10);
    padding: 14px 18px 14px 15px;
    border-left: 3px solid var(--fern);
    background: var(--fern-3);
    font-size: 16px;
    line-height: 25px;
  }

  .aticket__ac-label {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 14px;
    letter-spacing: 1px;
    white-space: pre-wrap;
    color: var(--ink-55);
  }

  /* Criteria: number, then title, text and chips; a hairline inset by the cell padding above */
  .aticket__criterion {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: var(--space-16);
    padding: 23px var(--cell-pad) 22px;
  }

  .aticket__criterion::before {
    content: "";
    position: absolute;
    top: 0;
    inset-inline: var(--cell-pad);
    height: 1px;
    background: var(--line-2);
  }

  .aticket__criterion--short { padding-block: 17px 16px; }

  .aticket__list > li:last-child .aticket__criterion {
    padding-bottom: 48px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: inset 1px 0 var(--cell-edge), inset -1px 0 var(--cell-edge), inset 0 -1px var(--cell-edge);
  }

  .aticket__num {
    flex: none;
    min-width: 8px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 16px;
    color: var(--ink-55);
  }

  .aticket__content {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-8);
    min-width: 0;
  }

  .aticket__criterion--short .aticket__content { gap: var(--space-6); }

  .aticket__title {
    font-size: 16px;
    font-weight: 600;
    line-height: 19px;
  }

  .aticket__text {
    font-size: 15px;
    line-height: 23px;
  }

  /* Source chips: decision ids and document names, not links */
  .aticket__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-8);
  }

  .aticket__chips > span {
    max-width: 100%;
    padding: 1px 6px;
    border: 1px solid var(--chip-edge);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 14px;
    color: var(--fern);
  }

  .aticket__chips--pending > span {
    border-color: var(--orange-40);
    color: var(--orange-ink);
  }

  /* Margin notes. --note-shift (set inline) moves a note off its chips row's top. */
  .aticket__note {
    --note-shift: 0px;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    margin: 14px 0 22px;
    padding: 2px 0 2px 12px;
    border-left: 2px solid var(--fern);
  }

  .aticket__note-label {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 14px;
    letter-spacing: 1px;
    color: var(--fern);
  }

  .aticket__note--pending .aticket__note-label { color: var(--orange-ink); }

  .aticket__note-text {
    font-size: 15px;
    line-height: 23px;
    color: var(--ink-muted);
  }

  @media (width < 900px) {
    .aticket__chips--stack-m {
      flex-direction: column;
      align-items: flex-start;
    }

    .aticket__criterion--short .aticket__chips--stack-m { gap: var(--space-6); }
  }

  @media (min-width: 900px) {
    .aticket {
      --cell-w: min(800px, 62.5%);
      --cell-pad: var(--space-32);
    }

    .aticket__title-row {
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
    }

    .aticket__ticket-title {
      font-size: 26px;
      line-height: 27px;
      letter-spacing: -0.5px;
    }

    .aticket__note {
      position: absolute;
      top: var(--note-top);
      left: var(--cell-w);
      width: min(480px, calc(100% - var(--cell-w)));
      margin: 0;
      padding: 0 0 0 64px;
      border: 0;
    }

    /* The 48px connector, level with the label's middle */
    .aticket__note::before {
      content: "";
      position: absolute;
      top: 7px;
      left: 0;
      width: 48px;
      height: 1px;
      background: var(--fern);
    }

    .aticket__note--pending::before { background: var(--orange); }

    @supports (anchor-name: --a) {
      .aticket__note { top: calc(anchor(top) + var(--note-shift)); }
    }
  }

  @media (forced-colors: active) {
    .aticket__cell { border-inline: 1px solid; }
    .aticket__note::before { background: CanvasText; }
  }
}
