/*
 * The Docs view: the list of documents on the left and the document on the right, with its
 * headings, code blocks and their captions, code colouring, tables, quotes and images. Used by
 * the Docs view in the dialog.
 * Colours, fonts and spacing come from the custom properties in tokens.css; this file
 * never writes a colour value (StyleRulesTests). More in
 * docs/ADR-010-the-palette-borrowed-from-theyard.md.
 */

/* #region docs */
.docs {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--space-4);
}

.docs nav {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  border-right: 1px solid var(--color-border);
  padding-right: var(--space-3);
}

.docs nav h3 {
  font-size: var(--readout-size);
  letter-spacing: var(--readout-tracking);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: var(--space-3) 0 var(--space-1);
}

.docs nav button {
  all: unset;
  /* all: unset leaves the button content-box, and a full-width button plus its padding ran past the
     column (a sideways scrollbar under the list at 1440). */
  box-sizing: border-box;
  display: block;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
  width: 100%;
}

.docs nav button:hover,
.docs nav button[aria-current='page'] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.docs nav button:focus-visible {
  outline: var(--focus-ring);
}

.docs article {
  overflow: auto;
  scrollbar-width: thin;
  padding-right: var(--space-3);
}

/* The measure belongs to the text, not to the box that scrolls: with the width on the box, its
   scrollbar stood a hand's width in from the panel's edge with nothing between. */
.docs article > * {
  max-width: 80ch;
}

.docs article h1 {
  font-size: var(--text-2xl);
  padding-bottom: var(--space-2);
  /* The gold rule is a background strip along the foot of the heading. A border-image here also
     painted a gold bar at the heading's right end. */
  border-bottom: var(--rule-width) solid transparent;
  background: var(--gradient-gold) left bottom / 100% var(--rule-width) no-repeat;
  display: block;
  width: fit-content;
}

/* A document's first heading gets focus from code, so a screen reader starts at the title. It is
   not a control, so it shows no focus ring: a ring here would be clipped by the scrolling article
   and read as a bar beside the title. */
.docs article h1:focus,
.docs article h2:focus {
  outline: none;
}

/* Document headings sit on their own line. The .panel h2 rule in page.css makes h2 inline-block
   for the dialog title, and a document is inside the panel, so this rule sets it back. */
.docs article h2 {
  font-size: var(--text-lg);
  margin-top: var(--space-6);
  display: block;
  width: fit-content;
}

.docs article h3 {
  font-size: var(--text-md);
  margin-top: var(--space-4);
}

.docs article pre {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  overflow: auto;
  font-family: var(--font-code);
  font-size: var(--text-sm);
  color: var(--color-code-text);
  line-height: 1.45;
}

.docs article pre .caption {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.docs article code {
  font-family: var(--font-code);
  font-size: 0.95em;
  background: var(--color-surface-muted);
  padding: 0 var(--space-1);
  border-radius: var(--radius-xs);
}

.docs article pre code {
  background: none;
  padding: 0;
}

.docs article .tok-comment {
  color: var(--color-code-comment);
}

.docs article .tok-keyword {
  color: var(--color-code-keyword);
}

.docs article .tok-string {
  color: var(--color-code-string);
}

.docs article table {
  margin: var(--space-3) 0;
}

.docs article th,
.docs article td {
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  white-space: normal;
}

.docs article th {
  position: static;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--text-sm);
  color: var(--color-heading);
}

/* Images in a document get a frame that matches the panel style: a deep teal border, a thin
   gold outline drawn with box-shadow, and a soft drop shadow. */
.docs article img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 3px solid var(--color-teal-deep);
  box-shadow: 0 0 0 1.5px var(--color-gold), var(--shadow-md);
  border-radius: var(--radius-sm);
}

.docs article p.figure {
  margin: var(--space-4) 0;
}

.docs article blockquote {
  margin: var(--space-3) 0;
  padding: var(--space-2) var(--space-3);
  border-left: var(--rule-width) solid var(--color-gold);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
}
/* #endregion docs */
