/* ============================================
   gabs.ai - Surreal Theater of Speech
   Split-screen narrative experience
   ============================================ */

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

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

body {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.7;
    color: #3D3655;
    background: #F5EDE3;
    overflow-x: hidden;
    position: relative;
}

/* --- Film Grain Overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Navigation --- */
#main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 24px 40px;
    z-index: 1000;
    display: flex;
    gap: 32px;
    transition: opacity 0.6s ease;
}

#main-nav.faded {
    opacity: 0.4;
}

.nav-link {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 14px;
    color: #1B1145;
    text-decoration: none;
    letter-spacing: 0.15em;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.nav-link:hover {
    color: #D4776B;
}

/* --- Split Container --- */
#split-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    min-height: 400vh;
    position: relative;
    transition: grid-template-columns 0.2s ease-in-out;
}

/* --- Panels --- */
.panel {
    position: relative;
    overflow: hidden;
}

#left-panel {
    background: #F5EDE3;
    z-index: 1;
}

#right-panel {
    background: #1B1145;
    z-index: 1;
}

/* --- Wobbling Divider --- */
#divider-container {
    position: fixed;
    top: 0;
    left: 60%;
    width: 10px;
    height: 100vh;
    z-index: 100;
    transform: translateX(-50%);
    pointer-events: none;
    transition: left 0.3s ease-in-out, opacity 0.6s ease;
}

#divider-container.hidden {
    opacity: 0;
}

#wobble-divider {
    width: 100%;
    height: 100%;
}

#divider-path {
    animation: wobble 6s ease-in-out infinite;
}

@keyframes wobble {
    0% {
        d: path("M5,0 C3,150 7,200 5,300 C3,400 7,500 5,600 C3,700 7,850 5,1000");
    }
    33% {
        d: path("M5,0 C7,150 3,200 5,300 C7,400 3,500 5,600 C7,700 3,850 5,1000");
    }
    66% {
        d: path("M5,0 C4,150 6,200 5,300 C6,400 4,500 5,600 C4,700 6,850 5,1000");
    }
    100% {
        d: path("M5,0 C3,150 7,200 5,300 C3,400 7,500 5,600 C3,700 7,850 5,1000");
    }
}

/* --- Act I: The Invitation --- */
#act-i-left {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding: 0 10%;
}

#site-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 64px;
    color: #1B1145;
    letter-spacing: -0.01em;
    opacity: 0;
    animation: appear 0.1s ease 0.4s forwards;
    position: relative;
    z-index: 10;
}

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

#act-i-right {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 0 10%;
    position: relative;
}

#tagline {
    font-family: 'Inconsolata', monospace;
    font-weight: 300;
    font-size: 16px;
    color: #D4C8B8;
    letter-spacing: 0.08em;
    opacity: 0;
    filter: blur(12px);
    animation: blurFocus 0.9s ease-out 1.2s forwards;
    position: relative;
    z-index: 10;
}

/* --- Blur Focus Animation --- */
@keyframes blurFocus {
    to {
        opacity: 1;
        filter: blur(0);
    }
}

.blur-observe {
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.8s ease-out, filter 0.8s ease-out;
}

.blur-observe.in-view {
    opacity: 1;
    filter: blur(0);
}

/* --- Floating Word Fragments --- */
.floating-words-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.floating-word {
    position: absolute;
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    color: #1B1145;
    opacity: 0.1;
    animation: floatUp 30s linear infinite;
}

.floating-word.dark-float {
    color: #F5EDE3;
    opacity: 0.08;
}

@keyframes floatUp {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-60px);
    }
}

/* --- Drifting Characters (Act I) --- */
.drifting-text {
    position: absolute;
    bottom: 30%;
    right: -5%;
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 36px;
    color: #1B1145;
    z-index: 10;
    white-space: nowrap;
}

.drift-char {
    display: inline-block;
    opacity: 0;
    animation: driftAcross 3s ease-in-out forwards;
}

@keyframes driftAcross {
    0% {
        opacity: 0;
        transform: translateX(-30px);
    }
    30% {
        opacity: 0.6;
    }
    100% {
        opacity: 0.15;
        transform: translateX(80px);
    }
}

/* --- Act II: The Exchange --- */
#act-ii-left,
#act-ii-right {
    padding: 120px 8% 80px;
}

/* --- Speech Bubbles --- */
.speech-bubble {
    position: relative;
    max-width: 480px;
    padding: 32px 36px;
    margin-bottom: 60px;
    background: transparent;
    border: 2px solid rgba(212, 119, 107, 0.4);
    border-radius: 24px;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.8s ease-out, filter 0.8s ease-out;
}

.speech-bubble.in-view {
    opacity: 1;
    filter: blur(0);
}

/* Human Bubbles (left panel) */
.human-bubble {
    border-radius: 24px 24px 24px 4px;
    margin-right: auto;
}

.human-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    right: -16px;
    width: 0;
    height: 0;
    border-left: 16px solid transparent;
    border-top: 12px solid rgba(212, 119, 107, 0.4);
}

.human-bubble p {
    font-family: 'Libre Baskerville', serif;
    font-size: 16px;
    line-height: 1.7;
    color: #3D3655;
}

/* AI Bubbles (right panel) */
.ai-bubble {
    border-radius: 24px 24px 4px 24px;
    margin-left: auto;
}

.ai-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: -16px;
    width: 0;
    height: 0;
    border-right: 16px solid transparent;
    border-top: 12px solid rgba(212, 119, 107, 0.4);
}

.ai-bubble p {
    font-family: 'Inconsolata', monospace;
    font-weight: 300;
    font-size: 14px;
    letter-spacing: 0.04em;
    line-height: 1.8;
    color: #D4C8B8;
}

/* --- Architectural Speech Bubble Outlines (decorative) --- */
.architectural-bubble {
    position: fixed;
    border: 2px solid rgba(212, 119, 107, 0.15);
    border-radius: 48px;
    pointer-events: none;
    z-index: 2;
}

.arch-bubble-1 {
    width: 400px;
    height: 300px;
    top: 20vh;
    left: -60px;
    transform: rotate(-8deg);
}

.arch-bubble-2 {
    width: 320px;
    height: 240px;
    top: 55vh;
    right: -40px;
    transform: rotate(5deg);
    border-radius: 48px 48px 48px 8px;
}

.arch-bubble-3 {
    width: 500px;
    height: 200px;
    bottom: 15vh;
    left: 30%;
    transform: rotate(-3deg);
    border-radius: 48px 48px 8px 48px;
}

/* --- Act III: The Synthesis --- */
#act-iii {
    position: relative;
    width: 100%;
    min-height: 100vh;
    background: #0D0A1A;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#act-iii::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.07;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

.act-iii-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 48px;
    color: #F5EDE3;
    letter-spacing: -0.01em;
    margin-bottom: 80px;
    z-index: 10;
    position: relative;
}

#particle-field {
    position: relative;
    width: 80%;
    height: 50vh;
    max-width: 1000px;
}

/* --- Particles --- */
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}

.cream-particle {
    background: #F5EDE3;
    left: 0;
    top: var(--y-start);
    animation: particleMoveRight 10s var(--delay) infinite;
}

.indigo-particle {
    background: #1B1145;
    right: 0;
    top: var(--y-start);
    animation: particleMoveLeft 10s var(--delay) infinite;
    box-shadow: 0 0 4px rgba(27, 17, 69, 0.6);
}

@keyframes particleMoveRight {
    0% {
        transform: translateX(0) scale(1);
        background: #F5EDE3;
    }
    45% {
        transform: translateX(calc(50vw - 80px)) scale(1);
        background: #F5EDE3;
    }
    55% {
        transform: translateX(calc(50vw - 40px)) scale(1.3);
        background: #C9A84C;
    }
    65% {
        transform: translateX(calc(50vw - 40px)) scale(1);
        background: #C9A84C;
    }
    100% {
        transform: translateX(0) scale(1);
        background: #F5EDE3;
        opacity: 0;
    }
}

@keyframes particleMoveLeft {
    0% {
        transform: translateX(0) scale(1);
        background: #1B1145;
    }
    45% {
        transform: translateX(calc(-50vw + 80px)) scale(1);
        background: #1B1145;
    }
    55% {
        transform: translateX(calc(-50vw + 40px)) scale(1.3);
        background: #C9A84C;
    }
    65% {
        transform: translateX(calc(-50vw + 40px)) scale(1);
        background: #C9A84C;
    }
    100% {
        transform: translateX(0) scale(1);
        background: #1B1145;
        opacity: 0;
    }
}

/* Merge Point Glow */
#merge-point {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #C9A84C;
    box-shadow: 0 0 40px 15px rgba(201, 168, 76, 0.4), 0 0 80px 30px rgba(201, 168, 76, 0.15);
    animation: mergeGlow 2s ease-in-out infinite;
}

@keyframes mergeGlow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 40px 15px rgba(201, 168, 76, 0.4), 0 0 80px 30px rgba(201, 168, 76, 0.15);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        box-shadow: 0 0 60px 25px rgba(201, 168, 76, 0.5), 0 0 100px 40px rgba(201, 168, 76, 0.2);
    }
}

/* --- Act IV: The Echo --- */
#act-iv {
    padding: 0;
}

.act-iv-content {
    max-width: 640px;
    margin: 0 auto;
    padding: 120px 24px 160px;
}

.act-iv-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 48px;
    color: #1B1145;
    letter-spacing: -0.01em;
    margin-bottom: 80px;
    text-align: center;
}

.contemplation {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 2.0;
    color: #3D3655;
    margin-bottom: 8vh;
    text-align: left;
}

.final-word {
    font-family: 'Inconsolata', monospace;
    font-weight: 300;
    font-size: 16px;
    letter-spacing: 0.08em;
    color: #7B6FA0;
    text-align: center;
    margin-top: 12vh;
    opacity: 0.8;
}

/* --- Act Titles --- */
.act-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* --- Accent / Labels --- */
.label-text {
    font-family: 'Inconsolata', monospace;
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: #7B6FA0;
    opacity: 0.8;
}

/* --- Scroll State Classes (applied via JS) --- */
body.act-ii #split-container {
    grid-template-columns: 1fr 1fr;
}

body.act-ii-mid #split-container {
    grid-template-columns: 1fr 1.5fr;
}

body.act-iii-state #split-container {
    grid-template-columns: 0fr 1fr;
}

body.act-ii #divider-container {
    left: 50%;
}

body.act-ii-mid #divider-container {
    left: 40%;
}

body.act-iii-state #divider-container {
    opacity: 0;
    left: 0%;
}

/* --- Right panel nav adjustment --- */
body.act-ii .nav-link,
body.act-ii-mid .nav-link {
    color: #F5EDE3;
}

body.act-iii-state .nav-link {
    color: #F5EDE3;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    #split-container {
        display: flex;
        flex-direction: column;
    }

    #left-panel,
    #right-panel {
        width: 100%;
    }

    #divider-container {
        display: none;
    }

    /* Horizontal wobble divider for mobile */
    #right-panel::before {
        content: '';
        display: block;
        width: 100%;
        height: 2px;
        background: #D4776B;
        margin: 0 auto;
    }

    #site-title {
        font-size: 42px;
    }

    .act-iii-title,
    .act-iv-title {
        font-size: 32px;
    }

    .speech-bubble {
        max-width: 90%;
    }

    .drifting-text {
        display: none;
    }

    .architectural-bubble {
        display: none;
    }

    #main-nav {
        padding: 16px 20px;
        gap: 16px;
        flex-wrap: wrap;
    }

    .nav-link {
        font-size: 12px;
    }

    .act-iv-content {
        padding: 80px 20px 120px;
    }

    .contemplation {
        font-size: 16px;
        margin-bottom: 6vh;
    }
}

/* --- Selection color --- */
::selection {
    background: rgba(212, 119, 107, 0.3);
    color: #1B1145;
}

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

::-webkit-scrollbar-track {
    background: #F5EDE3;
}

::-webkit-scrollbar-thumb {
    background: #D4C8B8;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #7B6FA0;
}
