/* =============================================
   Chloengine.com v2 - Engine Viewport Aesthetic
   ============================================= */

/* Color Palette:
   Void Black:      #08080f
   Electric Cyan:   #00e5ff
   Emission Amber:  #ffb347
   Wireframe Teal:  #1a3a4a
   Panel Dark:      #0d1a24
   Ghost White:     #e0e8f0
   Compile Green:   #39ff14
   Depth Gray:      #1c1c2e
*/

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

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

body {
    background: #08080f;
    color: #e0e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* =============================================
   HUD OVERLAY (persistent)
   ============================================= */

#hud-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#hud-overlay.active {
    opacity: 0.6;
}

#hud-overlay.scrolling {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

#hud-overlay.idle {
    opacity: 0.3;
    transition: opacity 2s ease;
}

#hud-top-left {
    position: absolute;
    top: 20px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hud-domain {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #e0e8f0;
    line-height: 1.3;
}

.hud-cursor {
    animation: cursorBlink 1s step-end infinite;
    color: #00e5ff;
}

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

.hud-fps {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 11px;
    color: #1a3a4a;
    line-height: 1.3;
}

#hud-top-right {
    position: absolute;
    top: 20px;
    right: 24px;
}

.hud-coords {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 11px;
    color: #1a3a4a;
    line-height: 1.3;
}

#hud-bottom-left {
    position: absolute;
    bottom: 20px;
    left: 24px;
}

#hud-frame-graph {
    opacity: 0.7;
}

/* Scan-line overlay for HUD elements */
#hud-top-left::after,
#hud-top-right::after,
#hud-bottom-left::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 1px,
        rgba(0, 229, 255, 0.02) 1px,
        rgba(0, 229, 255, 0.02) 2px
    );
    pointer-events: none;
}

#hud-top-left,
#hud-top-right,
#hud-bottom-left {
    position: absolute;
}

/* =============================================
   VIEWPORT SECTIONS (base)
   ============================================= */

.viewport-section {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* =============================================
   SECTION 1: ENGINE BOOT
   ============================================= */

#section-boot {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #08080f;
}

#compile-log {
    position: absolute;
    top: 56px;
    left: 24px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 11px;
    line-height: 1.5;
    color: #39ff14;
    white-space: pre-wrap;
    max-width: 400px;
    opacity: 0;
    z-index: 10;
    transition: opacity 0.5s ease;
}

#compile-log.visible {
    opacity: 1;
}

/* Wireframe Cube */
#wireframe-cube-container {
    perspective: 800px;
    width: 200px;
    height: 200px;
    opacity: 0;
    transition: opacity 1s ease-out;
}

#wireframe-cube-container.visible {
    opacity: 1;
}

#wireframe-cube {
    width: 200px;
    height: 200px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(15deg) rotateY(0deg);
    animation: cubeRotate 20s linear infinite;
}

@keyframes cubeRotate {
    from { transform: rotateX(15deg) rotateY(0deg); }
    to { transform: rotateX(15deg) rotateY(360deg); }
}

.cube-face {
    position: absolute;
    width: 200px;
    height: 200px;
    border: 1px solid #00e5ff;
    background: transparent;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
}

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

/* Radial glow behind the cube */
#section-boot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 500px;
    height: 500px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(0, 229, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

#wireframe-cube-container {
    z-index: 1;
}

/* =============================================
   SECTION 2: GRID UNFOLD + HUD PANELS
   ============================================= */

#section-grid {
    min-height: 200vh;
    background: #08080f;
    position: relative;
}

#grid-plane {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    background:
        linear-gradient(rgba(26, 58, 74, 0.3) 0.5px, transparent 0.5px),
        linear-gradient(90deg, rgba(26, 58, 74, 0.3) 0.5px, transparent 0.5px);
    background-size: 60px 60px;
    background-position: center center;
    transform: perspective(800px) rotateX(40deg);
    transform-origin: center 60%;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#grid-plane.visible {
    opacity: 1;
}

#hud-panels {
    position: absolute;
    top: 10vh;
    left: 0;
    width: 100%;
    height: 180vh;
    z-index: 10;
}

.hud-panel {
    position: absolute;
    background: rgba(13, 26, 36, 0.85);
    border: 1px solid rgba(0, 229, 255, 0.6);
    padding: 24px 28px;
    max-width: 340px;
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

.hud-panel:hover {
    border-color: rgba(0, 229, 255, 1);
    box-shadow: inset 0 0 30px rgba(0, 229, 255, 0.05);
    pointer-events: auto;
}

.hud-panel.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.hud-panel[data-panel="0"] { top: 5%; left: 8%; }
.hud-panel[data-panel="1"] { top: 15%; right: 10%; left: auto; }
.hud-panel[data-panel="2"] { top: 35%; left: 15%; }
.hud-panel[data-panel="3"] { top: 50%; right: 8%; left: auto; }
.hud-panel[data-panel="4"] { top: 65%; left: 5%; }

.panel-label {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #00e5ff;
    display: block;
    margin-bottom: 12px;
}

.panel-body {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    color: #e0e8f0;
    opacity: 0.85;
}

/* Vertex connection lines */
#vertex-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.vertex-line {
    stroke: #00e5ff;
    stroke-width: 0.15;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    opacity: 0.4;
    animation: vertexPulse 3s ease-in-out infinite;
    transition: stroke-dashoffset 2s ease;
    will-change: stroke-dashoffset;
}

.vertex-line.drawn {
    stroke-dashoffset: 0;
}

@keyframes vertexPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* =============================================
   SECTION 3: PARTICLE FIELD + TYPOGRAPHY
   ============================================= */

#section-particles {
    min-height: 300vh;
    background: #08080f;
    position: relative;
}

#particle-field {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #ffb347;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.particle.active {
    opacity: 0.7;
}

@keyframes particleDrift10 {
    from { transform: translateY(0); }
    to { transform: translateY(-110vh); }
}
@keyframes particleDrift13 {
    from { transform: translateY(0); }
    to { transform: translateY(-110vh); }
}
@keyframes particleDrift17 {
    from { transform: translateY(0); }
    to { transform: translateY(-110vh); }
}
@keyframes particleDrift21 {
    from { transform: translateY(0); }
    to { transform: translateY(-110vh); }
}
@keyframes particleDrift27 {
    from { transform: translateY(0); }
    to { transform: translateY(-110vh); }
}

#typographic-statements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300vh;
    z-index: 10;
    pointer-events: none;
}

.type-statement {
    position: absolute;
    width: 100%;
    text-align: center;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: clamp(40px, 8vw, 96px);
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-transform: uppercase;
    color: #e0e8f0;
    opacity: 0;
    filter: blur(6px);
    transition: opacity 0.8s ease-out, filter 0.8s ease-out;
    padding: 0 5vw;
    display: flex;
    align-items: center;
    justify-content: center;
}

.type-statement.visible {
    opacity: 1;
    filter: blur(0);
}

.type-statement.fading {
    opacity: 0;
    filter: blur(0);
    transition: opacity 0.4s ease;
}

.type-statement[data-statement="0"] { top: 10vh; height: 60vh; }
.type-statement[data-statement="1"] { top: 80vh; height: 60vh; }
.type-statement[data-statement="2"] { top: 155vh; height: 60vh; }
.type-statement[data-statement="3"] { top: 230vh; height: 60vh; }

/* =============================================
   SECTION 4: DEBUG CARDS
   ============================================= */

#section-cards {
    min-height: 200vh;
    background: #08080f;
    position: relative;
    padding: 10vh 5vw;
}

#debug-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    max-width: 1100px;
    margin: 0 auto;
}

.debug-card {
    position: relative;
    background: rgba(13, 26, 36, 0.9);
    border: 1px solid rgba(0, 229, 255, 0.4);
    padding: 28px 24px;
    transform: perspective(800px) rotateY(-2deg) rotateX(1deg) translateY(80px);
    opacity: 0;
    transition: opacity 0.7s ease, transform 0.7s ease;
    overflow: hidden;
}

.debug-card.visible {
    opacity: 1;
    transform: perspective(800px) rotateY(-2deg) rotateX(1deg) translateY(0);
}

.debug-card:hover {
    border-color: rgba(0, 229, 255, 0.8);
}

.card-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 1px,
        rgba(0, 229, 255, 0.02) 1px,
        rgba(0, 229, 255, 0.02) 2px
    );
    pointer-events: none;
    z-index: 1;
}

.card-title {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #00e5ff;
    display: block;
    margin-bottom: 16px;
    position: relative;
    z-index: 2;
}

.card-code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    color: #e0e8f0;
    opacity: 0.8;
    position: relative;
    z-index: 2;
    white-space: pre;
    overflow-x: auto;
}

.card-code code {
    font-family: inherit;
}

/* =============================================
   SECTION 5: CLOSING / CONVERGENCE
   ============================================= */

#section-closing {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #08080f;
    position: relative;
}

/* Radial glow behind the orb */
#section-closing::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 179, 71, 0.08) 0%, transparent 60%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

#section-closing.active::before {
    opacity: 1;
}

#convergence-orb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffb347;
    box-shadow: 0 0 40px rgba(255, 179, 71, 0.5), 0 0 80px rgba(255, 179, 71, 0.2);
    opacity: 0;
    transform: scale(0);
    transition: opacity 1s ease, transform 1s ease;
    margin-bottom: 40px;
}

#convergence-orb.visible {
    opacity: 1;
    transform: scale(1);
}

#convergence-orb.pulse {
    animation: orbPulse 0.6s ease;
}

@keyframes orbPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#closing-title {
    text-align: center;
    opacity: 0;
    transition: opacity 1s ease;
}

#closing-title.visible {
    opacity: 1;
}

#engine-name {
    display: block;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: clamp(36px, 6vw, 72px);
    letter-spacing: 2em;
    color: #e0e8f0;
    transition: letter-spacing 1.5s ease;
    white-space: nowrap;
    overflow: hidden;
}

#engine-name.compiled {
    letter-spacing: 0.05em;
}

#engine-version {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 14px;
    color: #1a3a4a;
    margin-top: 16px;
    letter-spacing: 0.1em;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
    #debug-cards {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .hud-panel {
        max-width: 280px;
        padding: 16px 20px;
    }

    .hud-panel[data-panel="1"],
    .hud-panel[data-panel="3"] {
        right: 4%;
    }

    #engine-name {
        font-size: clamp(28px, 6vw, 72px);
    }

    .type-statement {
        padding: 0 8vw;
    }
}
