/* ==========================================================================
   CSS Animation Showcase - Main Styles
   Inspired by STRML.net
   ========================================================================== */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --border: #2a2a3a;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background Canvas */
#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.3;
  pointer-events: none;
}

/* Code Panel */
.code-panel {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 400px;
  max-height: calc(100vh - 200px);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  z-index: 10;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.file-name {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.code-status {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent);
  color: white;
  font-weight: 500;
}

.code-content {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-y: auto;
  max-height: 400px;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-content .comment {
  color: #6b7280;
}

.code-content .selector {
  color: #f472b6;
}

.code-content .property {
  color: #93c5fd;
}

.code-content .value {
  color: #a5f3fc;
}

.code-progress {
  height: 3px;
  background: var(--bg-tertiary);
}

.progress-bar {
  height: 100%;
  background: var(--gradient-1);
  width: 0%;
  transition: width 0.1s linear;
}

/* Demo Stage */
.demo-stage {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 0 60px rgba(99, 102, 241, 0.1);
}

.stage-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-element {
  width: 120px;
  height: 120px;
  background: var(--gradient-1);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 40px rgba(99, 102, 241, 0.3);
  position: relative;
}

.demo-text {
  font-size: 2rem;
  font-weight: 700;
  color: white;
  font-family: var(--font-mono);
}

/* Demo Controls */
.demo-controls {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  z-index: 10;
}

.control-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-btn svg {
  width: 18px;
  height: 18px;
}

.control-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.control-btn.playing {
  background: var(--accent);
  border-color: var(--accent);
}

/* Demo Selector */
.demo-selector {
  position: fixed;
  bottom: 40px;
  right: 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 10;
}

.selector-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.demo-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.demo-option {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.demo-option:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.demo-option.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ==========================================================================
   Animation States - Applied by JavaScript
   ========================================================================== */

/* Bounce */
.demo-element.bounce {
  animation: bounce 0.8s ease;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-60px) scale(0.9); }
  50% { transform: translateY(0) scale(1.05); }
  70% { transform: translateY(-30px) scale(0.98); }
}

/* Fade In */
.demo-element.fade {
  animation: fadeIn 1s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide In */
.demo-element.slide {
  animation: slideIn 0.8s ease forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-100px) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(0);
  }
}

/* Scale */
.demo-element.scale {
  animation: scale 1.2s ease forwards;
}

@keyframes scale {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Rotate */
.demo-element.rotate {
  animation: rotate 1s ease forwards;
  transform-origin: center;
}

@keyframes rotate {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

/* Combined - Multi-step animation */
.demo-element.combine {
  animation: combined 2s ease forwards;
}

@keyframes combined {
  0% {
    opacity: 0;
    transform: translateY(100px) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translateY(-50px) scale(0.8);
  }
  40% {
    transform: translateY(0) scale(1.1);
  }
  60% {
    transform: translateY(-30px) scale(0.95);
  }
  80% {
    transform: translateY(0) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Pulse Animation for Demo 2 */
.demo-element.pulse {
  animation: pulseDemo 2s ease-in-out infinite;
}

@keyframes pulseDemo {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 10px 60px rgba(99, 102, 241, 0.5);
  }
}

/* Loading Spinner Demo */
.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Pulse Button Demo */
.pulse-btn {
  position: relative;
  padding: 16px 32px;
  background: var(--gradient-1);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  overflow: visible;
}

.pulse-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

/* Flip Card Demo */
.flip-card {
  width: 140px;
  height: 180px;
  perspective: 1000px;
  cursor: pointer;
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s;
  transform-style: preserve-3d;
}

.flip-card:hover .flip-inner {
  transform: rotateY(180deg);
}

.flip-front,
.flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.flip-front {
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  color: var(--text-primary);
}

.flip-back {
  background: var(--gradient-1);
  color: white;
  transform: rotateY(180deg);
}

/* Glow Text Demo */
.glow-text-demo {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  animation: glowDemo 2s ease-in-out infinite;
}

@keyframes glowDemo {
  0%, 100% {
    text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
  }
  50% {
    text-shadow: 0 0 20px var(--accent), 0 0 40px var(--accent), 0 0 60px var(--accent);
  }
}

/* Blob Demo */
.blob-demo {
  width: 150px;
  height: 150px;
  background: var(--gradient-1);
  animation: morphDemo 6s ease-in-out infinite;
}

@keyframes morphDemo {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  50% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .code-panel {
    width: 320px;
    max-height: 300px;
  }

  .demo-stage {
    width: 300px;
    height: 300px;
  }
}

@media (max-width: 700px) {
  .code-panel {
    position: relative;
    width: 100%;
    max-height: 200px;
    margin: 20px;
  }

  .demo-stage {
    position: relative;
    width: calc(100% - 40px);
    height: 300px;
    margin: 20px;
    transform: none;
    left: auto;
    top: auto;
  }

  .demo-selector {
    position: relative;
    right: auto;
    bottom: auto;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px;
  }

  .demo-controls {
    position: relative;
    bottom: auto;
    padding: 20px;
  }
}

/* Utility Classes */
.gradient-text {
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Selection */
::selection {
  background: var(--accent);
  color: white;
}
