/* ===== Exercise 6: CSS Animations & Transitions ===== */

:root{
  --bg: #fafaf9;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #7f1d1d;
  --line: #e7e5e4;
  --dark: #111;
  --white: #fff;
}

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'DM Mono', monospace;
}

body{
  background: var(--bg);
  color: var(--text);
}

/* ===== PAGE LAYOUT ===== */
.page-title{
  text-align: center;
  padding: 60px 20px 40px;
}

.page-title h1{
  font-family: 'Bitcount Single', sans-serif;
  font-size: 4rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.page-title p{
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.demos{
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 60px;
}

.demo{
  border-top: 1px solid var(--line);
  padding-top: 40px;
}

.demo h2{
  font-family: 'Bitcount Single', sans-serif;
  font-size: 1.6rem;
  color: var(--text);
  margin-bottom: 6px;
}

.demo .label{
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.demo-area{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: var(--white);
  border: 1px solid var(--line);
}

/* ===== 1. TEXT ROLLOVER — color + letter-spacing ===== */
.text-rollover{
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 40px;
}

.text-rollover a{
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
  text-decoration: none;
  transition: color 0.3s ease, letter-spacing 0.3s ease;
}

.text-rollover a:hover{
  color: var(--accent);
  letter-spacing: 0.25em;
}

/* ===== 2. IMAGE ROLLOVER — grayscale to color + zoom ===== */
.image-rollover{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.image-rollover .img-box{
  overflow: hidden;
  aspect-ratio: 1;
  background: #c4b5a5;
  position: relative;
  cursor: pointer;
}

.image-rollover .img-box .overlay-text{
  position: absolute;
  bottom: 12px;
  left: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.image-rollover .img-box:hover .overlay-text{
  opacity: 1;
  transform: translateY(0);
}

.image-rollover .img-box::after{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(127, 29, 29, 0.25);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.image-rollover .img-box:hover::after{
  opacity: 1;
}

/* placeholder colors for demo */
.image-rollover .img-box:nth-child(1){ background: #a8a29e; }
.image-rollover .img-box:nth-child(2){ background: #78716c; }
.image-rollover .img-box:nth-child(3){ background: #57534e; }

/* ===== 3. TEXT EFFECT — typing cursor animation ===== */
.typing-demo{
  padding: 40px;
  display: flex;
  justify-content: center;
}

.typing-text{
  font-family: 'DM Mono', monospace;
  font-size: 1.2rem;
  color: var(--text);
  border-right: 2px solid var(--accent);
  white-space: nowrap;
  overflow: hidden;
  width: 22ch;
  animation: typing 3s steps(22) 1s forwards, blink 0.6s step-end infinite;
}

@keyframes typing{
  from{ width: 0; }
  to{ width: 22ch; }
}

@keyframes blink{
  50%{ border-color: transparent; }
}

/* ===== 4. FLOATING ANIMATION — continuous float ===== */
.float-demo{
  padding: 40px;
  display: flex;
  gap: 40px;
  justify-content: center;
  align-items: center;
}

.float-box{
  width: 80px;
  height: 80px;
  background: var(--accent);
  animation: float 3s ease-in-out infinite;
}

.float-box:nth-child(2){
  animation-delay: 0.5s;
  background: var(--text);
}

.float-box:nth-child(3){
  animation-delay: 1s;
  background: var(--muted);
}

@keyframes float{
  0%, 100%{ transform: translateY(0); }
  50%{ transform: translateY(-20px); }
}

/* ===== 5. CARD FLIP — hover to reveal back ===== */
.flip-demo{
  padding: 40px;
  display: flex;
  gap: 30px;
  justify-content: center;
  flex-wrap: wrap;
  perspective: 800px;
}

.flip-card{
  width: 180px;
  height: 240px;
  cursor: pointer;
  perspective: 800px;
}

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

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

.flip-front,
.flip-back{
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
  text-align: center;
}

.flip-front{
  background: var(--dark);
  color: var(--white);
}

.flip-front h3{
  font-family: 'Bitcount Single', sans-serif;
  font-size: 1.4rem;
  color: var(--accent);
}

.flip-front p{
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 8px;
}

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

.flip-back p{
  font-size: 0.8rem;
  line-height: 1.5;
}
