/* =========================================
   ipjosim.com — 입조심
   Surreal Dreamscape of Suspended Utterances
   ========================================= */

/* --- Custom Properties --- */
:root {
    --void-top: #0B0A1A;
    --void-bottom: #1A1432;
    --drift-bg: #12102A;
    --resolution-bg: #1E1A38;
    --accent-lilac: #C8A2C8;
    --accent-lavender: #E8D5E8;
    --accent-amber: #D4A574;
    --text-body: #B8A8C8;
    --card-surface: #221E3A;
    --accent-blush: #E85A7A;
    --accent-muted: #8B7BA8;
    --scroll-progress: 0;
}

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

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

body {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.8;
    color: var(--text-body);
    background: var(--void-top);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Grain Overlay --- */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
}

.grain-overlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    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;
}

/* --- Scroll Progress --- */
.scroll-progress {
    position: fixed;
    right: 16px;
    top: 10%;
    width: 1px;
    height: 80%;
    background: rgba(200, 162, 200, 0.08);
    z-index: 900;
}

.scroll-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(200, 162, 200, 0.3);
    transition: height 0.1s linear;
}

.scroll-progress-text {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    color: #8B7BA8;
    opacity: 0.6;
    white-space: nowrap;
}

/* --- Fog Layers --- */
.fog-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    will-change: transform;
}

.fog-layer-1 {
    background: radial-gradient(ellipse at 30% 40%, rgba(200, 162, 200, 0.04), transparent 70%);
}

.fog-layer-2 {
    background: radial-gradient(ellipse at 70% 60%, rgba(200, 162, 200, 0.03), transparent 70%);
}

.fog-layer-3 {
    background: radial-gradient(ellipse at 50% 50%, rgba(200, 162, 200, 0.025), transparent 65%);
}

/* --- Thread Lines --- */
.thread-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
}

.thread-line {
    stroke: var(--accent-amber);
    stroke-width: 0.5;
    opacity: 0.2;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 2s ease-out;
    filter: url(#thread-glow);
}

.thread-line.visible {
    stroke-dashoffset: 0;
}

/* --- Zone: Void Entry --- */
.zone-void {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--void-top) 0%, var(--void-bottom) 100%);
    z-index: 5;
}

.mouth-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mouth-svg {
    width: clamp(120px, 20vw, 240px);
    height: auto;
    opacity: 0;
    animation: mouthFadeIn 2s ease-out 1.5s forwards;
}

@keyframes mouthFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Syllable Blobs --- */
.blob-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    overflow: hidden;
}

.syllable-blob {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Serif KR', serif;
    font-weight: 200;
    font-size: clamp(0.9rem, 1.5vw, 1.3rem);
    color: var(--accent-lavender);
    background: rgba(200, 162, 200, 0.06);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(200, 162, 200, 0.15);
    border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
    width: clamp(50px, 7vw, 90px);
    height: clamp(50px, 7vw, 90px);
    will-change: transform, opacity;
    animation: blobMorph 12s ease-in-out infinite alternate;
    transition: left 2s ease-in-out, opacity 1.5s ease;
}

@keyframes blobMorph {
    0%   { border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%; }
    25%  { border-radius: 55% 45% 40% 60% / 45% 55% 50% 50%; }
    50%  { border-radius: 45% 55% 60% 40% / 60% 45% 40% 55%; }
    75%  { border-radius: 60% 40% 45% 55% / 40% 60% 55% 45%; }
    100% { border-radius: 50% 50% 50% 50% / 55% 45% 55% 45%; }
}

@keyframes drift {
    from { transform: translateY(0); }
    to { transform: translateY(-110vh); }
}

@keyframes sway {
    from { transform: translateX(calc(var(--sway-amount) * -1)); }
    to { transform: translateX(var(--sway-amount)); }
}

/* --- Zone: Drift --- */
.zone-drift {
    position: relative;
    min-height: 200vh;
    padding: 10vh 5vw;
    background: linear-gradient(180deg, var(--void-bottom) 0%, var(--drift-bg) 20%, var(--drift-bg) 100%);
    z-index: 5;
}

.drift-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.drift-card {
    background: rgba(34, 30, 58, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    opacity: 0;
    filter: blur(12px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.1, 0.25, 1), filter 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.drift-card.visible {
    opacity: 1;
    filter: blur(0);
}

.card-text-ko {
    font-family: 'Noto Serif KR', serif;
    font-weight: 200;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    line-height: 1.9;
    color: var(--accent-lavender);
    margin-bottom: 1rem;
}

.card-text-en {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.7;
    font-style: italic;
    color: var(--text-body);
    opacity: 0.8;
}

/* Card positioning — scattered constellation */
.card-1 {
    grid-column: 1 / 6;
    margin-top: 0;
}

.card-2 {
    grid-column: 7 / 12;
    margin-top: 4rem;
}

.card-3 {
    grid-column: 2 / 7;
    margin-top: -2rem;
}

.card-4 {
    grid-column: 6 / 13;
    margin-top: 3rem;
}

.card-5 {
    grid-column: 1 / 5;
    margin-top: 1rem;
}

.card-6 {
    grid-column: 5 / 11;
    margin-top: -1rem;
}

/* --- Zone: Accumulation --- */
.zone-accumulation {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--drift-bg) 0%, #0E0C22 50%, var(--drift-bg) 100%);
    z-index: 5;
    overflow: visible;
}

.central-text {
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 10rem);
    color: var(--accent-lavender);
    letter-spacing: 0.15em;
    opacity: 0.1;
    filter: blur(20px);
    transition: opacity 0.3s ease, filter 0.3s ease;
    will-change: opacity, filter;
    text-align: center;
}

.central-char {
    display: inline-block;
    transition: transform 0.6s ease;
}

/* --- Zone: Resolution --- */
.zone-resolution {
    position: relative;
    min-height: 100vh;
    padding: 15vh 5vw 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, var(--drift-bg) 0%, var(--resolution-bg) 30%, var(--resolution-bg) 100%);
    z-index: 5;
}

.resolution-card {
    max-width: 38rem;
    background: rgba(34, 30, 58, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(200, 162, 200, 0.08);
    border-radius: 2px;
    padding: clamp(2rem, 4vw, 3.5rem);
    opacity: 0;
    filter: blur(8px);
    transition: opacity 1s ease, filter 1s ease;
}

.resolution-card.visible {
    opacity: 1;
    filter: blur(0);
}

.resolution-text {
    font-family: 'Noto Serif KR', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    line-height: 2;
    color: var(--accent-lavender);
    margin-bottom: 1.5rem;
}

.resolution-text-en {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: clamp(1.1rem, 1.5vw, 1.3rem);
    line-height: 1.8;
    color: var(--accent-lavender);
    opacity: 0.85;
}

.resolution-empty {
    height: 200vh;
}

.mouth-closed {
    padding-bottom: 20vh;
}

.mouth-final {
    opacity: 0.4;
    animation: none;
}

/* --- Animations for blobs orbiting central text --- */
@keyframes orbit {
    from { transform: rotate(0deg) translateX(var(--orbit-radius)) rotate(0deg); }
    to { transform: rotate(360deg) translateX(var(--orbit-radius)) rotate(-360deg); }
}

.blob-orbiting {
    animation: orbit var(--orbit-duration) linear infinite;
    transform-origin: center center;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .syllable-blob,
    .central-char,
    .mouth-svg {
        animation: none !important;
        transition: opacity 0.5s ease !important;
    }

    .drift-card {
        filter: none !important;
        opacity: 1 !important;
        transition: opacity 0.5s ease !important;
    }

    .central-text {
        filter: none !important;
        opacity: 1 !important;
    }

    .resolution-card {
        filter: none !important;
        opacity: 1 !important;
    }
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .drift-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

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

    .scroll-progress {
        right: 8px;
    }

    .syllable-blob {
        width: clamp(40px, 12vw, 70px);
        height: clamp(40px, 12vw, 70px);
        font-size: 0.85rem;
    }
}
