/* ============================================
   graphers.dev - Cyberpunk Data Observatory
   ============================================ */

/* --- Custom Properties --- */
:root {
    --void-black: #0A0E17;
    --deep-graphite: #141B2A;
    --signal-cyan: #00FFD1;
    --neon-magenta: #FF2D6B;
    --plasma-amber: #FFB800;
    --readout-silver: #B8C4D0;
    --dim-steel: #7A8B9E;
    --ghost-wire: #1E2A3D;
    --deep-bg: #0F1A2E;
    --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    --cyan-glow: rgba(0, 255, 209, 0.15);
    --magenta-glow: rgba(255, 45, 107, 0.15);
    --amber-glow: rgba(255, 184, 0, 0.15);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: linear-gradient(135deg, #0A0E17 0%, #141B2A 40%, #0F1A2E 100%);
    color: var(--readout-silver);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* --- Coordinate Grid Overlay --- */
.coord-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

.coord-grid.visible {
    opacity: 1;
}

.coord-grid line {
    stroke: var(--ghost-wire);
    stroke-width: 0.5;
}

.coord-grid line.heavy {
    stroke-width: 1;
    opacity: 0.6;
}

/* --- Axis Spine --- */
.axis-spine {
    position: fixed;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100vh;
    background: var(--signal-cyan);
    opacity: 0.15;
    z-index: 1;
    pointer-events: none;
    transform: translateX(-1px);
}

.axis-spine::before,
.axis-spine::after {
    content: '';
    position: absolute;
    left: -4px;
    width: 10px;
    height: 1px;
    background: var(--signal-cyan);
    opacity: 0.3;
}

.axis-spine::before { top: 20%; }
.axis-spine::after { top: 80%; }

/* --- Zones --- */
.zone {
    position: relative;
    z-index: 2;
}

/* --- Zone 0: Hero --- */
.zone-hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#hero-graph {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    pointer-events: none;
}

.hero-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5.5vw, 5.5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--signal-cyan);
    text-shadow: 0 0 30px rgba(0, 255, 209, 0.4), 0 0 60px rgba(0, 255, 209, 0.15);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.hero-title.visible {
    opacity: 1;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.4s ease, filter 0.4s ease;
}

.hero-title .letter.revealed {
    opacity: 1;
    filter: blur(0);
}

.hero-subtitle {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 300;
    font-size: 1.3rem;
    color: var(--readout-silver);
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

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

/* --- Honeycomb Grid --- */
.honeycomb-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 6px;
    padding: 4rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Hex Cell --- */
.hex-cell {
    clip-path: var(--hex-clip);
    background: var(--deep-graphite);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

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

.hex-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: var(--hex-clip);
    border: 3px solid var(--ghost-wire);
    z-index: 1;
    pointer-events: none;
    transition: border-color 0.3s ease;
}

.hex-cell:hover::before {
    border-color: var(--signal-cyan);
}

.hex-cell:hover {
    box-shadow: 0 0 20px var(--cyan-glow);
}

.hex-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

/* Hex Scan Line effect */
.hex-scan-line {
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--signal-cyan);
    opacity: 0.08;
    animation: scanLine 6s linear infinite;
    z-index: 5;
    pointer-events: none;
}

@keyframes scanLine {
    0% { top: -1%; }
    100% { top: 101%; }
}

/* Hex sizes */
.hex-large {
    width: min(90vw, 700px);
    min-height: 400px;
    aspect-ratio: auto;
}

.hex-small {
    width: min(40vw, 200px);
    height: min(40vw, 230px);
}

.hex-showcase {
    width: min(42vw, 220px);
    height: min(42vw, 250px);
}

.hex-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hex-viz {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* --- Section Heading --- */
.section-heading {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--signal-cyan);
    text-shadow: 0 0 12px rgba(0, 255, 209, 0.4);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

/* --- Mark elements (highlighted text in manifesto) --- */
mark {
    background: transparent;
    color: var(--signal-cyan);
    text-shadow: 0 0 12px rgba(0, 255, 209, 0.4);
}

/* --- Mono text --- */
.mono {
    font-family: 'JetBrains Mono', monospace;
    font-feature-settings: "zero" 1, "ss02" 1;
}

/* --- Sparkline Decorators --- */
.sparkline-decorator {
    width: 120px;
    height: 24px;
    overflow: visible;
}

.sparkline-large {
    width: 100px;
    height: 40px;
    overflow: visible;
}

.sparkline-path {
    fill: none;
    stroke: var(--signal-cyan);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

/* --- Radial Gauges --- */
.radial-gauge {
    width: 48px;
    height: 48px;
}

.gauge-sm {
    width: 36px;
    height: 36px;
}

.gauge-cluster {
    display: flex;
    gap: 6px;
    align-items: center;
}

.gauge-track {
    fill: none;
    stroke: var(--ghost-wire);
    stroke-width: 3;
}

.gauge-fill {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: center;
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.gauge-cyan { stroke: var(--signal-cyan); }
.gauge-magenta { stroke: var(--neon-magenta); }
.gauge-amber { stroke: var(--plasma-amber); }

.gauge-label {
    font-size: 0.65rem;
    color: var(--dim-steel);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* --- Bar Chart Viz --- */
.viz-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
    padding: 0 10px;
}

.bar {
    flex: 1;
    background: var(--bar-color, var(--signal-cyan));
    border-radius: 1px 1px 0 0;
    height: 0;
    transition: height 1s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 8px;
    opacity: 0.85;
}

.bar-horizontal {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 4px;
    width: 100%;
    padding: 0;
}

.bar-h {
    height: 10px;
    background: var(--bar-color, var(--signal-cyan));
    border-radius: 0 1px 1px 0;
    width: 0;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.85;
}

/* --- Donut Chart Viz --- */
.viz-donut {
    width: 56px;
    height: 56px;
}

.donut-track {
    fill: none;
    stroke: var(--ghost-wire);
    stroke-width: 6;
}

.donut-seg {
    fill: none;
    stroke-width: 6;
    stroke-linecap: butt;
    transform: rotate(-90deg);
    transform-origin: center;
    stroke-dasharray: 150.8;
    stroke-dashoffset: 150.8;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.donut-cyan { stroke: var(--signal-cyan); }
.donut-magenta { stroke: var(--neon-magenta); }
.donut-amber { stroke: var(--plasma-amber); }

/* --- Area Chart Viz --- */
.viz-area {
    width: 100px;
    height: 50px;
}

.area-fill {
    fill: rgba(0, 255, 209, 0.1);
    stroke: none;
}

.area-line {
    fill: none;
    stroke: var(--signal-cyan);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

/* --- Scatter Plot Viz --- */
.viz-scatter {
    width: 80px;
    height: 80px;
}

.scatter-dot {
    transition: r 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Zone 3: Terminal / Transmission Log --- */
.zone-transmission {
    padding: 4rem 2rem;
    display: flex;
    justify-content: center;
}

.hex-terminal {
    width: min(95vw, 800px);
    min-height: 500px;
}

.terminal-output {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.terminal-line {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    flex-wrap: wrap;
}

.terminal-line.revealed {
    opacity: 1;
    transform: translateX(0);
}

.ts {
    color: var(--dim-steel);
    font-size: 0.75rem;
    white-space: nowrap;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-cyan { background: var(--signal-cyan); box-shadow: 0 0 6px var(--signal-cyan); }
.dot-magenta { background: var(--neon-magenta); box-shadow: 0 0 6px var(--neon-magenta); }
.dot-amber { background: var(--plasma-amber); box-shadow: 0 0 6px var(--plasma-amber); }

.terminal-text {
    font-size: 0.8rem;
    color: var(--readout-silver);
}

/* --- Zone 4: Signal Fade --- */
.zone-fade {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#fade-graph {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.fade-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.fade-text {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: var(--dim-steel);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    animation: pulseFade 3s ease-in-out infinite;
}

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

.blink-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--signal-cyan);
    margin-left: 4px;
    vertical-align: middle;
    animation: blinkCursor 1.06s step-end infinite;
}

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

/* --- Radar Navigation --- */
.radar-nav {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    z-index: 100;
    cursor: pointer;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 50%;
    background: rgba(10, 14, 23, 0.85);
    border: 1px solid var(--ghost-wire);
    backdrop-filter: blur(8px);
    overflow: hidden;
}

.radar-nav:hover {
    width: 200px;
    height: 200px;
}

.radar-svg {
    width: 100%;
    height: 100%;
}

.radar-ring {
    fill: none;
    stroke: var(--ghost-wire);
    stroke-width: 1;
}

.radar-sweep {
    stroke: var(--signal-cyan);
    stroke-width: 1.5;
    opacity: 0.5;
    transform-origin: 100px 100px;
    animation: radarSweep 8s linear infinite;
}

@keyframes radarSweep {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.radar-dot {
    fill: var(--dim-steel);
    cursor: pointer;
    transition: fill 0.3s ease, r 0.3s ease;
}

.radar-dot:hover {
    fill: var(--signal-cyan);
    r: 7;
}

.radar-dot.active {
    fill: var(--signal-cyan);
    filter: drop-shadow(0 0 4px var(--signal-cyan));
    animation: radarPulse 2s ease-in-out infinite;
}

@keyframes radarPulse {
    0%, 100% { r: 5; }
    50% { r: 7; }
}

/* --- Tilt 3D on hex cells --- */
.hex-cell.tilt {
    transition: transform 0.1s ease-out;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .honeycomb-grid {
        max-width: 800px;
    }
}

@media (max-width: 768px) {
    .honeycomb-grid {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .hex-cell,
    .hex-large,
    .hex-small,
    .hex-showcase {
        width: 90vw;
        min-height: 180px;
        height: auto;
        clip-path: polygon(5% 0%, 95% 0%, 100% 15%, 100% 85%, 95% 100%, 5% 100%, 0% 85%, 0% 15%);
    }

    .hex-large {
        min-height: 300px;
    }

    .hex-terminal {
        min-height: 400px;
    }

    .hex-inner {
        padding: 1.5rem;
    }

    .radar-nav {
        bottom: 12px;
        right: 12px;
        width: 48px;
        height: 48px;
    }

    .radar-nav:hover {
        width: 160px;
        height: 160px;
    }

    .terminal-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .axis-spine {
        display: none;
    }
}

/* --- Hex entrance animation directions --- */
.hex-cell:nth-child(1) { transition-delay: 0s; }
.hex-cell:nth-child(2) { transition-delay: 0.1s; }
.hex-cell:nth-child(3) { transition-delay: 0.2s; }
.hex-cell:nth-child(4) { transition-delay: 0.3s; }
.hex-cell:nth-child(5) { transition-delay: 0.4s; }
.hex-cell:nth-child(6) { transition-delay: 0.5s; }

/* Hex-cell entry directions */
.hex-cell:nth-child(odd):not(.in-view) {
    transform: translateX(-40px) translateY(40px);
}

.hex-cell:nth-child(even):not(.in-view) {
    transform: translateX(40px) translateY(40px);
}

.hex-cell.in-view {
    transform: translateX(0) translateY(0);
}

/* Selection disabled on viz elements */
.hex-viz, .viz-bar-chart, .viz-donut, .viz-area, .viz-scatter, .radial-gauge, .sparkline-decorator, .sparkline-large {
    user-select: none;
}
