/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

:root {
    --color-text: #2c2c2c;
    --color-text-light: #666;
    --color-text-lighter: #999;
    --color-bg: #fafafa;
    --color-white: #ffffff;
    --color-divider: #e0e0e0;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --spacing-xl: 6rem;
    --spacing-xxl: 8rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 3rem;
    --line-height-tight: 1.4;
    --line-height-normal: 1.6;
    --line-height-relaxed: 1.8;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: var(--line-height-normal);
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: 60px; /* Space for fixed navbar - mobile first */
    overflow-x: hidden; /* Prevent horizontal scroll */
    width: 100%;
    max-width: 100vw;
    position: relative;
}


/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy Loading Images */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img.lazy-loaded {
    opacity: 1;
}

/* Placeholder for lazy images */
img[data-src]:not(.lazy-loaded) {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    body {
        padding-top: 0;
    }
    
    .navbar,
    .nav-toggle,
    .lang-switcher,
    .zen-pause-btn,
    .zen-pause-overlay,
    .connect-section {
        display: none;
    }
    
    .section {
        page-break-inside: avoid;
    }
}

/* Mobile-first: Base styles are for mobile */
/* Responsive Base Variables - Mobile (default) */
:root {
    --font-size-4xl: 2rem;
    --font-size-3xl: 1.75rem;
    --font-size-2xl: 1.25rem;
    --spacing-xl: 3rem;
    --spacing-xxl: 4rem;
}

body {
    padding-top: 60px;
}

/* Desktop enhancements */
@media (min-width: 769px) {
    :root {
        --font-size-4xl: 3rem;
        --font-size-3xl: 2rem;
        --font-size-2xl: 1.5rem;
        --spacing-xl: 6rem;
        --spacing-xxl: 8rem;
    }

    body {
        padding-top: 70px;
    }
}

/* Prevent text overflow on mobile */
* {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure touch targets are adequate */
a, button, input, textarea, select {
    touch-action: manipulation; /* Improve touch responsiveness */
}

/* Scroll Animations - Progressive Enhancement */
/* Default: Content is visible (no JS fallback) */
.scroll-animate {
    opacity: 1;
    transform: translateY(0);
}

/* Only apply animation when JS is loaded */
body.js-loaded .scroll-animate {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body.js-loaded .scroll-animate.scroll-animate-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile: Simpler/faster animations or no animation */
@media (max-width: 768px) {
    body.js-loaded .scroll-animate {
        opacity: 0.3;
        transform: translateY(10px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    body.js-loaded .scroll-animate {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* Silent Feedback - Subtle reminder after inactivity */
.silent-feedback {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.875rem;
    color: var(--color-text);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    user-select: none;
    z-index: 9999;
    transition: opacity 2s ease-in-out, visibility 2s ease-in-out;
    letter-spacing: 0.02em;
    font-weight: 300;
    text-align: center;
    white-space: nowrap;
}

.silent-feedback.visible {
    opacity: 0.5;
    visibility: visible;
}

/* Responsive adjustments */
@media (min-width: 769px) {
    .silent-feedback {
        font-size: 1rem;
        bottom: 3rem;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .silent-feedback {
        transition-duration: 0.01ms !important;
    }
}

/* Don't show in print */
@media print {
    .silent-feedback {
        display: none;
    }
}
