/* ============================================
   concengine.net - Submerged Engine Room
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyss-navy: #03045E;
    --midnight-reef: #023E8A;
    --depth-blue: #0077B6;
    --current-teal: #0096C7;
    --electric-aqua: #00B4D8;
    --foam-cyan: #48CAE4;
    --reef-ice: #90E0EF;
    --spray-mist: #ADE8F4;
    --ice-crystal: #CAF0F8;
    --solar-warm: #FFD166;
    --engine-room: #0A0A1A;
    --brass-tone: #D4A574;
    --brass-dark: #B8956A;
    --dark-blend: #1B1B2F;

    --font-display: 'Righteous', cursive;
    --font-body: 'Nunito', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;

    --bg-color: #03045E;
}

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

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

body {
    background-color: var(--bg-color);
    color: var(--spray-mist);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw, 1.125rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    transition: background-color 0.8s ease;
}

/* --- Depth Gauge (Fixed Right Edge) --- */
#depth-gauge {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 60vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#depth-gauge.visible {
    opacity: 1;
}

#depth-gauge-top {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--brass-tone);
    background: linear-gradient(135deg, var(--brass-tone), var(--brass-dark));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 0;
}

#depth-gauge-top:hover {
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(212, 165, 116, 0.4);
}

#depth-gauge-track {
    position: relative;
    width: 10px;
    flex: 1;
    background: linear-gradient(180deg, var(--brass-tone), var(--brass-dark));
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#depth-gauge-fill {
    position: absolute;
    top: 0;
    left: 1px;
    width: 8px;
    height: 0%;
    background: var(--electric-aqua);
    border-radius: 4px;
    transition: height 0.15s ease-out;
    box-shadow: 0 0 8px rgba(0, 180, 216, 0.6);
}

.depth-tick {
    position: absolute;
    left: -6px;
    width: 22px;
    height: 1px;
    background: rgba(202, 240, 248, 0.5);
}

.depth-tick::after {
    content: attr(data-label);
    position: absolute;
    right: 28px;
    top: -6px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--reef-ice);
    opacity: 0.7;
    white-space: nowrap;
}

/* --- Lens Flare --- */
.lens-flare {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 6px;
    pointer-events: none;
    z-index: 999;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, transparent 0%, var(--solar-warm) 20%, var(--solar-warm) 50%, transparent 100%);
}

.lens-flare.active-gold {
    animation: flareGold 800ms ease-out forwards;
}

.lens-flare.active-cool {
    background: linear-gradient(90deg, transparent 0%, var(--foam-cyan) 20%, var(--foam-cyan) 50%, transparent 100%);
    animation: flareCool 600ms ease-out forwards;
}

@keyframes flareGold {
    0% { opacity: 0.8; transform: scaleX(0); }
    40% { opacity: 0.6; transform: scaleX(1); }
    100% { opacity: 0; transform: scaleX(1); }
}

@keyframes flareCool {
    0% { opacity: 0.6; transform: scaleX(0); }
    40% { opacity: 0.4; transform: scaleX(1); }
    100% { opacity: 0; transform: scaleX(1); }
}

/* --- Particles --- */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--reef-ice);
    opacity: 0;
    animation: particleRise linear infinite;
}

@keyframes particleRise {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: var(--p-opacity, 0.2);
    }
    90% {
        opacity: var(--p-opacity, 0.2);
    }
    100% {
        transform: translateY(calc(-100vh - 20px)) translateX(var(--p-drift, 30px));
        opacity: 0;
    }
}

.particle.bioluminescent {
    animation: bioFloat linear infinite;
}

@keyframes bioFloat {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 0;
        background: var(--electric-aqua);
    }
    10% {
        opacity: var(--p-opacity, 0.3);
    }
    25% {
        background: var(--foam-cyan);
    }
    50% {
        transform: translateX(var(--p-drift, 60px)) translateY(-20px);
        background: var(--electric-aqua);
    }
    75% {
        background: var(--foam-cyan);
    }
    90% {
        opacity: var(--p-opacity, 0.3);
    }
    100% {
        transform: translateX(calc(var(--p-drift, 60px) * -1)) translateY(0);
        opacity: 0;
        background: var(--electric-aqua);
    }
}

/* --- Section: Surface (0-100vh) --- */
.section-surface {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--abyss-navy);
}

/* Water Caustics */
.caustics {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.6s ease;
    background:
        radial-gradient(ellipse 300px 300px at 20% 30%, var(--depth-blue) 0%, transparent 70%),
        radial-gradient(ellipse 250px 250px at 60% 60%, var(--electric-aqua) 0%, transparent 70%),
        radial-gradient(ellipse 350px 350px at 80% 20%, var(--depth-blue) 0%, transparent 70%);
    background-size: 400px 400px, 350px 350px, 450px 450px;
    animation:
        causticShift1 10s ease-in-out infinite alternate,
        causticShift2 14s ease-in-out infinite alternate,
        causticShift3 18s ease-in-out infinite alternate;
    mix-blend-mode: screen;
}

.caustics.active {
    opacity: 0.08;
}

@keyframes causticShift1 {
    0% { background-position: 0% 0%, 50% 50%, 80% 20%; }
    100% { background-position: 30% 40%, 20% 70%, 50% 50%; }
}

@keyframes causticShift2 {
    0% { background-position: 50% 50%, 0% 0%, 60% 40%; }
    100% { background-position: 70% 20%, 40% 60%, 30% 80%; }
}

@keyframes causticShift3 {
    0% { background-position: 80% 20%, 60% 40%, 0% 0%; }
    100% { background-position: 40% 60%, 80% 10%, 60% 70%; }
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.hero-title-wrapper {
    position: relative;
    display: inline-block;
    overflow: hidden;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 6rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--foam-cyan);
    position: relative;
    z-index: 2;
    line-height: 1;
    margin-bottom: 0;
    clip-path: inset(0 0 50% 0);
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    animation: letterFadeIn 800ms ease-out forwards;
}

@keyframes letterFadeIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.waterline {
    position: absolute;
    top: 50%;
    left: -10%;
    width: 120%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(72, 202, 228, 0.3) 20%, rgba(72, 202, 228, 0.5) 50%, rgba(72, 202, 228, 0.3) 80%, transparent 100%);
    z-index: 5;
    animation: waterlineRipple 4s ease-in-out infinite;
}

@keyframes waterlineRipple {
    0%, 100% { transform: translateY(0) scaleY(1); }
    50% { transform: translateY(1px) scaleY(1.5); }
}

.hero-title-refracted {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 8vw, 6rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--depth-blue);
    position: absolute;
    top: 0;
    left: 3px;
    z-index: 1;
    line-height: 1;
    opacity: 0.6;
    clip-path: inset(50% 0 0 0);
    transform: scaleY(1.05) translateY(2px);
    animation: refractionWobble 4s ease-in-out infinite;
}

.hero-title-refracted .letter {
    display: inline-block;
    opacity: 0;
    animation: letterFadeIn 800ms ease-out forwards;
}

@keyframes refractionWobble {
    0%, 100% { transform: scaleY(1.05) translateY(2px) translateX(0); }
    25% { transform: scaleY(1.04) translateY(3px) translateX(1px); }
    75% { transform: scaleY(1.06) translateY(1px) translateX(-1px); }
}

.hero-tagline {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--spray-mist);
    margin-top: 2rem;
    opacity: 0;
    animation: taglineFadeIn 800ms ease-out 1800ms forwards;
}

@keyframes taglineFadeIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Scroll Prompt */
.scroll-prompt {
    margin-top: 3rem;
    opacity: 0;
    animation: scrollPromptFadeIn 600ms ease-out 2200ms forwards;
}

@keyframes scrollPromptFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.scroll-chevron {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    animation: chevronPulse 2s ease-in-out infinite;
}

@keyframes chevronPulse {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(6px); }
}

.chevron-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--foam-cyan);
}

.chevron-dot:nth-child(1) { opacity: 0.2; }
.chevron-dot:nth-child(2) { opacity: 0.4; transform: translateX(-3px); }
.chevron-dot:nth-child(3) { opacity: 0.6; transform: translateX(-5px); }
.chevron-dot:nth-child(4) { opacity: 0.4; transform: translateX(-3px); }
.chevron-dot:nth-child(5) { opacity: 0.2; }

/* --- Section: Shallows (100vh - 300vh) --- */
.section-shallows {
    position: relative;
    min-height: 200vh;
    padding: 10vh 5vw 10vh;
    display: flex;
    flex-direction: column;
    gap: 20vh;
    background-color: var(--abyss-navy);
}

/* Content Panels (Shallows) */
.panel {
    max-width: min(70vw, 900px);
    padding: clamp(2rem, 4vw, 4rem);
    border-radius: 16px;
    border: 1px solid rgba(144, 224, 239, 0.25);
    background: rgba(2, 62, 138, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: relative;
    z-index: 10;
}

.panel-left {
    align-self: flex-start;
    margin-left: 10%;
}

.panel-right {
    align-self: flex-end;
    margin-right: 10%;
}

/* Animation states for scroll reveal */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

.animate-on-scroll[data-direction="left"] {
    transform: translateY(60px) translateX(-40px);
}

.animate-on-scroll[data-direction="right"] {
    transform: translateY(60px) translateX(40px);
}

.animate-on-scroll[data-direction="left"].visible,
.animate-on-scroll[data-direction="right"].visible {
    transform: translateY(0) translateX(0);
}

/* Section Headings */
.section-heading {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--foam-cyan);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    position: relative;
}

.panel p {
    margin-bottom: 1rem;
}

.panel p:last-of-type {
    margin-bottom: 0;
}

/* Coral Circuit SVG */
.coral-circuit {
    position: absolute;
    width: 40vw;
    height: 40vh;
    opacity: 0.04;
    z-index: 1;
    pointer-events: none;
}

.coral-circuit-1 {
    top: 5vh;
    right: 0;
}

.coral-circuit-2 {
    bottom: 10vh;
    left: 0;
}

.coral-path {
    fill: none;
    stroke: var(--depth-blue);
    stroke-width: 1.5;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 3s ease-out;
}

.coral-circuit.animate .coral-path {
    stroke-dashoffset: 0;
}

/* Bubble clusters */
.bubble-cluster {
    position: relative;
    height: 5vh;
    width: 100%;
}

/* --- Section: Engine Room (300vh-500vh) --- */
.section-engine {
    position: relative;
    min-height: 200vh;
    padding: 10vh 5vw 10vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40vh;
    background: linear-gradient(180deg, var(--abyss-navy) 0%, var(--dark-blend) 100%);
}

.engine-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(72, 202, 228, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(72, 202, 228, 0.03) 1px, transparent 1px);
    background-size: 8px 8px;
    pointer-events: none;
    z-index: 1;
}

.panel-engine {
    max-width: min(80vw, 1000px);
    width: 80%;
    align-self: center;
    margin-left: auto;
    margin-right: auto;
    border-image: linear-gradient(135deg, var(--ice-crystal), var(--spray-mist), var(--ice-crystal)) 1;
    border-width: 1px;
    border-style: solid;
    border-radius: 0;
    background: rgba(2, 62, 138, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: relative;
    z-index: 10;
}

.panel-engine .section-heading {
    color: var(--ice-crystal);
}

.tech-label {
    display: block;
    margin-top: 1.5rem;
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1.2vw, 0.875rem);
    color: var(--reef-ice);
    opacity: 0.7;
    letter-spacing: 0.05em;
}

/* --- Section: The Deep (500vh-650vh) --- */
.section-deep {
    position: relative;
    min-height: 150vh;
    padding: 15vh 5vw 15vh;
    background: var(--engine-room);
    display: flex;
    align-items: center;
    justify-content: center;
}

.deep-content {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 15vh;
}

.panel-deep {
    background: transparent;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    max-width: 640px;
    padding: clamp(1.5rem, 3vw, 3rem) 0;
}

.deep-heading {
    color: var(--ice-crystal);
    text-shadow: 0 0 20px rgba(0, 180, 216, 0.4), 0 0 40px rgba(0, 180, 216, 0.1);
}

.section-deep .panel-deep p {
    text-shadow: 0 0 15px rgba(0, 180, 216, 0.2);
    color: var(--spray-mist);
}

.deep-signature {
    text-align: center;
    padding: 4rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    opacity: 0.5;
}

/* --- Heading Flare Effect --- */
.section-heading::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--foam-cyan), transparent 70%);
    transform: scaleX(0);
    transform-origin: left center;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.section-heading.flare-active::before {
    animation: headingFlare 600ms ease-out forwards;
}

@keyframes headingFlare {
    0% { opacity: 0.5; transform: scaleX(0); }
    40% { opacity: 0.4; transform: scaleX(1); }
    100% { opacity: 0; transform: scaleX(1); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .panel-left,
    .panel-right {
        margin-left: 5%;
        margin-right: 5%;
        max-width: 90vw;
    }

    .panel-engine {
        width: 90%;
        max-width: 90vw;
    }

    #depth-gauge {
        right: 8px;
        height: 40vh;
    }

    .depth-tick::after {
        display: none;
    }

    .section-shallows {
        gap: 12vh;
    }

    .section-engine {
        gap: 20vh;
    }

    .hero-title,
    .hero-title-refracted {
        font-size: clamp(2rem, 10vw, 4rem);
    }
}

@media (max-width: 480px) {
    .panel {
        padding: 1.5rem;
    }

    .section-heading {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }
}
