/* The reading serif, shared by the list rows, the deck and the prose. */
:root { --article-serif: Georgia, "Iowan Old Style", "Times New Roman", serif; }
.articles-library { max-width: 960px; margin-inline: auto; }
.article-rows { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.article-rows li + li { border-top: 1px solid var(--line); }
.article-row { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; padding: 1.4rem .75rem; text-decoration: none; color: var(--ink); }
.article-row:hover { background: var(--row-hover); }
.article-row:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.article-row-copy { min-width: 0; }
/* The row is the article in miniature, so it is set like the reader's head:
   the title in sans, the deck in the serif italic the prose is written in. */
.article-row-title {
  display: block; font-weight: 700; font-size: 1.3rem; line-height: 1.25;
  letter-spacing: -.02em; overflow-wrap: break-word;
}
.article-row:hover .article-row-title { color: var(--green-deep); }
.article-row-description {
  display: block; margin-top: .4rem;
  font-family: var(--article-serif); font-style: italic;
  font-size: 1.08rem; line-height: 1.45; color: var(--ink-soft); overflow-wrap: break-word;
}
.article-row-date { flex: none; color: var(--ink-faint); font-size: .9rem; white-space: nowrap; }
/*
 * Reader. The bar, the heading and the prose share one measure so nothing is
 * inset against anything else: "All articles" sits left and the page numbers
 * right, in the same bar above and below the text.
 */
#article-reader { max-width: 44rem; margin-inline: auto; }
.article-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem 1.25rem; flex-wrap: wrap; }
#article-pages-top { padding-bottom: 1rem; border-bottom: 1px solid var(--line-soft); }
#article-pages-bottom { margin-top: 2.75rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); }
.article-back { padding: .25rem 0; font: inherit; font-weight: 600; color: var(--ink-soft); background: none; border: 0; cursor: pointer; }
.article-back:hover { color: var(--green-deep); }
.article-back:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: var(--radius-sm); }
/* Chevron, page chooser, total, chevron. The arrows need no label. */
.article-pages { display: flex; align-items: center; gap: .4rem; color: var(--ink-soft); }
.article-step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; color: inherit;
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
}
.article-step:hover:not([aria-disabled="true"]) { color: var(--green-deep); background: var(--green-soft); }
.article-step[aria-disabled="true"] { opacity: .3; cursor: default; }
.article-page-select { width: auto; min-width: 4rem; margin: 0; }
.article-page-total { white-space: nowrap; }

.article-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: 2.25rem 0 2rem; }
.article-head-copy { min-width: 0; }
/*
 * Editorial typography, matching the newsletter reading mode in
 * PandaInUniv-ForumPlus (frontend/src/styles/pages/forum-threads.css): a
 * Georgia-first serif for the prose, sans headings against it, and an
 * accent for the drop cap and the rules. That project's accent is warm; this
 * one takes the green the rest of the site is built in.
 */
#article-reader { --accent: var(--green-deep); --accent-soft: var(--green-soft); --accent-line: var(--line); }
#article-title {
  margin: 0; font-weight: 700; font-size: clamp(1.85rem, 5.5vw, 2.7rem);
  line-height: 1.12; letter-spacing: -.02em; text-wrap: pretty; overflow-wrap: break-word;
}
#article-description {
  margin: .75rem 0 0; font-family: var(--article-serif); font-style: italic;
  font-size: 1.15rem; line-height: 1.5; color: var(--ink-soft); min-height: 0;
  text-wrap: pretty; overflow-wrap: break-word;
}
.article-date { margin: .6rem 0 0; color: var(--ink-faint); font-size: .9rem; min-height: 0; }
.article-date:empty { display: none; }
/* Admin-only, so it is an icon and not a sentence competing with the deck. */
.article-pdf {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.article-pdf:hover { color: var(--green-deep); background: var(--green-soft); border-color: var(--green); }
.article-pdf[hidden] { display: none; }

.article-prose {
  max-width: 100%; font-family: var(--article-serif);
  font-size: 1.08rem; line-height: 1.85; letter-spacing: -.01em;
  /* `anywhere` would split ordinary words mid-line; `break-word` only rescues
     a long URL that genuinely cannot fit. */
  overflow-wrap: break-word; scroll-margin-top: 1rem;
}
/* Drop cap on the opening page only, so later pages do not each start one. */
.article-prose.article-opening > p:first-child::first-letter {
  float: left; margin: .06em .06em 0 0; font-size: 3.4em; line-height: .78;
  font-weight: 700; color: var(--accent);
}
.article-prose p { margin: 0 0 1.1rem; }
.article-prose blockquote, .article-prose pre, .article-prose figure { margin: 1.5rem 0; }
/* Sans against the serif, the way the newsletter sets its headings. */
.article-prose h2, .article-prose h3 {
  font-family: var(--font); letter-spacing: -.02em; line-height: 1.3;
  margin: 2rem 0 .6rem; text-wrap: pretty;
}
.article-prose h2 { font-size: 1.3rem; }
.article-prose h3 { font-size: 1.1rem; font-weight: 600; }
.article-prose > :first-child { margin-top: 0; }
/* The prose carries its emphasis in the wording, not in bolder type. */
.article-prose strong, .article-prose b { font-weight: inherit; }
.article-prose ul, .article-prose ol { padding-left: 1.6rem; }
.article-prose li { margin-bottom: .4rem; }
/*
 * A chart carries more detail than a line of prose, so a figure is allowed
 * wider than the measure, bleeding into the margin the column leaves free.
 */
.article-prose figure { --bleed: clamp(0rem, 4vw, 4rem); margin: 1.75rem calc(-1 * var(--bleed)); }
/* Each chart carries its own intended size, so the figure lets it take that
   and only scales down when the column is narrower. */
.article-prose figure img { display: block; margin-inline: auto; }
.article-prose img { max-width: 100%; height: auto; }
.article-prose pre { max-width: 100%; overflow-x: auto; }
.article-prose pre { padding: 1rem; background: var(--paper-tint); }
/*
 * A wrapper does the scrolling so the table can stay a real table. As
 * `display: block` it was a block box with rows inside, and border-collapse
 * never drew the outer edges, so every table ended without its last rule.
 */
.article-table { margin: 1.6rem 0; overflow-x: auto; }
/* Tables stay sans and a size down, so figures read as data, not as prose. */
.article-prose table { width: 100%; border-collapse: collapse; font-family: var(--font); font-size: .9rem; letter-spacing: 0; }
.article-prose th, .article-prose td { border: 1px solid var(--line); padding: .5rem .75rem; }
/* The app left-aligns the first header of every table, because its own data
   tables open with a row-label column that a reader scans down. An article
   table has no label column: its cells are centred like every other cell, so
   a left-aligned first heading sat out of line with the column beneath it. */
.article-prose thead > tr:first-child > th:first-child { text-align: center; }
/*
 * The condition column stays put while the rest scrolls. The grid in the
 * never-married article is seven columns wide and the wrapper scrolls on a
 * narrow screen, where a ratio read five columns to the right belongs to a
 * condition that has gone off the left edge.
 *
 * It carries its own background, because what scrolls under a sticky cell
 * paints over it otherwise, and its divider is a box-shadow: under
 * border-collapse a border on a sticky cell belongs to the collapsed edge and
 * scrolls away with the neighbour. The shadow takes the same colour as those
 * borders, so on the tables narrow enough never to scroll it sits under the
 * border it replaces and shows as nothing.
 *
 * It is the cell marked scope="row" that freezes, not whichever cell happens
 * to come first. Under a rowspan the rows inside a block have no label cell
 * of their own, and taking the first child pinned their second column to the
 * left edge in the middle of the table.
 */
.article-prose thead > tr:first-child > th:first-child,
.article-prose tbody [scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}
.article-prose thead > tr:first-child > th:first-child { z-index: 2; }
/* The label column is the one that holds a sentence rather than a figure, and
   left to itself it takes whatever width its longest condition wants: on the
   grid in the never-married article that was 413px, wider than a phone, so
   the frozen column covered the screen it was meant to be read beside. A cap
   makes the text wrap instead. It has to be max-width; width and a percentage
   are both suggestions a table in auto layout is free to ignore, and do. */
.article-prose [scope="row"] { min-width: 10rem; max-width: 14rem; white-space: normal; }
/* A table of marks rather than figures: nine columns, eight of them a single
   character wide. At the ordinary padding it ran 473px, half as wide again as
   a phone, so a reader had to scroll a grid of ticks sideways to find out
   which tick belonged to which rule. Only these tables need the tighter
   setting, and having an eighth column is what distinguishes them. */
.article-prose table:has(thead th:nth-child(8)) :is(th, td) { padding: .45rem .3rem; }
.article-prose table:has(thead th:nth-child(8)) [scope="row"] {
  min-width: 6.5rem; max-width: 9rem; padding-inline: .5rem;
}
/* A table of counts, headed by a blank corner cell because the first column
   names the rows rather than a quantity. Its numbers are one or two digits
   wide, so the label column's floor is what keeps it off a phone screen. */
.article-prose table:has(thead > tr > th:first-child:empty) :is(th, td) { padding: .45rem .35rem; }
.article-prose table:has(thead > tr > th:first-child:empty) [scope="row"] {
  min-width: 5rem; max-width: 10rem; padding-inline: .4rem;
}
/* The app keeps headers on one line, which a label column cannot afford:
   capped and still unwrappable, the text ran out over the next column. */
/* And it joins the hover band, which would otherwise start at column two. */
.article-prose tbody tr:hover [scope="row"] { background: var(--row-hover); }
/* The app drops the last rule on its data tables (styles.css `tbody
   tr:last-child`), which left every article table ending in mid-air. */
.article-prose tbody tr:last-child td,
.article-prose tbody tr:last-child th { border-bottom: 1px solid var(--line); }
.article-prose blockquote {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: .75rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic; color: var(--ink-soft);
}
/* A short centred rule rather than a full-width line across the column. */
.article-prose hr { border: 0; height: 0; margin: 2rem auto; max-width: 120px; border-top: 1px solid var(--accent-line); }
/* Centred under the drawing and set in the UI face, so a caption reads as a
   label on the figure rather than as a stray line of the article's prose. */
.article-prose figcaption { margin-top: .7rem; font-family: var(--font); color: var(--ink-soft);
  font-size: .88rem; line-height: 1.5; letter-spacing: 0; text-align: center; text-indent: 0; }
.article-prose a {
  color: inherit; text-decoration: underline; text-decoration-color: var(--accent-line);
  text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.article-prose a:hover { color: var(--accent); text-decoration-color: var(--accent); }
#articles-status { color: var(--ink-soft); }
@media (max-width: 480px) {
  .article-bar { gap: .75rem; }
  .article-pages { gap: .25rem; }
  .article-page-select { min-width: 3.5rem; }
  .article-head { margin: 1.5rem 0 1.5rem; }
  #article-description { font-size: 1.05rem; }
  .article-prose { font-size: 1.02rem; }
  .article-prose.article-opening > p:first-child::first-letter { font-size: 3em; }
  .article-prose figure { --bleed: 0rem; }
}

/* Editing happens on the same article, with a small toolbar above its text. */
#article-edit { flex: none; }
.article-edit-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem 0; }
.article-editing [contenteditable="true"] { outline: 1px dashed var(--line); outline-offset: 4px; min-height: 1.5em; }
.article-editing [contenteditable="true"]:focus { outline-color: var(--green); }
.article-editing .article-prose strong, .article-editing .article-prose b { font-weight: 700; }
.article-chart-picker { padding: 1rem; margin: .5rem 0 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.article-chart-picker label { display: block; margin-bottom: .75rem; }
.article-chart-picker select, .article-chart-picker input { width: 100%; max-width: 100%; }
.article-chart-drawing { width: min(100%, 520px); margin: 0 auto; font-family: var(--font); }
/*
 * A chart belongs beside the sentences about it, not stacked above them. One
 * on its own takes half the column and the prose runs down the other half, so
 * a reader can check a claim against the diagram without scrolling away from
 * it. Two charts that sit next to each other in the document share the row
 * instead, neither floated: a pair is there to be read against itself.
 *
 * Both cases give up the bleed that lets a figure outgrow the text column,
 * which would otherwise push a floated chart under the prose beside it. The
 * pair is recognised by adjacency, because the sanitiser strips classes from
 * article markup and a wrapping div is flattened before it ever renders.
 */
@media (min-width: 40rem) {
  .article-prose figure.article-chart {
    --bleed: 0rem;
    float: left;
    /* Each chart starts below the last, so two short readings in a row cannot
       leave a second diagram floating up beside the first one's caption. */
    clear: both;
    width: calc(50% - 1rem);
    margin: 1.75rem 2rem 1.25rem 0;
  }
  .article-prose figure.article-chart:has(+ figure.article-chart),
  .article-prose figure.article-chart + figure.article-chart {
    float: none;
    display: inline-block;
    /* Short of half, because the link stands in the gap between the two. */
    width: calc(50% - 1rem);
    margin-block: 1.75rem; margin-inline: 0;
    vertical-align: top;
  }
  .article-prose figure.article-chart:has(+ figure.article-chart) { margin-right: 2rem; }
  /* A heading starts its own section, never alongside the previous figure. */
  .article-prose h2 { clear: both; }
}
.article-chart-drawing svg { display: block; width: 100%; height: auto; }
.article-chart-link { display: inline-block; margin-top: .5rem; font: .85rem var(--font); }
.article-chart-remove { margin: .5rem; }
#article-edit-status:empty { display: none; }
.article-editing .article-prose figure { --bleed: 0rem; }
.article-bar[hidden], .article-edit-toolbar[hidden], #article-edit[hidden],
#article-edit-tools[hidden], .article-chart-picker[hidden] { display: none; }

.lesson-heading-row { display: flex; align-items: center; gap: .75rem; }
.lesson-heading-row #lesson-title { flex: 1; }
#lesson-edit { flex: none; }
#lesson-edit-tools[hidden] { display: none; }
#lesson-description:empty:not([contenteditable="true"]) { display: none; }
.tutorial-reader.article-editing #lesson-pagination { visibility: hidden; }
.tutorial-reader.article-editing #lesson-description { min-height: 1.5em; }

#article-publication { flex: none; }
#article-publication[hidden] { display: none; }
.article-publication-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.article-publication-switch button { background: var(--paper); color: var(--ink-soft); border: 0; border-radius: 0; padding: .4rem .65rem; }
.article-publication-switch button[aria-pressed="true"] { background: var(--green-soft); color: var(--green-deep); }
#article-publication-status { display: block; max-width: 15rem; font-size: .8rem; }
.article-draft-label { margin-left: .5rem; color: var(--ink-soft); font-size: .8rem; }
@media (max-width: 480px) { .article-head { flex-wrap: wrap; } }

#article-pages-top { justify-content: flex-start; gap: .75rem; }
#article-pages-top .article-pages { margin-inline-start: auto; }
.article-editing #article-pages-top .article-back,
.article-editing #article-pages-top .article-pages { display: none; }
