/* Hilfe-Overlay. */

body.help-open {
  overflow: hidden;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: var(--ui-space-16);
}

.help-overlay[hidden] {
  display: none;
}

.help-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 35, 50, 0.32);
}

.help-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(68rem, 100%);
  height: 100%;
  max-height: 100%;
  min-height: 0;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-panel-radius);
  color: var(--app-text);
  outline: none;
}

.help-dialog-head {
  display: flex;
  align-items: center;
  gap: var(--ui-space-12);
  min-height: var(--ui-size-header);
  padding: 0 var(--ui-space-8) 0 var(--ui-space-16);
  border-bottom: 1px solid var(--app-border);
  flex-shrink: 0;
}

.help-dialog-title {
  margin: 0;
  font-size: var(--ui-font-size-lg);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-wrap: balance;
  flex: 1 1 auto;
}

.help-close-btn {
  position: relative;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  background: transparent;
  color: var(--app-muted);
  border-radius: var(--ui-radius-control);
}

.help-close-btn:hover,
.help-close-btn:focus-visible {
  color: var(--app-text);
  background: var(--app-surface-muted);
}

.help-close-btn:focus:not(:focus-visible) {
  box-shadow: none;
  outline: none;
}

.help-dialog-body {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  min-height: 0;
  flex: 1 1 auto;
}

.help-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: var(--ui-space-12) var(--ui-space-8);
  border-right: 1px solid var(--app-border);
  overflow: auto;
  background: var(--app-surface);
}

.help-nav-link {
  display: block;
  padding: 0.4rem 0.65rem;
  border-radius: var(--ui-radius-control);
  color: var(--app-muted);
  text-decoration: none;
  font-size: var(--ui-font-size-sm);
  line-height: 1.35;
}

.help-nav-link:hover {
  color: var(--app-text);
  background: var(--ui-table-row-hover);
}

.help-nav-link.is-active {
  color: var(--app-primary);
  font-weight: 600;
  background: var(--app-primary-light);
}

.help-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.help-article {
  overflow: auto;
  flex: 1 1 auto;
  padding: var(--ui-space-24) clamp(1.25rem, 4vw, 2.5rem) 3rem;
}

.help-section + .help-section {
  margin-top: 2.25rem;
}

.help-article h2 {
  margin: 0 0 0.75rem;
  font-size: var(--ui-font-size-xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--app-text);
}

.help-article h3 {
  margin: 1.35rem 0 0.45rem;
  font-size: var(--ui-font-size-md);
  font-weight: 650;
  color: var(--app-text);
}

.help-article p,
.help-article li,
.help-article dd {
  font-size: var(--ui-font-size-md);
  line-height: 1.55;
  color: var(--app-text);
  text-wrap: pretty;
}

.help-article p {
  margin: 0 0 0.85rem;
}

.help-article p:last-child,
.help-article ul:last-child,
.help-article dl:last-child,
.help-keys:last-child {
  margin-bottom: 0;
}

.help-article ul {
  margin: 0 0 0.85rem;
  padding-left: 1.15rem;
}

.help-article li + li {
  margin-top: 0.35rem;
}

.help-article code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--app-surface-muted);
  border-radius: 0.2rem;
  padding: 0.05em 0.3em;
}

.help-aside {
  color: var(--app-muted);
}

.help-dl {
  margin: 0 0 0.85rem;
}

.help-dl-row {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: var(--ui-space-12);
  padding: 0.55rem 0;
  border-top: 1px solid var(--app-border);
}

.help-dl-row:last-child {
  border-bottom: 1px solid var(--app-border);
}

.help-dl dt {
  font-size: var(--ui-font-size-sm);
  font-weight: 650;
  color: var(--app-text);
  padding-top: 0.1rem;
}

.help-dl dd {
  margin: 0;
}

.help-keys {
  display: grid;
  gap: 0.45rem;
  margin: 0.35rem 0 0;
}

.help-key-row {
  display: grid;
  grid-template-columns: minmax(9.5rem, 12rem) minmax(0, 1fr);
  gap: var(--ui-space-12);
  align-items: center;
}

.help-key-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
}

.help-key-join {
  color: var(--app-text-tertiary);
  font-size: var(--ui-font-size-xs);
  padding: 0 0.1rem;
}

.help-key-keys kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.12rem 0.38rem;
  border: 1px solid var(--app-border-strong);
  border-radius: 0.25rem;
  background: var(--app-surface-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-xs);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--app-text);
}

.help-key-action {
  font-size: var(--ui-font-size-sm);
  color: var(--app-text);
}

.app-footer-help {
  font-size: inherit;
  line-height: inherit;
  color: var(--bs-secondary-color);
  text-decoration: none;
  vertical-align: baseline;
}

.app-footer-help:hover,
.app-footer-help:focus-visible {
  color: var(--bs-body-color);
  text-decoration: underline;
}

@media (max-width: 800px) {
  .help-overlay {
    padding: 0;
  }

  .help-dialog {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: 0;
  }

  .help-dialog-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .help-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--app-border);
    padding: var(--ui-space-8);
    gap: var(--ui-space-4);
  }

  .help-nav-link {
    white-space: nowrap;
  }

  .help-dl-row,
  .help-key-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .help-overlay-backdrop {
    opacity: 0;
    transition: opacity 0.18s ease;
  }

  .help-dialog {
    transform: translateY(6px);
    opacity: 0;
    transition-property: transform, opacity;
    transition-duration: 0.18s;
    transition-timing-function: ease;
  }

  .help-overlay.is-open .help-overlay-backdrop {
    opacity: 1;
  }

  .help-overlay.is-open .help-dialog {
    transform: none;
    opacity: 1;
  }
}
