/* ================================================
   ORIENTAL LEGACY - FULL OPTIMIZATION STYLES
   Mobile, Animations, Dark Mode, Performance
   ================================================ */

/* ================================================
   PERFORMANCE OPTIMIZATIONS
   ================================================ */

/* Hardware acceleration */
.accelerate {
    transform: translateZ(0);
    will-change: transform;
}

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

/* Lazy load placeholder */
.lazy-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ================================================
   MOBILE RESPONSIVE ENHANCEMENTS
   ================================================ */

/* Base mobile viewport */
@media (max-width: 1024px) {
    html { font-size: 15px; }
}

@media (max-width: 768px) {
    html { font-size: 14px; }
}

@media (max-width: 480px) {
    html { font-size: 13px; }
}

/* Mobile header - hamburger menu */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 1001;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: #1a1a1a;
    margin: 3px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 1024px) {
    .mobile-menu-btn { display: flex; }
    
    .site-header nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: #fff;
        flex-direction: column;
        padding: 100px 2rem 2rem;
        box-shadow: 4px 0 40px rgba(0,0,0,0.1);
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
    }
    
    .site-header nav.open {
        left: 0;
    }
    
    .site-header nav a {
        width: 100%;
        padding: 1rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        font-size: 1.1rem;
    }
}

/* Mobile hero section */
@media (max-width: 768px) {
    .home-hero-section {
        min-height: 70vh;
        padding: 4rem 1rem;
    }
    
    .home-hero-section h1 {
        font-size: 2.5rem !important;
        line-height: 1.3;
    }
    
    .home-hero-section p {
        font-size: 1.1rem;
    }
}

/* Mobile grid adjustments */
@media (max-width: 768px) {
    #heritage-grid,
    #articles-list,
    #regions-container {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    #heritage-grid,
    #articles-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Mobile touch targets */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}

/* Mobile scrollbars */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
}

/* ================================================
   ENHANCED INTERACTIVE ANIMATIONS
   ================================================ */

/* Card hover effects 2.0 */
.card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 
        0 20px 40px -12px rgba(0,0,0,0.15),
        0 0 0 1px rgba(192, 72, 81, 0.1);
}

.card-image-container {
    overflow: hidden;
    position: relative;
}

.card-image-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.2) 50%, transparent 60%);
    background-size: 300% 300%;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.card:hover .card-image-container::after {
    opacity: 1;
    animation: cardShine 1.2s ease;
}

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

/* Button ripple effect */
.ripple-btn {
    position: relative;
    overflow: hidden;
}

.ripple-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.ripple-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Reveal on scroll */
.reveal-element {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reveal-element.delay-100 { transition-delay: 0.1s; }
.reveal-element.delay-200 { transition-delay: 0.2s; }
.reveal-element.delay-300 { transition-delay: 0.3s; }
.reveal-element.delay-400 { transition-delay: 0.4s; }

/* Stagger children animation */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-children.visible > *:nth-child(1) { animation: fadeInUp 0.6s ease 0.1s forwards; }
.stagger-children.visible > *:nth-child(2) { animation: fadeInUp 0.6s ease 0.2s forwards; }
.stagger-children.visible > *:nth-child(3) { animation: fadeInUp 0.6s ease 0.3s forwards; }
.stagger-children.visible > *:nth-child(4) { animation: fadeInUp 0.6s ease 0.4s forwards; }
.stagger-children.visible > *:nth-child(5) { animation: fadeInUp 0.6s ease 0.5s forwards; }
.stagger-children.visible > *:nth-child(6) { animation: fadeInUp 0.6s ease 0.6s forwards; }

/* Magnetic button effect */
.magnetic-btn {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Smooth page transitions */
.page-transition {
    animation: pageIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ================================================
   DARK MODE ENHANCEMENTS & FIXES
   ================================================ */

/* Comprehensive dark mode reset */
body.dark-mode {
    --bg-primary: #0a0d12;
    --bg-secondary: #0f1419;
    --bg-tertiary: #151b22;
    --text-primary: #f8f4ee;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: rgba(255,255,255,0.1);
    --accent-red: #ff7a85;
    --accent-green: #6ee7b7;
    --accent-gold: #ffd766;
}

/* Force dark mode overrides with high specificity */
body.dark-mode,
body.dark-mode * {
    color-scheme: dark;
}

/* Header dark mode */
body.dark-mode .site-header {
    background: rgba(15, 20, 25, 0.95) !important;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
}

body.dark-mode .site-header nav a {
    color: #d1d5db !important;
}

body.dark-mode .site-header nav a:hover,
body.dark-mode .site-header nav a.text-vermilion {
    color: #ff7a85 !important;
}

/* Cards dark mode */
body.dark-mode .card {
    background: rgba(255,255,255,0.03) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3) !important;
}

body.dark-mode .card:hover {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,122,133,0.3) !important;
}

/* Buttons dark mode */
body.dark-mode .btn-secondary {
    border-color: rgba(255,255,255,0.2) !important;
    color: #f8f4ee !important;
}

body.dark-mode .btn-secondary:hover {
    background: rgba(255,255,255,0.08) !important;
}

/* Background sections dark mode */
body.dark-mode .bg-white,
body.dark-mode .bg-white\/50,
body.dark-mode .bg-white\/70,
body.dark-mode .bg-white\/80 {
    background: rgba(255,255,255,0.03) !important;
}

/* Text colors dark mode */
body.dark-mode .text-gray-400,
body.dark-mode .text-gray-500,
body.dark-mode .text-gray-600 {
    color: #d1d5db !important;
}

body.dark-mode .text-gray-700,
body.dark-mode .text-gray-800,
body.dark-mode .text-ink-black {
    color: #f8f4ee !important;
}

body.dark-mode .text-stone-gray {
    color: rgba(209,213,219,0.9) !important;
}

/* Inputs dark mode */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #f8f4ee !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: rgba(209,213,219,0.6) !important;
}

/* Dropdown dark mode */
body.dark-mode #user-menu-panel,
body.dark-mode .dropdown-menu {
    background: rgba(15,20,25,0.98) !important;
    border-color: rgba(255,255,255,0.1) !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4) !important;
}

body.dark-mode #user-menu-panel a,
body.dark-mode .dropdown-menu a,
body.dark-mode .dropdown-menu button {
    color: #d1d5db !important;
}

body.dark-mode #user-menu-panel a:hover,
body.dark-mode .dropdown-menu a:hover,
body.dark-mode .dropdown-menu button:hover {
    background: rgba(255,255,255,0.06) !important;
    color: #f8f4ee !important;
}

/* Language switcher dark mode */
body.dark-mode .lang-switcher {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.1) !important;
}

body.dark-mode .lang-switcher button {
    color: #d1d5db !important;
}

body.dark-mode .lang-switcher button:hover {
    color: #ff7a85 !important;
    background: rgba(192,72,81,0.15) !important;
}

body.dark-mode .lang-switcher button.active {
    background: #c04851 !important;
    color: white !important;
}

/* Theme toggle dark mode */
body.dark-mode #theme-toggle {
    background: rgba(255,255,255,0.08) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #fbbf24 !important;
}

body.dark-mode #theme-toggle:hover {
    background: rgba(255,255,255,0.12) !important;
}

/* Hero section dark mode */
body.dark-mode .home-hero-section {
    background: linear-gradient(180deg, #0a0d12 0%, #0f1419 100%) !important;
}

body.dark-mode .home-section-featured-backdrop {
    background: 
        radial-gradient(circle at top right, rgba(69,183,135,0.15), transparent 35%),
        radial-gradient(circle at bottom left, rgba(192,72,81,0.15), transparent 35%),
        linear-gradient(135deg, #0f1419 0%, #0a0d12 100%) !important;
}

/* Section backgrounds dark mode */
body.dark-mode .home-section-soft {
    background: rgba(255,255,255,0.02) !important;
}

/* Borders dark mode */
body.dark-mode [class*="border-"] {
    border-color: rgba(255,255,255,0.08) !important;
}

/* Shadows dark mode */
body.dark-mode .shadow-sm {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

body.dark-mode .shadow-lg {
    box-shadow: 0 10px 40px rgba(0,0,0,0.4) !important;
}

body.dark-mode .shadow-xl {
    box-shadow: 0 20px 60px rgba(0,0,0,0.5) !important;
}

/* Links dark mode */
body.dark-mode a:not(.btn-primary):not(.btn-secondary) {
    color: #ff7a85 !important;
}

body.dark-mode a:not(.btn-primary):not(.btn-secondary):hover {
    color: #ff949d !important;
}

/* Specific selected elements fix - FORCED */
html body.dark-mode div.bg-white,
html body.dark-mode div.flex.bg-white,
html body.dark-mode div[class*="bg-white"] {
    background-color: rgba(15, 20, 25, 0.85) !important;
    background: rgba(15, 20, 25, 0.85) !important;
    border-color: rgba(255,255,255,0.12) !important;
}

/* Video description card fix */
html body.dark-mode div.bg-white.p-8.rounded-xl {
    background-color: rgba(15, 20, 25, 0.9) !important;
    background: rgba(15, 20, 25, 0.9) !important;
}

/* Comment section card fix */
html body.dark-mode .comment-input {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #f8f4ee !important;
}

html body.dark-mode .comment-input::placeholder {
    color: rgba(209,213,219,0.5) !important;
}

/* Text colors inside white cards */
html body.dark-mode div.bg-white h3,
html body.dark-mode div.bg-white h4,
html body.dark-mode div[class*="bg-white"] h3,
html body.dark-mode div[class*="bg-white"] h4 {
    color: #f8f4ee !important;
}

html body.dark-mode div.bg-white .text-gray-600,
html body.dark-mode div[class*="bg-white"] .text-gray-600 {
    color: #d1d5db !important;
}

/* Sort buttons container dark mode */
body.dark-mode [data-sort] {
    background: rgba(255,255,255,0.05) !important;
    color: #d1d5db !important;
}

body.dark-mode [data-sort].bg-gold {
    background: #d4b106 !important;
    color: white !important;
}

/* Category filter dark mode */
body.dark-mode #category-filter {
    color: #d1d5db !important;
}

body.dark-mode #category-filter option {
    background: #0f1419 !important;
    color: #f8f4ee !important;
}

/* Product/card inner content dark mode */
body.dark-mode div.p-6 h3,
body.dark-mode div.p-6 h4 {
    color: #f8f4ee !important;
}

/* SVG icons dark mode */
body.dark-mode svg,
body.dark-mode [data-lucide] {
    color: inherit !important;
}

/* ================================================
   SPECIFIC PAGE COMPONENTS DARK MODE
   ================================================ */

/* Search sidebar card (article search) */
html body.dark-mode aside div.bg-white.p-6.rounded-2xl,
html body.dark-mode div.bg-white.p-6.rounded-2xl {
    background-color: rgba(15, 20, 25, 0.85) !important;
    background: rgba(15, 20, 25, 0.85) !important;
    border-color: rgba(255,255,255,0.1) !important;
}

/* Level filter container */
html body.dark-mode div.bg-white.border.border-ink-black\/5,
html body.dark-mode div.flex.bg-white.border.border-ink-black\/5 {
    background-color: rgba(15, 20, 25, 0.85) !important;
    background: rgba(15, 20, 25, 0.85) !important;
    border-color: rgba(255,255,255,0.1) !important;
}

/* Level filter select dropdown */
html body.dark-mode #level-filter {
    color: #d1d5db !important;
}

html body.dark-mode #level-filter option {
    background: #0f1419 !important;
    color: #f8f4ee !important;
}

/* Pagination buttons */
html body.dark-mode .pagination-btn,
html body.dark-mode [class*="pagination"] button,
html body.dark-mode [class*="page"] button {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.15) !important;
    color: #d1d5db !important;
}

html body.dark-mode .pagination-btn:hover,
html body.dark-mode [class*="pagination"] button:hover,
html body.dark-mode [class*="page"] button:hover {
    background: rgba(255,255,255,0.1) !important;
}

html body.dark-mode .pagination-btn.active,
html body.dark-mode [class*="pagination"] button.active,
html body.dark-mode [class*="page"] button.active {
    background: #c04851 !important;
    border-color: #c04851 !important;
    color: white !important;
}

/* Article search input */
html body.dark-mode #article-search {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #f8f4ee !important;
}

html body.dark-mode #article-search::placeholder {
    color: rgba(209,213,219,0.5) !important;
}

/* Category list buttons in sidebar */
html body.dark-mode #category-list button {
    background: rgba(255,255,255,0.05) !important;
    color: #d1d5db !important;
}

html body.dark-mode #category-list button:hover {
    background: rgba(255,255,255,0.1) !important;
}

html body.dark-mode #category-list button.bg-celadon\/10,
html body.dark-mode #category-list button.active {
    background: rgba(110,231,183,0.15) !important;
    color: #6ee7b7 !important;
}

/* Skeleton loading placeholders */
html body.dark-mode .skeleton {
    background: rgba(255,255,255,0.08) !important;
}

/* Aside sidebar container */
html body.dark-mode aside {
    color: #d1d5db !important;
}

/* Last resort - force text visibility */
body.dark-mode *:not(script):not(style):not(noscript) {
    color: var(--text-primary, #f8f4ee) !important;
}

/* ================================================
   UI/UX ENHANCEMENTS
   ================================================ */

/* Better focus states */
:focus-visible {
    outline: 2px solid #c04851;
    outline-offset: 2px;
}

/* Smooth scroll snapping */
.snap-scroll {
    scroll-snap-type: y mandatory;
}

.snap-item {
    scroll-snap-align: start;
}

/* Selection style */
::selection {
    background: rgba(192, 72, 81, 0.2);
    color: #c04851;
}

body.dark-mode ::selection {
    background: rgba(255, 122, 133, 0.3);
    color: #ff7a85;
}

/* Better typography */
.font-serif {
    font-feature-settings: "liga" 1, "kern" 1;
    letter-spacing: 0.01em;
}

/* Glassmorphism */
.glass {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.2);
}

body.dark-mode .glass {
    background: rgba(15,20,25,0.8);
    border-color: rgba(255,255,255,0.1);
}

/* Subtle gradient text */
.gradient-text {
    background: linear-gradient(135deg, #c04851, #d4b106);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Floating elements */
.float-slow {
    animation: float 6s ease-in-out infinite;
}

.float-medium {
    animation: float 4s ease-in-out infinite;
}

.float-fast {
    animation: float 2s ease-in-out infinite;
}

/* Pulse dots */
.pulse-dot {
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    background: inherit;
    border-radius: inherit;
    animation: pulseRing 2s ease-out infinite;
    opacity: 0.5;
}

@keyframes pulseRing {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

/* ================================================
   ACCESSIBILITY IMPROVEMENTS
   ================================================ */

/* Skip to main content */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #c04851;
    color: white;
    padding: 0.75rem 1.5rem;
    z-index: 9999;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --ink-black: #000;
        --paper-white: #fff;
    }
}

/* ================================================
   PERFORMANCE & LOADING OPTIMIZATIONS
   ================================================ */

/* Critical CSS only - above the fold */
.critical-content {
    will-change: transform;
}

/* Preload hint */
.preload {
    font-display: swap;
}

/* Intersection Observer triggers */
.observe-hidden {
    opacity: 0;
}

/* ================================================
   PRINT STYLES
   ================================================ */

@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}
