:root {
    --grid: 8px;
    --grid-2: 16px;
    --grid-4: 32px;
    --grid-8: 64px;
    --grid-16: 128px;
    --void-black: #0d0d0d;
    --deep-indigo: #1a0a2e;
    --neon-cyan: #00ffcc;
    --neon-magenta: #ff006e;
    --electric-blue: #3a86ff;
    --ash-gray: #b8b8b8;
    --pale-neon: #e0fff5;
    --bruise-purple: #2d1b4e;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    background: var(--void-black);
    color: var(--ash-gray);
    font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Grid Overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background:
        repeating-linear-gradient(90deg, rgba(0,255,204,0.04) 0px, rgba(0,255,204,0.04) 1px, transparent 1px, transparent 64px),
        repeating-linear-gradient(0deg, rgba(0,255,204,0.04) 0px, rgba(0,255,204,0.04) 1px, transparent 1px, transparent 64px);
}

/* Typography */
.display-heading {
    font-family: 'Zilla Slab', 'Rockwell', serif;
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    color: var(--pale-neon);
    letter-spacing: 0.02em;
    text-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
    margin-bottom: var(--grid-4);
}

.display-heading-sm {
    font-family: 'Zilla Slab', 'Rockwell', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    color: var(--pale-neon);
    letter-spacing: 0.02em;
    margin-bottom: var(--grid-4);
}

.display-heading-lg {
    font-family: 'Zilla Slab', 'Rockwell', serif;
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 4rem);
    color: var(--pale-neon);
    letter-spacing: 0.02em;
    text-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

.body-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    color: var(--ash-gray);
    margin-bottom: var(--grid-2);
    max-width: 50ch;
}

.body-text-sm {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--ash-gray);
    line-height: 1.6;
    margin-bottom: var(--grid);
}

.mono-label {
    font-family: 'IBM Plex Mono', 'Consolas', monospace;
    font-weight: 400;
    font-size: 14px;
    color: var(--neon-magenta);
    background: rgba(0, 255, 204, 0.08);
    padding: 2px 6px;
    display: inline-block;
}

/* Header Bar */
.header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--grid-8);
    background: rgba(13, 13, 13, 0.95);
    border-bottom: 1px solid rgba(0, 255, 204, 0.15);
    z-index: 100;
    display: flex;
    align-items: center;
}

.header-inner {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--grid-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--pale-neon);
    letter-spacing: 0.02em;
}

.status-indicators {
    display: flex;
    gap: var(--grid);
}

.status-dot {
    width: var(--grid);
    height: var(--grid);
    display: block;
}

.dot-magenta { background: var(--neon-magenta); animation: pulse-status 4s ease-in-out infinite; }
.dot-cyan { background: var(--neon-cyan); animation: pulse-status 4s ease-in-out 1.3s infinite; }
.dot-blue { background: var(--electric-blue); animation: pulse-status 4s ease-in-out 2.6s infinite; }

@keyframes pulse-status {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Zones */
.zone {
    padding: var(--grid-16) var(--grid-2);
    position: relative;
}

.zone-inner {
    max-width: 720px;
    margin: 0 auto;
}

/* Thesis Block */
.thesis-block {
    min-height: 480px;
    padding-top: calc(var(--grid-8) + var(--grid-8));
}

.thesis-watercolor {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 25% 30%, rgba(45, 27, 78, 0.6) 0%, transparent 70%),
        radial-gradient(ellipse at 75% 60%, rgba(26, 10, 46, 0.4) 0%, transparent 65%);
    pointer-events: none;
    background-attachment: fixed;
}

.thesis-layout {
    display: flex;
    gap: var(--grid-4);
    align-items: center;
    position: relative;
    z-index: 2;
}

.thesis-visual {
    flex: 0 0 60%;
}

.logic-gate-tree {
    width: 100%;
    max-width: 320px;
}

.thesis-text {
    flex: 1;
}

/* Card Matrix */
.card-matrix {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(26, 10, 46, 0.3) 0%, transparent 60%),
        var(--void-black);
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--grid-2);
}

.card {
    perspective: 1000px;
    height: 280px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover .card-inner,
.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: var(--void-black);
    border: 2px solid var(--neon-cyan);
    padding: var(--grid-4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow:
        0 0 8px rgba(0, 255, 204, 0.3),
        0 0 24px rgba(0, 255, 204, 0.1);
}

.card-back {
    transform: rotateY(180deg);
    align-items: flex-start;
}

.card-icon {
    width: 48px;
    height: 48px;
    margin-bottom: var(--grid-2);
}

.card-title {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--pale-neon);
}

/* Logic Flow */
.logic-flow {
    background: var(--void-black);
}

.flow-sequence {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.flow-node {
    display: flex;
    gap: var(--grid-4);
    align-items: center;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.flow-node.visible {
    opacity: 1;
    transform: translateY(0);
}

.node-right {
    flex-direction: row-reverse;
    text-align: right;
}

.node-right .body-text {
    margin-left: auto;
}

.node-icon {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.flow-title {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--pale-neon);
    margin-bottom: var(--grid);
}

.flow-connector {
    width: 2px;
    height: var(--grid-8);
    background: var(--neon-magenta);
    margin-left: 39px;
}

/* Terminus */
.terminus {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

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

.cursor-blink {
    width: var(--grid);
    height: var(--grid-2);
    background: var(--neon-cyan);
    margin: var(--grid-2) auto 0;
    animation: blink-cursor 1s step-end infinite;
}

@keyframes blink-cursor {
    0%, 60% { opacity: 1; }
    61%, 100% { opacity: 0; }
}

.binary-rain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.binary-col {
    position: absolute;
    top: 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--neon-cyan);
    opacity: 0.05;
    line-height: 1.4;
    white-space: pre;
    animation: rain-fall linear infinite;
}

@keyframes rain-fall {
    from { transform: translateY(-100%); }
    to { transform: translateY(100vh); }
}

/* Responsive */
@media (max-width: 768px) {
    .thesis-layout {
        flex-direction: column;
    }
    .thesis-visual {
        flex: none;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
    .flow-node, .node-right {
        flex-direction: column;
        text-align: center;
    }
    .node-right .body-text {
        margin-left: 0;
    }
    .flow-connector {
        margin-left: auto;
        margin-right: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dot-magenta, .dot-cyan, .dot-blue { animation: none; opacity: 0.7; }
    .cursor-blink { animation: none; }
    .binary-col { animation: none; }
    .card-inner { transition: none; }
    .flow-node { opacity: 1; transform: none; transition: none; }
}
