/* ========================================
   relative.quest - Glassmorphic Circuit Labyrinth
   Monochrome palette, z-pattern layout, tilt-3d
   Fonts: "IBM Plex Mono" (Google Fonts) circuit-precise headings.
   Body: "Inter" (Google Fonts) humanist sans.
   ======================================== */

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

/* Custom properties from DESIGN.md palette */
:root {
    --soft-black: #121218;
    --pure-white: #F0F0F5;
    --medium-gray: #888888;
    --dark-gray: #2A2A30;
    --light-gray: #CCCCCC;
    --dim-white: #555560;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-blur: 16px;
}

/* Body */
body {
    background: var(--soft-black);
    color: var(--pure-white);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.8;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ========================================
   Circuit Background
   ======================================== */
#circuit-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#circuit-svg {
    width: 100%;
    height: 100%;
}

.circuit-line {
    fill: none;
    stroke: var(--light-gray);
    stroke-width: 1;
    opacity: 0.25;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: circuit-draw 3s ease forwards;
}

.circuit-line-1 { animation-delay: 0.2s; }
.circuit-line-2 { animation-delay: 0.8s; }
.circuit-line-3 { animation-delay: 1.4s; }

@keyframes circuit-draw {
    to { stroke-dashoffset: 0; }
}

.circuit-node {
    fill: var(--light-gray);
    opacity: 0;
    animation: node-appear 0.4s ease forwards;
}

.circuit-node:nth-child(4) { animation-delay: 0.6s; }
.circuit-node:nth-child(5) { animation-delay: 1.2s; }
.circuit-node:nth-child(6) { animation-delay: 1.8s; }
.circuit-node:nth-child(7) { animation-delay: 2.4s; }

@keyframes node-appear {
    to { opacity: 0.4; }
}

/* ========================================
   Scan-line Overlay
   ======================================== */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.015) 2px,
        rgba(255, 255, 255, 0.015) 4px
    );
}

/* ========================================
   Z-Pattern Labyrinth Layout
   ======================================== */
#labyrinth {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem 6rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 8vh 3rem 10vh;
    min-height: 100vh;
    align-content: center;
}

/* Z-pattern: panels alternate left/right */
.panel-1 { grid-column: 1; }
.panel-2 { grid-column: 2; }
.panel-3 { grid-column: 1; }
.panel-4 { grid-column: 2; }

/* ========================================
   Glassmorphic Panels
   ======================================== */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2.5rem 2.5rem 2rem;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    perspective: 1000px;
    will-change: transform;
}

.glass-panel::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
}

/* Circuit connector stubs on panels */
.panel-1::after,
.panel-2::after,
.panel-3::after,
.panel-4::after {
    content: '';
    position: absolute;
    background: var(--light-gray);
    opacity: 0.2;
}

/* Right-side connector for left panels */
.panel-1::after {
    top: 50%;
    right: -3rem;
    width: 3rem;
    height: 1px;
}

.panel-3::after {
    top: 50%;
    right: -3rem;
    width: 3rem;
    height: 1px;
}

/* Left-side connector for right panels */
.panel-2::after {
    top: 50%;
    left: -3rem;
    width: 3rem;
    height: 1px;
}

.panel-4::after {
    top: 50%;
    left: -3rem;
    width: 3rem;
    height: 1px;
}

/* Hover glow */
.glass-panel:hover {
    box-shadow:
        0 0 30px rgba(255, 255, 255, 0.04),
        inset 0 0 30px rgba(255, 255, 255, 0.02);
}

/* ========================================
   Typography
   ======================================== */

/* Display / Headings - IBM Plex Mono */
.glitch-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 600;
    color: var(--pure-white);
    margin-bottom: 1rem;
    position: relative;
    text-shadow:
        2px 0 rgba(255, 255, 255, 0.3),
        -2px 0 rgba(200, 200, 200, 0.2);
    animation: glitch-flicker 6s infinite;
}

h2.glitch-text {
    font-size: clamp(1.2rem, 2.4vw, 1.8rem);
}

@keyframes glitch-flicker {
    0%, 92%, 94%, 100% {
        text-shadow:
            2px 0 rgba(255, 255, 255, 0.3),
            -2px 0 rgba(200, 200, 200, 0.2);
    }
    93% {
        text-shadow:
            -3px 0 rgba(255, 255, 255, 0.5),
            3px 0 rgba(200, 200, 200, 0.3);
    }
    93.5% {
        text-shadow:
            4px 0 rgba(255, 255, 255, 0.2),
            -1px 0 rgba(200, 200, 200, 0.4);
    }
}

/* Body Text - Inter */
.body-text {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.8;
    color: var(--medium-gray);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    #labyrinth {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        padding: 6vh 1.5rem 8vh;
    }

    .panel-1, .panel-2, .panel-3, .panel-4 {
        grid-column: 1;
    }

    .glass-panel::after {
        display: none;
    }

    .glass-panel {
        padding: 2rem 1.5rem 1.5rem;
    }

    #circuit-bg {
        display: none;
    }
}

@media (max-width: 480px) {
    .glitch-text {
        font-size: 1.3rem;
    }

    h2.glitch-text {
        font-size: 1.1rem;
    }

    .body-text {
        font-size: 0.95rem;
    }
}
