/* ============================================
   layer-2.report -- Cyberpunk Data-Viz Dashboard
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg: #0A0F1E;
    --surface: #111827;
    --accent-primary: #00FFAA;
    --accent-secondary: #3B82F6;
    --accent-tertiary: #F59E0B;
    --text-primary: #B8C6DB;
    --text-secondary: #4A6FA5;
    --border-glow: rgba(0, 255, 170, 0.2);
    --error: #EF4444;

    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Mono', monospace;

    --telemetry-height: 60px;
    --dock-height: 48px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: #000000;
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

body.booted {
    background: var(--bg);
}

/* --- Boot Overlay --- */
#boot-overlay {
    position: fixed;
    inset: 0;
    background: #000000;
    z-index: 10000;
    pointer-events: none;
    transition: opacity 800ms ease;
}

#boot-overlay.fade-out {
    opacity: 0;
}

#boot-overlay.hidden {
    display: none;
}

/* --- Grid Overlay Texture --- */
#grid-overlay {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 255, 170, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 170, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 400ms ease;
}

#grid-overlay.visible {
    opacity: 1;
}

/* --- Scanline Effect --- */
#scanline-overlay {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.1) 2px,
        rgba(0, 0, 0, 0.1) 4px
    );
    z-index: 2;
    pointer-events: none;
    opacity: 0.3;
}

/* --- Telemetry Bar --- */
#telemetry-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--telemetry-height);
    background: rgba(10, 15, 30, 0.95);
    border-bottom: 1px solid var(--border-glow);
    z-index: 100;
    display: flex;
    align-items: center;
    overflow: hidden;
    transform: translateY(-100%);
    transition: transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

#telemetry-bar.visible {
    transform: translateY(0);
}

#ticker-track {
    width: 100%;
    overflow: hidden;
    position: relative;
}

#ticker-content {
    display: inline-flex;
    align-items: center;
    gap: 24px;
    white-space: nowrap;
    animation: ticker-scroll 40s linear infinite;
    padding-right: 24px;
}

@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ticker-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.ticker-value {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 400;
    color: var(--text-primary);
}

.ticker-value--mint { color: var(--accent-primary); }
.ticker-value--amber { color: var(--accent-tertiary); }
.ticker-value--blue { color: var(--accent-secondary); }

.ticker-sep {
    color: rgba(74, 111, 165, 0.3);
    font-size: 14px;
}

/* --- Dashboard Layout --- */
#dashboard {
    position: fixed;
    top: var(--telemetry-height);
    left: 0;
    right: 0;
    bottom: var(--dock-height);
    display: grid;
    grid-template-columns: 80px 1fr 280px;
    gap: 0;
    z-index: 10;
}

/* --- Nav Rail (Left Column) --- */
#nav-rail {
    background: rgba(17, 24, 39, 0.6);
    border-right: 1px solid var(--border-glow);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 300ms ease, transform 300ms ease;
}

#nav-rail.visible {
    opacity: 1;
    transform: scale(1);
}

.nav-rail-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    position: sticky;
    top: 24px;
}

.nav-brand {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 20px;
    color: var(--accent-primary);
    letter-spacing: -0.03em;
}

.nav-brand-dot {
    color: var(--accent-tertiary);
}

#nav-dots {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.nav-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    cursor: pointer;
    position: relative;
}

.dot-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: all 300ms ease;
}

.nav-dot.active .dot-indicator {
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    box-shadow: 0 0 4px var(--accent-primary), 0 0 8px rgba(0, 255, 170, 0.3);
    animation: pulse-attention 2s ease-in-out infinite;
}

@keyframes pulse-attention {
    0%, 100% { box-shadow: 0 0 4px var(--accent-primary), 0 0 8px rgba(0, 255, 170, 0.3); }
    50% { box-shadow: 0 0 8px var(--accent-primary), 0 0 16px rgba(0, 255, 170, 0.5); }
}

.dot-label {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: color 300ms ease;
}

.nav-dot.active .dot-label {
    color: var(--accent-primary);
}

/* --- Report Content (Center Column) --- */
#report-content {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 40px 48px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 255, 170, 0.2) transparent;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 300ms ease, transform 300ms ease;
}

#report-content.visible {
    opacity: 1;
    transform: scale(1);
}

#report-content::-webkit-scrollbar {
    width: 6px;
}

#report-content::-webkit-scrollbar-track {
    background: transparent;
}

#report-content::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 170, 0.2);
    border-radius: 3px;
}

/* --- Report Sections --- */
.report-section {
    margin-bottom: 64px;
    padding-bottom: 32px;
}

.report-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 56px;
    letter-spacing: -0.03em;
    color: var(--accent-primary);
    line-height: 1.1;
    margin-bottom: 16px;
}

.title-accent {
    color: var(--accent-secondary);
}

.report-subtitle {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 640px;
}

.report-meta {
    display: flex;
    gap: 32px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
}

.meta-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.section-heading {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 36px;
    letter-spacing: -0.03em;
    color: var(--accent-primary);
    margin-bottom: 24px;
    line-height: 1.2;
}

.report-body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 20px;
    max-width: 720px;
}

/* --- Hex Dividers --- */
.section-hex-divider {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    align-items: center;
}

.hex {
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.hex:nth-child(2) { opacity: 0.85; }
.hex:nth-child(3) { opacity: 0.7; }
.hex:nth-child(4) { opacity: 0.55; }
.hex:nth-child(5) { opacity: 0.4; }
.hex:nth-child(6) { opacity: 0.25; }
.hex:nth-child(7) { opacity: 0.1; }

.report-section.in-view .hex {
    opacity: 1;
    transform: translateY(0);
}

.report-section.in-view .hex:nth-child(1) { transition-delay: 0ms; }
.report-section.in-view .hex:nth-child(2) { transition-delay: 60ms; opacity: 0.85; }
.report-section.in-view .hex:nth-child(3) { transition-delay: 120ms; opacity: 0.7; }
.report-section.in-view .hex:nth-child(4) { transition-delay: 180ms; opacity: 0.55; }
.report-section.in-view .hex:nth-child(5) { transition-delay: 240ms; opacity: 0.4; }
.report-section.in-view .hex:nth-child(6) { transition-delay: 300ms; opacity: 0.25; }
.report-section.in-view .hex:nth-child(7) { transition-delay: 360ms; opacity: 0.1; }

/* --- Floating Panels --- */
.floating-panel {
    background: var(--surface);
    border: 1px solid rgba(0, 255, 170, 0.3);
    box-shadow: inset 0 0 20px rgba(0, 255, 170, 0.05);
    border-radius: 4px;
    padding: 24px;
    margin: 32px 0;
    position: relative;
}

.floating-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    opacity: 0.5;
}

.panel-header {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(74, 111, 165, 0.2);
}

.findings-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.findings-list li {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    padding-left: 20px;
    position: relative;
}

.findings-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

/* --- Topology Diagram --- */
.topology-container {
    margin: 32px 0;
    padding: 24px;
    background: rgba(17, 24, 39, 0.4);
    border: 1px solid rgba(0, 255, 170, 0.15);
    border-radius: 4px;
}

.topology-diagram {
    width: 100%;
    max-width: 600px;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Edges */
.edge {
    stroke-width: 1.5;
    stroke-dasharray: 6 4;
    stroke-dashoffset: 0;
    opacity: 0.6;
}

.edge--blue { stroke: #3B82F6; }
.edge--mint { stroke: #00FFAA; }
.edge--amber { stroke: #F59E0B; }

.report-section.in-view .edge {
    animation: edge-flow 3s linear infinite;
}

@keyframes edge-flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -20; }
}

/* Nodes */
.node {
    fill: var(--bg);
    stroke-width: 2;
    transition: all 300ms ease;
}

.node--l1 {
    stroke: var(--accent-primary);
    filter: drop-shadow(0 0 4px rgba(0, 255, 170, 0.5));
}

.node--optimistic {
    stroke: #3B82F6;
    filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.5));
}

.node--zk {
    stroke: #00FFAA;
    filter: drop-shadow(0 0 4px rgba(0, 255, 170, 0.5));
}

.node--channel {
    stroke: #F59E0B;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
}

.report-section.in-view .node {
    animation: node-pulse 2s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.node-label {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 500;
    fill: var(--text-secondary);
    text-anchor: middle;
    letter-spacing: 0.05em;
}

/* --- Sparklines --- */
.sparkline-row {
    display: flex;
    gap: 16px;
    margin: 24px 0 32px;
    flex-wrap: wrap;
}

.sparkline-card {
    flex: 1;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid rgba(74, 111, 165, 0.2);
    border-radius: 4px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sparkline-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.sparkline {
    width: 100%;
    height: 50px;
    overflow: visible;
}

.sparkline-path {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease;
}

.sparkline-path--blue { stroke: #3B82F6; }
.sparkline-path--mint { stroke: #00FFAA; }
.sparkline-path--amber { stroke: #F59E0B; }

.report-section.in-view .sparkline-path {
    stroke-dashoffset: 0;
}

.sparkline-value {
    font-family: var(--font-body);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* --- Comparison Grid --- */
.comparison-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.comparison-item {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    gap: 12px;
    align-items: center;
}

.comparison-name {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-primary);
}

.comparison-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(74, 111, 165, 0.15);
    position: relative;
    overflow: hidden;
}

.comparison-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--bar-width, 0%);
    border-radius: 3px;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.comparison-bar[data-protocol="optimistic"]::after { background: #3B82F6; }
.comparison-bar[data-protocol="zk"]::after { background: #00FFAA; }
.comparison-bar[data-protocol="channel"]::after { background: #F59E0B; }

.comparison-value {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
}

/* --- Data Panels (Right Column) --- */
#data-panels {
    background: rgba(17, 24, 39, 0.4);
    border-left: 1px solid var(--border-glow);
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 255, 170, 0.2) transparent;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 300ms ease, transform 300ms ease;
}

#data-panels.visible {
    opacity: 1;
    transform: scale(1);
}

#data-panels::-webkit-scrollbar {
    width: 4px;
}

#data-panels::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 170, 0.2);
    border-radius: 2px;
}

.data-panel {
    background: var(--surface);
    border: 1px solid rgba(0, 255, 170, 0.15);
    border-radius: 4px;
    padding: 20px;
}

/* Glossary */
.glossary-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glossary-list dt {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: -0.01em;
}

.glossary-list dd {
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-left: 0;
}

/* Metrics */
.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(74, 111, 165, 0.1);
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-label {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.metric-value {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--accent-primary);
    font-weight: 700;
}

/* Citations */
.citations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 20px;
}

.citations-list li {
    font-family: var(--font-body);
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.citations-list li::marker {
    color: var(--accent-primary);
}

/* --- Protocol Dock (Bottom) --- */
#protocol-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--dock-height);
    background: rgba(10, 15, 30, 0.95);
    border-top: 1px solid var(--border-glow);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dock-inner {
    display: flex;
    gap: 24px;
    align-items: center;
}

.protocol-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    color: var(--text-secondary);
    transition: color 300ms ease, transform 300ms ease;
    transform-style: preserve-3d;
    perspective: 600px;
}

.protocol-btn:hover {
    color: var(--text-primary);
}

.protocol-btn.active {
    color: var(--accent-primary);
}

.hex-icon {
    display: block;
    transition: transform 200ms ease;
}

.protocol-status {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: block;
}

/* --- Report Footer --- */
.report-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid rgba(74, 111, 165, 0.2);
    text-align: center;
}

.footer-text {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* --- Mobile Responsive --- */
@media (max-width: 900px) {
    #dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    #nav-rail {
        display: none;
    }

    #data-panels {
        display: none;
    }

    #report-content {
        padding: 24px 20px;
    }

    .report-title {
        font-size: 36px;
    }

    .section-heading {
        font-size: 28px;
    }

    .sparkline-row {
        flex-direction: column;
    }

    .comparison-item {
        grid-template-columns: 100px 1fr 60px;
    }

    .report-meta {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 600px) {
    .report-title {
        font-size: 28px;
    }

    .section-heading {
        font-size: 24px;
    }

    #report-content {
        padding: 16px 12px;
    }

    .floating-panel {
        padding: 16px;
    }
}