@import url("popcorn-shared.css");

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.kernel-map-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.kernel-main {
    flex: 1;
}

.kernel-hero {
    padding: 1.25rem 1.5rem 2.5rem;
    max-width: 1100px;
    margin: 0 auto;
}

.kernel-hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.kernel-hero .lead {
    font-size: 1rem;
    color: var(--text-muted);
    max-width: 46rem;
    line-height: 1.65;
}

.kernel-hero code {
    font-size: 0.88em;
    padding: 0.1em 0.35em;
    border-radius: 6px;
    background: rgba(0, 255, 157, 0.1);
    border: 1px solid rgba(0, 255, 157, 0.2);
    color: var(--accent);
}

.spec-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1.25rem;
}

.spec-chip {
    font-family: "Fira Code", monospace;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 0.32rem 0.6rem;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.viz-section {
    padding: 0 1.25rem 3rem;
    max-width: 1240px;
    margin: 0 auto;
}

.viz-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 1.25rem;
    align-items: stretch;
}

@media (max-width: 960px) {
    .viz-grid {
        grid-template-columns: 1fr;
    }
}

.glass-panel {
    border-radius: 16px;
    background: rgba(22, 22, 24, 0.75);
    backdrop-filter: saturate(180%) blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    overflow: hidden;
    min-height: 320px;
}

.panel-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.35);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 0.02em;
}

.panel-sub {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tree-root {
    padding: 0.75rem 0.5rem 1.25rem 1rem;
    max-height: min(70vh, 640px, calc(100dvh - var(--site-shell-safe) - 14rem));
    overflow: auto;
}

.tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-children {
    list-style: none;
    margin: 0.15rem 0 0.35rem 0.65rem;
    padding: 0 0 0 0.65rem;
    border-left: 1px solid rgba(0, 255, 157, 0.2);
}

.tree-node {
    margin: 0.2rem 0;
}

.tree-node__row {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.55rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(230, 255, 245, 0.92);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.tree-node__row:hover {
    background: rgba(0, 255, 157, 0.08);
    border-color: rgba(0, 255, 157, 0.2);
}

.tree-node.is-selected > .tree-node__row {
    border-color: rgba(0, 255, 157, 0.45);
    background: rgba(0, 255, 157, 0.1);
}

.chevron {
    display: inline-block;
    flex-shrink: 0;
    width: 1rem;
    color: var(--accent-dim);
    transform: rotate(0deg);
    transition: transform 0.25s ease;
    font-size: 0.65rem;
    margin-top: 0.2rem;
}

.tree-node.is-open > .tree-node__row .chevron {
    transform: rotate(90deg);
    color: var(--accent);
}

.tree-node__label {
    font-size: 0.8125rem;
    line-height: 1.45;
}

.tree-children {
    display: none;
}

.tree-node.is-open > .tree-children {
    display: block;
    animation: branch-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes branch-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tree-node.is-open > .tree-children {
        animation: none;
    }

    .chevron {
        transition: none;
    }
}

.detail-panel {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.detail-panel__head {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.35);
}

.detail-panel__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.detail-panel__body {
    padding: 1.1rem 1.25rem 1.35rem;
    flex: 1;
    overflow: auto;
    max-height: min(70vh, 640px, calc(100dvh - var(--site-shell-safe) - 14rem));
}

.detail-panel__pre {
    font-size: 0.75rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: rgba(210, 245, 225, 0.88);
    margin: 0;
}

.detail-panel__p {
    font-size: 0.9rem;
    color: rgba(224, 224, 224, 0.88);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.detail-panel__p:last-child {
    margin-bottom: 0;
}

.diagrams-section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
}

.diagrams-section h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 1rem;
}

.diagram-card {
    margin-bottom: 1.5rem;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.45);
}

.diagram-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mermaid-wrap {
    padding: 0.75rem 0.5rem 1rem;
    overflow-x: auto;
}

.mermaid {
    display: flex;
    justify-content: center;
}

.doc-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.25rem 4rem;
}

.doc-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    margin: 2.5rem 0 1rem;
}

details.doc-block {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(18, 18, 20, 0.65);
    margin-bottom: 0.65rem;
    overflow: hidden;
}

details.doc-block summary {
    cursor: pointer;
    list-style: none;
    padding: 0.9rem 1.1rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    transition: background 0.2s ease;
}

details.doc-block summary::-webkit-details-marker {
    display: none;
}

details.doc-block summary::after {
    content: "+";
    font-weight: 400;
    color: var(--accent);
    font-size: 1.1rem;
}

details.doc-block[open] summary::after {
    content: "−";
}

details.doc-block summary:hover {
    background: rgba(0, 255, 157, 0.06);
}

.doc-block__body {
    padding: 0 1.1rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
    color: rgba(224, 224, 224, 0.88);
    line-height: 1.65;
}

.doc-block__body pre {
    margin: 0.75rem 0 0;
    padding: 1rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(0, 255, 157, 0.12);
    font-family: "Fira Code", monospace;
    font-size: 0.72rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

.doc-block__body p {
    margin: 0.65rem 0 0;
}

.reading-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    font-size: 0.8rem;
}

.reading-table th,
.reading-table td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.6rem;
    text-align: left;
    vertical-align: top;
}

.reading-table th {
    background: rgba(0, 255, 157, 0.08);
    color: var(--accent);
    font-weight: 600;
}

.reading-table td {
    font-family: "Fira Code", monospace;
    font-size: 0.72rem;
    color: rgba(220, 245, 230, 0.9);
}
