/* ============================================================
   reasoner.dev — Cyberpunk Data-Viz Dashboard
   Colors: #0a0a0f #0f1923 #00e5ff #76ff03 #ff1744 #b0bec5 #263238 #ffd740
   Fonts: JetBrains Mono, Inter, Space Mono
   ============================================================ */

/* ----- Reset & Base ----- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0a0f;
    color: #b0bec5;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ----- Utility Classes ----- */
.mono {
    font-family: 'JetBrains Mono', monospace;
}

.hud-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    line-height: 1.3;
    letter-spacing: 0.08em;
    color: #b0bec5;
    text-transform: uppercase;
}

.accent-cyan  { color: #00e5ff; }
.accent-green { color: #76ff03; }
.accent-red   { color: #ff1744; }
.accent-amber { color: #ffd740; }

.separator { color: #263238; margin: 0 0.6rem; }
.separator.flex-grow { flex: 1; }

.hidden { opacity: 0; pointer-events: none; }

/* ----- Boot Screen ----- */
#boot-screen {
    position: fixed;
    inset: 0;
    background: #0a0a0f;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.6s ease;
}

#boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#boot-content {
    width: min(640px, 90vw);
}

#boot-title {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: clamp(1rem, 3vw, 2.5rem);
    color: #00e5ff;
    white-space: nowrap;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

#boot-cursor {
    color: #00e5ff;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

#boot-messages {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.boot-line {
    font-family: 'Space Mono', monospace;
    font-size: 0.78rem;
    color: #b0bec5;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: pre;
}

.boot-line.visible {
    opacity: 1;
}

.boot-ok {
    color: #76ff03;
}

/* ----- Dashboard Layout ----- */
#dashboard {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    background: #0a0a0f;
    transition: opacity 0.8s ease;
}

#dashboard.visible {
    opacity: 1;
    pointer-events: all;
}

/* ----- Top Bar ----- */
#top-bar {
    height: 60px;
    background: #0f1923;
    border-bottom: 1px solid #263238;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

#top-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #00e5ff, transparent);
    opacity: 0.4;
}

#top-bar-left,
#top-bar-center,
#top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #b0bec5;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #263238;
}

.status-dot.active {
    background: #76ff03;
    box-shadow: 0 0 6px #76ff03;
    animation: pulse-green 2s ease-in-out infinite;
}

.status-dot.warning {
    background: #ffd740;
    box-shadow: 0 0 6px #ffd740;
}

.status-dot.error {
    background: #ff1744;
    box-shadow: 0 0 6px #ff1744;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ----- Grid Wrapper ----- */
#grid-wrapper {
    flex: 1;
    display: grid;
    grid-template-columns: 240px 1fr 280px;
    grid-template-rows: 1fr;
    gap: 1px;
    background: #263238;
    overflow: hidden;
    min-height: 0;
}

/* ----- Panels ----- */
.panel {
    background: #0a0a0f;
    padding: 1.25rem 1.5rem;
    overflow: hidden;
}

.hud-panel {
    position: relative;
}

/* Corner bracket HUD framing */
.hud-panel::before,
.hud-panel::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    transition: width 0.25s ease, height 0.25s ease, opacity 0.25s ease;
    opacity: 0.7;
    pointer-events: none;
    z-index: 2;
}

/* Top-left corner */
.hud-panel::before {
    top: 8px;
    left: 8px;
    border-left: 2px solid #00e5ff;
    border-top: 2px solid #00e5ff;
}

/* Top-right corner */
.hud-panel::after {
    top: 8px;
    right: 8px;
    border-right: 2px solid #00e5ff;
    border-top: 2px solid #00e5ff;
}

/* Bottom corners via child pseudo */
.hud-panel .panel-header::before,
.hud-panel .panel-header::after {
    content: none;
}

.hud-panel:hover::before,
.hud-panel:hover::after {
    width: 30px;
    height: 30px;
    opacity: 1;
}

/* Bottom bracket corners */
.hud-panel .bottom-brackets::before,
.hud-panel .bottom-brackets::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    transition: width 0.25s ease, height 0.25s ease;
    pointer-events: none;
    z-index: 2;
    opacity: 0.7;
}

/* Scan-line hover effect */
.hud-panel::after {
    bottom: 8px;
    right: 8px;
    top: auto;
    border-right: 2px solid #00e5ff;
    border-bottom: 2px solid #00e5ff;
    border-top: none;
    border-left: none;
}

/* Corrected: bottom-left bracket via wrapper spans */
/* We use a different approach - inline spans in markup not needed */
/* Using a wrapper div that adds bottom-left bracket */
.hud-panel .bracket-bl {
    position: absolute;
    bottom: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
    border-left: 2px solid #00e5ff;
    border-bottom: 2px solid #00e5ff;
    opacity: 0.7;
    transition: width 0.25s ease, height 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
    z-index: 2;
}

.hud-panel:hover .bracket-bl {
    width: 30px;
    height: 30px;
    opacity: 1;
}

/* Scan-line effect on hover */
.hud-panel .scan-line {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,229,255,0.04) 50%, transparent 100%);
    height: 200%;
    width: 100%;
    top: -100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hud-panel:hover .scan-line {
    opacity: 1;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0%   { top: -100%; }
    100% { top: 100%;  }
}

/* ----- Panel Header ----- */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #263238;
}

.panel-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #b0bec5;
    text-transform: uppercase;
}

/* ----- Left Sidebar ----- */
#sidebar-left {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #263238 transparent;
}

#sidebar-left .panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ----- Logic Tree ----- */
#logic-tree {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #263238 transparent;
}

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

.tree-node summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.tree-node summary::-webkit-details-marker {
    display: none;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.73rem;
    color: #b0bec5;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    transition: background 0.15s ease, color 0.15s ease;
}

.tree-item:hover {
    background: #0f1923;
    color: #00e5ff;
}

.tree-root {
    color: #00e5ff;
    font-weight: 700;
}

.tree-icon {
    font-size: 0.7rem;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.tree-children {
    padding-left: 1.1rem;
    border-left: 1px dashed #263238;
    margin-left: 0.55rem;
    margin-top: 0.15rem;
}

.tree-leaf {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.68rem;
    color: #b0bec5;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    transition: color 0.15s ease;
}

.tree-leaf:hover {
    color: #00e5ff;
}

/* ----- System Status ----- */
#system-status {
    border-top: 1px solid #263238;
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-row .hud-label:first-child {
    width: 52px;
    flex-shrink: 0;
}

.status-bar {
    flex: 1;
    height: 4px;
    background: #0f1923;
    border: 1px solid #263238;
    overflow: hidden;
}

.status-fill {
    height: 100%;
    transition: width 1s ease;
}

/* ----- Main Content ----- */
#main-content {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #263238 transparent;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: #263238;
}

/* ----- Hero Panel ----- */
#hero-panel {
    position: relative;
    padding: 2rem 2rem 1.5rem;
    min-height: 220px;
    overflow: hidden;
}

#node-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.35;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-heading {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(1.3rem, 2.5vw, 2.2rem);
    font-weight: 700;
    color: #b0bec5;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.hero-sub {
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    color: #b0bec5;
    max-width: 560px;
    margin-bottom: 1rem;
    opacity: 0.85;
}

.hero-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid;
    letter-spacing: 0.08em;
}

.tag-cyan  { border-color: #00e5ff; color: #00e5ff; }
.tag-green { border-color: #76ff03; color: #76ff03; }
.tag-amber { border-color: #ffd740; color: #ffd740; }

/* ----- Feature Grid ----- */
#feature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #263238;
}

.feature-panel {
    padding: 1.25rem 1.5rem;
    background: #0f1923;
    transition: background 0.2s ease;
}

.feature-panel:hover {
    background: #111a22;
}

.feat-icon {
    font-size: 2rem;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 0.6rem;
    line-height: 1;
}

.feat-desc {
    font-size: 0.85rem;
    color: #b0bec5;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.feat-code {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    background: #0a0a0f;
    border: 1px solid #263238;
    padding: 0.6rem 0.75rem;
    font-size: 0.72rem;
}

.code-line {
    display: block;
}

/* ----- API Panel ----- */
#api-panel {
    background: #0a0a0f;
    padding: 1.25rem 1.5rem;
}

#api-content {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.5rem;
    align-items: start;
}

#api-code-block {
    min-width: 0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f1923;
    border: 1px solid #263238;
    border-bottom: none;
    padding: 0.4rem 0.75rem;
}

.code-pre {
    background: #050508;
    border: 1px solid #263238;
    padding: 1rem;
    font-size: 0.75rem;
    line-height: 1.6;
    overflow-x: auto;
    color: #b0bec5;
    white-space: pre;
    scrollbar-width: thin;
    scrollbar-color: #263238 transparent;
}

.code-comment { color: #37474f; }
.code-kw      { color: #00e5ff; }
.code-str     { color: #76ff03; }
.code-op      { color: #ffd740; }

#api-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
    min-width: 110px;
}

.stat-block {
    border: 1px solid #263238;
    padding: 0.6rem 0.75rem;
    background: #0f1923;
    text-align: center;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    display: block;
    margin-bottom: 0.2rem;
}

/* ----- Right Sidebar ----- */
#sidebar-right {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #263238 transparent;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: #263238;
}

#sidebar-right .panel {
    background: #0a0a0f;
    padding: 1rem 1.25rem;
}

/* ----- Trace Feed ----- */
#trace-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 360px;
}

#trace-feed {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #263238 transparent;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.trace-entry {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    line-height: 1.4;
    padding: 0.25rem 0.4rem;
    border-left: 2px solid transparent;
    opacity: 0;
    transform: translateY(-4px);
    animation: trace-appear 0.3s ease forwards;
}

.trace-entry.t-ok     { border-left-color: #76ff03; color: #76ff03; }
.trace-entry.t-warn   { border-left-color: #ffd740; color: #ffd740; }
.trace-entry.t-err    { border-left-color: #ff1744; color: #ff1744; }
.trace-entry.t-info   { border-left-color: #00e5ff; color: #b0bec5; }

@keyframes trace-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#trace-footer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-top: 0.5rem;
    border-top: 1px solid #263238;
    margin-top: 0.5rem;
}

/* ----- Graph Canvas Panel ----- */
#graph-panel {
    padding: 1rem 1.25rem 0.75rem;
}

#graph-canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* ----- Metrics Panel ----- */
#metrics-panel {
    padding: 1rem 1.25rem;
}

#metrics-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border-bottom: 1px solid #0f1923;
}

/* ----- Circuit Traces SVG ----- */
#circuit-traces {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.circuit-path {
    fill: none;
    stroke: #00e5ff;
    stroke-width: 1;
    stroke-dasharray: 6 4;
    opacity: 0.35;
    animation: flow-dash 3s linear infinite;
}

@keyframes flow-dash {
    to { stroke-dashoffset: -20; }
}

/* ----- Status Bar ----- */
#status-bar {
    height: 30px;
    background: #0f1923;
    border-top: 1px solid #263238;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0;
    flex-shrink: 0;
}

/* ----- Scrollbar Styling ----- */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #263238;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #37474f;
}

/* ----- Node Graph Background Pattern ----- */
#hero-panel {
    background-image: radial-gradient(circle, #263238 1px, transparent 1px);
    background-size: 30px 30px;
    background-color: #0a0a0f;
}

/* ----- Responsive (minimal — designed for desktop) ----- */
@media (max-width: 900px) {
    #grid-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    #sidebar-left,
    #sidebar-right {
        display: none;
    }

    #feature-grid {
        grid-template-columns: 1fr;
    }

    #api-content {
        grid-template-columns: 1fr;
    }

    #api-stats {
        flex-direction: row;
        flex-wrap: wrap;
    }
}
