/* Neural SUBLEQ Computer - Shared Demo Styles (Light Theme) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fb;
    color: #374151;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}

.page-layout {
    display: flex;
    gap: 24px;
    max-width: 1280px;
    width: 100%;
    align-items: flex-start;
}

header {
    text-align: center;
    margin-bottom: 24px;
    width: 100%;
    max-width: 1280px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
}

h1 a {
    color: inherit;
    text-decoration: none;
}

h1 a:hover {
    color: #6366f1;
}

.back-link {
    display: inline-block;
    font-size: 12px;
    color: #6b7280;
    text-decoration: none;
    margin-bottom: 4px;
}

.back-link:hover {
    color: #6366f1;
}

.subtitle {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 4px;
    font-weight: 400;
}

/* ---- Network Visualization Panel ---- */
.network-panel {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.panel-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

/* Architecture diagram */
.arch-layers {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.arch-layer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.arch-layer.active {
    border-color: #6366f1;
    background: #eef2ff;
}

.arch-layer .layer-glow {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, rgba(99,102,241,0.08) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.15s;
}

.arch-layer.active .layer-glow {
    opacity: 1;
}

.layer-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    color: #6366f1;
    width: 24px;
    flex-shrink: 0;
}

.layer-name {
    font-size: 0.7rem;
    color: #6b7280;
    flex: 1;
}

.arch-layer.active .layer-name {
    color: #111827;
    font-weight: 500;
}


.arch-connector {
    width: 2px;
    height: 3px;
    background: #d1d5db;
    margin-left: 19px;
}

/* State tensor heatmap */
.heatmap-container {
    position: relative;
}

#stateCanvasScratch, #stateCanvasData {
    image-rendering: pixelated;
    background: #f3f4f6;
    display: block;
    border: 1px solid #e5e7eb;
}

.heatmap-labels {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 6px;
}

.heatmap-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
}

.heatmap-swatch {
    width: 10px;
    height: 6px;
    border-radius: 2px;
    flex-shrink: 0;
}

.heatmap-label-text {
    color: #9ca3af;
}

/* Memory inspector */
.mem-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.mem-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.mem-label {
    font-size: 0.65rem;
    color: #9ca3af;
}

.mem-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

.mem-value.changed {
    color: #d97706;
    transition: color 0.3s;
}

/* Step info */
.step-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    gap: 8px;
}

.step-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 8px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.step-stat-label {
    font-size: 0.6rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.step-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

/* ---- Main Content Panel ---- */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #6b7280;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    flex-shrink: 0;
}

.status-dot.loading {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

.status-dot.ready {
    background: #10b981;
}

.status-dot.running {
    background: #6366f1;
    animation: pulse 0.5s infinite;
}

.status-dot.error {
    background: #ef4444;
}

.status-dot.done {
    background: #10b981;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Buttons */
.btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: #6366f1;
    color: #fff;
    box-shadow: 0 1px 3px rgba(99,102,241,0.3);
}

.btn-primary:hover {
    background: #4f46e5;
    box-shadow: 0 2px 6px rgba(99,102,241,0.4);
}

.btn-secondary {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #6366f1;
    color: #6366f1;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Info panel */
.info-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.info-panel h3 {
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-panel p {
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.65;
    margin-bottom: 6px;
}

.info-panel strong {
    color: #374151;
    font-weight: 600;
}

.info-panel code {
    font-family: 'JetBrains Mono', monospace;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #6366f1;
}

/* Overlay */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    z-index: 10;
}

.overlay-text {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
}

.hidden {
    display: none;
}

/* ---- Code Editor / Source View ---- */
.code-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.code-header-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.code-body {
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.7;
}

.code-line {
    display: flex;
    padding: 0 16px;
    min-height: 1.7em;
    transition: background 0.15s;
}

.code-line:hover {
    background: #f3f4f6;
}

.code-line.active {
    background: #eef2ff;
    border-left: 3px solid #6366f1;
    padding-left: 13px;
}

.code-line.executed {
    background: #f0fdf4;
}

.code-lineno {
    width: 36px;
    text-align: right;
    padding-right: 12px;
    color: #d1d5db;
    user-select: none;
    flex-shrink: 0;
}

.code-text {
    flex: 1;
    white-space: pre;
    color: #374151;
}

/* Syntax highlighting */
.code-text .kw { color: #7c3aed; }
.code-text .fn { color: #2563eb; }
.code-text .num { color: #d97706; }
.code-text .op { color: #0891b2; }
.code-text .str { color: #059669; }
.code-text .cmt { color: #9ca3af; font-style: italic; }
.code-text .type { color: #b45309; }

/* Variable watch panel */
.var-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.var-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.var-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #6366f1;
}

.var-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

.var-val.changed {
    color: #d97706;
    transition: color 0.3s;
}

/* Controls bar */
.controls-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.controls-bar select {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.controls-bar select:hover {
    border-color: #6366f1;
}

/* ---- Sorting Visualization ---- */
.sort-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    height: 200px;
    padding: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sort-bar {
    flex: 1;
    max-width: 60px;
    background: #6366f1;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease, background 0.3s ease;
    position: relative;
}

.sort-bar.comparing {
    background: #f59e0b;
}

.sort-bar.swapping {
    background: #ef4444;
}

.sort-bar.sorted {
    background: #10b981;
}

.sort-bar-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
}

/* ---- Game of Life Grid ---- */
.life-grid {
    display: grid;
    gap: 2px;
    background: #e5e7eb;
    border-radius: 8px;
    padding: 2px;
    margin: 0 auto;
}

.life-cell {
    aspect-ratio: 1;
    background: #fff;
    border-radius: 3px;
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.life-cell.alive {
    background: #6366f1;
    box-shadow: 0 0 6px rgba(99,102,241,0.25);
}

.life-cell.born {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16,185,129,0.25);
}

.life-cell.dying {
    background: #c7d2fe;
}

/* ---- REPL ---- */
.repl-editor {
    width: 100%;
    min-height: 200px;
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    resize: vertical;
    tab-size: 4;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.repl-editor:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.repl-output {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: #059669;
    min-height: 60px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.repl-output .error {
    color: #ef4444;
}

/* Stats bar (generic) */
.stats-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 0.65rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

/* Responsive: on narrow screens, stack vertically with demo content first */
@media (max-width: 860px) {
    .page-layout {
        flex-direction: column;
    }
    .network-panel {
        width: 100%;
        order: 99;
    }
    .main-panel {
        order: 1;
        width: 100%;
    }
}

/* Mobile: iPhone-class screens */
@media (max-width: 500px) {
    body { padding: 8px 10px 60px; }
    header { margin-bottom: 12px; }
    h1 { font-size: 1.15rem; }
    .subtitle { font-size: 0.75rem; }
    .page-layout { gap: 12px; }
    .panel { padding: 10px; }
    .code-body { max-height: 200px; font-size: 0.65rem; }
    .code-lineno { width: 20px; font-size: 0.55rem; }
    .info-panel { font-size: 0.75rem; }
    .info-panel h3 { font-size: 0.85rem; }
    .btn { padding: 8px 14px; font-size: 0.75rem; min-height: 44px; }
    input[type="range"] { min-height: 44px; }
}
