/* ============================================
   HISTORYGRAPHER.COM - Styles
   Dark Observatory Control Room Aesthetic
   ============================================ */

/* --- CSS Variables / Palette --- */
:root {
    --deep-space: #0A0E1A;
    --luminous-cyan: #00E5FF;
    --pale-cyan: #A8D8E8;
    --dark-navy: #1A2840;
    --muted-teal: #4A7A8A;
    --signal-orange: #FF6B35;
    --abyssal-blue: #0D1B2A;
    --bright-cerulean: #00B4D8;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-space);
    color: var(--pale-cyan);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 15px;
    line-height: 1.8;
    font-weight: 400;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Background Grid --- */
#bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, rgba(0, 229, 255, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
    background-size: 80px 80px;
}

/* --- Star Field --- */
#star-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.star {
    position: absolute;
    width: 1px;
    height: 1px;
    background: var(--pale-cyan);
    border-radius: 50%;
}

/* --- Scan Line --- */
#scan-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, transparent, rgba(0, 229, 255, 0.15), transparent);
    z-index: 100;
    transform: translateY(-100%);
    pointer-events: none;
    opacity: 0;
}

#scan-line.active {
    opacity: 1;
    animation: scanDown 1.5s ease-in forwards;
}

@keyframes scanDown {
    from { transform: translateY(-100vh); }
    to { transform: translateY(100vh); }
}

/* --- HUD Columns --- */
.hud-column {
    position: fixed;
    top: 0;
    width: 80px;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 12px;
    pointer-events: none;
}

#hud-left {
    left: 0;
}

#hud-right {
    right: 0;
    align-items: flex-end;
}

/* --- HUD Brackets --- */
.hud-bracket {
    width: 40px;
    height: 40px;
    opacity: 0;
}

.hud-bracket-tl {
    border-top: 2px solid var(--muted-teal);
    border-left: 2px solid var(--muted-teal);
    animation: bracketShimmer 4s ease-in-out infinite;
}

.hud-bracket-bl {
    border-bottom: 2px solid var(--muted-teal);
    border-left: 2px solid var(--muted-teal);
    animation: bracketShimmer 4s ease-in-out infinite 1s;
}

.hud-bracket-tr {
    border-top: 2px solid var(--muted-teal);
    border-right: 2px solid var(--muted-teal);
    align-self: flex-end;
    animation: bracketShimmer 4s ease-in-out infinite 0.5s;
}

.hud-bracket-br {
    border-bottom: 2px solid var(--muted-teal);
    border-right: 2px solid var(--muted-teal);
    align-self: flex-end;
    animation: bracketShimmer 4s ease-in-out infinite 1.5s;
}

.hud-bracket.visible {
    opacity: 1;
    transition: opacity 0.3s ease;
}

@keyframes bracketShimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

.hud-bracket.visible {
    animation: bracketDraw 0.6s ease-out forwards, bracketShimmer 4s ease-in-out infinite 1s;
}

@keyframes bracketDraw {
    from {
        opacity: 0;
        clip-path: inset(0 100% 100% 0);
    }
    to {
        opacity: 0.4;
        clip-path: inset(0 0 0 0);
    }
}

/* --- HUD Readouts --- */
.hud-readout {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 0;
    overflow: hidden;
}

.hud-right-readout {
    text-align: right;
}

.readout-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    line-height: 1.6;
    font-weight: 300;
    color: var(--muted-teal);
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
}

.readout-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.readout-dynamic {
    margin-top: auto;
}

/* --- Sections --- */
.section-boot {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.section-graph {
    position: relative;
    height: 250vh;
    z-index: 10;
}

.section-timeline {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.section-signal {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* --- Console Boot Section --- */
.boot-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.boot-node {
    width: 32px;
    height: 32px;
    transform: scale(0);
    opacity: 0;
}

.boot-node.visible {
    transform: scale(1);
    opacity: 1;
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

.boot-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 48px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--luminous-cyan);
    letter-spacing: 4px;
    overflow: hidden;
}

.boot-title .letter {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.06s ease;
}

.boot-title .letter.visible {
    opacity: 1;
}

.boot-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 24px;
    color: var(--muted-teal);
    opacity: 0;
    transition: opacity 0.4s ease;
}

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

.cursor {
    animation: blink 1s step-end infinite;
}

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

/* --- Graph Nodes --- */
.graph-node {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(0, 229, 255, 0.3), transparent);
    border: 1px solid rgba(0, 229, 255, 0.6);
    position: absolute;
    cursor: pointer;
    z-index: 20;
    animation: nodePulse 3s ease-in-out infinite;
    pointer-events: auto;
}

.graph-node:not(.boot-node):not(.signal-node) {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.graph-node:not(.boot-node):not(.signal-node).active {
    opacity: 1;
    transform: scale(1);
}

.graph-node.critical {
    background: radial-gradient(circle at center, rgba(255, 107, 53, 0.3), transparent);
    border: 1px solid rgba(255, 107, 53, 0.6);
    animation: nodePulseCritical 3s ease-in-out infinite;
}

.graph-node:hover {
    transform: scale(1.5) !important;
    z-index: 30;
}

.graph-node.critical:hover {
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.6);
}

.graph-node:not(.critical):hover {
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.6);
}

@keyframes nodePulse {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 229, 255, 0.3); }
    50% { box-shadow: 0 0 16px rgba(0, 229, 255, 0.5); }
}

@keyframes nodePulseCritical {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 107, 53, 0.3); }
    50% { box-shadow: 0 0 16px rgba(255, 107, 53, 0.5); }
}

/* --- Node Tooltips --- */
.node-tooltip {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-navy);
    border: 1px solid var(--luminous-cyan);
    padding: 8px 12px;
    white-space: nowrap;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--pale-cyan);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.graph-node:hover .node-tooltip {
    opacity: 1;
}

.tt-label {
    color: var(--luminous-cyan);
    font-weight: 400;
}

.tt-year {
    color: var(--muted-teal);
    font-weight: 300;
    font-size: 11px;
}

/* --- Graph SVG --- */
.graph-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

.graph-svg line {
    stroke: rgba(0, 229, 255, 0.2);
    stroke-width: 1;
    transition: stroke-opacity 0.3s ease, stroke-width 0.3s ease;
}

.graph-svg line.bright {
    stroke: rgba(0, 229, 255, 0.8);
    stroke-width: 2;
}

.graph-svg line.critical-edge {
    stroke: rgba(255, 107, 53, 0.2);
}

.graph-svg line.critical-edge.bright {
    stroke: rgba(255, 107, 53, 0.8);
}

/* --- Edge particles --- */
.edge-particle {
    fill: var(--luminous-cyan);
    r: 2;
    opacity: 0;
}

.edge-particle.active {
    opacity: 1;
}

/* --- Era Labels --- */
.era-label {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 3px;
    color: rgba(0, 180, 216, 0.5);
    z-index: 12;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.era-label.visible {
    opacity: 1;
}

/* --- Timeline Section --- */
.timeline-container {
    width: 80%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.timeline-heading {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--luminous-cyan);
    letter-spacing: 3px;
    text-align: center;
}

.timeline-bar {
    display: flex;
    flex-direction: column;
    width: 4px;
    height: 400px;
    background: rgba(0, 229, 255, 0.1);
    border-radius: 2px;
    position: relative;
}

.timeline-segment {
    position: relative;
    display: flex;
    align-items: center;
    border-left: 4px solid var(--luminous-cyan);
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.timeline-segment:hover {
    opacity: 1;
}

.timeline-segment:nth-child(even) .tl-label,
.timeline-segment:nth-child(even) .tl-range {
    left: auto;
    right: auto;
}

.tl-label {
    position: absolute;
    left: 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--luminous-cyan);
    white-space: nowrap;
}

.tl-range {
    position: absolute;
    left: 20px;
    top: 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 300;
    color: var(--muted-teal);
    white-space: nowrap;
}

.timeline-density-bars {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    height: 120px;
    width: 100%;
    max-width: 500px;
}

.density-bar {
    flex: 1;
    background: rgba(0, 229, 255, 0.05);
    border: 1px solid rgba(0, 229, 255, 0.15);
    position: relative;
    height: 100%;
    display: flex;
    align-items: flex-end;
}

.density-fill {
    width: 100%;
    background: linear-gradient(to top, rgba(0, 229, 255, 0.4), rgba(0, 229, 255, 0.1));
    transition: height 1s ease-out;
    height: 0;
}

.density-bar[data-density="12"] .density-fill { height: 34%; }
.density-bar[data-density="18"] .density-fill { height: 51%; }
.density-bar[data-density="15"] .density-fill { height: 43%; }
.density-bar[data-density="20"] .density-fill { height: 57%; }
.density-bar[data-density="22"] .density-fill { height: 63%; }
.density-bar[data-density="35"] .density-fill { height: 100%; }

/* --- Signal Section --- */
.signal-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    position: relative;
}

.signal-node {
    width: 48px;
    height: 48px;
    position: relative;
    z-index: 5;
    animation: signalPulse 2s ease-in-out infinite;
}

@keyframes signalPulse {
    0%, 100% { box-shadow: 0 0 16px rgba(0, 229, 255, 0.4); transform: scale(1); }
    50% { box-shadow: 0 0 40px rgba(0, 229, 255, 0.8); transform: scale(1.1); }
}

.signal-text {
    text-align: center;
}

.signal-heading {
    font-family: 'Orbitron', sans-serif;
    font-size: 44px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--luminous-cyan);
    letter-spacing: 4px;
    margin-bottom: 16px;
}

.signal-sub {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 15px;
    font-weight: 300;
    color: var(--muted-teal);
    letter-spacing: 1px;
}

/* --- Signal Rings --- */
.signal-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    pointer-events: none;
}

.signal-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 1px solid rgba(0, 229, 255, 0.15);
    transform: translate(-50%, -50%);
}

.ring-1 {
    width: 200px;
    height: 200px;
    animation: ringExpand 4s ease-out infinite;
}

.ring-2 {
    width: 200px;
    height: 200px;
    animation: ringExpand 4s ease-out infinite 1.33s;
}

.ring-3 {
    width: 200px;
    height: 200px;
    animation: ringExpand 4s ease-out infinite 2.66s;
}

@keyframes ringExpand {
    0% {
        width: 48px;
        height: 48px;
        opacity: 0.6;
        border-color: rgba(0, 229, 255, 0.4);
    }
    100% {
        width: 600px;
        height: 600px;
        opacity: 0;
        border-color: rgba(0, 229, 255, 0);
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .hud-column {
        display: none;
    }

    .boot-title {
        font-size: 28px;
        letter-spacing: 2px;
    }

    .boot-subtitle {
        font-size: 16px;
    }

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

    .timeline-heading {
        font-size: 20px;
    }

    .graph-node {
        width: 24px;
        height: 24px;
    }

    .era-label {
        font-size: 12px;
    }
}
