/* The inner pages of the site: the head of a page, the prose, the tables, the callouts, the cards, the lanes of the roadmap
   and the releases. Loaded after app.css, which holds the tokens: nothing here sets a colour of its own, so light and dark
   follow the page. */

/* The links to the pages: the current page is marked like the current section of the home page */

.site-nav-links a[aria-current="page"] {
  color: var(--color-accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

/* The menu of a small screen: the links of the header are hidden under 860px, and the menu takes their place */

.nav-menu {
  display: none;
  position: relative;
}

.nav-menu summary {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -6px -10px;
  list-style: none;
  cursor: pointer;
  color: var(--color-text);
}

.nav-menu summary::-webkit-details-marker {
  display: none;
}

.nav-menu[open] summary {
  color: var(--color-accent-ink);
}

.nav-menu-list {
  position: absolute;
  top: calc(100% + 18px);
  right: calc(-1 * var(--gutter));
  z-index: 60;
  display: grid;
  gap: 2px;
  min-width: 220px;
  margin: 0;
  padding: 10px;
  list-style: none;
  border: 2px solid var(--color-divider);
  background: var(--color-bg);
}

.nav-menu-list a {
  display: block;
  padding: 12px 14px;
  font-size: 0.75rem;
  color: var(--color-text);
  text-decoration: none;
}

.nav-menu-list a:hover,
.nav-menu-list a[aria-current="page"] {
  background: var(--color-surface);
  color: var(--color-accent-ink);
}

@media (max-width: 860px) {
  .nav-menu {
    display: block;
  }

  .site-nav-inner .btn-small {
    display: none;
  }
}

/* The head of a page */

.page-head {
  position: relative;
  border-bottom: 2px solid var(--color-divider);
  overflow: clip;
}

.page-head-inner {
  position: relative;
  padding-block: clamp(40px, 6vw, 72px) clamp(48px, 7vw, 84px);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
  letter-spacing: 0.08em;
  color: var(--color-quiet);
}

.crumbs a {
  color: var(--color-accent-ink);
  text-decoration: none;
}

.crumbs a:hover {
  text-decoration: underline;
}

.page-head h1 {
  max-width: 18em;
  font-size: clamp(2.125rem, 4.4vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.page-lead {
  max-width: 40em;
  margin-top: 24px;
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  color: color-mix(in srgb, var(--color-text) 82%, transparent);
  text-wrap: pretty;
}

.page-meta {
  margin-top: 28px;
  letter-spacing: 0.06em;
  color: var(--color-quiet);
}

/* The body of a page: a table of contents on the left, the prose on the right */

.doc {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  gap: 24px clamp(32px, 5vw, 80px);
  padding-block: clamp(48px, 6vw, 80px) clamp(64px, 8vw, 112px);
}

.doc-wide {
  grid-template-columns: minmax(0, 1fr);
}

.toc {
  align-self: start;
  position: sticky;
  top: 96px;
}

.toc .mono {
  margin: 0 0 14px;
  letter-spacing: 0.08em;
  color: var(--color-quiet);
}

.toc ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 2px solid var(--color-divider);
}

.toc a {
  display: block;
  padding: 7px 0 7px 16px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--color-muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--color-text);
}

.toc a[aria-current="location"] {
  border-left-color: var(--color-accent);
  color: var(--color-accent-ink);
  font-weight: 600;
}

@media (max-width: 960px) {
  .doc {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    position: static;
  }

  .toc ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0 22px;
    border-left: 0;
    border-bottom: 2px solid var(--color-divider);
  }

  .toc a {
    padding: 8px 0;
    margin: 0 0 -2px;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .toc a[aria-current="location"] {
    border-bottom-color: var(--color-accent);
  }
}

/* The prose */

.prose {
  min-width: 0;
}

.doc-section {
  /* The header is already cleared by the scroll padding of the page. */
  scroll-margin-top: 8px;
}

/* The text of a section keeps the measure of the public prose; its drawings and tables take the whole column. */
.doc .prose > .doc-section {
  max-width: none;
}

.doc .prose > .doc-section > :where(:not(.diagram, .table-wrap)) {
  max-width: 760px;
}

.doc-section + .doc-section {
  margin-top: clamp(48px, 6vw, 72px);
  padding-top: clamp(40px, 5vw, 56px);
  border-top: 2px solid var(--color-divider);
}

.prose h2 {
  margin: 0 0 20px;
  font-size: clamp(1.625rem, 2.8vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.prose h3 {
  margin: 36px 0 12px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.2;
}

.prose > p,
.prose .doc-section > p,
.prose .doc-section > ul,
.prose .doc-section > ol {
  max-width: 66ch;
}

.prose p {
  margin: 0 0 16px;
  text-wrap: pretty;
}

.prose p.lead {
  font-size: 1.125rem;
  color: color-mix(in srgb, var(--color-text) 86%, transparent);
}

.prose ul,
.prose ol {
  margin: 0 0 18px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 8px;
  padding-left: 4px;
}

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

.prose a {
  color: var(--color-accent-ink);
  text-underline-offset: 3px;
}

.prose a:hover {
  color: var(--color-accent-ink-hover);
}

.table code {
  overflow-wrap: normal;
  white-space: nowrap;
}

.prose code {
  padding: 1px 6px;
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: 0.82em;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.prose pre {
  margin: 0 0 20px;
  padding: 18px 20px;
  overflow-x: auto;
  background: var(--color-field);
  border: 2px solid var(--color-divider);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  overflow-wrap: normal;
}

.prose strong {
  font-weight: 600;
}

/* Tables: a header of small capitals, a rule under each row */

.table-wrap {
  margin: 4px 0 24px;
  overflow-x: auto;
  border-top: 2px solid var(--color-divider);
  border-bottom: 2px solid var(--color-divider);
}

.table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.table caption {
  padding: 14px 0 6px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-quiet);
}

.table th,
.table td {
  padding: 12px 18px 12px 0;
  vertical-align: top;
  text-align: left;
}

.table th:last-child,
.table td:last-child {
  padding-right: 0;
}

.table thead th {
  padding-block: 14px 10px;
  border-bottom: 2px solid var(--color-divider);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-quiet);
  white-space: nowrap;
}

.table tbody tr + tr > * {
  border-top: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
}

.table tbody th {
  font-weight: 600;
}

.table .num {
  font-variant-numeric: tabular-nums;
}

.table-note {
  margin: -8px 0 24px;
  font-size: 0.875rem;
  color: var(--color-quiet);
}

/* Chips: a state, in a word */

.chip {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid currentColor;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip-ok {
  border-color: var(--color-text);
  background: var(--signal);
  color: #0c1016;
}

.chip-next {
  color: var(--color-accent-ink);
}

.chip-explore {
  border-style: dashed;
  color: var(--color-muted);
}

.chip-plain {
  color: var(--color-muted);
}

/* A callout: what the reader must not miss */

.callout {
  margin: 8px 0 24px;
  padding: 20px 24px 8px;
  border-left: 4px solid var(--color-accent);
  background: var(--color-surface);
}

.callout-title {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-ink);
}

.callout p:last-child {
  margin-bottom: 14px;
}

.callout-warn {
  border-left-color: var(--color-text);
}

.callout-warn .callout-title {
  color: var(--color-text);
}

/* Lists with a mark: a tick for what Beffroi does, a cross for what it does not */

.ticks,
.crosses {
  margin: 0 0 18px;
  padding-left: 0;
  list-style: none;
}

.ticks li,
.crosses li {
  position: relative;
  padding-left: 30px;
}

.ticks li::before,
.crosses li::before {
  content: '';
  position: absolute;
  top: 0.45em;
  left: 2px;
  width: 12px;
  height: 12px;
}

.ticks li::before {
  background: var(--color-accent);
  clip-path: polygon(0 55%, 15% 40%, 40% 62%, 85% 10%, 100% 25%, 40% 95%);
}

.crosses li::before {
  background: var(--color-text);
  clip-path: polygon(15% 0, 50% 35%, 85% 0, 100% 15%, 65% 50%, 100% 85%, 85% 100%, 50% 65%, 15% 100%, 0 85%, 35% 50%, 0 15%);
}

/* Cards: a short list of things to open */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin: 8px 0 24px;
  padding: 0;
  list-style: none;
}

.prose .doc-section > ul.cards {
  max-width: none;
  padding-left: 0;
}

.prose .cards > li {
  margin: 0;
  padding: 0;
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px;
  border: 2px solid var(--color-divider);
  background: var(--color-bg);
}

.card .mono {
  margin: 0 0 12px;
  letter-spacing: 0.08em;
  color: var(--color-accent-ink);
}

.card h3 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.card p {
  margin: 0 0 16px;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-muted);
}

.card .arrow-link {
  margin-top: auto;
}

/* The security defaults: each one named, with what the code does, marked by the brand square */

.defaults {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 4px 0 28px;
  border-top: 2px solid var(--color-divider);
}

.defaults > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 8px 32px;
  padding: 16px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
}

.defaults dt {
  position: relative;
  padding-left: 30px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.3;
  text-wrap: balance;
}

.defaults dt::before {
  content: '';
  position: absolute;
  top: 0.45em;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--color-accent);
}

.defaults dd {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-muted);
}

@media (max-width: 640px) {
  .defaults > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Facts: a term, and what is true of it */

.facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 4px 0 24px;
  border-top: 2px solid var(--color-divider);
}

.facts > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr);
  gap: 8px 32px;
  padding: 14px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
}

.facts dt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-quiet);
}

.facts dd {
  margin: 0;
}

@media (max-width: 640px) {
  .facts > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The lanes of the roadmap: available, next, being explored */

.lanes {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 8px 0 24px;
}

.lane {
  padding: 22px 22px 8px;
  border: 2px solid var(--color-divider);
  background: var(--color-bg);
}

.lane h3 {
  margin: 0 0 6px;
  font-size: 1.375rem;
}

.lane-note {
  margin: 0 0 18px;
  font-size: 0.875rem;
  color: var(--color-quiet);
}

.lane ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lane li {
  padding: 14px 0;
  border-top: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.lane li strong {
  display: block;
  margin-bottom: 2px;
}

@media (max-width: 960px) {
  .lanes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The releases of the changelog */

.releases {
  display: grid;
  gap: 0;
}

.release {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 8fr);
  gap: 16px clamp(24px, 4vw, 56px);
  padding-block: 32px;
}

.release + .release {
  border-top: 2px solid var(--color-divider);
}

.release-id {
  align-self: start;
}

.release-id h2 {
  margin: 0 0 10px;
  font-size: 1.875rem;
}

.release-body h3:first-child {
  margin-top: 0;
}

@media (max-width: 760px) {
  .release {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The people */

.people {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 8px 0 24px;
}

.person {
  padding: 24px;
  border: 2px solid var(--color-divider);
  background: var(--color-bg);
}

.person h3 {
  margin: 0 0 4px;
  font-size: 1.375rem;
}

.person .mono {
  margin: 0 0 14px;
  letter-spacing: 0.08em;
  color: var(--color-accent-ink);
}

.person p:last-child {
  margin-bottom: 0;
}

/* What a creator is known for, the libraries of one and the talks of the other: a title that leads to it, and a line
   under it (what the library does, the event of the talk). The same list in both cards keeps them level. */
.person .person-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  line-height: 1.5;
}

.person .person-list li {
  padding: 8px 0;
  border-top: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
}

.person .person-list .mono {
  display: block;
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--color-quiet);
}

/* A diagram: a drawing rendered from Mermaid by Pele, by the rules of the brand (charter p. 28 and 31, and the Pele
   theme of the Slidev theme): 2 px lines with square ends, boxes with square corners, labels in Martian Mono, ink for
   everything, the light for the path that matters, and corner brackets of 22 px around the figure rather than a frame
   that would weigh as much as a box. Pele reads its colours and its font from these variables, so that light and dark
   follow the page. The caption stands under it. A narrow screen gets a drawing of its own. */

.diagram {
  --bracket: linear-gradient(var(--color-accent), var(--color-accent));
  margin: 8px 0 32px;
  padding: clamp(20px, 3vw, 28px);
  background:
    var(--bracket) top left / 22px 2px no-repeat,
    var(--bracket) top left / 2px 22px no-repeat,
    var(--bracket) top right / 22px 2px no-repeat,
    var(--bracket) top right / 2px 22px no-repeat,
    var(--bracket) bottom left / 22px 2px no-repeat,
    var(--bracket) bottom left / 2px 22px no-repeat,
    var(--bracket) bottom right / 22px 2px no-repeat,
    var(--bracket) bottom right / 2px 22px no-repeat,
    var(--color-bg);
  /* The light of the tower: ultramarine on paper, the cold light on ink. */
  --diagram-light: var(--color-accent);
  --pele-bg: var(--color-bg);
  --pele-fg: var(--color-text);
  --pele-fg-on-light: #0c1016;
  --pele-fg-on-dark: #f2f4f6;
  --pele-muted: var(--color-muted);
  --pele-line: var(--color-text);
  --pele-surface: var(--color-field);
  --pele-surface-alt: var(--color-surface);
  --pele-border: var(--color-text);
  --pele-accent: var(--diagram-light);
  --pele-error: var(--color-error);
  --pele-critical: var(--color-error);
  --pele-font: var(--font-mono);
  --pele-font-mono: var(--font-mono);
  --pele-radius: 0;
  --pele-title-weight: 600;
  --pele-heading-weight: 600;
  --pele-bold-weight: 600;
  /* Charts and the branches of a mind map: ultramarine first, then the accent scale of the brand, ink last. */
  --pele-series-1: var(--diagram-light);
  --pele-series-2: #7d8bff;
  --pele-series-3: #1b2bb8;
  --pele-series-4: #a9b3ff;
  --pele-series-5: #2336e0;
  --pele-series-6: #cfd5ff;
  --pele-series-7: var(--color-text);
  --pele-series-8: var(--color-muted);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .diagram {
    --diagram-light: var(--color-accent-ink);
  }
}

:root[data-theme="dark"] .diagram {
  --diagram-light: var(--color-accent-ink);
}

.diagram svg {
  display: block;
  margin: 0 auto;
  font-stretch: 100%;
}

/* 2 px lines with square ends, 2 px borders, and no rounded corner anywhere. */
.diagram .pele-edge path:not(.pele-marker) {
  stroke-width: 2px;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.diagram .pele-node > rect,
.diagram .pele-node > polygon,
.diagram .pele-node > path,
.diagram .pele-node > circle,
.diagram .pele-node > ellipse {
  stroke-width: 2px;
}

.diagram rect {
  rx: 0 !important;
  ry: 0 !important;
}

/* A band (a subgraph) separates, it does not frame: the divider's weight of ink, at the width of a line. */
.diagram .pele-cluster > rect {
  stroke: var(--color-divider);
  stroke-width: 2px;
}

/* The lines of a label after its first: the description under the title. */
.diagram .pele-label .pele-sub {
  fill: var(--color-muted);
}

/* The path that matters: the node marked "light" in the source. */
.diagram .pele-node.light > rect,
.diagram .pele-node.light > polygon,
.diagram .pele-node.light > path,
.diagram .pele-node.light > circle {
  stroke: var(--diagram-light) !important;
}

.diagram .pele-node.light > .pele-label {
  fill: var(--color-accent-ink);
}

.diagram figcaption {
  margin-top: 20px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-quiet);
  text-wrap: pretty;
}

.diagram-fig {
  margin-right: 6px;
  color: var(--color-accent-ink);
}

.diagram-narrow {
  display: none;
}

@media (max-width: 640px) {
  .diagram-wide {
    display: none;
  }

  /* A drawing wider than the screen keeps its size and scrolls sideways, rather than shrinking past what can be read. */
  .diagram-narrow {
    display: block;
    overflow-x: auto;
  }

  .diagram-narrow svg {
    max-width: none !important;
  }
}

/* The references under a section: the specifications, the tools and the pages of the documentation it rests on */

.refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.refs li::after {
  content: '·';
  margin-left: 10px;
  color: var(--color-quiet);
}

.refs li:last-child::after {
  content: none;
}

.prose .doc-section > ul.refs {
  max-width: none;
  padding-left: 0;
}

.prose .refs li {
  margin: 0;
  padding: 0;
}

/* Text for a screen reader alone */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A table on a narrow screen: each row becomes a block, and each cell carries the name of its column (set by the script
   of the tables). Without the script, the table scrolls sideways inside its frame. */

@media (max-width: 640px) {
  .table.is-stacked {
    min-width: 0;
  }

  .table.is-stacked thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .table.is-stacked tr,
  .table.is-stacked tbody,
  .table.is-stacked tbody th,
  .table.is-stacked td {
    display: block;
  }

  .table.is-stacked tbody tr {
    padding: 14px 0;
  }

  .table.is-stacked tbody tr + tr {
    border-top: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
  }

  .table.is-stacked tbody tr + tr > * {
    border-top: 0;
  }

  .table.is-stacked th,
  .table.is-stacked td {
    padding: 2px 0;
  }

  .table.is-stacked td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-quiet);
  }
}
