/*
 * Shared UI: loaded on every page, Kloudfuse and Dexter alike.
 *
 * Only the pieces both products need live here. Everything that gives the
 * Dexter docs their own look (reading surface, header lockup, Copy page menu,
 * light / dark theme, version bar) is in dexter-space.css, reading-surface.css
 * and dark-theme.css, which partials/head-styles.hbs loads only on Dexter
 * pages.
 *
 * The drawer head clones the Dexter brand lockup and adds the theme button on
 * Dexter pages only (js/page-actions.js); the rules for those parts match
 * nothing on Kloudfuse pages.
 */

/* ── Search results: product label ────────────────────────────────── */

/* Each search result says which product it belongs to
   (partials/search-scripts.hbs): Kloudfuse in the orange accent, Dexter in
   the blue one. */
.pf-result__product {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(242, 80, 34, 0.1);
  color: #c2390f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  vertical-align: 1px;
  white-space: nowrap;
}

.pf-result--dexter .pf-result__product {
  background: rgba(26, 86, 219, 0.1);
  color: #1a56db;
}

/* The whole result is one link, and the site underlines links on hover. The
   row already changes ground on hover, so no underline. !important: the
   bundle's a:hover rule is more specific in places. */
a.pf-result,
a.pf-result:hover,
a.pf-result:focus,
a.pf-result:hover * {
  text-decoration: none !important;
}

/* ── Product switcher (partials/nav-menu.hbs) ─────────────────────── */

/* Replaces the component title at the top of the sidebar when the site
   publishes more than one product: a dropdown to move between the Kloudfuse
   and Dexter docs. */
.nav-panel-menu .nav-menu .kf-switcher {
  position: relative;
  margin: 0 0 0.75rem;
}

.nav-panel-menu .nav-menu .kf-switcher__current {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1.5px solid var(--kf-accent, #F25022);
  border-radius: 8px;
  background: #fff;
  color: var(--kf-nav-strong, #14171f);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-panel-menu .nav-menu .kf-switcher__current::-webkit-details-marker {
  display: none;
}

.nav-panel-menu .nav-menu .kf-switcher__current::after {
  content: "";
  margin-left: auto;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid var(--kf-nav-muted, #6b7280);
  border-bottom: 1.5px solid var(--kf-nav-muted, #6b7280);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}

.nav-panel-menu .nav-menu .kf-switcher[open] > .kf-switcher__current::after {
  transform: translateY(2px) rotate(-135deg);
}

.nav-panel-menu .nav-menu .kf-switcher__current:focus-visible {
  outline: 2px solid var(--kf-accent, #F25022);
  outline-offset: 2px;
}

.nav-panel-menu .nav-menu .kf-switcher__menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--kf-rule, #e7e9ee);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

.nav-panel-menu .nav-menu .kf-switcher__mark {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.nav-panel-menu .nav-menu .kf-switcher__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  color: var(--kf-nav-strong, #14171f);
}

.nav-panel-menu .nav-menu .kf-switcher__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-panel-menu .nav-menu .kf-switcher__text b {
  font-weight: 600;
}

.nav-panel-menu .nav-menu .kf-switcher__text span {
  font-size: 12px;
  color: var(--kf-nav-muted, #6b7280);
}

.nav-panel-menu .nav-menu .kf-switcher__item:hover {
  background: var(--kf-nav-hover, rgba(242, 80, 34, 0.06));
}

.nav-panel-menu .nav-menu .kf-switcher__item.is-current {
  background: var(--kf-nav-tint, rgba(242, 80, 34, 0.09));
}

.nav-panel-menu .nav-menu .kf-switcher__item.is-current b {
  color: var(--kf-accent-deep, #C2390F);
}

/* ── Header bar on small screens ──────────────────────────────────── */

/* The full bar needs about 1000px. Below the desktop breakpoint it overflowed:
   the brand was pushed out and the links ran off the right edge. Drop the
   parts a phone or tablet can do without, in two steps, and let the search
   field take whatever width is left. */
@media screen and (max-width: 1023.98px) {
  body.article .navbar .navbar-item.is-cta-ghost,
  body.article .navbar-brand .navbar-item.search > a.navbar-brand__website-link {
    display: none !important;
  }

  body.article .navbar-brand {
    flex-wrap: nowrap;
    min-width: 0;
  }

  body.article .navbar-brand > .navbar-item:first-child {
    flex: none;
    padding-left: 12px;
  }

  body.article .navbar-brand .navbar-item.search {
    flex: 1 1 0;
    gap: 10px;
    min-width: 0;
    padding: 0 10px;
  }

  body.article .navbar-brand .navbar-item.search > #search-field {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 380px;
    margin: 0 0 0 auto;
  }

  body.article .navbar #search-input,
  body.article .navbar #search-input:focus {
    width: 100% !important;
    min-width: 0;
  }

  body.article .navbar .navbar-item.is-cta {
    flex: none;
  }
}

/* Phones: brand and search only. */
@media screen and (max-width: 640px) {
  body.article .navbar .navbar-item.is-cta {
    display: none !important;
  }

  body.article .navbar #search-input {
    padding-right: 12px !important;
  }
}

/* ── Nav drawer on small screens (js/page-actions.js) ─────────────── */

/* The drawer's own head and foot are only for the drawer. */
.kf-drawer-head {
  display: none;
}

/* Below the desktop breakpoint the bundle showed the sidebar as a full-width
   grey sheet under the header, with the breadcrumb bar drawn over its first
   row. It is now a drawer: a white panel that slides in from the left over a
   dimmed page, with the brand, the theme button and a close button at its
   top. .nav-container is the dimmed
   layer; aside.nav is the panel. */
@media screen and (max-width: 1023.98px) {
  body.article .body .nav-container,
  body.article.kf-nav-collapsed .body .nav-container {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 300;
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: rgba(16, 19, 25, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
  }

  body.article .body .nav-container.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease;
  }

  body.article .body .nav-container aside.nav,
  body.article.kf-nav-collapsed .body .nav-container aside.nav {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    width: min(21rem, 86vw) !important;
    height: auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 0 40px rgba(16, 19, 25, 0.22);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  body.article .body .nav-container.is-active aside.nav {
    transform: none;
  }

  body.article .body .nav-container aside.nav .panels {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.article .body .nav-container .nav-panel-menu {
    height: auto;
    overflow: visible;
    padding: 4px 10px 12px;
  }

  .kf-drawer-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 12px 8px 16px;
  }

  .kf-drawer-head__brand {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #14171f;
    text-decoration: none;
  }

  .kf-drawer-head__brand .kf-brand__mark {
    width: 26px;
    height: 26px;
  }

  .kf-drawer-head__brand .kf-brand__name {
    font-size: 19px;
  }

  .kf-drawer-head__brand .kf-brand__docs {
    font-size: 15px;
    padding-left: 9px;
  }

  .kf-drawer-head__tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .kf-drawer-head .kf-theme-toggle {
    margin: 0;
  }

  .kf-drawer-close {
    order: 100;
    position: relative;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: #6b7280;
    cursor: pointer;
  }

  .kf-drawer-close::before,
  .kf-drawer-close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 1.6px;
    border-radius: 1px;
    background: currentColor;
  }

  .kf-drawer-close::before { transform: translate(-50%, -50%) rotate(45deg); }
  .kf-drawer-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

  .kf-drawer-close:hover {
    background: #f1f2f5;
    color: #14171f;
  }
}

/* ── Search results on small screens ──────────────────────────────── */

/* The results panel is 580px wide and starts at the search field's left edge
   (set inline by partials/search-scripts.hbs), so on a phone or tablet it ran
   off the right of the screen. Below the desktop breakpoint it spans the
   screen with a small margin instead. !important beats the inline left. */
@media screen and (max-width: 1023.98px) {
  #pagefind-results {
    left: 12px !important;
    right: 12px;
    width: auto;
    max-height: 70vh;
  }
}

/* ── "More" menu in the header on small screens (js/page-actions.js) ─ */

/* A three-dot button at the right of the header, below the desktop
   breakpoint only, opening Playground, Dexter Labs and Free Download (and the
   theme switch on phones) as a small menu. */
.kf-more,
.kf-more-menu {
  display: none;
}

@media screen and (max-width: 1023.98px) {
  .navbar .kf-more {
    order: 100;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: #5b6472;
    cursor: pointer;
  }

  /* Three dots, drawn from one. */
  .navbar .kf-more span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
  }

  .navbar .kf-more:hover,
  .navbar .kf-more[aria-expanded="true"] {
    background: #f1f2f5;
    color: #14171f;
  }

  .navbar .kf-more:focus-visible {
    outline: 2px solid #f25022;
    outline-offset: 1px;
  }

  .kf-more-menu {
    position: fixed;
    right: 12px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 190px;
    padding: 6px;
    border: 1px solid #e5e8ef;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(22, 27, 36, 0.14);
  }

  .kf-more-menu[hidden] {
    display: none;
  }

  .kf-more-menu__item {
    display: block;
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: #14171f;
    font: inherit;
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
  }

  .kf-more-menu__item:hover {
    background: #f6f7f9;
    text-decoration: none;
  }

  .kf-more-menu__item--cta {
    color: #c2390f;
    font-weight: 600;
  }

  /* The theme row is for phones: the header keeps its own theme button down
     to 768px. */
  .kf-more-menu__theme {
    margin-top: 4px;
    padding-top: 11px;
    border-top: 1px solid #eceef2;
    border-radius: 0 0 8px 8px;
  }
}

@media screen and (min-width: 768.51px) and (max-width: 1023.98px) {
  .kf-more-menu__theme {
    display: none;
  }
}

/* Tablets have room for Free Download in the header, so it is not repeated
   in the menu there. */
@media screen and (min-width: 640.01px) and (max-width: 1023.98px) {
  .kf-more-menu__item--cta {
    display: none;
  }
}
