/* Pixel Art for Games - Main Stylesheet */

/* CSS Variables for theme management */
:root {
    --bg-primary: #2c3e50;
    --bg-secondary: #34495e;
    --bg-tertiary: #3a4a5c;
    --accent-primary: #e91e63;
    --accent-secondary: #f06292;
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --border-color: #34495e;
    --success: #4CAF50;
    --warning: #ff9800;
    --error: #f44336;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --task-bg: #e91e63;
    --task-hover: #f06292;
    --canvas-bg: #2c3e50;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header styles */
.header {
    background: var(--gradient-1);
    padding: 2rem 0;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main navigation (weeks) */
.main-nav {
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.main-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0;
}

.main-nav li {
    margin: 0;
}

.main-nav a {
    display: block;
    padding: 1rem 2rem;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

.main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-bottom-color: #3498db;
}

.main-nav a.active {
    background-color: rgba(52, 152, 219, 0.2);
    border-bottom-color: #3498db;
}

/* Content container */
.content-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Week section */
.week-section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.week-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sub-navigation (within weeks) */
.sub-nav {
    background-color: var(--bg-secondary);
    border-radius: 10px;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.sub-nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
}

.sub-nav a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    background-color: #4a5568;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.sub-nav li:last-child a {
    border-right: none;
}

.sub-nav a:hover {
    background-color: var(--task-hover);
    transform: translateY(-2px);
}

.sub-nav a.active {
    background-color: var(--task-bg);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Sub-content sections */
.sub-content {
    display: none;
    background-color: var(--bg-secondary);
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.sub-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

/* Typography within content */
.sub-content h2 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    background: var(--gradient-2);
    padding: 2rem;
    margin: -2rem -2rem 2rem -2rem;
    border-radius: 10px 10px 0 0;
    text-align: center;
}

.sub-content h3 {
    color: #3498db;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.sub-content h4 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.sub-content p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.sub-content ul, .sub-content ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.sub-content li {
    margin-bottom: 0.5rem;
}

/* Exercise containers */
.exercise-container {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.exercise-instructions {
    flex: 1;
    min-width: 300px;
}

.exercise-workspace {
    flex: 1;
    min-width: 300px;
    background-color: var(--canvas-bg);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

/* Canvas and tools */
.canvas-container {
    background-color: white;
    border-radius: 5px;
    padding: 10px;
    display: inline-block;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    position: relative;
}

.pixel-canvas {
    image-rendering: pixelated; /* Most modern browsers */
    image-rendering: crisp-edges; /* Firefox, some others */
    image-rendering: -webkit-optimize-contrast; /* Old Safari, Edge 79+ */
    image-rendering: -moz-crisp-edges; /* Old Firefox */
    image-rendering: -o-crisp-edges; /* Old Opera */
    image-rendering: optimize-contrast; /* Legacy */
    -ms-interpolation-mode: nearest-neighbor; /* IE */
    cursor: crosshair;
    border: 1px solid #ddd;
    display: block;
}

.tools {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    background-color: #4a5568;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.tool-btn:hover {
    background-color: #5a6578;
    transform: translateY(-2px);
}

.tool-btn.active {
    background-color: #3498db;
    color: white;
}

.palette {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 35px;
    height: 35px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
    border: 2px solid transparent;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.3);
}

/* Info boxes */
.info-box {
    background-color: rgba(52, 152, 219, 0.1);
    border-left: 4px solid #3498db;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 5px;
}

.tip-box {
    background-color: rgba(76, 175, 80, 0.1);
    border-left: 4px solid var(--success);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 5px;
}

.warning-box {
    background-color: rgba(255, 152, 0, 0.1);
    border-left: 4px solid var(--warning);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 5px;
}

/* Quiz styles */
.quiz-question {
    background-color: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.quiz-question h4 {
    margin-bottom: 1rem;
    color: #3498db;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quiz-option {
    padding: 0.75rem;
    background-color: #4a5568;
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.quiz-option:hover {
    border-color: #3498db;
    transform: translateX(5px);
    background-color: #5a6578;
}

.quiz-option.correct {
    background-color: rgba(76, 175, 80, 0.3);
    border-color: var(--success);
}

.quiz-option.incorrect {
    background-color: rgba(244, 67, 54, 0.3);
    border-color: var(--error);
}

/* Layer controls */
.layer-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Animation controls */
.animation-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.frame-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}

.frame-indicator {
    padding: 0.25rem 0.75rem;
    background-color: var(--bg-tertiary);
    border-radius: 5px;
    font-weight: bold;
}

/* Preview container */
.preview-container {
    margin-top: 1rem;
    text-align: center;
}

.preview-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

#tile-preview {
    background-color: white;
    border: 1px solid #ddd;
    display: inline-block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Responsive design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .main-nav a {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .content-container {
        padding: 1rem;
    }
    
    .exercise-container {
        flex-direction: column;
    }
    
    .sub-nav ul {
        flex-direction: column;
    }
    
    .sub-nav a {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sub-nav li:last-child a {
        border-bottom: none;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.hidden { display: none; }

/* Code blocks */
.code-block {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1rem;
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
}

/* Export button */
.export-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--success);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.export-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
}

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

/* Reference image */
.reference-image {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 1rem 0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    pointer-events: none;
}

[data-tooltip]:after {
    content: '';
    position: absolute;
    bottom: 135%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    pointer-events: none;
}

[data-tooltip]:hover:before,
[data-tooltip]:hover:after {
    opacity: 1;
    visibility: visible;
}

/* Custom color picker */
.custom-color-container {
    margin-left: 0.5rem;
}

.custom-color-picker {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #ddd;
    background-color: #f0f0f0;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    text-align: center;
    line-height: 26px;
    vertical-align: middle;
}

.custom-color-picker:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.custom-color-picker.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.3);
}

.color-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Progress indicators */
.progress-indicator {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    background-color: #e0e0e0;
    color: #666;
    transition: all 0.3s ease;
}

.progress-indicator.partial {
    background-color: #ffa726;
    color: white;
}

.progress-indicator.complete {
    background-color: #4caf50;
    color: white;
}

/* Sub-tab visited indicator */
.sub-tab-nav.visited::after {
    content: '✓';
    margin-left: 0.5rem;
    color: #4caf50;
    font-weight: bold;
}

/* Task example styling */
.task-with-example {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    align-items: flex-start;
}

.task-instructions {
    flex: 1;
    min-width: 0;
}

.task-example {
    flex: 0 0 320px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pixel-example {
    width: 100%;
    max-width: 300px;
    height: auto;
    border: 2px solid #ddd;
    border-radius: 4px;
    background-color: white;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    transition: transform 0.2s ease;
}

/* Large example for specific images that need more space */
.task-example-large {
    flex: 0 0 520px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pixel-example-large {
    width: 100%;
    max-width: 500px;
    height: auto;
    border: 2px solid #ddd;
    border-radius: 4px;
    background-color: white;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    transition: transform 0.2s ease;
}

.pixel-example:hover,
.pixel-example-large:hover {
    transform: scale(1.1);
    border-color: var(--accent-primary);
}

.example-caption {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
    line-height: 1.3;
}

/* Responsive design for task examples */
@media (max-width: 768px) {
    .task-with-example {
        flex-direction: column;
        gap: 1rem;
    }
    
    .task-example {
        flex: none;
        align-self: center;
        max-width: 200px;
    }
    
    .pixel-example {
        max-width: 140px;
    }
    
    .task-example-large {
        flex: none;
        align-self: center;
        max-width: 400px;
    }
    
    .pixel-example-large {
        max-width: 350px;
    }
}
