/* =========================================================
   CSS MOTION LAB
   Week 02 — HTML / CSS
   ========================================================= */


/* ---------- PAGE SETUP ---------- */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: #f4f4f1;
    color: #161616;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

.site-header,
main,
footer {
    width: min(1500px, 92vw);
    margin: 0 auto;
}

.site-header {
    padding: 80px 0 55px;
}

.eyebrow,
.section-number,
.challenge-label {
    font-size: 0.78rem;
    font-weight: bold;
    letter-spacing: 0.12em;
}

h1 {
    margin: 10px 0 18px;
    font-size: clamp(3rem, 8vw, 7rem);
    line-height: 0.92;
    letter-spacing: -0.055em;
}

.intro {
    max-width: 780px;
    font-size: 1.2rem;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 30px;
}

.legend span {
    background: white;
    border: 1px solid #cfcfc8;
    border-radius: 100px;
    padding: 9px 14px;
    font-size: 0.9rem;
}


/* ---------- SECTIONS ---------- */

.section {
    padding: 70px 0 100px;
    border-top: 1px solid #cfcfc8;
}

.section-heading {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 20px;
    margin-bottom: 35px;
}

.section-heading h2 {
    margin: 0 0 5px;
    font-size: 2rem;
}

.section-heading p {
    margin-top: 0;
}


/* ---------- CSS GRID ---------- */

.example-grid {
    display: grid;

    /* Each card should be at least 360px wide.
       The browser automatically decides how many columns fit. */
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));

    gap: 22px;
}


/* ---------- EXAMPLE CARDS ---------- */

.example-card {
    display: flex;
    flex-direction: column;
    min-height: 620px;
    overflow: hidden;
    background: white;
    border: 1px solid #cfcfc8;
    border-radius: 16px;
}

.card-heading {
    padding: 22px 22px 5px;
}

.card-heading h3 {
    margin: 8px 0 14px;
    font-size: 1.35rem;
}

.tag {
    display: inline-block;
    background: #efe8ff;
    color: #5634a5;
    border-radius: 100px;
    padding: 5px 9px;
    font-size: 0.68rem;
    font-weight: bold;
    letter-spacing: 0.08em;
}

.tag-animation {
    background: #e7f1ff;
    color: #215a96;
}

pre {
    margin: 0;
    padding: 22px;
    overflow-x: auto;
    background: #191919;
    color: #f4f4f1;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre;
}

code {
    font-family: "Courier New", Courier, monospace;
}

.demo {
    flex: 1;
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 30px;
    overflow: hidden;
}

.demo small {
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.word {
    font-size: clamp(2.6rem, 5vw, 5rem);
    font-weight: bold;
    line-height: 1;
}


/* =========================================================
   TRANSITIONS
   ========================================================= */


/* 1. COLOR */

.color-change {
    color: black;
    transition: color 0.5s;
}

.color-change:hover {
    color: red;
}


/* 2. OPACITY */

.fade-hover {
    opacity: 1;
    transition: opacity 0.8s;
}

.fade-hover:hover {
    opacity: 0.15;
}


/* 3. SCALE */

.grow {
    display: inline-block;
    transition: transform 0.5s;
}

.grow:hover {
    transform: scale(1.6);
}


/* 4. ROTATE */

.turn {
    display: inline-block;
    transition: transform 0.5s;
}

.turn:hover {
    transform: rotate(12deg);
}


/* 5. MOVE */

.slide {
    display: inline-block;
    transition: transform 0.7s;
}

.slide:hover {
    transform: translateX(90px);
}


/* 6. COMBINE SEVERAL PROPERTIES */

.combine {
    display: inline-block;
    transition: all 0.7s;
}

.combine:hover {
    color: blue;
    transform: scale(1.3) rotate(-8deg);
    letter-spacing: 12px;
}


/* 7. BACKGROUND + TEXT */

.invert {
    padding: 14px 20px;
    transition: all 0.4s;
}

.invert:hover {
    color: white;
    background: black;
}


/* 8. LINK STATES */

.poem-link {
    color: black;
    text-decoration: none;
    transition: color 0.4s;
}

.poem-link:hover {
    color: magenta;
}

.poem-link:visited {
    color: purple;
}


/* =========================================================
   ANIMATIONS
   ========================================================= */


/* 9. FADE */

@keyframes fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.fade {
    animation: fade 2s infinite alternate;
}


/* 10. PULSE */

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.45);
    }
}

.pulse {
    display: inline-block;
    animation: pulse 1.2s infinite alternate;
}


/* 11. FLOAT */

@keyframes float {
    from {
        transform: translateY(20px);
    }

    to {
        transform: translateY(-20px);
    }
}

.float {
    display: inline-block;
    animation: float 2s infinite alternate ease-in-out;
}


/* 12. SPIN */

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

    to {
        transform: rotate(360deg);
    }
}

.spin {
    display: inline-block;
    animation: spin 3s infinite linear;
}


/* 13. BOUNCE */

@keyframes bounce {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-45px);
    }

    100% {
        transform: translateY(0);
    }
}

.bounce {
    display: inline-block;
    animation: bounce 1.1s infinite;
}


/* 14. COLOR SHIFT */

@keyframes colorCycle {
    0% {
        color: red;
    }

    50% {
        color: blue;
    }

    100% {
        color: purple;
    }
}

.color-cycle {
    animation: colorCycle 3s infinite;
}


/* 15. DRIFT + FADE */

@keyframes drift {
    0% {
        transform: translateX(-40px);
        opacity: 0;
    }

    100% {
        transform: translateX(40px);
        opacity: 1;
    }
}

.drift {
    display: inline-block;
    animation: drift 2.5s infinite alternate;
}


/* 16. LETTER SPACING */

@keyframes expandText {
    from {
        letter-spacing: 0;
    }

    to {
        letter-spacing: 24px;
    }
}

.expand-text {
    animation: expandText 2s infinite alternate;
}


/* 17. BLINK */

@keyframes blink {
    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

.blink {
    animation: blink 1s infinite;
}


/* 18. DELAYED ENTRANCE */

@keyframes appear {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.delayed {
    animation: appear 2s infinite;
    animation-delay: 1s;
}


/* ---------- FINAL CHALLENGE ---------- */

.challenge-section {
    padding-bottom: 80px;
}

.challenge {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border: 1px solid #cfcfc8;
    border-radius: 16px;
    overflow: hidden;
}

.challenge > div {
    min-height: 330px;
    padding: 45px;
}

.challenge-demo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #191919;
    color: white;
}

@keyframes strange {
    0% {
        opacity: 0.2;
        transform: translate(-35px, 10px) rotate(-4deg);
        letter-spacing: 0;
    }

    50% {
        opacity: 1;
        transform: translate(20px, -15px) rotate(5deg);
        letter-spacing: 16px;
    }

    100% {
        opacity: 0.45;
        transform: translate(-5px, 5px) rotate(-1deg);
        letter-spacing: 4px;
    }
}

.strange {
    display: inline-block;
    animation: strange 2.2s infinite alternate ease-in-out;
}


/* ---------- FOOTER ---------- */

footer {
    padding: 40px 0 90px;
    border-top: 1px solid #cfcfc8;
}


/* ---------- SMALLER SCREENS ---------- */

@media (max-width: 800px) {

    .example-grid {
        grid-template-columns: 1fr;
    }

    .challenge {
        grid-template-columns: 1fr;
    }

    .section-heading {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}


/* Respect visitors who ask their operating system for reduced motion. */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
