/*
 * FA-Soft Learn: the site's own styles, on top of fa-soft.css (never change that file here).
 * Colors only through the FA-Soft tokens (var(--...)).
 */

/* ---- Left menu: the apps, and the current app's toc as a tree (<details> groups, no script) ---- */

/* The menu's panel, its width (drag the right edge) and Hide menu / Show menu come from fa-soft.css (FA-Soft UI 1.1).
   The tree fills the panel and scrolls within it. */
.learn-menu {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.125rem;
}

.learn-menu,
.learn-menu-level {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.learn-menu-app-link {
    display: block;
    font-weight: 600;
}

.learn-menu-level { margin-top: 0.125rem; }
.learn-menu-level.level-2 { padding-left: 0.75rem; }
.learn-menu-level.level-3,
.learn-menu-level.level-4 { padding-left: 0.75rem; }

.learn-menu-level a,
.learn-menu-group,
.learn-menu-missing {
    display: block;
    padding: 0.35rem 0.75rem;
    font-size: 0.925rem;
    line-height: 1.35;
}

.learn-menu-group { color: var(--muted); font-weight: 600; }
.learn-menu-missing { color: var(--muted); font-style: italic; }

.learn-menu details > summary {
    display: flex;
    align-items: center;
    list-style: none;
    cursor: pointer;
    border-radius: var(--radius);
}
.learn-menu details > summary::-webkit-details-marker { display: none; }
.learn-menu details > summary::before {
    content: "";
    flex: none;
    width: 0.4rem;
    height: 0.4rem;
    margin-left: 0.4rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.15s;
}
.learn-menu details[open] > summary::before { transform: rotate(45deg); }
.learn-menu details > summary > a,
.learn-menu details > summary > span { flex: 1; min-width: 0; }
.learn-menu details > summary:hover { background: var(--bg); }
:root[data-theme="standard"] .learn-menu details > summary:hover { background: var(--info-bg); }

.learn-menu-lang {
    margin-left: 0.35rem;
    padding: 0 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid currentColor;
    border-radius: 4px;
    opacity: 0.8;
}

/* ---- Top bar: the search box in the middle (Learn only) ---- */

/* Three columns, so the search box is in the middle whatever the widths of the app name and the switches. */
.topbar {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) minmax(10rem, 32rem) minmax(max-content, 1fr);
    align-items: center;
}
.topbar-end { justify-self: end; }

.topbar-search { position: relative; display: flex; align-items: center; min-width: 0; }
.topbar-search input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 2.4rem 0.4rem 0.8rem;
    font: inherit;
    font-size: 0.925rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--control-radius);
}
.topbar-search input::placeholder { color: var(--muted); opacity: 1; }
.topbar-search input:hover { border-color: var(--muted); }
.topbar-search input:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
/* The button: a magnifying glass drawn with borders (no image, no inline style). */
.topbar-search button {
    position: absolute;
    right: 0.2rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: var(--control-radius);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.topbar-search button:hover { color: var(--accent); background: var(--surface); }
.topbar-search button::before {
    content: "";
    position: absolute;
    left: 0.55rem;
    top: 0.5rem;
    width: 0.6rem;
    height: 0.6rem;
    border: 2px solid currentColor;
    border-radius: 50%;
}
.topbar-search button::after {
    content: "";
    position: absolute;
    left: 1.2rem;
    top: 1.15rem;
    width: 0.45rem;
    height: 2px;
    background: currentColor;
    transform: rotate(45deg);
    transform-origin: left center;
}

/* ---- Search results ---- */

.learn-search .lead { color: var(--muted); max-width: 60ch; }
.search-summary { color: var(--muted); margin: 0 0 0.75rem; }

.search-filter ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; padding: 0; }
.search-filter a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.search-filter a:hover { border-color: var(--accent); }
.search-filter a[aria-current="true"] { border-color: var(--accent); background: var(--info-bg); }
.search-count { color: var(--muted); font-size: 0.8rem; }

.search-results { list-style: none; margin: 0; padding: 0; max-width: 110ch; display: flex; flex-direction: column; gap: 0.75rem; }
.search-results li {
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.search-result-title { font-weight: 600; font-size: 1.05rem; }
.search-result-trail { margin: 0.15rem 0 0.35rem; font-size: 0.85rem; color: var(--muted); }
.search-result-snippet { margin: 0; line-height: 1.5; overflow-wrap: break-word; }
.search-results mark { padding: 0 0.1em; color: inherit; background: var(--warn-bg); border-radius: 3px; }

/* ---- Home: the apps ---- */

.learn-home .lead { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }

.app-cards {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
}
.app-cards .card h2 { margin: 0 0 0.5rem; }
.app-cards .card p { margin: 0.25rem 0 0; }

/* ---- Breadcrumbs, notices, previous and next ---- */

.breadcrumbs ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0 0 1rem;
    padding: 0;
    font-size: 0.875rem;
    color: var(--muted);
}
.breadcrumbs li + li::before { content: "›"; margin-right: 0.25rem; }
.breadcrumbs [aria-current="page"] { color: var(--text); }

.fallback-notice { max-width: 110ch; }

.pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    max-width: 110ch;
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.pager a {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
    max-width: 48%;
}
.pager a:hover { border-color: var(--accent); }
.pager-next { margin-left: auto; text-align: right; }
.pager-label { font-size: 0.8rem; color: var(--muted); }

/* ---- Pages (rendered Markdown) ---- */

.prose { max-width: 110ch; line-height: 1.6; overflow-wrap: break-word; }
/* Every heading has the color of the page title: navy in Standard (fa-soft.css colors h1 only), the text color in the
   other themes. */
:root[data-theme="standard"] .content :is(h2, h3, h4, h5, h6) { color: var(--brand-navy); }
.prose h1 { margin-bottom: 1.25rem; }
.prose h2 { font-size: 1.3rem; margin-top: 2rem; }
.prose h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.prose h4 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
.prose p, .prose ul, .prose ol, .prose table, .prose pre, .prose blockquote, .prose figure { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: 0.25rem 0; }
.prose li > ul, .prose li > ol { margin: 0.25rem 0 0; }
.prose li.task-list-item { list-style: none; margin-left: -1.25rem; }
.prose li.task-list-item input { margin-right: 0.4rem; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* The outline: the content under a heading (and the headings below it) is indented one step per level, when the body
   is wide enough (the renderer wraps it in .section-body). Lists keep their normal indent. On a narrow body the
   text stays flush, so it keeps its width. */
@container body (min-width: 48rem) {
    .prose .section-body { padding-left: 1.75rem; }
}

/* A light border (the same as code blocks), so a screenshot's edges stay visible when its background is the page's. */
.prose img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.prose code {
    font-size: 0.9em;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
}
.prose pre {
    padding: 0.85rem 1rem;
    overflow-x: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    line-height: 1.45;
}
.prose pre code { padding: 0; border: none; background: none; font-size: 0.875rem; }

.prose table { width: auto; max-width: 100%; display: block; overflow-x: auto; }
.prose th { background: var(--bg); font-weight: 600; }

.prose blockquote {
    padding: 0.25rem 1rem;
    border-left: 4px solid var(--border);
    color: var(--muted);
}

/* Alert blocks: > [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION]. */
.prose .markdown-alert {
    margin: 0 0 1rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--accent);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: var(--info-bg);
}
.prose .markdown-alert > :last-child { margin-bottom: 0; }
.prose .markdown-alert-title { font-weight: 600; margin-bottom: 0.25rem; }
.prose .markdown-alert-title svg { display: none; }
.prose .markdown-alert-tip { border-color: var(--ok); background: var(--ok-bg); }
.prose .markdown-alert-warning { border-color: var(--warn); background: var(--warn-bg); }
.prose .markdown-alert-caution { border-color: var(--danger); background: var(--danger-bg); }

/* Links to pages that do not exist, and images that are missing. */
.prose .broken-link { color: var(--muted); text-decoration: line-through dotted; cursor: not-allowed; }
.prose .broken-image { min-width: 8rem; min-height: 3rem; }

/* ---- The page index: the page's headings (##, ### and ####) as a tree ---- */

/* The body is the container: whether the index fits depends on the body's width, which changes with the window and with
   the left menu (its width, Hide menu). Without room the index is not shown, so the text always keeps a comfortable width. */
.content { container: body / inline-size; }

.page-index { display: none; }

@container body (min-width: 66rem) {
    /* At least 48rem for the text, then the index (15rem) on the right. */
    .page-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 15rem;
        gap: 2.5rem;
        align-items: start;
    }
    .page-index {
        display: block;
        position: sticky;
        top: 5rem;
        max-height: calc(100vh - 6rem);
        overflow-y: auto;
        padding: 0.25rem 0 0.25rem 0.75rem;
        border-left: 1px solid var(--border);
        font-size: 0.875rem;
    }
    /* The index replaces the table that <!-- toc --> puts at the top of the page. */
    .page-toc { display: none; }
}

.page-index-title,
.page-toc-title { margin: 0 0 0.35rem; font-weight: 600; }
.page-index-title { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }

.page-index-level {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.page-index-level .page-index-level { padding-left: 0.9rem; }
.page-index-level a {
    display: block;
    padding: 0.2rem 0.4rem;
    line-height: 1.35;
    text-decoration: none;
    border-radius: 4px;
}
.page-index-level a:hover { text-decoration: underline; }

/* A heading with headings below it folds open and shut (<details>, no script), with the left menu's chevron. */
.page-index-level details > summary {
    display: flex;
    align-items: center;
    list-style: none;
    cursor: pointer;
    margin-left: -0.9rem;
}
.page-index-level details > summary::-webkit-details-marker { display: none; }
.page-index-level details > summary::before {
    content: "";
    flex: none;
    width: 0.35rem;
    height: 0.35rem;
    margin: 0 0.2rem 0 0.15rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.15s;
}
.page-index-level details[open] > summary::before { transform: rotate(45deg); }
.page-index-level details > summary > a { flex: 1; min-width: 0; }
.page-index-level.level-1 { padding-left: 0.9rem; } /* room for the chevrons of the first level */

/* The table of the page's headings at the top (<!-- toc -->), when the index is not shown. */
.page-toc {
    margin: 0 0 1.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    max-width: 40rem;
}

@media (max-width: 720px) {
    .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.5rem; }
    .sidenav-body { flex-direction: column; } /* the tree stays a column */
    .menu-toggle { flex-basis: auto; }
    .pager { flex-direction: column; }
    .pager a { max-width: none; }
}
