/* ==========================================================================
   KYTRIX Brand Experience — Phase 1 Pure Atmosphere CSS
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #FBFCFE; /* Living light background */
    cursor: default;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#water-trail-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #FBFCFE;
    z-index: 1;
}

#water-trail-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Edge Fade Overlays: Blends WebGL gradients seamlessly into background */
.wt-fade {
    position: absolute;
    pointer-events: none;
    z-index: 2;
}

.wt-fade-top {
    top: 0;
    left: 0;
    width: 100%;
    height: 15vh;
    background: linear-gradient(to bottom, #FBFCFE 0%, rgba(251, 252, 254, 0) 100%);
}

.wt-fade-bottom {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15vh;
    background: linear-gradient(to top, #FBFCFE 0%, rgba(251, 252, 254, 0) 100%);
}

.wt-fade-left {
    top: 0;
    left: 0;
    width: 15vw;
    height: 100%;
    background: linear-gradient(to right, #FBFCFE 0%, rgba(251, 252, 254, 0) 100%);
}

.wt-fade-right {
    top: 0;
    right: 0;
    width: 15vw;
    height: 100%;
    background: linear-gradient(to left, #FBFCFE 0%, rgba(251, 252, 254, 0) 100%);
}

/* ─── LOGO MONUMENT CONTAINER & PERSPECTIVE ─── */
#monument-container {
    position: fixed; /* Fixed relative to screen scroll */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    pointer-events: auto; /* Clickable to toggle states */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 46vw;
    max-width: 760px;
    min-width: 300px;
    aspect-ratio: 700 / 230;
    perspective: 1200px;
    transform-style: preserve-3d;
    /* NO positional transition — story-mode snaps instantly via JS class toggle */
}

/* Story Mode — monument snaps instantly to left spine (no slide) */
.story-mode #monument-container {
    top: 12vh;
    left: 6vw;
    transform: translate(0, 0);
    width: 14vw;
    min-width: 160px;
    max-width: 260px;
    aspect-ratio: auto;
    height: 76vh;
    align-items: flex-start;
    justify-content: flex-start;
    transition: none; /* Instant repositioning — letters emerge in place */
}

#monument-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    transform-style: preserve-3d;
    will-change: transform;
    
    /* Gentle floating motion for luxury brand feel */
    animation: logo-float 9s ease-in-out infinite alternate;
}

.story-mode #monument-wrapper {
    align-items: flex-start;
    animation: none; /* Disable float in story mode for stable navigation click targets */
}

/* ─── ATMOSPHERIC ILLUMINATION AURA ─── */
#logo-atmospheric-glow {
    position: absolute;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 76vw;
    height: 38vh;
    max-width: 800px;
    max-height: 400px;
    
    /* Soft color-matched backlighting gradient */
    background: radial-gradient(circle, 
        rgba(124, 50, 179, 0.16) 0%, 
        rgba(75, 62, 192, 0.06) 45%, 
        rgba(234, 161, 164, 0.02) 70%,
        transparent 90%
    );
    filter: blur(65px);
    z-index: -2;
    pointer-events: none;
    opacity: 0;
    
    /* Slow luxury emergence fade-in */
    animation: glow-emerge 4s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    animation-delay: 0.4s;
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.story-mode #logo-atmospheric-glow {
    opacity: 0 !important;
    transform: translate(-50%, -50%) scale(0.7);
}

@keyframes logo-float {
    0% {
        transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg);
    }
    50% {
        transform: translate3d(0, -9px, 8px) rotateX(1deg) rotateY(-0.5deg);
    }
    100% {
        transform: translate3d(0, 5px, -4px) rotateX(-0.5deg) rotateY(0.5deg);
    }
}

@keyframes glow-emerge {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.0);
    }
}

#kytrix-logo-letters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.14em;
    transform-style: preserve-3d;
    transition: none; /* No gap transition — letters appear in place */
}

.story-mode #kytrix-logo-letters {
    flex-direction: column;
    gap: 2.8vh;
    align-items: flex-start;
    width: 100%;
}

/* ─── CASCADING ATMOSPHERIC LIGHT PULSE ─── */
.logo-letter.shimmer-pulse {
    animation: letter-glow-pulse 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes letter-glow-pulse {
    0% {
        filter: brightness(1) drop-shadow(0 0 0px rgba(75, 62, 192, 0));
    }
    25% {
        filter: brightness(1.75) drop-shadow(0 0 12px currentColor);
    }
    100% {
        filter: brightness(1) drop-shadow(0 0 0px rgba(75, 62, 192, 0));
    }
}

/* ─── LETTER CONTAINERS — BASE STATE (landing page, centered) ─── */
.letter-container {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    will-change: transform, opacity, filter;
    transform-style: preserve-3d;
    opacity: 0;
    animation: letter-emerge 2.2s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── STORY MODE — Letters already in left position, emerge like surfacing from water ─── */
.story-mode .letter-container {
    flex-direction: row;
    align-items: center;
    width: auto;
    pointer-events: auto;
    /* Reset any active animation, then play water-surface emergence */
    animation: none;
    opacity: 0;
    filter: blur(10px);
    transform: translateZ(-60px) scale(0.88);
    transition: none; /* Will be applied after class toggle via JS micro-delay */
}

/* Emergence triggered by adding .emerging class via JS */
.story-mode .letter-container.emerging {
    opacity: 0.72;
    filter: blur(0px);
    transform: translateZ(0) scale(1);
    transition: opacity 1.6s cubic-bezier(0.16, 1, 0.3, 1),
                filter 1.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 1.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.story-mode .letter-container.active {
    opacity: 1.0;
    filter: blur(0px);
    transform: translateZ(0) translate3d(10px, 0, 0) scale(1.02);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.4s ease,
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.story-mode .letter-container:not(.active):hover {
    opacity: 0.88;
    filter: blur(0px);
    transform: translateZ(0) translate3d(5px, 0, 0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes letter-emerge {
    0% {
        opacity: 0;
        transform: translate3d(0, 50px, -150px) rotateX(-20deg) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) rotateX(0deg) scale(1);
    }
}

/* Staggered entrance delays for each letter container */
.letter-K-container { animation-delay: 0.12s; }
.letter-Y-container { animation-delay: 0.22s; }
.letter-T-container { animation-delay: 0.32s; }
.letter-R-container { animation-delay: 0.42s; }
.letter-I-container { animation-delay: 0.52s; }
.letter-X-container { animation-delay: 0.62s; }

/* Menu concept labels */
.letter-label {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.5s ease, max-width 0.5s ease, margin-left 0.5s ease;
}

.story-mode .letter-label {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(11px, 1.05vw, 15px);
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(20, 18, 60, 0.78);  /* Deep navy — readable on light bg */
    margin-left: 14px;
    opacity: 1;
    max-width: 220px;
    pointer-events: auto;
}

.logo-letter {
    font-family: "Arial Black", "Montserrat", sans-serif;
    font-weight: 900; /* Extremely heavy, bold and blocky geometry */
    font-size: 8.6vw; /* Robust visual scale */
    line-height: 1.0;
    display: inline-block;
    
    /* Perfect vector gradients with shimmer backgrounds */
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    
    will-change: transform;
    transform-style: preserve-3d;
    
    /* Smooth text size transition during layout folding */
    transition: font-size 1.8s cubic-bezier(0.19, 1, 0.22, 1);
    
    /* Continuous slow color flow inside the letterforms */
    animation: letter-shimmer 14s ease infinite alternate;
}

.story-mode .logo-letter {
    font-size: clamp(40px, 4.2vw, 68px); /* Larger, bolder presence in sidebar */
    /* Boost saturation for dark readable letters */
    filter: saturate(1.4) brightness(0.82);
}

@keyframes letter-shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* Individual color gradients — deeper, richer tones for dark readability */
.letter-K { animation-delay: 0.0s; background-image: linear-gradient(135deg, #1a2d8a, #2B43B6, #3C3FC0); }
.letter-Y { animation-delay: 0.5s; background-image: linear-gradient(135deg, #3230a0, #5a3ec0, #7833B4); }
.letter-T { animation-delay: 1.0s; background-image: linear-gradient(135deg, #6B28A8, #9e3596, #B63E97); }
.letter-R { animation-delay: 1.5s; background-image: linear-gradient(135deg, #9e3080, #C44080, #DD5B7F); }
.letter-I { animation-delay: 2.0s; background-image: linear-gradient(135deg, #C04468, #D9607A, #e8949a); }
.letter-X { animation-delay: 2.5s; background-image: linear-gradient(135deg, #c87882, #d98d92, #ebb3b5); }

#kytrix-tagline-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 4px; /* Reduced vertical gap to integrate with KYTRIX */
    transform: translateZ(10px); /* 3D layer separation */
    transition: opacity 0.8s ease, transform 0.8s ease;
    will-change: opacity, transform;
}

.story-mode #kytrix-tagline-container {
    opacity: 0 !important;
    pointer-events: none;
    transform: translate3d(0, -10px, 10px) !important;
}

#kytrix-tagline {
    font-family: 'Outfit', 'Montserrat', sans-serif;
    font-size: clamp(9px, 1.3vw, 15px); /* Increased size to align bounds */
    font-weight: 700; /* Increased visual weight for luxury presence */
    letter-spacing: 1.8em; /* Expanded tracking to cover 70-90% of logo width */
    text-transform: uppercase;
    color: #4B3EC0;
    opacity: 0; /* Starts hidden to emerge after letters */
    margin-left: 1.8em; /* Compensate for right-side letter-spacing of last letter 'S' */
    
    /* Tagline Entrance animation */
    animation: tagline-emerge 2.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    animation-delay: 1.1s; /* Delayed appearance after logo letter entrance finishes */
}

#kytrix-tagline-sub {
    font-family: 'Outfit', 'Montserrat', sans-serif;
    font-size: clamp(7px, 0.8vw, 10px); /* Smaller, more delicate subtitle */
    font-weight: 500;
    letter-spacing: 0.35em; /* Elegant condensed-but-open tracking */
    text-transform: uppercase;
    color: rgba(75, 62, 192, 0.75); /* Increased opacity stop */
    opacity: 0; /* Starts hidden */
    margin-top: 4px; /* Tightened gap below main tagline */
    margin-left: 0.35em; /* Optical compensation */
    
    /* Secondary entrance animation */
    animation: tagline-sub-emerge 2.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    animation-delay: 2.2s; /* Reveals after primary tagline has unfolded */
}

@keyframes tagline-emerge {
    0% {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    100% {
        opacity: 0.92; /* High visual weight opacity */
        transform: translate3d(0, 0, 0);
    }
}

@keyframes tagline-sub-emerge {
    0% {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    100% {
        opacity: 0.65; /* Elegant contrast opacity */
        transform: translate3d(0, 0, 0);
    }
}

/* ─── EDITORIAL STORY TIMELINE ─── */
#story-container {
    position: fixed;
    top: 18vh;
    left: 22vw; /* Shifted right to balance restored sidebar */
    width: 70vw; /* Balanced screen area for narrative content */
    overflow-y: visible; /* Tabs are absolute, no scrolling needed */
    pointer-events: none;
    opacity: 0;
    z-index: 4; /* Sits below the logo layers, above the WebGL background */
    
    /* 3D Entry Transition */
    transform: translate3d(50px, 0, 0);
    transition: opacity 1.8s cubic-bezier(0.19, 1, 0.22, 1),
                transform 1.8s cubic-bezier(0.19, 1, 0.22, 1);
}

/* Show in Story Mode */
.story-mode #story-container {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
}

.story-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 800px;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, 25px, 0);
    transition: opacity 0.7s cubic-bezier(0.19, 1, 0.22, 1),
                transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

.story-section.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
}

/* ─── KNOWLEDGE PORTAL GATEWAY OVERLAYS ─── */
.gateway-canvas {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    pointer-events: none;
    z-index: -1;
    border-radius: 16px;
    opacity: 0;
    will-change: opacity;
    transition: opacity 1.8s ease;
    
    /* Soft liquid glass masking */
    mask-image: radial-gradient(circle at 50% 60%, black 20%, rgba(0,0,0,0.6) 50%, transparent 95%);
    -webkit-mask-image: radial-gradient(circle at 50% 60%, black 20%, rgba(0,0,0,0.6) 50%, transparent 95%);
}

.story-section.active .gateway-canvas {
    opacity: 1;
}

/* Staggered Gateway Cards reveals for all timeline sections */
.story-section.active.gateway-revealed .kai-hidden-layer {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0px);
    pointer-events: auto;
}

/* Initial state for cards: locked in the atmosphere (blurred/hidden) */
.story-section .kai-layer-card {
    opacity: 0 !important;
    filter: blur(25px) !important;
    transform: translate3d(0, 35px, 0) !important;
    transition: opacity 1.8s cubic-bezier(0.16, 1, 0.3, 1),
                filter 1.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 1.8s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease !important;
}

/* Fade in automatically only after sequence class is added */
.story-section.active.gateway-revealed .kai-layer-card:nth-child(1) {
    opacity: 1 !important;
    filter: blur(0) !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 1.1s !important;
}
.story-section.active.gateway-revealed .kai-layer-card:nth-child(2) {
    opacity: 1 !important;
    filter: blur(0) !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 1.4s !important;
}
.story-section.active.gateway-revealed .kai-layer-card:nth-child(3) {
    opacity: 1 !important;
    filter: blur(0) !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 1.7s !important;
}
.story-section.active.gateway-revealed .kai-layer-card:nth-child(4) {
    opacity: 1 !important;
    filter: blur(0) !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 2.0s !important;
}
.story-section.active.gateway-revealed .kai-layer-card:nth-child(5) {
    opacity: 1 !important;
    filter: blur(0) !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 2.3s !important;
}
.story-section.active.gateway-revealed .kai-layer-card:nth-child(6) {
    opacity: 1 !important;
    filter: blur(0) !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 2.6s !important;
}
.story-section.active.gateway-revealed .kai-layer-card:nth-child(7) {
    opacity: 1 !important;
    filter: blur(0) !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 2.9s !important;
}

.story-meta {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(11px, 1.1vw, 13px);
    font-weight: 700;
    letter-spacing: 0.35em;
    color: #7C32B3;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.story-headline {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(20px, 2.2vw, 32px);
    font-weight: 800;
    letter-spacing: -0.015em;
    margin: 0 0 12px 0;
    line-height: 1.2;
    background: linear-gradient(135deg, #2B43B6, #7C32B3, #B63E97);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
}

.story-paragraph {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(14px, 1.3vw, 19px);
    line-height: 1.7;
    font-style: italic;
    font-weight: 300;
    color: #2B43B6;
    margin: 0 0 24px 0;
}

/* ==========================================================================
   ◈ KAI INTELLIGENCE COMPANION SYSTEMS
   ========================================================================== */

#kai-orb-container {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.7);
    transition: opacity 1.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 1.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Awakes gracefully inside Story Mode — rises from bottom-right corner */
.story-mode #kai-orb-container {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.story-mode #kai-orb-container:hover {
    opacity: 1;
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px rgba(124, 50, 179, 0.4));
}

/* Attaches to cursor in Active Navigator Mode — JS fully controls position via translate3d */
body.kai-navigator-active #kai-orb-container {
    position: fixed;
    top: 0;
    left: 0;
    bottom: auto;
    right: auto;
    margin-top: -38px;
    margin-left: -38px;
    pointer-events: none;
    z-index: 99999;
    opacity: 1;
    /* No transform here — JS spring controls via style.transform = translate3d(...) */
    transition: opacity 0.4s ease;
}

/* HUD concentric indicator rings */
.kai-hud-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px dashed rgba(75, 62, 192, 0.25);
    will-change: transform;
}

.ring-1 {
    width: 58px;
    height: 58px;
    animation: ring-rotate-cw 10s linear infinite;
}

.ring-2 {
    width: 44px;
    height: 44px;
    border-style: dotted;
    border-color: rgba(234, 161, 164, 0.4);
    animation: ring-rotate-ccw 7s linear infinite;
}

.kai-orb {
    font-size: 26px;
    font-weight: 900;
    background: linear-gradient(135deg, #2B43B6, #7C32B3, #EAA1A4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 6px rgba(124, 50, 179, 0.65));
    animation: kai-pulse 2.2s ease-in-out infinite alternate;
    user-select: none;
}

.kai-label {
    position: absolute;
    bottom: -22px;
    font-family: monospace;
    font-size: 8px;
    letter-spacing: 0.18em;
    color: #4B3EC0;
    opacity: 0.8;
    white-space: nowrap;
    text-transform: uppercase;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

body.kai-navigator-active .kai-label {
    opacity: 0;
}

/* Flight HUD Notifications */
#kai-hud-notification {
    position: fixed;
    top: 25px;
    left: 50%;
    transform: translate3d(-50%, -10px, 0);
    font-family: monospace;
    font-size: 10px;
    color: #4B3EC0;
    text-shadow: 0 0 6px rgba(75, 62, 192, 0.4);
    letter-spacing: 0.15em;
    z-index: 99998;
    pointer-events: none;
    background: rgba(251, 252, 254, 0.88);
    padding: 8px 20px;
    border-radius: 30px;
    border: 1px solid rgba(75, 62, 192, 0.16);
    box-shadow: 0 8px 30px rgba(75, 62, 192, 0.06);
    backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
    white-space: nowrap;
    text-transform: uppercase;
}

#kai-hud-notification.active {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
}

/* KAI Query Cockpit Console */
#kai-hud-console {
    position: fixed;
    bottom: 30px;
    right: 30px;
    left: auto;
    width: 360px;
    background: rgba(251, 252, 254, 0.82);
    border: 1px solid rgba(75, 62, 192, 0.22);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(75, 62, 192, 0.12);
    backdrop-filter: blur(25px) saturate(190%);
    z-index: 10000;
    padding: 14px 18px;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, 40px, 0);
    transition: opacity 0.7s cubic-bezier(0.19, 1, 0.22, 1),
                transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

#kai-hud-console.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
}

.console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(75, 62, 192, 0.08);
    padding-bottom: 6px;
}

.console-status-dot {
    width: 6px;
    height: 6px;
    background-color: #32d74b;
    border-radius: 50%;
    box-shadow: 0 0 6px #32d74b;
    animation: status-blink 1.2s infinite alternate;
}

.console-title {
    font-family: monospace;
    font-size: 9px;
    color: #4B3EC0;
    letter-spacing: 0.12em;
    font-weight: 700;
}

#console-close-btn {
    background: none;
    border: none;
    color: rgba(75, 62, 192, 0.45);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

#console-close-btn:hover {
    color: #4B3EC0;
}

#console-output {
    font-family: monospace;
    font-size: 11px;
    line-height: 1.45;
    color: #1e1e1e;
    min-height: 52px;
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.console-input-row {
    display: flex;
    align-items: center;
    background: rgba(75, 62, 192, 0.05);
    border-radius: 6px;
    padding: 7px 12px;
}

.console-prompt {
    font-family: monospace;
    font-size: 11px;
    color: #7C32B3;
    margin-right: 6px;
}

#console-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: monospace;
    font-size: 11px;
    color: #1e1e1e;
    width: 100%;
}

/* Hidden Intelligence Layer Panels (Fogs Open on Hover) */
.kai-hidden-layer {
    position: relative;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(75, 62, 192, 0.08);
    opacity: 0;
    filter: blur(25px);
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 1.2s cubic-bezier(0.19, 1, 0.22, 1),
                filter 1.2s cubic-bezier(0.19, 1, 0.22, 1),
                transform 1.2s cubic-bezier(0.19, 1, 0.22, 1);
}

/* Fogs open only in active navigator mode when hovering active story timeline items */
body.kai-navigator-active .story-section.active:hover .kai-hidden-layer {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0px);
    pointer-events: auto;
}

.kai-scanner-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1.5px;
    background: linear-gradient(90deg, transparent, #7C32B3, #EAA1A4, transparent);
    box-shadow: 0 0 10px rgba(124, 50, 179, 0.7);
    opacity: 0;
    pointer-events: none;
}

body.kai-navigator-active .story-section.active:hover .kai-scanner-bar {
    opacity: 1;
    animation: scanner-sweep 2.4s ease-in-out infinite;
}

.kai-layer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 6px;
}

.kai-layer-card {
    background: rgba(251, 252, 254, 0.45);
    border: 1px solid rgba(75, 62, 192, 0.06);
    border-radius: 8px;
    padding: 12px 14px;
    backdrop-filter: blur(12px);
    transition: border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: border-color, background, box-shadow, transform;
}

.kai-layer-card:hover {
    background: rgba(251, 252, 254, 0.75);
    border-color: rgba(75, 62, 192, 0.24);
    box-shadow: 0 12px 30px rgba(75, 62, 192, 0.05);
    transform: translateY(-2px) scale(1.015);
}

.kai-layer-card .kai-extended-article {
    display: none; /* Hidden until cloned into the expanding viewport */
}

.kai-layer-card .card-summary {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(9px, 0.9vw, 11px);
    line-height: 1.45;
    color: rgba(30, 30, 30, 0.72);
    margin: 0;
}

.kai-card-hud {
    font-family: monospace;
    font-size: 8px;
    color: #7C32B3;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.kai-layer-card h4 {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(11px, 1.1vw, 14px);
    font-weight: 700;
    color: #4B3EC0;
    margin: 0 0 6px 0;
}

.kai-layer-card p {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(9px, 0.9vw, 11px);
    line-height: 1.45;
    color: rgba(30, 30, 30, 0.72);
    margin: 0;
}

/* ==========================================================================
   ◈ ANIMATIONS KEYFRAMES
   ========================================================================== */

@keyframes ring-rotate-cw {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes ring-rotate-ccw {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

@keyframes kai-pulse {
    0% {
        transform: scale(0.92) rotate(0deg);
        filter: drop-shadow(0 0 4px rgba(124, 50, 179, 0.5));
    }
    100% {
        transform: scale(1.12) rotate(8deg);
        filter: drop-shadow(0 0 12px rgba(124, 50, 179, 0.9));
    }
}

@keyframes scanner-sweep {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

@keyframes status-blink {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* ─── KAI REFRACTION FORCE FIELD ─── */
#kai-force-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 170px;
    height: 170px;
    margin-top: -85px; /* Centered under hotspot */
    margin-left: -85px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 99998; /* Under KAI orb, above typography */
    opacity: 0;
    will-change: transform, opacity;
    
    /* Premium atmospheric lens distortion */
    backdrop-filter: blur(14px) saturate(170%) brightness(1.06);
    -webkit-backdrop-filter: blur(14px) saturate(170%) brightness(1.06);
    
    /* Feathered organic mask (radius ~60px - 100px) */
    mask-image: radial-gradient(circle at center, black 0%, rgba(0,0,0,0.85) 22%, rgba(0,0,0,0.3) 52%, transparent 72%);
    -webkit-mask-image: radial-gradient(circle at center, black 0%, rgba(0,0,0,0.85) 22%, rgba(0,0,0,0.3) 52%, transparent 72%);
    
    /* Soft color refraction glow */
    background: radial-gradient(circle at center, rgba(124, 50, 179, 0.04) 0%, rgba(75, 62, 192, 0.02) 40%, transparent 70%);
    
    transition: opacity 0.8s ease;
}

/* ─── KAI IMMERSIVE CARD EXPANDER ─── */
#kai-expanded-viewer {
    background: rgba(251, 252, 254, 0.4);
    border: 1px solid rgba(75, 62, 192, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(25px) saturate(180%) brightness(1.04);
    -webkit-backdrop-filter: blur(25px) saturate(180%) brightness(1.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 70px rgba(75, 62, 192, 0.08);
    will-change: top, left, width, height, opacity;
    
    /* FLIP spring-like transition */
    transition: top 0.75s cubic-bezier(0.16, 1, 0.3, 1),
                left 0.75s cubic-bezier(0.16, 1, 0.3, 1),
                width 0.75s cubic-bezier(0.16, 1, 0.3, 1),
                height 0.75s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.6s ease;
}

.kai-expanded-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    border-radius: 12px;
}

.kai-expanded-content {
    padding: clamp(24px, 4vw, 48px) clamp(24px, 5vw, 54px);
    overflow-y: auto;
    height: 100%;
    color: #1e1e1e;
    display: flex;
    flex-direction: column;
    z-index: 2;
    position: relative;
    box-sizing: border-box;
}

/* Staggered text entrances for premium editorial look */
.kai-expanded-content > * {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

#kai-expanded-viewer.expanded .kai-expanded-content > * {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

/* Stagger timings */
#kai-expanded-viewer.expanded .kai-expanded-content > .kai-expanded-close {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    transition-delay: 0.1s;
}
#kai-expanded-viewer.expanded .kai-expanded-content > .kai-card-hud {
    transition-delay: 0.2s;
}
#kai-expanded-viewer.expanded .kai-expanded-content > h4 {
    transition-delay: 0.3s;
}
#kai-expanded-viewer.expanded .kai-expanded-content > .kai-extended-article {
    transition-delay: 0.4s;
}

.kai-expanded-close {
    position: absolute;
    top: 24px;
    right: 32px;
    background: none;
    border: none;
    font-family: monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    color: #7C32B3;
    cursor: pointer;
    font-weight: 700;
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.kai-expanded-close:hover {
    color: #2B43B6;
    transform: scale(1.05);
}

.kai-expanded-content h4 {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(22px, 2.4vw, 34px) !important;
    font-weight: 900 !important;
    background: linear-gradient(135deg, #2B43B6, #7C32B3, #EAA1A4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 12px 0 20px 0 !important;
    line-height: 1.15 !important;
}

.kai-expanded-content .kai-extended-article {
    display: block !important; /* Forces visibility inside cloned viewer */
    max-width: 720px;
    margin-top: 10px;
}

.kai-extended-article p {
    font-family: 'Outfit', sans-serif !important;
    font-size: clamp(13px, 1.2vw, 16px) !important;
    line-height: 1.75 !important;
    color: rgba(30, 30, 30, 0.85) !important;
    margin: 0 0 20px 0 !important;
    font-style: normal !important;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* ─── KAI INTELLIGENCE CONDUIT CANVAS ─── */
#kai-conduit-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 3; /* Sits between WebGL background (z-index 1) and text overlays (z-index 4) */
    opacity: 0;
    transition: opacity 1.8s ease-in-out;
}

.story-mode #kai-conduit-canvas {
    opacity: 1; /* Only visible when inside story mode pages */
}

/* Destination ripple highlight animations */
.destination-ripple-ring {
    position: fixed;
    border-radius: 50%;
    border: 1.5px solid #7C32B3;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%) scale(0.1);
    opacity: 1;
    animation: ripple-out 1.2s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes ripple-out {
    0% {
        transform: translate(-50%, -50%) scale(0.1);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.0);
        opacity: 0;
        border-color: #DD5B7F;
    }
}

/* ─── PREMIUM CTA ACTION BUTTONS ─── */
.kai-cta-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.kai-cta-btn {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(11px, 1.0vw, 13px);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 10px 22px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.kai-cta-btn.btn-primary {
    background: linear-gradient(135deg, #2B43B6, #7C32B3);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(43, 67, 182, 0.2);
}

.kai-cta-btn.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(43, 67, 182, 0.35);
}

.kai-cta-btn.btn-secondary {
    background: rgba(75, 62, 192, 0.08);
    color: #4B3EC0;
    border: 1px solid rgba(75, 62, 192, 0.15);
}

.kai-cta-btn.btn-secondary:hover {
    background: rgba(75, 62, 192, 0.16);
    transform: translateY(-2px);
}

.kai-cta-btn.btn-outline {
    background: transparent;
    color: rgba(30, 30, 30, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.kai-cta-btn.btn-outline:hover {
    border-color: rgba(0, 0, 0, 0.35);
    color: rgba(30, 30, 30, 1);
    transform: translateY(-2px);
}
