/* ============================================
   GGIGGL.com v2 — The Anatomy of a Giggle
   Surrealist Dream Logic / Five-Act Narrative
   ============================================ */

:root {
    --void-indigo: #0B0A1A;
    --dreaming-mauve: #1E1232;
    --laryngeal-pink: #FF6B9D;
    --resonance-teal: #3DFFC0;
    --uvula-gold: #FFCA3A;
    --pale-breath: #E8E0F0;
    --whisper-lilac: #9B8FB8;
    --belly-laugh-red: #FF3366;
}

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

html {
    scroll-behavior: smooth;
    background: var(--void-indigo);
}

body {
    font-family: 'Outfit', sans-serif;
    font-weight: 300;
    font-size: clamp(16px, 1.1vw, 19px);
    line-height: 1.7;
    letter-spacing: 0.01em;
    color: var(--pale-breath);
    background: var(--void-indigo);
    overflow-x: hidden;
}

/* ---- Shared Typography ---- */

h2, h3 {
    font-family: 'Unbounded', sans-serif;
    font-weight: 700;
    line-height: 1.15;
}

.annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(14px, 1vw, 18px);
    color: var(--uvula-gold);
    transform: rotate(-2deg);
    display: inline-block;
}

/* ---- Act Sections (each min 100vh) ---- */

.act {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.act-label {
    position: absolute;
    bottom: 2vh;
    right: 3vw;
    font-family: 'Caveat', cursive;
    font-size: clamp(12px, 0.9vw, 15px);
    color: var(--whisper-lilac);
    opacity: 0.4;
    transform: rotate(-2deg);
    pointer-events: none;
}

/* ============================================
   ACT I — Genesis
   ============================================ */

#act-genesis {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120vh;
    background: var(--void-indigo);
}

.genesis-void {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
}

/* Synapse burst */
.synapse-burst {
    position: absolute;
    top: 28%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
}

.synapse-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--uvula-gold);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: synapse-pulse 2.4s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 202, 58, 0.4), 0 0 60px rgba(255, 202, 58, 0.15);
}

.synapse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 1px solid var(--uvula-gold);
    transform: translate(-50%, -50%);
    opacity: 0;
}

.synapse-ring--1 {
    width: 40px;
    height: 40px;
    animation: ring-expand 2.4s ease-out infinite 0s;
}
.synapse-ring--2 {
    width: 40px;
    height: 40px;
    animation: ring-expand 2.4s ease-out infinite 0.6s;
}
.synapse-ring--3 {
    width: 40px;
    height: 40px;
    animation: ring-expand 2.4s ease-out infinite 1.2s;
}

@keyframes synapse-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; box-shadow: 0 0 20px rgba(255, 202, 58, 0.4), 0 0 60px rgba(255, 202, 58, 0.15); }
    50% { transform: translate(-50%, -50%) scale(1.8); opacity: 0.6; box-shadow: 0 0 40px rgba(255, 202, 58, 0.6), 0 0 90px rgba(255, 202, 58, 0.25); }
}

@keyframes ring-expand {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0.7; }
    100% { transform: translate(-50%, -50%) scale(5); opacity: 0; }
}

/* Title letters */
.genesis-title {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 0.05em;
    font-family: 'Unbounded', sans-serif;
    font-weight: 900;
    font-size: clamp(48px, 9vw, 140px);
    color: var(--pale-breath);
    margin-top: 10vh;
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(40px);
    animation: letter-arrive 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: font-variation-settings 0.3s ease;
}

.letter--g1 { animation-delay: 0.3s; }
.letter--g2 { animation-delay: 0.5s; }
.letter--i  { animation-delay: 0.7s; }
.letter--g3 { animation-delay: 0.9s; }
.letter--g4 { animation-delay: 1.1s; }
.letter--l  { animation-delay: 1.3s; }

@keyframes letter-arrive {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Letter vibration after arrival (applied via JS) */
.letter.vibrating {
    animation: letter-jitter 0.08s linear infinite;
}

@keyframes letter-jitter {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(1.5px, -1px); }
    50%  { transform: translate(-1px, 1.5px); }
    75%  { transform: translate(1px, 0.5px); }
    100% { transform: translate(-0.5px, -1.5px); }
}

.genesis-subtitle {
    margin-top: 3vh;
    opacity: 0;
    animation: fade-in 1.2s ease forwards 2.2s;
}

@keyframes fade-in {
    to { opacity: 1; }
}

/* Sine divider */
.sine-divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    pointer-events: none;
}

.sine-divider svg {
    width: 100%;
    height: 100%;
}

.sine-path--pink { stroke: var(--laryngeal-pink); opacity: 0.6; }
.sine-path--teal { stroke: var(--resonance-teal); opacity: 0.5; }
.sine-path--gold { stroke: var(--uvula-gold); opacity: 0.4; }

/* Floating mouths */
.floating-mouth {
    position: absolute;
    opacity: 0.2;
    pointer-events: none;
}

.mouth--specimen-1 {
    width: 100px;
    top: 18%;
    left: 8%;
    animation: mouth-drift-1 42s ease-in-out infinite;
}

.mouth--specimen-2 {
    width: 70px;
    top: 65%;
    right: 12%;
    animation: mouth-drift-2 55s ease-in-out infinite;
}

.mouth--specimen-3 {
    width: 55px;
    top: 40%;
    right: 22%;
    animation: mouth-drift-3 48s ease-in-out infinite;
    opacity: 0.15;
}

@keyframes mouth-drift-1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(30px, -20px) rotate(3deg); }
    50%  { transform: translate(-15px, 15px) rotate(-2deg); }
    75%  { transform: translate(20px, 10px) rotate(1deg); }
}

@keyframes mouth-drift-2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33%  { transform: translate(-25px, 15px) rotate(-3deg); }
    66%  { transform: translate(15px, -25px) rotate(2deg); }
}

@keyframes mouth-drift-3 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    20%  { transform: translate(18px, -12px) rotate(2deg); }
    50%  { transform: translate(-10px, 20px) rotate(-4deg); }
    80%  { transform: translate(22px, 8px) rotate(1deg); }
}


/* ============================================
   ACT II — Descent
   ============================================ */

#act-descent {
    min-height: 180vh;
    background: linear-gradient(180deg, var(--void-indigo) 0%, var(--dreaming-mauve) 40%, var(--void-indigo) 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 10vh 5vw 15vh;
}

.descent-container {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 55% 40%;
    gap: 5%;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.throat-diagram-col {
    position: sticky;
    top: 10vh;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.throat-cross-section {
    width: 100%;
    max-width: 400px;
    height: auto;
}

/* Path-draw animation: all paths start hidden */
.throat-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.05s linear;
}

/* Annotations */
.descent-annotations {
    padding-top: 18vh;
    display: flex;
    flex-direction: column;
    gap: 18vh;
}

.annotation-item {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.annotation-item.revealed {
    opacity: 1;
    transform: translateX(0);
}

.annotation-line {
    display: block;
    width: 40px;
    height: 1px;
    background: var(--whisper-lilac);
    margin-bottom: 8px;
    opacity: 0.5;
}

.annotation-item .annotation {
    font-size: clamp(15px, 1.2vw, 20px);
    line-height: 1.6;
    max-width: 320px;
}


/* ============================================
   ACT III — Resonance
   ============================================ */

#act-resonance {
    min-height: 130vh;
    background: var(--void-indigo);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 15vh 0;
}

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

.wave-canvas {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 300px;
    transform: translateY(-50%);
}

.resonance-wave--pink { stroke: var(--laryngeal-pink); opacity: 0.7; }
.resonance-wave--teal { stroke: var(--resonance-teal); opacity: 0.6; }
.resonance-wave--gold { stroke: var(--uvula-gold); opacity: 0.5; }

/* Broken-grid content cards */
.resonance-content {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2vw;
    padding: 0 5vw;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.resonance-card {
    background: rgba(30, 18, 50, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--resonance-teal);
    padding: clamp(24px, 2.5vw, 40px);
    position: relative;
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Vibration halo on hover */
.resonance-card::before,
.resonance-card::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.6s ease;
}

.resonance-card::before {
    border: 1px solid var(--laryngeal-pink);
    opacity: 0;
}

.resonance-card::after {
    border: 1px solid var(--laryngeal-pink);
    opacity: 0;
}

.resonance-card:hover {
    border-color: var(--laryngeal-pink);
    box-shadow: 0 0 40px rgba(255, 107, 157, 0.12);
}

.resonance-card:hover::before {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 0.2;
}

.resonance-card:hover::after {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 0.08;
}

.resonance-card h3 {
    font-size: clamp(22px, 2.2vw, 36px);
    color: var(--pale-breath);
    margin-bottom: 0.6em;
}

.resonance-card p {
    color: var(--whisper-lilac);
    font-weight: 300;
}

/* Broken grid placements */
.resonance-card--1 {
    grid-column: 1 / 6;
    grid-row: 1;
    margin-top: 5vh;
}

.resonance-card--2 {
    grid-column: 7 / 13;
    grid-row: 1;
    margin-top: 15vh;
}

.resonance-card--3 {
    grid-column: 2 / 7;
    grid-row: 2;
    margin-top: -3vh;
}

.resonance-card--4 {
    grid-column: 8 / 13;
    grid-row: 2;
    margin-top: 6vh;
}

.resonance-card--5 {
    grid-column: 4 / 10;
    grid-row: 3;
    margin-top: 4vh;
    border-color: var(--uvula-gold);
    background: rgba(30, 18, 50, 0.4);
}

.resonance-card--5:hover {
    border-color: var(--uvula-gold);
    box-shadow: 0 0 40px rgba(255, 202, 58, 0.12);
}

.resonance-annotation {
    font-size: clamp(16px, 1.3vw, 22px);
}


/* ============================================
   ACT IV — Escape
   ============================================ */

#act-escape {
    min-height: 150vh;
    background: radial-gradient(ellipse at center, var(--dreaming-mauve) 0%, var(--void-indigo) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 15vh 5vw;
}

.escape-center-origin {
    position: relative;
    width: min(90vw, 1200px);
    height: min(80vh, 900px);
}

.burst-fragment {
    position: absolute;
    background: rgba(30, 18, 50, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid var(--whisper-lilac);
    padding: clamp(18px, 2vw, 32px);
    max-width: 280px;
    opacity: 0;
    transition: opacity 0.8s ease, transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.burst-fragment h3 {
    font-size: clamp(16px, 1.4vw, 22px);
    color: var(--laryngeal-pink);
    margin-bottom: 0.4em;
}

.burst-fragment p {
    color: var(--whisper-lilac);
    font-size: clamp(13px, 0.9vw, 16px);
    line-height: 1.6;
}

/* Initial positions: clustered at center */
.burst-fragment--1 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.burst-fragment--2 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.burst-fragment--3 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.burst-fragment--4 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.burst-fragment--5 { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.burst-fragment--6 { top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* Teardrop particles */
.teardrop-field {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.teardrop {
    position: absolute;
    bottom: -20px;
    width: 0;
    height: 0;
    border-left: var(--td-size, 6px) solid transparent;
    border-right: var(--td-size, 6px) solid transparent;
    border-bottom: calc(var(--td-size, 6px) * 2) solid var(--td-color, var(--resonance-teal));
    border-radius: 0 0 50% 50%;
    opacity: var(--td-opacity, 0.5);
    animation: teardrop-rise var(--td-duration, 6s) ease-in forwards;
    animation-delay: var(--td-delay, 0s);
}

@keyframes teardrop-rise {
    0% {
        transform: translateY(0) scale(1) rotate(0deg);
        opacity: var(--td-opacity, 0.5);
    }
    30% {
        transform: translateY(-30vh) scale(1.05) rotate(5deg);
    }
    60% {
        transform: translateY(-60vh) scale(0.9) rotate(-3deg);
    }
    80% {
        opacity: var(--td-opacity, 0.5);
    }
    100% {
        transform: translateY(calc(-100vh - 40px)) scale(0.6) rotate(8deg);
        opacity: 0;
    }
}


/* ============================================
   ACT V — Contagion
   ============================================ */

#act-contagion {
    min-height: 140vh;
    background: var(--void-indigo);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10vh 5vw;
}

.contagion-mouths {
    position: relative;
    width: min(85vw, 900px);
    height: min(60vh, 550px);
    margin-bottom: 8vh;
}

.contagion-mouth {
    position: absolute;
    width: clamp(45px, 6vw, 80px);
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.6s ease;
}

.contagion-mouth.mouth-open {
    opacity: 1;
}

.contagion-mouth.mouth-open .cm-lips {
    animation: mouth-open-anim 0.6s ease forwards;
}

.contagion-mouth.mouth-open .cm-teeth {
    opacity: 0.6;
    transition: opacity 0.3s ease 0.3s;
}

@keyframes mouth-open-anim {
    0% { d: path("M10,25 Q20,22 40,22 Q60,22 70,25 Q60,28 40,28 Q20,28 10,25Z"); }
    100% { d: path("M10,25 Q20,10 40,10 Q60,10 70,25 Q60,40 40,42 Q20,40 10,25Z"); }
}

/* Mouth positions: scattered across the container in a crowd-like pattern */
.cm--0  { top: 42%; left: 45%; } /* Center — opens first */
.cm--1  { top: 28%; left: 30%; }
.cm--2  { top: 30%; left: 62%; }
.cm--3  { top: 55%; left: 22%; }
.cm--4  { top: 58%; left: 68%; }
.cm--5  { top: 15%; left: 48%; }
.cm--6  { top: 72%; left: 42%; }
.cm--7  { top: 12%; left: 14%; }
.cm--8  { top: 78%; left: 72%; }
.cm--9  { top: 20%; left: 80%; }
.cm--10 { top: 68%; left: 12%; }
.cm--11 { top: 82%; left: 28%; }

/* Sine burst from each mouth on open */
.contagion-mouth.mouth-open::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    border: 1px solid var(--laryngeal-pink);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    animation: mouth-burst 1.2s ease-out forwards;
}

@keyframes mouth-burst {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
}

/* Second ripple ring */
.contagion-mouth.mouth-open::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 1px solid var(--resonance-teal);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    animation: mouth-burst-2 1.6s ease-out 0.2s forwards;
}

@keyframes mouth-burst-2 {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0.35; }
    100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

/* Finale text */
.contagion-finale {
    position: relative;
    z-index: 2;
    text-align: center;
}

.finale-text {
    font-family: 'Unbounded', sans-serif;
    font-weight: 900;
    font-size: clamp(36px, 7vw, 110px);
    line-height: 1.05;
    color: var(--pale-breath);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease, transform 1s ease;
}

.finale-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.finale-annotation {
    margin-top: 2vh;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
    font-size: clamp(16px, 1.3vw, 22px);
}

.finale-text.visible ~ .finale-annotation,
.finale-annotation.visible {
    opacity: 1;
}


/* ============================================
   EQUALIZER NAVIGATION
   ============================================ */

.equalizer-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 52px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    padding: 0 20vw 8px;
    z-index: 100;
    background: linear-gradient(transparent, rgba(11, 10, 26, 0.92) 50%);
}

.eq-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    text-decoration: none;
    position: relative;
    width: 28px;
    height: 44px;
    cursor: pointer;
}

.eq-bar-inner {
    display: block;
    width: 4px;
    border-radius: 2px 2px 0 0;
    background: var(--whisper-lilac);
    transition: height 0.3s ease, background 0.3s ease;
}

.eq-bar--1 .eq-bar-inner { height: 14px; animation: eq-idle-1 2.8s ease-in-out infinite 0s; }
.eq-bar--2 .eq-bar-inner { height: 10px; animation: eq-idle-2 3.2s ease-in-out infinite 0.4s; }
.eq-bar--3 .eq-bar-inner { height: 18px; animation: eq-idle-3 2.5s ease-in-out infinite 0.8s; }
.eq-bar--4 .eq-bar-inner { height: 12px; animation: eq-idle-4 3.5s ease-in-out infinite 0.2s; }
.eq-bar--5 .eq-bar-inner { height: 16px; animation: eq-idle-5 2.9s ease-in-out infinite 0.6s; }

@keyframes eq-idle-1 {
    0%, 100% { height: 14px; }
    50% { height: 20px; }
}
@keyframes eq-idle-2 {
    0%, 100% { height: 10px; }
    50% { height: 17px; }
}
@keyframes eq-idle-3 {
    0%, 100% { height: 18px; }
    50% { height: 25px; }
}
@keyframes eq-idle-4 {
    0%, 100% { height: 12px; }
    50% { height: 19px; }
}
@keyframes eq-idle-5 {
    0%, 100% { height: 16px; }
    50% { height: 23px; }
}

.eq-bar:hover .eq-bar-inner {
    height: 34px !important;
    background: var(--resonance-teal);
    animation: none;
}

.eq-bar.active .eq-bar-inner {
    background: var(--laryngeal-pink);
}

.eq-label {
    font-family: 'Outfit', sans-serif;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pale-breath);
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    transition: opacity 0.25s ease;
    pointer-events: none;
    margin-bottom: 4px;
}

.eq-bar:hover .eq-label {
    opacity: 1;
}

/* ============================================
   RESPONSIVE ADAPTATIONS
   ============================================ */

@media (max-width: 900px) {
    .descent-container {
        grid-template-columns: 1fr;
        gap: 4vh;
    }

    .throat-diagram-col {
        position: relative;
        top: auto;
        height: auto;
        margin-bottom: 4vh;
    }

    .throat-cross-section {
        max-width: 280px;
    }

    .descent-annotations {
        padding-top: 4vh;
        gap: 8vh;
    }

    .resonance-card--1,
    .resonance-card--2,
    .resonance-card--3,
    .resonance-card--4,
    .resonance-card--5 {
        grid-column: 1 / -1;
        margin-top: 2vh;
    }

    .burst-fragment {
        max-width: 220px;
    }

    .equalizer-nav {
        padding: 0 8vw 8px;
    }

    .contagion-mouth {
        width: clamp(35px, 8vw, 60px);
    }

    .genesis-title {
        font-size: clamp(36px, 12vw, 80px);
    }
}

@media (max-width: 600px) {
    .resonance-content {
        grid-template-columns: 1fr;
        gap: 3vh;
        padding: 0 4vw;
    }

    .resonance-card--1,
    .resonance-card--2,
    .resonance-card--3,
    .resonance-card--4,
    .resonance-card--5 {
        grid-column: 1 / -1;
        grid-row: auto;
        margin-top: 0;
    }

    .escape-center-origin {
        height: auto;
        min-height: 80vh;
    }

    .burst-fragment {
        max-width: 85vw;
    }
}
