/*
 * Rules prose.
 *
 * Everything under `.prose` is author-written markdown, so the selectors are
 * element-level rather than class-level.
 */

.prose {
  max-width: var(--measure);
  font-size: var(--text-md);
  /* The one surface the reader's line-spacing control acts on. */
  line-height: var(--leading-reading);
  /*
   * Rules text carries things with no break opportunities in them — the image
   * credits in High Frontier are bare Wikimedia URLs, the longest of them 620px
   * of unbreakable string in a 358px column. A word that cannot fit on a line
   * of its own does not wrap, it hangs off the side, and the page it is on
   * scrolls sideways into empty margin.
   */
  overflow-wrap: break-word;
}

.prose > * + * {
  margin-top: var(--space-4);
}

/*
 * A section heading gets more room above it than a paragraph break does. It is
 * the largest division on the page and has to read as one — set flush with the
 * paragraph before it, a new section of the rules looked like a new sentence.
 *
 * `.section-heading` in components.css has said `margin: var(--space-7) 0 …`
 * all along, and lost: it is the same specificity as the rule above and
 * components.css loads first, so the generic gap overwrote it on every heading
 * in every rulebook. Naming the parent here is what settles it, and putting it
 * beside the rule it is arguing with is what stops it being settled again by
 * accident.
 *
 * Bare `h2` as well as the wrapper, because the bookmarkable content types get
 * the wrapper from `enhanceHeadings` and the rest — About, a glossary's prose —
 * write their headings straight into the markdown.
 */
.prose > * + .section-heading,
.prose > * + h2 {
  margin-top: var(--space-7);
}

.prose h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
}

.prose h3 {
  margin-top: var(--space-6);
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: var(--tracking-normal);
}

.prose h4 {
  margin-top: var(--space-5);
  font-size: var(--text-base);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.prose h3,
.prose h4 {
  scroll-margin-top: calc(var(--header-height) + var(--section-bar-height) + var(--space-4));
}

.prose ul,
.prose ol {
  padding-left: var(--space-5);
}

.prose li + li {
  margin-top: var(--space-2);
}

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

.prose blockquote {
  padding-left: var(--space-4);
  border-left: 3px solid var(--line-strong);
  color: var(--ink-muted);
  font-style: italic;
}

.prose strong {
  font-weight: 700;
}

.prose code {
  padding: 0.1em 0.35em;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}

.prose--intro {
  margin-bottom: var(--space-6);
  color: var(--ink-muted);
}

/* ------------------------------------------------------------- figures */

.figure {
  margin-block: var(--space-5);
}

.figure img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.figure figcaption {
  margin-top: var(--space-2);
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

/* ------------------------------------------------------------ callouts */

.callout {
  display: block;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-sunken);
  border-left: 3px solid var(--line-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--text-base);
}

.callout > * + * {
  margin-top: var(--space-3);
}

.callout__title {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.callout--inline {
  display: block;
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--ink-muted);
  font-size: var(--text-base);
}

/* -------------------------------------------------------------- tables */

.table-scroll {
  overflow-x: auto;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}

.prose th,
.prose td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--surface-sunken);
  font-weight: 700;
}

/* --------------------------------------------------------- cross-links */

/*
 * Cross-references have to read as references, not as ordinary links — and
 * the difference cannot rest on colour alone. Each carries its own underline
 * style as well as its own hue: glossary terms are dotted, rulebook sections
 * are dashed, plain links stay solid.
 */
.term-link {
  color: var(--term);
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.term-link:hover,
.term-link:focus-visible {
  background: var(--term-wash);
  color: var(--term);
  text-decoration-style: solid;
}

.rule-link {
  color: var(--rule);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.rule-link:hover,
.rule-link:focus-visible {
  background: var(--rule-wash);
  color: var(--rule);
  text-decoration-style: solid;
}

/* ================================================== my reference */

/*
 * The reader's own page. Everything below is drawn by `my-reference.js` out of
 * their bookmarks, so nothing here exists at build time except the empty state.
 */

.reference-empty {
  display: grid;
  gap: var(--space-4);
  max-width: var(--measure);
}

.reference-empty__lead {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

.reference-empty__how,
.reference-empty__why {
  color: var(--ink-muted);
}

/* The control being described, drawn as it appears beside a heading. */
.reference-empty__demo {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-1);
  border: 1px solid var(--marker);
  border-radius: var(--radius);
  color: var(--marker);
  translate: 0 0.15em;
}

.reference-empty__where {
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}

/* ------------------------------------------------- contents of this page */

.reference-contents {
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-sunken);
  border-radius: var(--radius-lg);
}

.reference-contents__list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: reference;
}

.reference-contents__list li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
}

.reference-contents__list a {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  text-decoration: none;
}

.reference-contents__list a:hover {
  text-decoration: underline;
}

/* Which document it came from — the same answer the eyebrow gives below. */
.reference-contents__from {
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--text-2xs);
}

/* --------------------------------------------------------- sections */

.reference-section + .reference-section {
  margin-top: var(--space-7);
}

/*
 * The eyebrow, and the way back. Two documents in one game can carry the same
 * heading, so a heading here needs to say where it is from — and that label is
 * also the most honest place to put "read this where it actually lives".
 */
.reference-source {
  margin-bottom: var(--space-1);
}

.reference-source a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  text-decoration: none;
}

.reference-source a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.reference-section .section-heading {
  margin-top: 0;
}

.reference-section__body > * + * {
  margin-top: var(--space-4);
}

/* ---------------------------------------------------- states */

.reference-missing {
  color: var(--ink-faint);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}

.reference-section--missing .section-heading h2 {
  color: var(--ink-faint);
}

/* Removed, but still here until the page is next loaded. */
.reference-section.is-removed {
  opacity: 0.45;
}

.reference-removed {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}

.reference-removed__undo {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent-strong);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* The removed section keeps its own control readable while it is dimmed. */
.reference-section.is-removed .reference-removed {
  opacity: 1;
}
