/* RepoDNA documentation. The colors are those of the web interface (apps/web/src/styles.css). */

:root {
  --font:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-raised: #ffffff;
  --ink: #0b0b0b;
  --ink-secondary: #52514e;
  --muted: #6f6d67;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #1f5fae;
  --accent-wash: #eaf2fc;
  --focus: #2a78d6;
  --code: #f0efec;
  --header: 3.5rem;
  color-scheme: light;
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-raised: #222221;
    --ink: #ffffff;
    --ink-secondary: #c3c2b7;
    --muted: #9d9b94;
    --line: #2c2c2a;
    --line-strong: #383835;
    --accent: #3987e5;
    --accent-ink: #8ab9f1;
    --accent-wash: #13263d;
    --focus: #6da7ec;
    --code: #1f1f1e;
    color-scheme: dark;
  }
}

@media screen {
  :root[data-theme="dark"] {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-raised: #222221;
    --ink: #ffffff;
    --ink-secondary: #c3c2b7;
    --muted: #9d9b94;
    --line: #2c2c2a;
    --line-strong: #383835;
    --accent: #3987e5;
    --accent-ink: #8ab9f1;
    --accent-wash: #13263d;
    --focus: #6da7ec;
    --code: #1f1f1e;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--header) + 1rem);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.65 var(--font);
}

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

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

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

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 30;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
}

.skip:focus {
  top: 0.6rem;
}

/* The bar at the top. */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--header);
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--page);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand .section {
  color: var(--muted);
  font-weight: 500;
}

.menu,
.theme,
.copy {
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.menu {
  display: none;
}

.search {
  position: relative;
  flex: 1;
  max-width: 26rem;
  margin-left: auto;
}

.search input {
  width: 100%;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
}

#results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 18%);
}

#results a {
  display: block;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}

#results a:hover,
#results a:focus {
  background: var(--accent-wash);
}

#results strong {
  display: block;
  font-size: 0.9375rem;
}

#results span {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

#results .none {
  padding: 0.5rem 0.65rem;
  color: var(--muted);
}

.links {
  display: flex;
  align-items: center;
  gap: 1rem;
  white-space: nowrap;
}

.links a {
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
}

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

/* The sidebar, the page, and what is on it. */
.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 48rem) minmax(0, 1fr);
  gap: 2.5rem;
  max-width: 88rem;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--header);
  align-self: start;
  height: calc(100vh - var(--header));
  overflow: auto;
  padding: 1.25rem 0.5rem 2rem 1rem;
  border-right: 1px solid var(--line);
}

.sidebar h2 {
  margin: 1.1rem 0 0.35rem;
  padding: 0 0.6rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar section:first-child h2 {
  margin-top: 0;
}

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

.sidebar a {
  display: block;
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  color: var(--ink-secondary);
  font-size: 0.9rem;
  line-height: 1.4;
  text-decoration: none;
}

.sidebar a:hover {
  background: var(--surface-raised);
  color: var(--ink);
}

.sidebar a[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-weight: 600;
}

main {
  min-width: 0;
  padding: 2rem 0 3rem;
}

.toc {
  position: sticky;
  top: calc(var(--header) + 2rem);
  align-self: start;
  max-height: calc(100vh - var(--header) - 4rem);
  overflow: auto;
  font-size: 0.875rem;
}

.toc h2 {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.toc li {
  margin: 0.3rem 0;
}

.toc a {
  color: var(--ink-secondary);
  text-decoration: none;
}

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

/* The guide itself. */
article h1 {
  margin: 0 0 1rem;
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

article h2 {
  margin: 2.4rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.45rem;
  line-height: 1.3;
}

article h3 {
  margin: 1.9rem 0 0.6rem;
  font-size: 1.15rem;
}

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

.anchor {
  margin-left: 0.4rem;
  color: var(--line-strong);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
}

:is(h2, h3, h4):hover .anchor,
.anchor:focus {
  opacity: 1;
}

article p,
article ul,
article ol {
  margin: 0.75rem 0;
}

article li + li {
  margin-top: 0.25rem;
}

article img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

article blockquote {
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--ink-secondary);
}

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

code {
  font-family: var(--mono);
  font-size: 0.875em;
}

:not(pre) > code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: var(--code);
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--code);
  line-height: 1.5;
}

.code,
.diagram {
  position: relative;
  margin: 1rem 0;
}

.copy {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.8125rem;
  opacity: 0;
}

.code:hover .copy,
.copy:focus {
  opacity: 1;
}

@media (hover: none) {
  .copy {
    opacity: 1;
  }
}

.diagram figcaption {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.table {
  margin: 1rem 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

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

th {
  background: var(--surface);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

/* Previous and next, the edit link, and the footer. */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
}

.pager a {
  display: block;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.pager a:hover {
  border-color: var(--accent);
}

.pager span {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

.pager .next {
  text-align: right;
}

.edit {
  margin-top: 1.5rem;
  font-size: 0.875rem;
}

footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

footer a {
  color: var(--ink-secondary);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 2rem;
    padding-right: 1.5rem;
  }

  .toc {
    display: none;
  }
}

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

  .brand .section,
  .links a {
    display: none;
  }

  .top {
    gap: 0.6rem;
    padding: 0 0.75rem;
  }

  /* The search box is narrow here: the results take the width of the screen instead. */
  .search {
    position: static;
  }

  #results {
    left: 0.5rem;
    right: 0.5rem;
    max-height: calc(100vh - var(--header) - 1rem);
  }

  .layout {
    display: block;
    padding: 0 1rem;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: var(--header) 0 0 0;
    z-index: 15;
    height: auto;
    padding: 1rem;
    background: var(--page);
    border-right: 0;
  }

  .nav-open .sidebar {
    display: block;
  }

  main {
    padding-top: 1.25rem;
  }

  article h1 {
    font-size: 1.7rem;
  }
}

@media (max-width: 480px) {
  .brand span {
    display: none;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager .next {
    text-align: left;
  }
}

@media print {
  .top,
  .sidebar,
  .toc,
  .pager,
  .edit,
  .copy,
  .anchor {
    display: none;
  }

  .layout {
    display: block;
  }

  pre,
  .table {
    overflow: visible;
    white-space: pre-wrap;
  }
}
