/* Xong Help — xong.app/help/
   Three columns, the way a reference reads: topics on the left, the article on
   an island in the middle, the article's own outline on the right. Every
   colour, font and radius comes from /styles.css; this file only lays out.

   Without scripts every article is shown, one after another, and the topic
   list is a list of links into the page. help.js turns that into one article
   at a time, with search, an outline and previous/next links. */

.help {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 200px;
    gap: 32px;
    max-width: 1280px;
    margin-inline: auto;
    padding: 36px max(20px, env(safe-area-inset-right, 0px)) 96px max(20px, env(safe-area-inset-left, 0px));
    align-items: start;
}

/* ---- Topics --------------------------------------------------------------- */

.help-side {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 4px 6px 24px 2px;
    scrollbar-width: thin;
}

.help-search {
    position: relative;
    margin-bottom: 18px;
}

.help-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.help-search input {
    width: 100%;
    padding: 9px 40px 9px 36px;
    border: 0;
    border-radius: 11px;
    background: var(--island);
    box-shadow: 0 0 0 1px var(--line);
    color: var(--ink);
    font: 400 0.9375rem/1.3 var(--font);
}

.help-search input::placeholder { color: var(--muted); }
.help-search input:focus { outline: 2px solid var(--tint); outline-offset: 0; }
.help-search input::-webkit-search-cancel-button { display: none; }

.help-search kbd {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    pointer-events: none;
}

.help-search input:focus + kbd,
.help-search input:not(:placeholder-shown) + kbd { display: none; }

.help-nav { font-size: 0.9375rem; }

.help-nav details + details { margin-top: 6px; }

.help-nav summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    list-style: none;
}

.help-nav summary::-webkit-details-marker { display: none; }
.help-nav summary:hover { background: var(--sunk); }

.help-nav summary::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-right: 1.6px solid var(--muted);
    border-bottom: 1.6px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.help-nav details[open] > summary::before { transform: rotate(45deg) translate(-1px, -1px); }

.help-nav ul {
    list-style: none;
    margin: 2px 0 4px 11px;
    padding: 0 0 0 10px;
    border-left: 1px solid var(--line);
}

.help-nav li a {
    display: block;
    padding: 5px 10px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    line-height: 1.35;
}

.help-nav li a:hover { color: var(--ink); background: var(--sunk); }

.help-nav li a[aria-current="page"] {
    color: var(--ink);
    font-weight: 600;
    background: var(--island);
    box-shadow: 0 0 0 1px var(--line);
}

.help-nav .home-link {
    display: block;
    margin-bottom: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
}

.help-nav .home-link:hover { background: var(--sunk); }
.help-nav .home-link[aria-current="page"] { background: var(--island); box-shadow: 0 0 0 1px var(--line); }

/* Search results replace the topic list while there is a query. */
.help-results { list-style: none; margin: 0; padding: 0; }
.help-results li + li { margin-top: 2px; }

.help-results a {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none;
}

.help-results a:hover,
.help-results a.active { background: var(--island); box-shadow: 0 0 0 1px var(--line); }
.help-results b { display: block; font-size: 0.9375rem; }
.help-results .where { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.02em; }
.help-results .snip { display: block; margin-top: 2px; font-size: 0.8125rem; color: var(--muted); line-height: 1.4; }
.help-results mark { background: var(--tint-soft); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.help-empty { padding: 8px 10px; font-size: 0.875rem; color: var(--muted); }

/* ---- Article -------------------------------------------------------------- */

.help-main { min-width: 0; }

.doc {
    padding: clamp(24px, 4.5vw, 52px);
    border-radius: 24px;
    background: var(--island);
    box-shadow: 0 0 0 1px var(--line);
    scroll-margin-top: 84px;
}

.doc + .doc { margin-top: 24px; }
.js .doc { display: none; }
.js .doc.shown { display: block; }

.crumb {
    font: 600 0.75rem/1 var(--font);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--muted);
}

.doc h1 {
    margin-top: 12px;
    font-size: clamp(1.875rem, 4.2vw, 2.625rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.doc .lede {
    margin-top: 14px;
    font-size: 1.1875rem;
    line-height: 1.5;
    color: var(--muted);
}

.doc h2 {
    margin-top: 40px;
    font-size: 1.375rem;
    letter-spacing: -0.02em;
    scroll-margin-top: 90px;
}

.doc h3 {
    margin-top: 26px;
    font-size: 1.0625rem;
    scroll-margin-top: 90px;
}

.doc p,
.doc ul,
.doc ol,
.doc pre,
.doc .table-wrap,
.doc figure,
.doc .note { margin-top: 14px; }

.doc ul,
.doc ol { padding-left: 1.3em; }
.doc li + li { margin-top: 6px; }
.doc li::marker { color: var(--muted); }

.doc code {
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--sunk);
    font: 0.875em var(--font-mono);
    overflow-wrap: anywhere;
}

.doc pre {
    padding: 16px 18px;
    border-radius: 12px;
    background: var(--sunk);
    overflow-x: auto;
    font: 0.875rem/1.6 var(--font-mono);
}

.doc pre code { padding: 0; background: none; font: inherit; overflow-wrap: normal; }

/* A callout, like the tip boxes in other help centres. */
.note {
    padding: 14px 18px 14px 16px;
    border-radius: 12px;
    background: var(--sunk);
    border-left: 3px solid var(--tint);
    font-size: 0.9688rem;
}

.note b:first-child { color: var(--ink); }
.note.warn { border-left-color: #e0a100; }

.doc figure { margin-inline: 0; }
.doc figure .window img { width: 100%; }
.doc figcaption { margin-top: 10px; font-size: 0.875rem; color: var(--muted); }

.table-wrap { overflow-x: auto; }

.doc table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.doc th,
.doc td {
    padding: 10px 14px 10px 0;
    border-top: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.doc th { color: var(--muted); font-weight: 600; font-size: 0.8125rem; letter-spacing: 0.02em; }
/* Keys stay on one line; code and words in the first column wrap. */
.doc td:first-child { min-width: 7rem; }
.doc td:first-child:has(kbd) { white-space: nowrap; }

/* Steps: a numbered list where the numbers are the point. */
.steps { list-style: none; padding-left: 0 !important; counter-reset: step; }
.steps > li { position: relative; padding-left: 40px; counter-increment: step; }
.steps > li + li { margin-top: 14px; }

.steps > li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: -1px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--tint-soft);
    color: var(--tint);
    font: 700 0.8125rem/1 var(--font);
}

/* The home page: a card per area, like the front page of a manual. */
.areas {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 32px;
}

.area {
    padding: 20px 20px 18px;
    border-radius: 16px;
    background: var(--ground);
    box-shadow: 0 0 0 1px var(--line);
}

.area h2 { margin: 0; font-size: 1.0625rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.area h2 svg { flex: none; color: var(--tint); }
.area p { margin-top: 6px; font-size: 0.9375rem; color: var(--muted); }
.area ul { list-style: none; margin-top: 12px; padding: 0; font-size: 0.9375rem; }
.area li + li { margin-top: 4px; }
.area a { text-decoration: none; }
.area a:hover { text-decoration: underline; }

/* Previous and next, at the foot of each article. */
.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 44px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.pager a {
    display: block;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 0 0 1px var(--line);
    color: var(--ink);
    text-decoration: none;
}

.pager a:hover { background: var(--sunk); }
.pager span { display: block; font-size: 0.8125rem; color: var(--muted); }
.pager b { font-weight: 600; }
.pager .next { grid-column: 2; text-align: right; }

.still {
    margin-top: 20px;
    font-size: 0.9375rem;
    color: var(--muted);
}

/* ---- Outline -------------------------------------------------------------- */

.help-toc {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding-top: 6px;
    font-size: 0.875rem;
}

.help-toc p {
    margin-bottom: 10px;
    font: 600 0.75rem/1 var(--font);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--muted);
}

.help-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }

.help-toc a {
    display: block;
    margin-left: -1px;
    padding: 4px 0 4px 12px;
    border-left: 2px solid transparent;
    color: var(--muted);
    text-decoration: none;
    line-height: 1.35;
}

.help-toc a:hover { color: var(--ink); }
.help-toc a.on { color: var(--ink); border-left-color: var(--tint); }
.help-toc .sub a { padding-left: 24px; font-size: 0.8125rem; }

/* The topic button, at narrow widths. */
.help-topics-btn { display: none; }

/* ---- Narrow --------------------------------------------------------------- */

@media (max-width: 1100px) {
    .help { grid-template-columns: 230px minmax(0, 1fr); }
    .help-toc { display: none; }
}

@media (max-width: 760px) {
    .help { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 20px; }

    /* Without scripts the topics sit above the articles, folded. */
    .help-side { position: static; max-height: none; overflow: visible; padding: 0; }

    .js .help-topics-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 9px 14px;
        border: 0;
        border-radius: 999px;
        background: var(--island);
        box-shadow: 0 0 0 1px var(--line);
        color: var(--ink);
        font: 500 0.9375rem/1.2 var(--font);
        cursor: pointer;
    }

    .js .help-side-panel { display: none; margin-top: 12px; padding: 14px; border-radius: var(--radius); background: var(--island); box-shadow: 0 0 0 1px var(--line); }
    .js .help-side.open .help-side-panel { display: block; }
    .js .help-side.open .help-nav li a[aria-current="page"] { background: var(--sunk); box-shadow: none; }
    .help-search input { background: var(--ground); }
    .areas { grid-template-columns: minmax(0, 1fr); }
    .pager { grid-template-columns: minmax(0, 1fr); }
    .pager .next { grid-column: 1; }
    .doc { border-radius: 18px; }
    .doc td:first-child:has(kbd) { white-space: normal; }
}
