/* Main Styles - Core layout and typography */
/* Design System: Whimsical Halloween theme with no gore or frightening imagery (Requirement 14.7) */
/* Color Palette: Deep dark backgrounds with pumpkin orange, soft purple, and ghostly teal accents */
/* Typography: Decorative fonts for headings, sans-serif for body text for readability */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Deep Dark Background (Requirement 14.1) */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;
    
    /* Accent Colors: Pumpkin Orange, Soft Purple, Ghostly Teal (Requirement 14.2) */
    --accent-orange: #ff8c42;
    --accent-purple: #9d7bd8;
    --accent-teal: #5dd9c1;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Typography (Requirements 14.3, 14.4) */
    --font-heading: 'Creepster', 'Georgia', cursive; /* Spooky horror font for headings */
    --font-decorative: 'Nosifer', 'Creepster', cursive; /* Extra spooky for special elements */
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; /* Sans-serif for readability */
    --font-mono: 'Courier New', Courier, monospace;
    
    /* Subtle Glow and Shadow Effects (Requirement 14.6) */
    --shadow-glow: 0 0 20px rgba(255, 140, 66, 0.3);
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-medium: 0 8px 24px rgba(0, 0, 0, 0.4);
    --glow-orange: 0 0 15px rgba(255, 140, 66, 0.4);
    --glow-purple: 0 0 15px rgba(157, 123, 216, 0.4);
    --glow-teal: 0 0 15px rgba(93, 217, 193, 0.4);
    
    /* Border and Overlay */
    --overlay-bg: rgba(10, 10, 10, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-radius-sm: 6px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    
    /* Transition Durations for Smooth Micro-interactions (Requirement 14.5) */
    --transition-fast: 0.15s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;
    
    /* Z-index layers */
    --z-background: 1;
    --z-content: 10;
    --z-nav: 100;
    --z-transition: 1000;
    --z-cursor-trail: 9999;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    min-height: 100vh;
    line-height: 1.6; /* Improved readability (Requirement 14.8) */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
}

/* Navigation Bar */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-icons {
    display: flex;
    gap: var(--spacing-sm);
}

.nav-controls {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.nav-icon {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-normal) ease; /* Smooth micro-interaction (Requirement 14.5) */
    color: var(--text-primary);
    font-size: 1.5rem;
}

.nav-icon:hover {
    border-color: var(--accent-orange);
    background: rgba(255, 140, 66, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--glow-orange); /* Subtle glow effect (Requirement 14.6) */
}

.nav-icon:focus {
    outline: 2px solid var(--accent-orange);
    outline-offset: 2px;
}

.nav-icon:focus-visible {
    outline: 3px solid var(--accent-orange);
    outline-offset: 3px;
}

.nav-icon:active {
    transform: translateY(0); /* Smooth press feedback (Requirement 14.5) */
}

.nav-icon.active {
    border-color: var(--accent-orange);
    background: rgba(255, 140, 66, 0.2);
    box-shadow: var(--glow-orange); /* Subtle glow effect (Requirement 14.6) */
}

.realm-toggle {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-normal) ease;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.realm-toggle:hover {
    border-color: var(--accent-purple);
    background: rgba(157, 123, 216, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--glow-purple);
}

.realm-toggle:active {
    transform: translateY(0);
}

.realm-toggle:focus-visible {
    outline: 3px solid var(--accent-purple);
    outline-offset: 2px;
}

.theme-night .realm-icon::after {
    content: '🌙';
}

.theme-day .realm-icon::after {
    content: '☀️';
}

.mute-toggle {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: all var(--transition-normal) ease;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.mute-toggle:hover {
    border-color: var(--accent-teal);
    background: rgba(93, 217, 193, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--glow-teal);
}

.mute-toggle:active {
    transform: translateY(0);
}

.mute-icon::after {
    content: '🔊';
}

.mute-toggle.muted .mute-icon::after {
    content: '🔇';
}

/* Page Container */
.page-container {
    position: relative;
    z-index: var(--z-content);
    min-height: 100vh;
    padding: calc(50px + var(--spacing-xl)) var(--spacing-xl) var(--spacing-xl);
}

/* Typography (Requirements 14.3, 14.4, 14.8) */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading); /* Spooky horror font for headings */
    font-weight: 400;
    line-height: 1.2;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    text-shadow: 0 0 10px rgba(255, 102, 0, 0.3);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-md);
}

h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
}

h3 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
}

p {
    font-family: var(--font-body); /* Sans-serif for body text (Requirement 14.4) */
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--spacing-xl);
    font-family: var(--font-body);
    text-shadow: none;
}

/* Buttons with Smooth Micro-interactions (Requirement 14.5) */
button {
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition-normal) ease;
    border: none;
    outline: none;
}

button:hover:not(:disabled) {
    transform: translateY(-2px); /* Subtle lift on hover */
}

button:active:not(:disabled) {
    transform: translateY(0); /* Press feedback */
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Accessibility (Requirement 16.5) */

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

/* Enhanced focus indicators for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent-orange);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--accent-orange);
    outline-offset: 2px;
}

/* Ensure sufficient color contrast (Requirement 16.5) */
/* Text colors are defined in themes.css with WCAG AA compliance:
   - Night mode: #e8e8e8 on #0a0a0a (contrast ratio > 15:1)
   - Day mode: #1a1a1a on #f5f0e8 (contrast ratio > 12:1)
*/

/* Screen reader only */
.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;
}

/* Skip to main content link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-orange);
    color: var(--bg-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    z-index: 10000;
    font-weight: bold;
    border-radius: 0 0 var(--border-radius-sm) 0;
}

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

/* Responsive */
@media (max-width: 768px) {
    .nav-icons {
        gap: var(--spacing-xs);
    }
    
    .nav-icon {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 1.25rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .page-container {
        padding: calc(50px + var(--spacing-md)) var(--spacing-md) var(--spacing-md);
    }
    
    .realm-toggle,
    .mute-toggle {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 1.25rem;
    }
}


/* Spooky Horror Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 400;
    letter-spacing: 0.05em;
    text-shadow: 0 0 10px rgba(255, 102, 0, 0.5);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-lg);
}

h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
}

h3 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
}

.subtitle, .card-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    text-shadow: none;
}


/* Copyright Footer */
.copyright-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: var(--z-nav);
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.copyright-footer:hover {
    opacity: 1;
}

.copyright-footer p {
    margin: 0;
    font-family: var(--font-body);
    line-height: 1.4;
}

@media (max-width: 768px) {
    .copyright-footer {
        font-size: 0.65rem;
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}


/* Mobile Performance Optimizations */
@media (max-width: 768px) {
    /* Reduce animations for better performance */
    * {
        animation-duration: 0.5s !important;
    }
    
    /* Optimize touch interactions */
    button, .btn, .mini-widget, .nav-icon {
        -webkit-tap-highlight-color: rgba(157, 123, 216, 0.3);
        touch-action: manipulation;
    }
    
    /* Reduce blur effects for performance */
    .card, .mini-widget {
        backdrop-filter: none;
    }
    
    /* Optimize scrolling */
    .page-container {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
    
    /* Reduce shadow complexity */
    .spectral-title {
        text-shadow: 
            0 0 10px rgba(157, 123, 216, 0.8),
            0 0 20px rgba(157, 123, 216, 0.6);
    }
    
    /* Optimize cursor trail for mobile */
    .cursor-trail {
        display: none;
    }
    
    /* Reduce particle effects */
    .background-world {
        opacity: 0.5;
    }
}

/* Touch-friendly sizing */
@media (max-width: 768px) {
    /* Larger touch targets */
    .nav-icon {
        min-width: 44px;
        min-height: 44px;
    }
    
    .btn, button {
        min-height: 44px;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    /* Better spacing for mobile */
    .mini-widgets {
        gap: var(--spacing-md);
    }
    
    /* Adjust page container for mobile */
    .page-container {
        padding-bottom: calc(var(--spacing-xl) + 40px); /* Extra space for copyright */
    }
}

/* Prevent text selection on interactive elements */
.nav-icon, .btn, button, .mini-widget {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Hardware acceleration for animations */
.candle-flame, .mini-widget, .nav-icon, .transition-layer {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}


/* Floating Ghosts on ground */
.ground-ghost {
    position: fixed;
    bottom: 30px;
    width: 80px;
    height: 96px;
    pointer-events: none;
    opacity: 0.95;
    filter: drop-shadow(0 4px 15px rgba(255, 255, 255, 0.4));
    z-index: 5;
}

.ground-ghost svg {
    width: 100%;
    height: 100%;
}

/* Left ghost positioning */
.ground-ghost-left {
    left: 13%;
    animation: groundGhostFloat 4s ease-in-out infinite;
}

/* Right ghost positioning */
.ground-ghost-right {
    right: 13%;
    animation: groundGhostFloat2 4.5s ease-in-out infinite 0.5s;
}

@keyframes groundGhostFloat {
    0%, 100% {
        transform: translateY(0) rotate(-3deg);
    }
    25% {
        transform: translateY(-15px) rotate(2deg);
    }
    50% {
        transform: translateY(-8px) rotate(-2deg);
    }
    75% {
        transform: translateY(-18px) rotate(3deg);
    }
}

@keyframes groundGhostFloat2 {
    0%, 100% {
        transform: translateY(0) rotate(3deg);
    }
    25% {
        transform: translateY(-12px) rotate(-2deg);
    }
    50% {
        transform: translateY(-20px) rotate(2deg);
    }
    75% {
        transform: translateY(-10px) rotate(-3deg);
    }
}

@media (max-width: 768px) {
    .ground-ghost {
        width: 60px;
        height: 72px;
        bottom: 25px;
    }
    
    .ground-ghost-left {
        left: 10%;
    }
    
    .ground-ghost-right {
        right: 10%;
    }
}
