/* Source code (ui/code-view.js): the files grouped by API on the left, one file read in place on the right,
   colored by ui/code-highlight.js and numbered line by line. */
.code-layout {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.code-tree {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-right: 4px;
}
.code-tree h2 {
  margin: 0 0 6px;
  font: 600 12px/1.4 var(--ui);
  color: var(--ink-3);
}
.code-tree section + section > h2 {
  margin-top: 18px;
}
.code-tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.code-tree a {
  display: block;
  padding: 4px 8px;
  border-radius: 6px;
  font: 13px/1.4 var(--mono);
  color: var(--ink-2);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.code-tree a:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.code-tree a[aria-current='page'] {
  background: var(--nav-sel);
  color: var(--heading);
  font-weight: 600;
}
.code-file {
  min-width: 0;
}
/* No file chosen: the files to pick from, with what each does. */
.code-group + .code-group {
  margin-top: 28px;
}
.code-group h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--heading);
}
.code-group > p {
  margin: 0 0 12px;
  max-width: 78ch;
  color: var(--ink-2);
}
.code-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.code-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.code-card:hover {
  border-color: var(--accent);
}
.code-card code {
  font-weight: 600;
  color: var(--heading);
}
.code-card span {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-2);
}
.code-card small {
  font-size: 12px;
  color: var(--ink-3);
}
/* One file: what it does, then its text. */
.code-head h2 {
  margin: 0;
  font-size: 17px;
  color: var(--heading);
  overflow-wrap: anywhere;
}
.code-head p {
  margin: 6px 0 0;
  max-width: 80ch;
  color: var(--ink-2);
}
.code-head .code-go {
  font-size: 13px;
  color: var(--ink-3);
}
.code-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 14px;
}
.code-text {
  margin: 0;
  padding: 14px 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  font: 13px/1.6 var(--mono);
  color: var(--ink);
  overflow-x: auto;
  counter-reset: line;
  tab-size: 2;
}
.code-line {
  display: block;
  padding: 0 16px 0 0;
  white-space: pre;
}
.code-line::before {
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  width: 3.4em;
  margin-right: 14px;
  padding-right: 8px;
  border-right: 1px solid var(--rule);
  text-align: right;
  color: var(--ink-3);
  user-select: none;
}
.c-com {
  color: var(--ink-3);
  font-style: italic;
}
.c-str {
  color: var(--pix-strong);
}
.c-key {
  color: var(--gen);
  font-weight: 600;
}
.c-num {
  color: var(--link);
}
.c-def {
  color: var(--heading);
  font-weight: 700;
}
.c-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.code-all {
  display: none;
}
/* One column: the file (or the files to start with) first. With a file open the list waits behind "All files";
   without one, the list holds only the groups the cards above leave out. */
@media (max-width: 900px) {
  .code-layout {
    display: flex;
    flex-direction: column;
  }
  .code-file {
    order: -1;
    width: 100%;
  }
  .code-tree {
    position: static;
    max-height: none;
  }
  .code-tree ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .has-file .code-tree,
  .code-tree [data-group='apis'],
  .code-tree [data-group='shared'] {
    display: none;
  }
  .code-all {
    display: inline-flex;
  }
}
