/*********************************************
 * GARBAGE COLLECTION ANIMATIONS
 * Dedicated stylesheet for GC visualizations in Lesson 7
 *********************************************/

/* GC Animation Container */
.gc-animation {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px auto;
    padding: 20px;
    font-size: 0.8em;
}

/* Memory Areas */
.gc-memory-area {
    border: 3px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin: 10px;
    min-height: 200px;
    position: relative;
}

.gc-memory-area-label {
    position: absolute;
    top: -12px;
    left: 10px;
    background: white;
    padding: 0 8px;
    font-weight: bold;
    font-size: 0.9em;
    color: #7F52FF;
}

.gc-stack {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-color: #1976d2;
    width: 180px;
}

.gc-heap {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    border-color: #7b1fa2;
    min-width: 400px;
}

/* Objects */
.gc-object {
    display: inline-block;
    border: 2px solid #333;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 8px;
    font-weight: 600;
    position: relative;
    transition: all 0.4s ease;
    min-width: 60px;
    text-align: center;
}

.gc-object-label {
    font-size: 0.95em;
    color: #333;
}

.gc-object-age {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff9800;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-weight: bold;
}

/* Object States */
.gc-live {
    background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
    border-color: #2e7d32;
    color: white;
}

.gc-dead {
    background: linear-gradient(135deg, #bdbdbd 0%, #e0e0e0 100%);
    border-color: #757575;
    color: #424242;
    opacity: 0.6;
}

.gc-marked {
    background: linear-gradient(135deg, #2196f3 0%, #64b5f6 100%);
    border-color: #1565c0;
    color: white;
    box-shadow: 0 0 12px rgba(33, 150, 243, 0.5);
}

.gc-unreachable {
    background: linear-gradient(135deg, #f44336 0%, #e57373 100%);
    border-color: #c62828;
    color: white;
}

.gc-swept {
    opacity: 0;
    transform: scale(0.5);
}

/* Reference Arrows */
.gc-reference-arrow {
    stroke: #333;
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
}

.gc-reference-arrow.active {
    stroke: #4caf50;
    stroke-width: 3;
}

.gc-reference-arrow.broken {
    stroke: #f44336;
    stroke-dasharray: 5, 5;
    opacity: 0.4;
}

/* Stack Variables */
.gc-stack-var {
    background: #fff;
    border: 2px solid #1976d2;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 6px 0;
    font-size: 0.9em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gc-stack-var-name {
    font-weight: bold;
    color: #1565c0;
}

.gc-stack-var-ref {
    color: #7b1fa2;
    font-family: monospace;
}

/* Generational GC Areas */
.gc-young-gen {
    border: 3px solid #ff9800;
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    padding: 15px;
    margin: 10px;
    border-radius: 8px;
    display: flex;
    gap: 10px;
}

.gc-old-gen {
    border: 3px solid #795548;
    background: linear-gradient(135deg, #efebe9 0%, #d7ccc8 100%);
    padding: 15px;
    margin: 10px;
    border-radius: 8px;
}

.gc-eden {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #4caf50;
    padding: 10px;
    border-radius: 6px;
    flex: 2;
    min-height: 140px;
    position: relative;
}

.gc-survivor {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #2196f3;
    padding: 10px;
    border-radius: 6px;
    flex: 1;
    min-height: 140px;
    position: relative;
}

.gc-generation-label {
    position: absolute;
    top: -10px;
    left: 10px;
    background: white;
    padding: 2px 8px;
    font-weight: bold;
    font-size: 0.85em;
    border-radius: 3px;
}

/* GC Event Indicator */
.gc-event {
    background: #ff5722;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    display: inline-block;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(255, 87, 34, 0.4);
}

.gc-event.minor {
    background: #ff9800;
}

.gc-event.major {
    background: #f44336;
}

/* Memory Compaction */
.gc-memory-bar {
    display: flex;
    align-items: center;
    border: 3px solid #333;
    border-radius: 8px;
    padding: 5px;
    background: white;
    min-height: 80px;
    margin: 15px 0;
    position: relative;
}

.gc-memory-block {
    padding: 15px 20px;
    margin: 2px;
    border-radius: 4px;
    font-weight: bold;
    transition: all 0.6s ease;
    position: relative;
}

.gc-memory-block.allocated {
    background: #7F52FF;
    color: white;
    border: 2px solid #5a37b8;
}

.gc-memory-block.free {
    background: repeating-linear-gradient(
        45deg,
        #f5f5f5,
        #f5f5f5 10px,
        #e0e0e0 10px,
        #e0e0e0 20px
    );
    border: 2px dashed #999;
    color: #666;
}

.gc-memory-block.compacting {
    animation: slide-left 0.6s ease;
}

@keyframes slide-left {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-100px);
    }
}

/* Mark-and-Sweep Graph */
.gc-object-graph {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    padding: 30px;
    position: relative;
}

.gc-root {
    background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
    border-color: #f57c00;
    font-weight: bold;
}

.gc-root::before {
    content: "⚡";
    margin-right: 5px;
}

/* Helper Text */
.gc-note {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
    margin: 10px 0;
    padding: 10px;
    background: #f5f5f5;
    border-left: 4px solid #7F52FF;
    border-radius: 4px;
}

.gc-highlight {
    color: #7F52FF;
    font-weight: bold;
}

/* SVG Arrow Marker */
svg.gc-arrows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gc-animation {
        flex-direction: column;
    }

    .gc-heap {
        min-width: 300px;
    }

    .gc-young-gen {
        flex-direction: column;
    }
}
