/* ======================================================
   SocialDebug.Org v2 - Diagnostic Imaging Interface
   ====================================================== */

/* --- CSS Custom Properties --- */
:root {
    --c-scan-dark: #0a0e17;
    --c-panel-slate: #111827;
    --c-diagnostic-cyan: #7eb8c9;
    --c-pathology-violet: #c084fc;
    --c-recovery-green: #34d399;
    --c-report-white: #f0f4f8;
    --c-alert-coral: #e2725b;
    --c-divider-charcoal: #1e293b;
    --c-inactive-label: #4a5568;

    --font-heading: "Outfit", "Helvetica Neue", Arial, sans-serif;
    --font-body: "Libre Franklin", Georgia, serif;
    --font-mono: "DM Mono", "SF Mono", Menlo, Consolas, monospace;

    --panel-w: 38%;
    --narrative-w: 62%;
}

/* --- Reset / Base --- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--c-scan-dark);
    color: var(--c-report-white);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.1vw, 1.125rem);
    line-height: 1.75;
    overflow-x: hidden;
    scroll-behavior: smooth;
}
body {
    min-height: 100vh;
    position: relative;
}

img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* --- Boot Pulse Overlay --- */
.boot-pulse {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--c-diagnostic-cyan);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transform: translateY(-50%);
}
.boot-pulse.active {
    animation: boot-pulse-anim 2s ease-in-out forwards;
}
@keyframes boot-pulse-anim {
    0%   { opacity: 0; transform: translateY(-50%) scaleX(0.3); }
    50%  { opacity: 0.6; transform: translateY(-50%) scaleX(1); }
    100% { opacity: 0; transform: translateY(-50%) scaleX(1); }
}

/* --- Diagnostic Panel (left, fixed) --- */
.diagnostic-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--panel-w);
    height: 100vh;
    background: var(--c-panel-slate);
    border-right: 1px solid var(--c-divider-charcoal);
    overflow: hidden;
    z-index: 50;
    opacity: 0;
    transition: opacity 1.5s ease-in;
}
.diagnostic-panel.revealed {
    opacity: 1;
}

.panel-inner {
    height: 100%;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.panel-header,
.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: var(--c-inactive-label);
    text-transform: uppercase;
}
.panel-header .panel-tag { color: var(--c-diagnostic-cyan); }
.panel-status { color: var(--c-recovery-green); }

/* Scan-line sweep across panel */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(126, 184, 201, 0.4) 50%,
        transparent 100%);
    animation: scan-sweep 12s linear infinite;
    pointer-events: none;
    z-index: 5;
}
@keyframes scan-sweep {
    0%   { transform: translateY(0); }
    100% { transform: translateY(100vh); }
}

/* Body Diagram */
.body-diagram-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.body-diagram {
    width: 100%;
    max-width: 320px;
    height: auto;
}

/* SVG node text + animation states */
.body-diagram .node text {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.1em;
    fill: var(--c-inactive-label);
    transition: fill 350ms ease-out;
}
.body-diagram .node circle {
    fill: var(--c-panel-slate);
    stroke: rgba(126, 184, 201, 0.5);
    stroke-width: 1;
    transition: fill 350ms ease-out, stroke 350ms ease-out, filter 350ms ease-out;
}
.body-diagram .node.active circle {
    fill: var(--c-diagnostic-cyan);
    stroke: var(--c-diagnostic-cyan);
    filter: drop-shadow(0 0 12px rgba(126, 184, 201, 0.6));
}
.body-diagram .node.active text {
    fill: var(--c-diagnostic-cyan);
}

/* Pathology markers - hidden until activated */
.path-marker {
    fill: var(--c-pathology-violet);
    opacity: 0;
    transform: scale(0);
    transform-origin: center;
    transform-box: fill-box;
    transition: opacity 200ms ease-out, transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.path-marker.visible {
    opacity: 1;
    transform: scale(1);
}

/* Diagnostic readout */
.panel-readout {
    border: 1px solid var(--c-divider-charcoal);
    padding: 1rem 1.1rem;
    background: rgba(10, 14, 23, 0.45);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.readout-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.07em;
}
.readout-label {
    color: var(--c-inactive-label);
    text-transform: uppercase;
}
.readout-value {
    color: var(--c-diagnostic-cyan);
    text-transform: uppercase;
}
.readout-value.priority {
    color: var(--c-alert-coral);
}

/* --- Narrative Field (right) --- */
.narrative-field {
    margin-left: var(--panel-w);
    width: var(--narrative-w);
    min-height: 100vh;
    padding: 5rem 5rem 8rem 5rem;
    scroll-snap-type: y proximity;
}

.narrative-section {
    max-width: 720px;
    margin: 0 0 8rem 0;
    scroll-snap-align: start;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}
.narrative-section.revealed {
    opacity: 1;
    transform: translateX(0);
}

.section-meta {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--c-inactive-label);
    letter-spacing: 0.08em;
    margin-bottom: 2rem;
    text-transform: uppercase;
}
.section-meta .meta-item { margin-right: 0.4rem; }
.section-meta #scanDate { color: var(--c-diagnostic-cyan); }

/* Hero Title (typed) */
.hero-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4.2rem);
    line-height: 1.1;
    color: var(--c-report-white);
    margin: 0 0 1.5rem 0;
    min-height: 1.1em;
}
.hero-title::after {
    content: "";
    display: inline-block;
    width: 12px;
    height: 1.05em;
    background: var(--c-diagnostic-cyan);
    margin-left: 6px;
    vertical-align: -0.15em;
    animation: cursor-blink 1.05s steps(2) infinite;
}
.hero-title.typing-done::after {
    animation: none;
    opacity: 0.55;
}
@keyframes cursor-blink {
    50% { opacity: 0; }
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.15rem;
    line-height: 1.7;
    color: rgba(240, 244, 248, 0.78);
    max-width: 640px;
    margin: 0 0 3rem 0;
}

/* Section Headers */
.section-header {
    margin-bottom: 2rem;
}
.section-tag {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--c-diagnostic-cyan);
    display: block;
    margin-bottom: 0.85rem;
}
.section-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(1.8rem, 3.5vw, 3rem);
    line-height: 1.2;
    color: var(--c-report-white);
    margin: 0;
}

/* Section Body Text */
.section-body {
    max-width: 640px;
}
.section-body p {
    margin: 0 0 1.5rem 0;
    color: rgba(240, 244, 248, 0.92);
}

/* Annotation Markers */
.annotation {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    transition: filter 200ms ease-out;
}
.annotation .annotation-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c-pathology-violet);
}
.annotation.recovery .annotation-dot {
    background: var(--c-recovery-green);
}
.annotation .annotation-num {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--c-pathology-violet);
    letter-spacing: 0.05em;
    margin-left: 1px;
    line-height: 1;
}
.annotation.recovery .annotation-num {
    color: var(--c-recovery-green);
}
.annotation:hover {
    filter: drop-shadow(0 0 6px rgba(192, 132, 252, 0.55));
}
.annotation.recovery:hover {
    filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.55));
}

/* Cross-Section Visualization */
.cross-section {
    width: 100%;
    max-width: none;
    height: 280px;
    margin: 3.5rem 0 2.5rem 0;
    background:
        radial-gradient(circle at 50% 50%, rgba(126,184,201,0.05), transparent 65%),
        var(--c-panel-slate);
    border: 1px solid var(--c-divider-charcoal);
    position: relative;
    overflow: hidden;
}
.cs-rings {
    position: absolute;
    inset: 0;
}
.cs-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid rgba(126, 184, 201, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.cs-ring.r1 { width: 60%; height: 200%; }
.cs-ring.r2 { width: 45%; height: 150%; }
.cs-ring.r3 { width: 30%; height: 100%; }
.cs-ring.r4 { width: 15%; height: 50%; }

.cs-node {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c-diagnostic-cyan);
    box-shadow: 0 0 8px rgba(126, 184, 201, 0.5);
}
.cs-node.violet {
    background: var(--c-pathology-violet);
    box-shadow: 0 0 8px rgba(192, 132, 252, 0.55);
}
.cs-node.green {
    background: var(--c-recovery-green);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.55);
}
.cs-node.n1 { top: 28%; left: 22%; }
.cs-node.n2 { top: 65%; left: 78%; }
.cs-node.n3 { top: 35%; left: 72%; }
.cs-node.n4 { top: 70%; left: 30%; }

.cs-label {
    position: absolute;
    bottom: 1rem;
    left: 1.2rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--c-diagnostic-cyan);
    text-transform: uppercase;
}
.cross-section.alt .cs-rings {
    transform: rotate(7deg);
}

/* Waveform divider */
.waveform {
    width: 100%;
    height: 38px;
    margin: 3rem 0 1rem 0;
    opacity: 0.85;
}

/* Closing */
.section-closing .closing-signature {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    color: var(--c-diagnostic-cyan);
    text-align: center;
    margin-top: 3rem;
}

/* --- Scan Nav (bottom-right) --- */
.scan-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    z-index: 60;
}
.scan-dot {
    width: 32px;
    height: 32px;
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid var(--c-divider-charcoal);
    border-radius: 50%;
    color: var(--c-inactive-label);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 250ms ease-out, color 250ms ease-out, transform 250ms ease-out;
    padding: 0;
}
.scan-dot:hover {
    border-color: var(--c-diagnostic-cyan);
    color: var(--c-diagnostic-cyan);
    transform: scale(1.08);
}
.scan-dot.active {
    border-color: var(--c-diagnostic-cyan);
    color: var(--c-diagnostic-cyan);
    box-shadow: 0 0 14px rgba(126, 184, 201, 0.5);
}

/* --- Annotation Slide-out Panel --- */
.annotation-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    background: var(--c-scan-dark);
    border-left: 3px solid var(--c-pathology-violet);
    transform: translateX(100%);
    transition: transform 350ms ease-out;
    z-index: 80;
    overflow-y: auto;
}
.annotation-panel.recovery {
    border-left-color: var(--c-recovery-green);
}
.annotation-panel.open {
    transform: translateX(0);
}
.ap-inner {
    padding: 2.5rem 2rem;
}
.ap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--c-divider-charcoal);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    font-family: var(--font-mono);
}
.ap-id {
    font-size: 0.85rem;
    color: var(--c-pathology-violet);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.annotation-panel.recovery .ap-id {
    color: var(--c-recovery-green);
}
.ap-close {
    background: transparent;
    border: 1px solid var(--c-divider-charcoal);
    color: var(--c-inactive-label);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    padding: 0.4rem 0.8rem;
    transition: color 200ms, border-color 200ms;
}
.ap-close:hover {
    color: var(--c-report-white);
    border-color: var(--c-diagnostic-cyan);
}
.ap-fields {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 1rem 1rem;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
}
.ap-fields dt {
    color: var(--c-inactive-label);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.ap-fields dd {
    color: var(--c-report-white);
    margin: 0;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .diagnostic-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 64px;
        border-right: none;
        border-bottom: 1px solid var(--c-divider-charcoal);
    }
    .panel-inner {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
        padding: 0.5rem 1rem;
    }
    .panel-header,
    .panel-footer,
    .panel-readout {
        display: none;
    }
    .body-diagram-wrap {
        height: 100%;
        flex: 1;
    }
    .body-diagram {
        max-height: 50px;
        max-width: 100%;
    }
    /* Mobile: scan line is horizontal sweeping */
    .scan-line {
        height: 100%;
        width: 1px;
        top: 0;
        bottom: 0;
        background: linear-gradient(180deg,
            transparent 0%,
            rgba(126, 184, 201, 0.4) 50%,
            transparent 100%);
        animation: scan-sweep-h 12s linear infinite;
    }
    @keyframes scan-sweep-h {
        0%   { transform: translateX(0); }
        100% { transform: translateX(100vw); }
    }

    .narrative-field {
        margin-left: 0;
        width: 100%;
        padding: 5rem 1.25rem 6rem 1.25rem;
    }
    .narrative-section { margin-bottom: 5rem; }
    .scan-nav {
        bottom: 1rem;
        right: 1rem;
        flex-direction: row;
        gap: 0.4rem;
    }
    .annotation-panel {
        width: 100%;
        border-left: none;
        border-top: 3px solid var(--c-pathology-violet);
    }
    .annotation-panel.recovery {
        border-top-color: var(--c-recovery-green);
    }
    .cross-section {
        height: 220px;
    }
}

@media (max-width: 480px) {
    .narrative-field { padding: 5rem 1rem 5rem 1rem; }
    .scan-dot { width: 28px; height: 28px; font-size: 0.55rem; }
}
