/* ============================================
   GRAFIT DOCUMENTATION — Dark Theme Styles
   ============================================ */

:root {
    --g-bg: #0a0a0f;
    --g-surface: #12121a;
    --g-surface-2: #1a1a26;
    --g-border: rgba(255,255,255,0.06);
    --g-text: #e8e8f0;
    --g-text-muted: #8888a0;
    --g-accent: #00cec9;
    --g-accent-glow: rgba(0,206,201,0.3);

    /* Category colors */
    --cat-input: #e74c3c;
    --cat-math: #636e72;
    --cat-color: #e84393;
    --cat-string: #8e44ad;
    --cat-json: #e67e22;
    --cat-structure: #f1c40f;
    --cat-filter: #00b894;
    --cat-generator: #00cec9;
    --cat-render: #0984e3;
    --cat-particles: #fd79a8;
    --cat-tcp: #d63031;
    --cat-osc: #d63031;
    --cat-serial: #d63031;
    --cat-midi: #d63031;
    --cat-dmx: #d63031;
    --cat-utility: #636e72;
    --cat-uiElement: #74b9ff;
    --cat-macro: #a29bfe;

    /* Port colors */
    --port-float: #27ae60;
    --port-int: #00cec9;
    --port-string: #8e44ad;
    --port-bool: #e74c3c;
    --port-color: #e84393;
    --port-structure: #f1c40f;
    --port-image: #00cec9;
    --port-json: #e67e22;
    --port-any: #95a5a6;
    --port-double: #2ecc71;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    background: var(--g-bg);
    color: var(--g-text);
    margin: 0;
    line-height: 1.6;
}

a { color: var(--g-accent); text-decoration: none; }
a:hover { color: #5eead4; }

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    background: rgba(10,10,15,0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--g-border);
    padding: 0.6rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--g-accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.nav-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: brightness(1.4) drop-shadow(0 0 4px rgba(0,206,201,0.3));
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--g-text-muted);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.nav-links a:hover { color: var(--g-text); background: rgba(255,255,255,0.05); }
.nav-links a.active { color: var(--g-accent); background: rgba(0,206,201,0.1); }

/* ============================================
   HERO SECTION (Portal Animation)
   ============================================ */
.hero {
    position: relative;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #0d0d1a 0%, #0a0a0f 70%);
}

.hero-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 800px;
    padding: 1rem 2rem;
}

.hero-logo {
    width: clamp(200px, 30vw, 360px);
    height: auto;
    object-fit: contain;
    margin-bottom: -6rem;
    filter: brightness(1.6) drop-shadow(0 0 20px rgba(0,206,201,0.5)) drop-shadow(0 0 50px rgba(162,155,254,0.2));
    animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #e8e8f0 0%, #00cec9 50%, #a29bfe 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 6s ease infinite;
    margin: 0 0 0.25rem;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero p {
    font-size: 1.25rem;
    color: var(--g-text-muted);
    margin: 0 auto 0.75rem;
    max-width: 600px;
}

.hero-badges {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hero-badge {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: var(--g-text-muted);
}

/* ============================================
   SECTION LAYOUT
   ============================================ */
.section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.section-subtitle {
    color: var(--g-text-muted);
    margin: 0 0 2.5rem;
    font-size: 1.05rem;
}

/* ============================================
   DOCS LAYOUT — Sidebar + Content Panel
   ============================================ */
.catalog-page {
    overflow: hidden;
}

.docs-layout {
    display: flex;
    height: calc(100vh - 45px); /* below navbar */
    overflow: hidden;
}

/* ── Sidebar ── */
.docs-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--g-surface);
    border-right: 1px solid var(--g-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--g-border);
    flex-shrink: 0;
}

.sidebar-search {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-icon {
    position: absolute;
    left: 0.6rem;
    font-size: 0.8rem;
    color: var(--g-text-muted);
    pointer-events: none;
}

.sidebar-search input {
    width: 100%;
    padding: 0.45rem 0.6rem 0.45rem 2rem;
    border-radius: 0.4rem;
    border: 1px solid var(--g-border);
    background: var(--g-bg);
    color: var(--g-text);
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-search input:focus {
    border-color: var(--g-accent);
}

.sidebar-search input::placeholder {
    color: var(--g-text-muted);
}

.sidebar-count {
    display: block;
    font-size: 0.7rem;
    color: var(--g-text-muted);
    margin-top: 0.4rem;
    padding-left: 0.1rem;
}

/* ── Tree View ── */
.sidebar-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.4rem 0;
}

.sidebar-tree::-webkit-scrollbar {
    width: 4px;
}

.sidebar-tree::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-tree::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
}

.sidebar-tree::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.15);
}

.tree-category {
    margin-bottom: 0.15rem;
}

.tree-cat-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.4rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--g-text);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s;
    font-family: inherit;
}

.tree-cat-btn:hover {
    background: rgba(255,255,255,0.03);
}

.tree-chevron {
    font-size: 0.6rem;
    color: var(--g-text-muted);
    width: 0.8rem;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.tree-cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tree-cat-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-cat-count {
    font-size: 0.65rem;
    color: var(--g-text-muted);
    font-weight: 400;
    flex-shrink: 0;
}

.tree-children {
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.tree-children.collapsed {
    display: none;
}

.tree-node {
    display: block;
    padding: 0.3rem 0.75rem 0.3rem 2.2rem;
    font-size: 0.78rem;
    color: var(--g-text-muted);
    text-decoration: none;
    border-radius: 0.25rem;
    margin: 0 0.35rem;
    transition: all 0.1s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-node:hover {
    background: rgba(255,255,255,0.04);
    color: var(--g-text);
}

.tree-node.active {
    background: rgba(0,206,201,0.12);
    color: var(--g-accent);
    font-weight: 500;
}

/* ── Content Panel ── */
.docs-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--g-bg);
}

.docs-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 2rem;
    opacity: 0.6;
}

.welcome-icon {
    font-size: 3rem;
    color: var(--g-accent);
    margin-bottom: 1rem;
}

.welcome-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: brightness(1.4) drop-shadow(0 0 20px rgba(0,206,201,0.25));
    opacity: 0.7;
}

.docs-welcome h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.docs-welcome p {
    color: var(--g-text-muted);
    margin: 0 0 0.25rem;
}

/* Detail within sidebar layout */
.docs-content .detail-hero {
    padding: 2.5rem 2rem;
}

.docs-content .detail-hero-inner {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.docs-content .detail-section {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

/* Prev / Next nav */
.detail-nav {
    display: flex;
    justify-content: space-between;
    margin: 2.5rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--g-border);
}

.detail-nav-link {
    font-size: 0.85rem;
    color: var(--g-text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: color 0.15s;
}

.detail-nav-link:hover {
    color: var(--g-accent);
}

/* ── Mobile: sidebar becomes top drawer ── */
@media (max-width: 768px) {
    .docs-layout {
        flex-direction: column;
        height: auto;
    }
    .docs-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--g-border);
    }
    .docs-content {
        min-height: 60vh;
    }
    .docs-content .detail-section {
        padding: 1rem;
    }
}

/* ============================================
   NODE CARD (Catalog Grid)
   ============================================ */
.node-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.node-card {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.node-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.12);
}

.node-card-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}

.node-card-header .cat-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    background: rgba(0,0,0,0.3);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.node-card-body {
    padding: 1rem;
    display: flex;
    gap: 1rem;
}

.node-card-ports {
    display: flex;
    gap: 1.5rem;
    flex: 1;
}

.port-column {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.port-column-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--g-text-muted);
    margin-bottom: 0.2rem;
}

.port-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--g-text-muted);
}

.port-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.node-card-desc {
    padding: 0 1rem 1rem;
    font-size: 0.8rem;
    color: var(--g-text-muted);
    line-height: 1.5;
}

/* ============================================
   NODE VISUAL PREVIEW (Frosted Glass Style)
   ============================================ */
.node-preview {
    background: rgba(18,18,26,0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0.75rem;
    overflow: hidden;
    max-width: 380px;
    margin: 0 auto 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
}

.node-preview-header {
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.node-preview-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.node-preview-body {
    padding: 0.5rem 0;
}

.node-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0.75rem;
    min-height: 1.6rem;
}

.node-preview-port {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
}

.node-preview-port.input { color: var(--g-text-muted); }
.node-preview-port.output { color: var(--g-text-muted); }

.preview-port-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid;
    flex-shrink: 0;
}

.preview-port-dot.filled {
    border: none;
}

/* ============================================
   NODE DETAIL PAGE
   ============================================ */
.detail-hero {
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.detail-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center top, var(--detail-color, var(--g-accent)) -80%, transparent 60%);
    opacity: 0.12;
    pointer-events: none;
}

.detail-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 0.5rem;
}

.detail-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.detail-meta-item {
    font-size: 0.85rem;
    color: var(--g-text-muted);
}

.detail-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.detail-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--g-border);
}

.port-table {
    width: 100%;
    border-collapse: collapse;
}

.port-table th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--g-text-muted);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--g-border);
}

.port-table td {
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: top;
}

.port-table tr:hover td { background: rgba(255,255,255,0.02); }

.port-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255,255,255,0.05);
}

.port-type-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 3rem 2rem;
    border-top: 1px solid var(--g-border);
    color: var(--g-text-muted);
    font-size: 0.8rem;
}

.footer-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    margin-bottom: 0.75rem;
    filter: brightness(1.2);
    opacity: 0.5;
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--g-text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .hero h1 { font-size: 2.5rem; }
    .node-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .search-box { max-width: 100%; margin-left: 0; }
}

/* ============================================
   STAT CARDS
   ============================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--g-accent), #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--g-text-muted);
    margin-top: 0.25rem;
}

/* Feature cards */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.feature-card {
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.feature-card:hover { border-color: rgba(255,255,255,0.12); }

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--g-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* Hide/show for filtering */
.node-card.hidden { display: none; }
