/* ========================================
   Koning Mexico - Main Stylesheet
   ======================================== */

/* CSS Custom Properties (Design Tokens) */
:root {
    /* Colors */
    --color-gold: #D4AF37;
    --color-gold-light: #FFD700;
    --color-gold-dark: #B8960F;
    --color-green: #0D5E3A;
    --color-green-light: #1B7A4B;
    --color-red: #8B0000;
    --color-red-light: #B22222;
    --color-brown-dark: #3E2723;
    --color-brown-medium: #5D4037;
    --color-cream: #F5E6D3;
    --color-cream-light: #FFF8E7;
    --color-white: #FFFFFF;

    /* Typography */
    --font-heading: 'Cinzel', serif;
    --font-body: 'Open Sans', sans-serif;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 3rem;
    --space-xl: 4rem;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.6s ease;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.25);

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Background colors */
    --bg-primary: #FFF8E7;
    --bg-secondary: #F5E6D3;
    --text-primary: #3E2723;
    --text-secondary: #5D4037;
}

/* ========================================
   Dark Mode Variables
   ======================================== */

body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --color-cream: #2a2a2a;
    --color-cream-light: #1a1a1a;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode section {
    background-color: var(--bg-secondary) !important;
}

body.dark-mode .bg-white {
    background-color: #2a2a2a !important;
}

body.dark-mode .bg-cream,
body.dark-mode .bg-cream-light {
    background-color: #1a1a1a !important;
}

body.dark-mode .text-brown-dark {
    color: #e0e0e0 !important;
}

body.dark-mode .card {
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

body.dark-mode .shadow-lg,
body.dark-mode .shadow-xl {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6) !important;
}

/* ========================================
   Mobile Navigation Styles
   ======================================== */

/* Mobile menu hidden by default */
@media (max-width: 768px) {
    #main-navigation {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(to bottom, var(--color-green), var(--color-green-light));
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    #main-navigation.active {
        display: flex !important;
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    #main-navigation a {
        padding: 1rem;
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    #main-navigation a:last-child {
        border-bottom: none;
    }

    /* Hamburger animation */
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

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

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

/* ========================================
   Dice Styles
   ======================================== */

.die,
.die-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform var(--transition-fast);
}

.die:hover,
.die-mini:hover {
    transform: scale(1.1);
}

.die.rolling {
    animation: diceRoll 0.5s ease;
}

@keyframes diceRoll {
    0%, 100% {
        transform: rotate(0deg) scale(1);
    }
    25% {
        transform: rotate(90deg) scale(1.1);
    }
    50% {
        transform: rotate(180deg) scale(1.2);
    }
    75% {
        transform: rotate(270deg) scale(1.1);
    }
}

/* ========================================
   Card Styles
   ======================================== */

.requirement-card,
.variant-card,
.phase-card,
.strategy-item {
    transition: all var(--transition-normal);
}

.variant-card {
    cursor: pointer;
    border: 2px solid transparent;
}

.variant-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-gold);
}

.variant-card.active {
    border-color: var(--color-gold);
    background-color: var(--color-white);
    box-shadow: var(--shadow-lg);
}

/* ========================================
   Scroll Animations
   ======================================== */

.animate-in {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ========================================
   Floating Animation
   ======================================== */

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

.dice-float {
    animation: diceFloat 3s ease-in-out infinite;
}

.dice-float:nth-child(2) {
    animation-delay: 0.5s;
}

/* ========================================
   Pulse Animation
   ======================================== */

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

.pulse-anim {
    animation: pulse 2s ease-in-out infinite;
}

/* ========================================
   Bounce Animation (for Easter Egg)
   ======================================== */

@keyframes bounce {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* ========================================
   Back to Top Button
   ======================================== */

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-gold-light) 100%);
    color: var(--color-brown-dark);
    border: 3px solid var(--color-gold-dark);
    font-size: 24px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
    z-index: 999;
    transition: all var(--transition-normal);
}

.back-to-top:hover {
    transform: scale(1.1) translateY(-5px);
}

/* ========================================
   Utility Classes
   ======================================== */

.clickable {
    cursor: pointer;
    user-select: none;
}

.no-scroll {
    overflow: hidden;
}

/* ========================================
   Responsive Typography
   ======================================== */

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

@media (min-width: 641px) and (max-width: 1024px) {
    html {
        font-size: 15px;
    }
}

@media (min-width: 1025px) {
    html {
        font-size: 16px;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .back-to-top,
    .mobile-menu-toggle,
    header {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    section {
        page-break-inside: avoid;
    }
}

/* ========================================
   Accessibility Improvements
   ======================================== */

/* Focus styles for keyboard navigation */
a:focus,
button:focus {
    outline: 3px solid var(--color-gold);
    outline-offset: 2px;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-gold: #FFD700;
        --color-green: #00FF00;
        --color-red: #FF0000;
    }
}

/* ========================================
   Loading State (Optional)
   ======================================== */

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-cream);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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