/*
 * User guide styles. Every color and the corner radius come from the admin app's dark tokens,
 * which build.mjs copies from web/src/pages/AdminPage.css into each page's :root. Never write a
 * color value here: a copy would drift from the app. Accent marks things (rings, bars, tints),
 * never words, as in the app.
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--text);
  text-decoration: underline;
}

a:focus-visible,
summary:focus-visible,
.copy-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 1;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius);
}

/* Navigation, phone first: a closed Menu toggle above the page. */

nav {
  background: var(--side);
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

/* The boxed look shared by the Menu toggle, figures, warnings, code blocks and the Copy button. */
summary,
figure,
.warning,
pre,
.copy-button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

summary {
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}

.brand {
  margin: 12px 12px 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

nav h2 {
  margin: 16px 12px 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

nav a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  text-decoration: none;
}

nav a:hover,
.copy-button:hover {
  background: var(--accent-tint);
}

nav a[aria-current="page"] {
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 600;
}

/* Page content: fills all the width the nav leaves free, with no width cap. */

main {
  padding: 24px 16px 48px;
  overflow-wrap: anywhere;
}

h1 {
  margin: 0 0 12px;
  line-height: 1.25;
}

main h2 {
  margin: 32px 0 8px;
  font-size: 1.35rem;
  line-height: 1.25;
}

main h3 {
  margin: 24px 0 6px;
  font-size: 1.1rem;
  line-height: 1.25;
}

figure {
  margin: 20px 0;
  padding: 12px;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: calc(var(--radius) / 2);
}

figcaption {
  margin-top: 8px;
  color: var(--muted);
}

ol,
ul {
  padding-left: 1.5rem;
}

li + li {
  margin-top: 4px;
}

.warning {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--danger);
}

.warning p {
  margin: 0;
}

/* Commands scroll inside their own block, so the page never scrolls sideways. */
pre {
  margin: 12px 0;
  padding: 12px 16px;
  overflow-x: auto;
  overflow-wrap: normal;
}

/* copy.js wraps each <pre class="copy"> in .copy-block and puts the button in its top-right corner. */
.copy-block {
  position: relative;
}

/* Room on the right so no code line sits under the button. */
.copy-block pre {
  padding-right: 72px;
}

.copy-button {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

/* Hidden until hover only where hover exists; touch screens always show it. Focus shows it too. */
@media (hover: hover) {
  .copy-button {
    opacity: 0;
  }

  .copy-block:hover .copy-button,
  .copy-block:focus-within .copy-button {
    opacity: 1;
  }
}

/* Desktop: a fixed side panel like the app's, always open, with no script. */
@media (min-width: 800px) {
  nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--nav-width);
    overflow-y: auto;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    padding: 16px 12px;
  }

  /* Browsers without ::details-content keep the Menu toggle on desktop, which still works. */
  @supports selector(::details-content) {
    summary {
      display: none;
    }

    details.nav-toggle::details-content {
      content-visibility: visible;
      display: block;
    }
  }

  .brand {
    margin-top: 4px;
  }

  main {
    margin-left: var(--nav-width);
    padding: 32px 40px 64px;
  }
}
