/* ============================================
   genpatsu.io — Atomic Goblincore Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Backgrounds */
    --reactor-dark: #0B0E0F;
    --forest-dark: #121A0E;
    /* Neons */
    --toxic-green: #39FF14;
    --reactor-blue: #00F0FF;
    --emergency-red: #FF003C;
    /* Organic */
    --aged-paper: #F5E6C8;
    --parchment: #E8E0D4;
    --bark-brown: #D4A574;
    --bioluminescent: #B8F0B0;
    --moss-green: #4A6741;
    /* Neutral */
    --graphite: #2A2D2E;

    /* Layout */
    --split-ratio: 1fr;
    --fissure-width: 4px;

    /* Typography */
    --font-main: 'Commissioner', sans-serif;
}

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

html {
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--reactor-dark);
    color: var(--aged-paper);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Sections --- */
.section {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--split-ratio) var(--fissure-width) 1fr;
    scroll-snap-align: start;
    position: relative;
}

.section-incident {
    display: flex;
    grid-template-columns: none;
}

.section-reclamation {
    grid-template-columns: 2fr var(--fissure-width) 3fr;
}

.section-equilibrium {
    grid-template-columns: 35fr var(--fissure-width) 65fr;
}

/* --- Split Panels --- */
.panel-industrial {
    background: var(--reactor-dark);
    position: relative;
    overflow: hidden;
}

.panel-organic {
    background: var(--forest-dark);
    position: relative;
    overflow: hidden;
}

.panel-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 3rem 2rem;
    position: relative;
    z-index: 2;
}

/* Decomposition noise texture for organic panels */
.panel-organic::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='0.5' fill='%23B8F0B0' opacity='0.08'/%3E%3Ccircle cx='3' cy='3' r='0.5' fill='%23B8F0B0' opacity='0.06'/%3E%3Ccircle cx='2' cy='0' r='0.4' fill='%234A6741' opacity='0.1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    z-index: 1;
    pointer-events: none;
}

/* --- Central Fissure --- */
.fissure {
    background: linear-gradient(180deg, var(--toxic-green), var(--reactor-blue), var(--toxic-green));
    box-shadow:
        0 0 12px rgba(57, 255, 20, 0.4),
        0 0 24px rgba(0, 240, 255, 0.2);
    animation: fissurePulse 4s ease-in-out infinite;
    position: relative;
    z-index: 10;
}

.fissure-shifted {
    /* Visual cue that fissure has moved leftward */
}

.fissure-vine {
    background: none;
    box-shadow: none;
    animation: none;
    overflow: visible;
    width: 20px;
    margin: 0 -8px;
}

.vine-svg {
    width: 100%;
    height: 100%;
}

.vine-path {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 2;
    filter: drop-shadow(0 0 4px rgba(184, 240, 176, 0.4));
}

.vine-leaf {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1.5;
    filter: drop-shadow(0 0 3px rgba(184, 240, 176, 0.3));
}

@keyframes fissurePulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1.0; }
}

/* --- Typography --- */

/* Primary headings */
.heading-primary {
    font-family: var(--font-main);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: clamp(2.4rem, 5vw, 4.2rem);
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

.industrial-heading {
    color: var(--toxic-green);
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
}

.organic-heading {
    color: var(--aged-paper);
    text-shadow: 0 0 12px rgba(245, 230, 200, 0.15);
}

.warning-heading {
    color: var(--emergency-red);
    text-shadow: 0 0 12px rgba(255, 0, 60, 0.4);
    font-size: clamp(3rem, 8vw, 7rem);
    font-weight: 900;
}

.equilibrium-heading {
    color: var(--bioluminescent);
    text-shadow: 0 0 20px rgba(184, 240, 176, 0.3);
}

.fading-heading {
    opacity: 0.5;
}

/* Secondary headings */
.heading-secondary {
    font-family: var(--font-main);
    font-weight: 500;
    letter-spacing: 0.02em;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    margin-bottom: 0.4rem;
}

.industrial-sub {
    color: var(--bioluminescent);
}

.organic-sub {
    color: var(--bark-brown);
}

/* Body text */
.body-text {
    font-family: var(--font-main);
    font-weight: 300;
    line-height: 1.65;
    max-width: 38ch;
    color: var(--parchment); /* #E8E0D4 warm parchment per design */
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    margin-top: 0.8rem;
}

/* Captions and metadata */
.caption-text {
    font-family: var(--font-main);
    font-weight: 200;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    color: rgba(57, 255, 20, 0.6);
    margin-top: 0.4rem;
}

/* Warning accent */
.warning-caption {
    color: var(--emergency-red);
    font-weight: 900;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-shadow: 0 0 8px rgba(255, 0, 60, 0.3);
}

/* --- Hero Icons --- */
.hero-icon {
    width: 200px;
    height: 200px;
    margin: 1.5rem 0;
}

.hero-icon svg {
    width: 100%;
    height: 100%;
}

/* Industrial icon styles */
.icon-reactor .reactor-vessel,
.icon-reactor .reactor-core,
.icon-reactor .reactor-fuel {
    fill: none;
    stroke: var(--toxic-green);
    stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(57, 255, 20, 0.3));
}

.icon-reactor .control-rod {
    stroke: var(--toxic-green);
    stroke-width: 2.5;
    filter: drop-shadow(0 0 6px rgba(57, 255, 20, 0.3));
}

.icon-reactor .orbital {
    fill: none;
    stroke: var(--reactor-blue);
    stroke-width: 1;
    opacity: 0.5;
}

.icon-reactor .orbital-2 {
    transform: rotate(60deg);
    transform-origin: 120px 120px;
}

.icon-reactor .orbital-3 {
    transform: rotate(-60deg);
    transform-origin: 120px 120px;
}

.icon-reactor .containment-dome {
    fill: none;
    stroke: var(--toxic-green);
    stroke-width: 2;
    stroke-dasharray: 6 3;
    filter: drop-shadow(0 0 6px rgba(57, 255, 20, 0.3));
}

.icon-reactor .reactor-base {
    fill: none;
    stroke: var(--toxic-green);
    stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(57, 255, 20, 0.3));
}

/* Organic icon styles */
.icon-forest .moss-line {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(184, 240, 176, 0.3));
}

.icon-forest .moss-2 {
    opacity: 0.6;
}

.icon-forest .mushroom-stem {
    stroke: var(--bioluminescent);
    stroke-width: 2;
    fill: none;
    filter: drop-shadow(0 0 6px rgba(184, 240, 176, 0.3));
}

.icon-forest .mushroom-cap {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 2;
    filter: drop-shadow(0 0 8px rgba(184, 240, 176, 0.4));
}

.icon-forest .small-shroom {
    opacity: 0.7;
}

.icon-forest .fern-main {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(184, 240, 176, 0.3));
}

.icon-forest .fern-leaf {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1.5;
    filter: drop-shadow(0 0 4px rgba(184, 240, 176, 0.25));
}

.icon-forest .seedling-stem {
    stroke: var(--bioluminescent);
    stroke-width: 2;
    fill: none;
}

.icon-forest .seedling-leaf {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1.5;
}

/* --- Card Grid --- */
.card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    justify-content: center;
    margin-top: 1.5rem;
    perspective: 1200px;
}

.reclamation-grid {
    max-width: 640px;
}

/* --- Card Flip --- */
.card-flip {
    width: 280px;
    height: 360px;
    perspective: 1200px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.card-flip.active {
    opacity: 1;
    transform: scale(1);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-flip:hover .card-inner,
.card-flip.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
}

.card-front {
    background: var(--graphite);
    z-index: 2;
}

.card-front.card-industrial {
    border: 1px solid var(--toxic-green);
    box-shadow: 0 0 8px rgba(57, 255, 20, 0.15);
}

.card-front.card-organic {
    border: 1px solid var(--bioluminescent);
    box-shadow: 0 0 8px rgba(184, 240, 176, 0.15);
}

.card-back {
    background: var(--reactor-dark);
    transform: rotateY(180deg);
    border: 1px solid var(--toxic-green);
    box-shadow: 0 0 8px rgba(57, 255, 20, 0.1);
    padding: 1.8rem;
}

.card-back.card-back-organic {
    background: var(--forest-dark);
    border-color: var(--bioluminescent);
    box-shadow: 0 0 8px rgba(184, 240, 176, 0.1);
}

.card-back .heading-secondary {
    color: var(--bioluminescent);
}

.card-back .body-text {
    font-size: 0.85rem;
    max-width: 30ch;
}

.card-back .caption-text {
    margin-top: auto;
    padding-top: 0.8rem;
}

/* Edge glow during mid-flip */
.card-flip:hover .card-inner::after,
.card-flip.flipped .card-inner::after {
    content: '';
    position: absolute;
    top: 10%;
    bottom: 10%;
    left: -2px;
    right: -2px;
    border-radius: 8px;
    box-shadow: 0 0 15px var(--toxic-green);
    opacity: 0;
    animation: edgeGlow 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.card-front.card-organic ~ .card-back.card-back-organic {
    border-color: var(--bioluminescent);
}

@keyframes edgeGlow {
    0%, 100% { opacity: 0; }
    40%, 60% { opacity: 0.8; }
}

/* Card icons */
.card-icon {
    width: 80px;
    height: 100px;
    margin-bottom: 0.8rem;
}

.icon-industrial {
    fill: none;
    stroke: var(--toxic-green);
    stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(57, 255, 20, 0.3));
}

.icon-organic {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(184, 240, 176, 0.3));
}

.gauge-needle {
    stroke-width: 2.5;
}

.fern-detail,
.moss-detail,
.mushroom-detail {
    stroke-width: 1.5;
    opacity: 0.8;
}

.glow-dot {
    fill: var(--bioluminescent);
    stroke: none;
    filter: drop-shadow(0 0 4px rgba(184, 240, 176, 0.6));
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* --- Section 3: Incident --- */
.section-incident {
    background: var(--reactor-dark);
    position: relative;
    overflow: hidden;
}

.incident-fullbleed {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(
        ellipse at center,
        rgba(57, 255, 20, 0.05) 0%,
        var(--reactor-dark) 70%
    );
}

.incident-flash {
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
}

.incident-flash.flash-active {
    animation: incidentFlash 1.5s ease-out forwards;
}

@keyframes incidentFlash {
    0% { opacity: 0; }
    5% { opacity: 0.9; }
    15% { opacity: 0.7; }
    30% { opacity: 0.3; }
    100% { opacity: 0; }
}

.incident-content {
    text-align: center;
    z-index: 2;
    padding: 2rem;
    max-width: 700px;
}

.incident-icon-row {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.icon-trefoil {
    width: 120px;
    height: 120px;
}

.trefoil-center {
    fill: var(--emergency-red);
    filter: drop-shadow(0 0 8px rgba(255, 0, 60, 0.5));
}

.trefoil-blade {
    fill: none;
    stroke: var(--emergency-red);
    stroke-width: 2;
    filter: drop-shadow(0 0 6px rgba(255, 0, 60, 0.4));
}

.blade-1 { animation: bladePulse 3s ease-in-out infinite 0s; }
.blade-2 { animation: bladePulse 3s ease-in-out infinite 1s; }
.blade-3 { animation: bladePulse 3s ease-in-out infinite 2s; }

@keyframes bladePulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; fill: rgba(255, 0, 60, 0.15); }
}

.leaf-vein-emerging {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1.5;
    opacity: 0.6;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: drawVein 3s ease-out forwards 1.5s;
}

@keyframes drawVein {
    to { stroke-dashoffset: 0; }
}

.incident-text {
    max-width: 50ch;
    margin-left: auto;
    margin-right: auto;
}

/* --- Section 4: Reclamation --- */
.panel-retreating .panel-content {
    opacity: 0.6;
}

.retreat-icons {
    margin-top: 2rem;
}

.icon-decay {
    width: 120px;
    height: 120px;
}

.decay-stroke {
    stroke-dasharray: 4 4;
    opacity: 0.6;
}

.crack {
    stroke-width: 1.5;
    opacity: 0.8;
}

.spore-cloud {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1;
    opacity: 0.4;
}

/* --- Section 5: Equilibrium --- */
.panel-minimal {
    opacity: 0.3;
}

.ghost-reactor {
    width: 200px;
    height: 400px;
    opacity: 0.2;
}

.ghost-line {
    fill: none;
    stroke: var(--toxic-green);
    stroke-width: 1;
    stroke-dasharray: 8 6;
}

.panel-dominant {
    position: relative;
}

.equilibrium-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.leaf-overlay-svg {
    width: 100%;
    height: 100%;
    opacity: 0.3;
}

.leaf-vein-main {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 2;
    filter: drop-shadow(0 0 4px rgba(184, 240, 176, 0.3));
}

.leaf-vein-branch {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1.5;
    opacity: 0.6;
}

.leaf-vein-sub {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1;
    opacity: 0.4;
}

/* Equilibrium central text */
.equilibrium-text-block {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    text-align: center;
    padding: 3rem;
    max-width: 650px;
    background: rgba(11, 14, 15, 0.7);
    border-radius: 4px;
    backdrop-filter: blur(8px);
}

.equilibrium-body {
    max-width: 50ch;
    color: var(--aged-paper);
}

.equilibrium-body em {
    color: var(--bioluminescent);
    font-style: italic;
}

.equilibrium-caption {
    margin-top: 1.5rem;
    color: rgba(184, 240, 176, 0.6);
}

/* --- Tendril Overlay --- */
#tendril-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 500vh;
    pointer-events: none;
    z-index: 15;
    mix-blend-mode: screen;
}

.tendril {
    fill: none;
    stroke: var(--bioluminescent);
    stroke-width: 1.5;
    opacity: 0;
    filter: drop-shadow(0 0 4px rgba(184, 240, 176, 0.3));
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: opacity 0.5s ease;
}

.tendril.visible {
    opacity: 0.4;
    animation: drawTendril 3s ease-out forwards;
}

@keyframes drawTendril {
    to { stroke-dashoffset: 0; }
}

/* --- Spore Particles --- */
#spore-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.spore {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--bioluminescent);
    border-radius: 50%;
    opacity: 0.2;
    animation: sporeDrift var(--drift-duration) linear infinite;
    animation-delay: var(--drift-delay);
    left: var(--drift-x);
    bottom: -10px;
}

@keyframes sporeDrift {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0.2;
    }
    10% {
        opacity: 0.2;
    }
    50% {
        transform: translateY(-50vh) translateX(var(--drift-sway));
        opacity: 0.15;
    }
    90% {
        opacity: 0.05;
    }
    100% {
        transform: translateY(-110vh) translateX(calc(var(--drift-sway) * -1));
        opacity: 0;
    }
}

/* --- Responsive: Mobile Stacked Diptych --- */
@media (max-width: 768px) {
    .section {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 4px 1fr;
        min-height: auto;
    }

    .section-incident {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }

    .section-reclamation {
        grid-template-columns: 1fr;
        grid-template-rows: 2fr 4px 3fr;
    }

    .section-equilibrium {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 4px 2fr;
    }

    .fissure {
        width: 100%;
        height: 4px;
        background: linear-gradient(90deg, var(--toxic-green), var(--reactor-blue), var(--toxic-green));
    }

    .fissure-vine {
        width: 100%;
        height: 20px;
        margin: 0;
    }

    .card-flip {
        width: 240px;
        height: 310px;
    }

    .card-grid {
        gap: 0.8rem;
    }

    .hero-icon {
        width: 150px;
        height: 150px;
    }

    .heading-primary {
        font-size: clamp(1.8rem, 6vw, 2.8rem);
    }

    .equilibrium-text-block {
        padding: 1.5rem;
        width: 90%;
    }

    #spore-container {
        width: 100%;
    }

    #tendril-overlay {
        display: none;
    }

    .panel-content {
        padding: 2rem 1.2rem;
        min-height: 50vh;
    }

    /* Mobile: tap to flip instead of hover */
    .card-flip:hover .card-inner {
        transform: none;
    }

    .card-flip.flipped .card-inner {
        transform: rotateY(180deg);
    }
}

/* --- Utility --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
