/* ltms.sh: the structure of every page. Each colour, font and size of spacing here is a custom
   property from tokens.css; this file writes no such value of its own (only 0, 100%, auto, keywords, and the
   skip link's clip, inset(50%)). */

html {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: var(--font-text);
  font-size: var(--text-size);
  font-weight: var(--weight-text);
  line-height: var(--leading);
}

html[lang|="he"] body {
  line-height: var(--leading-hebrew);
}

.page {
  box-sizing: border-box;
  max-inline-size: var(--page-width);
  margin-inline: auto;
  padding: var(--page-top) var(--page-gutter) var(--page-bottom);
}

/* The skip link: out of sight until it has the focus, then the first thing on the page */
.skip {
  margin-block-end: var(--space-s);
}

.skip:not(:focus) {
  position: absolute;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Links: underlined, the one sign of a link (no hue) */
a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline-width);
  text-underline-offset: var(--underline-offset);
}

a:hover {
  text-decoration-thickness: var(--underline-hover-width);
}

a:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

/* Room above and below a link that Tab scrolls into view, so its outline is never cut off at the screen's edge */
a {
  scroll-margin-block: var(--focus-room);
}

/* Every link is a target of its own, at least --target-min on each side (no link sits inside a sentence) */
.skip,
.bar a,
.links a,
td a {
  display: inline-block;
  min-block-size: var(--target-min);
  min-inline-size: var(--target-min);
  padding-block: var(--target-pad-block);
}

/* The header: the link home (on every page but the landing) at the start, the language link at the end */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--bar-gap);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--small-size);
}

.bar .lang {
  margin-inline-start: auto;
}

.bar .home {
  display: inline-flex;
  position: relative;
  align-items: center;
}

/* The logo, "3 · Rows": the mark with the name set in its rows, one drawing, inline in the header of every page
   (the landing's heading, and the link home on the others), in the logo's colour. Its name, for a screen reader
   and for a reader that does not draw it, is the hidden text beside it. */
.logo {
  flex: none;
  inline-size: var(--logo-width);
  block-size: var(--logo-height);
  color: var(--logo);
}

/* Out of sight and still read, as the skip link is when it has no focus: the name beside the logo. What holds it
   (the heading, the link home) is position: relative, so the name wraps inside that box, not the window's. */
.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
}

.links {
  list-style: none;
  margin: 0 0 var(--space-m);
  padding: 0;
}

.links li {
  margin-block-end: var(--space-xs);
}

/* Headings: the page's title over a rule, the sections' headings over a thinner one */
h1,
h2 {
  font-weight: var(--weight-heading);
  line-height: var(--leading-heading);
}

h1 {
  display: flex;
  position: relative;
  align-items: center;
  margin: var(--space-xs) 0 var(--space-m);
  padding-block-end: var(--space-s);
  border-block-end: var(--title-rule-width) solid var(--rule);
  font-size: var(--h1-size);
}

h2 {
  margin: var(--space-xxl) 0 var(--space-s);
  padding-block-end: var(--space-xs);
  border-block-end: var(--rule-width) solid var(--rule);
  font-size: var(--h2-size);
}

/* Text */
p {
  margin: 0 0 var(--space-m);
}

.lead {
  max-inline-size: var(--lead-width);
  font-size: var(--lead-size);
}

.note {
  font-size: var(--small-size);
  color: var(--muted);
}

strong {
  font-weight: var(--weight-strong);
}

ul,
ol {
  margin: 0 0 var(--space-m);
  padding-inline-start: var(--list-indent);
}

li {
  margin-block-end: var(--space-xs);
}

.facts > li {
  margin-block-end: var(--space-m);
}

dl {
  margin: 0 0 var(--space-m);
}

dt {
  margin-block-start: var(--space-m);
}

dd {
  margin: 0;
  margin-inline-start: var(--list-indent);
}

/* The facts, as rows: each row's name on a grey, its value beside it */
table {
  inline-size: 100%;
  margin: 0 0 var(--space-m);
  border-collapse: collapse;
  font-size: var(--table-size);
}

th,
td {
  padding: var(--cell-pad-block) var(--cell-pad-inline);
  border: var(--rule-width) solid var(--rule);
  text-align: start;
  vertical-align: baseline;
}

th {
  inline-size: var(--th-width);
  white-space: nowrap;
  background: var(--th-bg);
  font-weight: var(--weight-heading);
}

td {
  overflow-wrap: anywhere;
}

/* Code: a command or a path inside a sentence or a row, and the boxed commands and output */
code,
pre {
  font-family: var(--font-code);
}

code {
  font-size: var(--code-size);
  overflow-wrap: anywhere;
}

/* A command or a path inside a sentence or a row, a name marked .whole inside a command, a Hebrew prefix held in
   .whole with the command its maqaf joins, and a command held with its punctuation in .with-punctuation (below):
   kept whole on one line, and broken inside only where it is longer than the line. (A command broken across two
   lines of right-to-left text starts at the left end of one line and ends at the right end of the next.) */
:not(pre) > code,
.whole,
.with-punctuation {
  display: inline-block;
  max-inline-size: 100%;
}

/* A command and the punctuation that touches it, "(" before it or ",", ":", ")", "’s" after it, held together in
   .with-punctuation: never broken between the command and its punctuation, so the punctuation stays on the line
   of the character it touches. In left-to-right text the unit is the box, and the command is set in it as text.
   In right-to-left text the command keeps its own box inside the unit, and the unit is narrower than the line by
   --punctuation-room, the room its punctuation takes beside that box. A unit that holds a .whole (a Hebrew prefix
   and its command) keeps the whole line, since a .whole narrower than its prefix and command breaks after the
   maqaf; its one mark may then pass the line by its own width, into the cell's padding. */
.with-punctuation {
  white-space: nowrap;
}

.with-punctuation > code,
.with-punctuation > .whole {
  white-space: normal;
}

.with-punctuation > code {
  display: inline;
}

.with-punctuation:dir(rtl) {
  max-inline-size: calc(100% - var(--punctuation-room));
}

.with-punctuation:dir(rtl) > code {
  display: inline-block;
}

.with-punctuation:dir(rtl):has(> .whole) {
  max-inline-size: 100%;
}

pre {
  box-sizing: border-box;
  inline-size: fit-content;
  max-inline-size: 100%;
  margin: 0 0 var(--space-s);
  padding: var(--code-pad-block) var(--code-pad-inline);
  color: var(--text);
  background: var(--code-bg);
  border: var(--rule-width) solid var(--rule);
  font-size: var(--pre-size);
  line-height: var(--leading-code);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre code {
  font-size: inherit;
}

/* An option (--max) is never broken between its hyphens and its name */
.nowrap {
  white-space: nowrap;
}

/* A fact only the site's owner can give: marked, never filled in for him */
.todo {
  border: var(--rule-width) dashed var(--rule);
  padding: var(--code-pad-block) var(--code-pad-inline);
}

.site-footer {
  margin-block-start: var(--space-xxl);
  padding-block-start: var(--space-m);
  border-block-start: var(--rule-width) solid var(--rule);
  font-size: var(--footer-size);
  color: var(--muted);
}
