/* ═══════════════ INFINITUS MAP (js/infinitus-map.js) ═══════════════
   The realm map: starfield canvas, the loop, twelve planets, the flowing current and the comet.
   Sizes inside the scene are in em off a font-size divided by --im-base, so they keep their on-screen
   size at the page's resting zoom and grow with the camera when it dives in. */

.im-viewport { position: relative; overflow: hidden; isolation: isolate; user-select: none; -webkit-user-select: none; touch-action: pan-y; perspective: 1400px; background: radial-gradient(ellipse at 50% 50%, #0d1430 0%, #070a18 55%, #03050c 100%); }
.im-dragging { cursor: grabbing; }
.im-stars { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.im-nebula { position: absolute; inset: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 34% 48% at 27% 50%, rgba(60, 100, 255, 0.16), transparent 70%),
        radial-gradient(ellipse 34% 48% at 73% 50%, rgba(170, 70, 255, 0.13), transparent 70%),
        radial-gradient(circle at 50% 50%, rgba(150, 190, 255, 0.14), transparent 24%); }
.im-tilt { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.2, .7, .2, 1); }
.im-camera { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.im-camera.im-moving { will-change: transform; }
.im-scene { position: relative; font-size: calc(11px / var(--im-base, 1)); opacity: 0; transition: opacity .8s ease; }
.im-ready .im-scene { opacity: 1; }
.im-loop { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }

/* current flowing round the figure-8 (the right lobe runs the other way, so it reads as one loop) */
.im-paths { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.im-flow { fill: none; stroke: rgba(225, 238, 255, 0.95); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 10 150 26 420; mix-blend-mode: screen; filter: drop-shadow(0 0 12px rgba(130, 175, 255, 0.95)); animation: im-flow-l 7s linear infinite; }
.im-flow-r { animation-name: im-flow-r; }
@keyframes im-flow-l { to { stroke-dashoffset: -1212; } }
@keyframes im-flow-r { to { stroke-dashoffset: 1212; } }
.im-trail-glow { fill: none; stroke: #ff9d00; stroke-width: 64; stroke-linecap: round; opacity: 0.45; }
.im-trail { fill: none; stroke: #ffc21a; stroke-width: 20; stroke-linecap: round; }
.im-trail-fade { opacity: 0; transition: opacity 1.6s ease .4s; }

.im-core { position: absolute; width: 6.5%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; mix-blend-mode: screen;
    background: radial-gradient(circle, rgba(255,255,255,0.85) 0%, rgba(160,195,255,0.5) 22%, rgba(80,120,255,0.18) 45%, transparent 70%);
    animation: im-core 4.2s ease-in-out infinite; }
@keyframes im-core { 0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.85); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.18); } }

/* ── planets ── */
.im-planet { position: absolute; transform: translate(-50%, -50%); display: block; height: auto; padding: 0; margin: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
div.im-planet { cursor: default; }
.im-planet::after { content: ''; position: absolute; inset: -30%; border-radius: 50%; }
.im-planet:focus { outline: none; }
.im-orb { position: relative; display: block; width: 100%; animation: im-bob var(--im-bob-d, 6s) ease-in-out var(--im-bob-delay, 0s) infinite; }
/* The planet the camera dives onto holds still: an animated layer keeps the resolution it started
   at, so a bobbing planet stays soft at close zoom. */
.im-focused .im-target .im-orb, .im-cinematic .im-target .im-orb { animation: none; }
@keyframes im-bob { 0%, 100% { transform: translateY(-3%); } 50% { transform: translateY(3%); } }
.im-orb img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none;
    filter: drop-shadow(0 0 .35em var(--im-glow)) drop-shadow(0 0 1em color-mix(in srgb, var(--im-glow) 55%, transparent));
    transition: transform .35s cubic-bezier(.3, 1.4, .5, 1), filter .35s ease; }
.im-planet:hover .im-orb img, .im-planet:focus-visible .im-orb img { transform: scale(1.14); filter: drop-shadow(0 0 .5em var(--im-glow)) drop-shadow(0 0 1.8em var(--im-glow)) brightness(1.12); }
.im-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: .5em; white-space: nowrap; pointer-events: none; font-family: 'HwyGothic', sans-serif; font-size: 1em; letter-spacing: .28em; text-indent: .28em; text-transform: uppercase; color: rgba(236, 240, 250, 0.82); text-shadow: 0 0 4px #000, 0 0 10px #000, 0 0 14px var(--im-glow); transition: opacity .3s, color .3s; }
.im-planet:hover .im-label, .im-planet:focus-visible .im-label { color: #fff; }
.im-chip { position: absolute; bottom: 100%; left: 50%; margin-bottom: .7em; white-space: nowrap; pointer-events: none; padding: .35em .9em; border-radius: 999px; font-family: 'HwyGothic', sans-serif; font-size: .78em; letter-spacing: .2em; color: #0b1020; background: linear-gradient(180deg, #ffe08a, #ffbf00); box-shadow: 0 0 1.2em rgba(255, 191, 0, 0.55); animation: im-chip 1.8s ease-in-out infinite; transition: opacity .3s; }
.im-chip:empty { display: none; }
@keyframes im-chip { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -.35em); } }
.im-ring { position: absolute; inset: -16%; border-radius: 50%; border: .18em solid var(--im-ring, #ffbf00); box-shadow: 0 0 .8em var(--im-ring, #ffbf00), inset 0 0 .8em var(--im-ring, #ffbf00); opacity: 0; pointer-events: none; }
.im-current .im-ring, .im-target .im-ring { animation: im-ring 2.2s ease-out infinite; }
.im-target { --im-ring: var(--im-glow); }
.im-origin .im-ring { --im-ring: rgba(143, 184, 255, 0.8); opacity: .6; }
@keyframes im-ring { 0% { opacity: 0.95; transform: scale(0.88); } 100% { opacity: 0; transform: scale(1.45); } }
.im-badge { position: absolute; z-index: 2; right: 2%; bottom: 2%; width: 1.7em; height: 1.7em; border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 1em; line-height: 1; border: .15em solid #0b1020; }
.im-cleared .im-badge { display: flex; background: #3fbf6b; color: #0b1020; }
.im-cleared .im-badge::before { content: '\2713'; font-weight: bold; }
.im-locked .im-orb img { filter: grayscale(0.85) brightness(0.45); }
.im-locked:hover .im-orb img { filter: grayscale(0.6) brightness(0.65); }
.im-locked .im-badge { display: flex; background: rgba(9, 11, 22, 0.9); color: rgba(236, 240, 250, 0.7); border-color: rgba(143, 184, 255, 0.4); }
.im-locked .im-badge::before { content: '\f023'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: .8em; }
.im-locked .im-label { color: rgba(236, 240, 250, 0.45); }
.im-focused .im-label, .im-focused .im-chip, .im-focused .im-badge, .im-cinematic .im-label, .im-cinematic .im-chip, .im-cinematic .im-badge { opacity: 0; transition: opacity .3s; }

/* ── comet, sparks and shockwaves ── */
.im-comet { position: absolute; width: 2.6em; height: .8em; transform-origin: 100% 50%; pointer-events: none; opacity: 0; z-index: 5; border-radius: .45em;
    background: linear-gradient(90deg, transparent, rgba(143, 184, 255, 0.35) 35%, rgba(255, 214, 120, 0.8) 80%, #fff); transition: opacity .25s; }
.im-comet::after { content: ''; position: absolute; right: -.9em; top: 50%; width: 1.8em; height: 1.8em; transform: translateY(-50%); border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, #fff6d6 35%, rgba(255, 191, 0, 0.6) 60%, transparent 72%);
    box-shadow: 0 0 1em #fff, 0 0 2.4em #ffbf00, 0 0 4.5em rgba(143, 184, 255, 0.9); }
.im-comet-on { opacity: 1; }
.im-spark { position: absolute; z-index: 4; width: .45em; height: .45em; border-radius: 50%; pointer-events: none; background: #fff3c4; box-shadow: 0 0 .4em #ffbf00, 0 0 1.1em rgba(255, 157, 0, 0.9); transform: translate(-50%, -50%); animation: im-spark .85s ease-out forwards; }
@keyframes im-spark { to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.1); } }
.im-shock { position: absolute; z-index: 4; aspect-ratio: 1; border-radius: 50%; pointer-events: none; border: .25em solid var(--im-glow); box-shadow: 0 0 1.4em var(--im-glow), inset 0 0 1.4em var(--im-glow); transform: translate(-50%, -50%) scale(0.3); animation: im-shock .9s ease-out forwards; }
.im-shock-big { animation-duration: 1.3s; }
.im-shock-big::before { content: ''; position: absolute; inset: 20%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.9), transparent 70%); animation: im-flash .7s ease-out forwards; }
@keyframes im-shock { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.3); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); } }
@keyframes im-flash { 0% { opacity: 1; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.4); } }

/* ── focus mode: back button and the planet's panel ── */
.im-back { position: absolute; z-index: 6; top: 12px; left: 12px; height: auto; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-family: 'HwyGothic', sans-serif; font-size: 0.72rem; letter-spacing: 2px; color: #ffe9a8; background: rgba(9, 11, 22, 0.78); border: 1px solid rgba(143, 184, 255, 0.35); backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transform: translateY(-6px); transition: opacity .35s, transform .35s, border-color .2s; }
.im-back:hover { border-color: rgba(255, 233, 168, 0.7); }
.im-focused .im-back { opacity: 1; pointer-events: auto; transform: none; transition-delay: .5s; }
.im-panel { position: absolute; z-index: 6; right: 16px; top: 50%; width: min(380px, 44%); max-height: calc(100% - 32px); overflow-y: auto; box-sizing: border-box; padding: 18px 18px 16px; border-radius: 16px; text-align: left;
    background: linear-gradient(180deg, rgba(16, 24, 48, 0.9) 0%, rgba(9, 11, 22, 0.94) 100%); border: 1px solid rgba(143, 184, 255, 0.3); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); backdrop-filter: blur(8px);
    opacity: 0; pointer-events: none; transform: translate(28px, -50%); transition: opacity .45s ease, transform .45s ease; }
.im-focused .im-panel { opacity: 1; pointer-events: auto; transform: translate(0, -50%); transition-delay: .55s; }

/* ── cinematic ── */
.im-cinema-open { overflow: hidden; }
.im-cinema { position: fixed; inset: 0; z-index: 3000; background: #03050c; opacity: 0; transition: opacity .5s ease; }
.im-cinema-in { opacity: 1; }
.im-cinema.im-cinema-out { opacity: 0; transition: opacity .45s ease; }
.im-cinema-stage { position: absolute; inset: 0; }
.im-viewport.im-cinematic { position: absolute; inset: 0; touch-action: none; }
.im-cinema-bar { position: absolute; z-index: 2; left: 0; right: 0; height: 9vh; background: #000; transform: scaleY(0); transition: transform .8s cubic-bezier(.65, 0, .35, 1); }
.im-cinema-bar-top { top: 0; transform-origin: top; }
.im-cinema-bar-bottom { bottom: 0; transform-origin: bottom; }
.im-cinema-in .im-cinema-bar { transform: scaleY(1); }
.im-cinema-card { position: absolute; z-index: 3; left: 16px; right: 16px; bottom: calc(9vh + 4vh); text-align: center; pointer-events: none; }
.im-cinema-kicker { display: block; font-family: 'HwyGothic', sans-serif; font-size: clamp(0.7rem, 1.3vw, 0.95rem); letter-spacing: .5em; text-indent: .5em; color: #c4d8ff; text-shadow: 0 0 6px #000, 0 0 14px #000, 0 0 18px rgba(143, 184, 255, 0.6); opacity: 0; transform: translateY(10px); transition: opacity .6s, transform .6s; }
.im-cinema-name { margin: .08em 0 0; font-family: 'DragonSlayer', 'HwyGothic', sans-serif; font-weight: normal; font-size: clamp(2.6rem, 8vw, 6.2rem); line-height: 1; letter-spacing: .1em; text-indent: .1em; text-transform: uppercase;
    background: linear-gradient(180deg, #fff6d6, #ffbf00 60%, #c98a00); -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 0 18px var(--im-glow)) drop-shadow(0 4px 10px #000); opacity: 0; transform: scale(0.9); transition: opacity .8s ease .1s, transform 1.4s cubic-bezier(.2, .7, .2, 1) .1s, letter-spacing 2.4s ease; }
.im-cinema-sub { margin: .5em 0 0; font-size: clamp(0.95rem, 2vw, 1.25rem); font-style: italic; color: #ffe9a8; text-shadow: 0 0 10px #000, 0 0 4px #000; opacity: 0; transform: translateY(8px); transition: opacity .7s ease .5s, transform .7s ease .5s; }
.im-cinema-card-in .im-cinema-kicker, .im-cinema-card-in .im-cinema-name { opacity: 1; transform: none; }
.im-cinema-landed .im-cinema-name { letter-spacing: .16em; text-indent: .16em; }
.im-cinema-landed .im-cinema-sub { opacity: 1; transform: none; }
.im-cinema-skip { position: absolute; z-index: 4; right: 16px; top: calc(9vh + 14px); height: auto; display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; cursor: pointer; font-family: 'HwyGothic', sans-serif; font-size: 0.72rem; letter-spacing: 2px; color: #ffe9a8; background: rgba(9, 11, 22, 0.6); border: 1px solid rgba(143, 184, 255, 0.35); backdrop-filter: blur(4px); transition: border-color .2s, color .2s; }
.im-cinema-skip:hover { border-color: rgba(255, 233, 168, 0.7); color: #ffbf00; }
.im-cinema-still-img { position: absolute; left: 50%; top: 42%; width: min(44vh, 60vw); transform: translate(-50%, -50%); filter: drop-shadow(0 0 30px rgba(143, 184, 255, 0.6)); }

/* ── phone ── */
@media only screen and (max-width: 767px) {
    .im-panel { left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-height: 56%; transform: translateY(28px); }
    .im-focused .im-panel { transform: none; }
    .im-cinema-bar { height: 7vh; }
    .im-cinema-skip { top: calc(7vh + 10px); }
    .im-cinema-card { bottom: calc(7vh + 5vh); }
}

@media (prefers-reduced-motion: reduce) {
    .im-orb, .im-flow, .im-core, .im-chip, .im-current .im-ring, .im-target .im-ring { animation: none; }
    .im-current .im-ring, .im-target .im-ring { opacity: .9; }
    .im-camera { transition-duration: .2s !important; }
}
