/* style.css*/

/**
 * Cosmic Focus - Main Stylesheet
 * A 3D productivity universe with pomodoro timer and ambient features
 */

/* Global Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    max-width: 100vw;
    max-height: 100vh;
}

:root {
    --animation-speed: 1;
    --particle-density: 1;
    --performance-level: 1; /* 1 = high, 0.75 = medium, 0.5 = low */
    
    /* Liquid Glass Scrollbar Variables */
    --scrollbar-bg: rgba(176, 224, 230, 0.12);
    --scrollbar-border: rgba(255, 255, 255, 0.2);
    --scrollbar-shadow: rgba(176, 224, 230, 0.15);
    --scrollbar-hover-bg: rgba(176, 224, 230, 0.2);
    --scrollbar-hover-border: rgba(255, 255, 255, 0.35);
    --scrollbar-hover-glow: rgba(176, 224, 230, 0.4);
}

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    width: 100%;
    max-width: 100vw;
    max-height: 100vh;
    position: relative;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    transition: all 0.3s ease;
    position: relative;
    font-display: swap; /* Prevent layout shift from font loading */
}

/* 3D Scene Container - FIXED for Babylon.js */
#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background: #000; /* Fallback background */
    transition: opacity 0.3s ease, filter 0.3s ease; /* Add smooth transitions */
}

#scene-container canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
    pointer-events: auto !important; /* Canvas needs pointer events for Babylon.js */
}

/* Main Content Container */
.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 70px 20px 20px;
    position: relative;
    z-index: 10;
    width: 100%;
    overflow: hidden;
    contain: layout style paint;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.container::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.container.loaded {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* Enable pointer events only for interactive elements */
.container > *, 
.nav-buttons, 
.progress-3d, 
.btn, 
button, 
input, 
textarea, 
select, 
a {
    pointer-events: auto !important;
}/* Mode Display System — smooth transitions */
.mode {
    position: absolute;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.45s ease, transform 0.45s ease;
    pointer-events: none;
    text-align: center;
    max-width: 600px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    max-height: none; /* Remove height restriction */
    overflow: visible;
    animation: none; /* Disable animation on initial load */
    position: relative;
    z-index: 15;
    pointer-events: auto; /* Mode content needs pointer events */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.mode::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Ensure task list doesn't cause overflow */
.task-section {
    max-height: none; /* Remove height restriction */
    overflow: visible; /* No scrollbar on section */
}

.task-list {
    max-height: 140px;
    overflow-y: auto;
    overflow-x: hidden;
    
    /* Apple-style minimal scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(200, 146, 42, 0.15) transparent;
}

/* Apple-style scrollbar for webkit browsers - minimal glass */
.task-list::-webkit-scrollbar {
    width: 12px;
    background: transparent;
    display: block;
}

.task-list::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0; /* Add margin to not touch edges */
}

.task-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08) !important; /* More visible glass */
    backdrop-filter: blur(10px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(10px) saturate(180%) !important;
    border-radius: 6px !important; /* Rounder for glass effect */
    border: 0.5px solid rgba(255, 255, 255, 0.15) !important; /* More visible border */
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.2s ease !important;
}

.task-list::-webkit-scrollbar-thumb:hover {
    background: rgba(176, 224, 230, 0.12) !important;
    backdrop-filter: blur(12px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(200%) !important;
    border-color: rgba(176, 224, 230, 0.3) !important;
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 4px 12px rgba(176, 224, 230, 0.15),
        0 0 16px rgba(176, 224, 230, 0.2) !important;
}

.mode.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Override transform for positioned home mode */
#home.active {
    transform: translateX(-50%);
}
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Loading Screen — cosmic gradient */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: radial-gradient(ellipse at center, rgba(25, 8, 50, 1) 0%, rgba(5, 5, 15, 1) 70%) !important;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

.loading-screen.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.loading-text {
    font-size: 1.5em;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #8B5CF6 0%, #06D6A0 50%, #60A5FA 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 300;
    letter-spacing: 2px;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}


/* Productivity glow effect */
.productivity-glow {
    animation: productivityPulse 2s ease-in-out infinite;
}

@keyframes productivityPulse {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3),
                    0 0 40px rgba(99, 102, 241, 0.1);
    }
    50% { 
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.5),
                    0 0 60px rgba(99, 102, 241, 0.2);
    }
}





/* Performance optimization for reduced motion users */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .productivity-glow {
        animation: none;
    }
}

/* Layout Stability Fixes */
.task-section {
    position: relative !important;
    z-index: 100 !important;
    isolation: isolate !important;
    background: var(--bg-glass) !important;
    pointer-events: auto !important;
}

#addTaskBtn {
    position: relative !important;
    z-index: 101 !important;
    isolation: isolate !important;
    pointer-events: auto !important;
}

/* All interactive elements need pointer events */
.focus-content,
.home-content,
.ambient-content,
.task-section,
.task-input-group,
.task-list,
.timer-controls,
.ambient-controls {
    pointer-events: auto !important;
}

/* Prevent horizontal overflow */
*[position="fixed"], 
.nav-buttons,
.progress-3d {
    contain: layout style paint;
    will-change: auto;
}

*[style*="transform"] {
    contain: layout;
}

/* Force hardware acceleration */
/* Nav buttons - hardware acceleration handled in positioning rule below */
.nav-buttons {
    backface-visibility: hidden;
}

/* Ensure UI elements are above the 3D scene */
.nav-buttons {
    z-index: 1000 !important;
}

.progress-3d {
    z-index: 1000 !important;
}

/* Z-Index Hierarchy (add this comment block for reference) */
/* 
 * 1: #scene-container canvas
 * 10: .container
 * 15: .mode
 * 20-30: Content sections (.home-content, .focus-content, .task-section)
 * 100-101: Task components
 * 1000: Navigation (.nav-buttons, .progress-3d)
 * 9999: .loading-screen
 */


/* Make all glass backgrounds extremely transparent */
/* Background colors now controlled in components.css */
.ambient-content,
.task-section {
    background-color: transparent !important;
}

/* iOS Safari and Mobile Viewport Fixes */
@supports (-webkit-touch-callout: none) {
    html, body {
        height: -webkit-fill-available;
    }
    
    .container {
        height: -webkit-fill-available;
    }
}

/* Prevent pull-to-refresh and overscroll */
html {
    overscroll-behavior: none;
}

body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Disable iOS zoom and selection */
input, textarea, select {
    font-size: 16px; /* Prevents iOS zoom */
}

/* Prevent text selection on UI elements */
.nav-buttons, .timer-display, .progress-3d {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}


/* Enhanced theme-specific glow effects */
body[data-theme="dark"] .productivity-glow {
    animation: productivityPulseDark 2s ease-in-out infinite;
}

body[data-theme="cosmos"] .productivity-glow {
    animation: productivityPulseCosmos 2s ease-in-out infinite;
}

@keyframes productivityPulseDark {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3),
                    0 0 40px rgba(99, 102, 241, 0.1);
    }
    50% { 
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.5),
                    0 0 60px rgba(99, 102, 241, 0.2);
    }
}

@keyframes productivityPulseCosmos {
    0%, 100% { 
        box-shadow: 0 0 25px rgba(168, 85, 247, 0.4),
                    0 0 50px rgba(139, 92, 246, 0.2);
    }
    50% { 
        box-shadow: 0 0 40px rgba(168, 85, 247, 0.6),
                    0 0 80px rgba(139, 92, 246, 0.3);
    }
}

/* ===== ENHANCED SCROLLBAR ANIMATIONS ===== */

/* Container hover state - makes scrollbar slightly more visible */
.task-list:hover::-webkit-scrollbar-thumb {
    background: rgba(176, 224, 230, 0.08); /* Glass with slight teal tint */
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}

/* Cosmic corner styling for scrollbar track area */
.task-list::-webkit-scrollbar-corner {
    background: transparent;
}

/* Additional spacing for better floating effect */
.task-section {
    padding-right: 4px; /* Add slight padding to separate scrollbar from content */
}

/* Remove default page scrollbar entirely */
html,
body {
    scrollbar-width: none;
    -ms-overflow-style: none; /* IE/Edge */
}

body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Enhanced scrollbar for mode containers - also minimal */
.mode::-webkit-scrollbar {
    width: 12px;
    background: transparent;
}

.mode::-webkit-scrollbar-track {
    background: transparent;
}

.mode::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border-radius: 6px;
    border: 0.5px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.mode::-webkit-scrollbar-thumb:hover {
    background: rgba(176, 224, 230, 0.18);
    border-color: rgba(176, 224, 230, 0.35);
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 4px 12px rgba(176, 224, 230, 0.2),
        0 0 20px rgba(176, 224, 230, 0.25);
}

/* ===== MOZILLA FIREFOX SCROLLBAR ENHANCEMENT ===== */
/* Enhanced Firefox scrollbar theming */
.task-list, .settings-modal, .mode {
    scrollbar-width: thin;
    scrollbar-color: rgba(176, 224, 230, 0.4) transparent;
}

/* Support for upcoming CSS scrollbar styling */
@supports (scrollbar-color: rgba(176, 224, 230, 0.4) transparent) {
    .task-list, .settings-modal, .mode {
        scrollbar-width: auto;
        scrollbar-color: rgba(176, 224, 230, 0.4) transparent;
    }
}

/* ===== SCROLLBAR FADE ANIMATION ===== */
/* Create fade-in effect when scrolling */
@keyframes scrollbar-appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Ensure scrollbar doesn't interfere with content layout */
.task-list,
.settings-modal,
.mode {
    /* Preserve space for scrollbar */
    scrollbar-gutter: stable;
}
/* Navigation buttons wrapper - iOS clear glass container */
.nav-buttons {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) translateZ(0);
    display: inline-flex; /* Changed from flex to inline-flex for proper centering */
    gap: 0;
    z-index: 1000;
    width: auto; /* Let content determine width */
}
