/* Desire DB. The protocol page. */

.docs {
  display: grid;
  grid-template-columns: 17.5rem minmax(0, 1fr);
  border-bottom: 1px solid var(--ink);
}

/* ---------- The fixed section index ---------- */
.docs-index {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1.4rem 1.2rem 2rem 0;
  font-size: 0.88rem;
  line-height: 1.35;
  scrollbar-width: thin;
}
.docs-index summary {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.35rem;
  text-transform: uppercase;
  line-height: 1;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--ink);
  list-style: none;
  cursor: default;
}
.docs-index summary::-webkit-details-marker {
  display: none;
}
.index-list > li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.index-list > li > a {
  font-weight: 700;
}
.index-list ol {
  margin-top: 0.25rem;
}
.index-list ol a {
  color: var(--ink-soft);
}
.index-list a {
  display: block;
  padding: 0.16rem 0.5rem 0.16rem 0;
  text-decoration: none;
}
.index-list a:hover {
  text-decoration: underline;
}
.index-list a.is-here {
  color: var(--ink);
  box-shadow: inset -4px 0 0 var(--marker);
}

/* ---------- The text ---------- */
.prose {
  min-width: 0;
  padding: 1.6rem 0 4rem var(--gutter);
  border-left: 1px solid var(--ink);
}
.prose > * {
  max-width: 46rem;
}
.prose > .table-wrap,
.prose > .code {
  max-width: 58rem;
}
.prose h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.8rem, 6vw, 5.6rem);
  line-height: 0.88;
  text-transform: uppercase;
  text-wrap: balance;
  max-width: 12em;
  margin-bottom: 1.4rem;
}
.prose h1 + p {
  font-size: 1.2rem;
  line-height: 1.45;
  font-weight: 500;
}
.prose h2 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2rem, 3.4vw, 3rem);
  line-height: 0.95;
  text-transform: uppercase;
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 4px solid var(--ink);
  max-width: none;
}
.prose h3 {
  font-size: 1.22rem;
  font-weight: 750;
  line-height: 1.25;
  margin-top: 2.6rem;
}
.prose h2 code,
.prose h3 code {
  font-size: 0.82em;
  text-transform: none;
}
.prose p,
.prose ul,
.prose ol,
.prose .code,
.prose .table-wrap {
  margin-top: 1rem;
}
.prose ul,
.prose ol {
  padding-left: 1.4rem;
}
.prose ul {
  list-style: square;
}
.prose ol {
  list-style: decimal;
}
.prose li {
  padding-left: 0.2rem;
}
.prose li + li {
  margin-top: 0.4rem;
}
.prose li::marker {
  font-weight: 700;
}
.anchor {
  margin-left: 0.2em;
  color: var(--ink-soft);
  text-decoration: none;
  opacity: 0;
  font-family: var(--text);
  font-weight: 500;
}
h2:hover .anchor,
h3:hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}
.alias {
  position: relative;
  top: -1.5rem;
}
:target {
  scroll-margin-top: 1.5rem;
}
h2:target,
h3:target {
  text-decoration: underline;
  text-decoration-color: var(--marker);
  text-decoration-thickness: 4px;
  text-underline-offset: 0.12em;
}
tr:target td {
  background: rgb(255 74 28 / 0.18);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
  line-height: 1.4;
}
th {
  padding: 0.4rem 0.9rem 0.4rem 0;
  border-bottom: 2px solid var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
  vertical-align: bottom;
  white-space: nowrap;
}
td {
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
td:first-child {
  font-weight: 600;
}
td:first-child code {
  white-space: nowrap;
}
td code {
  overflow-wrap: normal;
}

@media (max-width: 900px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
  }
  .docs-index {
    position: static;
    max-height: none;
    padding: 1rem 0;
    border-bottom: 1px solid var(--ink);
  }
  .docs-index summary {
    cursor: pointer;
    border-bottom: 0;
    padding-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .docs-index summary::after {
    content: "show";
    font-family: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: none;
    text-decoration: underline;
  }
  .docs-index details[open] summary::after {
    content: "hide";
  }
  .docs-index details[open] summary {
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--ink);
  }
  .index-list {
    columns: 2;
    column-gap: 1.5rem;
  }
  .index-list > li {
    break-inside: avoid;
  }
  .prose {
    padding-left: 0;
    border-left: 0;
  }
  .anchor {
    opacity: 1;
  }
}

/* A phone shows a table as stacked rows. Each cell carries the name of its column. */
@media (max-width: 640px) {
  .index-list {
    columns: 1;
  }
  .table-wrap {
    overflow-x: visible;
  }
  table,
  tbody,
  tr,
  td {
    display: block;
  }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  tbody {
    border-top: 2px solid var(--ink);
  }
  tr {
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--ink);
  }
  td {
    position: relative;
    min-height: 1.6rem;
    padding: 0.15rem 0 0.15rem 5.9rem;
    border-bottom: 0;
  }
  td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 0.2rem;
    width: 5.3rem;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--ink-soft);
    line-height: 1.35;
  }
  /* The first cell names the row. It needs no label. */
  td:first-child {
    padding-left: 0;
    padding-bottom: 0.3rem;
    font-size: 1rem;
  }
  td:first-child::before {
    content: none;
  }
  td:empty {
    display: none;
  }
  td:first-child code {
    white-space: normal;
  }
  tr:target td {
    background: none;
  }
  tr:target {
    box-shadow: inset 4px 0 0 var(--marker);
    padding-left: 0.7rem;
  }
}
