:root {
    --paper: #f4ead5;
    --paper-edge: #e2cfa6;
    --ink: #3b2f22;
    --ink-soft: rgba(59, 47, 34, .68);
    --contour: rgba(122, 92, 50, .24);
    --route: #b5462b;
    --envelope: #fbf5e8;
    --seal: #a8322a;
    --accent: #2f5d50;
    --on-accent: #f4ead5;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #151d24;
        --paper-edge: #0b1116;
        --ink: #efe4cc;
        --ink-soft: rgba(239, 228, 204, .7);
        --contour: rgba(214, 190, 140, .15);
        --route: #e58a62;
        --envelope: #24303a;
        --seal: #c9543f;
        --accent: #9cc9b4;
        --on-accent: #151d24;
    }
}

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

html,
body {
    height: 100%;
}

body {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 100%;
    padding: 24px 16px 64px;
    overflow: hidden;
    background: radial-gradient(ellipse at center, var(--paper) 55%, var(--paper-edge) 100%);
    color: var(--ink);
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    text-align: center;
}

.map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.map__contour {
    fill: none;
    stroke: var(--contour);
    stroke-width: 1.2;
}

.map__route {
    fill: none;
    stroke: var(--route);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 1 11;
}

.map__reveal {
    fill: none;
    stroke: #fff;
    stroke-width: 12;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: reveal 9s ease-out infinite;
}

.paper {
    max-width: 34rem;
}

.letter {
    width: clamp(9rem, 42vw, 13rem);
    height: auto;
    animation: float 4.5s ease-in-out infinite;
}

.letter__body {
    fill: var(--envelope);
    stroke: var(--ink);
    stroke-width: 2;
    stroke-linejoin: round;
}

.letter__fold {
    fill: none;
    stroke: var(--ink);
    stroke-width: 2;
    stroke-linejoin: round;
}

.letter__seal {
    fill: var(--seal);
}

.letter__seal-mark {
    fill: none;
    stroke: var(--envelope);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.letter__stamp {
    fill: none;
    stroke: var(--route);
    stroke-width: 1.5;
    stroke-dasharray: 3 2;
}

.letter__stamp-text {
    fill: var(--route);
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 7px;
    letter-spacing: .08em;
    text-anchor: middle;
}

.paper__title {
    margin-top: 20px;
    font-size: clamp(1.6rem, 6vw, 2.3rem);
    font-weight: 600;
    letter-spacing: .01em;
}

.paper__text {
    max-width: 28rem;
    margin: 14px auto 0;
    color: var(--ink-soft);
    font-size: 1.05rem;
    line-height: 1.55;
}

.paper__en {
    max-width: 28rem;
    margin: 32px auto 0;
    padding-top: 16px;
    border-top: 1px solid var(--contour);
    color: var(--ink-soft);
    font-size: .85rem;
    font-style: italic;
    line-height: 1.5;
}

.paper__en a {
    color: inherit;
    text-underline-offset: 2px;
}

.paper__link {
    display: inline-block;
    margin-top: 26px;
    padding: 12px 28px;
    border: 2px solid var(--accent);
    border-radius: 999px;
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .2s, color .2s;
}

.paper__link:hover,
.paper__link:focus-visible {
    background-color: var(--accent);
    color: var(--on-accent);
    outline: none;
}

.paper__link:focus-visible {
    box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent);
}

.legend {
    position: absolute;
    right: 16px;
    bottom: 16px;
    left: 16px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    color: var(--ink-soft);
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .72rem;
}

@keyframes reveal {
    0% {
        stroke-dashoffset: 1;
        opacity: 1;
    }

    55%,
    85% {
        stroke-dashoffset: 0;
        opacity: 1;
    }

    95% {
        stroke-dashoffset: 0;
        opacity: 0;
    }

    100% {
        stroke-dashoffset: 1;
        opacity: 0;
    }
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0) rotate(-3deg);
    }

    50% {
        transform: translateY(-6px) rotate(-1deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .letter {
        animation: none;
    }

    .map__reveal {
        animation: none;
        stroke-dashoffset: 0;
    }
}

@media (min-width: 640px) {
    .legend {
        right: 24px;
        bottom: 20px;
        left: 24px;
        font-size: .78rem;
    }
}
