/* ==========================================================================
   File Tree — interactive tree view for ASCII directory structures
   ========================================================================== */

/* Details/Summary styling (was missing from theme) */
details {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 1.5rem 0;
    overflow: hidden;
}

details summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    transition: background 0.2s ease;
}

details summary:hover {
    background: rgba(12, 213, 99, 0.05);
}

details summary::before {
    content: '▶';
    color: var(--green);
    font-size: 0.7em;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

details[open] summary::before {
    transform: rotate(90deg);
}

details summary::-webkit-details-marker {
    display: none;
}

/* Container */
.ft-wrapper {
    padding: 1rem;
    padding-top: 0.5rem;
}

.ft-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--green);
}

.ft-header::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 14px;
    background: var(--green);
    clip-path: polygon(0 0, 60% 0, 60% 25%, 100% 25%, 100% 100%, 0 100%);
    flex-shrink: 0;
}

/* Tree list */
.ft-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
}

.ft-tree ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1.25rem;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    max-height: 2000px;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.ft-tree li {
    position: relative;
}

/* Folder / File items */
.ft-item {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 1px 0;
    border-radius: 3px;
}

.ft-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Icons — CSS-only */
.ft-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    position: relative;
    top: 2px;
}

/* Folder icon */
.ft-folder > .ft-item > .ft-icon::before {
    content: '';
    display: block;
    width: 14px;
    height: 12px;
    background: var(--green);
    clip-path: polygon(0 0, 40% 0, 50% 20%, 100% 20%, 100% 100%, 0 100%);
    opacity: 0.8;
}

/* File icon */
.ft-file > .ft-item > .ft-icon::before {
    content: '';
    display: block;
    width: 12px;
    height: 14px;
    background: rgba(255, 255, 255, 0.25);
    clip-path: polygon(0 0, 65% 0, 100% 30%, 100% 100%, 0 100%);
}

/* Toggle chevron for folders */
.ft-toggle {
    flex-shrink: 0;
    width: 12px;
    font-size: 0.65em;
    color: var(--green);
    cursor: pointer;
    transition: transform 0.2s ease;
    user-select: none;
}

.ft-folder > .ft-item {
    cursor: pointer;
}

.ft-folder.ft-open > .ft-item > .ft-toggle {
    transform: rotate(90deg);
}

/* Collapsed children */
.ft-folder:not(.ft-open) > ul {
    max-height: 0;
    opacity: 0;
}

/* Names */
.ft-name {
    color: var(--text-primary);
    white-space: nowrap;
}

.ft-folder > .ft-item > .ft-name {
    color: var(--green);
    font-weight: 500;
}

/* Descriptions */
.ft-desc {
    color: var(--text-secondary);
    font-size: 0.8em;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ft-desc--alert {
    color: #ff4444;
    font-weight: 600;
    opacity: 1;
}

/* Category/section headers (no icon, just a label) */
.ft-category > .ft-item > .ft-name {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85em;
}

.ft-category > .ft-item > .ft-icon::before {
    display: none;
}

/* Responsive */
@media (max-width: 640px) {
    .ft-desc {
        display: none;
    }

    .ft-tree {
        font-size: 0.8rem;
    }

    .ft-wrapper {
        padding: 0.75rem;
    }
}
