/* ===================================================
   gabs.cx - Styles
   Overheard conversations in a fever dream
   =================================================== */

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

:root {
    --void-indigo: #0D0B1E;
    --twilight-plum: #1A1433;
    --warm-parchment: #F2E6D9;
    --warm-stone: #C9B8A8;
    --medium-orchid: #BA55D3;
    --teal-foam: #4ECDC4;
    --coral-shout: #FF6B6B;
    --muted-grape: #2D2654;
    --deep-bottom: #12091F;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--void-indigo);
    color: var(--warm-parchment);
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.7;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* Grain Texture Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: overlay;
    opacity: 0.04;
    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)' fill='%23F2E6D9'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Typography --- */
.playfair {
    font-family: 'Playfair Display', serif;
}

.caveat {
    font-family: 'Caveat', cursive;
}

/* --- Opening Sequence --- */
.opening-sequence {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 2;
}

.quotation-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.quotation-rain .quote-char {
    position: absolute;
    font-family: 'Playfair Display', serif;
    font-style: italic;
    color: var(--medium-orchid);
    opacity: 0;
    animation: quoteRise 12s linear infinite;
    pointer-events: none;
    user-select: none;
}

@keyframes quoteRise {
    0% {
        opacity: 0;
        transform: translateY(0) rotate(0deg);
    }
    10% {
        opacity: 0.08;
    }
    50% {
        opacity: 0.06;
    }
    90% {
        opacity: 0.03;
    }
    100% {
        opacity: 0;
        transform: translateY(-120vh) rotate(15deg);
    }
}

.title-container {
    position: relative;
    z-index: 2;
    text-align: center;
    opacity: 0;
}

.title-container.visible {
    opacity: 1;
}

.site-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--warm-parchment);
    letter-spacing: -0.02em;
    line-height: 0.95;
    text-shadow: 0 0 30px rgba(186, 85, 211, 0.3);
    overflow: hidden;
}

.site-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
}

.site-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
    animation: letterBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.subtitle {
    font-family: 'Caveat', cursive;
    font-style: italic;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: var(--medium-orchid);
    opacity: 0;
    margin-top: 1.5rem;
    transition: opacity 1.2s ease;
}

.subtitle.visible {
    opacity: 0.7;
}

/* --- Whisper Margin --- */
.whisper-margin {
    position: fixed;
    top: 0;
    left: 0;
    width: 35%;
    height: 100vh;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}

.whisper-fragment {
    position: absolute;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: var(--medium-orchid);
    opacity: 0;
    transition: opacity 0.8s ease;
    white-space: nowrap;
}

.whisper-fragment.active {
    opacity: 0.6;
}

.whisper-fragment[data-section="0"] { top: 20%; left: 8%; transform: rotate(-3deg); }
.whisper-fragment[data-section="1"] { top: 35%; left: 12%; transform: rotate(2deg); }
.whisper-fragment[data-section="2"] { top: 50%; left: 5%; transform: rotate(-5deg); }
.whisper-fragment[data-section="3"] { top: 65%; left: 15%; transform: rotate(1deg); }
.whisper-fragment[data-section="4"] { top: 78%; left: 8%; transform: rotate(-2deg); }
.whisper-fragment[data-section="5"] { top: 88%; left: 10%; transform: rotate(4deg); }

/* Decorative Quotation Marks */
.quote-decoration {
    position: absolute;
    font-size: 180px;
    font-style: italic;
    color: var(--warm-parchment);
    opacity: 0.06;
    animation: quoteFloat 20s linear infinite;
    pointer-events: none;
    user-select: none;
}

#qd1 { left: 5%; font-size: 200px; animation-duration: 25s; animation-delay: 0s; }
#qd2 { left: 20%; font-size: 140px; animation-duration: 30s; animation-delay: -5s; }
#qd3 { left: 10%; font-size: 260px; animation-duration: 22s; animation-delay: -8s; }
#qd4 { left: 28%; font-size: 120px; animation-duration: 28s; animation-delay: -12s; }
#qd5 { left: 3%; font-size: 300px; animation-duration: 35s; animation-delay: -3s; }
#qd6 { left: 18%; font-size: 160px; animation-duration: 20s; animation-delay: -15s; }
#qd7 { left: 25%; font-size: 220px; animation-duration: 27s; animation-delay: -7s; }
#qd8 { left: 8%; font-size: 180px; animation-duration: 32s; animation-delay: -20s; }

@keyframes quoteFloat {
    0% {
        transform: translateY(100vh) rotate(-10deg);
        opacity: 0;
    }
    5% {
        opacity: 0.07;
    }
    50% {
        opacity: 0.05;
    }
    95% {
        opacity: 0.02;
    }
    100% {
        transform: translateY(-120vh) rotate(10deg);
        opacity: 0;
    }
}

/* --- Speech Bubble Ghosts --- */
.speech-bubbles-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.speech-bubble {
    position: absolute;
    opacity: 0;
    animation: bubbleDrift 18s ease-in-out infinite;
}

.speech-bubble:nth-child(1) { top: 10%; left: 55%; opacity: 0.25; animation-duration: 22s; animation-delay: 0s; transform: rotate(-8deg); }
.speech-bubble:nth-child(2) { top: 30%; left: 75%; opacity: 0.15; animation-duration: 18s; animation-delay: -4s; transform: rotate(12deg); }
.speech-bubble:nth-child(3) { top: 55%; left: 40%; opacity: 0.2; animation-duration: 25s; animation-delay: -8s; transform: rotate(-5deg); }
.speech-bubble:nth-child(4) { top: 75%; left: 85%; opacity: 0.3; animation-duration: 16s; animation-delay: -2s; transform: rotate(10deg); }
.speech-bubble:nth-child(5) { top: 20%; left: 65%; opacity: 0.18; animation-duration: 20s; animation-delay: -10s; transform: rotate(-12deg); }
.speech-bubble:nth-child(6) { top: 45%; left: 50%; opacity: 0.22; animation-duration: 24s; animation-delay: -6s; transform: rotate(7deg); }
.speech-bubble:nth-child(7) { top: 85%; left: 60%; opacity: 0.35; animation-duration: 15s; animation-delay: -1s; transform: rotate(-15deg); }
.speech-bubble:nth-child(8) { top: 65%; left: 70%; opacity: 0.12; animation-duration: 28s; animation-delay: -14s; transform: rotate(5deg); }

@keyframes bubbleDrift {
    0% {
        transform: translate(0, 0) rotate(var(--start-rot, 0deg));
    }
    25% {
        transform: translate(20px, -30px) rotate(calc(var(--start-rot, 0deg) + 5deg));
    }
    50% {
        transform: translate(-15px, -10px) rotate(calc(var(--start-rot, 0deg) - 3deg));
    }
    75% {
        transform: translate(10px, 20px) rotate(calc(var(--start-rot, 0deg) + 8deg));
    }
    100% {
        transform: translate(0, 0) rotate(var(--start-rot, 0deg));
    }
}

/* --- Interstitial Voids --- */
.interstitial-void {
    position: relative;
    height: 60vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.final-void {
    height: 40vh;
}

.sine-wave {
    position: absolute;
    width: 100%;
    height: 100px;
    opacity: 0.15;
}

.sine-wave-2 {
    top: 40%;
    opacity: 0.1;
}

.sine-wave-3 {
    top: 60%;
    opacity: 0.12;
}

.sine-path {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    animation: sineDrawIn 4s ease-out forwards, sineFlow 8s ease-in-out infinite 4s;
}

@keyframes sineDrawIn {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes sineFlow {
    0% {
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* --- Thought Panels --- */
.thought-panel {
    position: relative;
    width: 100%;
    padding: 0;
    z-index: 3;
    margin-top: -60px;
    margin-bottom: -60px;
}

.thought-panel .panel-content {
    position: relative;
    margin-left: 40%;
    margin-right: 5%;
    padding: 4rem 3.5rem;
    background: var(--twilight-plum);
    clip-path: polygon(0 8%, 100% 0, 100% 92%, 0 100%);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.thought-panel.in-view .panel-content {
    opacity: 1;
    transform: translateX(0);
}

/* Alternating offsets for the meandering effect */
.thought-panel[data-panel="1"] .panel-content { margin-left: 38%; clip-path: polygon(0 6%, 100% 0, 100% 94%, 0 100%); }
.thought-panel[data-panel="2"] .panel-content { margin-left: 42%; clip-path: polygon(0 0, 100% 7%, 100% 100%, 0 93%); }
.thought-panel[data-panel="3"] .panel-content { margin-left: 36%; clip-path: polygon(0 10%, 100% 0, 100% 90%, 0 100%); }
.thought-panel[data-panel="4"] .panel-content { margin-left: 44%; clip-path: polygon(0 0, 100% 9%, 100% 100%, 0 91%); }
.thought-panel[data-panel="5"] .panel-content { margin-left: 40%; clip-path: polygon(0 5%, 100% 0, 100% 95%, 0 100%); }
.thought-panel[data-panel="6"] .panel-content { margin-left: 38%; clip-path: polygon(0 0, 100% 8%, 100% 100%, 0 92%); }

.panel-heading {
    font-weight: 700;
    font-size: clamp(2.8rem, 6vw, 5rem);
    letter-spacing: -0.02em;
    line-height: 0.95;
    color: var(--warm-parchment);
    text-shadow: 0 0 30px rgba(186, 85, 211, 0.3);
    margin-bottom: 2rem;
}

.panel-body p {
    color: var(--warm-stone);
    margin-bottom: 1.2rem;
    max-width: 600px;
}

.panel-body p:last-child {
    margin-bottom: 0;
}

/* Word stagger animation */
.panel-body .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    margin-right: 0.25em;
}

.panel-body .word.visible {
    opacity: 1;
    transform: translateY(0);
}

.panel-heading .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    margin-right: 0.2em;
}

.panel-heading .word.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Radial Navigation --- */
.radial-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
}

.mouth-glyph {
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseAttention 2s ease-in-out infinite;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mouth-glyph:hover {
    transform: scale(1.1);
}

.mouth-glyph.active {
    transform: scale(1.33);
    animation: none;
}

.mouth-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawMouth 1.5s ease-out 1s forwards;
}

@keyframes drawMouth {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes pulseAttention {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.radial-menu {
    position: absolute;
    bottom: 0;
    right: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.radial-menu.open {
    pointer-events: auto;
    opacity: 1;
}

.radial-link {
    position: absolute;
    display: block;
    color: var(--teal-foam);
    text-decoration: none;
    font-size: 1.3rem;
    white-space: nowrap;
    opacity: 0;
    transform: translate(0, 0) scale(0.5);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
    padding: 0.3rem 0.6rem;
    pointer-events: auto;
}

.radial-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0.6rem;
    right: 0.6rem;
    height: 1.5px;
    background: var(--teal-foam);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.radial-link:hover::after {
    transform: scaleX(1);
}

.radial-link:hover {
    color: var(--coral-shout);
}

.radial-menu.open .radial-link {
    opacity: 1;
}

/* Positions calculated in JS, but base hover state here */
.radial-menu.open .radial-link[data-index="0"] { transition-delay: 0ms; }
.radial-menu.open .radial-link[data-index="1"] { transition-delay: 50ms; }
.radial-menu.open .radial-link[data-index="2"] { transition-delay: 100ms; }
.radial-menu.open .radial-link[data-index="3"] { transition-delay: 150ms; }
.radial-menu.open .radial-link[data-index="4"] { transition-delay: 200ms; }
.radial-menu.open .radial-link[data-index="5"] { transition-delay: 250ms; }

/* --- Scroll Background Shift (handled in JS but base transition here) --- */
body {
    transition: background-color 0.3s ease;
}

/* --- Responsive adjustments --- */
@media (max-width: 1024px) {
    .whisper-margin {
        display: none;
    }

    .thought-panel .panel-content {
        margin-left: 10%;
        margin-right: 5%;
    }

    .thought-panel[data-panel="1"] .panel-content,
    .thought-panel[data-panel="2"] .panel-content,
    .thought-panel[data-panel="3"] .panel-content,
    .thought-panel[data-panel="4"] .panel-content,
    .thought-panel[data-panel="5"] .panel-content,
    .thought-panel[data-panel="6"] .panel-content {
        margin-left: 10%;
    }
}

@media (max-width: 768px) {
    .thought-panel .panel-content {
        margin-left: 5%;
        margin-right: 5%;
        padding: 3rem 2rem;
    }

    .thought-panel[data-panel="1"] .panel-content,
    .thought-panel[data-panel="2"] .panel-content,
    .thought-panel[data-panel="3"] .panel-content,
    .thought-panel[data-panel="4"] .panel-content,
    .thought-panel[data-panel="5"] .panel-content,
    .thought-panel[data-panel="6"] .panel-content {
        margin-left: 5%;
    }

    .panel-heading {
        font-size: clamp(2rem, 6vw, 3.5rem);
    }

    .interstitial-void {
        height: 40vh;
    }

    .radial-nav {
        bottom: 1rem;
        right: 1rem;
    }
}
