/* ============================================
   archetype.boo — Styles
   Candy-bright whimsical wonderland
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --pink: #FF6B9D;
    --lemon: #FFE156;
    --mint: #4ECDC4;
    --grape: #A855F7;
    --tangerine: #FF8A5C;
    --plum: #2D1B3D;
    --cream: #FFF8F0;
    --lavender: #F3E8FF;
    --lemon-dark: #FFCF26;
    --mint-dark: #38B2AC;
    --grape-dark: #9333EA;

    --bounce-lg: cubic-bezier(0.34, 1.56, 0.64, 1);
    --bounce-md: cubic-bezier(0.25, 1.4, 0.55, 1);
    --bounce-sm: cubic-bezier(0.2, 1.6, 0.4, 1);

    --font-display: 'Fredoka', sans-serif;
    --font-body: 'Quicksand', sans-serif;
    --font-accent: 'Baloo 2', cursive;
}

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

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

body {
    font-family: var(--font-body);
    color: var(--plum);
    background-color: var(--cream);
    overflow-x: hidden;
    position: relative;
}

/* --- Dot Grid Overlay --- */
.dot-grid-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(circle, #2D1B3D 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.02;
}

/* --- Cursor Trail Canvas --- */
#cursor-trail {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
}

/* --- Floating Rings --- */
.floating-rings {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid;
    opacity: 0.15;
    animation: float 12s linear infinite;
}

.ring-1 { width: 80px; height: 80px; left: 5%; top: 20%; border-color: var(--pink); animation-delay: 0s; }
.ring-2 { width: 50px; height: 50px; left: 80%; top: 30%; border-color: var(--lemon); animation-delay: -3s; }
.ring-3 { width: 100px; height: 100px; left: 15%; top: 60%; border-color: var(--mint); animation-delay: -6s; }
.ring-4 { width: 60px; height: 60px; left: 70%; top: 70%; border-color: var(--grape); animation-delay: -2s; }
.ring-5 { width: 40px; height: 40px; left: 45%; top: 10%; border-color: var(--tangerine); animation-delay: -8s; }
.ring-6 { width: 70px; height: 70px; left: 90%; top: 85%; border-color: var(--pink); animation-delay: -4s; }

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-60px) rotate(180deg); }
    100% { transform: translateY(0) rotate(360deg); }
}

/* --- Scene Base --- */
.scene {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: clamp(2rem, 6vw, 8rem) clamp(1rem, 4vw, 4rem);
}

/* --- Bounce-In Animation --- */
.bounce-in {
    opacity: 0;
    transform: translateY(40px) scale(0.9);
    transition: opacity 800ms var(--bounce-lg),
                transform 800ms var(--bounce-lg);
    transition-delay: var(--delay, 0s);
}

.bounce-in.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ============================================
   SECTION 1: HERO
   ============================================ */
.scene-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--cream);
    position: relative;
    overflow: hidden;
}

.hero-inner {
    text-align: center;
    position: relative;
    z-index: 3;
}

.hero-subtitle {
    font-family: var(--font-accent);
    font-size: clamp(1rem, 3vw, 1.8rem);
    font-weight: 700;
    color: var(--grape);
    margin-bottom: clamp(1.5rem, 4vw, 3rem);
    letter-spacing: 0.02em;
}

/* --- Domain Assembly --- */
.domain-assembly {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0;
    position: relative;
}

.letter-group {
    position: relative;
    display: inline-block;
}

.letter-char {
    font-family: var(--font-display);
    font-size: clamp(3rem, 10vw, 8rem);
    font-weight: 600;
    color: var(--pink);
    display: inline-block;
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 0 rgba(0,0,0,0.05);
}

.letter-dot .letter-char {
    color: var(--tangerine);
    margin: 0 0.05em;
}

/* Geometric pieces behind each letter */
.geo-piece {
    position: absolute;
    width: 20px;
    height: 20px;
    z-index: 1;
    opacity: 0.85;
    top: 50%;
    left: 50%;
    transition: transform 1.2s var(--bounce-lg), opacity 1.2s ease;
    will-change: transform;
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
}

.geo-piece.assembled {
    transform: translate(-50%, -50%) rotate(0deg);
    opacity: 0.6;
}

.circle-piece {
    border-radius: 50%;
    background: var(--hue);
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.08);
}

.square-piece {
    border-radius: 3px;
    background: var(--hue);
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.08);
}

.triangle-piece {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 18px solid var(--hue);
    background: transparent;
    box-shadow: none;
}

/* Scroll Hint */
.scroll-hint {
    margin-top: clamp(2rem, 5vw, 4rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.scroll-hint-text {
    font-family: var(--font-accent);
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    font-weight: 700;
    color: var(--grape);
    opacity: 0.6;
    text-transform: lowercase;
}

.scroll-arrow {
    font-size: 1.2rem;
    color: var(--grape);
    opacity: 0.4;
    animation: arrowBounce 2s ease-in-out infinite;
}

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

/* Hero confetti layer */
.confetti-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.confetti-dot {
    position: absolute;
    border-radius: 50%;
    animation: spin 8s linear infinite;
    will-change: transform;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.08);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   WAVY DIVIDERS
   ============================================ */
.wavy-divider {
    position: relative;
    z-index: 2;
    height: 80px;
    margin: -1px 0;
    overflow: hidden;
}

.wavy-divider svg {
    width: 100%;
    height: 100%;
    display: block;
}

.wave-path {
    animation: waveShift 6s ease-in-out infinite alternate;
}

@keyframes waveShift {
    0% { d: path("M0,60 C240,120 480,0 720,60 C960,120 1200,0 1440,60 L1440,120 L0,120 Z"); }
    100% { d: path("M0,60 C240,0 480,120 720,60 C960,0 1200,120 1440,60 L1440,120 L0,120 Z"); }
}

/* ============================================
   SECTION 2: MEET THE ARCHETYPES
   ============================================ */
.scene-meet {
    background: linear-gradient(180deg, var(--cream) 0%, var(--lavender) 100%);
    padding-bottom: clamp(4rem, 10vw, 10rem);
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 5rem);
    font-weight: 600;
    text-align: center;
    color: var(--plum);
    margin-bottom: clamp(3rem, 8vw, 8rem);
}

/* Character Clusters - organic offset */
.character-cluster {
    position: relative;
    margin-left: var(--offset-x, 10%);
    max-width: 700px;
    margin-bottom: clamp(4rem, 8vw, 8rem);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: clamp(1rem, 3vw, 2rem);
}

/* Archetype Characters */
.archetype-character {
    width: clamp(100px, 20vw, 160px);
    height: clamp(100px, 20vw, 160px);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 400ms var(--bounce-lg);
}

.archetype-character:hover {
    transform: scale(1.15) rotate(5deg);
}

.char-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Character idle animations */
.character-boo .char-svg {
    animation: wobble 3s ease-in-out infinite;
}

.character-peek .char-svg {
    animation: tilt 4s ease-in-out infinite;
}

.character-archie .char-svg {
    animation: bob 5s ease-in-out infinite;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

@keyframes tilt {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Speech Bubbles */
.speech-bubble {
    background: white;
    border-radius: 20px;
    padding: clamp(0.75rem, 2vw, 1.25rem) clamp(1rem, 2.5vw, 1.5rem);
    position: relative;
    box-shadow: 0 4px 20px rgba(45, 27, 61, 0.08);
    flex: 1 1 200px;
    min-width: 200px;
    max-width: 380px;
}

.bubble-text {
    font-family: var(--font-accent);
    font-size: clamp(0.875rem, 2vw, 1.1rem);
    font-weight: 400;
    line-height: 1.5;
    color: var(--plum);
}

.bubble-tail {
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 14px solid white;
}

.bubble-boo { border: 2px solid var(--lemon); }
.bubble-peek { border: 2px solid var(--mint); }
.bubble-archie { border: 2px solid var(--grape); }

/* Character Story Text */
.character-story {
    flex: 1 1 250px;
    min-width: 220px;
}

.char-name {
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 3vw, 2rem);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.char-description {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    font-weight: 400;
    line-height: 1.7;
    color: var(--plum);
    opacity: 0.85;
}

/* Cluster confetti (populated by JS) */
.cluster-confetti {
    position: absolute;
    inset: -30px;
    pointer-events: none;
    z-index: -1;
    overflow: visible;
}

/* ============================================
   SECTION 3: THEY PLAYED TOGETHER
   ============================================ */
.scene-play {
    background: linear-gradient(180deg, var(--lavender) 0%, var(--cream) 50%, var(--lavender) 100%);
    position: relative;
    overflow: hidden;
}

.story-ribbon {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: clamp(1.5rem, 4vw, 3rem);
}

.story-block {
    display: flex;
    align-items: flex-start;
    gap: clamp(1rem, 3vw, 2rem);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 24px rgba(45, 27, 61, 0.06);
    backdrop-filter: blur(4px);
    max-width: 700px;
}

.story-left {
    align-self: flex-start;
    margin-left: 5%;
}

.story-right {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 5%;
}

.story-characters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.mini-char {
    width: 40px;
    height: 40px;
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.08);
}

.mini-boo {
    border-radius: 50%;
    background: linear-gradient(180deg, var(--lemon) 0%, var(--lemon-dark) 100%);
}

.mini-peek {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 36px solid var(--mint);
    background: transparent;
    box-shadow: none;
}

.mini-archie {
    border-radius: 6px;
    background: linear-gradient(180deg, var(--grape) 0%, var(--grape-dark) 100%);
}

.story-content h3 {
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    font-weight: 600;
    color: var(--plum);
    margin-bottom: 0.5rem;
}

.story-content p {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2vw, 1.05rem);
    font-weight: 400;
    line-height: 1.7;
    color: var(--plum);
    opacity: 0.85;
}

/* Shape Bridges */
.shape-bridge {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1.5rem);
    padding: 0.5rem 0;
}

.bridge-shape {
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: var(--color);
    opacity: 0.8;
    animation: bounce 2s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.2s);
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.08);
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* Bouncing Stars */
.bouncing-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.star {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 30px;
    height: 30px;
    animation: bounce 2s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.2s);
}

.star::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* ============================================
   SECTION 4: FINALE / MANDALA
   ============================================ */
.scene-finale {
    background: linear-gradient(180deg, var(--lavender) 0%, var(--cream) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100vh;
}

.mandala-container {
    position: relative;
    width: clamp(300px, 60vw, 500px);
    height: clamp(300px, 60vw, 500px);
    margin: clamp(2rem, 5vw, 4rem) auto;
}

.mandala {
    position: relative;
    width: 100%;
    height: 100%;
    animation: mandalaRotate 40s linear infinite;
}

@keyframes mandalaRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mandala-ring {
    position: absolute;
    inset: 0;
}

.mandala-shape {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(-1 * var(--dist)));
    will-change: transform;
}

.m-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color);
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.08);
}

.m-triangle {
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 22px solid var(--color);
}

.m-square {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--color);
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.08);
}

.mandala-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    animation: mandalaRotate 40s linear infinite reverse;
}

.center-shape {
    width: 100%;
    height: 100%;
}

.finale-tagline {
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 3.5vw, 2.5rem);
    font-weight: 600;
    color: var(--plum);
    margin-top: clamp(1rem, 3vw, 2rem);
    opacity: 0.9;
}

/* ============================================
   PLAYGROUND FOOTER
   ============================================ */
.scene-playground {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--cream) 0%, var(--lavender) 100%);
    position: relative;
    overflow: hidden;
}

.playground-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.boo-finale {
    position: relative;
    z-index: 2;
    cursor: pointer;
}

.boo-text {
    font-family: var(--font-display);
    font-size: clamp(4rem, 15vw, 12rem);
    font-weight: 600;
    color: var(--pink);
    text-shadow: 0 4px 0 rgba(255, 107, 157, 0.2);
    transition: transform 400ms var(--bounce-lg), color 400ms ease;
    display: inline-block;
    user-select: none;
}

.boo-text:hover {
    transform: scale(1.15) rotate(-3deg);
    color: var(--grape);
}

.boo-text.boo-bounce {
    animation: booJump 600ms var(--bounce-lg);
}

@keyframes booJump {
    0% { transform: scale(1); }
    30% { transform: scale(0.85) translateY(10px); }
    60% { transform: scale(1.2) translateY(-30px) rotate(5deg); }
    100% { transform: scale(1) translateY(0) rotate(0deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .character-cluster {
        margin-left: 5% !important;
        margin-right: 5%;
        flex-direction: column;
        align-items: center;
    }

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

    .bubble-tail {
        left: 50%;
        top: -12px;
        transform: translateX(-50%) rotate(90deg);
    }

    .story-block {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .story-left,
    .story-right {
        margin-left: 5%;
        margin-right: 5%;
        align-self: center;
    }

    .story-characters {
        flex-direction: row;
    }

    .mandala-container {
        width: 280px;
        height: 280px;
    }

    .mandala-shape.m-circle { width: 18px; height: 18px; }
    .mandala-shape.m-square { width: 16px; height: 16px; }
}

@media (max-width: 480px) {
    .letter-char {
        font-size: clamp(2rem, 12vw, 4rem);
    }

    .geo-piece {
        width: 14px;
        height: 14px;
    }

    .triangle-piece {
        border-left-width: 7px;
        border-right-width: 7px;
        border-bottom-width: 12px;
    }
}
