/* SocialDebug.Org — Cyberpunk Social Debugger */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --void: #08080f;
    --midnight: #0d1117;
    --cyan: #00e5ff;
    --magenta: #ff0066;
    --white: #e8eaf6;
    --ghost: #6b7394;
    --indigo: #141425;
    --amber: #ffab00;
    --sidebar-w: 280px;
    --sans: 'Space Grotesk', sans-serif;
    --display: 'Orbitron', sans-serif;
    --body: 'IBM Plex Sans', sans-serif;
    --mono: 'IBM Plex Mono', monospace;
}

html, body {
    background: var(--void);
    color: var(--white);
    font-family: var(--body);
    font-weight: 300;
    line-height: 1.85;
    overflow-x: hidden;
    min-height: 100vh;
}

/* === Starfield Drift Background === */
.starfield {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1.5px 1.5px at 13% 24%, rgba(232,234,246,0.18), transparent 60%),
        radial-gradient(1px 1px at 27% 81%, rgba(232,234,246,0.12), transparent 60%),
        radial-gradient(2px 2px at 41% 47%, rgba(232,234,246,0.15), transparent 60%),
        radial-gradient(1px 1px at 58% 18%, rgba(232,234,246,0.10), transparent 60%),
        radial-gradient(1.5px 1.5px at 67% 73%, rgba(232,234,246,0.14), transparent 60%),
        radial-gradient(1px 1px at 79% 38%, rgba(232,234,246,0.10), transparent 60%),
        radial-gradient(2px 2px at 88% 91%, rgba(232,234,246,0.13), transparent 60%),
        radial-gradient(1px 1px at 5% 62%, rgba(232,234,246,0.08), transparent 60%),
        radial-gradient(1.5px 1.5px at 33% 11%, rgba(232,234,246,0.12), transparent 60%),
        radial-gradient(1px 1px at 92% 7%, rgba(232,234,246,0.10), transparent 60%);
    background-size: 100% 100%;
    background-repeat: repeat;
    width: 200%;
    height: 100%;
    animation: drift 240s linear infinite;
    will-change: transform;
}
@keyframes drift {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: #0a0a12;
    border-right: 1px solid rgba(0, 229, 255, 0.2);
    padding: 32px 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.35s ease;
}

.sidebar-header { margin-bottom: 36px; }

.wordmark {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(1.4rem, 2.4vw, 1.75rem);
    color: var(--white);
    letter-spacing: 0.04em;
    margin-bottom: 16px;
    line-height: 1;
    min-height: 1.8em;
}
.wordmark .glyph {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    animation: decode 0.6s forwards;
}
.wordmark .slash { color: var(--cyan); }
@keyframes decode {
    to { opacity: 1; transform: translateY(0); }
}

.meta-line {
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.mono { font-family: var(--mono); font-weight: 400; }
.cyan { color: var(--cyan); }
.magenta { color: var(--magenta); }
.amber { color: var(--amber); }
.ghost { color: var(--ghost); }
.small { font-size: 0.72rem; }

.stack-trace {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.frame {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 8px;
    text-decoration: none;
    color: var(--white);
    font-family: var(--sans);
    font-weight: 500;
    font-size: clamp(0.875rem, 1.2vw, 1rem);
    letter-spacing: 0.06em;
    transition: color 0.25s ease, background 0.25s ease;
}

.frame .hex {
    font-family: var(--mono);
    font-size: 0.8125rem;
    color: var(--ghost);
    transition: color 0.25s ease;
}

.frame .label { white-space: nowrap; }

.frame::after {
    content: "";
    position: absolute;
    left: 8px;
    bottom: 6px;
    height: 1px;
    width: 0;
    background: var(--cyan);
    transition: width 0.3s ease-out;
}

.frame:hover {
    color: var(--cyan);
    background: var(--indigo);
}
.frame:hover .hex { color: var(--cyan); }
.frame:hover::after { width: calc(100% - 16px); }

.frame.active {
    color: var(--cyan);
}
.frame.active .hex { color: var(--cyan); }
.frame.active::after {
    width: calc(100% - 16px);
    animation: pulseUnderline 2s ease-in-out infinite;
}
@keyframes pulseUnderline {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.sidebar-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(107, 115, 148, 0.2);
}
.sidebar-footer div { margin-bottom: 4px; }

/* === Menu Toggle === */
.menu-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    background: rgba(10, 10, 18, 0.9);
    border: 1px solid rgba(0, 229, 255, 0.4);
    z-index: 200;
    cursor: pointer;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}
.menu-toggle span {
    display: block;
    width: 22px;
    height: 1.5px;
    background: var(--cyan);
}

/* === Viewport === */
.viewport {
    margin-left: var(--sidebar-w);
    position: relative;
    z-index: 1;
}

/* === Panel === */
.panel {
    position: relative;
    min-height: 100vh;
    background: var(--void);
    overflow: hidden;
}
.panel.alt { background: var(--midnight); }

.panel-inner {
    display: grid;
    grid-template-columns: 60% 40%;
    align-items: stretch;
    min-height: 100vh;
    gap: 0;
}

.panel-inner.full {
    grid-template-columns: 1fr;
}

.narrative {
    padding: clamp(48px, 8vh, 120px) clamp(32px, 5vw, 80px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.narrative.wide {
    max-width: 1000px;
}

.frame-header {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
    font-size: 0.8125rem;
}

.panel-title {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 32px;
    color: var(--white);
    line-height: 1.05;
    min-height: 1.1em;
}

.panel-title .glyph {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
}
.panel.in-view .panel-title .glyph {
    animation: decode 0.5s forwards;
}

.lede, .narrative p {
    font-family: var(--body);
    font-weight: 300;
    font-size: 1.0625rem;
    line-height: 1.85;
    max-width: 62ch;
    margin-bottom: 24px;
    color: var(--white);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.lede {
    font-weight: 500;
    color: #f4f5fb;
}

.panel.in-view .narrative p {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.4s;
}
.panel.in-view .narrative p:nth-of-type(2) { transition-delay: 0.55s; }
.panel.in-view .narrative p:nth-of-type(3) { transition-delay: 0.7s; }
.panel.in-view .narrative p:nth-of-type(4) { transition-delay: 0.85s; }

.glitch {
    position: relative;
    color: var(--magenta);
    font-weight: 500;
    cursor: default;
}
.glitch.active {
    animation: glitchShift 0.2s steps(2) 1;
}
@keyframes glitchShift {
    0% { transform: translateX(0); clip-path: inset(0 0 0 0); }
    20% { transform: translateX(-2px); clip-path: inset(20% 0 50% 0); }
    40% { transform: translateX(2px); clip-path: inset(50% 0 20% 0); }
    60% { transform: translateX(-1px); clip-path: inset(10% 0 70% 0); }
    100% { transform: translateX(0); clip-path: inset(0 0 0 0); }
}

/* === Diagnostic Display === */
.diagnostic {
    position: relative;
    padding: clamp(32px, 6vh, 80px) clamp(24px, 3vw, 56px);
    border-left: 1px solid rgba(0, 229, 255, 0.12);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 24px;
}

.diag-label {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--cyan);
    align-self: flex-start;
}

.constellation {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1 / 1;
    overflow: visible;
}

.constellation .star {
    fill: var(--cyan);
    filter: drop-shadow(0 0 4px var(--cyan));
}
.constellation .star.fail {
    fill: var(--magenta);
    filter: drop-shadow(0 0 6px var(--magenta));
    animation: failPulse 1.6s ease-in-out infinite;
}
.constellation .star.warn {
    fill: var(--amber);
    filter: drop-shadow(0 0 5px var(--amber));
}
@keyframes failPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.constellation .line {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 1;
    opacity: 0.65;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    will-change: stroke-dashoffset;
    transition: stroke-dashoffset 1.5s ease-out;
}
.panel.in-view .constellation .line {
    stroke-dashoffset: 0;
}

.diag-readout {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8125rem;
    border-top: 1px solid rgba(107, 115, 148, 0.2);
    padding-top: 16px;
}
.diag-readout > div {
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
}

/* === Scan-line Separator === */
.scanline {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: var(--magenta);
    box-shadow: 0 0 8px var(--magenta);
}
.panel.scanline-fired .scanline {
    animation: scanSweep 0.8s ease-out forwards;
}
@keyframes scanSweep {
    0% { width: 0; }
    100% { width: 100%; }
}

/* === Last panel (no constellation column) === */
#trace-end .panel-inner.full .narrative {
    padding: clamp(60px, 12vh, 160px) clamp(32px, 6vw, 120px);
    max-width: 1100px;
}

/* === Mobile === */
@media (max-width: 900px) {
    .menu-toggle { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .viewport { margin-left: 0; }
    .panel-inner {
        grid-template-columns: 1fr;
    }
    .narrative {
        padding: 80px 24px 32px;
    }
    .diagnostic {
        border-left: none;
        border-top: 1px solid rgba(0, 229, 255, 0.12);
        padding: 32px 24px 56px;
    }
    .panel-title { font-size: clamp(1.75rem, 7vw, 2.5rem); }
}
