:root {
    --primary: #1a1a1a;
    --secondary: #f5f5f5;
    --accent: #3b82f6;
    --layer1: #242424;
    --layer2: #2a2a2a;
    --encoder: #3b82f6;
    --decoder: #10b981;
    --attention: #8b5cf6;
    --feedforward: #f59e0b;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--primary);
    color: var(--secondary);
    overflow: hidden;
}

.font-geist-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#transformerCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    transition: opacity 0.5s ease;
}

#loading-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--primary);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

#loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Transformer logo animation */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

#transformerLogo {
    animation: pulse 2s infinite ease-in-out;
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background-color: rgba(42, 42, 42, 0.9);
    backdrop-filter: blur(8px);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 200px;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    transform: translate(-50%, -110%);
}

.tooltip:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(42, 42, 42, 0.9);
}

/* Component highlight */
.highlight-pulse {
    animation: highlight-pulse 2s infinite;
}

@keyframes highlight-pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

/* Data token animation */
.data-token {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--accent);
    filter: blur(2px);
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0.9;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

/* Animation for component info panel */
@keyframes fadeScale {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#componentInfo {
    animation: fadeScale 0.3s ease forwards;
}

/* Data visualization panel slide-in animation */
@keyframes slideInRight {
    0% { transform: translate(100%, -50%); opacity: 0; }
    100% { transform: translate(0, -50%); opacity: 1; }
}

#dataVisualization.visible {
    animation: slideInRight 0.5s ease forwards;
    display: block !important;
    transform: translateX(0) translateY(-50%);
    opacity: 1;
}

/* Encoding flow animation effects */
.active-component {
    filter: drop-shadow(0 0 8px var(--accent));
}

.token-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 1) 0%, rgba(59, 130, 246, 0.4) 70%, rgba(59, 130, 246, 0) 100%);
    pointer-events: none;
    z-index: 10;
}

.pulse-animation {
    animation: pulse-glow 1.5s ease infinite;
}

@keyframes pulse-glow {
    0% { filter: brightness(1) drop-shadow(0 0 2px rgba(59, 130, 246, 0.5)); }
    50% { filter: brightness(1.2) drop-shadow(0 0 8px rgba(59, 130, 246, 0.8)); }
    100% { filter: brightness(1) drop-shadow(0 0 2px rgba(59, 130, 246, 0.5)); }
}

/* Data text highlighting animation */
@keyframes highlightText {
    0% { background-color: transparent; }
    50% { background-color: rgba(59, 130, 246, 0.2); }
    100% { background-color: transparent; }
}

.highlight-text {
    animation: highlightText 1.5s ease;
    border-radius: 3px;
    padding: 1px 2px;
}

/* Data flow visualization */
#transformationVisualizer {
    position: relative;
    overflow: hidden;
}

/* Attention matrix visualization */
.attention-matrix {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 2px;
    width: 100%;
    height: 100%;
}

.matrix-cell {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-family: monospace;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.matrix-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--attention);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.matrix-cell.active::before {
    opacity: 0.3;
}

.matrix-cell.highlighted {
    background-color: rgba(139, 92, 246, 0.3);
}

/* Token visualization */
.token-block {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(59, 130, 246, 0.2);
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 2px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.token-block.active {
    background-color: rgba(59, 130, 246, 0.4);
    transform: scale(1.05);
}

.token-block.encoder {
    background-color: rgba(59, 130, 246, 0.2);
}

.token-block.decoder {
    background-color: rgba(16, 185, 129, 0.2);
}

/* Vector visualization */
.vector-viz {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1px;
    height: 30px;
    width: 100%;
}

.vector-element {
    flex: 1;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.1);
    position: relative;
    border-radius: 2px;
    overflow: hidden;
}

.vector-element::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--encoder);
    transition: height 0.5s ease;
}

.vector-element.encoder::before {
    background-color: var(--encoder);
}

.vector-element.decoder::before {
    background-color: var(--decoder);
}

.vector-element.attention::before {
    background-color: var(--attention);
}

.vector-flow-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--accent);
    transform: translateY(-100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.vector-flow-indicator.active {
    opacity: 1;
    animation: flowDown 1s ease-in-out infinite;
}

@keyframes flowDown {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(40px); }
}

/* Attention flow lines */
.attention-line {
    position: absolute;
    background-color: rgba(139, 92, 246, 0.5);
    height: 1px;
    transform-origin: 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.attention-line.active {
    opacity: 1;
}

/* Flow visualization elements */
.flow-step {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.flow-step.active {
    opacity: 1;
}

.flow-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--layer1);
    font-size: 10px;
    font-weight: bold;
}

.flow-step-number.completed {
    background-color: var(--accent);
    color: white;
}

.flow-step-content {
    flex: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #componentInfo {
        width: 85%;
    }
    
    #controlPanel {
        padding: 8px 12px;
        flex-direction: column;
    }
    
    #controlPanel button {
        font-size: 12px;
        padding: 6px 10px;
        margin-bottom: 8px;
    }
    
    #controlPanel .flex.space-x-4 {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    #interactionHelp {
        display: none;
    }
    
    #dataVisualization {
        width: 90%;
        left: 5%;
        right: auto;
        transform: translateY(-50%);
    }
}

/* New animation for data flow path */
.data-flow-path {
    stroke-dasharray: 10;
    animation: flowDash 1s linear infinite;
}

@keyframes flowDash {
    to {
        stroke-dashoffset: -20;
    }
}

/* Animation for attention scores */
@keyframes scoreHighlight {
    0% { background-color: rgba(139, 92, 246, 0.1); }
    50% { background-color: rgba(139, 92, 246, 0.4); }
    100% { background-color: rgba(139, 92, 246, 0.1); }
}

.score-highlight {
    animation: scoreHighlight 2s ease-in-out;
}

/* Vector transformation animations */
.vector-transform {
    animation: vectorTransform 1.5s ease-in-out;
}

@keyframes vectorTransform {
    0% { transform: translateY(0); opacity: 1; }
    40% { transform: translateY(-10px); opacity: 0.7; }
    60% { transform: translateY(5px); opacity: 0.9; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Node connection visualization */
.node-connection {
    position: absolute;
    height: 2px;
    transform-origin: 0 0;
    background: linear-gradient(90deg, var(--encoder), var(--attention));
    opacity: 0;
    transition: opacity 0.5s ease;
}

.node-connection.active {
    opacity: 0.7;
}

.node-connection.encoder-connection {
    background: linear-gradient(90deg, var(--encoder), var(--attention));
}

.node-connection.decoder-connection {
    background: linear-gradient(90deg, var(--attention), var(--decoder));
}

.node-connection.attention-connection {
    background: linear-gradient(90deg, var(--encoder), var(--decoder));
}

/* Data tokens */
.data-token-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.data-token-viz {
    padding: 2px 5px;
    border-radius: 3px;
    background-color: rgba(59, 130, 246, 0.2);
    font-size: 10px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.data-token-viz.active {
    background-color: rgba(59, 130, 246, 0.5);
}

.data-token-viz.encoder {
    background-color: rgba(59, 130, 246, 0.2);
}

.data-token-viz.decoder {
    background-color: rgba(16, 185, 129, 0.2);
}
