/* ---------- Basics ---------- */
@font-face {
    font-family: "MyFont";
    src: url("../assets/fonts/ShortStack-Regular.ttf") format("truetype");
    font-display: swap;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "MyFont", system-ui, sans-serif;
    background: #fde8ef;
    color: #1c1d2e;
    line-height: 1.6;
}

p {
    font-size: 1.35rem;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}


/* ---------- Size of the milestone images ----------
   Change this ONE value to make every image bigger or smaller.
   clamp(smallest, preferred, largest): it scales with the screen
   width but never goes below 180px or above 300px. */
:root {
    --tile-size: 400px
}

/* ---------- Title and intro text at the top ---------- */
.intro {
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 1.5rem 3rem;
    text-align: center;
}

.intro h1 {
    color: #5D3232;
    font-family: "MyFont", system-ui, sans-serif;
    font-size: 3rem;
    margin-bottom: 1rem;
}

.intro p {
    color: #5D3232;
    max-width: 60ch;
    /* keeps lines a comfortable length */
    margin: 0 auto;
}

/* ---------- The map ----------
   A tall column that holds the trail and the milestones.
   "gap" is the vertical space between milestones: raise it for a
   longer trail, lower it for a shorter one. */
.map {
    position: relative;
    /* the trail is positioned inside this */
    max-width: 900;
    margin: 0 auto;
    padding: 4rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 5rem;
}


/* ---------- The trail layer ----------
   Sits behind the milestones and never blocks clicks.
   main.js puts the little trail pieces inside it. */
.trail {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.trail-piece {
    position: absolute;
    /* If your trail image is too big or small, set a size here, e.g.
     width: 20px; */
}


/* ---------- One milestone ---------- */
.tile {
    position: relative;
    z-index: 1;
    /* above the trail */
    display: block;
    width: var(--tile-size);
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

/* ---------- The zig-zag ----------
   Each milestone is pushed left or right. The pattern repeats every
   4 images, with different amounts so it looks hand-placed, not rigid.
   Edit the percentages to move things around.
   (We use "nth-of-type" because the trail <div> is also in the map.) */
.tile:nth-of-type(4n + 1) {
    align-self: flex-start;
    margin-left: 6%;
}

.tile:nth-of-type(4n + 2) {
    align-self: flex-end;
    margin-right: 10%;
}

.tile:nth-of-type(4n + 3) {
    align-self: flex-start;
    margin-left: 24%;
}

/* Keyboard users get a simple outline when they tab onto a tile */
.tile:focus-visible {
    outline: 2px solid #5b3fe0;
    outline-offset: 4px;
}


/* ---------- The two stacked images (instant swap) ---------- */
.tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tile .img-hover {
    opacity: 0;
}

.tile:hover .img-hover,
.tile:focus-visible .img-hover {
    opacity: 1;
}

.tile:hover .img-default,
.tile:focus-visible .img-default {
    opacity: 0;
}


/* ---------- The pages you open by clicking ---------- */
.content-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    animation: page-in 0.6s ease-out both;
}

.content-page h1 {
    margin: 1.5rem 0 1rem;
}

.content-page img {
    margin: 1.5rem 0;
    max-width: 320px;
}

.back-link {
    display: inline-block;
    color: #5b3fe0;
    font-weight: 600;
    transition: transform 0.2s;
}

.back-link:hover {
    transform: translateX(-4px);
}

/* ---------- Text beside each envelope ---------- */
.note {
    position: absolute;
    top: 50%;
    /* vertically centered on the envelope */
    transform: translateY(-50%);
    width: 200px;
    /* how wide the text block can be */
    font-size: 1.35rem;
    line-height: 1.35;
    color: #3a3b55;
}

/* Left-hand envelopes (1st, 3rd, 5th...): text goes on the RIGHT */
.tile:nth-of-type(odd) .note {
    left: 100%;
    margin-left: 1.5rem;
    text-align: left;
}

/* Right-hand envelopes (2nd, 4th, 6th...): text goes on the LEFT */
.tile:nth-of-type(even) .note {
    right: 100%;
    margin-right: 1.5rem;
    text-align: right;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* ---------- Scattered dots behind everything ---------- */
body {
    position: relative;
    /* the dots layer is sized to the whole page */
    min-height: 100vh;
}

.dots {
    position: absolute;
    inset: 0;
    /* covers the entire page, top to bottom */
    z-index: -1;
    /* behind all content */
    overflow: hidden;
    /* dots near the edge can't cause side-scrolling */
    pointer-events: none;
    /* never blocks clicks */
}

.dot {
    position: absolute;
    opacity: 0.3;
    /* lower = fainter, 1 = full strength */
}

/* ---------- Music button ---------- */
.music-toggle {
    position: fixed;
    /* stays in place while you scroll */
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 10;
    /* above the envelopes */
    width: 64px;
    /* how big it appears on the page */
    height: 64px;
    padding: 0;
    border: none;
    background: none;
    /* your picture is the whole button */
    cursor: pointer;
}

.music-toggle img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---------- Entry screen: the big envelope ---------- */
.entry {
    position: fixed;
    inset: 0;
    /* covers the whole window */
    z-index: 100;
    /* above everything else */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background: #fde8ef;
    /* same pink as the page */
    transition: opacity 0.6s ease;
    /* the fade when it leaves */
}

.entry.leaving {
    opacity: 0;
    pointer-events: none;
}

/* Already opened it earlier in this tab? Don't show it again. */
.skip-entry .entry {
    display: none;
}

/* No scrolling behind the entry screen */
html.entry-active,
html.entry-active body {
    overflow: hidden;
}

.entry-envelope {
    position: relative;
    height: min(70vh, 700px);
    /* big, but always fits the window */
    aspect-ratio: 1 / 1;
    /* your entry images' width / height */
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

/* Two stacked images, swapped instantly (same trick as the tiles) */
.entry-envelope img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.entry-envelope .entry-open {
    opacity: 0;
}

.entry-envelope:hover .entry-open,
.entry.opening .entry-open {
    opacity: 1;
}

.entry-envelope:hover .entry-closed,
.entry.opening .entry-closed {
    opacity: 0;
}

.entry-hint {
    margin-top: -2rem;
    /* pulls the text up into the empty space */
    color: #3a3b55;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    pointer-events: none;
    /* clicks pass through to the envelope */
}

/* ---------- Respect "reduce motion" settings ---------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
