/* Custom styles for Astrology Beginner's Guide - Optimized */

/* CSS Variables for theming */
:root {
    --primary-color: rgb(99, 102, 241);
    --primary-hover: rgb(79, 70, 229);
    --bg-primary: #000000;
    --bg-secondary: #111827;
    --bg-tertiary: #1F2937;
    --text-primary: #F9FAFB;
    --text-secondary: #D1D5DB;
    --text-muted: #9CA3AF;
    --border-color: #374151;
    --transition-fast: 150ms;
    --transition-normal: 300ms;
    --transition-slow: 500ms;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Light theme variables */
html.light-theme,
html.light-theme body {
    --bg-primary: #F9FAFB;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F3F4F6;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
}

html.light-theme body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

html.light-theme .bg-gray-900 {
    background-color: var(--bg-secondary) !important;
}

html.light-theme .text-white {
    color: var(--text-primary) !important;
}

html.light-theme .text-gray-300 {
    color: var(--text-secondary) !important;
}

html.light-theme .border-gray-800 {
    border-color: var(--border-color) !important;
}

/* Font styles with fallbacks */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.font-geist-mono {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Smooth animations and transitions */
@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

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

/* Card animations */
.card-animate {
    animation: fadeIn 0.6s ease-out;
    transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
}

.card-animate:hover {
    transform: translateY(-4px);
}

.card-animate:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Staggered animation for cards */
.card-animate:nth-child(1) { animation-delay: 0.1s; }
.card-animate:nth-child(2) { animation-delay: 0.2s; }
.card-animate:nth-child(3) { animation-delay: 0.3s; }
.card-animate:nth-child(4) { animation-delay: 0.4s; }
.card-animate:nth-child(5) { animation-delay: 0.5s; }
.card-animate:nth-child(6) { animation-delay: 0.6s; }

/* Image lazy loading placeholder */
.lazy-load {
    background: linear-gradient(90deg, #111827 25%, #1F2937 50%, #111827 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
    animation: none;
}

/* Natal chart container */
.natal-chart-container {
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-normal) ease, box-shadow var(--transition-normal) ease;
}

.natal-chart-container:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* Zodiac wheel container with improved hover effect */
.zodiac-wheel-container svg {
    transition: transform var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.zodiac-wheel-container:hover svg {
    transform: rotate(15deg) scale(1.05);
}

/* Custom scrollbar - improved */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: #4B5563;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-primary);
}

/* Decorative elements */
.border-l-4 {
    position: relative;
}

.border-l-4::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-color);
    animation: pulse 2s ease-in-out infinite;
}

/* Focus styles for accessibility */
a:focus,
button:focus,
[tabindex="0"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remove default focus outline for mouse users */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Reduced motion support */
@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;
    }
    
    .card-animate {
        animation: none;
    }
    
    .zodiac-wheel-container:hover svg {
        transform: none;
    }
    
    .natal-chart-container:hover {
        transform: none;
    }
}

/* Performance optimizations */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Print styles */
@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    .sr-only,
    nav,
    #back-to-top {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
}

/* Responsive adjustments */
@media (max-width: 640px) {
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Adjust card grid for mobile */
    .grid {
        grid-template-columns: 1fr;
    }
    
    /* Smaller spacing on mobile */
    .mb-16 {
        margin-bottom: 3rem;
    }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
    }
}

/* Large screen optimizations */
@media (min-width: 1440px) {
    .container {
        max-width: 1280px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #FFFFFF;
        --text-secondary: #FFFFFF;
    }
    
    .bg-gray-900 {
        border-width: 2px;
    }
}

/* Dark mode preference (already dark, but ensure consistency) */
@media (prefers-color-scheme: dark) {
    :root {
        /* Already optimized for dark mode */
    }
}

/* Performance: will-change hints */
.natal-chart-container,
.zodiac-wheel-container svg,
.card-animate {
    will-change: transform;
}

/* Optimize repaints */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}
