/* animations.css - Styles for CSS Animations Example Page */

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f8f9fa;
  color: #222;
  margin: 0;
  padding: 0;
}

.back-btn {
  display: inline-block;
  margin-top: 24px;
  padding: 10px 22px;
  background: linear-gradient(90deg, #3498db 60%, #8e44ad 100%);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  box-shadow: 0 2px 8px 0 rgba(52, 152, 219, 0.12);
  transition: color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.back-btn:hover {
  color: #ffd200;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px 0 rgba(52, 152, 219, 0.2);
}

main {
  max-width: 900px;
  margin: 2rem auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(52,152,219,0.08);
  padding: 2rem 2.5vw;
}
header h1 {
  margin-top: 0;
  color: #3498db;
  font-size: 2.2rem;
  letter-spacing: 0.02em;
}
section.theory {
  background: #f0f6ff;
  border-left: 4px solid #3498db;
  padding: 1.2rem 1.5rem;
  margin-bottom: 2rem;
  border-radius: 8px;
}
section.code-demo {
  margin-bottom: 2rem;
}
.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}
.demo-card {
  background: #f9f9fb;
  border: 1px solid #e0e6ed;
  border-radius: 8px;
  padding: 1rem 1rem 1.5rem 1rem;
  box-shadow: 0 2px 8px rgba(52,152,219,0.04);
  margin-bottom: 1rem;
  transition: box-shadow 0.3s, transform 0.3s;
}
.demo-card:hover {
  box-shadow: 0 6px 24px 0 #8e44ad33;
  transform: translateY(-4px) scale(1.03);
}
.demo-card h3 {
  margin-top: 0;
  color: #8e44ad;
  font-size: 1.1rem;
}
.box {
  width: 120px;
  height: 48px;
  background: #3498db;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin: 0.5rem 0 1rem 0;
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(52,152,219,0.08);
  transition: background-color 0.3s, transform 0.3s;
}
.box:hover {
  background: #8e44ad;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52,152,219,0.2);
}

.img-demo-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0 1rem 0;
}
.img-anim-demo {
  width: 100%;
  max-width: 220px;
  border-radius: 10px;
  box-shadow: 0 2px 12px 0 #3498db22;
}
pre {
  background: #222;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  font-size: 0.98rem;
  overflow-x: auto;
  margin: 0.5rem 0 0 0;
  border: 1.5px solid #8e44ad22;
  box-shadow: 0 1px 4px 0 #8e44ad11;
}
.note {
  color: #8e44ad;
  font-size: 1rem;
  margin-top: 1.2rem;
  font-style: italic;
}
@media (max-width: 600px) {
  main {
    padding: 1rem 2vw;
  }
  .demo-grid {
    grid-template-columns: 1fr;
  }
  .box {
    width: 100%;
    min-width: 0;
  }
}

/* Animations for the examples */
@keyframes bounce {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-40px); }
  100% { transform: translateY(0); }
}
.anim-bounce {
  animation: bounce 1s ease-in-out infinite;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.anim-delay {
  animation: fadeIn 1.2s ease 1s forwards;
}

@keyframes colorLoop {
  0%   { background: #3498db; }
  50%  { background: #8e44ad; }
  100% { background: #3498db; }
}
.anim-iterate {
  animation: colorLoop 1.2s linear 0s 3;
}

@keyframes slideX {
  from { transform: translateX(0); }
  to   { transform: translateX(60px); }
}
.anim-direction {
  animation: slideX 1.1s cubic-bezier(.4,1.6,.4,1) infinite alternate;
}

@keyframes grow {
  from { width: 120px; }
  to   { width: 220px; }
}
.anim-fill {
  animation: grow 1.2s ease-in 0s 1 forwards;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 #8e44ad44; }
  50% { box-shadow: 0 0 16px 8px #8e44ad44; }
}
.anim-multi {
  animation: spin 1.2s linear infinite, pulse 1.2s ease-in-out infinite;
}

@keyframes imgPop {
  0%   { transform: scale(1) rotate(0deg); }
  50%  { transform: scale(1.13) rotate(-4deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.img-anim-demo {
  animation: imgPop 1.4s cubic-bezier(.4,1.6,.4,1) infinite;
}

/* Pendulum Animation */
.pendulum-demo {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: 140px;
  margin-bottom: 1rem;
}
.pendulum-arm {
  width: 6px;
  height: 90px;
  background: #8e44ad;
  margin: 0 auto;
  border-radius: 3px;
  transform-origin: top center;
  animation: swing 2s cubic-bezier(.4,1.6,.4,1) infinite;
  position: relative;
}
@keyframes swing {
  0%   { transform: rotate(-30deg); }
  50%  { transform: rotate(30deg); }
  100% { transform: rotate(-30deg); }
}
.pendulum-bob {
  width: 32px;
  height: 32px;
  background: #ffd200;
  border-radius: 50%;
  box-shadow: 0 4px 16px #8e44ad44;
  border: 3px solid #8e44ad;
  position: absolute;
  bottom: -16px; /* Hangs the bob off the arm by half its height */
  left: 50%;
  transform: translateX(-50%);
}

/* Loader Dots Animation */
.loader-demo {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 48px;
  margin-bottom: 1rem;
}
.dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin: 0 4px;
  background: #3498db;
  border-radius: 50%;
  animation: dotFlare 1.2s infinite both;
}
@keyframes dotFlare {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}
.dot2 { animation-delay: 0.2s; }
.dot3 { animation-delay: 0.4s; }

/* Card Flip Animation */
.flip-card {
  width: 120px;
  height: 60px;
  perspective: 600px;
  margin: 0 auto 1rem auto;
}
.flip-inner {
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(.4,1.6,.4,1);
  transform-style: preserve-3d;
  position: relative;
}
.flip-card:hover .flip-inner {
  transform: rotateY(180deg);
}
.flip-front, .flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
  border-radius: 8px;
}
.flip-front {
  background: #3498db;
  color: #fff;
}
.flip-back {
  background: #ffd200;
  color: #222;
  transform: rotateY(180deg);
}

@media (prefers-reduced-motion: reduce) {
  /* Stop all animations and transitions */
  .anim-bounce,
  .anim-delay,
  .anim-iterate,
  .anim-direction,
  .anim-fill,
  .anim-multi,
  .img-anim-demo,
  .pendulum-arm,
  .dot {
    animation: none;
  }

  .back-btn,
  .demo-card,
  .box,
  .flip-inner {
    transition: none;
  }

  /* Reset hover states that rely on transforms */
  .back-btn:hover,
  .demo-card:hover,
  .box:hover {
    transform: none;
  }
}
