/* The home map: sky, mountain, camps, arrows, peaks row. */

/* No card: the mountain and its sky ARE the page, edge to edge. */
.home-map-shell {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5;
    /* Foothills: dusk. Each mountain has its own sky. */
    --hm-sky-0: #0a0f24;
    --hm-sky-1: #1a2342;
    --hm-sky-2: #453e66;
    --hm-sky-3: #a06a58;
    --hm-sky-4: #e8b072;
    --hm-sky-5: #f4d6a0;
}

/* The Am path: blue hour. */
.home-map-shell[data-world='am-path'] {
    --hm-sky-0: #070d22;
    --hm-sky-1: #13234a;
    --hm-sky-2: #2c4472;
    --hm-sky-3: #56699a;
    --hm-sky-4: #9aa6c8;
    --hm-sky-5: #d6d6e6;
}

/* The IV: dawn. */
.home-map-shell[data-world='the-iv'] {
    --hm-sky-0: #120f2c;
    --hm-sky-1: #2b2350;
    --hm-sky-2: #6b3f6e;
    --hm-sky-3: #c4607a;
    --hm-sky-4: #f09a8a;
    --hm-sky-5: #fbd2b0;
}

/* The web of changes: deep night, a green glow on the horizon. */
.home-map-shell[data-world='web-of-changes'] {
    --hm-sky-0: #04060f;
    --hm-sky-1: #0b1530;
    --hm-sky-2: #173058;
    --hm-sky-3: #1f5a6e;
    --hm-sky-4: #3f8f8a;
    --hm-sky-5: #9fd1b8;
}

/* The open neck: deep starlit indigo warming into copper-gold on the horizon. */
.home-map-shell[data-world='open-neck'] {
    --hm-sky-0: #050514;
    --hm-sky-1: #141236;
    --hm-sky-2: #302154;
    --hm-sky-3: #6c385a;
    --hm-sky-4: #bf6b56;
    --hm-sky-5: #f0b878;
}

#hm-sky stop {
    transition: stop-color 600ms ease;
}

.hm-sky-0 {
    stop-color: var(--hm-sky-0);
}

.hm-sky-1 {
    stop-color: var(--hm-sky-1);
}

.hm-sky-2 {
    stop-color: var(--hm-sky-2);
}

.hm-sky-3 {
    stop-color: var(--hm-sky-3);
}

.hm-sky-4 {
    stop-color: var(--hm-sky-4);
}

.hm-sky-5 {
    stop-color: var(--hm-sky-5);
}

body.home-map-mode .home-map-shell {
    display: block;
}

/* The mountain itself. Terrain SVG stretches to fill the viewport; trail
   nodes are positioned in the same coordinate space so everything stays
   aligned at any screen shape. */
.home-map-scene {
    position: absolute;
    inset: 0;
    overflow: hidden;
    /* Sideways swipes belong to the map: they turn to the next mountain. */
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

#home-map-terrain {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.hm-star {
    animation: hm-twinkle 3.4s ease-in-out infinite;
}

.hm-star:nth-child(2n) {
    animation-delay: 1.1s;
}

.hm-star:nth-child(3n) {
    animation-delay: 2.2s;
}

.hm-star:nth-child(5n) {
    animation-duration: 4.6s;
}

@keyframes hm-twinkle {
    0%,
    100% {
        opacity: 0.9;
    }
    50% {
        opacity: 0.2;
    }
}

.home-map-clouds {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.cloud {
    position: absolute;
    display: block;
    border-radius: 999px;
    background: radial-gradient(
        ellipse at center,
        rgba(226, 232, 255, 0.16),
        rgba(226, 232, 255, 0) 70%
    );
    filter: blur(6px);
}

.shooting-star {
    position: absolute;
    top: 9%;
    left: -6%;
    width: 90px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff);
    opacity: 0;
    pointer-events: none;
    animation: hm-shoot 19s linear infinite;
}

.shooting-star--b {
    top: 22%;
    left: 30%;
    width: 70px;
    animation-duration: 31s;
    animation-delay: 11s;
}

@keyframes hm-shoot {
    0%,
    91% {
        opacity: 0;
        transform: translate(0, 0) rotate(9deg);
    }
    92.5% {
        opacity: 0.9;
    }
    98%,
    100% {
        opacity: 0;
        transform: translate(58vw, 11vw) rotate(9deg);
    }
}

.cloud-a {
    width: 44%;
    height: 12%;
    top: 12%;
    left: -10%;
    animation: hm-drift 90s linear infinite;
}

.cloud-b {
    width: 34%;
    height: 9%;
    top: 26%;
    left: 30%;
    animation: hm-drift 120s linear infinite reverse;
}

.cloud-c {
    width: 50%;
    height: 10%;
    top: 6%;
    left: 55%;
    animation: hm-drift 105s linear infinite;
    animation-delay: -40s;
}

@keyframes hm-drift {
    from {
        transform: translateX(-30%);
    }
    to {
        transform: translateX(130%);
    }
}

.home-map-node-field {
    position: absolute;
    inset: 0;
    z-index: 2;
}

/* Camps on the trail: marker centered on the trail point, label pill
   beside it (side alternates so neighbors never stack). */
.map-node {
    position: absolute;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 7px;
    transform: translate(-16px, -16px);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--home-map-ink);
    -webkit-tap-highlight-color: transparent;
}

.map-node--label-left {
    flex-direction: row-reverse;
    transform: translate(calc(-100% + 16px), -16px);
}

/* No room on either side: the label sits above or below the marker. */
.map-node--label-above {
    flex-direction: column-reverse;
    gap: 3px;
    transform: translate(-50%, calc(-100% + 16px));
}

.map-node--label-below {
    flex-direction: column;
    gap: 3px;
    transform: translate(-50%, -16px);
}

.map-node__marker {
    position: relative;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 15px;
    color: #f4f7ff;
    background: radial-gradient(
        circle at 35% 30%,
        #8f9ab5,
        #5a6480 55%,
        #39415a
    );
    border: 2px solid rgba(255, 246, 227, 0.75);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.5),
        0 0 0 3px rgba(20, 24, 40, 0.35);
    transition:
        transform 140ms ease,
        box-shadow 140ms ease;
}

.map-node__label {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff7ea;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    background: rgba(10, 13, 26, 0.62);
    border: 1px solid rgba(255, 240, 214, 0.14);
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.map-node__stars {
    font-size: 10px;
    letter-spacing: 0.14em;
    color: #f2c46d;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.map-node__stars.is-zero {
    color: rgba(255, 255, 255, 0.38);
}

.map-node.is-recommended {
    z-index: 1;
}

/* No room beside the marker (phones in landscape): the camp keeps only
   its stars, tucked under the marker. Labels never run over each other. */
.map-node.is-label-hidden .map-node__label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, -4px);
    padding: 0;
    background: none;
    border: none;
}

.map-node.is-label-hidden .map-node__title {
    display: none;
}

.map-node.is-label-hidden .map-node__stars {
    font-size: 8px;
    letter-spacing: 0.02em;
}

.map-node.is-label-hidden.has-no-stars .map-node__label {
    display: none;
}

.map-node:hover:not(:disabled) .map-node__marker {
    transform: scale(1.14);
}

.map-node.is-completed .map-node__marker {
    background: radial-gradient(
        circle at 35% 30%,
        #d9f2df,
        #9dc4ab 55%,
        #5f8f74
    );
    border-color: rgba(226, 255, 235, 0.85);
    color: #0f2417;
}

.map-node--unlock .map-node__marker {
    background: radial-gradient(
        circle at 35% 30%,
        #cdebd6,
        #9dc4ab 60%,
        #6c9a80
    );
    color: #12291b;
    font-size: 19px;
}

.map-node--utility .map-node__marker {
    background: radial-gradient(
        circle at 35% 30%,
        #ffe9bd,
        #f2c46d 60%,
        #cf9a49
    );
    color: #241503;
}

.map-node.is-recommended .map-node__marker {
    background: radial-gradient(
        circle at 35% 30%,
        #fffdf6,
        #ffe9bd 60%,
        #f2c46d
    );
    color: #241503;
    animation: hm-beacon 2s ease-in-out infinite;
}

.map-node.is-recommended .map-node__marker::before {
    content: '⚑';
    position: absolute;
    top: -26px;
    left: 50%;
    font-size: 17px;
    color: #ffd98c;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    animation: hm-bob 1.6s ease-in-out infinite;
}

@keyframes hm-beacon {
    0%,
    100% {
        box-shadow:
            0 4px 14px rgba(0, 0, 0, 0.5),
            0 0 0 0 rgba(242, 196, 109, 0.55);
    }
    50% {
        box-shadow:
            0 4px 14px rgba(0, 0, 0, 0.5),
            0 0 0 11px rgba(242, 196, 109, 0);
    }
}

@keyframes hm-bob {
    0%,
    100% {
        transform: translate(-50%, 0);
    }
    50% {
        transform: translate(-50%, -5px);
    }
}

.map-node.is-locked {
    opacity: 0.42;
    filter: grayscale(0.7);
    cursor: not-allowed;
}

.map-node.is-selected .map-node__marker {
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.55),
        0 4px 14px rgba(0, 0, 0, 0.5);
}

.map-node.just-cleared .map-node__marker {
    animation: hm-clear-pop 1.4s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes hm-clear-pop {
    0% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.7);
    }
    55% {
        transform: scale(0.92);
    }
    100% {
        transform: scale(1);
    }
}

.home-map-title {
    position: absolute;
    top: 18px;
    left: 22px;
    z-index: 3;
    pointer-events: none;
}

#home-map-heading {
    font-family: 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
    font-size: clamp(26px, 3.4vw, 44px);
    line-height: 0.95;
    letter-spacing: 0.04em;
    color: #fff7ec;
    text-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

#home-map-recommendation {
    margin-top: 7px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 236, 205, 0.85);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.home-map-shell__actions {
    position: absolute;
    right: 18px;
    /* Clear of the version stamp in the corner. */
    bottom: 34px;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.home-map-shell__actions button {
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 238, 213, 0.16);
    background: rgba(23, 28, 40, 0.68);
    color: #fff5e3;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: inset 0 1px 0 rgba(255, 247, 230, 0.07);
}

.home-map-shell__actions button:hover {
    transform: translateY(-1px);
}

/* Arrows at the screen edges step to the neighboring mountain. The one
   pointing toward the next camp glows like the next camp does. */
.home-map-arrow {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 38px;
    height: 38px;
    margin-top: -19px;
    padding: 0 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 238, 213, 0.22);
    background: rgba(23, 28, 40, 0.68);
    color: #fff5e3;
    font:
        900 26px/1 system-ui,
        sans-serif;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.home-map-arrow[hidden] {
    display: none;
}

.home-map-arrow--prev {
    left: 10px;
}

.home-map-arrow--next {
    right: 10px;
}

.home-map-arrow:hover {
    filter: brightness(1.2);
}

.home-map-arrow.is-beckoning {
    color: #241503;
    border-color: rgba(255, 246, 227, 0.8);
    background: radial-gradient(
        circle at 35% 30%,
        #fffdf6,
        #ffe9bd 60%,
        #f2c46d
    );
    animation: hm-beacon 2s ease-in-out infinite;
}

/* One peak per mountain: the big one is where you are, green ones are
   climbed, the gold one holds the next camp. Tap one to go there. */
.home-map-worlds {
    position: absolute;
    left: 50%;
    bottom: 8px;
    z-index: 3;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(10, 13, 26, 0.5);
}

.home-map-worlds[hidden] {
    display: none;
}

.home-map-world {
    width: 30px;
    height: 30px;
    padding: 0 0 7px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border: none;
    background: none;
    color: rgba(255, 246, 227, 0.55);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.home-map-world__peak {
    display: block;
    width: 12px;
    height: 10px;
    background: currentColor;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    transition:
        width 200ms ease,
        height 200ms ease;
}

.home-map-world.is-current {
    color: #fff7ea;
}

.home-map-world.is-current .home-map-world__peak {
    width: 20px;
    height: 16px;
}

.home-map-world.is-locked {
    color: rgba(255, 255, 255, 0.28);
}

.home-map-world.is-climbed {
    color: #9dc4ab;
}

.home-map-world.is-next {
    color: #f2c46d;
}

/* Turning to another mountain: its camps slide in from that side. */
.home-map-scene.is-arriving-from-right .home-map-node-field {
    animation: hm-arrive-right 340ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.home-map-scene.is-arriving-from-left .home-map-node-field {
    animation: hm-arrive-left 340ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.home-map-scene.is-arriving-from-right #trail-base,
.home-map-scene.is-arriving-from-right #trail-progress,
.home-map-scene.is-arriving-from-left #trail-base,
.home-map-scene.is-arriving-from-left #trail-progress {
    animation: hm-fade-in 340ms ease-out;
}

@keyframes hm-arrive-right {
    from {
        opacity: 0;
        transform: translateX(36px);
    }
}

@keyframes hm-arrive-left {
    from {
        opacity: 0;
        transform: translateX(-36px);
    }
}

@keyframes hm-fade-in {
    from {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-map-scene .home-map-node-field,
    .home-map-scene #trail-base,
    .home-map-scene #trail-progress {
        animation: none !important;
    }

    #hm-sky stop {
        transition: none;
    }
}

/* Mobile responsive (phones in either orientation) */
@media (max-width: 720px), (max-height: 500px) {
    /* The gold action button already covers this on small screens. */
    .map-node--utility {
        display: none;
    }

    .map-node__label {
        font-size: 10px;
        padding: 1px 7px;
    }

    .map-node {
        transform: translate(-14px, -14px);
    }

    .map-node--label-left {
        transform: translate(calc(-100% + 14px), -14px);
    }

    .map-node--label-above {
        transform: translate(-50%, calc(-100% + 14px));
    }

    .map-node--label-below {
        transform: translate(-50%, -14px);
    }

    .map-node__marker {
        width: 27px;
        height: 27px;
        font-size: 13px;
    }

    .home-map-title {
        top: 12px;
        left: 14px;
    }

    .home-map-shell__actions {
        right: 10px;
        bottom: 30px;
        gap: 6px;
    }

    .home-map-shell__actions button {
        padding: 8px 12px;
        font-size: 12px;
    }

    .home-map-arrow {
        width: 32px;
        height: 32px;
        margin-top: -16px;
        font-size: 22px;
    }

    .home-map-arrow--prev {
        left: 6px;
    }

    .home-map-arrow--next {
        right: 6px;
    }

    .home-map-worlds {
        bottom: 6px;
    }

    .home-map-world {
        width: 28px;
        height: 26px;
        padding-bottom: 6px;
    }
}
