/* ===== CSS Custom Properties ===== */
:root {
    --pink: #FF6B9D;
    --yellow: #FFD93D;
    --blue: #6BC5F8;
    --mint: #4ECDC4;
    --purple: #A06CD5;
    --bg: #FFF5F7;
    --bg-alt: #FFFEF2;
    --text: #2D2D3A;

    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    color: var(--text);
    background-color: var(--bg);
    overflow-x: hidden;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Floating Decorative Elements ===== */
.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.floating-el {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    will-change: transform;
}

.floating-el.active {
    opacity: 1;
}

.floating-circle {
    border-radius: 50%;
}

.floating-rect {
    border-radius: 6px;
}

.floating-jamo {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

@keyframes floatDrift1 {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(80px, -60px) rotate(90deg); }
    50% { transform: translate(30px, -120px) rotate(180deg); }
    75% { transform: translate(-50px, -80px) rotate(270deg); }
    100% { transform: translate(0, 0) rotate(360deg); }
}

@keyframes floatDrift2 {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-70px, -90px) rotate(-90deg); }
    50% { transform: translate(-20px, 40px) rotate(-180deg); }
    75% { transform: translate(60px, -30px) rotate(-270deg); }
    100% { transform: translate(0, 0) rotate(-360deg); }
}

@keyframes floatDrift3 {
    0% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(50px, 70px) rotate(120deg); }
    66% { transform: translate(-40px, 30px) rotate(240deg); }
    100% { transform: translate(0, 0) rotate(360deg); }
}

/* ===== ENTRY ZONE ===== */
.entry-zone {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg);
    z-index: 2;
    overflow: hidden;
}

.jamo-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.3rem, 1.5vw, 1.2rem);
    flex-wrap: wrap;
    padding: 0 1rem;
}

.jamo-block {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: clamp(5rem, 12vw, 9rem);
    line-height: 1;
    border-radius: 16px;
    padding: clamp(0.3rem, 1vw, 0.8rem) clamp(0.5rem, 1.5vw, 1.2rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-120vh);
    will-change: transform, opacity;
    position: relative;
    cursor: default;
    user-select: none;
}

.jamo-hieut {
    color: #FFF5F7;
    background: linear-gradient(135deg, #FF85B1, #FF6B9D);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 8px 32px rgba(255, 107, 157, 0.35),
        0 2px 8px rgba(255, 107, 157, 0.2);
    transform-origin: center bottom;
    rotate: -3deg;
}

.jamo-a {
    color: #FFFEF2;
    background: linear-gradient(135deg, #FFE066, #FFD93D);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 8px 32px rgba(255, 217, 61, 0.35),
        0 2px 8px rgba(255, 217, 61, 0.2);
    transform-origin: center bottom;
    rotate: 2deg;
}

.jamo-nieun {
    color: #F0FFFE;
    background: linear-gradient(135deg, #6FD9D1, #4ECDC4);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 8px 32px rgba(78, 205, 196, 0.35),
        0 2px 8px rgba(78, 205, 196, 0.2);
    transform-origin: center bottom;
    rotate: -1deg;
}

.jamo-giyeok {
    color: #F0F8FF;
    background: linear-gradient(135deg, #85D4FA, #6BC5F8);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 8px 32px rgba(107, 197, 248, 0.35),
        0 2px 8px rgba(107, 197, 248, 0.2);
    transform-origin: center bottom;
    rotate: 4deg;
}

.jamo-eu {
    color: #F8F0FF;
    background: linear-gradient(135deg, #B485E0, #A06CD5);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 8px 32px rgba(160, 108, 213, 0.35),
        0 2px 8px rgba(160, 108, 213, 0.2);
    transform-origin: center bottom;
    rotate: -2deg;
}

.jamo-rieul {
    color: #FFF5F7;
    background: linear-gradient(135deg, #FFA3C0, #FF85B1);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 8px 32px rgba(255, 133, 177, 0.35),
        0 2px 8px rgba(255, 133, 177, 0.2);
    transform-origin: center bottom;
    rotate: 3deg;
}

/* Jamo block entrance animation */
@keyframes jamoEnter {
    0% {
        opacity: 0;
        transform: translateY(-120vh) scaleX(1) scaleY(1);
    }
    60% {
        opacity: 1;
        transform: translateY(0) scaleX(1.15) scaleY(0.85);
    }
    75% {
        transform: translateY(-15px) scaleX(0.92) scaleY(1.08);
    }
    87% {
        transform: translateY(5px) scaleX(1.05) scaleY(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scaleX(1) scaleY(1);
    }
}

.jamo-block.animate-in {
    animation-name: jamoEnter;
    animation-duration: 600ms;
    animation-timing-function: var(--bounce);
    animation-fill-mode: forwards;
}

.jamo-block:hover {
    transform: scale(1.08) !important;
    transition: transform 200ms var(--bounce);
}

/* Domain suffix */
.domain-suffix {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    color: var(--text);
    opacity: 0;
    margin-top: 0.5rem;
    letter-spacing: 0.02em;
    transition: opacity 400ms ease;
}

.domain-suffix.visible {
    opacity: 1;
}

/* Scroll chevron */
.scroll-chevron {
    position: absolute;
    bottom: 2rem;
    color: var(--blue);
    opacity: 0;
    transition: opacity 300ms ease;
}

.scroll-chevron.visible {
    opacity: 1;
    animation: chevronBounce 1.5s ease-in-out infinite;
}

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

/* ===== STORY ZONE ===== */
.story-zone {
    position: relative;
    z-index: 2;
    padding: 10vh 5vw 15vh;
    background-color: var(--bg-alt);
    min-height: 150vh;
}

.story-cluster {
    max-width: 720px;
    background: var(--bg);
    border-radius: 24px;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: clamp(3rem, 6vh, 6rem);
    display: flex;
    align-items: center;
    gap: clamp(1rem, 2vw, 2rem);
    position: relative;
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 500ms var(--bounce), transform 500ms var(--bounce);
    box-shadow: 0 8px 32px rgba(160, 108, 213, 0.12);
}

.story-cluster.visible {
    opacity: 1;
    transform: translateY(0) rotate(var(--cluster-rotate, 0deg));
}

.cluster-left {
    margin-left: 5%;
    margin-right: auto;
    --cluster-rotate: -2deg;
}

.cluster-left.visible {
    transform: translateY(0) translateX(0) rotate(-2deg);
}

.cluster-right {
    margin-right: 5%;
    margin-left: auto;
    --cluster-rotate: 2deg;
}

.cluster-right.visible {
    transform: translateY(0) translateX(0) rotate(2deg);
}

.cluster-left {
    transform: translateY(60px) translateX(-40px);
}

.cluster-right {
    transform: translateY(60px) translateX(40px);
}

.cluster-jamo-block {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 5rem);
    color: #fff;
    background: var(--block-color);
    border-radius: 16px;
    padding: 0.6rem 1rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 6px 24px var(--block-shadow);
    transform: rotate(var(--block-rotate, 0deg));
    min-width: clamp(4rem, 10vw, 6rem);
    min-height: clamp(4rem, 10vw, 6rem);
    line-height: 1;
    user-select: none;
}

.cluster-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: var(--text);
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

.cluster-text {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.7;
    color: var(--text);
}

.cluster-content {
    flex: 1;
    position: relative;
}

/* Cluster doodles */
.cluster-doodle {
    position: absolute;
    bottom: -10px;
    right: -10px;
    opacity: 0.4;
    animation: doodleSpin 12s linear infinite;
}

.doodle-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid var(--pink);
}

.doodle-star {
    width: 24px;
    height: 24px;
    background: var(--yellow);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.doodle-wave {
    width: 32px;
    height: 12px;
    border-bottom: 3px solid var(--mint);
    border-radius: 0 0 50% 50%;
}

@keyframes doodleSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== INTERACTIVE ZONE ===== */
.interactive-zone {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: 10vh 5vw 15vh;
    background-color: var(--yellow);
    background-image:
        radial-gradient(circle, rgba(255, 107, 157, 0.05) 6px, transparent 6px),
        radial-gradient(circle, rgba(107, 197, 248, 0.05) 6px, transparent 6px);
    background-size: 48px 48px;
    background-position: 0 0, 24px 24px;
    text-align: center;
    overflow: hidden;
}

.interactive-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--text);
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

.interactive-subtitle {
    font-family: 'Baloo 2', sans-serif;
    font-weight: 600;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--text);
    opacity: 0.7;
    margin-bottom: 3rem;
}

.jamo-playground {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(0.8rem, 2vw, 1.5rem);
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 0;
}

.play-block {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #fff;
    background: var(--block-color);
    border-radius: 16px;
    width: clamp(3.5rem, 7vw, 5.5rem);
    height: clamp(3.5rem, 7vw, 5.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 6px 24px var(--block-shadow);
    cursor: pointer;
    user-select: none;
    transition: transform 200ms var(--bounce), box-shadow 200ms ease;
    position: relative;
    line-height: 1;
}

.play-block:hover {
    transform: scale(1.1);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 10px 40px var(--block-shadow);
}

.play-block:active {
    transform: scale(0.95);
}

@keyframes squashStretch {
    0% { transform: scale(1); }
    20% { transform: scaleX(1.15) scaleY(0.85); }
    40% { transform: scaleX(0.92) scaleY(1.08); }
    60% { transform: scaleX(1.05) scaleY(0.95); }
    80% { transform: scaleX(0.98) scaleY(1.02); }
    100% { transform: scale(1); }
}

.play-block.bounce {
    animation: squashStretch 400ms var(--bounce);
}

/* Particle burst */
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
}

@keyframes particleBurst {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0);
    }
}

/* ===== CLOSING ZONE ===== */
.closing-zone {
    position: relative;
    z-index: 2;
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10vh 5vw;
    background: linear-gradient(180deg, var(--purple) 0%, #8B5CC0 100%);
    text-align: center;
}

.closing-jamo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.2rem, 1vw, 0.8rem);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.closing-block {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    color: #fff;
    background: var(--block-color);
    border-radius: 16px;
    padding: 0.2rem 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        0 8px 32px rgba(0, 0, 0, 0.15);
    line-height: 1;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 600ms var(--bounce), transform 600ms var(--bounce);
}

.closing-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.closing-suffix {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    color: #fff;
    letter-spacing: 0.02em;
    margin-bottom: 2rem;
    opacity: 0;
    transition: opacity 600ms ease 300ms;
}

.closing-suffix.visible {
    opacity: 1;
}

.closing-message {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 2vw, 1.35rem);
    color: rgba(255, 255, 255, 0.9);
    max-width: 600px;
    line-height: 1.8;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease 500ms, transform 600ms var(--bounce) 500ms;
}

.closing-message.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Transition between Story and Interactive zones ===== */
.story-zone::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20vh;
    background: linear-gradient(to bottom, var(--bg-alt), var(--yellow));
    pointer-events: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .jamo-block {
        font-size: clamp(3rem, 14vw, 5rem);
        padding: 0.2rem 0.4rem;
    }

    .jamo-hero {
        gap: 0.3rem;
    }

    .story-cluster {
        flex-direction: column;
        text-align: center;
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
    }

    .cluster-left,
    .cluster-right {
        margin-left: auto;
        margin-right: auto;
    }

    .cluster-left.visible,
    .cluster-right.visible {
        transform: translateY(0) rotate(0deg);
    }

    .cluster-jamo-block {
        min-width: clamp(3rem, 18vw, 5rem);
        min-height: clamp(3rem, 18vw, 5rem);
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

    .play-block {
        width: clamp(3rem, 14vw, 4.5rem);
        height: clamp(3rem, 14vw, 4.5rem);
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }

    .closing-block {
        font-size: clamp(2.5rem, 10vw, 5rem);
    }
}

@media (max-width: 480px) {
    .jamo-block {
        font-size: clamp(2.5rem, 16vw, 4rem);
    }

    .cluster-heading {
        font-size: clamp(1.3rem, 5vw, 1.8rem);
    }
}
