/* ========================================
   PREMIUM UI/UX ENHANCEMENTS
   Zero-Tolerance Content Delivery Experience
   ======================================== */

/* ==================== SMOOTH TRANSITIONS ==================== */

* {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Override for animations that need custom timing */
.no-transition,
.no-transition * {
    transition: none !important;
}

/* ==================== LOADING STATES ==================== */

/* Beautiful skeleton loader for content */
.skeleton-loader {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg,
            #f0f0f0 25%,
            #e0e0e0 50%,
            #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

body.dark-mode .skeleton-loader {
    background: linear-gradient(90deg,
            #2a2a2a 25%,
            #3a3a3a 50%,
            #2a2a2a 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Content loading overlay */
.content-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: 20px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(39, 174, 96, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 1.1em;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==================== CONTENT REVEAL ANIMATIONS ==================== */

.handout-panel {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation for list items */
.handout-panel li,
.topic-list .topic-item {
    animation: fadeInLeft 0.5s ease-out backwards;
}

.handout-panel li:nth-child(1) {
    animation-delay: 0.1s;
}

.handout-panel li:nth-child(2) {
    animation-delay: 0.2s;
}

.handout-panel li:nth-child(3) {
    animation-delay: 0.3s;
}

.handout-panel li:nth-child(4) {
    animation-delay: 0.4s;
}

.handout-panel li:nth-child(5) {
    animation-delay: 0.5s;
}

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

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== ENHANCED SCROLLING ==================== */

html {
    scroll-behavior: smooth;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: #229954;
}

/* ==================== INTERACTIVE ELEMENTS ==================== */

/* Enhanced button hover effects */
.nav-btn,
.mark-complete-btn,
.cta-button {
    position: relative;
    overflow: hidden;
    transform: translateY(0);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.nav-btn:hover::before,
.mark-complete-btn:hover::before {
    width: 300px;
    height: 300px;
}

.nav-btn:hover,
.mark-complete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.3);
}

.nav-btn:active,
.mark-complete-btn:active {
    transform: translateY(0);
}

/* Topic link hover effect */
.topic-link {
    position: relative;
    overflow: hidden;
}

.topic-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 3px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.topic-link:hover::after {
    width: 100%;
}

.topic-link:hover {
    transform: translateX(5px);
}

/* ==================== TYPOGRAPHY ENHANCEMENTS ==================== */

/* Smooth font rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Enhanced heading hierarchy */
h1,
h2,
h3,
h4,
h5,
h6 {
    letter-spacing: -0.02em;
    line-height: 1.3;
    font-weight: 700;
}

/* Beautiful text selection */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* ==================== CARD ANIMATIONS ==================== */

.feature-card,
.module-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.feature-card:hover,
.module-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* ==================== PROGRESS BAR ANIMATION ==================== */

.progress-fill {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* ==================== FOCUS STATES ==================== */

/* Accessible focus indicators */
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==================== SIDEBAR ENHANCEMENTS ==================== */

.sidebar {
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.module-header {
    transition: all 0.3s ease;
}

.module-header:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.2);
}

/* ==================== CONTENT AREA POLISH ==================== */

.handout-content-wrapper {
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.dark-mode .handout-content-wrapper {
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== CODE BLOCK ENHANCEMENTS ==================== */

pre {
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--primary-color);
}

/* Copy Button Styles */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e0e0e0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(4px);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.copy-btn.copied {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.copy-btn i {
    font-size: 1rem;
}

/* Hide default label as button provides context */
pre::before {
    display: none;
}

/* ==================== MOBILE OPTIMIZATIONS ==================== */

@media (max-width: 768px) {

    /* Faster animations on mobile */
    * {
        transition-duration: 0.2s !important;
    }

    /* Reduce motion for better performance */
    @media (prefers-reduced-motion: reduce) {

        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

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

@media print {

    .sidebar,
    .nav-btn,
    .mobile-menu-btn,
    .theme-toggle {
        display: none !important;
    }

    .content-area {
        width: 100%;
        max-width: 100%;
    }

    .handout-panel {
        box-shadow: none;
    }
}

/* ==================== ACCESSIBILITY ENHANCEMENTS ==================== */

/* Skip to main content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
}

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

/* GPU acceleration for animations */
.handout-panel,
.feature-card,
.module-card,
.nav-btn {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Contain layout shifts */
.handout-content-wrapper {
    contain: layout style paint;
}

/* ==================== EASTER EGG: CELEBRATION ==================== */

@keyframes celebrate {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-5deg);
    }

    75% {
        transform: rotate(5deg);
    }
}

.completed-celebration {
    animation: celebrate 0.5s ease-in-out;
}

/* ==================== UTILITY ANIMATIONS ==================== */

.fade-in-up {
    animation: fadeInUpFast 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInUpFast {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* View Transitions API Customization */
::view-transition-old(root) {
    animation: fadeOut 0.2s ease-in-out both;
}

::view-transition-new(root) {
    animation: fadeIn 0.3s ease-in-out both;
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
}

/* ==================== AI KITCHEN ACADEMY HIGHLIGHT ==================== */

.ai-kitchen-banner {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 2px solid #f59e0b;
    border-radius: 20px;
    padding: 3rem 2rem;
    margin: 4rem auto;
    max-width: 900px;
    text-align: center;
    box-shadow: 0 20px 40px -10px rgba(245, 158, 11, 0.2);
    position: relative;
    overflow: hidden;
    border-left: 8px solid #f59e0b;
}

.ai-kitchen-banner::after {
    content: '\f2e7'; /* fa-utensils */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: -20px;
    right: -20px;
    font-size: 8rem;
    color: rgba(245, 158, 11, 0.05);
    transform: rotate(15deg);
}

.ai-kitchen-title {
    color: #92400e;
    font-size: 2.2rem;
    font-weight: 900;
    margin-bottom: 1.2rem;
    line-height: 1.1;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    letter-spacing: -0.03em;
}

.ai-kitchen-subtitle {
    color: #b45309;
    font-size: 1.25rem;
    margin-bottom: 2.5rem;
    font-weight: 500;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.ai-kitchen-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #f59e0b !important;
    color: white !important;
    text-decoration: none;
    padding: 16px 36px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4) !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.ai-kitchen-btn:hover {
    background: #d97706 !important;
    transform: translateY(-5px) scale(1.02) !important;
    box-shadow: 0 12px 30px rgba(217, 119, 6, 0.5) !important;
}

.ai-kitchen-btn i {
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .ai-kitchen-banner {
        padding: 2rem 1.5rem;
        margin: 2.5rem 1rem;
    }
    
    .ai-kitchen-title {
        font-size: 1.6rem;
    }
    
    .ai-kitchen-subtitle {
        font-size: 1.1rem;
    }
}
