/* The Docs section's pages (docs/*.html, generated from the repository's docs/ by
   src/scripts/generate-promo-docs.ts). They load styles.css first for the tokens, the font, the top bar and the
   footer, and wear the page's own Bibliup dark: they have no bands, so there is nothing for the bar to follow and
   motion.js is not loaded. Everything here is set for READING: a measure near 72ch, and a sidebar of the guides that
   becomes a plain list under the text on a phone. */

.docs .topbar {
  position: sticky;
}

.docs-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(1.5rem, 4dvh, 2.5rem) 1.5rem 0;
}

.docs-nav {
  position: sticky;
  top: 5rem;
  align-self: start;
  max-height: calc(100dvh - 6rem);
  overflow-y: auto;
  font-size: 0.875rem;
}

.docs-nav ul {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.docs-nav-heading {
  margin: 0 0 0.4rem;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.docs-nav a {
  display: block;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  text-decoration: none;
}

.docs-nav-all {
  margin-bottom: 1rem;
}

.docs-nav a:hover,
.docs-nav a:focus-visible {
  background: var(--accent);
  color: var(--foreground);
}

/* Where the reader is: a weight and an edge as well as a colour, so it is never carried by colour alone. */
.docs-nav a[aria-current="page"] {
  color: var(--foreground);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}

.docs-nav a[aria-current="page"]:dir(rtl) {
  box-shadow: inset -2px 0 0 var(--primary);
}

.docs-body {
  min-width: 0;
  max-width: 72ch;
  line-height: 1.7;
}

.docs-body h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.docs-body h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.docs-body h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.1rem;
}

.docs-body h2,
.docs-body h3 {
  scroll-margin-block-start: 6rem;
}

.docs-body a {
  color: var(--primary);
  text-underline-offset: 0.18em;
}

.docs-body code {
  padding: 0.1em 0.35em;
  border-radius: var(--radius-md);
  background: var(--card);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

/* A command is copied, so it must never wrap mid-word: the block scrolls sideways inside itself instead, which
   keeps the page itself free of a horizontal scroll at phone width. */
.docs-body pre {
  overflow-x: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  line-height: 1.5;
}

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

/* A table is the docs' favourite shape and the one that overflows a phone, so it scrolls inside itself too. */
.docs-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.docs-body th,
.docs-body td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

.docs-body th {
  color: var(--muted-foreground);
  font-weight: 600;
}

.docs-body blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-inline-start: 3px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.docs-body blockquote p {
  margin: 0;
}

/* GitHub's alert, which the generator gives a class and a label. The label is MARKUP, in the page's language, and
   never stylesheet `content`: a stylesheet cannot be translated, and a screen reader may skip generated text. */
.docs-alert {
  border-inline-start-color: var(--primary);
}

.docs-body .docs-alert-label {
  margin-bottom: 0.25rem;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* A guide not translated yet, shown in English under this line in the page's own language. */
.docs-untranslated {
  padding: 0.6rem 0.9rem;
  border: 1px dashed var(--control-edge);
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

/* The language menu: a disclosure of plain links, so it needs no script, offered only when there is a second
   language. It opens below the bar, at the reader's end edge. */
.docs-lang {
  position: relative;
  margin-inline-start: 0.5rem;
  font-size: 0.875rem;
}

.docs-lang summary {
  display: flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0 0.6rem;
  border: 1px solid var(--control-edge);
  border-radius: var(--radius-md);
  cursor: pointer;
  list-style: none;
}

.docs-lang summary::-webkit-details-marker {
  display: none;
}

.docs-lang summary:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.docs-lang ul {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 0.4rem);
  min-width: 10rem;
  margin: 0;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  list-style: none;
}

.docs-lang a {
  display: block;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-md);
  color: var(--foreground);
  text-decoration: none;
}

.docs-lang a:hover,
.docs-lang a:focus-visible {
  background: var(--accent);
}

.docs-lang a[aria-current="page"] {
  font-weight: 600;
}

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

  /* The guide a reader opened comes first; the list of the others follows it rather than filling the first screen.
     Visual order only, so in reading and tab order it stays first, as the skip link expects. */
  .docs-nav {
    position: static;
    order: 2;
    max-height: none;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
  }
}
