/*
 * ape-ui: Favoriten-Dropdown und Schnellwechsler (Strg/Cmd+K).
 * Nutzt nur Forgejo-Variablen -> funktioniert mit jedem Theme (github-*,
 * forgejo-*, gitea-*), hell und dunkel.
 */

/* ---- Favoriten-Dropdown in der Kopfzeile ---- */
#navbar .ape-fav > summary {
  color: var(--color-text);
  cursor: pointer;
}
.ape-fav .ape-fav-list {
  max-height: min(60vh, 420px);
  overflow-y: auto;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
}
.ape-fav .ape-fav-list > li > a {
  gap: .5rem !important;
}
.ape-fav .ape-fav-list .ape-owner {
  color: var(--color-text-light);
}
.ape-fav .ape-fav-list .ape-name {
  font-weight: 600;
}
.ape-fav .ape-fav-list .ape-label,
.ape-fav .ape-fav-list > li > a > span:not(.ape-ico) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ape-fav .ape-fav-msg {
  padding: .5rem var(--dropdown-padding-inline, .75rem);
  color: var(--color-text-light);
  white-space: normal;
  max-width: 280px;
}
.ape-ico {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--color-text-light);
}

/* ---- Knopf "Springen zu … Strg K" ---- */
#navbar .ape-k-btn {
  gap: .5rem;
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--border-radius);
  color: var(--color-text-light);
  font: inherit;
  cursor: pointer;
}
@media (min-width: 768px) {
  #navbar .ape-k-btn {
    border: 1px solid var(--color-secondary);
    margin-inline-start: .5rem;
    padding-inline: .6rem;
  }
}
#navbar .ape-k-btn:hover,
#navbar .ape-k-btn:focus-visible {
  color: var(--color-text);
}
.ape-k-kbd,
.ape-k kbd {
  font-family: var(--fonts-monospace);
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border: 1px solid var(--color-secondary);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--color-text-light);
  background: var(--color-body);
}
@media (max-width: 767.98px) {
  #navbar .ape-k-kbd {
    display: none;
  }
}

/* ---- Modal ---- */
dialog.ape-k {
  position: fixed;
  inset: 12vh 0 auto 0;
  margin: 0 auto;
  width: min(640px, calc(100vw - 32px));
  max-height: 70vh;
  padding: 0;
  border: 1px solid var(--color-secondary);
  border-radius: 12px;
  background: var(--color-body);
  color: var(--color-text);
  box-shadow: 0 8px 24px var(--color-shadow);
  overflow: hidden;
}
dialog.ape-k[open] {
  display: flex;
  flex-direction: column;
}
dialog.ape-k::backdrop {
  background: var(--color-overlay-backdrop, #0008);
}
.ape-k-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-secondary);
}
.ape-k-head input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
}
.ape-k-list {
  list-style: none;
  margin: 0;
  padding: .25rem 0 .5rem;
  overflow-y: auto;
}
.ape-k-group {
  padding: .5rem 1rem .25rem;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-light);
}
.ape-k-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 .5rem;
  padding: .45rem .5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  color: var(--color-text);
}
.ape-k-item[aria-selected="true"] {
  background: var(--color-active);
  box-shadow: inset 2px 0 0 var(--color-primary);
}
.ape-k-item .ape-k-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ape-k-item .ape-owner {
  color: var(--color-text-light);
}
.ape-k-item .ape-name {
  font-weight: 600;
}
.ape-k-item .ape-k-desc {
  color: var(--color-text-light);
  font-size: 12px;
  margin-inline-start: .5rem;
}
.ape-k-msg {
  padding: .75rem 1rem;
  color: var(--color-text-light);
}
.ape-k-foot {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  padding: .5rem 1rem;
  border-top: 1px solid var(--color-secondary);
  font-size: 12px;
  color: var(--color-text-light);
  background: var(--color-box-header);
}
@media (max-width: 767.98px) {
  dialog.ape-k {
    inset-block-start: 16px;
    max-height: calc(100vh - 32px);
  }
  .ape-k-foot {
    display: none;
  }
}
