@font-face {
    font-family: "Cormorant Garamond";
    src: url("/fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

/* Theme */

:root {
    /* Dawn: the last stars fading from a blue sky, with the sun coming up to the
       north-east, behind the ridge. Light marks on a sky dark enough to hold them. */
    --sky:
        radial-gradient(ellipse 75% 34% at 80% 80%, rgb(255 196 128 / .8), transparent),
        linear-gradient(in oklab, #67889f, #8fadbe 26%, #c6d2cc 44%, #ecdcc2 56%, #f4cda4 66%, #f2ab86 76%, #e3917c 86%);
    --text: #14261d;
    --text-soft: #2b3f35;
    --trail: #fbfaf0;
    --trail-cool: #dcf0ff;
    --trail-warm: #ffe2a6;
    --trail-ember: #ffc8b4;
    --star: #fff3cf;
    --ridge-far: #b98a86;
    --ridge-near: #17302c;

    /* Where the sky turns. Everything in .sky is measured from this point. */
    --pole-x: 72%;
    --pole-y: 26%;
    --ridge-height: clamp(6rem, 30vh, 18rem);
}

@media (prefers-color-scheme: dark) {
    :root {
        --sky: linear-gradient(#0a1411, #12261f 58%, #1f4a43 88%);
        --text: #f0f3e6;
        --text-soft: #c6d2bf;
        --trail: #e8efe2;
        --trail-cool: #9fd0ee;
        --trail-warm: #f2c46d;
        --trail-ember: #ee9f86;
        --star: #e8bf6a;
        --ridge-far: #0f231d;
        --ridge-near: #0a1512;
    }
}

@media (max-width: 40rem) {
    :root {
        --pole-x: 66%;
        --pole-y: 20%;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    position: relative;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: clip;
    background: var(--sky);
    color: var(--text);
    font-family: "Cormorant Garamond", "Iowan Old Style", "Apple Garamond", Baskerville, "Times New Roman", serif;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none;
    user-select: none;
    cursor: default;
}

/* Sky */

.sky {
    position: absolute;
    inset: 0;
    overflow: clip;
    /* Trails fade with distance from the pole, so only faint ones cross the text. */
    --fade: radial-gradient(circle farthest-corner at var(--pole-x) var(--pole-y), #000 12%, transparent 60%);
    -webkit-mask-image: var(--fade);
    mask-image: var(--fade);
}

/* A 1px box at the pole, so circles drawn around 0,0 are centred on it
   and their radii stay in CSS pixels at every viewport size. */
.trails {
    position: absolute;
    top: var(--pole-y);
    left: var(--pole-x);
    width: 1px;
    height: 1px;
    overflow: visible;
    /* The same sweep for every star, as in a real long exposure. Units are degrees:
       script.js sets pathLength="360", and lengthens this while the shutter is open. */
    --sweep: 70;
}

.trails circle {
    fill: none;
    stroke: var(--trail);
    stroke-linecap: round;
    stroke-dasharray: var(--sweep) 360;
    animation: expose 9s cubic-bezier(.16, .7, .3, 1) both;
}

.trails circle.cool {
    stroke: var(--trail-cool);
}

.trails circle.warm {
    stroke: var(--trail-warm);
}

.trails circle.ember {
    stroke: var(--trail-ember);
}

@keyframes expose {
    from {
        stroke-dashoffset: var(--sweep);
    }
}

.polaris {
    position: absolute;
    z-index: 1;
    top: var(--pole-y);
    left: var(--pole-x);
    width: 26px;
    height: 26px;
    translate: -50% -50%;
    background: var(--star);
    clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
    animation: twinkle 5s ease-in-out infinite alternate;
}

@keyframes twinkle {
    to {
        opacity: .6;
        scale: .86;
    }
}

/* Ridge: one tile, masked twice at different scales for depth. */

.ridge {
    position: absolute;
    inset: auto 0 0;
    height: var(--ridge-height);
    pointer-events: none;
}

.ridge::before,
.ridge::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    -webkit-mask: url("/treeline.svg") repeat-x bottom / auto 100%;
    mask: url("/treeline.svg") repeat-x bottom / auto 100%;
}

.ridge::before {
    bottom: 22%;
    height: 62%;
    background: var(--ridge-far);
    -webkit-mask-position: 37% 100%;
    mask-position: 37% 100%;
}

.ridge::after {
    height: 100%;
    background: var(--ridge-near);
}

/* Content */

.intro {
    position: relative;
    z-index: 1;
    align-self: end;
    width: min(100%, 90rem);
    margin-inline: auto;
    padding: 3rem clamp(1.5rem, 6vw, 6rem) calc(var(--ridge-height) + 1rem);
    animation: rise 1.4s cubic-bezier(.16, .7, .3, 1) both;
}

@keyframes rise {
    from {
        opacity: 0;
        translate: 0 .75rem;
    }
}

h1 {
    margin: 0;
    font-size: clamp(4.5rem, 12vw, 11rem);
    font-weight: 500;
    line-height: .88;
    letter-spacing: -.025em;
    text-wrap: balance;
}

p {
    max-width: 40ch;
    /* Clears the descender of the y. */
    margin: clamp(1.75rem, 4.2vw, 4rem) 0 0;
    color: var(--text-soft);
    font-size: clamp(1.375rem, 2.2vw, 1.875rem);
    line-height: 1.2;
    text-wrap: balance;
}

a {
    color: var(--text);
    text-decoration-thickness: from-font;
    text-underline-offset: .12em;
}

@media (prefers-reduced-motion: reduce) {
    .trails circle,
    .polaris,
    .intro {
        animation: none;
    }
}
