/* 
    Interactive Code Playground Styles
    
    This file contains styles for the interactive code playground component
    where students can edit HTML/CSS and see live previews.
    
    Students can learn how to style complex interactive components and
    create responsive layouts for code editors.
*/

/* 
    Playground Container
    
    The main container that holds the editor and preview sections.
    Uses a two-column layout that adapts to screen size.
*/
.code-playground {
    margin: 2rem 0;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
    background-color: white;
}

/* 
    Playground Controls
    
    Buttons to reset code or show solutions.
    Positioned at the top of the playground.
*/
.playground-controls {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.playground-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    background-color: white;
    color: var(--text-color, #334155);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.playground-btn:hover {
    background-color: var(--primary-color, #2563eb);
    color: white;
    border-color: var(--primary-color, #2563eb);
}

.playground-btn:focus {
    outline: 2px solid var(--primary-color, #2563eb);
    outline-offset: 2px;
}

.playground-btn-reset {
    background-color: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.playground-btn-reset:hover {
    background-color: #f59e0b;
    color: white;
}

.playground-btn-solution {
    background-color: #e0f2fe;
    border-color: var(--primary-color, #2563eb);
    color: var(--primary-color, #2563eb);
}

.playground-btn-solution:hover {
    background-color: var(--primary-color, #2563eb);
    color: white;
}

/* 
    Playground Layout
    
    Creates a two-column layout on larger screens, stacked on mobile.
    Uses CSS Grid for flexible responsive design.
*/
.playground-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

/* 
    Editor Panel
    
    Each panel (HTML or CSS) has its own textarea editor.
*/
.editor-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color, #e2e8f0);
}

.editor-panel:last-child {
    border-right: none;
}

.editor-label {
    padding: 0.75rem 1rem;
    background-color: #1e293b;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.code-editor {
    flex: 1;
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: none;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    background-color: #f8fafc;
    color: var(--text-color, #334155);
}

.code-editor:focus {
    outline: 2px solid var(--primary-color, #2563eb);
    outline-offset: -2px;
    background-color: white;
}

.code-editor::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* 
    Preview Section
    
    Contains the iframe that displays the live preview.
*/
.playground-preview {
    display: flex;
    flex-direction: column;
}

.preview-label {
    padding: 0.75rem 1rem;
    background-color: #16a34a;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preview-container {
    position: relative;
    min-height: 400px;
    background-color: white;
    border-top: 1px solid var(--border-color, #e2e8f0);
}

.preview-iframe {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border: none;
    background-color: white;
}

/* 
    Responsive Design
    
    On smaller screens, stack the editor panels vertically
    and make the preview full width below.
*/
@media (max-width: 768px) {
    .playground-editor {
        grid-template-columns: 1fr;
    }
    
    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color, #e2e8f0);
    }
    
    .editor-panel:last-child {
        border-bottom: none;
    }
    
    .code-editor {
        min-height: 250px;
    }
    
    .preview-container {
        min-height: 300px;
    }
    
    .preview-iframe {
        min-height: 300px;
    }
    
    .playground-controls {
        flex-direction: column;
    }
    
    .playground-btn {
        width: 100%;
    }
}

/* 
    Accessibility
    
    Ensure keyboard navigation works well and screen readers
    can understand the playground structure.
*/
.code-playground:focus-within {
    outline: 3px solid var(--primary-color, #2563eb);
    outline-offset: 2px;
}

.playground-intro {
    background-color: #e0f2fe;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color, #2563eb);
    margin: 1.5rem 0;
    font-weight: 500;
}

