/* Basic page layout */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 28px 20px;
  background-color: #f1f5f9;
  color: #17233a;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

header, main, footer {
  max-width: 850px;
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-size: 2rem;
}

header p {
  margin: 4px 0 24px;
}

section {
  margin-bottom: 24px;
  padding: 24px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #ffffff;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

section p {
  margin: 0 0 20px;
}

.demo-area {
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f1f5f9;
  border-radius: 6px;
}

.transition-box, .moving-box, .hover-animation-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  color: #ffffff;
  font-weight: bold;
  text-align: center;
}

/* Requirement 1: timed transitions triggered by hover. */
.transition-box {
  border: 4px solid transparent;
  border-radius: 6px;
  background-color: #1d4ed8;
  transition: background-color 1s ease, border-color 1s ease,
              transform 1s ease;
}

.transition-box:hover, .transition-box:focus {
  background-color: #7e22ce;
  border-color: #17233a;
  transform: scale(1.2);
}

/* Requirement 2a: a keyframe animation that runs continuously on load. */
.animation-track {
  position: relative;
  height: 170px;
  padding: 0;
  background-color: #f1f5f9;
  border-radius: 6px;
}

.moving-box {
  position: absolute;
  top: 25px;
  left: 0;
  border-radius: 6px;
  background-color: #0f766e;
  animation: move-across 3s ease-in-out infinite alternate;
}

@keyframes move-across {
  from {
    left: 0;
    background-color: #0f766e;
  }
  to {
    left: calc(100% - 120px);
    background-color: #1d4ed8;
  }
}

/* Requirement 2b: a timed keyframe animation triggered by hover. */
.hover-animation-box {
  border-radius: 6px;
  background-color: #9d174d;
}

.hover-trigger:hover .hover-animation-box,
.hover-trigger:focus .hover-animation-box {
  animation: rotate-and-grow 2s ease-in-out 1;
}

@keyframes rotate-and-grow {
  0% {
    transform: rotate(0deg) scale(1);
    background-color: #9d174d;
  }
  50% {
    transform: rotate(180deg) scale(1.15);
    background-color: #7e22ce;
  }
  100% {
    transform: rotate(360deg) scale(1);
    background-color: #9d174d;
  }
}

/* Requirement 3: an example of a gradient background. */
.gradient-example {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 20px;
  border-radius: 6px;
  background: linear-gradient(to right, #1e40af, #6b21a8, #9d174d);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: bold;
  text-align: center;
}

:focus-visible {
  outline: 3px solid #17233a;
  outline-offset: 5px;
}

footer {
  color: #475569;
}

@media (max-width: 480px) {
  body {
    padding: 20px 12px;
  }
  section {
    padding: 18px;
  }
}
