/* Layout and components specific to the guide. The palette, typography and
   theme switching all come from style.css, which this loads after. */

.doc-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
  padding: 2.5rem 0 5rem;
}

/* ---- Sidebar --------------------------------------------------------- */

.doc-nav {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  font-size: .9rem;
  padding-right: .5rem;
}
.doc-nav strong {
  display: block;
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 1.5rem 0 .5rem;
}
.doc-nav strong:first-child { margin-top: 0; }
.doc-nav a {
  display: block;
  padding: .25rem .6rem;
  margin-left: -.6rem;
  border-radius: 7px;
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.45;
}
.doc-nav a:hover { background: var(--bg-sunken); color: var(--ink); }
.doc-nav a.current { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* ---- Body ------------------------------------------------------------ */

.doc-body { min-width: 0; }
.doc-body > section { padding: 0 0 3rem; border: none; }
.doc-body > section + section { border-top: 1px solid var(--line); padding-top: 3rem; }

.doc-body h1 {
  font-size: clamp(2rem, 4vw, 2.6rem);
  margin: 0 0 .6rem;
}
.doc-body h2 {
  font-size: 1.55rem;
  letter-spacing: -.02em;
  margin: 0 0 1rem;
  scroll-margin-top: 80px;
}
.doc-body h3 {
  font-size: 1.1rem;
  margin: 2rem 0 .6rem;
  scroll-margin-top: 80px;
}
.doc-body h4 {
  font-size: .95rem;
  margin: 1.5rem 0 .5rem;
  color: var(--ink-soft);
}
.doc-body p, .doc-body li { max-width: var(--measure); }
.doc-body p { margin: 0 0 1rem; }
.doc-body ul, .doc-body ol { margin: 0 0 1rem; padding-left: 1.3rem; }
.doc-body li { margin-bottom: .4rem; }
.doc-body li > ul, .doc-body li > ol { margin-top: .4rem; }

.doc-body code {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .08em .35em;
  font-size: .89em;
}
.doc-body pre code { background: none; border: none; padding: 0; font-size: inherit; }

.lead { font-size: 1.08rem; color: var(--ink-soft); max-width: 62ch; }

/* ---- Code blocks ----------------------------------------------------- */

.doc-body figure.code { margin: 0 0 1.4rem; }

/* Two implementations of one idea, side by side. Collapses to one column
   before the columns get too narrow to read the code in. */
.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.compare figure.code { margin: 0; }

/* ---- Callouts -------------------------------------------------------- */

.note {
  border-left: 3px solid var(--accent);
  background: var(--bg-raised);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  margin: 0 0 1.4rem;
  max-width: var(--measure);
}
.note p:last-child { margin-bottom: 0; }
.note .note-title {
  display: block;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: .4rem;
}
.note.warn { border-left-color: #d97706; }
.note.warn .note-title { color: #b45309; }
:root:not([data-theme="light"]) .note.warn .note-title,
:root[data-theme="dark"] .note.warn .note-title { color: #fbbf24; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .note.warn .note-title { color: #fbbf24; }
}

/* ---- Tables ---------------------------------------------------------- */

.doc-body .table-wrap { overflow-x: auto; margin: 0 0 1.4rem; }
.doc-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: .92rem;
  min-width: 460px;
}
.doc-body th, .doc-body td {
  text-align: left;
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.doc-body th {
  font-size: .78rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom-color: var(--ink-faint);
}
.doc-body tbody tr:last-child td { border-bottom: none; }
.doc-body td code { white-space: nowrap; }

/* ---- Keys ------------------------------------------------------------ */

kbd {
  display: inline-block;
  padding: .1em .45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-raised);
  font-size: .84em;
  line-height: 1.5;
  white-space: nowrap;
}

/* ---- Mobile ---------------------------------------------------------- */

@media (max-width: 900px) {
  .doc-shell { grid-template-columns: 1fr; gap: 1.5rem; }
  .doc-nav {
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 1rem;
    columns: 2;
    column-gap: 1.5rem;
  }
  .doc-nav strong { break-after: avoid; }
  .doc-nav a { break-inside: avoid; }
}
