/* styles/editorial-blocks.css
 * Article blocks from the Editorial board (ouGVN), split from editorial.css by concern:
 * lists, tables, code and Prism tokens, margin figures, related sidenotes, definition lists,
 * FAQ, pull lines, quote marks, scribble underline and pull quotes. Load it right after
 * editorial.css (same layer, same order as before the split); the --ed-* and --rail-*
 * properties it reads are set on .article in editorial.css. */
@layer editorial {
  /* Lists keep native list semantics and markers; ::marker carries the tone. */
  .prose ul,
  .prose ol {
    display: flex;
    flex-direction: column;
    gap: var(--space-10);
    margin: 0;
    padding-inline-start: var(--space-24);
  }

  .prose ul {
    list-style: square;
  }

  .prose ol {
    gap: var(--space-16);
    padding-inline-start: 28px;
    list-style: decimal;
  }

  .prose li::marker {
    color: var(--fern);
  }

  .prose ol li::marker {
    font-family: var(--font-display);
    font-weight: 500;
  }

  .prose li > :is(ul, ol) {
    margin-top: var(--space-10);
  }

  /* Table. Wrap in .table-scroll (role="region", tabindex="0", aria-label). */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Fixed layout: the first column takes the board's 200/300/360px, the rest share equally. */
  .prose table {
    width: 100%;
    min-width: 750px;
    table-layout: fixed;
    border-collapse: collapse;
    font-family: var(--font-body);
    font-size: var(--ed-table-size);
    line-height: 1.45;
    text-align: start;
  }

  .prose caption {
    padding-bottom: var(--space-8);
    font-size: 13px;
    text-align: start;
    color: var(--ink-2);
  }

  .prose th,
  .prose td {
    padding: var(--space-12) var(--space-16) var(--space-12) 0;
    text-align: start;
    vertical-align: top;
    color: var(--ink-2);
  }

  .prose thead th {
    padding-top: 0;
    padding-bottom: var(--space-10);
    border-bottom: 1px solid var(--ink);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.2px;
    color: var(--ink-muted);
  }

  .prose tr > :first-child {
    width: var(--ed-table-first);
  }

  .prose tbody tr {
    border-bottom: 1px solid var(--rule-cell);
  }

  .prose tbody th {
    font-weight: 400;
    color: var(--ink);
  }

  @media (min-width: 900px) {
    .prose table {
      min-width: 0;
    }
  }

  /* Code block. Give <pre> tabindex="0" so it scrolls from the keyboard. */
  .prose pre {
    display: flex;
    flex-direction: column;
    gap: var(--space-10);
    margin: 0;
    padding: var(--ed-code-pad);
    overflow-x: auto;
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink);
  }

  .prose pre[data-lang]::before {
    content: attr(data-lang);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.2;
    color: var(--ink-55);
  }

  .prose pre code {
    font-family: var(--font-mono);
    font-size: var(--ed-code-size);
    line-height: 1.6;
    white-space: pre;
    tab-size: 2;
  }

  /* Prism theme, token colors only. Contrast on paper is 4.5:1 or better. */
  .token.comment,
  .token.prolog,
  .token.doctype,
  .token.cdata {
    color: var(--ink-55);
    font-style: italic;
  }

  .token.punctuation,
  .token.operator {
    color: var(--ink-2);
  }

  .token.keyword,
  .token.atrule,
  .token.selector,
  .token.tag {
    color: var(--fern);
    font-weight: 600;
  }

  .token.string,
  .token.attr-value,
  .token.char {
    color: var(--magenta);
  }

  .token.function,
  .token.class-name,
  .token.property,
  .token.attr-name {
    color: var(--slate);
  }

  .token.number,
  .token.boolean,
  .token.constant {
    color: var(--success);
  }

  /* Margin figure: figcaption sits in the margin track (first child), media in the text track. */
  .prose figure {
    margin: 0;
  }

  .prose figure.caption--margin {
    display: grid;
    gap: var(--space-10);
    padding-block: var(--space-16);
  }

  .caption--margin figcaption {
    font-family: var(--font-display);
    font-size: 15px;
    font-style: italic;
    line-height: 1.45;
    color: var(--ink-2);
  }

  .caption--margin figcaption strong {
    display: block;
    margin-bottom: var(--space-6);
    font-style: normal;
    font-weight: 500;
    color: var(--fern);
  }

  .prose figure img,
  .prose figure svg {
    display: block;
    max-width: 100%;
    height: auto;
  }

  /* Related sidenote: follows its paragraph and sits in the side track on D and W. */
  .prose aside.related {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-4) 0 var(--space-4) var(--space-14);
    border-inline-start: 2px solid var(--fern);
    align-self: start;
  }

  .related__index {
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.2;
    color: var(--ink-2);
  }

  .related__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--fern);
  }

  .related__deck {
    max-width: 280px;
    margin: 0;
    font-family: var(--font-display);
    font-size: 15px;
    font-style: italic;
    line-height: 1.45;
    color: var(--ink-2);
  }

  @media (min-width: 900px) {
    .article--rail figure.caption--margin {
      grid-template-columns: subgrid;
      grid-column: 1 / -1;
      column-gap: var(--rail-gap);
    }

    .article--rail .caption--margin figcaption {
      grid-column: 1;
      grid-row: 1;
      padding-top: 2px;
    }

    .article--rail .caption--margin > :not(figcaption) {
      grid-column: 2;
      grid-row: 1;
    }

    .prose aside.related {
      padding-left: 0;
      border-inline-start: 0;
      padding-block-start: var(--space-4);
    }

    .related__title {
      font-size: 18px;
    }
  }

  /* Definition list: .dl-intro is the lead-in, each dt/dd pair is a ruled row */
  .prose .dl-intro {
    font-family: var(--prose-font);
  }

  .prose dl {
    display: flex;
    flex-direction: column;
    margin: 0;
  }

  .prose dl > div {
    display: grid;
    gap: var(--space-10);
    padding-block: var(--space-16);
    border-top: 1px solid var(--ink-16);
  }

  /* The frames close the list with a rule and, on the rail, set each pair 28px apart. */
  .prose dl > div:last-child {
    border-bottom: 1px solid var(--ink-16);
  }

  .article--rail dl {
    row-gap: var(--ed-gap);
  }

  .prose dt {
    padding-top: 3px;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--fern);
  }

  .prose dd {
    margin: 0;
    font-family: var(--prose-font);
  }

  .prose dl dd {
    line-height: var(--ed-dd-lh);
  }

  @media (min-width: 900px) {
    .article--rail dl,
    .article--rail dl > div {
      grid-column: 1 / 3;
    }

    .article--rail dl {
      display: grid;
      grid-template-columns: subgrid;
    }

    .article--rail dl > div {
      grid-template-columns: subgrid;
      column-gap: var(--rail-gap);
    }

    .article--rail dl > div > dt {
      grid-column: 1;
    }

    .article--rail dl > div > dd {
      grid-column: 2;
    }
  }

  /* FAQ: a margin label and, per row, either one accordion item (accordion.css) or the
     board's static item (.prose-faq > div: an h3 question over its answer, 8px apart). */
  .prose-faq {
    display: grid;
    gap: var(--space-10);
  }

  .prose-faq + .prose-faq {
    padding-top: var(--space-8);
  }

  .prose-faq > div:not(.accordion) {
    display: grid;
    gap: var(--space-8);
  }

  .prose .prose-faq > div:not(.accordion) h3 {
    padding-top: 0;
    letter-spacing: -0.01em;
  }

  .prose-faq__label {
    font-family: var(--font-display);
    font-size: 15px;
    font-style: italic;
    line-height: 1.2;
    color: var(--ink-2);
  }

  @media (min-width: 900px) {
    .article--rail .prose-faq {
      grid-template-columns: subgrid;
      grid-column: 1 / -1;
      column-gap: var(--rail-gap);
    }

    .article--rail .prose-faq__label {
      grid-column: 1;
      padding-top: 3px;
    }

    .article--rail .prose-faq:has(> .accordion) .prose-faq__label {
      padding-top: var(--space-20);
    }

    .article--rail .prose-faq > div {
      grid-column: 2;
    }
  }

  /* Pull lines */
  /* A pull line balances its lines like a heading, so a two-line pull never ends on one
     word (team review, Oct 16) */
  .pull-line {
    text-wrap: balance;
    margin: 0;
    padding: var(--ed-pull-line-pad);
    font-family: var(--font-display);
    font-size: var(--ed-pull-line);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: var(--ed-pull-line-ls);
    color: var(--fern);
  }

  .pull-line--rule {
    padding: var(--space-20) 0 var(--space-20) var(--space-20);
    border-inline-start: 3px solid var(--fern);
    font-size: var(--ed-pull-rule);
    letter-spacing: var(--ed-pull-rule-ls);
  }

  @media (min-width: 900px) {
    .pull-line--rule {
      padding-inline-start: var(--space-40);
    }
  }

  @media (min-width: 1680px) {
    .article--rail > .pull-line:not(.pull-line--rule) {
      grid-column: 2 / -1;
    }

    .pull-line--rule {
      padding: var(--space-28) 0 var(--space-28) var(--space-48);
      border-inline-start-width: 4px;
      line-height: 0.95;
    }
  }

  /* Quote mark and scribble underline */
  .quote-mark {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 0.95;
    letter-spacing: -0.025em;
    color: var(--quote-mark-color, var(--ink));
  }

  .quote-mark--fern {
    --quote-mark-color: var(--fern);
  }

  .quote-mark--inverse {
    --quote-mark-color: var(--white);

    line-height: 1.05;
    letter-spacing: -0.02em;
  }

  /* Decorative only: the underline is the board's scribble (assets/figures/ds), used as a mask
     filled from --orange, never the sole cue. It sits behind the words; the first 0.62em is
     repeated in front, as the board layers it. Stroke weight follows the viewport (2.5, 3, 4). */
  .scribble-underline {
    position: relative;
    display: inline-block;
    isolation: isolate;
  }

  .scribble-underline::before,
  .scribble-underline::after {
    content: "";
    position: absolute;
    inset: auto 0 var(--ed-scribble-bottom, -0.2em);
    height: var(--ed-scribble-h, 0.28em);
    background: var(--orange);
    -webkit-mask: var(--ed-scribble-mask, url("/assets/figures/ds/scribble-underline.svg")) 0 0 / 100% 100% no-repeat;
    mask: var(--ed-scribble-mask, url("/assets/figures/ds/scribble-underline.svg")) 0 0 / 100% 100% no-repeat;
    pointer-events: none;
  }

  .scribble-underline::after {
    z-index: -1;
  }

  .scribble-underline::before {
    z-index: 1;
    clip-path: inset(0 calc(100% - 0.62em) 0 0);
  }

  /* Pull quotes. Attribution is the .attribution primitive on the figcaption. */
  .pull-quote {
    margin: 0;
  }

  .pull-quote--scribble {
    padding-block: var(--ed-quote-pad);
  }

  .pull-quote blockquote {
    margin: 0;
  }

  .pull-quote blockquote p {
    max-width: var(--ed-quote-max);
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--ed-quote);
    font-style: italic;
    font-weight: 600;
    line-height: var(--ed-quote-lh);
    letter-spacing: var(--ed-quote-ls);
    color: var(--ink);
    text-wrap: balance;
  }

  .pull-quote .attribution {
    margin-top: var(--space-16);
  }

  .pull-quote--scribble blockquote p {
    max-width: none;
    font-size: var(--ed-quote-scribble);
    font-style: normal;
    line-height: 0.95;
    letter-spacing: var(--ed-quote-scribble-ls);
    color: var(--fern);
  }

  /* The open mark hangs in the gutter: zero width, shifted left by its own width plus a hair. */
  .pull-quote--scribble .quote-mark {
    display: inline-block;
    width: 0;
    overflow: visible;
    letter-spacing: inherit;
    color: var(--fern);
    transform: translateX(var(--ed-mark-x));
  }
}
