/**--- Core ---*/
.category-tree {
    background: var(--color-surface-container-low);
    border: 0.09375rem solid var(--color-outline);
}

/* Overrides main.min.css - h1-h6 color, font-family and font-weight */
.category-tree__title {
    background: var(--color-surface);
    color: var(--color-on-surface);
    font-weight: 600;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.875rem;
    line-height: 1;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.category-tree__link {
    border-bottom: 0.0625rem solid var(--color-outline-variant);
    color: var(--color-on-surface);
    font-family: Archivo, system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.3;
    /* Overrides main.min.css - a font-weight */
    font-weight: 400;
    text-decoration: none;
}

.category-tree__link.is-on-path {
    font-weight: 600;
}

.category-tree__link.is-leaf {
    color: var(--color-on-surface-variant);
}

/* Overrides main.min.css - a:hover */
.category-tree__link:hover,
.category-tree__link:focus {
    color: var(--color-on-surface);
    text-decoration: none;
}

/* Underlines only the name: a decoration on the link would propagate to the mark too, and can't be cleared there. */
.category-tree__link:hover .category-tree__name,
.category-tree__link:focus .category-tree__name {
    text-decoration: underline;
}

/* Overrides main.min.css - a:hover */
.category-tree__link.is-leaf:hover,
.category-tree__link.is-leaf:focus {
    color: var(--color-on-surface-variant);
}

.category-tree__link[aria-current="page"] {
    background: var(--color-inverse-surface);
    color: var(--color-inverse-on-surface);
}

/* Overrides main.min.css - a:hover */
.category-tree__link[aria-current="page"]:hover,
.category-tree__link[aria-current="page"]:focus {
    color: var(--color-inverse-on-surface);
}

/* Overrides main.min.css - :focus{outline:0}. Inset so it stays inside the row. */
.category-tree__link:focus-visible {
    outline: 0.125rem solid var(--color-focus);
    outline-offset: -0.125rem;
}

/* A ring on the current row's dark fill takes that fill's on-color. */
.category-tree__link[aria-current="page"]:focus-visible {
    outline-color: var(--color-inverse-on-surface);
}

.category-tree__mark {
    font-weight: 500;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Long names at deep levels wrap rather than overflow the narrow sidebar. */
.category-tree__name {
    overflow-wrap: anywhere;
}

/**--- Mobile ---*/
.category-tree {
    display: none;
}

/**--- Desktop ---*/
@media (min-width: 768px) {
    .category-tree {
        display: block;
    }

    .category-tree__title {
        margin: 0;
        padding: 0.75rem 1rem;
    }

    .category-tree__list {
        margin: 0;
        padding: 0;
    }

    /* Indented by padding, not by nesting the lists, so every row and its border stays full width at any depth. */
    .category-tree__link {
        display: flex;
        gap: 0.5rem;
        padding: 0.5625rem 0.875rem 0.5625rem calc(0.875rem + var(--tree-depth, 0) * 1rem);
    }

    .category-tree__mark {
        flex: none;
        width: 0.625rem;
    }

    .category-tree__name {
        min-width: 0;
    }
}
