/* =============================================
   ethica.dev — Techno-Mycological Ethics
   ============================================= */

:root {
    --void: #0a0b0f;
    --bark: #141519;
    --mycelium: #00e5c3;
    --spore: #ff2d7b;
    --amber: #ffaa00;
    --lichen: #c8ccd4;
    --moss: #5a5f6b;
    --canopy: #1a1d24;

    --font-primary: 'Space Grotesk', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --font-serif: 'Cormorant Garamond', serif;

    --space-1: 1.618rem;
    --space-2: 2.618rem;
    --space-3: 4.236rem;
    --space-4: 6.854rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--void);
    color: var(--lichen);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   GLOBAL OVERLAYS
   ============================================= */

#noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.035;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    animation: noise-shift 0.5s steps(1) infinite;
}

@keyframes noise-shift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-2px, 3px); }
    50% { transform: translate(3px, -1px); }
    75% { transform: translate(-1px, -2px); }
    100% { transform: translate(0, 0); }
}

#golden-line {
    position: fixed;
    left: 61.8%;
    top: 0;
    width: 1px;
    height: 100vh;
    background: rgba(0, 229, 195, 0.04);
    pointer-events: none;
    z-index: 999;
}

#spore-dots {
    position: fixed;
    left: 0;
    top: 0;
    width: 20px;
    height: 100%;
    pointer-events: none;
    z-index: 998;
}

.spore-dot {
    position: absolute;
    left: 8px;
    width: 4px;
    height: 4px;
    background: var(--amber);
    opacity: 0.5;
    display: block;
}

#ripple-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 997;
}

.ripple {
    position: absolute;
    border: 1px solid var(--mycelium);
    width: 0;
    height: 0;
    transform: translate(-50%, -50%);
    animation: ripple-expand 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none;
}

@keyframes ripple-expand {
    from {
        width: 0;
        height: 0;
        opacity: 0.6;
    }
    to {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* =============================================
   STRATUM BASE
   ============================================= */

.stratum {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: var(--void);
}

.stratum-stamp {
    position: absolute;
    bottom: var(--space-1);
    right: var(--space-1);
    font-family: var(--font-mono);
    font-size: clamp(0.55rem, 0.8vw, 0.7rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--moss);
    opacity: 0.6;
}

.stratum-stamp-light {
    color: var(--moss);
}

/* =============================================
   TYPOGRAPHY
   ============================================= */

.display-headline {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 3.8rem);
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--lichen);
    text-transform: lowercase;
}

.body-text {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--lichen);
    max-width: 32ch;
}

.meta-label {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--moss);
}

.quote-text {
    font-family: var(--font-serif);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    line-height: 1.45;
    color: var(--spore);
    max-width: 32ch;
}

.node-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    fill: var(--moss);
}

/* =============================================
   STRATUM 0 — THE SURFACE
   ============================================= */

#stratum-0 {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stratum-0-content {
    position: relative;
    text-align: center;
    z-index: 2;
    padding: var(--space-2);
}

.stratum-0-content .display-headline {
    font-size: clamp(2rem, 4vw, 3.6rem);
    position: relative;
    z-index: 2;
}

.stratum-0-content .meta-label {
    margin-top: var(--space-2);
    position: relative;
    z-index: 2;
}

.mycelium-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 600px;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at 50% 50%, rgba(0, 229, 195, 0.08) 0%, transparent 40%);
    animation: pulse-spread 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes pulse-spread {
    0%, 100% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.6;
    }
    50% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.stratum-bottom-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--mycelium);
    opacity: 0.08;
    animation: line-pulse 4s ease-in-out infinite;
}

@keyframes line-pulse {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.15; }
}

/* =============================================
   STRATUM 1 — ROOT ARGUMENTS
   ============================================= */

#stratum-1 {
    min-height: 120vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--void) 0%, var(--bark) 50%, var(--void) 100%);
}

.stratum-1-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-4) var(--space-2);
    padding-top: 38.2%;
}

.root-proposition {
    margin-bottom: var(--space-3);
}

.root-proposition:last-child {
    margin-bottom: 0;
}

/* Fade-in elements */
.fade-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1),
                transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-element.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Floating Polyhedra */
.polyhedron {
    position: absolute;
    z-index: 1;
    animation: poly-float 60s linear infinite;
}

.polyhedron-left {
    left: 12%;
    top: 30%;
    transform: scale(0.8);
}

.polyhedron-right {
    right: 15%;
    top: 55%;
    transform: scale(1.1);
}

.poly-face {
    position: absolute;
}

.polyhedron-left .poly-face-1 {
    width: 80px;
    height: 92px;
    background: var(--bark);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    box-shadow:
        0 0 20px rgba(0, 229, 195, 0.08),
        inset 0 0 15px rgba(0, 229, 195, 0.05);
    border: 1px solid rgba(0, 229, 195, 0.12);
}

.polyhedron-left .poly-face-2 {
    width: 60px;
    height: 69px;
    background: rgba(20, 21, 25, 0.7);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    top: -15px;
    left: 10px;
    opacity: 0.6;
    box-shadow: 0 0 12px rgba(0, 229, 195, 0.06);
}

.polyhedron-left .poly-face-3 {
    width: 40px;
    height: 46px;
    background: rgba(26, 29, 36, 0.5);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    top: 30px;
    left: 20px;
    box-shadow: 0 0 8px rgba(0, 229, 195, 0.1);
}

.polyhedron-right .poly-face-1 {
    width: 100px;
    height: 100px;
    background: var(--bark);
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
    box-shadow:
        0 0 25px rgba(0, 229, 195, 0.08),
        inset 0 0 20px rgba(0, 229, 195, 0.04);
    border: 1px solid rgba(0, 229, 195, 0.1);
}

.polyhedron-right .poly-face-2 {
    width: 70px;
    height: 70px;
    background: rgba(20, 21, 25, 0.6);
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
    top: 15px;
    left: 15px;
    box-shadow: 0 0 15px rgba(0, 229, 195, 0.06);
}

.polyhedron-right .poly-face-3 {
    width: 45px;
    height: 45px;
    background: rgba(26, 29, 36, 0.4);
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
    top: 28px;
    left: 28px;
    box-shadow: 0 0 10px rgba(0, 229, 195, 0.12);
}

@keyframes poly-float {
    0% { transform: rotateY(0deg) rotateX(5deg) translateY(0); }
    25% { transform: rotateY(90deg) rotateX(5deg) translateY(-10px); }
    50% { transform: rotateY(180deg) rotateX(5deg) translateY(0); }
    75% { transform: rotateY(270deg) rotateX(5deg) translateY(10px); }
    100% { transform: rotateY(360deg) rotateX(5deg) translateY(0); }
}

.polyhedron-right {
    animation-duration: 45s;
    animation-direction: reverse;
}

.tendril-divider {
    position: absolute;
    bottom: var(--space-3);
    left: 0;
    width: 100%;
    height: 30px;
    opacity: 0.6;
}

/* =============================================
   STRATUM 2 — THE MYCELIUM NETWORK
   ============================================= */

#stratum-2 {
    min-height: 150vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#mycelium-network {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.6;
    transition: opacity 1.5s ease-in-out;
}

#mycelium-network.active {
    opacity: 1;
}

.network-path {
    fill: none;
    stroke: var(--mycelium);
    stroke-width: 1;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 2s cubic-bezier(0.16, 1, 0.3, 1);
}

.network-path.drawn {
    stroke-dashoffset: 0;
}

.network-node circle {
    fill: var(--mycelium);
    filter: drop-shadow(0 0 8px var(--mycelium));
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.network-node.visible circle {
    opacity: 1;
}

.network-node text {
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1) 200ms;
}

.network-node.visible text {
    opacity: 1;
}

.node-ripple {
    fill: none;
    stroke: var(--mycelium);
    stroke-width: 1;
    opacity: 0;
    animation: node-ripple-expand 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes node-ripple-expand {
    from {
        r: 4;
        opacity: 0.6;
        stroke-width: 2;
    }
    to {
        r: 40;
        opacity: 0;
        stroke-width: 0.5;
    }
}

.stratum-2-noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    z-index: 3;
}

/* =============================================
   STRATUM 3 — THE DECOMPOSITION CHAMBER
   ============================================= */

#stratum-3 {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.stratum-3-content {
    position: relative;
    width: 100%;
    max-width: 800px;
    min-height: 80vh;
    padding: var(--space-4) var(--space-2);
}

.decomp-block {
    max-width: 32ch;
}

.decomp-block-1 {
    position: relative;
    opacity: 1;
    z-index: 5;
    margin-left: 5%;
}

.decomp-block-2 {
    position: relative;
    margin-top: -1rem;
    margin-left: 15%;
    z-index: 4;
}

.decomp-block-2 .body-text {
    opacity: 0.8;
    mix-blend-mode: screen;
}

.decomp-block-3 {
    position: relative;
    margin-top: -0.5rem;
    margin-left: 8%;
    z-index: 3;
}

.decomp-block-4 {
    position: relative;
    margin-top: -1.5rem;
    margin-left: 20%;
    z-index: 2;
}

.decomp-block-4 .body-text {
    opacity: 0.6;
    mix-blend-mode: overlay;
}

.decomp-block-5 {
    position: relative;
    margin-top: var(--space-2);
    margin-left: 10%;
    z-index: 6;
}

.stratum-3-magenta-bleed {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60%;
    height: 60%;
    background: radial-gradient(ellipse at 20% 80%, rgba(255, 45, 123, 0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
}

#stratum-3 #noise-overlay-3 {
    opacity: 0.06;
}

/* =============================================
   STRATUM 4 — THE SPORE RELEASE
   ============================================= */

#stratum-4 {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void);
    transition: background 1.5s ease-in-out;
}

#stratum-4.active {
    background: radial-gradient(ellipse at 50% 40%, #1a0a14 0%, var(--void) 100%);
}

#stratum-4::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 50%, rgba(255, 45, 123, 0.08) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 2s ease-in-out;
    pointer-events: none;
}

#stratum-4.active::before {
    opacity: 1;
}

.stratum-4-content {
    position: relative;
    text-align: center;
    z-index: 2;
    padding: var(--space-2);
}

.breathe-text {
    animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.stratum-4-domain {
    margin-top: var(--space-3);
    text-decoration: underline;
    text-decoration-color: rgba(0, 229, 195, 0.3);
    text-underline-offset: 4px;
}

/* =============================================
   REDUCED MOTION
   ============================================= */

@media (prefers-reduced-motion: reduce) {
    .mycelium-pulse,
    .stratum-bottom-line,
    .breathe-text,
    .polyhedron,
    #noise-overlay {
        animation: none;
    }
    .fade-element {
        transition: opacity 400ms ease;
        transform: none;
    }
    .fade-element.visible {
        transform: none;
    }
    .network-path {
        transition: none;
        stroke-dashoffset: 0;
    }
}

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

@media (max-width: 768px) {
    .polyhedron-left,
    .polyhedron-right {
        display: none;
    }

    .stratum-3-content {
        padding: var(--space-2) var(--space-1);
    }

    .decomp-block {
        margin-left: 0 !important;
    }

    .decomp-block-2,
    .decomp-block-4 {
        margin-top: var(--space-1);
    }

    .decomp-block-2 .body-text,
    .decomp-block-4 .body-text {
        opacity: 1;
        mix-blend-mode: normal;
    }

    #mycelium-network {
        opacity: 0.4;
    }
}
