/* ============================================
   확률.com — Goblincore Probability Lab
   Layered-depth terrarium aesthetic
   ============================================ */

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

html, body {
    width: 100%;
    height: 100%;
    background: #0f0f0a;
    color: #e8e5d8;
    font-family: 'Barlow', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* ============================================
   SCROLL & LAYOUT FOUNDATION
   ============================================ */

body {
    position: relative;
    --scroll-y: 0px;
}

/* ============================================
   LAYER SYSTEM (Z-Index Tiers)
   ============================================ */

.layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.layer-0 {
    z-index: 0;
    --parallax-speed: 0.2;
}

.layer-1 {
    z-index: 10;
    pointer-events: auto;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
}

.layer-2 {
    z-index: 20;
    --parallax-speed: 1.4;
}

.layer-3 {
    z-index: 30;
    --parallax-speed: 0.6;
}

/* Content wrapper for layer 1 */
.content-wrapper {
    position: relative;
    width: 100%;
    padding: 100vh 0;
}

/* ============================================
   SECTION STRUCTURE
   ============================================ */

.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    scroll-margin-top: 60px;
}

.section-hero {
    min-height: 150vh;
    justify-content: flex-start;
    padding-top: 20vh;
}

.section-specimens {
    padding: 80px 20px;
}

.section-experiments {
    padding: 80px 20px;
}

.section-ecosystem {
    padding: 80px 20px;
}

.section-final {
    min-height: 150vh;
    justify-content: center;
    padding-bottom: 50vh;
}

/* ============================================
   SECTION TITLES
   ============================================ */

.section-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: #39ff14;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 60px;
    text-align: center;
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.4);
}

/* ============================================
   ORGANIC BLOB CONTAINERS (clip-path)
   ============================================ */

.blob-frame {
    position: relative;
    padding: 40px;
    border: 2px solid #39ff14;
    background: #1e1c15;
    color: #e8e5d8;
    box-shadow: 
        0 0 10px rgba(57, 255, 20, 0.3),
        0 0 20px rgba(57, 255, 20, 0.15),
        inset 0 0 20px rgba(57, 255, 20, 0.05);
    animation: neonPulse 3s ease-in-out infinite;
    overflow: hidden;
}

.blob-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    clip-path: polygon(
        5% 0%, 95% 2%, 98% 8%, 100% 20%, 98% 35%, 95% 50%,
        98% 65%, 100% 80%, 98% 92%, 95% 98%, 85% 100%, 70% 99%,
        50% 100%, 30% 99%, 15% 100%, 5% 98%, 2% 92%, 0% 80%,
        2% 65%, 0% 50%, 2% 35%, 0% 20%, 2% 8%, 5% 2%
    );
    background: inherit;
    pointer-events: none;
    z-index: -1;
}

@keyframes neonPulse {
    0%, 100% {
        border-color: #39ff14;
        box-shadow: 
            0 0 10px rgba(57, 255, 20, 0.3),
            0 0 20px rgba(57, 255, 20, 0.15),
            inset 0 0 20px rgba(57, 255, 20, 0.05);
    }
    50% {
        border-color: #ff00ff;
        box-shadow: 
            0 0 10px rgba(255, 0, 255, 0.3),
            0 0 20px rgba(255, 0, 255, 0.15),
            inset 0 0 20px rgba(255, 0, 255, 0.05);
    }
}

/* ============================================
   BLOB CONTENT TYPOGRAPHY
   ============================================ */

.blob-label {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    color: #39ff14;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
    display: block;
}

.blob-subtitle {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: clamp(0.75rem, 1vw, 0.85rem);
    color: #00ffff;
    letter-spacing: 0.15em;
    margin-bottom: 16px;
    display: block;
}

.blob-desc {
    font-family: 'Barlow', sans-serif;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    color: #e8e5d8;
    line-height: 1.72;
    margin-bottom: 0;
}

.blob-content {
    display: block;
}

.blob-content p {
    margin-bottom: 16px;
    color: #e8e5d8;
}

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

/* ============================================
   SPECIMEN FORMULA DISPLAY
   ============================================ */

.specimen-formula {
    font-family: 'Fira Code', monospace;
    font-size: clamp(0.75rem, 1vw, 0.85rem);
    color: #00ffff;
    margin-top: 20px;
    padding: 12px 8px;
    background: rgba(0, 255, 255, 0.05);
    border-left: 2px solid #00ffff;
    letter-spacing: 0.02em;
    display: inline-block;
}

/* ============================================
   HERO BLOB (Center, Larger)
   ============================================ */

.blob-hero {
    max-width: 600px;
    text-align: center;
    margin: 0 auto;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
}

.blob-hero .blob-label {
    font-size: clamp(3rem, 9vw, 7rem);
    color: #39ff14;
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
}

.blob-hero .blob-subtitle {
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
}

.blob-hero .blob-desc {
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    max-width: 90%;
    margin: 0 auto;
}

/* ============================================
   SPECIMENS GRID
   ============================================ */

.specimens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.blob-specimen {
    max-width: 100%;
}

.blob-specimen .blob-label {
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
}

.blob-specimen .blob-content {
    font-size: clamp(0.85rem, 1.2vw, 0.95rem);
}

/* ============================================
   EXPERIMENTS CONTAINER
   ============================================ */

.experiments-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.blob-experiment {
    flex: 1;
    min-width: 280px;
    max-width: 350px;
}

/* ============================================
   ECOSYSTEM BLOB (Wide)
   ============================================ */

.blob-ecosystem {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.blob-ecosystem .blob-content p {
    text-align: left;
    margin-bottom: 20px;
}

/* ============================================
   FINAL BLOB
   ============================================ */

.blob-final {
    max-width: 700px;
    text-align: center;
    margin: 0 auto;
}

.blob-final .blob-label {
    font-size: clamp(2.5rem, 7vw, 5rem);
}

.blob-final .blob-subtitle {
    font-size: clamp(0.9rem, 1.8vw, 1.3rem);
}

/* ============================================
   BLOB LAYER SVG
   ============================================ */

.blob-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Layer 0 background circles (low opacity, slow movement) */
#bg-blobs circle {
    fill: #0f0f0a;
    opacity: 0.05;
    filter: blur(2px);
}

/* Layer 2 foreground circles (higher opacity, faster movement) */
#foreground-blobs circle {
    opacity: 0.2;
    filter: blur(1px);
    mix-blend-mode: screen;
}

/* Layer 3 particles (max blur, atmospheric) */
#particle-system {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.3;
    filter: blur(4px);
}

/* ============================================
   SHAKE-ERROR ANIMATION
   ============================================ */

@keyframes shake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(-6px) rotate(-1deg);
    }
    75% {
        transform: translateX(6px) rotate(1deg);
    }
}

.blob-frame.shake-error {
    animation: shake 400ms ease-in-out forwards;
}

/* Color shift on shake */
.blob-frame.shake-error-color-1 {
    border-color: #ff00ff;
    box-shadow: 
        0 0 10px rgba(255, 0, 255, 0.3),
        0 0 20px rgba(255, 0, 255, 0.15),
        inset 0 0 20px rgba(255, 0, 255, 0.05);
}

.blob-frame.shake-error-color-2 {
    border-color: #00ffff;
    box-shadow: 
        0 0 10px rgba(0, 255, 255, 0.3),
        0 0 20px rgba(0, 255, 255, 0.15),
        inset 0 0 20px rgba(0, 255, 255, 0.05);
}

.blob-frame.shake-error-color-3 {
    border-color: #ffaa00;
    box-shadow: 
        0 0 10px rgba(255, 170, 0, 0.3),
        0 0 20px rgba(255, 170, 0, 0.15),
        inset 0 0 20px rgba(255, 170, 0, 0.05);
}

/* ============================================
   DEPTH OF FIELD EFFECTS
   ============================================ */

.layer-0 {
    filter: blur(2px);
    opacity: 0.3;
}

.layer-1 {
    filter: none;
    opacity: 1;
}

.layer-2 {
    filter: blur(1px);
    opacity: 0.25;
}

.layer-3 {
    filter: blur(4px);
    opacity: 0.15;
}

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

@media (max-width: 768px) {
    .specimens-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .blob-frame {
        padding: 30px;
    }

    .blob-label {
        font-size: clamp(1.1rem, 3vw, 1.5rem);
    }

    .section-title {
        font-size: clamp(1.5rem, 4vw, 2.2rem);
        margin-bottom: 40px;
    }

    .experiments-container {
        flex-direction: column;
        align-items: stretch;
    }

    .blob-experiment {
        max-width: 100%;
    }
}

/* ============================================
   ACCESSIBILITY: Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .blob-frame {
        animation: none;
        border-color: #39ff14;
    }

    .particle {
        animation: none;
    }

    .blob-frame.shake-error {
        animation: none;
    }

    #bg-blobs circle,
    #foreground-blobs circle {
        animation: none;
    }

    .particle-system {
        animation: none;
    }
}

/* ============================================
   SCROLL BEHAVIOR
   ============================================ */

#layer-1 {
    scroll-behavior: smooth;
}

/* ============================================
   PRINT MEDIA
   ============================================ */

@media print {
    .layer-0, .layer-2, .layer-3 {
        display: none;
    }

    .layer-1 {
        position: static;
        height: auto;
        overflow: visible;
    }

    .section {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
