
/* =========================
   RESET
========================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


/* =========================
   BODY
========================= */

body {
    min-height: 100vh;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;

    font-family: Arial, Helvetica, sans-serif;

    background:
        radial-gradient(
            circle at center,
            #293444 0%,
            #171d28 45%,
            #080b10 100%
        );

    color: white;
}


/* =========================
   GEAR BACKGROUND
========================= */

.gear-background {
    position: fixed;
    inset: 0;

    overflow: hidden;

    pointer-events: none;

    z-index: 0;

    /*
        JavaScript changes this variable
        while the slot is spinning.
    */
    --gear-speed: 18s;
}


/* =========================
   GEAR
========================= */

.gear {
    position: absolute;

    width: var(--size);
    height: var(--size);

    border-radius: 50%;

    /*
        Teeth.
    */
    background:
        repeating-conic-gradient(
            from 0deg,
            #657080 0deg 5deg,
            transparent 5deg 10deg
        );

    opacity: 0.16;

    display: flex;
    justify-content: center;
    align-items: center;

    animation-duration: var(--gear-speed);
    animation-timing-function: linear;
    animation-iteration-count: infinite;

    transition:
        animation-duration 0.15s;
}


/* =========================
   GEAR INNER BODY
========================= */

.gear::before {
    content: "";

    position: absolute;

    width: 76%;
    height: 76%;

    border-radius: 50%;

    background: #111720;

    box-shadow:
        inset 0 0 0 5px #303947;
}


/* =========================
   GEAR CENTER
========================= */

.gear-hole {
    position: relative;

    width: 25%;
    height: 25%;

    border-radius: 50%;

    background: #657080;

    border: 7px solid #111720;

    z-index: 2;
}


/* =========================
   INDIVIDUAL GEARS
========================= */


/*
    Top-left large gear
*/
.gear-1 {
    --size: 260px;

    left: -75px;
    top: -70px;

    animation-name: clockwise;
}


/*
    Gear touching gear 1.
    Smaller = faster.
*/
.gear-2 {
    --size: 155px;

    left: 145px;
    top: 105px;

    animation-name: counterClockwise;
}


/*
    Gear touching gear 2.
*/
.gear-3 {
    --size: 220px;

    left: 275px;
    top: 245px;

    animation-name: clockwise;
}


/*
    Upper-right large gear.
*/
.gear-4 {
    --size: 300px;

    right: -110px;
    top: -80px;

    animation-name: counterClockwise;
}


/*
    Gear touching gear 4.
*/
.gear-5 {
    --size: 145px;

    right: 155px;
    top: 155px;

    animation-name: clockwise;
}


/*
    Bottom-left large gear.
*/
.gear-6 {
    --size: 310px;

    left: -115px;
    bottom: -120px;

    animation-name: counterClockwise;
}


/*
    Gear touching gear 6.
*/
.gear-7 {
    --size: 170px;

    left: 155px;
    bottom: 95px;

    animation-name: clockwise;
}


/*
    Bottom-right large gear.
*/
.gear-8 {
    --size: 250px;

    right: -80px;
    bottom: -75px;

    animation-name: clockwise;
}


/*
    Gear touching gear 8.
*/
.gear-9 {
    --size: 130px;

    right: 155px;
    bottom: 125px;

    animation-name: counterClockwise;
}


/* =========================
   GEAR ROTATION
========================= */

@keyframes clockwise {

    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}


@keyframes counterClockwise {

    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(-360deg);
    }
}


/* =========================
   MAIN
========================= */

.container {
    position: relative;

    z-index: 10;

    width: min(720px, 92vw);

    text-align: center;
}


/* =========================
   TITLE
========================= */

h1 {
    margin-bottom: 28px;

    font-size: clamp(2.5rem, 7vw, 4.5rem);

    font-weight: 900;

    letter-spacing: -2px;

    color: #f4f6f9;

    text-shadow:
        0 4px 0 #080b10,
        0 8px 25px rgba(0, 0, 0, 0.5);
}


/* =========================
   MACHINE
========================= */

.machine {
    padding: 18px;

    border-radius: 24px;

    background:
        linear-gradient(
            145deg,
            #596473,
            #292f3a
        );

    border: 3px solid #707b8b;

    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.55),
        inset 0 2px 0 rgba(255, 255, 255, 0.16);
}


/* =========================
   MACHINE HEADER
========================= */

.machine-top {
    padding: 12px;

    margin-bottom: 15px;

    border-radius: 12px;

    background: #111722;

    border: 2px solid #080b10;

    color: #aeb8c7;

    font-size: 0.85rem;

    font-weight: 900;

    letter-spacing: 4px;
}


/* =========================
   FACT WINDOW
========================= */

.fact-window {
    position: relative;

    height: 260px;

    border-radius: 16px;

    background:
        linear-gradient(
            145deg,
            #f2f4f7,
            #cfd5dc
        );

    border: 6px solid #171c25;

    box-shadow:
        inset 0 0 25px rgba(0, 0, 0, 0.18),
        0 5px 0 #11151c;

    color: #111722;

    overflow: hidden;
}


/* =========================
   SLOT MASK
========================= */

.slot-mask {
    position: absolute;

    inset: 0;

    overflow: hidden;

    display: flex;

    justify-content: center;

    align-items: center;
}


/*
    Shadow at top and bottom.
    This gives the slot window
    some depth.
*/

.slot-mask::before,
.slot-mask::after {
    content: "";

    position: absolute;

    left: 0;
    right: 0;

    height: 55px;

    z-index: 5;

    pointer-events: none;
}


.slot-mask::before {
    top: 0;

    background:
        linear-gradient(
            to bottom,
            rgba(25, 30, 38, 0.32),
            transparent
        );
}


.slot-mask::after {
    bottom: 0;

    background:
        linear-gradient(
            to top,
            rgba(25, 30, 38, 0.32),
            transparent
        );
}


/* =========================
   SLOT CONTENT
========================= */

.slot-content {
    width: 100%;

    padding: 35px;

    text-align: center;

    transform: translateY(0);
}


/*
    New fact comes completely
    from above.

    It travels far enough that
    the previous fact cannot
    remain visible.
*/

.slot-content.slot-enter {
    animation:
        slotDrop var(--slot-animation-time, 0.18s)
        cubic-bezier(0.18, 0.85, 0.3, 1);
}


@keyframes slotDrop {

    0% {
        transform:
            translateY(-130%);
        opacity: 0;
    }

    35% {
        opacity: 0.55;
    }

    100% {
        transform:
            translateY(0);
        opacity: 1;
    }
}


/* =========================
   CATEGORY
========================= */

.category {
    margin-bottom: 18px;

    font-size: 0.8rem;

    font-weight: 900;

    letter-spacing: 4px;

    color: #596273;
}


/* =========================
   FACT
========================= */

.fact {
    max-width: 600px;

    margin: auto;

    font-size: clamp(1.3rem, 3vw, 1.8rem);

    line-height: 1.5;

    font-weight: 700;
}


/* =========================
   SPIN BUTTON
========================= */

#spinButton {
    width: 100%;

    margin-top: 18px;

    padding: 18px;

    border: none;

    border-radius: 14px;

    background:
        linear-gradient(
            180deg,
            #ffbd4a,
            #e88916
        );

    border-bottom: 5px solid #a95d08;

    color: #17110a;

    font-size: 1.2rem;

    font-weight: 900;

    letter-spacing: 3px;

    cursor: pointer;

    transition:
        transform 0.1s,
        filter 0.1s;
}


#spinButton:hover {
    filter: brightness(1.08);

    transform: translateY(-2px);
}


#spinButton:active {
    transform: translateY(3px);

    border-bottom-width: 2px;
}


#spinButton:disabled {
    cursor: not-allowed;

    filter: grayscale(0.4);

    opacity: 0.65;

    transform: none;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {

    .gear-1 {
        left: -130px;
    }

    .gear-2 {
        left: 60px;
    }

    .gear-3 {
        left: 160px;
    }

    .gear-4 {
        right: -150px;
    }

    .gear-5 {
        right: 55px;
    }

    .gear-6 {
        left: -150px;
    }

    .gear-7 {
        left: 50px;
    }

    .gear-8 {
        right: -130px;
    }

    .gear-9 {
        right: 55px;
    }

    .fact-window {
        height: 300px;
    }

    .slot-content {
        padding: 25px 18px;
    }

    .machine {
        padding: 12px;
    }
}
