/*
 * Administrator help page (#1225).
 *
 * Two jobs. First, restore typography inside a help topic: Unfold's Tailwind build resets
 * `ol, ul { list-style: none }` and `h1..h6 { font-size: inherit; font-weight: inherit }`,
 * and ships no typography plugin, so a topic's headings, bullets and numbers all render as
 * flat body text. Everything here is scoped to `.help-topic-body` so it cannot leak into
 * the rest of the admin.
 *
 * Second, the concertina itself. Built on <details>, so it works without JavaScript, is
 * reachable by keyboard, and browsers can open a closed topic when find-in-page matches
 * inside it.
 *
 * Colours are derived from `currentColor`, so the page follows the admin's light and dark
 * themes without naming either.
 */

.help-page {
    --help-rule: color-mix(in srgb, currentColor 14%, transparent);
    --help-rule-strong: color-mix(in srgb, currentColor 26%, transparent);
    --help-wash: color-mix(in srgb, currentColor 4%, transparent);
    max-width: 62rem;
}

.help-page__intro {
    margin: 0 0 1.5rem;
    opacity: 0.75;
    max-width: 60ch;
}

/* Contents ---------------------------------------------------------------- */

.help-contents {
    border: 1px solid var(--help-rule);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
}

.help-contents__heading {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
    margin: 0 0 0.75rem;
}

.help-contents__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.35rem 2rem;
}

.help-contents__list a {
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.help-contents__list a:hover {
    border-bottom-color: currentColor;
}

/* Sections ---------------------------------------------------------------- */

.help-section {
    margin-bottom: 2.5rem;
}

.help-section__heading {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--help-rule-strong);
}

.help-section__count {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.55;
    margin-left: 0.5rem;
}

.help-section__note {
    font-size: 0.85rem;
    opacity: 0.7;
    margin: 0.75rem 0 0;
}

/* One topic --------------------------------------------------------------- */

.help-topic {
    border-bottom: 1px solid var(--help-rule);
}

.help-topic__summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0.25rem;
    cursor: pointer;
    font-weight: 500;
    list-style: none;
}

/* Safari still draws its own triangle without this */
.help-topic__summary::-webkit-details-marker {
    display: none;
}

.help-topic__summary:hover {
    background: var(--help-wash);
}

.help-topic__summary:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.help-topic__chevron {
    flex: none;
    width: 1rem;
    height: 1rem;
    opacity: 0.5;
    transition: transform 0.15s ease;
}

.help-topic[open] > .help-topic__summary {
    font-weight: 600;
}

.help-topic[open] > .help-topic__summary .help-topic__chevron {
    transform: rotate(90deg);
}

/* The topic's own content ------------------------------------------------- */

.help-topic-body {
    padding: 0.25rem 0 1.75rem 1.75rem;
    max-width: 68ch;
    line-height: 1.6;
}

.help-topic-body > :first-child {
    margin-top: 0;
}

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

.help-topic-body h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1.75rem 0 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--help-rule);
}

.help-topic-body ul,
.help-topic-body ol {
    margin: 0.85rem 0;
    padding-left: 1.4rem;
}

.help-topic-body ul {
    list-style: disc outside;
}

.help-topic-body ol {
    list-style: decimal outside;
}

.help-topic-body li {
    margin: 0.45rem 0;
    padding-left: 0.25rem;
}

.help-topic-body li > ul,
.help-topic-body li > ol {
    margin: 0.35rem 0;
}

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

.help-topic-body dt {
    font-weight: 600;
    margin-top: 0.85rem;
}

.help-topic-body dd {
    margin: 0.2rem 0 0 1.4rem;
}

.help-topic-body strong {
    font-weight: 600;
}

.help-topic-body a {
    text-decoration: underline;
}

.help-topic-body table {
    border-collapse: collapse;
    margin: 0.85rem 0;
}

.help-topic-body th,
.help-topic-body td {
    border: 1px solid var(--help-rule);
    padding: 0.4rem 0.6rem;
    text-align: left;
}

/* Search ------------------------------------------------------------------ */

.help-search {
    margin-bottom: 1rem;
}

.help-search__label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
    margin-bottom: 0.4rem;
}

.help-search__input {
    width: 100%;
    max-width: 28rem;
    padding: 0.5rem 0.75rem;
    font: inherit;
    color: inherit;
    background: none;
    border: 1px solid var(--help-rule-strong);
    border-radius: 0.375rem;
}

.help-search__input:focus {
    outline: 2px solid currentColor;
    outline-offset: -1px;
}

.help-search__result {
    font-size: 0.8rem;
    opacity: 0.7;
    margin: 0.4rem 0 0;
    min-height: 1.2em;
}

.help-empty {
    margin: 1.5rem 0;
    opacity: 0.75;
    max-width: 60ch;
}

/* Filtering hides whole topics and sections; `details` needs telling. */
.help-page [hidden] {
    display: none !important;
}

/* Controls ---------------------------------------------------------------- */

.help-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.help-controls__button {
    background: none;
    border: 1px solid var(--help-rule-strong);
    border-radius: 0.375rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: inherit;
}

.help-controls__button:hover {
    background: var(--help-wash);
}

/* A topic opened from a contents link, so it is obvious which one you landed on */
.help-topic:target > .help-topic__summary {
    box-shadow: inset 3px 0 0 currentColor;
}

@media print {
    .help-contents,
    .help-controls,
    .help-search,
    .help-topic__chevron {
        display: none;
    }

    .help-topic-body {
        padding-left: 0;
    }

    .help-section {
        break-inside: avoid;
    }
}
