/* =====================================================
   SPRING BOOT ENGINEERING PLATFORM
   animations.css — Diagram Animations & Transitions
   ===================================================== */

/* =====================================================
   BASE ANIMATION KEYFRAMES
   ===================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes ping {
  0% { transform: scale(1); opacity: 0.8; }
  75%, 100% { transform: scale(2); opacity: 0; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); animation-timing-function: ease-in; }
  50% { transform: translateY(-8px); animation-timing-function: ease-out; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

@keyframes dataFlow {
  0% { stroke-dashoffset: 100; opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes arrowMove {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(40px); opacity: 0; }
}

@keyframes nodeActivate {
  0% { box-shadow: 0 0 0 0 rgba(30, 64, 175, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(30, 64, 175, 0); }
  100% { box-shadow: 0 0 0 0 rgba(30, 64, 175, 0); }
}

@keyframes typingDots {
  0%, 20% { opacity: 0; }
  50% { opacity: 1; }
  80%, 100% { opacity: 0; }
}

@keyframes progressFill {
  from { width: 0%; }
  to { width: var(--target-width, 100%); }
}

@keyframes countUp {
  from { content: '0'; }
  to { content: attr(data-count); }
}

/* =====================================================
   JVM MEMORY DIAGRAM ANIMATIONS
   ===================================================== */

.jvm-diagram {
  font-family: var(--font-sans);
  width: 100%;
}

.jvm-region {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
  cursor: pointer;
}

.jvm-region:hover {
  filter: brightness(1.05);
}

.jvm-region.heap {
  background: linear-gradient(135deg, #DBEAFE, #EFF6FF);
  border: 2px solid #BFDBFE;
}

.jvm-region.stack {
  background: linear-gradient(135deg, #DCFCE7, #F0FDF4);
  border: 2px solid #BBF7D0;
}

.jvm-region.metaspace {
  background: linear-gradient(135deg, #EDE9FE, #F5F3FF);
  border: 2px solid #DDD6FE;
}

.jvm-region.code-cache {
  background: linear-gradient(135deg, #FEF3C7, #FFFBEB);
  border: 2px solid #FDE68A;
}

.jvm-region-title {
  font-weight: 700;
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.jvm-region-content {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: var(--leading-relaxed);
}

.memory-block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  margin: 2px;
  animation: fadeInUp 0.3s ease;
}

.memory-block.object {
  background: #BFDBFE;
  color: #1E40AF;
}

.memory-block.string {
  background: #BBF7D0;
  color: #166534;
}

.memory-block.array {
  background: #DDD6FE;
  color: #6D28D9;
}

.memory-block.garbage {
  background: #FEE2E2;
  color: #991B1B;
  text-decoration: line-through;
  opacity: 0.6;
}

/* GC animation */
.gc-sweep {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(220,252,231,0.8), transparent);
  animation: gcSweep 1.5s ease forwards;
}

@keyframes gcSweep {
  from { left: -100%; }
  to { left: 100%; }
}

/* =====================================================
   THREAD DIAGRAM ANIMATIONS
   ===================================================== */

.thread-diagram {
  font-family: var(--font-sans);
}

.thread-lane {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.thread-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  width: 80px;
  flex-shrink: 0;
}

.thread-timeline {
  flex: 1;
  height: 32px;
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.thread-segment {
  position: absolute;
  top: 4px;
  height: 24px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
  padding: 0 4px;
  transition: all var(--transition-base);
}

.thread-segment.running {
  background: linear-gradient(90deg, #BBF7D0, #86EFAC);
  color: #166534;
  border: 1px solid #86EFAC;
}

.thread-segment.blocked {
  background: linear-gradient(90deg, #FEE2E2, #FECACA);
  color: #991B1B;
  border: 1px solid #FECACA;
}

.thread-segment.waiting {
  background: linear-gradient(90deg, #FEF3C7, #FDE68A);
  color: #92400E;
  border: 1px solid #FDE68A;
}

.thread-segment.sleeping {
  background: linear-gradient(90deg, #EDE9FE, #DDD6FE);
  color: #6D28D9;
  border: 1px solid #DDD6FE;
}

/* Active thread pulse */
.thread-active-indicator {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #16A34A;
  position: relative;
}

.thread-active-indicator::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: #16A34A;
  border-radius: var(--radius-full);
  animation: ping 1.5s cubic-bezier(0,0,0.2,1) infinite;
}

/* =====================================================
   HTTP REQUEST LIFECYCLE DIAGRAM
   ===================================================== */

.request-flow {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: var(--space-4) 0;
}

.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.flow-node-box {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  min-width: 90px;
  transition: all var(--transition-base);
  cursor: pointer;
}

.flow-node-box:hover,
.flow-node-box.active {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.15);
}

.flow-node-box.active {
  animation: nodeActivate 1s ease infinite;
}

.flow-node-icon {
  font-size: var(--text-xl);
  margin-bottom: var(--space-1);
}

.flow-node-name {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.flow-node-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--color-text-muted);
}

.flow-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
  padding: 0 var(--space-2);
}

.flow-arrow-line {
  width: 40px;
  height: 2px;
  background: var(--color-border-strong);
  position: relative;
  overflow: hidden;
}

.flow-arrow-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
}

.flow-arrow-line.animate::after {
  animation: arrowFlow 1s ease forwards;
}

@keyframes arrowFlow {
  from { left: -100%; }
  to { left: 100%; }
}

.flow-arrow-head {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-left: 32px;
  margin-top: -8px;
}

.flow-arrow-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* =====================================================
   FAILURE SIMULATOR
   ===================================================== */

.simulator {
  background: #1E1E2E;
  border: 1px solid #313244;
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin: var(--space-8) 0;
}

.simulator-header {
  background: #181825;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #313244;
}

.simulator-title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #F38BA8;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.simulator-title::before {
  content: '⚡';
}

.simulator-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #6C7086;
}

.status-dot.running {
  background: #A6E3A1;
  animation: pulse 1s ease infinite;
}

.status-dot.error {
  background: #F38BA8;
  animation: pulse 0.5s ease infinite;
}

.status-text {
  color: #6C7086;
  font-size: var(--text-xs);
}

.simulator-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.simulator-controls {
  padding: var(--space-5) var(--space-6);
  border-right: 1px solid #313244;
}

.simulator-output {
  padding: var(--space-5) var(--space-6);
}

.simulator-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  color: #6C7086;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-3);
}

.control-group {
  margin-bottom: var(--space-4);
}

.control-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: #BAC2DE;
  margin-bottom: var(--space-2);
  display: flex;
  justify-content: space-between;
}

.control-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  border-radius: var(--radius-full);
  background: #45475A;
  outline: none;
  cursor: pointer;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: #89B4FA;
  cursor: pointer;
}

.simulator-log {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: #A6E3A1;
  height: 200px;
  overflow-y: auto;
}

.simulator-log::-webkit-scrollbar {
  width: 3px;
}

.simulator-log::-webkit-scrollbar-track {
  background: transparent;
}

.simulator-log::-webkit-scrollbar-thumb {
  background: #45475A;
}

.log-line {
  display: flex;
  gap: var(--space-3);
  animation: fadeIn 0.2s ease;
}

.log-timestamp {
  color: #6C7086;
  flex-shrink: 0;
}

.log-level {
  flex-shrink: 0;
  font-weight: 700;
}

.log-level.info { color: #89B4FA; }
.log-level.warn { color: #F9E2AF; }
.log-level.error { color: #F38BA8; }
.log-level.debug { color: #CBA6F7; }

@media (max-width: 640px) {
  .simulator-body {
    grid-template-columns: 1fr;
  }

  .simulator-controls {
    border-right: none;
    border-bottom: 1px solid #313244;
  }
}

/* =====================================================
   GENERAL ANIMATION UTILITIES
   ===================================================== */

.animate-fade-in {
  animation: fadeIn 0.4s ease;
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s ease;
}

.animate-pulse {
  animation: pulse 2s ease infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Intersection Observer reveal */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* =====================================================
   LOADING SKELETON
   ===================================================== */

.skeleton {
  background: linear-gradient(90deg, var(--color-bg-alt) 25%, var(--color-border) 50%, var(--color-bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  border-radius: var(--radius-sm);
}

.skeleton-heading {
  height: 2em;
  width: 60%;
  margin-bottom: 1em;
}
