/* === BASE RESET === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --deep-bg: #0a1628;
    --surface: #111d30;
    --elevated: #1a2940;
    --text-headline: #c8d4e0;
    --text-body: #a8b8cc;
    --hud-chrome: #5a7090;
    --accent-cyan: #7ec8e3;
    --accent-brass: #d4a853;
    --divider-silver: #b8c6d4;
    --alert-coral: #d4735a;
    --label-blue: #6a8aaa;
    --grid-line: rgba(120, 140, 180, 0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep-bg);
    color: var(--text-body);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.2vw + 0.3rem, 1.2rem);
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* === SCANLINES OVERLAY === */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(10, 22, 40, 0.03) 2px,
        rgba(10, 22, 40, 0.03) 4px
    );
}

/* === HUD DISPLAY === */
.hud-display {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 0.8vw + 0.2rem, 0.8rem);
    color: var(--hud-chrome);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hud-depth, .hud-sector {
    display: block;
}

.hud-sector {
    color: var(--accent-cyan);
}

/* === HERO SECTION === */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    background: var(--deep-bg);
    display: flex;
    align-items: center;
    overflow: hidden;
}

.iso-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    animation: fadeInGrid 1.2s 0.4s forwards;
    background-image:
        repeating-linear-gradient(
            30deg,
            transparent,
            transparent 39px,
            var(--grid-line) 39px,
            var(--grid-line) 40px
        ),
        repeating-linear-gradient(
            -30deg,
            transparent,
            transparent 39px,
            var(--grid-line) 39px,
            var(--grid-line) 40px
        );
}

@keyframes fadeInGrid {
    to { opacity: 1; }
}

.hero-content {
    position: relative;
    z-index: 2;
    padding-left: 8%;
    opacity: 0;
    animation: heroContentIn 1s 1.8s forwards;
}

@keyframes heroContentIn {
    to { opacity: 1; }
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(3rem, 6vw + 1rem, 6rem);
    font-weight: 700;
    color: var(--text-headline);
    letter-spacing: -0.02em;
    text-shadow: 0 0 40px rgba(120, 160, 220, 0.15);
    animation: glowPulse 4s 2.5s infinite;
}

@keyframes glowPulse {
    0%, 100% { text-shadow: 0 0 40px rgba(120, 160, 220, 0.15); }
    50% { text-shadow: 0 0 60px rgba(120, 160, 220, 0.25); }
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 1vw + 0.2rem, 0.95rem);
    color: var(--hud-chrome);
    letter-spacing: 0.25em;
    margin-top: 1rem;
    opacity: 0;
    animation: fadeInGrid 0.8s 2.6s forwards;
}

/* === BAYESIAN CUBE === */
.bayesian-cube {
    position: absolute;
    right: 15%;
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    height: 200px;
    perspective: 800px;
    opacity: 0;
    animation: fadeInGrid 1.5s 2s forwards;
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(55deg) rotateY(0deg) rotateZ(-45deg);
    animation: cubeRotate 20s linear infinite;
}

@keyframes cubeRotate {
    from { transform: rotateX(55deg) rotateY(0deg) rotateZ(-45deg); }
    to { transform: rotateX(55deg) rotateY(360deg) rotateZ(-45deg); }
}

.cube-face {
    position: absolute;
    width: 120px;
    height: 120px;
    top: 50%;
    left: 50%;
    margin-top: -60px;
    margin-left: -60px;
    border: 1px solid rgba(126, 200, 227, 0.3);
}

.cube-front  { background: rgba(126, 200, 227, 0.2); transform: translateZ(60px); }
.cube-back   { background: rgba(126, 200, 227, 0.1); transform: translateZ(-60px); }
.cube-top    { background: rgba(126, 200, 227, 0.15); transform: rotateX(90deg) translateZ(60px); }
.cube-bottom { background: rgba(126, 200, 227, 0.05); transform: rotateX(-90deg) translateZ(60px); }
.cube-left   { background: rgba(126, 200, 227, 0.25); transform: rotateY(-90deg) translateZ(60px); }
.cube-right  { background: rgba(126, 200, 227, 0.35); transform: rotateY(90deg) translateZ(60px); }

/* === DATA BREACH DIVIDERS === */
.data-breach {
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--deep-bg), var(--divider-silver), var(--deep-bg));
    background-size: 200% 100%;
    animation: dataPulse 6s ease-in-out infinite;
    margin: clamp(4rem, 8vh, 8rem) 0;
}

@keyframes dataPulse {
    0%, 100% { background-position: 0% 0%; }
    50% { background-position: 100% 0%; }
}

/* === PLATEAUS === */
.plateau {
    position: relative;
    background: var(--surface);
    padding: clamp(2rem, 4vw, 4rem);
    transform: rotateX(2deg) rotateY(-1deg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.plateau.visible {
    opacity: 1;
}

.plateau-axioms {
    width: 90%;
    margin-left: 0;
}

.plateau-priors {
    width: 75%;
    margin-left: 8%;
}

.plateau-inference {
    width: 65%;
    margin-left: 5%;
}

.plateau-posteriors {
    width: 70%;
    margin-left: 10%;
}

.plateau-footer {
    width: 60%;
    margin-left: 5%;
    text-align: left;
}

/* === CORNER BRACKETS === */
.corner-bracket {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--hud-chrome);
    border-style: solid;
    border-width: 0;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.corner-tl { top: 8px; left: 8px; border-top-width: 2px; border-left-width: 2px; }
.corner-tr { top: 8px; right: 8px; border-top-width: 2px; border-right-width: 2px; }
.corner-bl { bottom: 8px; left: 8px; border-bottom-width: 2px; border-left-width: 2px; }
.corner-br { bottom: 8px; right: 8px; border-bottom-width: 2px; border-right-width: 2px; }

.plateau:hover .corner-bracket {
    width: 24px;
    height: 24px;
}

/* === COORD LABELS === */
.coord-label {
    position: absolute;
    top: 12px;
    left: 36px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--label-blue);
    letter-spacing: 0.05em;
}

/* === PLATEAU CONTENT === */
.plateau-content p {
    margin-bottom: 1.2em;
    max-width: 65ch;
}

.plateau-content p:last-child {
    margin-bottom: 0;
}

/* === DROP CAP === */
.drop-cap::first-letter {
    font-family: 'Playfair Display', serif;
    font-size: 4.5rem;
    float: left;
    line-height: 0.8;
    margin-right: 0.1em;
    margin-top: 0.05em;
    color: var(--accent-brass);
    font-weight: 700;
}

/* === TWO COLUMNS === */
.two-columns {
    display: flex;
    gap: clamp(2rem, 4vw, 4rem);
    align-items: flex-start;
}

.col-text {
    flex: 1;
}

.col-chart {
    flex: 0 0 160px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-top: 1rem;
}

/* === ISOMETRIC BAR CHART === */
.iso-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    transform: rotateX(55deg) rotateY(0deg) rotateZ(-45deg);
    height: 150px;
}

.iso-bar {
    width: 30px;
    background: var(--accent-cyan);
    border: 1px solid rgba(126, 200, 227, 0.5);
    transition: height 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.bar-1 { height: 60%; opacity: 0.6; }
.bar-2 { height: 90%; opacity: 0.8; }
.bar-3 { height: 45%; opacity: 0.4; }

/* === DECISION TREE === */
.decision-tree {
    margin-top: 2rem;
    position: relative;
}

.decision-tree svg {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.tree-branch {
    stroke: var(--hud-chrome);
    stroke-width: 1.5;
    fill: none;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.plateau-inference.visible .tree-branch {
    stroke-dashoffset: 0;
}

.tree-node {
    fill: var(--hud-chrome);
    cursor: pointer;
    transition: fill 0.3s;
}

.tree-node:hover {
    fill: var(--accent-cyan);
}

.tree-node-terminal {
    fill: var(--accent-brass);
}

.tree-node-terminal:hover {
    fill: var(--accent-cyan);
}

.tree-tooltip {
    position: absolute;
    background: var(--surface);
    border-left: 3px solid var(--accent-brass);
    padding: 8px 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-body);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
    z-index: 10;
}

.tree-tooltip.active {
    opacity: 1;
}

/* === AZIMUTH RINGS === */
.azimuth-rings {
    position: absolute;
    top: 50%;
    right: -10%;
    transform: translateY(-50%);
    width: 300px;
    height: 300px;
    pointer-events: none;
}

.ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.ring circle {
    fill: none;
    stroke: var(--accent-cyan);
    stroke-width: 1;
    stroke-dasharray: 4 8;
    opacity: 0.06;
}

.ring-1 {
    animation: ringRotate 40s linear infinite;
}

.ring-2 {
    animation: ringRotate 40s linear infinite reverse;
}

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

/* === FOOTER === */
.footer-text {
    font-family: 'Source Serif 4', serif;
    color: var(--text-body);
    margin-bottom: 0.5em;
}

.footer-mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 0.8vw + 0.2rem, 0.8rem);
    color: var(--hud-chrome);
    letter-spacing: 0.1em;
}

/* === HOVER STATES === */
.plateau:hover {
    transform: rotateX(2deg) rotateY(-1deg) translateY(-2px);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35), 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* === PROBABILITY DOT FIELD BACKGROUND === */
.plateau-posteriors {
    background-image: radial-gradient(circle, var(--elevated) 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: var(--surface);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .two-columns {
        flex-direction: column;
    }

    .col-chart {
        flex: none;
        width: 100%;
    }

    .bayesian-cube {
        right: 5%;
        width: 120px;
        height: 120px;
    }

    .cube-face {
        width: 80px;
        height: 80px;
        margin-top: -40px;
        margin-left: -40px;
    }

    .cube-front  { transform: translateZ(40px); }
    .cube-back   { transform: translateZ(-40px); }
    .cube-top    { transform: rotateX(90deg) translateZ(40px); }
    .cube-bottom { transform: rotateX(-90deg) translateZ(40px); }
    .cube-left   { transform: rotateY(-90deg) translateZ(40px); }
    .cube-right  { transform: rotateY(90deg) translateZ(40px); }

    .plateau-axioms,
    .plateau-priors,
    .plateau-inference,
    .plateau-posteriors,
    .plateau-footer {
        width: 95%;
        margin-left: 2.5%;
    }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
