/* CSS Variables */
:root {
    --primary-color: #d4af37;
    --secondary-color: #8b4513;
    --accent-color: #ff6b35;
    --dark-color: #1a1a1a;
    --darker-color: #0f0f0f;
    --light-color: #f5f5f5;
    --text-color: #e8e8e8;
    --text-muted: #a0a0a0;
    --bg-gradient: linear-gradient(135deg, #0f0f0f 0%, #2a1810 50%, #1a1a1a 100%);
      /* Vietnamese Historical Typography */
    --font-primary: 'Playfair Display', 'Noto Serif', 'Be Vietnam Pro', serif;
    --font-secondary: 'Crimson Text', 'Lora', 'Be Vietnam Pro', serif;
    --font-body: 'Lora', 'Be Vietnam Pro', 'Inter', sans-serif;
    --font-ui: 'Inter', 'Be Vietnam Pro', sans-serif;
    --font-display: 'Playfair Display', serif;
    
    /* Spacing */
    --section-padding: 120px 0;
    --container-max-width: 1200px;
    
    /* Transitions */
    --transition-fast: 0.3s ease;
    --transition-smooth: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--text-color);
    line-height: 1.7;
    overflow-x: hidden;
    letter-spacing: 0.3px;
}

/* Container */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(2rem, 4vw, 3rem); }
h3 { font-size: clamp(1.5rem, 3vw, 2rem); }
h4 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }

p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 32px;
    border: none;
    border-radius: 50px;
    font-family: var(--font-secondary);
    font-weight: 500;
    font-size: 1rem;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
    z-index: -1;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    color: var(--dark-color);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: var(--dark-color);
    transform: translateY(-2px);
}

.btn-large {
    padding: 16px 48px;
    font-size: 1.125rem;
}

/* Navigation */
.nav-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, 
        rgba(26, 26, 26, 0.98) 0%,
        rgba(42, 24, 16, 0.96) 30%,
        rgba(15, 15, 15, 0.98) 100%);
    backdrop-filter: blur(15px) saturate(1.2);
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                0 2px 8px rgba(212, 175, 55, 0.1);
    z-index: 1000;
    transition: all var(--transition-smooth);
}

.nav-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%,
        var(--primary-color) 25%,
        var(--accent-color) 50%,
        var(--primary-color) 75%,
        transparent 100%);
    animation: navGlow 3s ease-in-out infinite alternate;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2rem;
    max-width: var(--container-max-width);
    margin: 0 auto;
    position: relative;
}

/* Logo Enhanced */
.logo {
    position: relative;
    z-index: 2;
}

.logo h2 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.8rem;
    font-family: var(--font-display);
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
}

/* Navigation Menu Enhanced */
.nav-menu {
    display: flex;
    gap: 2.5rem;
    align-items: center;
    position: relative;
}

.nav-menu::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -20px;
    width: 1px;
    height: 30px;
    background: linear-gradient(to bottom, 
        transparent, 
        var(--primary-color), 
        transparent);
    transform: translateY(-50%);
    opacity: 0.5;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    font-family: var(--font-secondary);
    font-size: 1rem;
    transition: all var(--transition-smooth);
    position: relative;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    overflow: hidden;
    z-index: 1;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(212, 175, 55, 0.1) 0%,
        rgba(255, 107, 53, 0.1) 100%);
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-smooth);
    z-index: -1;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        var(--primary-color), 
        var(--accent-color));
    transition: all var(--transition-smooth);
    transform: translateX(-50%);
    border-radius: 1px;
}

.nav-link:hover::before {
    opacity: 1;
    transform: scale(1);
}

.nav-link:hover::after {
    width: 80%;
}

.nav-link:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
    text-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.nav-link.active {
    color: var(--primary-color);
    background: rgba(212, 175, 55, 0.1);
    box-shadow: inset 0 2px 8px rgba(212, 175, 55, 0.2);
}

.nav-link.active::after {
    width: 80%;
}

/* Mobile Toggle Enhanced */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.2);
    transition: all var(--transition-fast);
}

.nav-toggle:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.nav-toggle span {
    width: 28px;
    height: 3px;
    background: linear-gradient(90deg, 
        var(--primary-color), 
        var(--accent-color));
    border-radius: 2px;
    transition: all var(--transition-fast);
    transform-origin: center;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Scroll Effect */
.nav-container.scrolled {
    background: linear-gradient(135deg, 
        rgba(15, 15, 15, 0.98) 0%,
        rgba(26, 26, 26, 0.96) 50%,
        rgba(15, 15, 15, 0.98) 100%);
    backdrop-filter: blur(20px) saturate(1.5);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4),
                0 4px 12px rgba(212, 175, 55, 0.15);
}

.nav-container.scrolled .nav-content {
    padding: 0.8rem 2rem;
}

.nav-container.scrolled .logo h2 {
    font-size: 1.6rem;
}

/* Section Headers */
.section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.section-title {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

.fade-in { animation: fadeInUp 0.8s ease forwards; }
.fade-in-left { animation: fadeInLeft 0.8s ease forwards; }
.fade-in-right { animation: fadeInRight 0.8s ease forwards; }

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, 
            rgba(15, 15, 15, 0.98) 0%,
            rgba(26, 26, 26, 0.96) 50%,
            rgba(15, 15, 15, 0.98) 100%);
        backdrop-filter: blur(20px) saturate(1.5);
        flex-direction: column;
        gap: 0;
        padding: 2rem 0;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-smooth);
        border-top: 1px solid rgba(212, 175, 55, 0.2);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }

    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-menu::before {
        display: none;
    }

    .nav-link {
        padding: 1rem 2rem;
        border-radius: 0;
        border-bottom: 1px solid rgba(212, 175, 55, 0.1);
        font-size: 1.1rem;
        text-align: center;
        transition: all var(--transition-fast);
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .nav-link::before {
        display: none;
    }

    .nav-link::after {
        bottom: 0;
        left: 0;
        width: 0;
        height: 100%;
        background: linear-gradient(90deg, 
            rgba(212, 175, 55, 0.1) 0%,
            rgba(255, 107, 53, 0.1) 100%);
        transform: none;
    }

    .nav-link:hover::after,
    .nav-link.active::after {
        width: 100%;
    }

    .nav-toggle {
        display: flex;
    }

    .logo h2 {
        font-size: 1.6rem;
    }

    .logo h2::before,
    .logo h2::after {
        display: none;
    }

    .nav-content {
        padding: 1rem 1.5rem;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .btn {
        padding: 10px 24px;
        font-size: 0.9rem;
    }
    
    .btn-large {
        padding: 14px 36px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    :root {
        --section-padding: 80px 0;
    }
    
    .nav-content {
        padding: 0.75rem 1rem;
    }
    
    .logo h2 {
        font-size: 1.25rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dark-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* ENHANCED: Performance optimizations for low-end devices */
.performance-mode * {
    animation-duration: 0.1s !important;
    transition-duration: 0.1s !important;
}

.performance-mode .particle-system,
.performance-mode .loading-particles,
.performance-mode .three-canvas {
    display: none !important;
}

.performance-mode .image-container img {
    transform: none !important;
    filter: none !important;
}

/* CRITICAL FIX: Scroll Performance Optimizations */
.parallax-img {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
    transform-style: preserve-3d;
    
    /* CRITICAL: Prevent layout thrashing during scroll */
    contain: layout style;
    
    /* IMPROVED: GPU acceleration for smoother scrolling */
    transform: translateZ(0);
}

.story-image {
    /* FIXED: Prevent scroll jitter with containment */
    contain: layout style paint;
    
    /* ENHANCED: Smooth scrolling optimization */
    overflow: hidden;
    will-change: transform;
}

/* OPTIMIZED: Reduce scroll jitter with better transitions */
.parallax-img {
    transition: transform 0.1s linear, filter 0.2s ease-out !important;
}

.story-image.in-viewport .parallax-img {
    /* ENHANCED: Smoother animation when in viewport */
    transition: transform 0.05s linear, filter 0.1s ease-out !important;
}

/* CRITICAL FIX: Prevent competing animations */
.story-image[data-gsap-controlled="true"] .parallax-img {
    /* Let GSAP handle the animation completely */
    transition: none !important;
    will-change: auto !important;
}

/* IMPROVED: Scroll snap for better user experience */
.scroll-container {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ENHANCED: Reduce motion for better performance */
@media (prefers-reduced-motion: reduce) {
    .parallax-img {
        transform: none !important;
        transition: none !important;
        will-change: auto !important;
    }
    
    .story-image {
        contain: none !important;
    }
}
