/* ============================================
   prototypic.dev — Biopunk Aquatic Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-abyss: #0a0e1a;
    --midnight-reef: #101828;
    --bioluminescent-teal: #0fd9b2;
    --reef-cerulean: #1a8aaf;
    --reef-blue: #1a6b8a;
    --deep-teal: #0d4f4f;
    --coral-fin: #ff6b4a;
    --steel-mist: #b8c4d4;
    --phosphor-white: #e4f0f6;
    --code-green: #4de8c2;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep-abyss);
    color: var(--steel-mist);
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
}

/* --- Navigation --- */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.8rem 3rem;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(8px);
}

.nav-line {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--deep-teal), var(--bioluminescent-teal), var(--deep-teal), transparent);
}

.nav-item {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--steel-mist);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.3s ease;
    position: relative;
}

.nav-item:hover {
    color: var(--bioluminescent-teal);
}

.nav-item.active {
    color: var(--bioluminescent-teal);
}

.nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--deep-teal);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.nav-item.active .nav-dot {
    background: var(--bioluminescent-teal);
    box-shadow: 0 0 8px var(--bioluminescent-teal);
}

/* --- Slabs (Diagonal Sections) --- */
.slab {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.slab-inner {
    position: relative;
    z-index: 2;
    padding: 8rem 6vw 6rem;
    max-width: 900px;
}

.slab-left {
    margin-left: 5vw;
    margin-right: auto;
}

.slab-right {
    margin-left: auto;
    margin-right: 5vw;
}

/* --- Slab 1: Hero --- */
.slab-hero {
    display: flex;
    align-items: center;
    clip-path: polygon(0 0, 100% 0, 100% 94%, 0 100%);
    background: var(--deep-abyss);
    min-height: 100vh;
}

.caustic-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 50%, rgba(13, 79, 79, 0.3) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 30%, rgba(26, 138, 175, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(15, 217, 178, 0.1) 0%, transparent 50%);
    animation: causticShift 20s ease-in-out infinite;
}

@keyframes causticShift {
    0%, 100% {
        background-position: 0% 0%, 100% 0%, 50% 100%;
    }
    33% {
        background-position: 20% 10%, 80% 20%, 40% 90%;
    }
    66% {
        background-position: 10% 20%, 90% 10%, 60% 80%;
    }
}

.hero-content {
    position: relative;
    z-index: 5;
    padding: 0 6vw;
    max-width: 50%;
}

.hero-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--phosphor-white);
    clip-path: inset(0 100% 0 0);
    animation: revealTitle 0.8s ease-out 0.9s forwards;
}

@keyframes revealTitle {
    to { clip-path: inset(0 0% 0 0); }
}

.hero-tagline {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--steel-mist);
    margin-top: 1rem;
    opacity: 0;
    animation: pulseBreath 3s ease-in-out 1.5s infinite, fadeInTagline 0.6s ease 1.4s forwards;
}

@keyframes fadeInTagline {
    to { opacity: 0.8; }
}

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

/* Jellyfish */
.jellyfish-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 60%;
    height: 100%;
    z-index: 3;
    opacity: 0;
    animation: fadeIn 1s ease 0.6s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.jellyfish {
    position: absolute;
    animation: jellyDrift 15s ease-in-out infinite;
}

.jf-1 { right: 15%; top: 20%; animation-delay: 0s; }
.jf-2 { right: 35%; top: 40%; animation-delay: -5s; }
.jf-3 { right: 55%; top: 60%; animation-delay: -10s; }

@keyframes jellyDrift {
    0%, 100% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(-30px) translateX(10px); }
    50% { transform: translateY(-60px) translateX(-5px); }
    75% { transform: translateY(-30px) translateX(15px); }
}

.jf-bell {
    width: 40px;
    height: 28px;
    border-radius: 50% 50% 30% 30%;
    background: radial-gradient(ellipse at 50% 40%, rgba(15, 217, 178, 0.25), rgba(26, 138, 175, 0.1));
    border: 1px solid rgba(15, 217, 178, 0.15);
    animation: jellyPulse 3s ease-in-out infinite;
}

.jf-2 .jf-bell { width: 30px; height: 22px; }
.jf-3 .jf-bell { width: 24px; height: 18px; }

@keyframes jellyPulse {
    0%, 100% { transform: scaleX(1); }
    50% { transform: scaleX(0.85); }
}

.jf-tendril {
    width: 1px;
    height: 30px;
    background: linear-gradient(to bottom, rgba(15, 217, 178, 0.2), transparent);
    margin: 0 auto;
    animation: tendrilSway 4s ease-in-out infinite;
}

.t1 { margin-left: 30%; animation-delay: 0s; }
.t2 { margin-left: 50%; animation-delay: -1.3s; }
.t3 { margin-left: 70%; animation-delay: -2.6s; }

@keyframes tendrilSway {
    0%, 100% { transform: translateX(0) scaleY(1); }
    50% { transform: translateX(5px) scaleY(1.1); }
}

/* Angelfish */
.angelfish-svg {
    position: absolute;
    bottom: 8%;
    right: -130px;
    z-index: 4;
    animation: angelGlide 8s ease-in-out 1.2s forwards;
    opacity: 0;
}

@keyframes angelGlide {
    0% { right: -130px; opacity: 0; }
    10% { opacity: 0.4; }
    90% { opacity: 0.4; }
    100% { right: calc(100% + 130px); opacity: 0; }
}

/* --- Fish Parallax Layer --- */
.fish-parallax-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.small-fish {
    position: absolute;
}

.sf-1 { top: 30%; right: 10%; }
.sf-2 { top: 55%; right: 25%; }
.sf-3 { top: 70%; right: 40%; }
.sf-4 { top: 20%; left: 75%; }
.sf-5 { top: 60%; left: 85%; }

/* --- Slab 2: Iteration --- */
.slab-iteration {
    background: var(--midnight-reef);
    clip-path: polygon(0 4%, 100% 0, 100% 96%, 0 100%);
    margin-top: -6vh;
    padding-top: 4vh;
}

.circuit-coral {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

.coral-path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2s ease;
}

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

.coral-node {
    transition: opacity 1s ease 1.5s;
}

.coral-node.visible {
    opacity: 0.4 !important;
    animation: nodePulse 2.5s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% { opacity: 0.2; r: 2; }
    50% { opacity: 0.6; r: 4; }
}

/* --- Section Typography --- */
.section-heading {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--phosphor-white);
    margin-bottom: 1.5rem;
}

.section-text {
    margin-bottom: 1.2rem;
    max-width: 640px;
}

.section-text em {
    color: var(--bioluminescent-teal);
    font-style: normal;
    font-weight: 500;
}

/* --- Slab 3: Ecosystem --- */
.slab-ecosystem {
    background: linear-gradient(135deg, var(--deep-teal), var(--reef-blue), var(--reef-cerulean));
    clip-path: polygon(0 0, 100% 5%, 100% 100%, 0 95%);
    margin-top: -6vh;
    padding-top: 4vh;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.glass-card {
    background: rgba(10, 14, 26, 0.4);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(15, 217, 178, 0.15);
    border-top: 3px solid var(--bioluminescent-teal);
    border-radius: 6px;
    padding: 1.8rem;
    transition: transform 0.3s ease, border-color 0.3s ease;
    position: relative;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bioluminescent-teal);
    animation: cardPulse 3s ease-in-out infinite;
}

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

.glass-card:hover {
    transform: translateY(-4px);
    border-color: rgba(15, 217, 178, 0.4);
}

.card-fish-icon {
    margin-bottom: 1rem;
}

.css-fish {
    width: 32px;
    height: 18px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    position: relative;
}

.css-fish::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 3px;
    width: 0;
    height: 0;
    border-left: 10px solid;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.fish-ui { background: var(--bioluminescent-teal); }
.fish-ui::after { border-left-color: var(--bioluminescent-teal); }
.fish-api { background: var(--reef-cerulean); }
.fish-api::after { border-left-color: var(--reef-cerulean); }
.fish-data { background: var(--code-green); }
.fish-data::after { border-left-color: var(--code-green); }
.fish-system { background: var(--coral-fin); }
.fish-system::after { border-left-color: var(--coral-fin); }

.card-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--phosphor-white);
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.card-desc {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--steel-mist);
}

/* --- Slab 4: Adaptation --- */
.slab-adaptation {
    background: var(--deep-abyss);
    clip-path: polygon(0 3%, 100% 0, 100% 97%, 0 100%);
    margin-top: -6vh;
    padding-top: 4vh;
}

.showcase-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.showcase-item {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
}

.showcase-clip {
    width: 100%;
    height: 100%;
    clip-path: polygon(20% 0, 100% 0, 100% 100%, 0 100%, 0 20%);
    position: relative;
    overflow: hidden;
    transition: clip-path 0.6s ease;
}

.showcase-item:hover .showcase-clip {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 0);
}

.showcase-inner {
    width: 100%;
    height: 100%;
    filter: saturate(0.6);
    transition: filter 0.4s ease;
}

.showcase-item:hover .showcase-inner {
    filter: saturate(1);
}

.showcase-label {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--code-green);
    background: rgba(10, 14, 26, 0.7);
    padding: 0.3rem 0.6rem;
    border-radius: 3px;
}

/* --- Slab 5: Depth --- */
.slab-depth {
    background: var(--midnight-reef);
    clip-path: polygon(0 0, 100% 6%, 100% 94%, 0 100%);
    margin-top: -6vh;
    padding-top: 4vh;
}

.code-block {
    background: var(--deep-abyss);
    border-radius: 6px;
    padding: 1.8rem 2rem;
    margin-top: 1.5rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(15, 217, 178, 0.08);
}

.code-border-coral {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--bioluminescent-teal), var(--deep-teal), var(--bioluminescent-teal));
    animation: coralBorderPulse 4s ease-in-out infinite;
}

@keyframes coralBorderPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

pre {
    margin: 0;
    overflow-x: auto;
}

code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    line-height: 1.6;
    color: var(--code-green);
}

.code-keyword { color: var(--reef-cerulean); }
.code-string { color: var(--bioluminescent-teal); }
.code-number { color: var(--coral-fin); }
.code-comment { color: rgba(184, 196, 212, 0.4); }

/* --- Slab 6: Surface --- */
.slab-surface {
    background: var(--deep-abyss);
    clip-path: polygon(0 5%, 100% 0, 100% 100%, 0 100%);
    margin-top: -6vh;
    padding-top: 4vh;
    min-height: 70vh;
    display: flex;
    align-items: center;
}

.cta-button {
    display: inline-block;
    margin-top: 2rem;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--deep-abyss);
    background: var(--coral-fin);
    padding: 1rem 2.5rem;
    border-radius: 4px;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: ctaPulse 2.5s ease-in-out infinite;
}

@keyframes ctaPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 107, 74, 0.3); }
    50% { box-shadow: 0 0 35px rgba(255, 107, 74, 0.6); }
}

.cta-button:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--bioluminescent-teal), var(--coral-fin));
    color: var(--deep-abyss);
}

/* --- Link Styles --- */
a:not(.nav-item):not(.cta-button) {
    color: var(--steel-mist);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

a:not(.nav-item):not(.cta-button):hover {
    color: var(--bioluminescent-teal);
}

a:not(.nav-item):not(.cta-button)::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--bioluminescent-teal);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

a:not(.nav-item):not(.cta-button):hover::after {
    transform: scaleX(1);
}

/* --- School of fish container --- */
.school-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

.school-fish {
    position: absolute;
    width: 10px;
    height: 5px;
    background: var(--bioluminescent-teal);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    opacity: 0.5;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .nav-bar {
        padding: 0.6rem 1.5rem;
        gap: 1rem;
        overflow-x: auto;
    }

    .slab-inner {
        padding: 6rem 5vw 4rem;
    }

    .slab-left, .slab-right {
        margin-left: 3vw;
        margin-right: 3vw;
    }

    .hero-content {
        max-width: 80%;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .showcase-grid {
        grid-template-columns: 1fr;
    }

    .jellyfish-container {
        width: 40%;
        opacity: 0.5;
    }
}
