/* ============================================
   xity.dev — Nostalgic Corporate Futurism
   Crystalline Data Dashboard
   ============================================ */

:root {
    --deep-bg: #0d1321;
    --module-bg: #1a1f2e;
    --surface: #1b2d3a;
    --accent-cyan: #3fb8af;
    --accent-jade: #7bc8a4;
    --accent-amber: #e8a838;
    --text-primary: #e8edf3;
    --text-secondary: #8899aa;
    --glass-edge: #2a3a4a;
    --accent-lavender: #9b72cf;
    --gutter: 8px;
    --ease-primary: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep-bg);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    letter-spacing: -0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Grid Overlay */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background-image:
        linear-gradient(rgba(63,184,175,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(63,184,175,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* Refraction Lines */
#refraction-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Prism Scatter */
#prism-scatter {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.prism-diamond {
    position: absolute;
    width: 8px;
    height: 8px;
    transform: rotate(45deg);
    opacity: 0.15;
}

/* Site Container */
#site-container {
    display: flex;
    max-width: 1440px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

/* Left Rail */
#left-rail {
    position: fixed;
    left: max(0px, calc((100vw - 1440px) / 2));
    top: 0;
    width: 80px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.rail-line {
    position: absolute;
    top: 10%;
    bottom: 10%;
    width: 2px;
    background: linear-gradient(
        to bottom,
        transparent,
        var(--glass-edge) 20%,
        var(--accent-cyan) 50%,
        var(--glass-edge) 80%,
        transparent
    );
    clip-path: polygon(0 0, 100% 2%, 100% 98%, 0 100%);
}

.rail-nav {
    display: flex;
    flex-direction: column;
    gap: 32px;
    position: relative;
    z-index: 2;
}

.rail-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.3s var(--ease-primary);
}

.rail-node:hover,
.rail-node.active {
    color: var(--accent-cyan);
}

.node-dot {
    width: 10px;
    height: 10px;
    border: 2px solid var(--glass-edge);
    background: var(--module-bg);
    transform: rotate(45deg);
    transition: all 0.3s var(--ease-primary);
    margin-bottom: 4px;
}

.rail-node:hover .node-dot,
.rail-node.active .node-dot {
    border-color: var(--accent-cyan);
    background: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(63,184,175,0.5);
}

.node-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    writing-mode: horizontal-tb;
}

/* Main Content */
#main-content {
    margin-left: 80px;
    flex: 1;
    padding: 0 24px;
    max-width: calc(1440px - 80px);
}

/* Section Frames */
.section-frame {
    min-height: 100vh;
    padding: 40px 0;
    display: flex;
    align-items: center;
}

/* Module Grid */
.module-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--gutter);
    width: 100%;
}

/* Module Sizes */
.module-12x6 { grid-column: span 12; }
.module-8x4 { grid-column: span 8; }
.module-8x3 { grid-column: span 8; }
.module-4x4 { grid-column: span 4; }
.module-4x3 { grid-column: span 4; }
.module-4x2 { grid-column: span 4; }

/* Module Base */
.module {
    position: relative;
    overflow: hidden;
}

.module-glass {
    background: rgba(26, 31, 46, 0.85);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 24px;
    height: 100%;
    position: relative;
    clip-path: polygon(
        0 0,
        calc(100% - 12px) 0,
        100% 12px,
        100% 100%,
        12px 100%,
        0 calc(100% - 12px)
    );
    transition: transform 0.6s var(--ease-primary), opacity 0.6s var(--ease-primary);
}

.module-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(63,184,175,0.05) 0%, transparent 50%, rgba(155,114,207,0.03) 100%);
    pointer-events: none;
}

/* Corner Brackets */
.corner-bracket {
    position: absolute;
    width: 16px;
    height: 16px;
    z-index: 5;
}

.corner-bracket::before,
.corner-bracket::after {
    content: '';
    position: absolute;
    background: var(--glass-edge);
}

.top-left { top: 4px; left: 4px; }
.top-left::before { width: 16px; height: 1px; top: 0; left: 0; }
.top-left::after { width: 1px; height: 16px; top: 0; left: 0; }

.top-right { top: 4px; right: 4px; }
.top-right::before { width: 16px; height: 1px; top: 0; right: 0; }
.top-right::after { width: 1px; height: 16px; top: 0; right: 0; }

.bottom-left { bottom: 4px; left: 4px; }
.bottom-left::before { width: 16px; height: 1px; bottom: 0; left: 0; }
.bottom-left::after { width: 1px; height: 16px; bottom: 0; left: 0; }

.bottom-right { bottom: 4px; right: 4px; }
.bottom-right::before { width: 16px; height: 1px; bottom: 0; right: 0; }
.bottom-right::after { width: 1px; height: 16px; bottom: 0; right: 0; }

/* Timestamp Watermarks */
.timestamp-watermark {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.15;
    letter-spacing: 0.05em;
}

/* Typography */
.wordmark {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: clamp(48px, 8vw, 96px);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    position: relative;
    z-index: 2;
}

.module-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 48px);
    color: var(--text-primary);
    margin-bottom: 16px;
}

.stat-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 36px;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 12px;
}

.stat-unit {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 2px;
}

/* Hero Section */
.hero-grid {
    min-height: 60vh;
}

.hero-wordmark .module-glass {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

#wordmark-container {
    position: relative;
    text-align: center;
}

#wordmark-fragments {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.wordmark-fragment {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    opacity: 0;
    transition: all 1.8s var(--ease-elastic);
}

.hero-tagline {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sparkline-inline {
    display: inline-block;
    vertical-align: middle;
}

/* Data Visualization */
.data-viz {
    width: 100%;
    margin-bottom: 16px;
}

.line-chart-container svg,
.polar-chart-container svg,
.network-container svg {
    width: 100%;
    height: auto;
}

.data-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2.5s var(--ease-primary);
}

.data-line.animate {
    stroke-dashoffset: 0;
}

/* Polar Chart */
.polar-petal {
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.8s var(--ease-primary), transform 0.8s var(--ease-primary);
}

.polar-petal.animate {
    opacity: 1;
}

/* Data Meta */
.data-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.data-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Sparklines */
.sparkline {
    width: 100%;
    height: 32px;
}

.sparkline svg {
    width: 100%;
    height: 100%;
}

.sparkline-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 2s var(--ease-primary);
}

.sparkline-path.animate {
    stroke-dashoffset: 0;
}

/* Crystalline Section */
.crystalline-glass {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
}

.crystalline-content {
    max-width: 600px;
}

.crystalline-text {
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1.7;
    margin-bottom: 32px;
}

.crystal-decoration {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.crystal-facet {
    opacity: 0;
    transition: opacity 1s var(--ease-primary);
}

.crystal-facet.animate {
    opacity: 1;
}

/* Crystalline dissolve animation */
.crystalline-module.dissolving .module-glass {
    transform: rotate(2deg) scale(0.98);
}

/* Network Section */
.network-container {
    min-height: 300px;
}

#network-graph {
    width: 100%;
    height: auto;
}

.network-node {
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.6s var(--ease-primary);
}

.network-node.animate {
    opacity: 1;
}

.network-edge {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s var(--ease-primary);
}

.network-edge.animate {
    stroke-dashoffset: 0;
}

/* Pulse animation for node connections */
@keyframes pulse-line {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

.network-edge.animate {
    animation: pulse-line 4s ease-in-out infinite;
    animation-delay: var(--pulse-delay, 0s);
}

/* Metrics List */
.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(42, 58, 74, 0.5);
}

.metric-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

.metric-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--accent-cyan);
}

/* Bar Chart */
.bar-chart-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    width: 48px;
    text-align: right;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 20px;
    background: rgba(42, 58, 74, 0.3);
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    transition: width 1.5s var(--ease-primary);
    clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 4px 100%, 0 calc(100% - 4px));
}

.bar-fill.animate {
    width: var(--bar-width);
}

.bar-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    width: 36px;
    flex-shrink: 0;
}

/* Reflection Section */
.reflection-glass {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
}

.reflection-content {
    max-width: 700px;
}

.reflection-text {
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1.7;
    margin-bottom: 32px;
}

.ghost-chart {
    width: 100%;
    max-width: 600px;
    height: auto;
    opacity: 0;
    transition: opacity 2s var(--ease-primary);
}

.ghost-chart.animate {
    opacity: 1;
}

.reflection-footer {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-edge);
}

.footer-brand {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 14px;
    color: var(--accent-cyan);
}

.footer-timestamp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Amber warm overlay for reflection */
.reflection-module .module-glass::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, rgba(232,168,56,0.06) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 2s var(--ease-primary);
}

.reflection-module.warm .module-glass::after {
    opacity: 1;
}

/* Frost halo hover effect */
.module-glass:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Module reveal animation */
.module {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s var(--ease-primary), transform 0.7s var(--ease-primary);
}

.module.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
    #left-rail {
        display: none;
    }
    #main-content {
        margin-left: 0;
        max-width: 100%;
    }
    .module-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .module-12x6 { grid-column: span 6; }
    .module-8x4 { grid-column: span 6; }
    .module-8x3 { grid-column: span 6; }
    .module-4x4 { grid-column: span 6; }
    .module-4x3 { grid-column: span 6; }
    .module-4x2 { grid-column: span 3; }
}

@media (max-width: 640px) {
    .module-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .module-12x6,
    .module-8x4,
    .module-8x3,
    .module-4x4,
    .module-4x3,
    .module-4x2 {
        grid-column: span 2;
    }
    .module-glass {
        padding: 16px;
    }
    #main-content {
        padding: 0 12px;
    }
    .wordmark {
        font-size: 36px;
    }
    .section-title {
        font-size: 24px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: no-preference) {
    .module {
        will-change: transform, opacity;
    }
    .parallax-layer {
        will-change: transform;
    }
}
