/* The help panel behind „?“ (Components/Layout/Help/HelpPanel.razor). Global, not component-scoped: the article
   text is HTML from the help site that the component does not render tag by tag, and the large picture is appended to
   the body by wwwroot/js/help-panel.js. Every class starts with hp-.

   Layer on a desktop (999): over the page, under the app bar (1100) and under everything a page lays over itself —
   its dialogs, shades and drawers start at 1000 — and under the message sidebar (1400). What a page opens while the
   help is open therefore lies over the help, not under it. On a phone the panel takes the whole screen (5000). */

.hp-panel {
    --hp-w: clamp(400px, 30vw, 460px);
    --hp-tint: var(--cx-sidebar-active-bg);
    position: fixed;
    top: calc(var(--cx-maintenance-banner-h, 0px) + var(--cx-topbar-h));
    right: 0;
    bottom: 0;
    z-index: 999;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: var(--hp-w);
    max-width: 100vw;
    background: var(--cx-card-bg);
    border-left: 1px solid var(--cx-hairline-strong);
    box-shadow: -12px 0 28px -16px rgba(28, 25, 21, 0.28);
    color: var(--cx-text-primary);
    font-size: 14px;
    line-height: 1.45;
    outline: none;
    transform: translateX(102%);
    visibility: hidden;
    transition: transform 0.18s ease, visibility 0s linear 0.18s;
}

.hp-panel.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.18s ease;
}

/* The review of a document has no app bar; the panel starts below its dark head (56 px), whose „?“ stays reachable. */
.erp-main.hides-appbar .hp-panel {
    top: calc(var(--cx-maintenance-banner-h, 0px) + 56px);
}

/* The message sidebar, minimised, stays as a bar of 48 px at the lower right edge (AppBar.razor) and lies over the
   panel: the content of the panel ends above it, so its foot stays in view. The panel itself reaches the lower edge —
   the bar is narrower than the panel, and the page would show through beside it. Opened, the two never stand
   together (AppBar.razor). */
@media (min-width: 769px) {
    body:has(.chat-sidebar-panel.is-minimized) .hp-panel {
        padding-bottom: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hp-panel,
    .hp-panel.is-open {
        transition: none;
    }
}

.hp-panel button {
    font: inherit;
    color: inherit;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}

.hp-panel .icon-button {
    width: 32px;
    height: 32px;
    font-size: 18px;
    color: var(--cx-text-secondary);
    text-decoration: none;
}

.hp-panel .icon-button:hover {
    color: var(--cx-text-primary);
}

.hp-panel :focus-visible {
    outline: 2px solid var(--cx-primary);
    outline-offset: -2px;
}

/* ── Head ── */
.hp-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 52px;
    padding: 0 10px 0 16px;
    border-bottom: 1px solid var(--cx-hairline);
}

.hp-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hp-head .hp-back {
    margin-left: -8px;
}

.hp-crumb {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--cx-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Search ── */
.hp-search {
    flex: none;
    padding: 12px 16px 4px;
}

.hp-search[hidden] {
    display: none;
}

/* Size and weight are set here: the general rule for labels (app.css) would make the field, which inherits from its
   label, smaller and bolder than the text of the panel. The magnifier takes its size from the label as well; its
   colour is set on the symbol, the label keeps the central label colour. */
.hp-search label {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid var(--cx-hairline-strong);
    border-radius: var(--cx-radius-control);
    background: var(--cx-card-bg);
    font-size: 14px;
    font-weight: 400;
}

.hp-search label > i {
    color: var(--cx-text-muted);
}

.hp-search label:focus-within {
    border-color: var(--cx-primary);
    box-shadow: var(--cx-focus-ring);
}

.hp-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: none;
    font: inherit;
    color: var(--cx-text-primary);
    -webkit-appearance: none;
    appearance: none;
}

/* The box around the field shows the focus (:focus-within); a second ring inside it would cut into the text. */
.hp-search input:focus-visible {
    outline: 0;
}

.hp-search input::-webkit-search-cancel-button {
    display: none;
}

.hp-search input::placeholder {
    color: var(--cx-placeholder-color);
}

.hp-search .hp-clear {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: var(--cx-radius-control);
    font-size: 14px;
    color: var(--cx-text-secondary);
}

/* ── List ── */
.hp-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    /* A word longer than the panel is wide (a pasted address in the search, a file name in a title) breaks. */
    overflow-wrap: anywhere;
}

.hp-sec {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cx-text-secondary);
}

.hp-sec::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--cx-hairline);
}

.hp-panel .hp-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    width: 100%;
    padding: 10px 16px;
}

.hp-panel .hp-row:hover {
    background: var(--sand);
}

.hp-row > i {
    margin-top: 1px;
    font-size: 20px;
    color: var(--cx-text-secondary);
}

.hp-row b {
    display: block;
    font-weight: 600;
}

.hp-row .hp-d {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--cx-text-secondary);
}

.hp-row .hp-where {
    display: block;
    margin-bottom: 1px;
    font-size: 12px;
    font-weight: 600;
    color: var(--cx-text-secondary);
}

.hp-row .hp-m {
    margin-top: 2px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--cx-text-secondary);
}

.hp-row mark {
    padding: 0 1px;
    border-radius: calc(var(--cx-radius-control) / 3);
    background: rgba(184, 96, 31, 0.22);
    color: inherit;
}

/* ── Areas: each opens in place and lists its guides below its own row ── */
.hp-area-head .hp-m {
    margin-top: 3px;
    font-size: 16px;
}

/* The guides of an area stand under its name: their symbol starts where the name of the area starts. */
.hp-panel .hp-area-list .hp-row {
    padding-left: 48px;
}

.hp-count {
    padding: 12px 16px 2px;
    font-size: 12.5px;
    color: var(--cx-text-secondary);
}

/* ── Messages: nothing for this page, nothing found, not reachable ── */
.hp-msg {
    padding: 28px 24px 8px;
    text-align: center;
}

.hp-msg > i {
    font-size: 30px;
    color: var(--cx-text-muted);
}

.hp-msg h3 {
    margin: 10px 0 4px;
    font-size: 15px;
    font-weight: 700;
}

.hp-msg p {
    margin: 0;
    font-size: 13px;
    color: var(--cx-text-secondary);
}

.hp-panel .hp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    margin-top: 14px;
    padding: 0 12px;
    border: 1px solid var(--cx-hairline-strong);
    border-radius: var(--cx-radius-control);
    background: var(--cx-card-bg);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.hp-panel .hp-btn:hover:not(:disabled) {
    background: var(--sand);
}

.hp-panel .hp-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.hp-lnk {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--cx-radius-control);
    font-size: 13px;
    font-weight: 600;
    color: var(--cx-text-secondary);
    text-decoration: none;
}

.hp-lnk:hover {
    color: var(--cx-primary-hover);
}

.hp-msg .hp-lnk {
    margin-top: 12px;
}

/* Placeholder while the first package loads: rows in their final height, nothing jumps when the list arrives. */
.hp-loading {
    display: grid;
    gap: 18px;
    padding: 22px 16px;
}

.hp-loading span {
    display: block;
    height: 34px;
    border-radius: var(--cx-radius-control);
    background: var(--sand);
    animation: hp-pulse 1.2s ease-in-out infinite;
}

.hp-loading span:nth-child(2) {
    width: 82%;
}

.hp-loading span:nth-child(3) {
    width: 64%;
}

@keyframes hp-pulse {
    50% {
        opacity: 0.5;
    }
}

.hp-foot {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--cx-hairline);
}

/* ── Article ── */
.hp-art {
    padding: 16px 16px 28px;
}

.hp-art-title {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.hp-art .hp-lead {
    margin: 6px 0 0;
    color: var(--cx-text-secondary);
}

.hp-art .hp-notice {
    margin: 12px 0 0;
    padding: 8px 10px;
    border-radius: var(--cx-radius-control);
    background: var(--sand);
    font-size: 12.5px;
    color: var(--cx-text-secondary);
}

.hp-video {
    margin: 14px 0 0;
}

.hp-video video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--cx-radius-surface);
    background: #14110D;
}

/* ── Video larger, without full screen ──
   „Größer“ puts the stage of the video (video and „Kleiner“) into a large layer over the page, below the app bar.
   The video element stays where it is in the document — only its stage changes from the flow of the article to a
   fixed layer — so the playback runs on and the subtitles stay. The state is the attribute data-large on the stage,
   set by help-panel.js: the component never renders it, so no render of the panel takes it away, and a change of
   page — which resets the attributes of <html> — does not touch it. The layer lies inside the panel's own layer
   (999): above the page, under the app bar and under everything a page lays over itself. */
/* Prefixed with .hp-panel: the general rule for buttons of the panel (.hp-panel button) would win otherwise. */
.hp-panel .hp-vid-grow,
.hp-panel .hp-vid-shrink {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 10px;
    border-radius: var(--cx-radius-control);
    font-size: 13px;
    font-weight: 600;
}

.hp-panel .hp-vid-grow {
    margin-top: 6px;
    color: var(--cx-text-secondary);
}

.hp-panel .hp-vid-grow:hover {
    background: var(--hp-tint);
    color: var(--cx-text-primary);
}

.hp-panel .hp-vid-shrink {
    display: none;
}

.hp-video:has(> .hp-stage[data-large])::before {
    /* Keeps the place of the small video, so the article does not move up under the layer. */
    content: "";
    display: block;
    aspect-ratio: 16 / 9;
}

.hp-stage[data-large] {
    --hp-stage-top: calc(var(--cx-maintenance-banner-h, 0px) + var(--cx-topbar-h));
    position: fixed;
    top: var(--hp-stage-top);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 56px 32px 32px;
    background: rgba(20, 17, 13, 0.92);
    outline: none;
}

/* The review of a document has no app bar; the layer starts below its dark head, like the panel. */
.erp-main.hides-appbar .hp-stage[data-large] {
    --hp-stage-top: calc(var(--cx-maintenance-banner-h, 0px) + 56px);
}

.hp-stage[data-large] video {
    /* As wide as the layer allows, at most 1280 px, and never higher than the layer: the width follows the height. */
    width: min(1280px, 100%, calc((100vh - var(--hp-stage-top) - 88px) * 16 / 9));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.hp-panel .hp-stage[data-large] > .hp-vid-shrink {
    display: inline-flex;
    position: absolute;
    top: 12px;
    right: 16px;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.hp-panel .hp-stage[data-large] > .hp-vid-shrink:hover {
    background: rgba(255, 255, 255, 0.22);
}

.hp-panel .hp-video:has(> .hp-stage[data-large]) > .hp-vid-grow {
    visibility: hidden;
}

.hp-chapters {
    margin-top: 10px;
}

.hp-chapters h3 {
    display: flex;
    justify-content: space-between;
    margin: 0;
    padding: 4px 0 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cx-text-secondary);
}

.hp-chapters h3 span {
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.hp-chapters ol {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--cx-hairline);
    border-radius: var(--cx-radius-surface);
    overflow: hidden;
}

.hp-chapters li + li {
    border-top: 1px solid var(--cx-hairline);
}

.hp-chapters button {
    position: relative;
    display: flex;
    gap: 12px;
    width: 100%;
    padding: 8px 12px;
    font-weight: 500;
}

.hp-chapters button:hover {
    background: var(--sand);
}

.hp-chapters .hp-z {
    min-width: 32px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--cx-text-secondary);
}

/* The running chapter: copper bar and tint, as every active entry (design standard). */
.hp-chapters button[aria-current] {
    background: var(--hp-tint);
    color: var(--cx-primary-hover);
    font-weight: 700;
}

.hp-chapters button[aria-current] .hp-z {
    color: var(--cx-primary-hover);
}

.hp-chapters button[aria-current]::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--cx-primary);
}

/* The text of the article: HTML of the help site, cleaned on load. Only the elements the contract allows. */
.hp-abody {
    margin-top: 18px;
    overflow-wrap: anywhere;
}

.hp-abody h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 22px 0 8px;
    padding-top: 14px;
    border-top: 1px solid var(--cx-hairline);
    font-size: 15px;
    font-weight: 700;
    scroll-margin-top: 8px;
}

.hp-abody h3,
.hp-abody h4 {
    margin: 16px 0 6px;
    font-size: 14px;
    font-weight: 700;
    scroll-margin-top: 8px;
}

.hp-abody [id] {
    scroll-margin-top: 8px;
}

.hp-panel .hp-at {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 2px 9px 2px 7px;
    border: 1px solid var(--cx-hairline-strong);
    border-radius: var(--cx-radius-round);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--cx-text-secondary);
}

.hp-panel .hp-at:hover {
    border-color: var(--cx-primary);
    color: var(--cx-primary-hover);
}

.hp-abody p {
    margin: 0 0 10px;
}

.hp-abody ol {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: hp-step;
}

.hp-abody ol > li {
    position: relative;
    margin-bottom: 14px;
    padding-left: 30px;
    counter-increment: hp-step;
}

.hp-abody ol > li::before {
    content: counter(hp-step);
    position: absolute;
    left: 0;
    top: 0;
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    border-radius: var(--cx-radius-round);
    background: var(--sand);
    font-size: 12px;
    font-weight: 700;
    color: var(--cx-text-secondary);
}

/* The base rule of Tailwind takes the signs of every list away (ol, ul { list-style: none }): bullets come back here,
   the steps of an ol carry their number in the circle above. A check list keeps its own sign (further down). */
.hp-abody ul {
    margin: 0 0 10px;
    padding-left: 18px;
    list-style: disc;
}

.hp-abody ul ul {
    list-style: circle;
}

.hp-abody ul li {
    margin-bottom: 4px;
}

.hp-abody a {
    color: var(--cx-primary-hover);
    font-weight: 600;
    text-decoration: none;
}

.hp-abody a:hover {
    text-decoration: underline;
}

.hp-abody code,
.hp-abody kbd {
    padding: 1px 5px;
    border-radius: var(--cx-radius-control);
    background: var(--sand);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12.5px;
    color: inherit;
}

.hp-abody blockquote {
    margin: 0 0 10px;
    padding-left: 12px;
    border-left: 4px solid var(--cx-hairline-strong);
    color: var(--cx-text-secondary);
}

.hp-abody hr {
    margin: 16px 0;
    border: 0;
    border-top: 1px solid var(--cx-hairline);
}

.hp-abody img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--cx-hairline-strong);
    border-radius: var(--cx-radius-control);
    background: var(--sand);
    cursor: zoom-in;
}

.hp-abody table {
    width: 100%;
    margin: 0 0 10px;
    border-collapse: collapse;
    font-size: 13px;
}

.hp-abody th,
.hp-abody td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--cx-hairline);
    text-align: left;
    vertical-align: top;
}

/* Boxes of the older articles: a quiet tinted block, no second frame inside the panel. */
.hp-abody .callout,
.hp-abody div.check-list {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: var(--cx-radius-control);
    background: var(--sand);
}

.hp-abody .callout > :last-child,
.hp-abody div.check-list > :last-child {
    margin-bottom: 0;
}

.hp-abody .check-list ul,
.hp-abody ul.check-list {
    padding-left: 0;
    list-style: none;
}

.hp-abody .check-list li {
    position: relative;
    padding-left: 22px;
}

.hp-abody .check-list li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 4px;
    width: 12px;
    height: 12px;
    border: 1px solid var(--cx-hairline-strong);
    border-radius: calc(var(--cx-radius-control) / 2);
}

.hp-abody .check-list li.done::before {
    border-color: var(--cx-primary);
    background: var(--cx-primary);
}

.hp-abody .hp-flash {
    animation: hp-flash 1.6s ease;
}

@keyframes hp-flash {
    0%,
    40% {
        background: var(--hp-tint);
    }

    100% {
        background: transparent;
    }
}

/* ── Picture large ── */
.hp-lightbox {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    background: rgba(20, 17, 13, 0.86);
    cursor: zoom-out;
    outline: none;
}

.hp-lightbox img {
    max-width: 100%;
    max-height: calc(100% - 60px);
    border-radius: var(--cx-radius-surface);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.hp-lightbox p {
    max-width: 80ch;
    margin: 0;
    font-size: 14px;
    text-align: center;
    color: #fff;
}

/* ── The „?“ of the app bar while the panel is open ── */
.erp-topbar .icon-button.is-on {
    background: var(--cx-sidebar-active-bg);
    color: var(--cx-primary-hover);
}

.erp-topbar .icon-button > .ph {
    font-size: 18px;
}

/* ── Phone: the whole screen, below the maintenance banner (shown only during a maintenance notice; it lies over
   everything and would cover the head of the panel with its close button) ── */
@media (max-width: 768px) {
    .hp-panel,
    .erp-main.hides-appbar .hp-panel {
        top: var(--cx-maintenance-banner-h, 0px);
        width: 100vw;
        z-index: 5000;
        border-left: 0;
        box-shadow: none;
    }

    .hp-panel .icon-button {
        width: 40px;
        height: 40px;
    }

    .hp-search label {
        height: 40px;
    }

    /* On a phone the video already takes the whole width of the screen; larger is the player's full screen. */
    .hp-panel .hp-vid-grow {
        display: none;
    }

    .hp-search input {
        font-size: 16px; /* below 16 px iOS zooms into the field */
    }

    .hp-panel .hp-row {
        padding: 12px 16px;
    }
}

/* Last in the file, so it holds against the rules above: with reduced motion nothing pulses or flashes. */
@media (prefers-reduced-motion: reduce) {
    .hp-loading span,
    .hp-abody .hp-flash {
        animation: none;
    }
}
