/* Explorer tree in the rail: corpus switch, the Go to finder and folders that open lazily. */

.tree {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    min-width: 0;
}

.tree__corpora {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-1);
}

.tree__corpus {
    padding: var(--s-1) var(--s-2);
    font: 500 var(--t-xs) / var(--lh-xs) var(--font-mono);
    letter-spacing: .08em;
    color: var(--paper-lo);
    text-decoration: none;
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-1);
}

.tree__corpus:hover {
    color: var(--paper-hi);
    background-color: var(--ink-3);
}

.tree__corpus[aria-current="page"] {
    color: var(--paper-hi);
    background-color: var(--ink-3);
    border-color: var(--accent);
}

.tree__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Each nested level is indented and carries the hairline guide. */
.tree__list .tree__list {
    margin-left: var(--s-2);
    padding-left: var(--tree-indent);
    border-left: 1px solid var(--rule);
}

.tree__node {
    min-width: 0;
}

.tree__node > details {
    min-width: 0;
}

.tree__row {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 2rem;
    padding: 0 var(--s-2);
    font: 400 var(--t-sm) / var(--lh-sm) var(--font-mono);
    color: var(--paper);
    text-decoration: none;
    list-style: none;
    border-radius: var(--r-1);
    cursor: pointer;
}

.tree__row::-webkit-details-marker {
    display: none;
}

.tree__row:hover {
    color: var(--paper-hi);
    background-color: var(--ink-3);
}

.tree__row[aria-current="page"] {
    color: var(--paper-hi);
    background-color: var(--accent-wash);
    box-shadow: inset var(--bar) 0 0 var(--accent);
}

.tree__chevron {
    flex: none;
    width: var(--s-3);
    color: var(--paper-lo);
}

.tree__chevron::before {
    content: "▸";
}

details[open] > .tree__row > .tree__chevron::before {
    content: "▾";
}

.tree__glyph {
    flex: none;
    width: var(--s-3);
    color: var(--paper-lo);
}

.tree__glyph::before {
    content: "·";
}

/* "Open folder" follows each folder. It stays in the Tab order but is visually hidden until it has focus,
   so pointer users see only the folder rows. */
.tree__open:not(:focus-visible) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.tree__open:focus-visible {
    display: block;
    margin-inline-start: var(--s-4);
    padding: 0 var(--s-2);
    font: 400 var(--t-xs) / var(--lh-xs) var(--font-mono);
    color: var(--paper-lo);
}

/* Names truncate with an ellipsis so a long file name never widens the rail. */
.tree__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: inherit;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree__count {
    flex: none;
    font-size: var(--t-xs);
    color: var(--paper-lo);
}

.tree__more,
.tree__state {
    display: flex;
    align-items: center;
    min-height: 2rem;
    padding: 0 var(--s-2);
    font: 400 var(--t-xs) / var(--lh-xs) var(--font-mono);
    color: var(--paper-lo);
    text-decoration: none;
}

.tree__more:hover {
    color: var(--paper-hi);
    text-decoration: underline;
}

.tree__state {
    color: var(--paper-lo);
}

/* Go to finder: a text box and a button with the T shortcut hint. */
.goto {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-width: 0;
}

.goto__input {
    flex: 1 1 auto;
    min-width: 0;
}

.goto__submit {
    flex: none;
    white-space: nowrap;
}

@media (max-width: 899.98px), (pointer: coarse) {
    .tree__row,
    .tree__more,
    .tree__corpus {
        min-height: var(--tap);
    }

    .tree__corpus {
        display: inline-flex;
        align-items: center;
        padding-inline: var(--s-3);
    }
}
