/* ============================================================================
   holographic.css
   ============================================================================
   Sci-fi / holographic skin for the ThoughtVault.AI landing page.
   Loaded AFTER futuristic.css + neural-network.css so its declarations
   override theirs. Sub-pages do not load this file (Phase 2 decision).
   ============================================================================ */

/* ----- Design tokens ----- */
:root {
    --holo-bg-0: #04060d;
    --holo-bg-1: #070b18;
    --holo-bg-2: #0a0e1a;
    --holo-fog: rgba(4, 6, 13, 0.92);
    --holo-cyan: #5cf2ff;
    --holo-cyan-soft: rgba(92, 242, 255, 0.55);
    --holo-violet: #a472ff;
    --holo-violet-soft: rgba(164, 114, 255, 0.45);
    --holo-line: rgba(92, 242, 255, 0.14);
    --holo-card-bg: rgba(7, 11, 24, 0.55);
    --holo-card-border: rgba(255, 255, 255, 0.06);
    --holo-text: rgba(232, 240, 255, 0.92);
    --holo-text-dim: rgba(232, 240, 255, 0.55);
    --holo-scan: 8000ms;
    --camera-tilt: 0deg;
    --camera-z: 0px;
}

/* ----- Base background ----- */
html, body {
    background: var(--holo-bg-0);
    color: var(--holo-text);
}

body.neural-page {
    /* Deep radial vignette: top-center subtle glow, edges darker */
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%,
            rgba(92, 242, 255, 0.08) 0%,
            transparent 55%),
        radial-gradient(ellipse 70% 50% at 50% 100%,
            rgba(164, 114, 255, 0.06) 0%,
            transparent 60%),
        linear-gradient(180deg, var(--holo-bg-1) 0%, var(--holo-bg-0) 100%);
    overflow-x: hidden;
}

/* The original neural-page uses #particle-canvas. We replace it with our
   own WebGL canvas; hide the old Canvas2D one so we don't double-paint. */
canvas#particle-canvas {
    display: none !important;
}

/* Same for the scan-lines / matrix-rain divs from neural-network.css —
   the new look uses CSS-grid floor + holo card scanlines instead. */
#scan-lines,
#matrix-rain,
#cursor-trail {
    display: none !important;
}

/* The legacy .neural-background div renders a full-viewport cyberpunk
   city image (`mycitybackground2.png`) at z-index:0. The user likes
   that backdrop, so keep it — just darken it a bit and let the new
   WebGL + 3D layers composite on top. */
.neural-background {
    z-index: 0 !important;
    filter: brightness(0.55) saturate(1.05);
}
.neural-background::after {
    /* Extra tint so the city reads as ambient atmosphere, not a foreground */
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
        rgba(4, 6, 13, 0.35) 0%,
        rgba(4, 6, 13, 0.55) 60%,
        rgba(4, 6, 13, 0.85) 100%);
    pointer-events: none;
}

/* ----- New WebGL particle canvas ----- */
#bg-particles {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    /* z-index 1 puts the particles above any z:0 legacy backdrop while
       still sitting under the hero/cards (which are z:2 via the rule
       further down this file). */
    z-index: 1;
    opacity: 0.82;
    /* Mounted by js/bg-particles.js on requestIdleCallback */
}

/* ----- "Scroll to enter the vault" hint ----- */
#vault-scroll-hint {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--holo-text-dim);
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.vault-hint-arrow {
    font-size: 1.4rem;
    color: var(--holo-cyan);
    text-shadow: 0 0 10px var(--holo-cyan-soft);
    animation: hint-bob 1.8s ease-in-out infinite;
}
.vault-hint-text {
    opacity: 0.65;
}
@keyframes hint-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(6px); }
}
@media (max-width: 640px) { #vault-scroll-hint { display: none; } }
@media (prefers-reduced-motion: reduce) {
    .vault-hint-arrow { animation: none !important; }
}

/* ----- Holographic 3D centerpiece (three.js scene) ----- */
#holo-scene {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    /* Above particles, below hero text */
    z-index: 1;
    /* Slight blur on the canvas edges via mask so it doesn't read as a
       hard-edged box of pixels — feels holographic-emitted */
    -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 45%,
        black 40%, transparent 95%);
    mask-image: radial-gradient(ellipse 70% 70% at 50% 45%,
        black 40%, transparent 95%);
}

/* ----- Floor grid (CSS-only 3D plane) ----- */
#floor-grid {
    position: fixed;
    left: 50%;
    bottom: -40vh;
    width: 200vw;
    height: 100vh;
    transform: translateX(-50%) perspective(800px) rotateX(60deg);
    transform-origin: 50% 100%;
    background-image:
        linear-gradient(var(--holo-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--holo-line) 1px, transparent 1px);
    background-size: 60px 60px;
    background-position: 0 0, 0 0;
    -webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 30%,
        rgba(0, 0, 0, 0.95) 0%,
        transparent 70%);
    mask-image: radial-gradient(ellipse 60% 70% at 50% 30%,
        rgba(0, 0, 0, 0.95) 0%,
        transparent 70%);
    pointer-events: none;
    /* z-index 1 same as the particle canvas — both sit above any z:0
       legacy backdrop and below the hero/cards (z:2). */
    z-index: 1;
    opacity: 0.55;
    animation: floor-pan 22s linear infinite;
}

@keyframes floor-pan {
    from { background-position: 0 0, 0 0; }
    to   { background-position: 0 60px, 60px 0; }
}

/* ----- Make the hero and hub sit above the bg layers ----- */
.neural-nav,
.neural-hero,
#hubGrid,
#site-footer,
#webos-hint,
#secret-pixel,
.neural-loading {
    position: relative;
    z-index: 2;
}

/* ----- Nav refresh: glass + neon underline ----- */
.neural-nav {
    background: rgba(7, 11, 24, 0.55) !important;
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-bottom: 1px solid rgba(92, 242, 255, 0.08);
}

.neural-nav-logo-text {
    background: linear-gradient(120deg, #ffffff 0%, var(--holo-cyan) 50%, var(--holo-violet) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.02em;
}

/* ----- Hero ----- */
.neural-hero {
    padding-top: 80px;
    padding-bottom: 100px;
    /* Camera-dolly target: js/camera-scroll.js writes --camera-tilt + --camera-z */
    transform: translateZ(var(--camera-z)) rotateX(var(--camera-tilt));
    transform-origin: 50% 50%;
    will-change: transform;
}

.neural-hero-title {
    background: linear-gradient(135deg,
        #ffffff 0%,
        var(--holo-cyan) 40%,
        var(--holo-violet) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 0.12em;
    filter: drop-shadow(0 0 24px rgba(92, 242, 255, 0.18));
    animation: title-breath 6s ease-in-out infinite;
}

@keyframes title-breath {
    0%, 100% { filter: drop-shadow(0 0 24px rgba(92, 242, 255, 0.18)); }
    50%      { filter: drop-shadow(0 0 36px rgba(164, 114, 255, 0.28)); }
}

.neural-hero-subtitle {
    color: var(--holo-text);
    text-shadow: 0 0 12px rgba(92, 242, 255, 0.18);
}

.neural-hero-tagline {
    color: var(--holo-text-dim);
}

/* ----- Holographic search bar ----- */
.neural-search {
    border: 1px solid rgba(92, 242, 255, 0.18);
    background: rgba(7, 11, 24, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.02),
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 0 32px rgba(92, 242, 255, 0.06);
    position: relative;
    overflow: hidden;
}

/* Scanline shimmer across the search bar every 6s */
.neural-search::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(92, 242, 255, 0.10) 50%,
        transparent 100%);
    transform: translateX(-100%);
    animation: search-scan 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes search-scan {
    0%, 75%  { transform: translateX(-100%); }
    85%      { transform: translateX(100%); }
    100%     { transform: translateX(100%); }
}

.neural-search-input {
    color: var(--holo-text) !important;
    background: transparent !important;
}

.neural-search-input::placeholder { color: var(--holo-text-dim); }

/* ----- Hero CTAs ----- */
.hero-cta-primary {
    background: linear-gradient(135deg, var(--holo-cyan) 0%, var(--holo-violet) 100%) !important;
    color: #04060d !important;
    box-shadow: 0 0 24px rgba(92, 242, 255, 0.28);
}

.hero-cta-primary:hover {
    box-shadow: 0 0 36px rgba(164, 114, 255, 0.5) !important;
    transform: translateY(-2px) !important;
}

.hero-cta-secondary {
    background: rgba(7, 11, 24, 0.55) !important;
    border: 1px solid rgba(92, 242, 255, 0.28) !important;
    color: var(--holo-text) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.hero-cta-secondary:hover {
    border-color: var(--holo-cyan) !important;
    box-shadow: 0 0 24px rgba(92, 242, 255, 0.2);
    transform: translateY(-2px) !important;
}

/* ----- Holographic hub cards ----- */
#hubGrid {
    /* Camera dolly applies here too so cards feel anchored to the floor */
    transform: translateZ(calc(var(--camera-z) * 0.3));
    will-change: transform;
}

.section-card {
    background: var(--holo-card-bg) !important;
    border: 1px solid var(--holo-card-border) !important;
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 16px 48px rgba(0, 0, 0, 0.55),
        0 0 0 0 var(--card-color, transparent);
    position: relative;
    overflow: hidden;
    transition:
        transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1),
        border-color 0.25s ease;
    /* Pointer-tracked tilt: js/holo-cards.js writes --px / --py (0..1) */
    --px: 0.5;
    --py: 0.5;
    /* Tilt = max 4° on either axis, computed from --px/--py */
    transform:
        perspective(900px)
        rotateX(calc((0.5 - var(--py)) * 4deg))
        rotateY(calc((var(--px) - 0.5) * 4deg));
}

/* Top hairline scanline that re-runs every ~8s — the "holographic refresh" */
.section-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 1px;
    width: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--card-color, var(--holo-cyan)) 50%,
        transparent 100%);
    opacity: 0;
    animation: card-scan var(--holo-scan) ease-in-out infinite;
    pointer-events: none;
}

/* Stagger each card's scan so they don't all pulse at once */
.section-card:nth-child(2)::before { animation-delay: 1.1s; }
.section-card:nth-child(3)::before { animation-delay: 2.3s; }
.section-card:nth-child(4)::before { animation-delay: 3.4s; }
.section-card:nth-child(5)::before { animation-delay: 4.5s; }
.section-card:nth-child(6)::before { animation-delay: 5.6s; }
.section-card:nth-child(7)::before { animation-delay: 6.7s; }
.section-card:nth-child(8)::before { animation-delay: 7.8s; }

@keyframes card-scan {
    0%   { opacity: 0; transform: translateY(0); }
    4%   { opacity: 0.9; }
    14%  { opacity: 0; transform: translateY(40px); }
    100% { opacity: 0; transform: translateY(40px); }
}

/* Edge-glow ring on hover (cursor-driven via --px/--py) */
.section-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(
        260px circle at calc(var(--px) * 100%) calc(var(--py) * 100%),
        color-mix(in srgb, var(--card-color, var(--holo-cyan)) 24%, transparent),
        transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.section-card:hover {
    transform:
        perspective(900px)
        rotateX(calc((0.5 - var(--py)) * 4deg))
        rotateY(calc((var(--px) - 0.5) * 4deg))
        translateY(-4px);
    border-color: color-mix(in srgb, var(--card-color, var(--holo-cyan)) 38%, transparent) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 24px 56px rgba(0, 0, 0, 0.65),
        0 0 32px color-mix(in srgb, var(--card-color, var(--holo-cyan)) 22%, transparent) !important;
}

.section-card:hover::after {
    opacity: 1;
}

.card-title {
    text-shadow: 0 0 12px color-mix(in srgb, var(--card-color, var(--holo-cyan)) 50%, transparent);
}

.card-item:hover {
    background: color-mix(in srgb, var(--card-color, var(--holo-cyan)) 16%, transparent) !important;
}

/* ----- Secret-pixel discovery aid (the easter egg) ----- */
#secret-pixel {
    background: transparent !important;
    /* Make it slightly easier to hit (still 5px) but reward hover with a pulse */
    transition: box-shadow 0.4s ease;
}

#secret-pixel:hover {
    box-shadow:
        0 0 6px rgba(92, 242, 255, 0.45),
        0 0 18px rgba(164, 114, 255, 0.25);
}

/* ----- Warp transition: applied to <body> when WebOS is about to launch ----- */
body.webos-warping {
    animation: warp-in 600ms cubic-bezier(0.5, 0, 0.75, 0) forwards;
    transform-origin: bottom right;
}

body.webos-warping .neural-hero,
body.webos-warping #hubGrid,
body.webos-warping .neural-nav,
body.webos-warping #site-footer {
    filter: blur(0px);
    animation: warp-blur 600ms cubic-bezier(0.5, 0, 0.75, 0) forwards;
}

@keyframes warp-in {
    0%   { transform: scale(1); }
    100% { transform: scale(0.02) translate(45vw, 45vh); }
}

@keyframes warp-blur {
    0%   { filter: blur(0px) hue-rotate(0deg); opacity: 1; }
    100% { filter: blur(40px) hue-rotate(60deg); opacity: 0; }
}

/* WebOS container fades in OVER the warped body */
#webos-container:not(.hidden) {
    animation: warp-out 500ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

@keyframes warp-out {
    0%   { opacity: 0; transform: scale(0.6); filter: blur(20px); }
    100% { opacity: 1; transform: scale(1);   filter: blur(0px); }
}

/* ----- Mobile flattening ----- */
@media (max-width: 640px) {
    #floor-grid { display: none; }
    .section-card {
        transform: none !important;
    }
    .section-card:hover {
        transform: translateY(-2px) !important;
    }
    .neural-hero { padding-top: 48px; padding-bottom: 56px; }
}

/* ----- prefers-reduced-motion: kill the spectacle ----- */
@media (prefers-reduced-motion: reduce) {
    #bg-particles,
    #floor-grid,
    .section-card::before,
    .neural-search::before {
        display: none !important;
    }
    .neural-hero-title,
    .section-card,
    body.webos-warping,
    body.webos-warping .neural-hero,
    body.webos-warping #hubGrid {
        animation: none !important;
    }
    .section-card,
    .neural-hero,
    #hubGrid {
        transform: none !important;
    }
    body.webos-warping {
        opacity: 0.3;
        transition: opacity 200ms;
    }
}
