:root {
    --skyA: #58BEF7;
    --skyB: #2F92CA;

    --idle-x: 5px;
    --idle-y: 5px;

    --bg-color: #B0C5A4;
    --transition: all 200ms ease-in-out;

    @media (prefers-color-scheme: dark) {
        --bg-color: #161C2E;
    }
}

* {
    margin: 0;
    padding: 0;
}
@font-face {
    font-display: fallback;
    font-family: 'VT323';
    font-style: normal;
    font-weight: 400;
    src: url('fonts/vt323-v17-latin-regular.woff2') format('woff2');
  }
body {
    font-family: "VT323", monospace;
    background-color: var(--bg-color);
}

main {
    max-width: 1920px;
    margin-inline: auto;
}

.absolute {
    position: absolute;
}

.hero {
    height: 100dvh;
    width: 100%;
    min-height: 400px;
    aspect-ratio: 1.54;
    position: relative;
    display: grid;
    overflow: hidden;

    >* {
        grid-area: 1/-1;
    }

    .sky {
        background: linear-gradient(var(--skyA), var(--skyB));
    }

    .clouds {
        top: 15px;
        top: calc(60px - 10vw);
        left: 5%;
        width: 90%;
        min-width: 200px;
        aspect-ratio: 2.5;
        background: url(pixelstuff/clouds.png) no-repeat center / contain;
    }

    .landscape {
        bottom: 0;
        right: 0;
        width: 100%;
        min-width: 200px;
        aspect-ratio: 2.5;
        background: url(pixelstuff/landscape.png) no-repeat center / contain;
    }

    .tree {
        bottom: min(19.65vw, 376px);
        right: calc(24.6% - 3px);
        width: 23.1%;
        aspect-ratio: 0.775;
        background: url(pixelstuff/tree.png) no-repeat center / contain;
    }

    .person-on-a-stone {
        bottom: -15px;
        right: 50px;
        width: 14%;
        min-width: 200px;
        aspect-ratio: 0.63;
        background: url(pixelstuff/me-on-a-stone.png) no-repeat center / contain;
    }

    .grass {
        width: 3.1%;
        transform-origin: bottom center;
        transform: matrix(1, 0, 0, 1, 0, 0);
        background: no-repeat center / contain;
    }

    .grass-type-1 {
        aspect-ratio: 0.667;
        background-image: url(pixelstuff/grass-1.png);
    }

    .grass-type-2 {
        aspect-ratio: 0.667;
        background-image: url(pixelstuff/grass-2.png);
    }

    .grass-type-3 {
        aspect-ratio: 1.14;
        background-image: url(pixelstuff/grass-3.png);
        width: 4%;
    }

    .grass-smol {
        width: 1.55%;
    }

    .grass-smol.grass-type-3 {
        width: 2.9%;
    }

    .grass-1 {
        bottom: min(7.1vw, 136px);
        left: 14.9%;
    }

    .grass-2 {
        bottom: min(14.1vw, 270px);
        right: 19.5%;
    }

    .grass-3 {
        bottom: min(4vw, 76px);
        left: 37.9%;
    }

    .grass-4 {
        bottom: min(19vw, 363px);
        left: 21.7%;
    }

    .grass-5 {
        bottom: min(19.7vw, 378px);
        left: 25.9%;
    }

    .grass-6 {
        bottom: min(20vw, 383px);
        left: 38.6%;
    }
    .grass-7 {
        bottom: min(26.7vw, 511px);
        left: 39.1%;
    }

    .heart {
        width: 50px;
        height: 50px;
        background: url(pixelstuff/heart.png) no-repeat center / contain;
        box-sizing: border-box;
        padding: 25px;
        transition: var(--transition);
        top: 110%;
        &:hover {
            filter: drop-shadow(6px -1px 0px pink);
        }
    }
    h1 {
        right: 50%;
        bottom: min(31vw, 570px);
        color: transparent;
        font-size: clamp(2rem, 1rem + 6vw, 3rem);
        text-wrap: balance;
        background-color: white;
        border: 3px solid black;
        box-shadow: inset 0 0 0 3px white, inset 0 0 0 6px black;
        border-radius: 4px;
        color: black;
        padding: 1.5rem;
        @media all and (max-width: 480px) {
            bottom: 43%;
            inset-inline: 0;
        }
    }
}

#speaker {
    background: url(pixelstuff/speaker.png) no-repeat 14px center / 100%;
    height: 30px;
    width: 30px;
    padding: 10px;
    cursor: pointer;
    display: block;
    position: absolute;
    top: 15px;
    right: 15px;
    display: block;
    box-sizing: border-box;
    transition: var(--transition);
    opacity: 0;
    animation: fadeInSpeaker 1s 2s forwards;
}

#speaker.speakerplay {
    background-position: 0 0;
}
section {
    height: 100vh;
    display: grid;
    place-items: center;
}

@keyframes fadeInSpeaker {
    0% {
        opacity: 0;
        right: -5px;
    }
    100% {
        opacity: 1;
        right: 15px;
    }
}

/* Show h1 only when font is loaded */
body.font-loaded .hero h1 {
    color: black;
}

/* Container for text box */
#text-box {
    /* right: 50%; Position the container */
    bottom: min(56vw, 330px);
    
    /* Apply textbox style permanently */
    background-color: white;
    border: 3px solid black;
    box-shadow: inset 0 0 0 3px white, inset 0 0 0 6px black;
    border-radius: 4px;
    color: black; /* Text color inside box */
    padding: 1.5rem; /* Use textbox padding */
    max-width: 80%;
    
    visibility: hidden; /* Hide box until font loads */
    margin-inline: 10px;
    @media all and (min-width: 800px) {
        right: 50%;
        max-width: 48%;
        bottom: min(45vw, 600px);
    }
}

#text-box h1 {
    /* Remove positioning from h1 */
    /* color: transparent; */ /* Handled by #text-box visibility + color */
    font-size: clamp(2rem, 1rem + 6vw, 3rem);
    text-wrap: balance;
    margin-bottom: 0.5em; /* Space between text and action */
}

#text-action {
    display: block; /* Make it block for positioning */
    background: none;
    border: none;
    font-family: inherit; /* Use VT323 */
    font-size: 1.2rem; /* Slightly smaller */
    color: inherit; /* Inherit color from #text-box */
    cursor: pointer;
    text-align: right; /* Align text to the right */
    margin-left: auto; /* Push to the right */
    padding: 0.2em 0.5em; /* Small padding */
    &::before {
        content: "->";
        margin-right: 0.5em;
        @media all and (hover: hover) {
            visibility: hidden;
        }
    }
    &:focus {
        border: 0;
        outline: 0;
    }
    &:hover {
        outline: 2px solid black;
    }
}

#text-box:hover #text-action::before,
#text-action:hover::before {
    visibility: visible;
}

@media all and (max-width: 480px) {
    #text-box {
        bottom: 43%;
        inset-inline: 0;
        text-align: center; /* Center text on small screens */
    }
    #text-action {
        margin-right: auto; /* Center action button */
        text-align: center;
    }
    #text-box h1 {
         margin-bottom: 0.2em;
    }
}

/* Show text box only when font is loaded */
body.font-loaded #text-box {
    visibility: visible;
}