/* Stack Simulator — styling for the call stack visualizer */

@keyframes slideDown {
    from { transform: translateY(-40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-60px); opacity: 0; }
}

@keyframes overflowFlash {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
    50% { box-shadow: 0 0 24px 8px rgba(239, 68, 68, 0.6); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Module navigation hub */
.module-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.module-link {
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.module-link:hover {
    border-color: var(--primary);
    color: var(--text);
    background: var(--primary-soft);
}

.module-link.active {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
}

/* Badges */
.badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--success);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge.overflow {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.badge.underflow {
    color: #f59e0b;
    border-color: #f59e0b;
}

/* Memory layout overview */
.layout-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.layout-region {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layout-code { background: rgba(59, 130, 246, 0.18); border-color: #3b82f6; }
.layout-global { background: rgba(139, 92, 246, 0.18); border-color: #8b5cf6; }
.layout-heap { background: rgba(34, 197, 94, 0.14); border-color: #22c55e; }
.layout-stack { background: rgba(239, 68, 68, 0.16); border-color: #ef4444; }

.layout-region .arrow {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Status grid (Display panel) */
.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.status-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 0.7rem;
    text-align: center;
}

.status-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}

.status-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

/* Control actions */
.control-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.btn-info {
    background: #06b6d4;
    color: #fff;
}

.btn-info:hover {
    background: #0891b2;
    box-shadow: 0 4px 14px rgba(6, 182, 212, 0.4);
}

/* Stack layout */
.stack-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 860px) {
    .stack-layout {
        grid-template-columns: 1fr;
    }
}

.stack-visual {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 260px;
    max-height: 480px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.15);
}

.stack-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 3rem 1rem;
}

.stack-frame {
    background: linear-gradient(135deg, #312e81, #1e3a8a);
    border: 1px solid #4f46e5;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
    color: #e0e7ff;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stack-frame.top {
    border-color: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.stack-frame.push-in {
    animation: slideDown 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stack-frame.pop-out {
    animation: slideUp 0.5s ease forwards;
}

.stack-frame.overflow-flash {
    animation: overflowFlash 0.9s ease;
    border-color: var(--danger);
}

.frame-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.frame-fn {
    font-weight: 700;
    font-size: 0.85rem;
    color: #fbbf24;
}

.frame-size {
    background: rgba(255, 255, 255, 0.12);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
}

.frame-addr,
.frame-return {
    font-family: Consolas, monospace;
    font-size: 0.7rem;
    color: #94a3b8;
}

.frame-params {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.param {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.08rem 0.4rem;
    border-radius: 4px;
    font-size: 0.68rem;
}

/* Frame details / inspector */
.frame-details .muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.frame-inspector {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem;
    margin-top: 0.5rem;
}

.frame-inspector summary {
    cursor: pointer;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 0.4rem;
}

.inspector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.inspector-grid h4,
.inspector-cols h4 {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.inspector-grid code {
    font-size: 0.78rem;
    background: var(--bg-card-2);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: #a5b4fc;
}

.inspector-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.inspector-cols ul {
    list-style: none;
    font-size: 0.78rem;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.inspector-cols .muted {
    color: var(--text-muted);
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
}

.timeline .muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.timeline-step {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
}

.timeline-time {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    padding-top: 0.15rem;
}

.timeline-frames {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.timeline-frame {
    font-size: 0.78rem;
    color: var(--text);
    font-family: Consolas, monospace;
}
