/* Floating right-hand index for wiki connector docs (source_component pages).
   Loaded by views/wiki/article.pug only when is_connector_doc is true, so plain
   wiki articles are untouched by everything in this file. */

/* The navbar is fixed-top, so an anchor jump would otherwise park the heading
   underneath it. Scoped to the article body of connector pages only. */
.blog-content h2[id],
.blog-content h3[id],
.blog-content h4[id] {
  scroll-margin-top: 96px;
}

.kdd-toc-col {
  padding-left: 0;
  padding-right: 0;
}

/* #main sets overflow:hidden, which disables position:sticky for descendants.
   The existing left sidebar (.posts-navigation) works around it with fixed
   positioning; the right index does the same for consistency. */
.kdd-toc {
  position: fixed;
  top: 92px;
  right: 0;
  width: 16.666667%;
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  font-family: 'Assistant', 'Arial', sans-serif;
  z-index: 1030;
}

.kdd-toc-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  margin: 0 12px;
  border: 1px solid #e2e5ec;
  border-radius: 8px;
  background-color: #fff;
  box-shadow: 0 2px 10px rgba(56, 62, 81, 0.08);
  overflow: hidden;
}

.kdd-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px 14px;
  border-bottom: 1px solid #eef0f4;
}

.kdd-toc-title {
  color: #383e51;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.kdd-toc-search-wrap {
  position: relative;
  padding: 10px 12px 8px 12px;
}

.kdd-toc-search {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 30px 8px 12px;
  border: 1px solid #d7dbe4;
  border-radius: 6px;
  background-color: #f7f8fa;
  color: #383e51;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.kdd-toc-search::placeholder {
  color: #9aa2b4;
}

.kdd-toc-search:focus {
  border-color: #18a24a;
  background-color: #fff;
}

.kdd-toc-search-clear {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 4px;
  border: none;
  background: none;
  color: #9aa2b4;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.kdd-toc-search-clear:hover {
  color: #55607b;
}

.kdd-toc-empty {
  padding: 4px 14px 12px 14px;
  color: #9aa2b4;
  font-size: 0.8rem;
  font-style: italic;
}

/* Group headers ("Sections" / "In the content"). They carry display:flex, so
   the hidden attribute needs an explicit rule to win over it. */
.kdd-toc-group {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px 4px 14px;
  color: #9aa2b4;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kdd-toc-group[hidden] {
  display: none;
}

.kdd-toc-group-count {
  color: #b3bac8;
  font-weight: 600;
  letter-spacing: 0;
}

/* Full-text hits. Denser than the section index: every row is a snippet and
   wraps over two or three lines. */
.kdd-toc-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kdd-toc-result {
  display: block;
  padding: 7px 14px;
  border-left: 3px solid transparent;
  color: #55607b;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;
}

.kdd-toc-result:hover,
.kdd-toc-result:focus {
  border-left-color: #d7dbe4;
  background-color: #f4f6f9;
  text-decoration: none;
}

.kdd-toc-result-section {
  display: block;
  color: #18a24a;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.kdd-toc-result-snippet {
  display: block;
  color: #6b7488;
  font-size: 0.78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.kdd-toc-mark {
  padding: 0 1px;
  border-radius: 2px;
  background-color: #fff3b0;
  color: #383e51;
  font-weight: 600;
}

/* Transient highlight on the matched block after jumping to it, so the reader
   lands on the exact line and not just the right neighbourhood. */
.kdd-toc-hit-flash {
  animation: kdd-toc-hit-flash 2s ease-out 1;
}

@keyframes kdd-toc-hit-flash {
  0%, 45% { background-color: #fff3b0; }
  100% { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .kdd-toc-hit-flash {
    animation: none;
    background-color: #fff3b0;
  }
}

.kdd-toc-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 10px;
}

.kdd-toc-scroll::-webkit-scrollbar {
  width: 6px;
}

.kdd-toc-scroll::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background-color: #d7dbe4;
}

.kdd-toc-list,
.kdd-toc-sublist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kdd-toc-sublist {
  border-left: 1px solid #eef0f4;
  margin-left: 14px;
}

.kdd-toc-link {
  display: block;
  padding: 6px 14px;
  border-left: 3px solid transparent;
  color: #55607b;
  font-size: 0.85rem;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.kdd-toc-item-pipeline > .kdd-toc-link {
  color: #6b7488;
  font-size: 0.8rem;
}

.kdd-toc-link:hover,
.kdd-toc-link:focus {
  background-color: #f4f6f9;
  color: #383e51;
  text-decoration: none;
}

.kdd-toc-link.is-active {
  border-left-color: #18a24a;
  background-color: #f2f9f5;
  color: #18a24a;
  font-weight: 600;
}

/* Drawer trigger + backdrop: desktop-only layout has no use for them. */
.kdd-toc-drawer-toggle,
.kdd-toc-drawer-close,
.kdd-toc-backdrop {
  display: none;
}

/* Below lg the right column is gone: the index becomes an off-canvas drawer
   opened by a floating tab. The whole bottom band is already taken — Chatra
   anchors bottom-right and the first-party privacy notice
   (public/_shared/javascripts/privacy_notice.js) spans bottom-left to
   bottom-right at z-index 21000 until dismissed — so the tab rides the
   right edge at mid-height, which is free at every breakpoint. */
@media (max-width: 991.98px) {
  .kdd-toc-col {
    padding: 0;
  }

  .kdd-toc-drawer-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1041;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 7px;
    border-radius: 8px 0 0 8px;
    background-color: #383e51;
    color: #fff;
    font-family: 'Assistant', 'Arial', sans-serif;
    font-size: 0.78rem;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.25);
    cursor: pointer;
  }

  .kdd-toc-drawer-toggle-icon {
    font-size: 0.95rem;
  }

  .kdd-toc-drawer-toggle-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.03em;
  }

  .kdd-toc {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 84vw;
    max-width: 340px;
    max-height: 100%;
    z-index: 1045;
    transform: translateX(105%);
    transition: transform 0.25s ease;
  }

  .kdd-toc.is-open {
    transform: translateX(0);
  }

  .kdd-toc-inner {
    height: 100%;
    max-height: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: -2px 0 14px rgba(0, 0, 0, 0.2);
  }

  .kdd-toc-header {
    padding-top: 16px;
  }

  .kdd-toc-drawer-close {
    display: block;
    padding: 0 4px;
    border: none;
    background: none;
    color: #9aa2b4;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
  }

  .kdd-toc-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1044;
    background-color: rgba(0, 0, 0, 0.4);
  }

  .kdd-toc-backdrop.is-open {
    display: block;
  }
}

@media print {
  .kdd-toc,
  .kdd-toc-drawer-toggle,
  .kdd-toc-backdrop {
    display: none !important;
  }
}
