/* === J.A.R.V.I.S Copilot Speaker - Custom Styles === */

/* Fonts */
.font-display {
    font-family: 'Space Grotesk', sans-serif;
}
.font-body {
    font-family: 'Inter', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
}

/* Neural Glow Effects */
.neural-glow {
    box-shadow: 0 0 20px oklch(0.55 0.20 240 / 0.3);
}

.neural-glow-strong {
    box-shadow: 0 0 40px oklch(0.55 0.20 240 / 0.5);
}

.accent-glow {
    box-shadow: 0 0 20px oklch(0.80 0.12 195 / 0.4);
}

/* Grid Pattern */
.grid-pattern {
    background-image: 
        linear-gradient(oklch(0.25 0.04 240 / 0.3) 1px, transparent 1px),
        linear-gradient(90deg, oklch(0.25 0.04 240 / 0.3) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* Radial gradient helper */
.bg-gradient-radial {
    background: radial-gradient(circle at center, var(--tw-gradient-from) 0%, var(--tw-gradient-via) 50%, var(--tw-gradient-to) 100%);
}

/* === CSS Animations (replacing framer-motion) === */

/* Fade in up animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.8s ease-out both;
}

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 1s ease-out both;
}

/* Glow pulse animation */
@keyframes glowPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.5;
    }
}

.glow-pulse {
    animation: glowPulse 8s ease-in-out infinite;
}

/* Scroll-triggered reveal animation using IntersectionObserver-like approach with CSS */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), 
                transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Blazor error boundary */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* === Global Persistent Video Background === */

.global-video-bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    transition: opacity 0.6s ease;
}

.global-video-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.5) 0%,
        rgba(0, 0, 0, 0.6) 40%,
        rgba(0, 0, 0, 0.7) 100%
    );
    pointer-events: none;
    transition: opacity 0.6s ease;
}

/* === Loading Screen === */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a12;
    transition: opacity 0.8s ease;
    overflow: hidden;
}

.loading-screen.loading-hide {
    opacity: 0;
    pointer-events: none;
}

/* Blurred background layer - expanded loading media */
.loading-bg-blur {
    position: absolute;
    inset: -20px;
    width: calc(100% + 40px);
    height: calc(100% + 40px);
    object-fit: cover;
    filter: blur(30px) brightness(0.4) saturate(1.3);
    z-index: 0;
    pointer-events: none;
}

/* Subtle overlay on top of blur for depth */
.loading-bg-blur-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: radial-gradient(
        ellipse at center,
        rgba(10, 10, 18, 0.1) 0%,
        rgba(10, 10, 18, 0.4) 60%,
        rgba(10, 10, 18, 0.65) 100%
    );
    pointer-events: none;
}

.loading-monitor {
    position: relative;
    z-index: 2;
    width: 60vw;
    max-width: 800px;
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 0 60px rgba(100, 140, 255, 0.15),
        0 0 120px rgba(100, 140, 255, 0.05),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(100, 140, 255, 0.15);
}

.loading-monitor-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* === Main Content Visibility === */

.main-content {
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.main-content.content-visible {
    opacity: 1;
    pointer-events: auto;
}

/* === Hero Section (transparent, floating over global video) === */

.hero-section-transparent {
    background: transparent;
}

/* === Rotating Phrases === */

.hero-phrases {
    position: relative;
    height: 2.2em;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.hero-phrase {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.95rem, 2vw, 1.25rem);
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    opacity: 0;
    animation: phraseRotate 40s ease-in-out infinite;
    animation-delay: calc(var(--i) * 4s);
}

@keyframes phraseRotate {
    0%      { opacity: 0; }
    1.5%    { opacity: 1; }
    8.5%    { opacity: 1; }
    10%     { opacity: 0; }
    100%    { opacity: 0; }
}

/* === Horizontal Scroll Snap Layout === */

html.snap-mode,
html.snap-mode body {
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.snap-container {
    display: flex;
    overflow-x: hidden;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    height: 100vh;
    width: 100vw;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    cursor: grab;
    will-change: scroll-position;
}

.snap-container.dragging {
    scroll-snap-type: none;
    scroll-behavior: auto;
    cursor: grabbing;
}

.snap-container.dragging .snap-section {
    transition: transform 0s, opacity 0s;
}

.snap-container.settling {
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
}

.snap-container::-webkit-scrollbar {
    display: none;
}

.snap-section {
    min-width: 100vw;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Dot Navigation */

.snap-nav {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 50;
}

.snap-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid oklch(0.55 0.20 240 / 0.4);
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.snap-dot:hover {
    border-color: oklch(0.55 0.20 240);
    background: oklch(0.55 0.20 240 / 0.3);
}

.snap-dot.active {
    background: oklch(0.55 0.20 240);
    border-color: oklch(0.55 0.20 240);
    box-shadow: 0 0 8px oklch(0.55 0.20 240 / 0.5);
    transform: scale(1.3);
}

/* Mobile: vertical scroll fallback */

@media (max-width: 768px) {
    html.snap-mode,
    html.snap-mode body {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    .snap-container {
        display: block;
        overflow: visible;
        height: auto;
        scroll-snap-type: none;
        width: 100%;
    }

    .snap-section {
        width: 100%;
        min-width: 100%;
        min-height: 100vh;
        height: auto;
    }

    .snap-nav {
        right: 0.75rem;
        gap: 0.5rem;
    }

    .snap-dot {
        width: 8px;
        height: 8px;
    }
}

@media (max-width: 480px) {
    .snap-nav {
        display: none;
    }
}

/* === Quest Log Styles === */

.quest-card {
    transition: border-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.quest-card:hover {
    transform: translateY(-2px);
}

.quest-completed:hover {
    border-color: oklch(0.80 0.12 195 / 0.6);
    box-shadow: 0 0 20px oklch(0.80 0.12 195 / 0.1);
}

.quest-in-progress:hover {
    border-color: oklch(0.55 0.20 240 / 0.6);
    box-shadow: 0 0 20px oklch(0.55 0.20 240 / 0.15);
}

@keyframes questPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 oklch(0.55 0.20 240 / 0.2);
    }
    50% {
        box-shadow: 0 0 12px 4px oklch(0.55 0.20 240 / 0.1);
    }
}

.quest-pulse {
    animation: questPulse 3s ease-in-out infinite;
}

.quest-progress-fill {
    background: linear-gradient(90deg, oklch(0.55 0.20 240) 0%, oklch(0.65 0.18 220) 100%);
    position: relative;
}

.quest-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(90deg, transparent, oklch(0.75 0.15 210 / 0.5));
    border-radius: 0 9999px 9999px 0;
}

/* === Narrative Video Layers (fixed, cross-faded during state transition) === */

.narrative-video-layer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.narrative-video-layer.segment-active {
    opacity: 1;
}

/* Global overlay hidden during narrative */
.global-video-overlay.overlay-hidden {
    opacity: 0;
}

/* === Page 2 content fade for narrative transition === */

.what-is-content {
    transition: opacity 0.5s ease;
}

.what-is-content.content-faded-out {
    opacity: 0;
    pointer-events: none;
}

/* Nav dots hidden during narrative */
.snap-nav.snap-nav-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* === Narrative Overlay (Voltar button) === */

.narrative-overlay {
    position: fixed;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    gap: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.narrative-overlay.narrative-overlay-visible {
    opacity: 1;
    pointer-events: auto;
}

/* === Video Narrative Section === */

.video-narrative-section {
    background: transparent;
    overflow: hidden;
}

.video-narrative-controls {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: none;
}

.video-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.video-nav-back {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
}

.video-nav-back:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}