/**
 * P4PN v3.1 — authority layer: kills legacy CSS/JS conflicts, final home layout.
 * Loads LAST — overrides home-refined, home-layout, home-polish transforms.
 */

/* ═══ HEADER — single source of truth ═══ */
html:not(.p4p-preloader-active) body.p4pn-home .p4p-header,
html:not(.p4p-preloader-active) body.p4pn-cover-page .p4p-header,
html:not(.p4p-preloader-active) body.p4pn-fluid .p4p-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 10000 !important;
    transform: none !important;
    translate: none !important;
}

/* ═══ Kill home-refined bottom-anchor grid conflicts ═══ */
body.p4pn-cover-page .p4p-section--capabilities .p4p-section__shell {
    justify-content: center !important;
    align-items: center !important;
    overflow: hidden !important;
}

body.p4pn-cover-page .p4p-capabilities-stack {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(210px, 340px) !important;
    grid-template-rows: minmax(0, 1fr) auto !important;
    align-items: center !important;
    justify-items: stretch !important;
    width: min(100%, 900px) !important;
    max-width: min(100%, 900px) !important;
    height: 100% !important;
    max-height: 100% !important;
    margin-left: auto !important;
    margin-right: clamp(0.25rem, 1.5cqi, 1rem) !important;
    gap: clamp(0.4rem, 1cqi, 0.75rem) !important;
    transform: none !important;
    transform-origin: center center !important;
}

body.p4pn-cover-page .p4p-section--capabilities .p4p-carousel-scene {
    grid-column: 1 !important;
    grid-row: 1 !important;
    z-index: 5 !important;
    min-height: 0 !important;
    max-height: 100% !important;
    margin: 0 !important;
}

body.p4pn-cover-page .p4p-cap-band {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: auto !important;
    flex: none !important;
    align-self: center !important;
}

body.p4pn-cover-page .p4p-cap-rail {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
}

/* Organic backdrop — authority definition */
body.p4pn-cover-page .p4p-capabilities-stack::before {
    content: '' !important;
    display: block !important;
    position: absolute;
    inset: -5% -6% -8% -10%;
    z-index: 0;
    pointer-events: none;
    border-radius: 38% 62% 58% 42% / 52% 44% 56% 48%;
    background:
        radial-gradient(ellipse 80% 70% at 28% 42%, rgba(167, 139, 250, 0.14) 0%, transparent 62%),
        radial-gradient(ellipse 65% 55% at 78% 28%, rgba(232, 168, 124, 0.12) 0%, transparent 58%),
        radial-gradient(ellipse 90% 80% at 50% 88%, rgba(34, 211, 238, 0.06) 0%, transparent 55%),
        linear-gradient(145deg, rgba(12, 10, 22, 0.52) 0%, rgba(6, 6, 14, 0.32) 100%);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

body.p4pn-cover-page .p4p-capabilities-stack::after {
    display: none !important;
}

/* ═══ Gateway — CSS-only 3D (block JS tilt override) ═══ */
body.p4pn-cover-page .p4p-portal-door--dev {
    transform: rotateY(14deg) translateZ(0) !important;
}

body.p4pn-cover-page .p4p-portal-door--client {
    transform: rotateY(-14deg) translateZ(0) !important;
}

@media (hover: hover) {
    body.p4pn-cover-page .p4p-portal-door--dev:hover {
        transform: rotateY(0deg) translateZ(48px) scale(1.02) !important;
    }

    body.p4pn-cover-page .p4p-portal-door--client:hover {
        transform: rotateY(0deg) translateZ(48px) scale(1.02) !important;
    }
}

/* ═══ Careers — globe + hover (from refined, without layout bugs) ═══ */
body.p4pn-cover-page .p4p-careers-globe .p4p-csgo-stage {
    border-radius: 50%;
    transform-style: preserve-3d;
}

body.p4pn-cover-page .p4p-section--careers .p4p-csgo-node.is-active .p4p-csgo-node__content,
body.p4pn-cover-page .p4p-section--careers .p4p-csgo-node:hover .p4p-csgo-node__content {
    background: rgba(232, 168, 124, 0.14) !important;
    border-color: rgba(232, 168, 124, 0.55) !important;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5), 0 0 24px rgba(232, 168, 124, 0.25) !important;
    transform: translateZ(36px) scale(1.06) !important;
}

/* ═══ Disable cover-scale transform bugs on sections ═══ */
body.p4pn-cover-page [data-p4pn-cover-target] {
    transform: none !important;
    will-change: auto !important;
}

body.p4pn-cover-page .p4p-vp-fit {
    transform: scale(var(--p4pn-cover-scale, 1)) !important;
    transform-origin: center center !important;
}

/* ═══ FPS — tier 2 kills expensive layers ═══ */
html.p4p-perf-tier-2 body.p4pn-home .p4p-ambient-light,
html.p4p-perf-tier-2 body.p4pn-home .p4p-hero-v3__orbit,
html.p4p-perf-tier-2 body.p4pn-home .p4p-tl-minimal__orbit {
    display: none !important;
}

html.p4p-perf-tier-1 body.p4pn-home .p4p-ambient-light {
    opacity: 0.45 !important;
    filter: none !important;
}

html.p4p-perf-lite body.p4pn-home .p4p-fx-cursor,
html.p4p-perf-lite body.p4pn-home .p4p-cursor {
    display: none !important;
}

/* ═══ Inner pages — kill duplicate mesh filters ═══ */
body.p4pn-fluid.p4p-page--grid-full .p4p-page-mesh {
    filter: brightness(1.05) contrast(1.02) !important;
    mix-blend-mode: normal !important;
    opacity: 0.75 !important;
}

body.p4pn-fluid.p4p-page--portfolio .p4p-portfolio-grid,
body.p4pn-fluid.p4p-page--about .bento-grid {
    contain: layout style;
}

@media (max-width: 820px) {
    body.p4pn-cover-page .p4p-capabilities-stack {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto auto !important;
        margin-right: 0 !important;
    }

    body.p4pn-cover-page .p4p-cap-band {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    body.p4pn-cover-page .p4p-section--capabilities .p4p-carousel-scene {
        grid-row: 2 !important;
    }
}
