/* ppuzzl.party — a quiet zero-gravity gathering
   inflated-3d × dark-neon × zen-contemplative */

:root {
    --void:        #080614;   /* obsidian void */
    --plum:        #120a24;   /* midnight plum */
    --magenta:     #ff2dd6;   /* neon magenta pulse */
    --cyan:        #1ce0ff;   /* electric cyan */
    --lavender:    #9b6cff;   /* soft lavender glow */
    --pearl:       #fef9ff;   /* pearl white */
    --indigo:      #3a2761;   /* dusk indigo */
    --warm-soft:   #fef3c7;   /* (palette completeness) */

    --text:        rgba(254, 249, 255, 0.88);
    --text-soft:   rgba(254, 249, 255, 0.55);
    --text-faint:  rgba(254, 249, 255, 0.32);

    --font-display: 'Inter', sans-serif;
    --font-body:    'Manrope', sans-serif;
    --font-accent:  'Outfit', sans-serif;
}

/* ------------------------------------------------------------- */
/* Page skeleton                                                   */
/* ------------------------------------------------------------- */

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

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

body {
    background: var(--void);
    color: var(--text);
    font-family: var(--font-body);
    font-weight: 400;
    margin: 0;
    overflow-x: hidden;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    position: relative;
}

main {
    position: relative;
    z-index: 1;
    scroll-snap-type: y proximity;
}

/* ------------------------------------------------------------- */
/* Atmospheric fixed layers                                       */
/* ------------------------------------------------------------- */

.atmospheric-haze {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 28%, rgba(58, 39, 97, 0.55) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(155, 108, 255, 0.18) 0%, transparent 60%),
        radial-gradient(ellipse at 14% 70%, rgba(28, 224, 255, 0.10) 0%, transparent 55%);
    mix-blend-mode: lighten;
    pointer-events: none;
    z-index: 0;
}

.starfield {
    position: fixed;
    inset: -10vh -10vw;
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}

.starfield--far {
    background-image:
        radial-gradient(1px 1px at 12% 18%, rgba(254, 249, 255, 0.55), transparent 60%),
        radial-gradient(1px 1px at 28% 64%, rgba(254, 249, 255, 0.40), transparent 60%),
        radial-gradient(1px 1px at 41% 22%, rgba(254, 249, 255, 0.35), transparent 60%),
        radial-gradient(1px 1px at 55% 88%, rgba(254, 249, 255, 0.45), transparent 60%),
        radial-gradient(1px 1px at 67% 36%, rgba(254, 249, 255, 0.40), transparent 60%),
        radial-gradient(1px 1px at 73% 70%, rgba(254, 249, 255, 0.30), transparent 60%),
        radial-gradient(1px 1px at 86% 14%, rgba(254, 249, 255, 0.50), transparent 60%),
        radial-gradient(1px 1px at 92% 50%, rgba(254, 249, 255, 0.35), transparent 60%);
    background-size: 100% 100%;
    opacity: 0.55;
}

.starfield--mid {
    background-image:
        radial-gradient(1.4px 1.4px at 20% 30%, rgba(254, 249, 255, 0.55), transparent 60%),
        radial-gradient(1.4px 1.4px at 38% 78%, rgba(254, 249, 255, 0.50), transparent 60%),
        radial-gradient(1.4px 1.4px at 60% 12%, rgba(254, 249, 255, 0.55), transparent 60%),
        radial-gradient(1.4px 1.4px at 78% 56%, rgba(254, 249, 255, 0.45), transparent 60%),
        radial-gradient(1.4px 1.4px at 90% 92%, rgba(254, 249, 255, 0.50), transparent 60%);
    background-size: 100% 100%;
    opacity: 0.45;
}

.starfield--near {
    background-image:
        radial-gradient(2px 2px at 16% 50%, rgba(155, 108, 255, 0.5), transparent 60%),
        radial-gradient(2px 2px at 50% 24%, rgba(28, 224, 255, 0.45), transparent 60%),
        radial-gradient(2px 2px at 84% 70%, rgba(255, 45, 214, 0.5), transparent 60%);
    background-size: 100% 100%;
    opacity: 0.6;
}

/* ------------------------------------------------------------- */
/* Sections (rooms)                                                */
/* ------------------------------------------------------------- */

.room {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: stretch;
    scroll-snap-align: start;
}

.parallax-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.parallax-layer--flare {
    z-index: 4;
    mix-blend-mode: screen;
}

.parallax-layer--bloom {
    z-index: 2;
}

.content-layer {
    position: relative;
    z-index: 5;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4vh 6vw;
    pointer-events: none;
}

/* ------------------------------------------------------------- */
/* Inflated 3D puzzle pieces                                       */
/* ------------------------------------------------------------- */

.puzzle-piece {
    position: absolute;
    left: var(--piece-x, 50%);
    top: var(--piece-y, 50%);
    width: var(--piece-size, 220px);
    height: var(--piece-size, 220px);
    margin-left: calc(var(--piece-size, 220px) * -0.5);
    margin-top: calc(var(--piece-size, 220px) * -0.5);
    transform: rotate(var(--piece-rot, 0deg));
    animation: breathe 7.4s ease-in-out infinite;
    animation-delay: var(--breath-delay, 0s);
    will-change: transform;
    filter: drop-shadow(0 14px 44px rgba(255, 45, 214, 0.32));
}

.piece-body {
    width: 100%;
    height: 100%;
    /* Classic interlocking puzzle piece via clip-path */
    clip-path: path('M 50 0 L 130 0 Q 150 0 150 20 Q 150 50 175 50 Q 200 50 200 75 Q 200 100 175 100 Q 150 100 150 130 Q 150 150 130 150 L 50 150 Q 30 150 30 130 Q 30 105 5 105 Q -20 105 -20 80 Q -20 55 5 55 Q 30 55 30 30 Q 30 0 50 0 Z');
    /* Background = inflated gloss gradient */
    background:
        radial-gradient(circle at 30% 25%, var(--magenta) 0%, var(--lavender) 32%, var(--cyan) 72%, var(--plum) 100%);
    /* Inset highlights and rim shadow fake glossy 3D inflation */
    box-shadow:
        inset 8px 8px 24px rgba(255, 255, 255, 0.18),
        inset -8px -8px 24px rgba(0, 0, 0, 0.55),
        inset 0 0 12px rgba(255, 45, 214, 0.4),
        0 0 60px rgba(255, 45, 214, 0.42);
    transform: scale(1.18); /* enlarge so clip-path's 200x150 fills container */
    transform-origin: 50% 50%;
}

.piece--node .piece-body {
    background:
        radial-gradient(circle at 32% 22%, var(--cyan) 0%, var(--lavender) 38%, var(--magenta) 78%, var(--plum) 100%);
    box-shadow:
        inset 8px 8px 24px rgba(255, 255, 255, 0.16),
        inset -8px -8px 24px rgba(0, 0, 0, 0.55),
        inset 0 0 12px rgba(28, 224, 255, 0.4),
        0 0 50px rgba(28, 224, 255, 0.42);
}

.piece--outro .piece-body {
    background:
        radial-gradient(circle at 30% 28%, rgba(255, 45, 214, 0.7) 0%, rgba(155, 108, 255, 0.65) 38%, rgba(28, 224, 255, 0.55) 80%, var(--plum) 100%);
    box-shadow:
        inset 8px 8px 24px rgba(255, 255, 255, 0.10),
        inset -8px -8px 24px rgba(0, 0, 0, 0.65),
        inset 0 0 14px rgba(155, 108, 255, 0.45),
        0 0 80px rgba(255, 45, 214, 0.35);
}

@keyframes breathe {
    0%, 100% { transform: rotate(var(--piece-rot, 0deg)) scale(1) translateZ(0); }
    50%      { transform: rotate(var(--piece-rot, 0deg)) scale(1.04) translateZ(0); }
}

/* ------------------------------------------------------------- */
/* Lens flares                                                     */
/* ------------------------------------------------------------- */

.lens-flare {
    position: absolute;
    left: -40%;
    top: var(--flare-top, 50%);
    width: 180%;
    height: 8px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(28, 224, 255, 0.32) 25%,
        rgba(255, 45, 214, 0.55) 50%,
        rgba(28, 224, 255, 0.32) 75%,
        transparent 100%);
    filter: blur(48px);
    mix-blend-mode: screen;
    pointer-events: none;
    transform: translateX(0) rotate(-3deg);
    opacity: 0;
    animation: flare-sweep var(--flare-duration, 14s) linear infinite;
    animation-delay: var(--flare-delay, 0s);
}

.lens-flare--cyan {
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(155, 108, 255, 0.25) 30%,
        rgba(28, 224, 255, 0.6) 50%,
        rgba(155, 108, 255, 0.25) 70%,
        transparent 100%);
    height: 6px;
    filter: blur(56px);
}

.lens-flare--bright {
    height: 12px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(28, 224, 255, 0.45) 22%,
        rgba(255, 45, 214, 0.78) 50%,
        rgba(28, 224, 255, 0.45) 78%,
        transparent 100%);
    filter: blur(40px);
}

.lens-flare--dim {
    height: 5px;
    filter: blur(64px);
    opacity: 0.6;
}

@keyframes flare-sweep {
    0%   { transform: translateX(0) rotate(-3deg);    opacity: 0; }
    20%  { opacity: 0.9; }
    60%  { opacity: 0.7; }
    100% { transform: translateX(60%) rotate(-3deg);  opacity: 0; }
}

/* ------------------------------------------------------------- */
/* Typography phrases                                              */
/* ------------------------------------------------------------- */

.phrase {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 4.4rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text);
    text-shadow: 0 0 28px rgba(155, 108, 255, 0.28);
    max-width: 920px;
    text-align: center;
    pointer-events: auto;
}

.phrase--lower {
    margin-top: auto;
    margin-bottom: 12vh;
    font-size: clamp(1.4rem, 2.6vw, 2.4rem);
    letter-spacing: 0.005em;
    color: var(--text-soft);
    font-weight: 300;
    text-shadow: 0 0 24px rgba(255, 45, 214, 0.25);
}

.phrase--upper {
    margin-top: 14vh;
    margin-bottom: auto;
    font-size: clamp(2.2rem, 4.4vw, 3.8rem);
    text-align: left;
    align-self: flex-start;
    margin-left: 8vw;
}

.phrase--outro {
    font-family: var(--font-display);
    font-weight: 200;
    font-size: clamp(1.6rem, 3.2vw, 2.8rem);
    color: var(--text-soft);
    text-align: center;
    letter-spacing: 0.005em;
    text-shadow: 0 0 28px rgba(155, 108, 255, 0.32);
}

.content-layer--bloom-words {
    justify-content: flex-start;
    padding-top: 18vh;
}

.bloom-word-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4vh;
    margin-right: 6vw;
    margin-left: auto;
    max-width: 540px;
}

.bloom-word {
    font-family: var(--font-accent);
    font-weight: 200;
    font-size: clamp(3.2rem, 9vw, 6.8rem);
    letter-spacing: -0.025em;
    line-height: 1;
    color: var(--pearl);
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 1.8s ease, transform 1.8s ease, text-shadow 1.8s ease;
    text-shadow: 0 0 0 rgba(255, 0, 220, 0);
}

.bloom-word.is-revealed {
    opacity: 0.92;
    transform: translateY(0);
    text-shadow: 0 0 32px rgba(255, 0, 220, 0.45);
}

.bloom-word:nth-child(1) { color: var(--pearl); }
.bloom-word:nth-child(2) { color: var(--pearl); }
.bloom-word:nth-child(3) { color: var(--pearl); }

.content-layer--ribbon-title {
    justify-content: flex-start;
    align-items: flex-start;
    padding-top: 12vh;
}

.content-layer--outro {
    justify-content: center;
    align-items: center;
    gap: 8vh;
}

.outro-link {
    margin-top: 6vh;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--text-faint);
    letter-spacing: 0.04em;
    pointer-events: auto;
}

.outro-link a {
    color: var(--text-soft);
    text-decoration: underline;
    text-decoration-color: rgba(155, 108, 255, 0.5);
    text-underline-offset: 4px;
    transition: color 0.6s ease, text-decoration-color 0.6s ease, text-shadow 0.6s ease;
}

.outro-link a:hover {
    color: var(--pearl);
    text-decoration-color: rgba(255, 45, 214, 0.85);
    text-shadow: 0 0 18px rgba(255, 45, 214, 0.55);
}

/* ------------------------------------------------------------- */
/* Section 2 prose (corner)                                        */
/* ------------------------------------------------------------- */

.prose--corner {
    position: absolute;
    left: 6vw;
    bottom: 12vh;
    max-width: min(420px, 28vw);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--text-soft);
    pointer-events: auto;
}

/* ------------------------------------------------------------- */
/* Section 2 — constellation curves                                */
/* ------------------------------------------------------------- */

.constellation-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.85;
}

.constellation-path {
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
    transition: stroke-dashoffset 1.8s ease-out;
    filter: drop-shadow(0 0 6px rgba(155, 108, 255, 0.55));
}

.room--constellation.is-revealed .constellation-path {
    stroke-dashoffset: 0;
}

.room--constellation.is-revealed .constellation-path:nth-of-type(2) {
    transition-delay: 0.4s;
}

.room--constellation.is-revealed .constellation-path:nth-of-type(3) {
    transition-delay: 0.8s;
}

/* ------------------------------------------------------------- */
/* Section 3 — slow bloom                                          */
/* ------------------------------------------------------------- */

.room--bloom {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(58, 39, 97, 0.4) 0%, transparent 70%),
        var(--void);
}

.bloom-piece {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40vh;
    height: 40vh;
    transform: translate(-50%, -50%) scale(var(--bloom-scale, 1));
    transition: width 0.4s ease, height 0.4s ease;
    will-change: transform;
}

.bloom-body {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 25%, var(--magenta) 0%, var(--lavender) 30%, var(--cyan) 70%, var(--plum) 100%);
    box-shadow:
        inset 16px 16px 60px rgba(255, 255, 255, 0.22),
        inset -16px -16px 60px rgba(0, 0, 0, 0.55),
        inset 0 0 30px rgba(255, 45, 214, 0.5),
        0 0 140px rgba(255, 45, 214, 0.35),
        0 0 220px rgba(28, 224, 255, 0.18);
    animation: bloom-breathe 8.5s ease-in-out infinite;
}

.bloom-flare-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 26% 22%, rgba(255, 255, 255, 0.45) 0%, transparent 28%);
    mix-blend-mode: screen;
    pointer-events: none;
    overflow: hidden;
}

.bloom-flare-overlay::after {
    content: '';
    position: absolute;
    left: -40%;
    top: 28%;
    width: 180%;
    height: 14px;
    background: linear-gradient(90deg, transparent, rgba(28, 224, 255, 0.5), rgba(255, 45, 214, 0.85), rgba(28, 224, 255, 0.5), transparent);
    filter: blur(20px);
    mix-blend-mode: screen;
    transform: translateX(-30%) rotate(-12deg);
    animation: bloom-flare-sweep 9s ease-in-out infinite;
}

@keyframes bloom-flare-sweep {
    0%   { transform: translateX(-40%) rotate(-12deg); opacity: 0; }
    25%  { opacity: 1; }
    100% { transform: translateX(60%) rotate(-12deg); opacity: 0; }
}

@keyframes bloom-breathe {
    0%, 100% { transform: scale(1) translateZ(0); }
    50%      { transform: scale(1.03) translateZ(0); }
}

/* ------------------------------------------------------------- */
/* Section 4 — curve ribbon                                        */
/* ------------------------------------------------------------- */

.room--ribbon {
    min-height: 240vh;
}

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

.ribbon-path {
    transition: stroke-dashoffset 0.1s linear;
}

.ribbon-nodes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.ribbon-node {
    position: absolute;
    left: var(--node-x, 50%);
    top: var(--node-y, 50%);
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.4rem;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.ribbon-node.is-revealed {
    opacity: 1;
}

.ribbon-node .puzzle-piece {
    position: relative;
    left: auto;
    top: auto;
    margin: 0;
}

.node-label {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-faint);
    letter-spacing: 0.18em;
    text-transform: lowercase;
    text-shadow: 0 0 12px rgba(155, 108, 255, 0.35);
}

.content-layer--ribbon-title {
    height: auto;
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 6;
}

.room--ribbon .content-layer {
    height: 100vh;
    position: sticky;
    top: 0;
}

/* ------------------------------------------------------------- */
/* Section 5 — outro                                               */
/* ------------------------------------------------------------- */

.room--outro {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(58, 39, 97, 0.3) 0%, transparent 60%),
        var(--void);
}

/* ------------------------------------------------------------- */
/* Reduced motion                                                  */
/* ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .puzzle-piece,
    .bloom-body,
    .lens-flare,
    .bloom-flare-overlay::after {
        animation: none !important;
    }
    .parallax-layer {
        transform: none !important;
    }
    html {
        scroll-behavior: auto;
    }
    main {
        scroll-snap-type: none;
    }
    .bloom-word {
        opacity: 0.92;
        transform: none;
        text-shadow: 0 0 32px rgba(255, 0, 220, 0.45);
    }
    .ribbon-node {
        opacity: 1;
    }
    .constellation-path {
        stroke-dashoffset: 0;
    }
}

/* ------------------------------------------------------------- */
/* Mobile adaptation (narrow viewports)                            */
/* ------------------------------------------------------------- */

@media (max-width: 720px) {
    .phrase {
        font-size: clamp(1.6rem, 6vw, 2.6rem);
    }
    .phrase--lower {
        font-size: clamp(1.05rem, 4vw, 1.4rem);
        margin-bottom: 8vh;
    }
    .phrase--upper {
        margin-left: 5vw;
    }
    .bloom-word {
        font-size: clamp(2.6rem, 13vw, 5rem);
    }
    .bloom-word-stack {
        margin-right: 5vw;
    }
    .prose--corner {
        max-width: 84vw;
        bottom: 8vh;
    }
    .puzzle-piece {
        filter: drop-shadow(0 8px 28px rgba(255, 45, 214, 0.28));
    }
    .ribbon-node {
        gap: 0.8rem;
    }
    .node-label {
        font-size: 0.7rem;
    }
    .lens-flare {
        height: 6px;
        filter: blur(36px);
    }
}
