/* ============================================================
   causality.club — Seapunk Causality Engine
   ============================================================ */

/* --- Custom Properties --- */
:root {
    --abyssal: #0A1628;
    --twilight: #132744;
    --turquoise: #00CED1;
    --magenta: #E0115F;
    --mauve: #E0B0FF;
    --gold: #FFD700;
    --emerald: #2E8B57;
    --pearl: #C8D8E4;
    --foam: #F0F4F8;
    --amethyst: #7B2D8E;
    --navy: #1A2744;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.65;
    color: var(--pearl);
    background: var(--twilight);
    transition: background 0.8s ease;
    overflow-x: hidden;
}

body.zone-surface {
    background: var(--twilight);
}

body.zone-mesopelagic {
    background: var(--abyssal);
}

body.zone-abyssal {
    background: linear-gradient(170deg, var(--abyssal) 0%, var(--twilight) 40%, var(--amethyst) 100%);
}

/* --- SVG Defs (hidden) --- */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Trace Overlay --- */
.trace-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

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

.trace-line {
    fill: none;
    stroke: var(--turquoise);
    stroke-width: 1;
    stroke-dasharray: 4 2;
    opacity: 0.6;
}

/* --- Grid Container --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* --- Depth Zones --- */
.depth-zone {
    padding: 40px 0;
    position: relative;
}

.surface-zone {
    background: linear-gradient(170deg, var(--twilight) 0%, var(--abyssal) 100%);
}

.mesopelagic-zone {
    background: linear-gradient(170deg, var(--abyssal) 0%, #0d1e3a 100%);
}

.abyssal-zone {
    background: linear-gradient(170deg, var(--abyssal) 0%, var(--twilight) 40%, var(--amethyst) 100%);
}

/* --- Zone Labels --- */
.zone-label {
    text-align: center;
    padding: 20px 0 30px;
}

.zone-label-text {
    font-family: 'Bungee Shade', cursive;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--turquoise);
    letter-spacing: 0.08em;
}

/* --- Block Base Styles --- */
.cause-block,
.effect-block,
.nexus-block,
.reflection-block {
    padding: 24px 28px;
    border-radius: 6px;
    position: relative;
    opacity: 0;
    transform: scale(0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.cause-block.visible,
.effect-block.visible,
.nexus-block.visible,
.reflection-block.visible {
    animation: bounceIn 0.6s cubic-bezier(0.215, 0.610, 0.355, 1.000) forwards;
}

/* --- Cause Blocks --- */
.cause-block {
    background: var(--twilight);
    border: 2px solid var(--turquoise);
    min-height: 200px;
}

.cause-block:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 206, 209, 0.2);
    border-color: var(--turquoise);
}

.cause-block:hover::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(0, 206, 209, 0.1) 0%, rgba(224, 17, 95, 0.1) 100%);
    pointer-events: none;
}

.cause-block h3 {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--mauve);
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.cause-block p {
    color: var(--pearl);
}

/* --- Effect Blocks --- */
.effect-block {
    background: var(--twilight);
    border: 2px solid var(--magenta);
    min-height: 180px;
}

.effect-block:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(224, 17, 95, 0.2);
    border-color: var(--magenta);
}

.effect-block:hover::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(224, 17, 95, 0.1) 0%, rgba(0, 206, 209, 0.1) 100%);
    pointer-events: none;
}

.effect-block h3 {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--mauve);
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.effect-block p {
    color: var(--pearl);
}

/* --- Nexus Blocks --- */
.nexus-block {
    background: radial-gradient(ellipse at center, var(--twilight) 0%, var(--abyssal) 100%);
    border: 2px solid var(--gold);
    min-height: 280px;
    overflow: hidden;
}

.nexus-block:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.15);
}

.nexus-block h1 {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    color: var(--mauve);
    letter-spacing: 0.04em;
    margin-bottom: 16px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.nexus-block h2 {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--mauve);
    letter-spacing: 0.04em;
    margin-bottom: 14px;
    position: relative;
    z-index: 2;
}

.nexus-block p {
    color: var(--pearl);
    position: relative;
    z-index: 2;
}

.nexus-block .tagline {
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    text-align: center;
    color: var(--pearl);
    opacity: 0.85;
    max-width: 500px;
    margin: 0 auto;
}

.nexus-final {
    text-align: center;
}

/* --- Reflection Block (Footer) --- */
.reflection-block {
    background: radial-gradient(ellipse at center, var(--twilight) 0%, var(--abyssal) 100%);
    border: 1px solid rgba(0, 206, 209, 0.3);
    border-radius: 6px;
    text-align: center;
    padding: 40px 28px;
}

.reflection-text {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: var(--mauve);
    letter-spacing: 0.04em;
    margin-bottom: 16px;
}

.footer-note {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: var(--turquoise);
    text-shadow: 0 0 8px rgba(0, 206, 209, 0.4);
    opacity: 0.7;
}

/* --- Light Background Blocks (design spec: navy text on light surfaces) --- */
.block-light {
    background: var(--foam);
}

.block-light h3,
.block-light h2 {
    color: var(--navy);
}

.block-light p {
    color: var(--navy);
}

/* --- Port Icons --- */
.port {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
}

.port-input {
    left: -8px;
}

.port-output {
    right: -8px;
}

/* --- Annotations --- */
.annotation {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: var(--turquoise);
    text-shadow: 0 0 8px rgba(0, 206, 209, 0.4);
    margin-top: 12px;
    opacity: 0.8;
}

/* --- Circuit Diagrams --- */
.circuit-diagram {
    display: block;
    width: 100%;
    max-width: 180px;
    margin: 16px auto 8px;
}

.circuit-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 7px;
    fill: var(--turquoise);
    opacity: 0.7;
}

/* --- Compass Rose --- */
.compass-rose {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    z-index: 2;
}

.compass-svg {
    width: 200px;
    height: 200px;
    opacity: 0.85;
}

/* --- Jellyfish Decoration --- */
.jellyfish {
    position: absolute;
    top: -20px;
    right: 20px;
    width: 100px;
    height: 140px;
    pointer-events: none;
    opacity: 0.35;
    z-index: 1;
}

.jellyfish-large {
    width: 140px;
    height: 180px;
    top: -30px;
    right: 30px;
    opacity: 0.25;
}

.jellyfish-bell {
    width: 80%;
    height: 50%;
    margin: 0 auto;
    border-radius: 50% 50% 20% 20%;
    background: radial-gradient(ellipse at center, rgba(0, 206, 209, 0.3) 0%, rgba(224, 176, 255, 0.2) 50%, transparent 100%);
    mix-blend-mode: screen;
}

.jellyfish-large .jellyfish-bell {
    background: radial-gradient(ellipse at center, rgba(0, 206, 209, 0.25) 0%, rgba(224, 17, 95, 0.15) 50%, transparent 100%);
}

.jellyfish-tentacles {
    display: block;
    width: 100%;
    margin-top: -5px;
}

/* Tentacle drift animation */
.tentacle {
    animation: tentacleDrift 8s ease-in-out infinite alternate;
}

.tentacle.t2 { animation-delay: -2s; }
.tentacle.t3 { animation-delay: -4s; }
.tentacle.t4 { animation-delay: -6s; }
.tentacle.t5 { animation-delay: -1s; }

@keyframes tentacleDrift {
    0% {
        d: path("M20,0 C25,20 15,40 20,60");
    }
    50% {
        d: path("M20,0 C15,20 25,40 20,60");
    }
    100% {
        d: path("M20,0 C25,20 15,40 20,60");
    }
}

/* --- Wave Dividers --- */
.wave-divider {
    width: 100%;
    overflow: hidden;
    line-height: 0;
    padding: 10px 0;
}

.wave-divider svg {
    display: block;
    width: 100%;
    height: 60px;
}

/* --- Bounce-In Animation --- */
@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    70% {
        transform: scale(0.95);
        opacity: 0.9;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Trace Line Animation --- */
@keyframes traceDash {
    to {
        stroke-dashoffset: -30;
    }
}

.trace-line-animated {
    animation: traceDash 2s linear infinite;
}

/* --- Coral-Circuit Border Pattern (pseudo-element) --- */
.cause-block::before,
.effect-block::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 7px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cause-block:hover::before {
    opacity: 1;
    box-shadow: inset 0 0 20px rgba(0, 206, 209, 0.08);
}

.effect-block:hover::before {
    opacity: 1;
    box-shadow: inset 0 0 20px rgba(224, 17, 95, 0.08);
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--abyssal);
}

::-webkit-scrollbar-thumb {
    background: var(--twilight);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--turquoise);
}

/* --- Selection --- */
::selection {
    background: rgba(0, 206, 209, 0.3);
    color: var(--foam);
}

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

/* --- Tablet (768px - 1199px) --- */
@media (max-width: 1199px) and (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(6, 1fr);
        padding: 16px;
    }

    .cause-block,
    .effect-block,
    .nexus-block,
    .reflection-block {
        grid-column: span 3 !important;
    }

    .nexus-block {
        grid-column: span 6 !important;
    }

    .reflection-block {
        grid-column: span 6 !important;
    }

    .jellyfish {
        transform: scale(0.5);
        transform-origin: top right;
    }

    .compass-svg {
        width: 150px;
        height: 150px;
    }
}

/* --- Mobile (< 768px) --- */
@media (max-width: 767px) {
    .grid-container {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }

    .cause-block,
    .effect-block,
    .nexus-block,
    .reflection-block {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        min-height: auto;
    }

    .cause-block {
        border-left: 4px solid var(--turquoise);
        border-top: none;
        border-right: none;
        border-bottom: none;
    }

    .effect-block {
        border-left: 4px solid var(--magenta);
        border-top: none;
        border-right: none;
        border-bottom: none;
    }

    .nexus-block {
        border: 2px solid var(--gold);
    }

    .port {
        display: none;
    }

    .trace-overlay {
        display: none;
    }

    .jellyfish {
        display: none;
    }

    .compass-svg {
        width: 120px;
        height: 120px;
    }

    .nexus-block h1 {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }

    .wave-divider svg {
        height: 40px;
    }

    .zone-label {
        padding: 12px 0 20px;
    }
}

/* --- Large Desktop (1200px+) --- */
@media (min-width: 1200px) {
    .grid-container {
        padding: 24px 40px;
    }
}
