/* CSS Reset & Variable Definitions */
:root {
    --bg-main: #06070a;
    --bg-header: rgba(6, 7, 10, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-indigo: #6366f1;
    --accent-violet: #a855f7;
    --accent-pink: #ec4899;
    --accent-emerald: #34d399;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    --font-titles: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Header Navbar Styling */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    z-index: 1000;
}

.logo {
    font-family: var(--font-titles);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header nav a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 2rem;
    font-family: var(--font-titles);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

header nav a:hover {
    color: var(--text-primary);
}

/* Top Progress Line */
.scroll-progress-line {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--accent-gradient);
    z-index: 1001;
    transition: width 0.1s ease-out;
}

/* Parallax Sections & Layout */
.parallax-section {
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 6rem 5% 4rem 5%;
    scroll-snap-align: start;
    border-bottom: 1px solid var(--border-color);
}

/* Background Placeholder layer */
.layer-bg-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.08; /* Subdued to avoid distracting from content */
    z-index: -2;
    pointer-events: none;
}

/* Layout Containers */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    z-index: 5;
}

.container-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
    min-height: 80vh;
}

.container-split {
    display: flex;
    align-items: center;
    gap: 4rem;
}

.column {
    flex: 1;
    width: 50%;
}

/* Text & Headings Styling */
.text-content .step-num {
    display: inline-block;
    font-family: var(--font-titles);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-indigo);
    margin-bottom: 1rem;
    font-weight: 600;
}

.text-content h1 {
    font-family: var(--font-titles);
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -1px;
    margin-bottom: 1.5rem;
    background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-content .subtitle {
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-weight: 300;
}

.text-content .body-text {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.glow-divider {
    height: 2px;
    width: 80px;
    background: var(--accent-gradient);
    margin: 2rem auto 0 auto;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Floating Parallax Elements inside sections */
.parallax-item {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.bubble-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
    padding: 0.6rem 1.2rem;
    font-family: var(--font-titles);
    font-size: 0.85rem;
    color: var(--text-secondary);
    backdrop-filter: blur(4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.pt1 { top: 20%; left: 10%; }
.pt2 { top: 60%; right: 12%; }

.clouds-bg {
    top: 30%;
    left: 20%;
    width: 250px;
    height: 80px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
}

.float-code {
    font-family: 'Courier New', Courier, monospace;
    color: rgba(99, 102, 241, 0.15);
    font-size: 1.5rem;
    font-weight: 700;
}

.code-tag-1 { top: 15%; left: 8%; }
.code-tag-2 { bottom: 15%; right: 15%; }
.code-tag-3 { top: 25%; right: 8%; }
.code-tag-4 { bottom: 20%; left: 12%; }

/* Illustration / Graphics Boxes */
.illustration-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 3rem;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.01);
}

/* Layer 2 Flow Diagram Graphic */
.flow-diagram {
    flex-direction: column;
    gap: 1.5rem;
}

.node {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-family: var(--font-titles);
    font-weight: 500;
    color: var(--text-primary);
    width: 180px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.node-process {
    background: rgba(168, 85, 247, 0.08);
    border-color: rgba(168, 85, 247, 0.3);
}

.node-end {
    background: rgba(236, 72, 153, 0.08);
    border-color: rgba(236, 72, 153, 0.3);
}

.node-arrow {
    font-size: 1.2rem;
    color: var(--text-secondary);
    animation: bounceY 2s infinite ease-in-out;
}

/* Layer 3 Grid Graphic */
.api-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    font-family: var(--font-titles);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.grid-item:hover {
    border-color: var(--accent-indigo);
    color: var(--text-primary);
    transform: scale(1.03);
}

/* Layer 4 Code Terminal Preview */
.console-preview {
    background: #030407;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    max-width: 550px;
    margin: 2.5rem auto 0 auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    text-align: left;
}

.console-head {
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.console-head .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.console-head .dot.red { background: #ef4444; }
.console-head .dot.yellow { background: #f59e0b; }
.console-head .dot.green { background: #10b981; }

.console-head .title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-titles);
    margin-left: 0.5rem;
}

.console-body {
    padding: 1.5rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.line-c {
    display: block;
    color: #e2e8f0;
}

.line-c .k { color: #f43f5e; } /* Keyword */
.line-c .cls { color: #60a5fa; } /* Class */
.line-c .fn { color: #34d399; } /* Function */
.line-c .str { color: #fbbf24; } /* String */

.matrix-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.15;
}

/* FIXED AVATAR WRAPPER (DESKTOP) */
.fixed-avatar-wrapper {
    position: fixed;
    width: 280px;
    height: 280px;
    z-index: 20;
    pointer-events: none;
    display: block;
    transition: all 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.fixed-avatar-wrapper .avatar-avatar {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.4s ease-out;
}

.avatar-char-img {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    z-index: 2;
    mix-blend-mode: screen;
    animation: floatAnimation 4s ease-in-out infinite;
}

.dev-character-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

@keyframes floatAnimation {
    0% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-8px) rotate(0.8deg);
    }
    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

/* Custom transitions inside character SVG */
.cloud-prop, .flow-prop, .db-prop, .code-prop {
    opacity: 0;
    transform-origin: center;
    transform: scale(0.5);
    transition: all 0.6s ease;
}

/* AVATAR DESCENT POSITIONS PER SECTION (100vh heights) */
.fixed-avatar-wrapper.section-1 {
    top: 32%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.layer1-sky .text-content {
    margin-top: 14rem;
}

.fixed-avatar-wrapper.section-1 .cloud-prop {
    opacity: 1;
    transform: scale(1);
}

.fixed-avatar-wrapper.section-2 {
    top: 50%;
    left: 20%;
    transform: translate(0, -50%);
}

.fixed-avatar-wrapper.section-2 .flow-prop {
    opacity: 1;
    transform: scale(1);
}

.fixed-avatar-wrapper.section-3 {
    top: 50%;
    left: 80%;
    transform: translate(-100%, -50%);
}

.fixed-avatar-wrapper.section-3 .db-prop {
    opacity: 1;
    transform: scale(1);
}

.fixed-avatar-wrapper.section-4 {
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.fixed-avatar-wrapper.section-4 .code-prop {
    opacity: 1;
    transform: scale(1);
}

/* SCROLL REVEAL ANIMATIONS */
.reveal-text {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-text.active {
    opacity: 1;
    transform: translateY(0);
}

/* CHAT COMPONENT */
.floating-chat-container {
    position: fixed;
    right: 25px;
    bottom: 75px; /* Sits exactly above the 20px dev badge */
    z-index: 1000;
}

.chat-trigger-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-trigger-btn:hover {
    transform: scale(1.1);
}

.chat-icon-svg {
    width: 24px;
    height: 24px;
}

.chat-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 300px;
    background: #0f1016;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
}

/* Alpine Transitions */
.panel-enter {
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.panel-leave {
    animation: scaleOut 0.2s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

.panel-header h3 {
    font-family: var(--font-titles);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-panel-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-panel-btn:hover {
    color: #ef4444;
}

.panel-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group input, .input-group textarea {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.input-group input:focus, .input-group textarea:focus {
    border-color: var(--accent-indigo);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.send-btn {
    background: var(--accent-gradient);
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    color: #fff;
    font-family: var(--font-titles);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
    width: 100%;
}

.send-btn:hover {
    opacity: 0.9;
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.feedback-box {
    padding: 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
    margin-top: 0.5rem;
}

.feedback-box.success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.feedback-box.error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* FIXED DEV BADGE */
.fixed-dev-badge {
    position: fixed;
    right: 25px;
    bottom: 20px;
    z-index: 99999;
    background: rgba(10, 11, 16, 0.75);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    pointer-events: none;
    backdrop-filter: blur(8px);
}

/* KEYFRAMES & ANIMATIONS */
@keyframes scaleIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes scaleOut {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.85); opacity: 0; }
}

@keyframes bounceY {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

/* RESPONSIVE LAYOUTS (MOBILE FIRST / MEDIA QUERIES) */
@media (max-width: 768px) {
    /* Hide the fixed desktop character wrapper */
    .fixed-avatar-wrapper {
        display: none !important;
    }

    header {
        padding: 1rem 5%;
    }

    header nav a {
        margin-left: 1rem;
        font-size: 0.85rem;
    }

    .parallax-section {
        min-height: auto;
        height: auto;
        padding: 6rem 5% 3rem 5%;
        scroll-snap-align: none; /* Disable scroll snap on mobile for smoother standard scroll */
    }

    .container-split {
        flex-direction: column;
        gap: 2.5rem;
    }

    .column {
        width: 100%;
    }

    /* Force illustration always ABOVE text in mobile */
    .illustration-col {
        order: 1;
    }

    .text-col {
        order: 2;
        text-align: center;
    }

    .text-content h1 {
        font-size: 2.2rem;
    }

    .layer1-sky .text-content {
        margin-top: 0;
    }

    /* Render inline mobile avatars */
    .mobile-avatar-placeholder {
        display: block;
        width: 130px;
        height: 130px;
        margin: 0 auto 1.5rem auto;
        background-image: url('../assets/dev_avatar.png');
        background-size: contain;
        background-repeat: no-repeat;
        mix-blend-mode: screen;
        animation: floatAnimation 4s ease-in-out infinite;
    }

    .illustration-box {
        min-height: auto;
        padding: 2rem 1.5rem;
    }

    .floating-chat-container {
        right: 15px;
        bottom: 70px;
    }

    .chat-panel {
        width: 280px;
    }

    .fixed-dev-badge {
        right: 15px;
        bottom: 15px;
    }
}
