/* Docs chrome around the frame (templates/layout.ts): the logo, the version
 * and language controls, the dock and its menus, the help button, the
 * locale banner and the shortcuts dialog.
 *
 * The dock follows the Luminous kit's dock (50 high, 44px items, 20px
 * icons, 14px dividers, 6px gaps). Its search field rests as a ⌘K chip
 * and widens while it's hovered, focused or showing the search blind; on
 * phones only a tap opens it. */

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

.docs-kbd-group {
  display: inline-flex;
  flex: none;
  gap: 4px;
}

.docs-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--d-radius-sm);
  background: var(--d-active);
  font-family: var(--d-font);
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  color: var(--d-muted);
}

/* ---- Logo ---- */

.docs-logo {
  position: absolute;
  z-index: 45;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--d-radius);
  color: var(--d-fg);
  text-decoration: none;
}

.docs-logo:hover {
  background: var(--d-hover);
}

/* Syott is in early access: a quiet pill beside the logo on every page. */
.docs-early {
  position: absolute;
  z-index: 45;
  top: 19px;
  left: 54px;
  padding: 1px 9px;
  border: 1px solid var(--d-line-strong);
  border-radius: var(--d-radius-pill);
  background: var(--d-bg);
  font-family: var(--d-font);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  color: var(--d-muted);
  white-space: nowrap;
  cursor: help;
}

@media (min-width: 1024px) {
  .docs-body:has(#docs-sidebar-root) .docs-early {
    position: fixed;
  }

  .docs-body:has(#docs-sidebar-root) .docs-logo {
    position: fixed;
  }
}

/* ---- Top-right controls ---- */

.docs-top {
  position: absolute;
  z-index: 45;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (min-width: 1280px) {
  .docs-body:has(#docs-toc-root) .docs-top {
    position: fixed;
  }
}

.docs-pill,
.docs-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border: 1px solid var(--d-line);
  border-radius: var(--d-radius-pill);
  background: var(--d-panel);
  color: var(--d-fg);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.docs-pill {
  gap: 3px;
  padding: 0 7px 0 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.docs-pill svg {
  color: var(--d-muted);
}

.docs-round {
  width: 26px;
  padding: 0;
}

:is(.docs-pill, .docs-round):hover,
:is(.docs-pill, .docs-round)[aria-expanded="true"] {
  border-color: var(--d-line-strong);
  background: var(--d-panel-soft);
}

/* ---- Menus (dock, top controls, help) ---- */

.docs-menu-root {
  position: relative;
}

.docs-menu {
  position: absolute;
  z-index: 60;
  box-sizing: border-box;
  min-width: 248px;
  padding: 8px;
  border: 1px solid var(--d-line);
  border-radius: var(--d-radius-lg);
  background: var(--d-panel);
  box-shadow: var(--d-shadow-pop);
  color: var(--d-fg);
  text-align: left;
}

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

.docs-menu--up {
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  animation: docs-menu-up 0.16s ease-out;
}

.docs-menu--down {
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  transform-origin: 100% 0;
  animation: docs-menu-down 0.16s ease-out;
}

.docs-menu--up.docs-menu--end {
  right: -8px;
  left: auto;
  transform: none;
  transform-origin: 100% 100%;
}

.docs-menu__head {
  margin: 0;
  padding: 6px 10px 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--d-muted);
}

.docs-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  padding: 0 8px 0 10px;
  border: 0;
  border-radius: var(--d-radius-sm);
  background: transparent;
  font-size: 14px;
  line-height: 1.3;
  color: var(--d-fg);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.docs-menu__item:hover,
.docs-menu__item:focus-visible {
  outline: none;
  background: var(--d-hover);
}

.docs-menu__item > svg {
  flex: none;
  color: var(--d-fg-2);
}

.docs-menu__item > span:not([class]) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-menu__check {
  display: none;
  flex: none;
  color: var(--d-accent);
}

:is([aria-checked="true"], [aria-current="true"]) > .docs-menu__check {
  display: inline-flex;
}

:is([aria-checked="true"], [aria-current="true"]) > span:not([class]) {
  font-weight: 500;
}

.docs-menu__tag {
  flex: none;
  padding: 1px 7px;
  border-radius: var(--d-radius-pill);
  background: var(--d-accent-soft);
  font-size: 11px;
  font-weight: 500;
  color: var(--d-accent);
}

.docs-menu__rule {
  height: 1px;
  margin: 6px 4px;
  background: var(--d-line);
}

.docs-menu__empty {
  margin: 0;
  padding: 6px 10px 8px;
  font-size: 13px;
  color: var(--d-muted);
}

.docs-menu__empty[hidden] {
  display: none;
}

.docs-saved__list:empty {
  display: none;
}

.docs-saved__list .docs-menu__item > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-saved__toggle[aria-pressed="true"] > svg {
  fill: var(--d-accent);
  color: var(--d-accent);
}

/* Theme choice in the user menu: a three-way switch. */
.docs-theme {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 2px 4px 4px;
  padding: 3px;
  border-radius: var(--d-radius);
  background: var(--d-panel-soft);
}

.docs-theme__option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  color: var(--d-muted);
  cursor: pointer;
}

.docs-theme__option:hover {
  color: var(--d-fg);
}

.docs-theme__option[aria-checked="true"] {
  background: var(--d-panel);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  color: var(--d-fg);
}

/* ---- Dock ---- */

.docs-dock {
  position: fixed;
  z-index: 50;
  bottom: var(--d-dock-gap);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  height: var(--d-dock-h);
  padding: 3px 4px;
  border: 1px solid var(--d-line-strong);
  border-radius: var(--d-radius-pill);
  background: var(--d-panel);
  box-shadow: var(--d-shadow-dock);
  transform: translateX(-50%);
}

.docs-dock__item {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--d-fg-2);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.docs-dock__item:hover {
  background: var(--d-hover);
  color: var(--d-fg);
}

.docs-dock__item[aria-expanded="true"] {
  background: var(--d-active);
  color: var(--d-fg);
}

.docs-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--d-line-strong);
  border-radius: 50%;
  background: var(--d-panel-soft);
}

.docs-avatar svg {
  width: 16px;
  height: 16px;
}

/* The kit's tooltip, above a dock item. */
.docs-dock__item[data-tip] {
  position: relative;
  text-decoration: none;
}

.docs-dock__item[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  padding: 5px 10px;
  border: 1px solid var(--d-line);
  border-radius: var(--d-radius-sm);
  background: var(--d-panel);
  box-shadow: var(--d-shadow-pop);
  font-size: 12px;
  line-height: 16px;
  color: var(--d-fg);
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  pointer-events: none;
}

.docs-dock__item[data-tip]:is(:hover, :focus-visible)::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* The sidebar button only exists where there's a sidebar drawer. */
.docs-dock__nav {
  display: none;
}

@media (max-width: 1023.98px) {
  .docs-body:has(#docs-sidebar-root) .docs-dock:not(.is-searching) .docs-dock__nav {
    display: block;
  }
}

.docs-dock__divider {
  display: flex;
  flex: none;
  justify-content: center;
  width: 14px;
  height: 28px;
}

.docs-dock__divider::before {
  content: "";
  width: 1.5px;
  border-radius: 1px;
  background: var(--d-line-strong);
}

.docs-dock__search {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  width: 379px;
  height: 34px;
  padding: 0 6px 0 11px;
  overflow: hidden;
  border: 1px solid var(--d-line-strong);
  border-radius: var(--d-radius-pill);
  background: var(--d-panel);
  white-space: nowrap;
  cursor: text;
  transition:
    width 0.32s cubic-bezier(0.32, 0.72, 0, 1),
    padding 0.32s cubic-bezier(0.32, 0.72, 0, 1),
    border-color 0.15s ease;
}

.docs-dock__search:hover,
.docs-dock__search:focus-within {
  border-color: var(--d-faint);
}

.docs-dock__search-icon {
  display: grid;
  flex: none;
  place-items: center;
  color: var(--d-muted);
}

.docs-dock .docs-dock__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  box-shadow: none;
  font-family: var(--d-font);
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--d-fg);
  appearance: none;
}

.docs-dock__input::placeholder {
  color: var(--d-muted);
}

.docs-dock__input::-webkit-search-cancel-button {
  display: none;
}

/* Phones keep the field collapsed to its ⌘K chip until it's tapped. */
@media (max-width: 640px) {
  .docs-dock:not(.is-searching) .docs-dock__search {
    justify-content: center;
    width: 64px;
    padding: 0 11px;
    cursor: pointer;
  }

  .docs-dock:not(.is-searching) :is(.docs-dock__search-icon, .docs-dock__input) {
    display: none;
  }

  .docs-dock.is-searching {
    width: calc(100vw - 24px);
  }

  .docs-body .docs-dock.is-searching > :not(.docs-dock__search, .docs-blind) {
    display: none;
  }

  .docs-dock.is-searching .docs-dock__search {
    flex: 1;
    width: auto;
    margin-left: 3px;
  }
}

/* At rest the field is its ⌘K chip; hover, focus or a search widens it. */
.docs-dock:not(.is-searching) .docs-dock__search:not(:hover, :focus-within) {
  justify-content: center;
  width: 64px;
  padding: 0 11px;
  cursor: pointer;
}

.docs-dock:not(.is-searching) .docs-dock__search:not(:hover, :focus-within) :is(.docs-dock__search-icon, .docs-dock__input) {
  display: none;
}

@media (max-width: 640px) {
  .docs-dock {
    gap: 4px;
    padding: 3px;
  }

  .docs-dock__item {
    width: 40px;
    height: 40px;
  }

  .docs-menu--up {
    position: fixed;
    right: 12px;
    bottom: calc(var(--d-dock-h) + var(--d-dock-gap) + 12px);
    left: 12px;
    min-width: 0;
    transform: none;
  }

  .docs-menu--up.docs-menu--end {
    right: 12px;
    left: 12px;
  }
}

/* ---- Help ---- */

.docs-help {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: 20px;
}

.docs-help__button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--d-line);
  border-radius: 50%;
  background: var(--d-panel);
  color: var(--d-muted);
  cursor: pointer;
}

.docs-help__button:hover,
.docs-help__button[aria-expanded="true"] {
  border-color: var(--d-line-strong);
  color: var(--d-fg);
}

/* The messenger's 56px launcher holds the corner (20px in), so the help
 * button stacks above it, centred on it. */
.docs-body--messenger .docs-help {
  right: 35px;
  bottom: 88px;
}

.docs-help .docs-menu--up.docs-menu--end {
  right: 0;
}

@media (max-width: 640px) {
  .docs-help {
    display: none;
  }
}

/* ---- Locale banner ---- */

.docs-locale-banner {
  position: fixed;
  z-index: 70;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--d-line);
  border-radius: var(--d-radius-pill);
  background: var(--d-panel);
  box-shadow: var(--d-shadow-pop);
  font-size: 13px;
  color: var(--d-fg-2);
  transform: translateX(-50%);
}

.docs-locale-banner[hidden],
html:has(#docs-translation-notice, .docs-dock.is-searching) .docs-locale-banner {
  display: none;
}

@media (max-width: 640px) {
  .docs-locale-banner {
    top: auto;
    right: 12px;
    bottom: calc(var(--d-dock-h) + var(--d-dock-gap) + 12px);
    left: 12px;
    flex-wrap: wrap;
    max-width: none;
    padding: 10px 10px 10px 14px;
    border-radius: var(--d-radius-lg);
    transform: none;
  }

  .docs-locale-banner__text {
    flex: 1 0 100%;
  }

  .docs-locale-banner__switch {
    margin-left: auto;
  }
}

.docs-locale-banner__switch {
  padding: 3px 10px;
  border-radius: var(--d-radius-pill);
  background: var(--d-accent-soft);
  font-weight: 500;
  color: var(--d-accent);
  white-space: nowrap;
  text-decoration: none;
}

.docs-locale-banner__dismiss {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--d-muted);
  cursor: pointer;
}

.docs-locale-banner__dismiss:hover {
  background: var(--d-hover);
}

/* ---- Dialog (keyboard shortcuts) ---- */

.docs-dialog {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
}

.docs-dialog[hidden] {
  display: none;
}

.docs-dialog__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
}

.docs-dialog__panel {
  position: relative;
  width: min(380px, 100%);
  padding: 8px 8px 10px;
  border: 1px solid var(--d-line);
  border-radius: var(--d-radius-lg);
  background: var(--d-panel);
  box-shadow: var(--d-shadow-pop);
  animation: docs-menu-down 0.16s ease-out;
}

.docs-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px 10px;
}

.docs-dialog__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.docs-dialog__close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--d-muted);
  cursor: pointer;
}

.docs-dialog__close:hover {
  background: var(--d-hover);
}

.docs-dialog__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--d-line);
  font-size: 14px;
}

/* ---- Motion ---- */

@keyframes docs-menu-up {
  from {
    opacity: 0;
    translate: 0 6px;
  }
}

@keyframes docs-menu-down {
  from {
    opacity: 0;
    translate: 0 -4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .docs-menu,
  .docs-dialog__panel {
    animation: none;
  }

  .docs-dock__search {
    transition: none;
  }
}
