/* Home v11 — pixel-fit layout, z-index stack, cap rail, FPS-friendly surfaces */

body.p4p-home {
    --p4p-z-mesh: 1;
    --p4p-z-main: 10;
    --p4p-z-section: 8;
    --p4p-z-section-on: 20;
    --p4p-z-shell: 25;
    --p4p-z-interact: 30;
    --p4p-z-chrome: 4000;
    --p4p-z-tl: 5000;
    --p4p-z-header: 10000;
    --p4p-home-pad-x: max(clamp(0.85rem, 2.5vw, 1.35rem), env(safe-area-inset-left));
    --p4p-home-pad-top: calc(var(--p4p-header, 72px) + clamp(0.25rem, 1.2vh, 0.65rem));
    --p4p-home-pad-bot: max(clamp(0.35rem, 1.2vh, 0.75rem), env(safe-area-inset-bottom));
}

/* ── Z-index canonical stack ── */
.p4p-home-canvas { z-index: var(--p4p-z-mesh) !important; }
.p4p-home-main { z-index: var(--p4p-z-main); isolation: isolate; }
.p4p-section { z-index: var(--p4p-z-section); }
.p4p-section.is-active { z-index: var(--p4p-z-section-on); }
.p4p-section__shell { z-index: var(--p4p-z-shell); position: relative; isolation: isolate; }
.p4p-tl-minimal { z-index: var(--p4p-z-tl) !important; }
body.p4p-home .p4p-header { z-index: var(--p4p-z-header) !important; }
.p4p-next-indicator { z-index: calc(var(--p4p-z-chrome) - 50); pointer-events: auto; }

/* ── Global shell fit (every section) ── */
body.p4p-home .p4p-section__shell {
    width: min(100% - var(--p4p-home-pad-x) * 2, 1160px);
    max-height: 100svh;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: var(--p4p-home-pad-top) var(--p4p-home-pad-x) var(--p4p-home-pad-bot);
    justify-content: center;
    gap: clamp(0.3rem, 0.9vh, 0.55rem);
    box-sizing: border-box;
}

body.p4p-home .p4p-section--capabilities .p4p-section__shell,
body.p4p-home .p4p-section--careers .p4p-section__shell {
    overflow: visible;
}

body.p4p-home .p4p-section:not(.is-active) .p4p-section__shell {
    pointer-events: none;
}

/* No text overlap from glitch layers */
body.p4p-home .p4p-glitch-text {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    vertical-align: top;
}

body.p4p-home .p4p-section:not(.p4p-section--finale) .p4p-glitch-text::before,
body.p4p-home .p4p-section:not(.p4p-section--finale) .p4p-glitch-text::after {
    display: none;
}

/* FPS: replace heavy backdrop-filter on home cards with solid glass */
body.p4p-home .p4p-hero-v4__glass,
body.p4p-home .p4p-hero-v4__badge,
body.p4p-home .p4p-section-intro,
body.p4p-home .p4p-cap-studio__deck,
body.p4p-home .p4p-gateway-fuse,
body.p4p-home .p4p-studio-terminal,
body.p4p-home .p4p-section--finale .p4p-command-center {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ── SEC 1 Genesis ── */
.p4p-section--genesis .p4p-section__shell {
    justify-content: center;
}

.p4p-hero-v4 {
    min-height: 0 !important;
    padding-top: 0 !important;
    width: 100%;
}

.p4p-hero-v4__shell {
    max-width: min(820px, 100%);
}

.p4p-hero-v4__title {
    font-size: clamp(1.85rem, 4.8vw, 3.75rem) !important;
    line-height: 1.04 !important;
    margin-bottom: 0.65rem !important;
}

.p4p-hero-v4__lead {
    font-size: clamp(0.82rem, 1.45vw, 1.05rem) !important;
    margin-bottom: 1rem !important;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.p4p-hero-v4__glass {
    padding: clamp(1.1rem, 2.5vw, 1.85rem) clamp(1rem, 2.5vw, 1.65rem) !important;
}

.p4p-hero-v4__actions {
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center;
}

.p4p-hero-v4__actions .p4p-btn-glow {
    padding: 0.85rem 1.35rem;
    font-size: 0.72rem;
    position: relative;
    z-index: 2;
    flex: 0 1 auto;
    max-width: 100%;
}

.p4p-hero-v3__orbit {
    display: none !important;
}

/* ── SEC 2 Capabilities — stack fit (layout in v12) ── */
.p4p-section--capabilities {
    overflow: visible;
}

.p4p-section--capabilities .p4p-section__shell {
    overflow-x: visible;
    overflow-y: hidden;
    max-height: 100svh;
}

.p4p-capabilities-stack {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
}

.p4p-cap-studio {
    grid-area: studio;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
}

.p4p-cap-studio__head {
    margin-bottom: 0.15rem;
}

.p4p-cap-studio__title {
    font-size: clamp(1.2rem, 2.4vw, 1.75rem) !important;
}

.p4p-cap-studio__deck {
    padding: 0.45rem 0.65rem;
    gap: 0.35rem;
}

.p4p-cap-studio__lead {
    font-size: clamp(0.72rem, 1.25vw, 0.88rem) !important;
    line-height: 1.55 !important;
    overflow: visible;
    display: block;
    text-overflow: unset;
    -webkit-line-clamp: unset;
}

.p4p-cap-studio__duo {
    gap: 0.35rem;
}

.p4p-cap-studio__chip {
    padding: 0.4rem 0.55rem;
}

.p4p-cap-studio__chip p {
    font-size: clamp(0.68rem, 1.05vw, 0.78rem) !important;
    line-height: 1.45 !important;
    overflow: visible;
    display: block;
    -webkit-line-clamp: unset;
}

.p4p-cap-studio__hint {
    display: none;
}

.p4p-section--capabilities .p4p-carousel-scene {
    position: relative;
    z-index: var(--p4p-z-interact);
    width: 100%;
    max-width: min(100vw - 2rem, 980px);
    margin: 0 auto;
    height: auto;
    min-height: clamp(280px, 32vh, 380px);
    max-height: none;
    perspective: 1600px;
    perspective-origin: 50% 42%;
    overflow: visible;
    flex-shrink: 0;
    padding: 0 clamp(0.75rem, 4vw, 2.5rem);
}

.p4p-carousel-rotor {
    width: min(280px, 58vw) !important;
    height: min(380px, 38vh) !important;
    max-height: 420px;
}

.p4p-carousel-card {
    overflow: visible !important;
    padding: 0.85rem 1rem !important;
}

.p4p-service-card__visual {
    max-height: 52px;
    overflow: hidden;
    flex-shrink: 0;
}

.p4p-service-card__visual svg {
    max-height: 48px;
    width: auto;
}

.p4p-carousel-card .p4p-service-card__title {
    font-size: clamp(0.95rem, 1.8vw, 1.15rem) !important;
    margin-bottom: 0.35rem !important;
    line-height: 1.2;
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
}

.p4p-carousel-card .p4p-service-card__quote {
    margin-bottom: 0.35rem !important;
    padding: 0.4rem 0.55rem 0.4rem 0.85rem !important;
    font-size: 0.68rem !important;
    line-height: 1.45;
    overflow: visible;
    display: block;
    -webkit-line-clamp: unset;
}

.p4p-carousel-card .p4p-service-card__desc {
    font-size: 0.72rem !important;
    line-height: 1.45;
    margin-bottom: 0.45rem !important;
    flex: 0 1 auto;
    min-height: 0;
    overflow: visible;
    display: block;
    -webkit-line-clamp: unset !important;
}

.p4p-carousel-card .p4p-service-card__cta {
    padding: 0.55rem 0.85rem !important;
    font-size: 0.62rem !important;
    margin-top: auto;
    flex-shrink: 0;
    position: relative;
    z-index: 3;
    align-self: flex-start;
}

.p4p-service-card__inner {
    min-height: 0;
    overflow: visible;
}

/* ── Cap rail (section 2 sub-timeline) — full redesign ── */
.p4p-cap-rail {
    grid-area: rail;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    flex-shrink: 0;
    position: relative;
    z-index: var(--p4p-z-interact);
    padding: 0.45rem 0.55rem 0.35rem;
    border-radius: 14px;
    border: 1px solid rgba(167, 139, 250, 0.2);
    background: rgba(10, 8, 16, 0.88);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.p4p-cap-rail__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.p4p-cap-rail__label {
    font-family: var(--p4p-font-tech, monospace);
    font-size: 0.52rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(232, 168, 124, 0.75);
}

.p4p-cap-rail__counter {
    font-family: var(--p4p-font-tech, monospace);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.55);
}

.p4p-cap-rail__counter strong {
    color: var(--p4p-accent-soft, #f0c4a0);
    font-size: 0.72rem;
}

.p4p-cap-rail__track-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.35rem;
}

.p4p-cap-rail__nav {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.75);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    position: relative;
    z-index: 2;
}

.p4p-cap-rail__nav:hover:not(:disabled) {
    background: rgba(232, 168, 124, 0.12);
    border-color: rgba(232, 168, 124, 0.35);
    color: #fff;
}

.p4p-cap-rail__nav:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.p4p-cap-rail__track {
    position: relative;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.p4p-cap-rail__fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, rgba(167, 139, 250, 0.35), rgba(232, 168, 124, 0.45));
    transition: width 0.45s cubic-bezier(0.19, 1, 0.22, 1);
    pointer-events: none;
}

.p4p-cap-rail__nodes {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    height: 100%;
    padding: 3px 4px;
    gap: 2px;
}

.p4p-cap-rail__node {
    flex: 1 1 0;
    min-width: 0;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: rgba(255, 255, 255, 0.42);
    font-family: var(--p4p-font-tech, monospace);
    font-size: clamp(0.48rem, 1.1vw, 0.58rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.25s, background 0.25s, box-shadow 0.25s;
    position: relative;
    z-index: 2;
}

.p4p-cap-rail__node:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.06);
}

.p4p-cap-rail__node.is-active {
    color: #1a1008;
    background: linear-gradient(135deg, #e8a87c, #f0c4a0);
    box-shadow: 0 2px 12px rgba(232, 168, 124, 0.4);
}

.p4p-cap-rail__terminus {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: background 0.35s, box-shadow 0.35s;
    pointer-events: none;
    z-index: 2;
}

.p4p-cap-rail.is-at-end .p4p-cap-rail__terminus {
    background: #86efac;
    border-color: #86efac;
    box-shadow: 0 0 10px rgba(134, 239, 172, 0.65);
}

.p4p-cap-rail__status {
    margin: 0.35rem 0 0;
    text-align: center;
    font-family: var(--p4p-font-tech, monospace);
    font-size: 0.56rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.p4p-cap-rail.is-at-end .p4p-cap-rail__status {
    color: #86efac;
}

/* Hide legacy timeline */
.p4p-capabilities-timeline,
.p4p-capabilities-timeline__tags {
    display: none !important;
}

/* ── SEC 3 Gateway ── */
.p4p-section--gateway .p4p-section__shell {
    max-width: 920px;
}

.p4p-gateway-fuse__head {
    margin-bottom: 0.65rem !important;
}

.p4p-gateway-fuse__intro {
    font-size: clamp(0.78rem, 1.3vw, 0.88rem) !important;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.p4p-portals-3d {
    max-height: min(38svh, 340px);
    gap: clamp(0.65rem, 2vw, 1.25rem) !important;
}

.p4p-portal-door {
    height: auto !important;
    min-height: 0 !important;
    max-height: min(34svh, 300px) !important;
    padding: clamp(1rem, 2vw, 1.5rem) !important;
    overflow: hidden;
}

.p4p-portal-door h3 {
    font-size: clamp(1.1rem, 2vw, 1.5rem) !important;
    margin-bottom: 0.45rem !important;
}

.p4p-portal-door p {
    font-size: 0.78rem !important;
    margin-bottom: 0.85rem !important;
    -webkit-line-clamp: 2 !important;
}

.p4p-portal-door__btn {
    padding: 0.65rem 1.25rem !important;
    font-size: 0.68rem !important;
    position: relative;
    z-index: 2;
}

/* ── SEC 4 Experience ── */
.p4p-section--experience .p4p-section__head {
    margin-bottom: 0.35rem !important;
}

.p4p-section--experience .p4p-section-title {
    font-size: clamp(1.25rem, 2.5vw, 1.85rem) !important;
}

.p4p-section--experience .p4p-section-intro {
    font-size: 0.78rem !important;
    padding: 0.55rem 0.85rem !important;
    margin-top: 0.35rem !important;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.p4p-studio-flow {
    margin: 0.25rem 0 !important;
}

.p4p-studio-flow__step {
    min-width: 0 !important;
    padding: 0.45rem 0.65rem !important;
    font-size: 0.62rem !important;
}

.p4p-section--experience .p4p-studio-terminal {
    height: min(38svh, 360px) !important;
    max-height: 360px;
    flex-shrink: 1;
    min-height: 0;
}

.p4p-term-readout__text {
    font-size: 0.78rem !important;
    -webkit-line-clamp: 3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── SEC 5 Careers ── */
.p4p-section--careers {
    overflow: visible;
}

.p4p-section--careers .p4p-section__shell {
    overflow: visible;
}

.p4p-section--careers .p4p-section__head {
    margin-bottom: 0.25rem !important;
}

.p4p-careers-wheel {
    max-height: none !important;
    width: min(100%, 920px);
    margin: 0 auto;
}

.p4p-csgo-stage {
    width: min(420px, 88vw) !important;
    height: min(420px, 88vw) !important;
    max-width: 420px !important;
    max-height: 420px !important;
}

.p4p-csgo-core {
    width: 190px !important;
    height: 190px !important;
}

.p4p-csgo-core__title {
    font-size: 1rem !important;
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
    line-height: 1.15;
}

.p4p-csgo-core__desc {
    font-size: 0.72rem !important;
    line-height: 1.5 !important;
    overflow: visible;
    display: block;
    -webkit-line-clamp: unset !important;
    max-height: none;
}

.p4p-csgo-core__btn {
    font-size: 0.62rem !important;
    padding: 0.45rem 0.75rem !important;
    position: relative;
    z-index: 3;
}

/* ── SEC 6 Finale ── */
.p4p-section--finale .p4p-section__shell {
    max-width: 920px !important;
    padding-left: var(--p4p-home-pad-x) !important;
    padding-right: var(--p4p-home-pad-x) !important;
}

.p4p-section--finale .p4p-command-center {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(0.75rem, 2vw, 1.25rem);
    max-height: none;
    overflow: visible;
    align-items: stretch;
}

.p4p-command-center__hud {
    min-width: 0;
    overflow: visible;
}

.p4p-command-center__hud .p4p-section-title {
    font-size: clamp(1.5rem, 3vw, 2.25rem) !important;
    margin-bottom: 0.65rem !important;
}

.p4p-command-center__intro {
    font-size: 0.82rem !important;
    -webkit-line-clamp: unset;
    display: block;
    -webkit-box-orient: unset;
    overflow: visible;
}

.p4p-command-center__form {
    min-width: 0;
    max-height: none;
    overflow: visible;
}

/* Next indicator — avoid timeline overlap */
.p4p-next-indicator {
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    right: max(1.25rem, env(safe-area-inset-right));
}

@media (min-width: 1100px) {
    .p4p-next-indicator {
        right: calc(min(220px, 18vw) + 1.75rem);
    }
}

body.p4p-home.is-cap-section .p4p-next-indicator,
body.p4p-home.is-last-section .p4p-next-indicator {
    opacity: 0;
    pointer-events: none;
}

/* Short viewports */
@media (max-height: 720px) {
    .p4p-cap-studio { max-height: none; }
    .p4p-section--capabilities .p4p-carousel-scene { min-height: min(32svh, 280px); max-height: none; }
    .p4p-carousel-rotor { height: min(280px, 30svh) !important; }
    .p4p-hero-v4__title { font-size: clamp(1.65rem, 4.2vw, 2.5rem) !important; }
}

@media (max-height: 620px) {
    .p4p-cap-studio__duo { grid-template-columns: 1fr; }
    .p4p-cap-studio__chip:not(.is-active) { display: none; }
}

@media (max-width: 768px) {
    body.p4p-home .p4p-section__shell {
        max-height: none;
        height: auto;
        overflow: visible;
    }

    .p4p-section--capabilities .p4p-section__shell {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .p4p-cap-studio { max-height: none; }
    .p4p-cap-studio__lead,
    .p4p-cap-studio__chip p,
    .p4p-carousel-card .p4p-service-card__quote,
    .p4p-carousel-card .p4p-service-card__desc {
        font-size: 0.82rem !important;
        line-height: 1.55 !important;
    }

    .p4p-section--capabilities .p4p-carousel-scene {
        max-height: none;
        min-height: auto;
        padding: 0 0.25rem;
        overflow: visible;
    }

    .p4p-carousel-rotor.is-touch-flat .p4p-carousel-card.is-mobile-active {
        min-height: auto;
        height: auto !important;
    }

    /* Careers — vertical stack on phone */
    .p4p-careers-wheel { max-height: none !important; }
    .p4p-csgo-stage {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: none !important;
        display: grid;
        gap: 0.85rem;
        padding: 0.25rem;
    }
    .p4p-csgo-nodes {
        position: static;
        inset: auto;
        width: 100%;
        height: auto;
        border-radius: 16px;
        border: 1px solid rgba(232, 168, 124, 0.18);
        padding: 0.65rem;
        display: grid;
        gap: 0.5rem;
    }
    .p4p-csgo-node {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
        width: 100%;
    }
    .p4p-csgo-node:nth-child(1),
    .p4p-csgo-node:nth-child(2),
    .p4p-csgo-node:nth-child(3),
    .p4p-csgo-node:nth-child(4),
    .p4p-csgo-node:nth-child(5),
    .p4p-csgo-node:nth-child(6) {
        transform: none !important;
    }
    .p4p-csgo-node__content {
        width: 100%;
        min-height: 52px;
    }
    .p4p-csgo-core {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 160px;
        margin: 0;
    }
    .p4p-csgo-core__desc { display: block !important; }
    .p4p-csgo-side-preview {
        position: static;
        transform: none !important;
        width: 100%;
        opacity: 1;
        pointer-events: auto;
        margin-top: 0.25rem;
    }
    .p4p-csgo-bolts { display: none !important; }

    .p4p-section--finale .p4p-command-center { grid-template-columns: 1fr; max-height: none; }
    .p4p-next-indicator { right: 1rem; bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 0.5rem); }
}
