/*
 * Databad help guide.
 * Layout lives here; color values are expressed through the shared theme tokens
 * so dark-mode can later override the same variables.
 */

:root {
    --help-page-bg: var(--theme-page-bg);
    --help-text: var(--theme-text);
    --help-muted: var(--theme-text-muted);
    --help-card-bg: var(--theme-surface-bg);
    --help-card-border: var(--theme-border);
    --help-card-shadow: var(--theme-shadow-md);
    --help-soft-bg: var(--theme-surface-muted-bg);
    --help-accent: var(--theme-primary);
    --help-accent-dark: var(--theme-primary-dark);
    --help-mark-bg: var(--theme-warning-soft);
    --help-mark-text: var(--theme-text);
}

.helpquick-toggle,
.helpquick-close {
    align-items: center;
    background: var(--help-card-bg);
    border: 0;
    color: var(--help-accent-dark);
    display: inline-flex;
    justify-content: center;
}

.nav-utility-controls {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    position: static;
}

.content-breadcrumbs {
    max-width: min(42rem, 46vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-right-controls {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    max-width: calc(100vw - 4.75rem);
    padding-right: 2.75rem;
    position: fixed;
    right: 1.25rem;
    top: 0.75rem;
    z-index: 1032;
}

.topbar-right-controls .content-breadcrumbs {
    float: none;
    min-width: 0;
    position: static;
    z-index: auto;
}

.topbar-right-controls .breadcrumb {
    flex-wrap: nowrap;
    white-space: nowrap;
}

.helpquick-toggle {
    background: var(--help-card-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 999px;
    box-shadow: 0 8px 18px var(--theme-shadow-lg);
    font-size: 1rem;
    height: 30px;
    position: static;
    width: 30px;
}

.nav-utility-controls #langselect {
    min-height: 30px;
    position: static !important;
    right: auto !important;
    top: auto !important;
}

.nav-utility-controls .nav-logout {
    position: static !important;
    transform: none !important;
    white-space: nowrap;
}

.helpquick-close {
    border-radius: 8px;
    height: 30px;
    width: 30px;
}

.helpquick-toggle:hover,
.helpquick-toggle[aria-expanded="true"],
.helpquick-close:hover {
    background: var(--help-soft-bg);
    color: var(--help-accent);
}

.helpquick-popout {
    background: var(--help-card-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 8px;
    box-shadow: 0 16px 36px var(--theme-shadow-lg);
    color: var(--help-text);
    max-height: min(560px, calc(100vh - 5rem));
    overflow-y: auto;
    padding: 0.85rem;
    position: fixed;
    right: 9.3rem;
    top: 3.35rem;
    width: min(380px, calc(100vw - 2rem));
    z-index: 1033;
}

.helpquick-header,
.helpquick-search {
    align-items: center;
    display: flex;
    gap: 0.65rem;
}

.helpquick-header {
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.helpquick-header strong,
.helpquick-result strong {
    color: var(--help-text);
}

.helpquick-search {
    margin-bottom: 0.65rem;
}

.helpquick-search i,
.helpquick-result span,
.helpquick-results p {
    color: var(--help-muted);
}

.helpquick-open {
    color: var(--help-accent-dark);
    display: none;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0.45rem 0;
    text-align: right;
}

.helpquick-open:hover {
    color: var(--help-accent);
}

.helpquick-results {
    display: none;
    gap: 0.5rem;
    margin: 0.65rem 0;
}

.helpquick-popout.has-results .helpquick-results {
    display: grid;
}

.helpquick-popout.has-matches .helpquick-open {
    display: block;
}

.helpquick-result {
    background: var(--help-soft-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 7px;
    display: grid;
    gap: 0.2rem;
    padding: 0.65rem 0.7rem;
    text-decoration: none;
}

.helpquick-result:hover {
    border-color: var(--help-accent);
}

.helpquick-result strong,
.helpquick-result span {
    display: block;
}

.helpquick-result span,
.helpquick-results p {
    font-size: 0.88rem;
    line-height: 1.45;
    margin: 0;
}

.help-page {
    background: var(--help-page-bg);
    color: var(--help-text);
    height: calc(100vh - 4rem);
    overflow: hidden;
    padding: clamp(1rem, 2vw, 2rem);
}

.help-shell {
    background: var(--help-card-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 8px;
    box-shadow: 0 8px 20px var(--help-card-shadow);
    display: grid;
    gap: 0;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    height: 100%;
    margin: 0 auto;
    max-width: 1380px;
    min-height: 0;
    overflow: hidden;
}

.help-sidebar {
    border-right: 1px solid var(--help-card-border);
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
}

.help-search-panel label,
.help-sidebar h2 {
    color: var(--help-accent-dark);
    display: block;
    font-weight: 700;
    margin-bottom: 0.65rem;
}

.help-search-panel {
    margin-bottom: 30px;
}

.help-search-input-wrap {
    align-items: center;
    display: flex;
    gap: 0.55rem;
}

.help-search-panel p {
    color: var(--help-muted);
    font-size: 0.9rem;
    line-height: 1.45;
    margin: 0.65rem 0 1rem;
}

.help-index {
    display: grid;
    gap: 0.35rem;
}

.help-index-children {
    border-left: 2px solid var(--help-card-border);
    display: grid;
    gap: 0.25rem;
    margin: -0.15rem 0 0.35rem 0.75rem;
    padding-left: 0.55rem;
}

.help-page-hero {
    margin: 0 auto 1.5rem;
    max-width: 1380px;
}

.help-index-link {
    border-radius: 7px;
    color: var(--help-text);
    display: block;
    font-weight: 600;
    padding: 0.55rem 0.65rem;
    text-decoration: none;
}

.help-index-link-child {
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.42rem 0.55rem;
}

.help-index-link:hover,
.help-index-link:focus,
.help-index-link.is-active {
    background: var(--help-soft-bg);
    color: var(--help-accent-dark);
}

.help-content {
    align-content: start;
    display: grid;
    gap: 1rem;
    height: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
    scroll-padding-top: 1rem;
}

.help-topic,
.help-glossary-page-group {
    scroll-margin-top: 1rem;
}

.help-glossary-page-group {
    scroll-margin-top: 6rem;
}

.help-intro-card,
.help-topic,
.help-glossary,
.help-print-index {
    background: var(--help-card-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 8px;
    min-width: 0;
    padding: clamp(1.1rem, 2.2vw, 1.75rem);
}

.help-intro-card {
    display: grid;
    gap: 1.1rem;
}

.help-intro-card p {
    color: var(--help-muted);
    line-height: 1.55;
    margin: 0;
}

.help-intro-copy {
    min-width: 0;
}

.help-intro-toolbar {
    align-items: center;
    display: flex;
    gap: 0.85rem;
    justify-content: space-between;
    min-width: 0;
}

.help-sort-controls {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    min-width: 0;
}

.help-sort-controls strong {
    color: var(--help-text);
    flex: 0 0 auto;
}

.help-topic-child {
    margin-left: 1rem;
    position: relative;
}

.help-topic-child::before {
    background: var(--help-accent-dark);
    border-radius: 999px;
    bottom: 1rem;
    content: "";
    left: -0.55rem;
    opacity: 0.45;
    position: absolute;
    top: 1rem;
    width: 3px;
}

.help-content a,
.helpquick-popout a {
    text-decoration: none;
}

.help-content a:hover,
.helpquick-popout a:hover {
    text-decoration: none;
}

.help-topic h2,
.help-glossary h2,
.help-print-index h2 {
    color: var(--help-accent-dark);
    margin: 0;
}

.help-topic-header p,
.help-figure figcaption,
.help-glossary dd {
    color: var(--help-muted);
}

.help-print-button {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 42px;
}

.help-topic-header {
    align-items: flex-start;
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.help-topic-header p {
    line-height: 1.55;
    margin: 0.35rem 0 0;
}

.help-figure {
    margin: 1rem 0 1.25rem;
    overflow-x: auto;
}

.help-figure img {
    border: 1px solid var(--help-card-border);
    border-radius: 8px;
    display: block;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    width: auto;
}

.help-figure figcaption {
    font-size: 0.86rem;
    margin-top: 0.45rem;
}

.help-paragraph,
.help-list,
.help-note p,
.help-glossary dd {
    line-height: 1.62;
}

.help-list {
    margin: 0.75rem 0 0;
    padding-left: 1.15rem;
}

.help-list li + li {
    margin-top: 0.45rem;
}

.help-note {
    background: var(--help-soft-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 8px;
    margin-top: 1rem;
    padding: 0.85rem 1rem;
}

.help-note strong {
    color: var(--help-accent-dark);
    display: block;
    margin-bottom: 0.35rem;
}

.help-note p {
    margin: 0;
}

.help-glossary dl {
    display: grid;
    gap: 0.7rem;
    margin: 1rem 0 0;
    min-width: 0;
}

.help-glossary-toolbar {
    align-items: center;
    background: var(--help-card-bg);
    border-bottom: 1px solid var(--help-card-border);
    box-shadow:
        0 -2rem 0 2rem var(--help-card-bg),
        0 0.65rem 0.85rem -0.85rem var(--help-card-shadow);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin: 0 -0.25rem 0.75rem;
    padding: 1.65rem 0.25rem 0.75rem;
    position: sticky;
    top: -1px;
    z-index: 20;
}

.help-glossary-toggle {
    background: var(--help-soft-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 999px;
    display: inline-flex;
    max-width: 100%;
    padding: 0.2rem;
}

.help-glossary-toggle button {
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: var(--help-text);
    font-weight: 700;
    padding: 0.45rem 0.75rem;
    white-space: nowrap;
}

.help-glossary-toggle button.is-active {
    background: var(--help-card-bg);
    color: var(--help-accent-dark);
    box-shadow: 0 3px 10px var(--help-card-shadow);
}

.help-intro-toolbar .help-glossary-toggle {
    height: 42px;
    margin: 0;
    padding: 0;
}

.help-intro-toolbar .help-glossary-toggle button {
    align-items: center;
    display: inline-flex;
    height: 40px;
    padding: 0 0.85rem;
}

.help-guide-toggle {
    height: 42px;
    margin: 0;
    padding: 0;
}

.help-guide-toggle button {
    align-items: center;
    display: inline-flex;
    height: 40px;
    padding: 0 0.85rem;
}

.help-glossary-page-group + .help-glossary-page-group {
    margin-top: 1.35rem;
}

.help-glossary-page-child {
    margin-left: 1rem;
}

.help-glossary-page-group h3 {
    align-items: center;
    background: var(--help-soft-bg);
    border-left: 4px solid var(--help-accent-dark);
    border-radius: 7px;
    color: var(--help-accent-dark);
    display: flex;
    font-size: 1.08rem;
    font-weight: 800;
    margin: 1rem 0 0.75rem;
    min-height: 42px;
    padding: 0.65rem 0.85rem;
}

.help-glossary-page-group dl {
    margin-left: 1.15rem;
}

.help-glossary-entry {
    background: transparent;
    border: 0;
    border-left: 2px solid var(--help-card-border);
    border-radius: 0;
    min-width: 0;
    overflow-wrap: anywhere;
    padding: 0.25rem 0 0.25rem 0.85rem;
    word-break: normal;
}

.help-glossary-entry + .help-glossary-entry {
    margin-top: 0.45rem;
    padding-top: 0.7rem;
}

.help-glossary dt {
    color: var(--help-accent-dark);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.help-glossary dd {
    margin: 0;
}

.help-no-results {
    background: var(--help-soft-bg);
    border: 1px solid var(--help-card-border);
    border-radius: 8px;
    font-weight: 600;
    line-height: 1.45;
    margin: 0;
    padding: 1rem;
    white-space: pre-line;
}

.help-print-cover,
.help-print-index {
    display: none;
}

mark {
    background: #ffe36e;
    border: 1px solid #d4a600;
    border-radius: 5px;
    box-shadow: 0 1px 0 rgba(212, 166, 0, 0.25);
    color: #111827;
    font-weight: 700;
    padding: 0.02rem 0.22rem;
}

@media (max-width: 1200px) {
    .content-breadcrumbs {
        display: none;
    }

    .nav-utility-controls {
        right: 0.75rem;
    }
}

@media (max-width: 992px) {
    .help-shell {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .help-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--help-card-border);
        height: auto;
        max-height: 48vh;
        overflow-y: auto;
    }

    .help-page-hero {
        align-items: flex-start;
        display: grid;
        justify-items: start;
    }

    .help-intro-toolbar,
    .help-sort-controls {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .helpquick-popout {
        right: 0.75rem;
    }

    .help-page {
        height: auto;
        overflow: visible;
        padding: 1rem 0.75rem 2rem;
    }

    .help-content {
        height: auto;
        padding: 0.85rem;
        overflow-y: visible;
    }

    .help-glossary-page-group dl {
        margin-left: 0.45rem;
    }

    .help-topic-child,
    .help-glossary-page-child {
        margin-left: 0.35rem;
    }

    .help-topic-header {
        gap: 0.65rem;
    }
}

@media print {
    @page {
        margin: 14mm;
    }

    nav.navbar,
    .nav-utility-controls,
    #langselect,
    #helpquick-toggle,
    #helpquick-popout,
    .content-breadcrumbs,
    .help-screen-only,
    .cookie-consent,
    footer {
        display: none !important;
    }

    .wrapper,
    .boxed-wrapper,
    .content-wrapper {
        margin: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .help-page {
        padding: 0;
    }

    .help-shell,
    .help-content {
        display: block;
        height: auto;
        max-width: none;
        overflow: visible;
        padding: 0;
    }

    .help-print-cover {
        align-items: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 92vh;
        page-break-after: always;
        text-align: center;
    }

    .help-print-cover img {
        height: 112px;
        margin-bottom: 2.4rem;
    }

    .help-print-cover h1 {
        font-size: 32pt;
        margin: 0 0 0.8rem;
    }

    .help-print-cover p {
        font-size: 14pt;
        max-width: 145mm;
    }

    .help-print-index {
        display: block;
        page-break-after: always;
    }

    .help-topic,
    .help-glossary {
        border: 0 !important;
        box-shadow: none !important;
        margin: 0 0 1rem;
        page-break-inside: avoid;
        padding: 0;
    }

    .help-page-hero {
        display: none;
    }

    .help-figure img {
        max-height: 95mm;
    }

    .help-glossary {
        page-break-before: always;
    }
}
