/*
 * Stylesheet of the MyOwnPKI documentation site – the only one, no framework,
 * no web fonts, nothing loaded from other hosts.
 *
 * The look follows the product (web/styles/tokens.css): calm and plain, system
 * fonts, 2 px radius, no cards, no icons, no shadows. Light by default, dark
 * when the system asks for it. Status colors appear only in the "Note" and
 * "Warning" call-outs (a blockquote that starts with **Note:** or **Warning:**
 * and is followed by the line {: .note} or {: .warning}). The brand gold of the
 * logo is never used as an accent.
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-subtle: #f5f5f5;
  --border: #e0e0e0;
  --border-strong: #c7c7c7;
  --text: #242424;
  --text-muted: #5c5c5c;
  --link: #0b5aa0;
  --focus: #000000;
  --header-bg: #1f2a36;
  --header-text: #ffffff;
  --header-muted: #c3ccd5;
  --status-info: #0f5c99;
  --status-warn: #8a5300;

  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: Consolas, "Cascadia Mono", ui-monospace, "SF Mono", Menlo, "Liberation Mono", monospace;
  --radius: 2px;
  --rule: 4px;
  --measure: 50rem;
  --nav-w: 15rem;
  --toc-w: 13rem;
  --layout-w: 86rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1f;
    --bg-subtle: #292929;
    --border: #3d3d3d;
    --border-strong: #525252;
    --text: #ebebeb;
    --text-muted: #adadad;
    --link: #6aaee8;
    --focus: #ffffff;
    --header-bg: #0f0f0f;
    --header-text: #f0f0f0;
    --header-muted: #adadad;
    --status-info: #6aaee8;
    --status-warn: #f0b350;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Skip link: off screen until it gets the keyboard focus. */
.skip {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius);
}

.skip:focus {
  top: 0.5rem;
}

/* Header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  min-height: 3rem;
  padding: 0.5rem 1rem;
  background: var(--header-bg);
  color: var(--header-text);
}

.top a {
  color: var(--header-text);
  text-decoration: none;
}

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

.top :focus-visible {
  outline-color: #ffffff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 1.125rem;
}

.brand img {
  display: block;
}

.brand-sub {
  color: var(--header-muted);
  font-weight: 400;
}

.top-link {
  color: var(--header-muted);
  font-size: 0.9375rem;
}

/*
 * Page: navigation left, text right. On wide screens a third column holds
 * "On this page" (only for pages with at least three headings, see the layout).
 */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 2.5rem;
  max-width: var(--layout-w);
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 52rem) {
  .layout {
    grid-template-columns: var(--nav-w) minmax(0, var(--measure));
    padding: 0 1.5rem;
  }

  .nav {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    padding: 1.5rem 0;
  }
}

@media (min-width: 75rem) {
  .layout.has-toc {
    grid-template-columns: var(--nav-w) minmax(0, var(--measure)) var(--toc-w);
  }
}

/* Navigation: groups with a small heading each */
.nav {
  font-size: 0.9375rem;
  padding: 1rem 0 0.5rem;
}

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

.nav li ul {
  margin: 0.125rem 0 0.375rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.nav-group {
  margin: 1rem 0 0.125rem;
  padding-left: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.nav-groups > li:first-child > .nav-group {
  margin-top: 0;
}

.nav a {
  display: block;
  padding: 0.25rem 0.5rem;
  color: var(--text);
  text-decoration: none;
  border-left: var(--rule) solid transparent;
  margin-left: calc(var(--rule) * -1);
}

.nav a:hover {
  background: var(--bg-subtle);
}

.nav a[aria-current="page"] {
  font-weight: 600;
  border-left-color: var(--link);
}

/*
 * Narrow screens: the list sits in a <details> element that is closed, so the
 * navigation takes one line above the text. Wide screens show the list as a
 * column instead. The layout prints the same list twice; CSS shows one.
 */
.nav-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.nav-menu summary {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.nav-menu[open] summary {
  border-bottom: 1px solid var(--border);
}

.nav-menu .nav-groups {
  padding: 0.25rem 0.75rem 0.75rem;
}

@media (min-width: 52rem) {
  .nav-menu {
    display: none;
  }
}

@media (max-width: 51.99rem) {
  .nav-full {
    display: none;
  }
}

/* On this page: a column at the right of the text, wide screens only. */
.toc {
  display: none;
}

@media (min-width: 75rem) {
  .toc {
    display: block;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    padding: 1.5rem 0;
    font-size: 0.875rem;
  }

  /* The list that "* TOC" and "{:toc}" make inside the text is the same one. */
  .has-toc #markdown-toc {
    display: none;
  }

  .has-toc p:has(+ #markdown-toc) {
    display: none;
  }
}

.toc-title {
  margin: 0 0 0.25rem;
  padding-left: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--border);
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.1875rem 0.5rem 0.1875rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
}

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

.toc .toc-sub a {
  padding-left: 1.5rem;
}

/* Text */
main {
  min-width: 0;
  max-width: var(--measure);
  padding: 1rem 0 3rem;
}

main:focus {
  outline: none;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 600;
  scroll-margin-top: 1rem;
}

h1 {
  margin: 0.5rem 0 1rem;
  font-size: 1.75rem;
}

h2 {
  margin: 2.5rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 1.375rem;
}

h3 {
  margin: 2rem 0 0.5rem;
  font-size: 1.125rem;
}

h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
}

p,
ul,
ol,
dl {
  margin: 0 0 1rem;
}

li {
  margin: 0.25rem 0;
}

li > ul,
li > ol {
  margin-bottom: 0.25rem;
}

hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

strong {
  font-weight: 600;
}

/* Code: system monospace, no syntax colors */
code,
pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

code {
  padding: 0.0625rem 0.3125rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

pre {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.5;
  tab-size: 4;
}

pre code {
  padding: 0;
  background: none;
  border-radius: 0;
  overflow-wrap: normal;
  white-space: pre;
}

div.highlighter-rouge,
div.highlight {
  margin: 0 0 1rem;
}

div.highlighter-rouge pre,
div.highlight pre {
  margin: 0;
}

/* Call-outs: a plain line with a text label and a colored left rule, no tint. */
blockquote {
  margin: 0 0 1rem;
  padding: 0.125rem 0 0.125rem 1rem;
  border-left: var(--rule) solid var(--border-strong);
}

blockquote > :last-child {
  margin-bottom: 0.5rem;
}

blockquote.note {
  border-left-color: var(--status-info);
}

blockquote.warning {
  border-left-color: var(--status-warn);
}

blockquote.note > p:first-child > strong:first-child {
  color: var(--status-info);
}

blockquote.warning > p:first-child > strong:first-child {
  color: var(--status-warn);
}

/* Tables: row separators, no frames. */
table {
  width: 100%;
  margin: 0 0 1.25rem;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

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

th {
  font-weight: 600;
  border-bottom: 2px solid var(--border-strong);
}

td code {
  font-size: 0.8125rem;
}

@media (max-width: 40rem) {
  table {
    display: block;
    overflow-x: auto;
  }

  th,
  td {
    min-width: 7rem;
  }
}

/*
 * Comparison tables with long cells (class "stack", set with {: .stack .name}
 * under the table): on a phone each row becomes a block and each cell says
 * which column it belongs to, instead of three columns a few words wide.
 */
@media (max-width: 40rem) {
  table.stack,
  table.stack tbody {
    display: block;
    overflow-x: visible;
  }

  table.stack thead {
    display: none;
  }

  table.stack tr {
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
  }

  table.stack td {
    display: block;
    min-width: 0;
    padding: 0.25rem 0;
    border: 0;
  }

  table.stack td:first-child {
    font-weight: 600;
  }

  table.stack td:not(:first-child)::before {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
  }

  table.stack-server td:nth-child(2)::before {
    content: "systemd service";
  }

  table.stack-server td:nth-child(3)::before {
    content: "Container";
  }

  table.stack-levels td:nth-child(2)::before {
    content: "What you do, and what the server knows";
  }

  table.stack-levels td:nth-child(3)::before {
    content: "Pick it when";
  }

  table.stack-rollout td:nth-child(2)::before {
    content: "Who it is for, and the effort";
  }

  table.stack-rollout td:nth-child(3)::before {
    content: "What needs a person, and what is tested";
  }
}

/* The contents list kramdown makes for "* TOC" / "{:toc}". */
#markdown-toc {
  padding-left: 1.25rem;
  font-size: 0.9375rem;
}

#markdown-toc ul {
  padding-left: 1.25rem;
}

/* Footer */
.foot {
  max-width: var(--layout-w);
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

@media (min-width: 52rem) {
  .foot {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

.foot p {
  margin: 0 0 0.5rem;
}

.foot-note {
  max-width: var(--measure);
}

img {
  max-width: 100%;
  height: auto;
}

/*
 * The overview figure on the start page (assets/overview.svg, included into
 * the page so that it follows the text color and the light or dark scheme).
 * Boxes and arrows only; the file draws plain outlines when opened alone.
 */
.diagram {
  margin: 0 0 1.5rem;
}

.diagram svg {
  display: block;
  width: 100%;
  max-width: 30rem;
  height: auto;
}

.diagram .box {
  fill: var(--bg-subtle);
  stroke: var(--border-strong);
  stroke-width: 1;
}

.diagram .frame {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.diagram text {
  font-family: var(--font-sans);
}

.diagram .title {
  font-weight: 600;
}

.diagram .label {
  fill: var(--text-muted);
}

.diagram-caption {
  max-width: 30rem;
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}
