/* Z-Index Visualizer Styles */

/* Base Content Styles */
#content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

#content h1 {
    text-align: center;
    color: #333;
    margin-bottom: 1rem;
}

#content p {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

:root {
    --primary-color: #3498db;
    --secondary-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --purple-color: #9b59b6;
    --border-radius: 8px;
    --transition-duration: 0.3s;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Controls */
.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.control-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.control-group input[type="range"] {
    width: 100%;
    max-width: 150px;
}

.control-group span {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
    min-width: 40px;
    text-align: center;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #e1e8ed;
}

/* Demo Sections */
.demo-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.demo-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
}

.demo-section h2 {
    margin: 0 0 1rem 0;
    color: #333;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

/* Demo Containers */
.demo-container {
    position: relative;
    height: 300px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin: 1rem 0;
}

.demo-container.small {
    height: 200px;
}

/* Z-Index Boxes */
.z-box {
    position: absolute;
    width: 120px;
    height: 80px;
    border-radius: var(--border-radius);
    border: 2px solid rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: transform var(--transition-duration) ease, box-shadow var(--transition-duration) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.z-box:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.box-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    top: 50px;
    left: 50px;
}

.box-red {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    top: 80px;
    left: 120px;
}

.box-green {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    top: 110px;
    left: 190px;
}

.box-purple {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333;
    text-shadow: none;
    top: 140px;
    left: 260px;
}

.box-label {
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.2;
}

.z-value {
    font-size: 1rem;
    font-weight: 700;
}

/* Stacking Context Examples */
.stacking-examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.example-card {
    background: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 1px solid #e1e8ed;
    cursor: pointer;
    transition: transform var(--transition-duration) ease, box-shadow var(--transition-duration) ease;
}

.example-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.example-card h3 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1rem;
}

/* Stacking Context Elements */
.context-parent {
    position: relative;
    width: 150px;
    height: 100px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    text-align: center;
    margin: 20px;
}

.context-child {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 80px;
    height: 40px;
    background: var(--secondary-color);
    color: white;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    z-index: 999;
}

.context-sibling {
    position: absolute;
    top: 60px;
    left: 100px;
    width: 100px;
    height: 60px;
    background: var(--success-color);
    color: white;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    z-index: 1;
}

/* Context Types */
.transform-context {
    transform: translateX(0); /* Creates stacking context */
    z-index: 0;
}

.opacity-context {
    opacity: 0.9; /* Creates stacking context */
}

.position-context {
    z-index: 0; /* With positioned element, creates stacking context */
}

/* Negative Z-Index Demo */
.negative-demo {
    position: relative;
    height: 200px;
    background: #ecf0f1;
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.background-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 100px;
    background: var(--warning-color);
    color: white;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    z-index: 0;
}

.negative-box {
    position: absolute;
    top: 30px;
    left: 50px;
    width: 150px;
    height: 80px;
    background: var(--secondary-color);
    color: white;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    text-align: center;
    z-index: -1;
    cursor: pointer;
    transition: transform var(--transition-duration) ease;
}

.negative-box:hover {
    transform: scale(1.05);
}

.positive-box {
    position: absolute;
    top: 70px;
    right: 50px;
    width: 150px;
    height: 80px;
    background: var(--success-color);
    color: white;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    text-align: center;
    z-index: 1;
    cursor: pointer;
    transition: transform var(--transition-duration) ease;
}

.positive-box:hover {
    transform: scale(1.05);
}

/* Info Panel */
.info-panel {
    background: #e8f4fd;
    border: 1px solid #b3d9ff;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-top: 2rem;
}

.info-panel h3 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
}

.info-panel ul {
    margin: 0;
    padding-left: 1.5rem;
}

.info-panel li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    color: #333;
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .demo-container {
        height: 250px;
    }
    
    .z-box {
        width: 100px;
        height: 60px;
        font-size: 0.7rem;
    }
    
    .box-blue { top: 40px; left: 20px; }
    .box-red { top: 60px; left: 70px; }
    .box-green { top: 80px; left: 120px; }
    .box-purple { top: 100px; left: 170px; }
    
    .stacking-examples {
        grid-template-columns: 1fr;
    }
    
    .context-parent {
        width: 120px;
        height: 80px;
        margin: 15px;
    }
    
    .context-child {
        width: 70px;
        height: 35px;
        font-size: 0.6rem;
    }
    
    .context-sibling {
        width: 90px;
        height: 50px;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .demo-container {
        height: 200px;
    }
    
    .z-box {
        width: 80px;
        height: 50px;
        font-size: 0.6rem;
    }
    
    .box-blue { top: 30px; left: 10px; }
    .box-red { top: 45px; left: 50px; }
    .box-green { top: 60px; left: 90px; }
    .box-purple { top: 75px; left: 130px; }
}