/* ==========================================================================
   layer2.wiki - Seapunk Underwater Encyclopedia
   Color Palette:
     #0A4D68 - Dark Teal (Surface BG)
     #0B1D3A - Abyss Blue (Deep BG)
     #0E2845 - Card Surface (Midnight panel)
     #7FFFD4 - Aquamarine (Primary Accent / Bioluminescent green)
     #FF6B8A - Coral Pink (Jewel accent)
     #FFD93D - Sunlight Gold (Warm jewel accent)
     #1A8A9E - Teal Glow (Interactive borders)
     #0E6B82 - Mid Teal (Wave accent)
     #B8D4E3 - Ice Text (Body text)
     #050E1A - Near-black blue (Deep Dive BG)
     #030810 - Abyss black (Footer BG)
   Fonts: Bungee Shade (display), Recursive (headers, body, code)
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Recursive', sans-serif;
    font-weight: 400;
    color: #B8D4E3;
    background: #0A4D68;
    overflow-x: hidden;
    line-height: 1.8;
}

/* ==========================================================================
   Bioluminescent Bubbles Overlay
   ========================================================================== */

#bubbles-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(100vh) translateX(0);
        opacity: 0.3;
    }
    25% {
        opacity: 0.6;
    }
    50% {
        transform: translateY(50vh) translateX(15px);
        opacity: 0.3;
    }
    75% {
        opacity: 0.55;
    }
    100% {
        transform: translateY(-20px) translateX(-10px);
        opacity: 0.3;
    }
}

@keyframes bubblePulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* ==========================================================================
   SURFACE - Hero Section
   ========================================================================== */

#surface {
    position: relative;
    min-height: 100vh;
    background: linear-gradient(180deg, #0A4D68 0%, #0B1D3A 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Wave Container */
.wave-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20%;
    z-index: 2;
}

.wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.wave-1 {
    z-index: 3;
    animation: waveMotion1 8s ease-in-out infinite;
}

.wave-2 {
    z-index: 2;
    animation: waveMotion2 12s ease-in-out infinite;
}

.wave-3 {
    z-index: 1;
    animation: waveMotion3 16s ease-in-out infinite;
}

@keyframes waveMotion1 {
    0%, 100% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(-20px) translateY(3px);
    }
}

@keyframes waveMotion2 {
    0%, 100% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(25px) translateY(-4px);
    }
}

@keyframes waveMotion3 {
    0%, 100% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(-15px) translateY(5px);
    }
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 5;
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    animation: heroReveal 800ms ease-out 300ms forwards;
}

.site-title {
    font-family: 'Bungee Shade', cursive;
    font-weight: 400;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.05em;
    color: #7FFFD4;
    text-shadow: 0 0 20px rgba(127, 255, 212, 0.4);
    animation: titleGlow 3s ease-in-out 1100ms 1;
    margin-bottom: 1rem;
}

.site-subtitle {
    font-family: 'Recursive', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: #B8D4E3;
    opacity: 0.7;
    letter-spacing: 0.08em;
}

@keyframes heroReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes titleGlow {
    0% {
        text-shadow: 0 0 20px rgba(127, 255, 212, 0.4);
    }
    50% {
        text-shadow: 0 0 40px rgba(127, 255, 212, 0.7), 0 0 80px rgba(127, 255, 212, 0.3);
    }
    100% {
        text-shadow: 0 0 20px rgba(127, 255, 212, 0.4);
    }
}

/* Organic Blobs */
.blob-container {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    background: #1A8A9E;
    opacity: 0.2;
    animation: blobDrift linear infinite;
}

.blob-1 {
    width: 120px;
    height: 100px;
    border-radius: 40% 60% 55% 45% / 60% 40% 65% 35%;
    left: 10%;
    top: -20%;
    animation-duration: 25s;
}

.blob-2 {
    width: 80px;
    height: 70px;
    border-radius: 55% 45% 40% 60% / 45% 55% 50% 50%;
    left: 35%;
    top: -30%;
    animation-duration: 30s;
    animation-delay: -5s;
}

.blob-3 {
    width: 150px;
    height: 120px;
    border-radius: 45% 55% 60% 40% / 55% 45% 40% 60%;
    left: 60%;
    top: -15%;
    animation-duration: 35s;
    animation-delay: -10s;
}

.blob-4 {
    width: 60px;
    height: 55px;
    border-radius: 50% 50% 45% 55% / 60% 40% 55% 45%;
    left: 80%;
    top: -25%;
    animation-duration: 28s;
    animation-delay: -3s;
}

.blob-5 {
    width: 100px;
    height: 90px;
    border-radius: 60% 40% 50% 50% / 40% 60% 45% 55%;
    left: 50%;
    top: -10%;
    animation-duration: 32s;
    animation-delay: -8s;
}

@keyframes blobDrift {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(calc(100% + 200px)) rotate(45deg);
    }
}

/* ==========================================================================
   REEF INDEX - Wiki Category Cards
   ========================================================================== */

#reef-index {
    position: relative;
    background: #0B1D3A;
    padding: 6rem 2rem 8rem;
    z-index: 5;
}

.section-heading {
    font-family: 'Recursive', sans-serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    color: #7FFFD4;
    text-align: center;
    margin-bottom: 3rem;
    letter-spacing: 0.04em;
}

.reef-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.reef-card {
    background: #0E2845;
    border: 1px solid #1A8A9E;
    border-radius: 12px;
    padding: 1.8rem 1.5rem;
    transition: transform 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
    cursor: pointer;
    position: relative;
    opacity: 0;
    filter: blur(2px);
    animation: cardEmerge 600ms ease-out forwards;
}

.reef-card:nth-child(1) { animation-delay: 0ms; }
.reef-card:nth-child(2) { animation-delay: 80ms; }
.reef-card:nth-child(3) { animation-delay: 160ms; }
.reef-card:nth-child(4) { animation-delay: 240ms; }
.reef-card:nth-child(5) { animation-delay: 320ms; }
.reef-card:nth-child(6) { animation-delay: 400ms; }
.reef-card:nth-child(7) { animation-delay: 480ms; }
.reef-card:nth-child(8) { animation-delay: 560ms; }
.reef-card:nth-child(9) { animation-delay: 640ms; }

@keyframes cardEmerge {
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* Card not yet in viewport - controlled by JS IntersectionObserver */
.reef-card.not-visible {
    opacity: 0;
    filter: blur(2px);
    animation: none;
}

.reef-card.visible {
    animation: cardEmerge 600ms ease-out forwards;
}

/* Card Sizes - organic clustering */
.card-size-lg {
    flex: 0 1 320px;
    margin-top: 0.5rem;
}

.card-size-md {
    flex: 0 1 280px;
    margin-top: 1.2rem;
}

.card-size-sm {
    flex: 0 1 240px;
    margin-top: 0.8rem;
}

/* Organic border-radius per card - varied */
.reef-card:nth-child(1) { border-radius: 12px 18px 12px 16px; }
.reef-card:nth-child(2) { border-radius: 16px 12px 18px 12px; }
.reef-card:nth-child(3) { border-radius: 14px 16px 12px 18px; }
.reef-card:nth-child(4) { border-radius: 18px 14px 16px 12px; }
.reef-card:nth-child(5) { border-radius: 12px 16px 14px 18px; }
.reef-card:nth-child(6) { border-radius: 16px 18px 12px 14px; }
.reef-card:nth-child(7) { border-radius: 14px 12px 18px 16px; }
.reef-card:nth-child(8) { border-radius: 18px 16px 14px 12px; }
.reef-card:nth-child(9) { border-radius: 12px 14px 16px 18px; }

.reef-card:hover {
    transform: translateY(-4px);
    border-color: #7FFFD4;
    box-shadow: 0 8px 24px rgba(26, 138, 158, 0.3), 0 0 20px rgba(127, 255, 212, 0.15);
}

.reef-card:hover .card-title {
    color: #7FFFD4;
}

.card-title {
    font-family: 'Recursive', sans-serif;
    font-weight: 700;
    font-size: clamp(1.1rem, 1.8vw, 1.35rem);
    color: #B8D4E3;
    margin-bottom: 0.6rem;
    transition: color 300ms ease;
}

.card-desc {
    font-family: 'Recursive', sans-serif;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    color: #B8D4E3;
    opacity: 0.8;
    line-height: 1.7;
    margin-bottom: 0.8rem;
}

.card-tag {
    display: inline-block;
    font-family: 'Recursive', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: #1A8A9E;
    border: 1px solid rgba(26, 138, 158, 0.4);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   DEEP DIVE - Featured Article
   ========================================================================== */

#deep-dive {
    position: relative;
    min-height: 100vh;
    background: #050E1A;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    overflow: hidden;
}

.deep-dive-content {
    position: relative;
    z-index: 5;
    max-width: 720px;
    margin: 0 auto;
}

.deep-heading {
    font-family: 'Recursive', sans-serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    color: #7FFFD4;
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
}

.article-body p {
    font-family: 'Recursive', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: #B8D4E3;
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.highlight {
    color: #7FFFD4;
    font-weight: 700;
}

.code-inline {
    font-family: 'Recursive', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    background: rgba(14, 107, 130, 0.25);
    border-left: 2px solid #0E6B82;
    color: #7FFFD4;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

/* Deep Dive Bubbles */
.deep-bubbles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.deep-bubble {
    position: absolute;
    border-radius: 50%;
    bottom: -20px;
    animation: deepBubbleRise linear infinite;
}

.db-1 {
    width: 6px; height: 6px;
    background: #7FFFD4;
    opacity: 0.4;
    left: 8%;
    animation-duration: 35s;
}
.db-2 {
    width: 4px; height: 4px;
    background: #FF6B8A;
    opacity: 0.5;
    left: 22%;
    animation-duration: 42s;
    animation-delay: -8s;
}
.db-3 {
    width: 8px; height: 8px;
    background: #FFD93D;
    opacity: 0.35;
    left: 38%;
    animation-duration: 38s;
    animation-delay: -15s;
}
.db-4 {
    width: 5px; height: 5px;
    background: #7FFFD4;
    opacity: 0.45;
    left: 52%;
    animation-duration: 45s;
    animation-delay: -3s;
}
.db-5 {
    width: 7px; height: 7px;
    background: #FF6B8A;
    opacity: 0.3;
    left: 65%;
    animation-duration: 40s;
    animation-delay: -20s;
}
.db-6 {
    width: 4px; height: 4px;
    background: #FFD93D;
    opacity: 0.5;
    left: 78%;
    animation-duration: 36s;
    animation-delay: -12s;
}
.db-7 {
    width: 6px; height: 6px;
    background: #7FFFD4;
    opacity: 0.4;
    left: 88%;
    animation-duration: 50s;
    animation-delay: -6s;
}
.db-8 {
    width: 5px; height: 5px;
    background: #FF6B8A;
    opacity: 0.45;
    left: 95%;
    animation-duration: 33s;
    animation-delay: -18s;
}

@keyframes deepBubbleRise {
    0% {
        transform: translateY(0) translateX(0);
    }
    25% {
        transform: translateY(-25vh) translateX(8px);
    }
    50% {
        transform: translateY(-50vh) translateX(-5px);
    }
    75% {
        transform: translateY(-75vh) translateX(12px);
    }
    100% {
        transform: translateY(-110vh) translateX(0);
    }
}

/* ==========================================================================
   ABYSSAL FOOTER
   ========================================================================== */

#abyssal-footer {
    background: #030810;
    padding: 3rem 2rem;
    text-align: center;
}

.depth-indicator {
    font-family: 'Recursive', monospace;
    font-weight: 400;
    font-size: 0.9rem;
    color: #1A8A9E;
    opacity: 0.5;
    letter-spacing: 0.1em;
}

/* ==========================================================================
   Background Gradient Transition (scroll-driven via JS classes)
   ========================================================================== */

body.depth-1 {
    background: #0A4D68;
}

body.depth-2 {
    background: #0B1D3A;
}

body.depth-3 {
    background: #050E1A;
}

body.depth-4 {
    background: #030810;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .reef-cards {
        flex-direction: column;
        align-items: center;
    }

    .card-size-lg,
    .card-size-md,
    .card-size-sm {
        flex: 0 1 100%;
        max-width: 400px;
        margin-top: 0;
    }

    .deep-dive-content {
        padding: 0 1rem;
    }

    .wave-container {
        height: 15%;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 2rem;
    }

    .reef-card {
        padding: 1.4rem 1.2rem;
    }
}
