/* ═══════════════════════════════════════════════════════════════
   P4P UNIVERSE — Global animated background + section system
   One living background, glass sections, cinematic reveals
   ═══════════════════════════════════════════════════════════════ */

/* ── Global animated mesh background ── */
.p4p-universe-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    overflow: hidden;
    background: #0a0a14;
}

.p4p-universe-bg::before,
.p4p-universe-bg::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.72;
    animation: p4pBlobDrift 18s ease-in-out infinite alternate;
}

.p4p-universe-bg::before {
    width: 60vw;
    height: 60vw;
    max-width: 900px;
    max-height: 900px;
    background: radial-gradient(circle, rgba(255, 45, 45, 0.22) 0%, transparent 70%);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.p4p-universe-bg::after {
    width: 50vw;
    height: 50vw;
    max-width: 800px;
    max-height: 800px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.18) 0%, transparent 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -9s;
    animation-duration: 22s;
}

.p4p-universe-bg__orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.35;
    pointer-events: none;
    animation: p4pBlobDrift 25s ease-in-out infinite alternate;
}

.p4p-universe-bg__orb--1 {
    width: 40vw;
    height: 40vw;
    max-width: 600px;
    max-height: 600px;
    background: radial-gradient(circle, rgba(255, 42, 109, 0.15) 0%, transparent 70%);
    top: 40%;
    left: 60%;
    animation-delay: -5s;
    animation-duration: 20s;
}

.p4p-universe-bg__orb--2 {
    width: 35vw;
    height: 35vw;
    max-width: 500px;
    max-height: 500px;
    background: radial-gradient(circle, rgba(255, 154, 61, 0.1) 0%, transparent 70%);
    top: 10%;
    left: 40%;
    animation-delay: -12s;
    animation-duration: 28s;
}

@keyframes p4pBlobDrift {
    0% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(8vw, 5vh) scale(1.08);
    }
    66% {
        transform: translate(-5vw, 8vh) scale(0.95);
    }
    100% {
        transform: translate(3vw, -4vh) scale(1.04);
    }
}

/* ── Starfield noise overlay (subtle) ── */
.p4p-universe-bg__noise {
    position: absolute;
    inset: 0;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    pointer-events: none;
}

/* ── Section system: transparent with glass edge (inner pages only — not fullpage home) ── */
body:not(.p4p-home) .p4p-section {
    position: relative;
    padding: var(--p4p-section-pad) var(--p4p-shell-x);
    background: transparent;
    border: none;
}

/* Glass card system — floats over the living background */
.p4p-glass {
    background: linear-gradient(
        160deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.02) 50%,
        rgba(255, 255, 255, 0.01) 100%
    );
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--p4p-panel-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.p4p-glass-strong {
    background: linear-gradient(
        160deg,
        rgba(255, 255, 255, 0.07) 0%,
        rgba(255, 255, 255, 0.03) 50%,
        rgba(255, 255, 255, 0.01) 100%
    );
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ── Cinematic section reveals ──
   Previous section recedes (scale down + fade)
   New section arrives from camera (scale up + fade) */
.p4p-reveal-v2 {
    opacity: 0;
    transform: scale(0.96) translateY(24px);
    transition: opacity 0.7s var(--p4p-ease-ultra), transform 0.8s var(--p4p-ease-ultra);
    will-change: transform, opacity;
}

.p4p-reveal-v2.is-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.p4p-reveal-v2.is-exiting {
    opacity: 0.4;
    transform: scale(0.94) translateY(-16px);
}

/* Subtle 3D perspective on the page wrapper for depth */
.p4p-page-wrapper {
    perspective: 1200px;
    perspective-origin: 50% 40%;
}

/* ── Typography fixes: readable, sized for all screens ── */
.p4p-section h1,
.p4p-section h2,
.p4p-section-title {
    font-family: var(--p4p-font-display);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--p4p-text-bright);
    text-wrap: balance;
}

.p4p-section h1 {
    font-size: clamp(1.6rem, 3.2vw, 2.6rem);
    margin-bottom: 0.6em;
}

.p4p-section h2,
.p4p-section-title {
    font-size: clamp(1.3rem, 2.4vw, 2rem);
    margin-bottom: 0.7em;
}

.p4p-section h3 {
    font-family: var(--p4p-font-display);
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.5em;
    color: var(--p4p-text);
}

.p4p-section p,
.p4p-section .p4p-body {
    font-family: var(--p4p-font-ui);
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    line-height: 1.7;
    color: var(--p4p-text-dim);
    max-width: 65ch;
    text-wrap: pretty;
}

.p4p-section .p4p-lead {
    font-size: clamp(0.95rem, 1.3vw, 1.1rem);
    line-height: 1.65;
    color: var(--p4p-text-dim);
    max-width: 60ch;
}

/* Remove low-FPS text effects that blur or glow too aggressively */
.p4p-section .p4p-kicker {
    font-family: var(--p4p-font-ui);
    font-size: clamp(0.6rem, 0.8vw, 0.72rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--p4p-red-soft);
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 45, 45, 0.2);
    background: rgba(255, 45, 45, 0.06);
    margin-bottom: 0.75rem;
}

/* ── Responsive: mobile-first tweaks ── */
@media (max-width: 640px) {
    body:not(.p4p-home) .p4p-section {
        padding: 1.5rem 1.25rem;
    }

    .p4p-section h1 {
        font-size: 1.5rem;
        line-height: 1.2;
    }

    .p4p-section h2,
    .p4p-section-title {
        font-size: 1.25rem;
    }

    .p4p-glass,
    .p4p-glass-strong {
        backdrop-filter: blur(8px) saturate(1.1);
        -webkit-backdrop-filter: blur(8px) saturate(1.1);
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .p4p-section {
        padding: 2rem 2.5rem;
    }
}

@media (min-width: 1921px) {
    .p4p-section {
        padding: 4rem 5rem;
    }

    .p4p-section p,
    .p4p-section .p4p-body {
        max-width: 70ch;
    }
}

/* ═══════════════════════════════════════════════════════════════
   OVERRIDE: Cinematic scale reveals (replaces translateY slides)
   Previous sections recede, new ones arrive from camera
   ═══════════════════════════════════════════════════════════════ */

/* Base hidden state for all reveal elements */
.p4p-card,
.p4p-service-block,
.p4p-portfolio-card,
.p4p-rich-story__card,
.p4p-pkg-teaser,
.p4p-sw-card,
.p4p-showcase-tile,
.p4p-rich-section,
.p4p-reveal,
.p4p-scale-reveal {
    opacity: 0 !important;
    transform: scale(0.96) translateY(20px) !important;
    transition: opacity 0.7s var(--p4p-ease-ultra), transform 0.8s var(--p4p-ease-ultra) !important;
    will-change: transform, opacity;
}

/* Visible state — arrives from camera */
.p4p-card.is-visible,
.p4p-service-block.is-visible,
.p4p-portfolio-card.is-visible,
.p4p-rich-story__card.is-visible,
.p4p-pkg-teaser.is-visible,
.p4p-sw-card.is-visible,
.p4p-showcase-tile.is-visible,
.p4p-rich-section.is-visible,
.p4p-reveal.is-visible,
.p4p-scale-reveal.is-visible {
    opacity: 1 !important;
    transform: scale(1) translateY(0) !important;
}

/* Exiting state — recedes into distance */
.p4p-card.is-exiting,
.p4p-service-block.is-exiting,
.p4p-portfolio-card.is-exiting,
.p4p-rich-story__card.is-exiting,
.p4p-pkg-teaser.is-exiting,
.p4p-sw-card.is-exiting,
.p4p-showcase-tile.is-exiting,
.p4p-rich-section.is-exiting,
.p4p-reveal.is-exiting,
.p4p-scale-reveal.is-exiting {
    opacity: 0.35 !important;
    transform: scale(0.94) translateY(-12px) !important;
}

/* Reduced motion: instant visibility, no animation */
@media (prefers-reduced-motion: reduce) {
    .p4p-card,
    .p4p-service-block,
    .p4p-portfolio-card,
    .p4p-rich-story__card,
    .p4p-pkg-teaser,
    .p4p-sw-card,
    .p4p-showcase-tile,
    .p4p-rich-section,
    .p4p-reveal,
    .p4p-scale-reveal {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}
