/* ==========================================================================
   Cinematic Flow Upgrade Layer
   UI-only enhancements for spacing, hierarchy, transitions, and depth.
   ========================================================================== */

body.cinematic-shell {
    --upgrade-max-width: min(1700px, calc(100vw - clamp(1rem, 3vw, 3.4rem)));
    --upgrade-section-gap: clamp(2.8rem, 5.2vw, 5.4rem);
    --upgrade-card-gap: clamp(0.9rem, 1.8vw, 1.45rem);
    --upgrade-divider: rgba(154, 185, 255, 0.22);
    --upgrade-divider-soft: rgba(154, 185, 255, 0.1);
    --upgrade-surface-shadow: 0 30px 80px rgba(3, 8, 24, 0.46);
    --upgrade-surface-shadow-hover: 0 38px 96px rgba(3, 8, 24, 0.56);
    --stage-max-width: var(--upgrade-max-width);
    --layout-max-width: 1700px;
}

body.cinematic-shell .layout-topbar.layout-topbar-site,
body.cinematic-shell .layout-topbar.layout-topbar-app,
body.cinematic-shell .main-wrapper,
body.cinematic-shell .site-footer {
    width: min(100%, var(--upgrade-max-width));
}

body.cinematic-shell .main-wrapper,
body.cinematic-shell .site-footer {
    padding-inline: clamp(0.4rem, 1vw, 1.1rem);
}

body.cinematic-shell :is(.site-main, .app-main) {
    padding-inline: 0;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page) {
    margin-top: var(--upgrade-section-gap);
    padding-inline: clamp(0.25rem, 0.95vw, 0.8rem);
    position: relative;
    isolation: isolate;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page):first-child {
    margin-top: 0;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page):not(:first-child)::before {
    content: '';
    position: absolute;
    left: clamp(0.8rem, 2vw, 2.2rem);
    right: clamp(0.8rem, 2vw, 2.2rem);
    top: clamp(-2.15rem, -3vw, -1.2rem);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--upgrade-divider), transparent);
    box-shadow: 0 0 26px var(--upgrade-divider-soft);
    pointer-events: none;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page)::after {
    content: '';
    position: absolute;
    inset: clamp(0.15rem, 0.7vw, 0.55rem);
    border-radius: calc(var(--stage-radius-xl) + 8px);
    background:
        radial-gradient(circle at 14% 18%, rgba(143, 107, 242, 0.14), transparent 34%),
        radial-gradient(circle at 86% 78%, rgba(167, 139, 250, 0.1), transparent 30%);
    opacity: 0;
    transition: opacity 420ms ease;
    z-index: -1;
    pointer-events: none;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page):nth-of-type(even)::after,
body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page).flow-section-alt::after {
    opacity: 0.72;
}

body.cinematic-shell .surface-lift {
    box-shadow: var(--upgrade-surface-shadow);
    transform: var(--surface-tilt, translate3d(0, 0, 0));
    transition: transform 300ms ease, box-shadow 300ms ease, border-color 300ms ease, background 300ms ease;
    will-change: transform;
}

body.cinematic-shell .surface-lift:hover,
body.cinematic-shell .surface-lift:focus-within {
    transform: var(--surface-tilt, translate3d(0, -4px, 0));
    box-shadow: var(--upgrade-surface-shadow-hover);
}

body.cinematic-shell .surface-lift.surface-lift-strong:hover,
body.cinematic-shell .surface-lift.surface-lift-strong:focus-within {
    transform: var(--surface-tilt, translate3d(0, -6px, 0));
}

body.cinematic-shell :is(
    .page-intro,
    .chat-panel,
    .profile-panel,
    .profile-hero,
    .dashboard-welcome-card,
    .dashboard-usage,
    .agent-module-summary,
    .ticket-conversation-panel,
    .form-shell,
    .auth-shell,
    .auth-copy,
    .workspace-stage,
    .tab-shell,
    .overview-panel,
    .overview-kpi-card,
    .overview-note,
    .agent-checkout-shell,
    .agent-builder-shell
) {
    padding: clamp(1.1rem, 2vw, 1.55rem);
}

body.cinematic-shell :is(.feature-grid, .story-grid, .demo-grid, .metric-grid, .overview-grid, .ticket-console-grid, .pricing-v2-grid, .pricing-stage-band, .pricing-proof-grid, .dashboard-inbox-grid, .dashboard-inbox-meta, .workspace-stage-grid, .workspace-stage-metrics, .profile-layout-grid, .profile-column-main, .profile-column-side, .profile-dashboard-shell, .auth-grid, .split-section, .agent-checkout-layout, .agent-checkout-grid) {
    gap: var(--upgrade-card-gap);
}

body.cinematic-shell :is(.section-heading p, .section-copy p, .page-intro p, .profile-panel-title p, .workspace-stage-copy p, .pricing-v2-head p, .support-stage .section-copy p, .auth-copy p) {
    max-width: 72ch;
}

body.cinematic-shell :is(.section-heading h2, .section-copy h2, .page-intro h1, .workspace-stage-copy h1, .pricing-v2-head h1, .support-stage .section-copy h1, .auth-copy h1, .profile-title-row h1) {
    margin-bottom: 0.42em;
    line-height: 0.95;
}

body.has-flow-motion .flow-section {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(0.992);
    transition: opacity 560ms cubic-bezier(0.2, 0.7, 0.2, 1), transform 560ms cubic-bezier(0.2, 0.7, 0.2, 1);
    transition-delay: calc(var(--flow-index, 0) * 24ms);
}

body.has-flow-motion .flow-section.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

body.has-reveal-motion .reveal {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
    animation: none !important;
    transition: opacity 460ms cubic-bezier(0.2, 0.7, 0.2, 1), transform 460ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

body.has-reveal-motion .reveal.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    transition-delay: var(--stagger-delay, 0ms);
}

body[data-page='home'] .cinematic-home {
    padding-top: clamp(2rem, 4.5vw, 3.5rem);
}

body[data-page='home'] .home-stage {
    padding: clamp(1.5rem, 3vw, 2.45rem);
}

body[data-page='home'] .stat-strip {
    margin-top: clamp(1.7rem, 3.2vw, 2.7rem);
}

body[data-page='home'] .feature-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

body[data-page='home'] .feature-card,
body[data-page='home'] .hero-proof-card,
body[data-page='home'] .stat-card {
    min-height: 100%;
}

body[data-page='dashboard'] .workspace-stage {
    padding: clamp(1.35rem, 2.4vw, 2rem);
}

body[data-page='dashboard'] .dashboard-chat-first .dashboard-inbox-grid,
body[data-page='dashboard'] .dashboard-inbox-grid {
    grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.36fr) minmax(300px, 0.9fr);
    align-items: stretch;
}

body[data-page='dashboard'] .dashboard-inbox-meta {
    grid-auto-rows: minmax(0, auto);
}

body[data-page='dashboard'] :is(.history-list, .chat-thread) {
    max-height: clamp(340px, 54vh, 680px);
}

body[data-page='dashboard'] .workspace-stage-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

body[data-page='profile'] .profile-dashboard-shell {
    gap: clamp(1rem, 2vw, 1.6rem);
}

body[data-page='profile'] .profile-layout-grid {
    grid-template-columns: minmax(0, 1.22fr) minmax(320px, 0.78fr);
}

body[data-page='profile'] :is(.profile-column-main, .profile-column-side, .profile-info-stack) {
    gap: clamp(0.95rem, 1.8vw, 1.45rem);
}

body[data-page='profile'] .profile-hero-main {
    gap: clamp(1rem, 2vw, 1.8rem);
}

body[data-page='contact'] .support-stage {
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
    align-items: stretch;
}

body[data-page='contact'] .contact-stack {
    display: grid;
    gap: clamp(1rem, 2vw, 1.5rem);
}

body[data-page='contact'] .ticket-console-grid {
    grid-template-columns: minmax(300px, 0.78fr) minmax(0, 1.22fr);
}

body.ticket-access-page .ticket-access-shell {
    gap: clamp(0.95rem, 1.8vw, 1.4rem);
}

body[data-page='pricing'] .pricing-v2-shell {
    gap: clamp(1.2rem, 2.2vw, 1.95rem);
}

body[data-page='pricing'] .pricing-v2-grid {
    align-items: stretch;
}

body[data-page='pricing'] .pricing-v2-card {
    min-height: 100%;
}

body[data-page='agent_checkout'] .agent-checkout-layout {
    grid-template-columns: minmax(0, 1.16fr) minmax(320px, 0.84fr);
}

body[data-page='payment_success'] .stack-section {
    display: grid;
    gap: clamp(0.95rem, 2vw, 1.4rem);
}

body.admin-page .app-page {
    gap: clamp(1rem, 2vw, 1.55rem);
}

body.admin-page .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.auth-page .auth-grid {
    grid-template-columns: minmax(0, 1fr) minmax(390px, 0.92fr);
}

body.auth-page :is(.auth-copy, .auth-shell) {
    min-height: 100%;
}

@media (max-width: 1360px) {
    body.cinematic-shell {
        --upgrade-max-width: min(1500px, calc(100vw - 1.35rem));
    }

    body[data-page='dashboard'] .dashboard-chat-first .dashboard-inbox-grid,
    body[data-page='dashboard'] .dashboard-inbox-grid {
        grid-template-columns: minmax(260px, 0.78fr) minmax(0, 1.22fr) minmax(280px, 0.84fr);
    }

    body[data-page='contact'] .support-stage {
        grid-template-columns: minmax(0, 1fr) minmax(330px, 0.92fr);
    }
}

@media (max-width: 1180px) {
    body.cinematic-shell {
        --upgrade-section-gap: clamp(2.2rem, 4.8vw, 3.4rem);
    }

    body[data-page='dashboard'] .dashboard-chat-first .dashboard-inbox-grid,
    body[data-page='dashboard'] .dashboard-inbox-grid,
    body[data-page='contact'] .support-stage,
    body[data-page='contact'] .ticket-console-grid,
    body[data-page='profile'] .profile-layout-grid,
    body[data-page='agent_checkout'] .agent-checkout-layout,
    body.auth-page .auth-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    body.cinematic-shell {
        --upgrade-max-width: calc(100vw - 1rem);
    }

    body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page) {
        padding-inline: 0.2rem;
    }

    body[data-page='home'] .feature-grid,
    body[data-page='dashboard'] .workspace-stage-metrics,
    body.admin-page .metric-grid,
    body[data-page='pricing'] :is(.pricing-stage-band, .pricing-proof-grid) {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    body.cinematic-shell {
        --upgrade-section-gap: 2rem;
    }

    body.cinematic-shell :is(.page-intro, .chat-panel, .profile-panel, .profile-hero, .dashboard-welcome-card, .dashboard-usage, .agent-module-summary, .ticket-conversation-panel, .form-shell, .auth-shell, .auth-copy, .workspace-stage, .tab-shell, .overview-panel, .overview-kpi-card, .overview-note, .agent-checkout-shell, .agent-builder-shell) {
        padding: 1rem;
    }

    body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page):not(:first-child)::before {
        left: 0.4rem;
        right: 0.4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.cinematic-shell .surface-lift,
    body.cinematic-shell .surface-lift:hover,
    body.cinematic-shell .surface-lift:focus-within {
        transform: none !important;
        transition: none !important;
    }

    body.has-flow-motion .flow-section,
    body.has-flow-motion .flow-section.is-visible,
    body.has-reveal-motion .reveal,
    body.has-reveal-motion .reveal.is-visible {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   Global Cinematic Identity, Scroll Story, Scene Layer, and Magnetic System
   ========================================================================== */

html {
    --scroll-progress: 0;
}

body.has-scroll-story::before {
    content: '';
    position: fixed;
    left: 0;
    top: 0;
    width: calc(var(--scroll-progress, 0) * 100%);
    height: 3px;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.96), rgba(167, 139, 250, 0.96));
    box-shadow: 0 0 18px rgba(139, 92, 246, 0.35);
    z-index: 2200;
    pointer-events: none;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page) {
    overflow: clip;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page) > * {
    position: relative;
    z-index: 2;
}

body.cinematic-shell :is(.site-main, .app-main) > :where(.section, .app-page)::after {
    z-index: 1;
}

body.cinematic-shell .flow-section {
    border-radius: calc(var(--stage-radius-xl) + 8px);
}

body.cinematic-shell .flow-section.flow-section-alt::after {
    background:
        radial-gradient(circle at 18% 20%, rgba(139, 92, 246, 0.12), transparent 36%),
        radial-gradient(circle at 84% 74%, rgba(139, 92, 246, 0.16), transparent 31%);
}

body.cinematic-shell .magnetic-ui {
    transform: translate3d(var(--magnetic-x, 0px), var(--magnetic-y, 0px), 0) rotate(var(--magnetic-r, 0deg));
    transition: transform 180ms ease, box-shadow 240ms ease, border-color 220ms ease, background 220ms ease;
    will-change: transform;
}

body.cinematic-shell :is(.button, .tab-button, .filter-pill, .pricing-v2-segment-btn).magnetic-ui:hover {
    box-shadow: 0 16px 34px rgba(2, 10, 28, 0.34);
}

body.cinematic-shell[data-page='home'] .flow-section::after {
    opacity: 0.82;
}

body.cinematic-shell[data-page='home'] .home-stage::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 100px;
    background: linear-gradient(180deg, transparent, rgba(4, 9, 22, 0.42));
    pointer-events: none;
}

body.cinematic-shell[data-page='dashboard'] .flow-section::after {
    background:
        radial-gradient(circle at 20% 14%, rgba(99, 102, 241, 0.14), transparent 36%),
        radial-gradient(circle at 78% 76%, rgba(139, 92, 246, 0.1), transparent 30%);
}

body.cinematic-shell[data-page='dashboard'] .workspace-stage::before,
body.cinematic-shell[data-page='dashboard'] .chat-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(125deg, rgba(255, 255, 255, 0.06), transparent 36%, transparent 65%, rgba(255, 255, 255, 0.05));
    opacity: 0.42;
    z-index: 0;
}

body.cinematic-shell[data-page='profile'] .flow-section::after {
    background:
        radial-gradient(circle at 20% 16%, rgba(124, 58, 237, 0.15), transparent 34%),
        radial-gradient(circle at 82% 78%, rgba(167, 139, 250, 0.1), transparent 28%);
}

body.cinematic-shell[data-page='profile'] :is(.profile-hero, .profile-panel) {
    border-color: rgba(174, 196, 255, 0.2);
}

body.cinematic-shell[data-page='pricing'] .flow-section::after {
    background:
        radial-gradient(circle at 16% 22%, rgba(167, 139, 250, 0.16), transparent 34%),
        radial-gradient(circle at 88% 76%, rgba(167, 139, 250, 0.12), transparent 30%);
}

body.cinematic-shell[data-page='pricing'] .pricing-v2-card {
    transition: transform 300ms ease, box-shadow 300ms ease, border-color 260ms ease;
}

body.cinematic-shell[data-page='pricing'] .pricing-v2-card:hover {
    transform: translate3d(0, -6px, 0);
    box-shadow: 0 34px 86px rgba(6, 11, 28, 0.54);
}

body.cinematic-shell[data-page='contact'] .flow-section::after,
body.cinematic-shell.ticket-access-page .flow-section::after {
    background:
        radial-gradient(circle at 20% 18%, rgba(139, 92, 246, 0.14), transparent 35%),
        radial-gradient(circle at 84% 74%, rgba(139, 92, 246, 0.12), transparent 28%);
}

body.cinematic-shell[data-page='contact'] .ticket-summary-card,
body.cinematic-shell.ticket-access-page .ticket-conversation-panel {
    border-color: rgba(160, 233, 189, 0.2);
}

body.cinematic-shell[data-page='admin'] .flow-section::after,
body.cinematic-shell.admin-page .flow-section::after {
    background:
        radial-gradient(circle at 16% 16%, rgba(99, 102, 241, 0.16), transparent 32%),
        radial-gradient(circle at 84% 78%, rgba(139, 92, 246, 0.12), transparent 30%);
}

body.cinematic-shell.admin-page :is(.tab-shell, .overview-panel, .overview-kpi-card, .metric-card) {
    border-color: rgba(140, 178, 255, 0.2);
}

body.cinematic-shell[data-page='workspace_agents'] .flow-section::after,
body.cinematic-shell[data-page='agent_checkout'] .flow-section::after {
    background:
        radial-gradient(circle at 18% 18%, rgba(124, 58, 237, 0.16), transparent 34%),
        radial-gradient(circle at 86% 74%, rgba(139, 92, 246, 0.11), transparent 30%);
}

body.cinematic-shell[data-page='payment_success'] .flow-section::after,
body.cinematic-shell[data-page='ticket_success'] .flow-section::after {
    background:
        radial-gradient(circle at 16% 22%, rgba(167, 139, 250, 0.12), transparent 34%),
        radial-gradient(circle at 84% 76%, rgba(139, 92, 246, 0.14), transparent 30%);
}

body.cinematic-shell.auth-page .flow-section::after {
    background:
        radial-gradient(circle at 16% 22%, rgba(139, 92, 246, 0.18), transparent 35%),
        radial-gradient(circle at 86% 74%, rgba(167, 139, 250, 0.12), transparent 30%);
}

body.cinematic-shell .genasstai-asst-widget .asst-panel {
    box-shadow:
        0 28px 90px rgba(1, 7, 21, 0.56),
        0 0 0 1px rgba(139, 92, 246, 0.11),
        0 0 34px rgba(167, 139, 250, 0.1);
}

body.cinematic-shell .genasstai-asst-widget .asst-launcher {
    border-color: rgba(126, 163, 255, 0.34);
}

@media (max-width: 980px) {
    body.has-scroll-story::before {
        height: 2px;
    }

}

@media (max-width: 720px) {
}

@media (prefers-reduced-motion: reduce) {
    body.has-scroll-story::before {
        display: none;
    }

    body.cinematic-shell .magnetic-ui {
        transform: none !important;
        transition: none !important;
    }
}
