/* =============================================================
   RIRON BUSOU — Theoretical Armament System
   Cyberpunk Data-Viz Dashboard
   ============================================================= */

/* ---- Variables ---- */
:root {
    --abyss:        #0a0a0f;
    --hud-green:    #00ff88;
    --warning-red:  #ff3344;
    --intel-blue:   #0088ff;
    --grid-line:    #1a1a2e;
    --terminal-gray:#8892a0;

    --hud-green-80: rgba(0, 255, 136, 0.8);
    --hud-green-30: rgba(0, 255, 136, 0.3);
    --hud-green-10: rgba(0, 255, 136, 0.1);
    --intel-blue-30:rgba(0, 136, 255, 0.3);
    --intel-blue-10:rgba(0, 136, 255, 0.1);
    --red-30:       rgba(255, 51, 68, 0.3);
    --red-10:       rgba(255, 51, 68, 0.1);

    --font-display: 'Rajdhani', sans-serif;
    --font-body:    'Titillium Web', sans-serif;
    --font-hud:     'Fira Code', monospace;

    --status-bar-h: 48px;
    --timeline-h:   56px;
    --panel-h:      calc(100vh - var(--status-bar-h) - var(--timeline-h));
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--abyss);
    color: var(--terminal-gray);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.9375rem;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

/* ---- Tactical Grid Background ---- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 49px,
            var(--grid-line) 49px,
            var(--grid-line) 50px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 49px,
            var(--grid-line) 49px,
            var(--grid-line) 50px
        );
    background-size: 50px 50px;
    z-index: 0;
    pointer-events: none;
    animation: grid-drift 20s linear infinite;
}

@keyframes grid-drift {
    from { background-position: 0 0; }
    to   { background-position: 0 50px; }
}

/* ---- HUD Frame ---- */
#hud-frame {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

/* Corner Brackets */
.corner-bracket {
    position: absolute;
    width: 40px;
    height: 40px;
    animation: bracket-pulse 3s ease-in-out infinite;
}

#corner-tl { top: 4px;  left: 4px;  }
#corner-tr { top: 4px;  right: 4px; }
#corner-bl { bottom: 4px; left: 4px; }
#corner-br { bottom: 4px; right: 4px; }

@keyframes bracket-pulse {
    0%, 100% { opacity: 0.7; }
    50%       { opacity: 1.0; }
}

/* Status Bars */
#status-bar-top,
#status-bar-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--status-bar-h);
    display: flex;
    align-items: center;
    padding: 0 56px;
    gap: 1rem;
    font-family: var(--font-hud);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-color: var(--hud-green-30);
}

#status-bar-top {
    top: 0;
    border-bottom: 1px solid var(--hud-green-30);
    background: linear-gradient(180deg, rgba(10,10,15,0.95) 0%, rgba(10,10,15,0.6) 100%);
}

#status-bar-bottom {
    bottom: 0;
    border-top: 1px solid var(--hud-green-30);
    background: linear-gradient(0deg, rgba(10,10,15,0.95) 0%, rgba(10,10,15,0.6) 100%);
    overflow: hidden;
}

.status-label {
    color: var(--hud-green);
    font-weight: 400;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-center {
    flex: 1;
    text-align: center;
    color: var(--terminal-gray);
    opacity: 0.7;
}

.status-right {
    color: var(--terminal-gray);
    white-space: nowrap;
    flex-shrink: 0;
}

#status-active {
    color: var(--hud-green);
    animation: blink 2s step-end infinite;
}

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

/* Data Ticker */
.ticker-prefix {
    color: var(--intel-blue);
    flex-shrink: 0;
    margin-right: 0.5rem;
}

.ticker-wrap {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

#data-ticker {
    display: inline-block;
    color: var(--terminal-gray);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    animation: ticker 40s linear infinite;
}

@keyframes ticker {
    from { transform: translateX(100vw); }
    to   { transform: translateX(-100%); }
}

/* Scanning Line */
#scan-line {
    position: fixed;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(0, 255, 136, 0.3);
    animation: scan 8s linear infinite;
    pointer-events: none;
    z-index: 99;
}

@keyframes scan {
    from { top: 0; }
    to   { top: 100vh; }
}

/* Decorative Reticles */
.hud-reticle {
    position: absolute;
    width: 60px;
    height: 60px;
    pointer-events: none;
}

#reticle-1 {
    right: 80px;
    top: 60px;
    animation: reticle-spin 20s linear infinite;
}

#reticle-2 {
    left: 80px;
    bottom: 70px;
    animation: reticle-spin 30s linear infinite reverse;
}

@keyframes reticle-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ---- Tactical Interface (Main Layout) ---- */
#tactical-interface {
    position: absolute;
    top: var(--status-bar-h);
    left: 0;
    right: 0;
    bottom: var(--timeline-h);
    display: grid;
    grid-template-columns: 55% 45%;
    z-index: 10;
    border-bottom: 1px solid var(--grid-line);
}

/* ---- Panels ---- */
.panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

#panel-strategy {
    border-right: 1px solid var(--grid-line);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--grid-line);
    background: rgba(10, 10, 15, 0.8);
    flex-shrink: 0;
    position: relative;
}

.panel-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--hud-green);
}

.panel-meta {
    font-family: var(--font-hud);
    font-size: 0.7rem;
    color: var(--terminal-gray);
    opacity: 0.6;
    letter-spacing: 0.05em;
}

.panel-indicator {
    margin-left: auto;
    width: 8px;
    height: 8px;
    background: var(--hud-green);
    animation: indicator-pulse 1.5s ease-in-out infinite;
}

.panel-indicator-blue {
    background: var(--intel-blue);
}

@keyframes indicator-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px currentColor; }
    50%       { opacity: 0.3; box-shadow: none; }
}

/* ---- Strategy Board (Left Panel) ---- */
#argument-header {
    padding: 1.5rem 1.5rem 1rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--grid-line);
}

.arg-label {
    font-family: var(--font-hud);
    font-size: 0.7rem;
    color: var(--terminal-gray);
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

#argument-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--hud-green);
    line-height: 1.1;
    margin-bottom: 0.75rem;
}

.subtitle-en {
    display: block;
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    color: var(--terminal-gray);
    letter-spacing: 0.15em;
}

#argument-thesis {
    font-size: 0.875rem;
    color: var(--terminal-gray);
    line-height: 1.6;
    max-width: 55ch;
}

/* Tree Container */
#tree-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding: 1rem;
}

#argument-tree {
    width: 100%;
    height: 100%;
    display: block;
}

/* Tree Legend */
#tree-legend {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--grid-line);
    flex-shrink: 0;
    background: rgba(10,10,15,0.6);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-hud);
    font-size: 0.65rem;
    color: var(--terminal-gray);
    letter-spacing: 0.05em;
}

/* ---- Intelligence Feed (Right Panel) ---- */
#intel-feed {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--grid-line) transparent;
}

#intel-feed::-webkit-scrollbar {
    width: 4px;
}
#intel-feed::-webkit-scrollbar-track {
    background: transparent;
}
#intel-feed::-webkit-scrollbar-thumb {
    background: var(--grid-line);
}

/* Intel Cards */
.intel-card {
    background: rgba(26, 26, 46, 0.4);
    border: 1px solid var(--grid-line);
    border-left-width: 3px;
    padding: 0.875rem 1rem;
    position: relative;
    transition: background 0.2s, border-color 0.2s;
}

.intel-card[data-type="definition"] {
    border-left-color: var(--hud-green);
}
.intel-card[data-type="evidence"] {
    border-left-color: var(--intel-blue);
}
.intel-card[data-type="counter"] {
    border-left-color: var(--warning-red);
    background: rgba(255, 51, 68, 0.04);
}
.intel-card[data-type="protocol"] {
    border-left-color: var(--hud-green);
}
.intel-card[data-type="reference"] {
    border-left-color: var(--terminal-gray);
}

.intel-card:hover {
    background: rgba(26, 26, 46, 0.7);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.card-type {
    font-family: var(--font-hud);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--intel-blue);
    background: var(--intel-blue-10);
    border: 1px solid var(--intel-blue-30);
    padding: 0.1rem 0.4rem;
    flex-shrink: 0;
}

.card-type.warn {
    color: var(--warning-red);
    background: var(--red-10);
    border-color: var(--red-30);
}

.card-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hud-green);
    flex: 1;
}

.card-id {
    font-family: var(--font-hud);
    font-size: 0.65rem;
    color: var(--terminal-gray);
    opacity: 0.5;
    margin-left: auto;
}

.card-body {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--terminal-gray);
}

.card-body p + p {
    margin-top: 0.5rem;
}

.card-body em {
    font-style: normal;
    color: var(--intel-blue);
}

.card-body strong {
    font-weight: 600;
    color: var(--warning-red);
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.tag {
    font-family: var(--font-hud);
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    color: var(--terminal-gray);
    border: 1px solid var(--grid-line);
    padding: 0.1rem 0.4rem;
    text-transform: uppercase;
}

.tag-red {
    color: var(--warning-red);
    border-color: var(--red-30);
}

.tag-green {
    color: var(--hud-green);
    border-color: var(--hud-green-30);
}

/* Evidence Stat Bars */
.evidence-stat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.6rem;
    font-family: var(--font-hud);
    font-size: 0.7rem;
}

.stat-label {
    color: var(--terminal-gray);
    opacity: 0.6;
    min-width: 80px;
    letter-spacing: 0.05em;
}

.stat-bar {
    flex: 1;
    height: 3px;
    background: var(--grid-line);
    position: relative;
}

.stat-fill {
    height: 100%;
    background: var(--intel-blue);
    position: relative;
    transition: width 1s ease;
}

.stat-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: -2px;
    width: 1px;
    height: 7px;
    background: var(--intel-blue);
}

.stat-val {
    color: var(--intel-blue);
    min-width: 35px;
    text-align: right;
}

/* Protocol List */
.protocol-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.protocol-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

.step-num {
    font-family: var(--font-hud);
    font-size: 0.7rem;
    color: var(--hud-green);
    flex-shrink: 0;
    padding-top: 0.1rem;
    min-width: 20px;
}

/* Reference Grid */
.ref-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ref-item {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-family: var(--font-hud);
    font-size: 0.75rem;
    border-bottom: 1px solid var(--grid-line);
    padding-bottom: 0.4rem;
}

.ref-author {
    color: var(--hud-green);
    min-width: 80px;
    font-weight: 400;
    letter-spacing: 0.05em;
}

.ref-work {
    color: var(--terminal-gray);
    flex: 1;
    font-size: 0.7rem;
    opacity: 0.8;
}

.ref-node {
    color: var(--intel-blue);
    font-size: 0.65rem;
    opacity: 0.8;
}

/* ---- Timeline Bar ---- */
#timeline-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--timeline-h);
    background: rgba(10, 10, 15, 0.92);
    border-top: 1px solid var(--hud-green-30);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 20;
}

.timeline-label {
    font-family: var(--font-hud);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--terminal-gray);
    opacity: 0.5;
    white-space: nowrap;
    flex-shrink: 0;
}

#timeline-nodes {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.node-dot {
    width: 10px;
    height: 10px;
    border: 2px solid var(--grid-line);
    background: var(--abyss);
    position: relative;
}

.timeline-node.completed .node-dot {
    border-color: var(--hud-green);
    background: var(--hud-green-30);
    box-shadow: 0 0 6px var(--hud-green-30);
}

.timeline-node.active .node-dot {
    border-color: var(--hud-green);
    background: var(--abyss);
    animation: node-pulse 1.5s ease-in-out infinite;
}

@keyframes node-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--hud-green-30);
        border-color: var(--hud-green);
    }
    50% {
        box-shadow: 0 0 0 6px transparent;
        border-color: rgba(0, 255, 136, 0.5);
    }
}

.node-label {
    font-family: var(--font-hud);
    font-size: 0.55rem;
    letter-spacing: 0.08em;
    color: var(--terminal-gray);
    opacity: 0.5;
    text-transform: uppercase;
}

.timeline-node.completed .node-label,
.timeline-node.active .node-label {
    color: var(--hud-green);
    opacity: 1;
}

.timeline-connector {
    flex: 1;
    height: 1px;
    background: var(--grid-line);
    position: relative;
    top: -8px;
}

.timeline-connector.completed {
    background: var(--hud-green);
    opacity: 0.5;
}

.timeline-connector.active {
    background: linear-gradient(90deg, var(--hud-green) 50%, var(--grid-line) 50%);
    opacity: 0.5;
}

.timeline-progress-track {
    width: 100px;
    height: 3px;
    background: var(--grid-line);
    flex-shrink: 0;
}

#timeline-progress-fill {
    height: 100%;
    background: var(--hud-green);
    width: 60%;
    box-shadow: 0 0 8px var(--hud-green-30);
}

/* ---- SVG Tree Node Styles ---- */
.tree-line {
    stroke: var(--grid-line);
    stroke-width: 1.5;
    fill: none;
}

.tree-line.animated {
    stroke: var(--hud-green-30);
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.2s ease;
}

.tree-line.drawn {
    stroke-dashoffset: 0;
    stroke: var(--hud-green-30);
}

.tree-node-premise circle {
    fill: var(--abyss);
    stroke: var(--hud-green);
    stroke-width: 1.5;
}

.tree-node-inference circle {
    fill: var(--hud-green-10);
    stroke: var(--hud-green);
    stroke-width: 1.5;
}

.tree-node-conclusion circle.outer {
    fill: none;
    stroke: var(--hud-green);
    stroke-width: 1;
}

.tree-node-conclusion circle.inner {
    fill: var(--hud-green-10);
    stroke: var(--hud-green);
    stroke-width: 1.5;
}

.tree-node-counter circle {
    fill: var(--red-10);
    stroke: var(--warning-red);
    stroke-width: 1.5;
}

.tree-label {
    fill: var(--terminal-gray);
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    dominant-baseline: central;
    pointer-events: none;
}

.tree-label-id {
    fill: var(--hud-green);
    font-family: 'Fira Code', monospace;
    font-size: 8px;
    dominant-baseline: central;
    pointer-events: none;
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    #scan-line,
    .corner-bracket,
    #data-ticker,
    .hud-reticle {
        animation: none !important;
    }

    #data-ticker {
        transform: translateX(0);
    }

    #scan-line {
        display: none;
    }

    .tree-line.animated {
        stroke-dashoffset: 0;
        transition: none;
    }

    body::before {
        animation: none;
    }
}
