/* The knowledge base's guides, and the help panel's link to them. */

.pf-help-guide {
  margin: 0 0 10px;
}

.kb-guide-panel {
  margin-bottom: 16px;
}

.kb-guide-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kb-guide-links a {
  display: block;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}

.kb-guide-links a:hover {
  border-color: var(--carbon);
  background: var(--carbon-wash);
}

.kb-guide-links small {
  display: block;
  margin-top: 2px;
  color: var(--ink-3);
}

.kb-guides {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.kb-guide-card h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.kb-guide-card h2 a {
  color: inherit;
}

.kb-guide-parts {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

.kb-article {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
}

.kb-contents {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--steel);
}

.kb-contents h2 {
  margin: 0 0 6px;
  font-size: 14px;
}

.kb-contents ol {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
}

.kb-part {
  scroll-margin-top: 80px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  line-height: 1.55;
}

.kb-part:target {
  border-color: var(--carbon);
  box-shadow: 0 0 0 3px var(--carbon-wash);
}

.kb-part h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.kb-part p {
  margin: 0 0 8px;
}

.kb-part ol,
.kb-part ul {
  margin: 0 0 8px;
  padding-left: 22px;
}

.kb-part li + li {
  margin-top: 4px;
}

.kb-part > :last-child {
  margin-bottom: 0;
}

a .badge {
  cursor: pointer;
}

.kb-part ol,
.kb-contents ol {
  list-style: decimal;
}

.kb-part ul,
.kb-guide-parts {
  list-style: disc;
}

.kb-part li::marker {
  color: var(--ink-3);
  font-weight: 600;
}

/* Room under every page so the floating Hank button never sits over the last buttons. */
main.content:has(~ [data-controller="help-panel"]),
body:has(.hank-button) main.content {
  padding-bottom: 72px;
}

/* Keep the desktop map's scroll area above Hank, even midway through the list. */
@media (width > 1180px) {
  body:has(.hank-button) main.content:has(> .map-layout) {
    padding-bottom: 12px;
  }

  body:has(.hank-button) .map-layout > .map-side {
    margin-bottom: 60px;
  }
}

.handbook {
  max-width: 900px;
}

.handbook-content {
  overflow-x: auto;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

.handbook-content [id] {
  scroll-margin-top: 80px;
}

.handbook-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.handbook-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.handbook-content th,
.handbook-content td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.handbook-content th {
  background: var(--steel);
}

.handbook-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.handbook-content pre {
  overflow-x: auto;
}

.handbook-chapter-index summary {
  cursor: pointer;
  font-weight: 600;
}

.handbook-chapter-index[open] summary {
  margin-bottom: 8px;
}

.handbook-content p,
.handbook-content ol,
.handbook-content ul {
  margin-bottom: 12px;
}

.handbook-content h2:not(:first-child) {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.handbook-content [id^="start-here-as-"] + p,
.handbook-content blockquote {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-inline-start: 3px solid var(--carbon);
  border-radius: 4px;
  background: var(--steel);
}

.handbook-content blockquote > :last-child {
  margin-bottom: 0;
}

.handbook-content .handbook-topics {
  padding-block: 2px;
}

.handbook-topics a + a::before {
  content: "·";
  display: inline-block;
  margin-inline: 0.45em;
  color: var(--ink-3);
}

/* The guide drawer: a guide slid out from the right edge. On wide screens it docks as a
   third column and the screen beside it narrows; on narrow ones it slides over the screen. */
:root {
  --guide-width: min(440px, 34vw);
}

.guide-drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--paper);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.guide-drawer[hidden] {
  display: none;
}

.guide-drawer.is-open {
  opacity: 1;
}

.guide-drawer-inner {
  display: flex;
  flex-direction: column;
  width: var(--guide-width);
  height: 100%;
}

.guide-drawer header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  height: 58px;
  padding: 0 12px 0 18px;
  border-bottom: 1px solid var(--line);
}

.guide-drawer h2 {
  margin: 0 auto 0 6px;
  font-size: 15px;
}

.guide-drawer-body {
  position: relative;
  display: block;
  flex: 1;
  min-height: 0;
  padding: 16px 18px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.kb-article-drawer {
  max-width: none;
  gap: 12px;
}

.kb-article-title {
  margin: 0 0 4px;
  font-size: 18px;
}

.kb-article-drawer .kb-article-title + p {
  margin: 0;
}

.kb-article-drawer .kb-part {
  padding: 12px 14px;
}

.kb-article-drawer .kb-part h2 {
  font-size: 16px;
}

.kb-part.is-current {
  border-color: var(--carbon);
  box-shadow: 0 0 0 3px var(--carbon-wash);
}

@media (min-width: 961px) {
  .shell:has(> .guide-drawer) {
    grid-template-columns: 232px minmax(0, 1fr) 0;
    transition: grid-template-columns 0.24s cubic-bezier(0.2, 0.9, 0.25, 1);
  }

  .shell:has(> .guide-drawer.is-open) {
    grid-template-columns: 232px minmax(0, 1fr) var(--guide-width);
  }

  /* Hank steps aside, to the left of the drawer. */
  body:has(.guide-drawer.is-open) .pf-help-right {
    right: calc(var(--guide-width) + 16px);
  }
}

@media (max-width: 960px) {
  .guide-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    width: min(440px, 100vw);
    height: auto;
    box-shadow: var(--shadow-menu);
    opacity: 1;
    transform: translateX(100%);
    transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.25, 1);
  }

  .guide-drawer.is-open {
    transform: none;
  }

  .guide-drawer-inner {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guide-drawer,
  .shell:has(> .guide-drawer) {
    transition: none;
  }
}
