/* ZeroGrav DM: the front page.
   Sizes scale with the screen through --k (set by home.js from the size of the worlds). */

@font-face { font-family: "IM Fell English"; src: url(../assets/fonts/IMFellEnglish-400-latin.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "IM Fell English SC"; src: url(../assets/fonts/IMFellEnglishSC-400-latin.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Alegreya"; font-style: italic; src: url(../assets/fonts/Alegreya-400i-latin.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Alegreya Sans"; font-weight: 400; src: url(../assets/fonts/AlegreyaSans-400-latin.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Shadows Into Light"; src: url(../assets/fonts/ShadowsIntoLight-400-latin.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Star Jedi"; src: url(../assets/fonts/StarJedi.woff2) format("woff2"); font-display: block; }
@font-face { font-family: "Aurebesh Bold"; src: url(../assets/fonts/AurebeshBold.woff2) format("woff2"); font-display: block; }

:root {
  --sky-top: #04060c;
  --sky-bot: #080b17;
  --cream: #efe2c4;
  --ink-2: #a79f89;
  --ink-3: #676253;
  --brass-hi: #e7c27a;
  --warm: 217, 166, 75;
  --cool: 111, 184, 255;
  --warm-a: .21;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: linear-gradient(180deg, var(--sky-top), var(--sky-bot)); color: var(--cream); font-family: "Alegreya Sans", system-ui, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }

/* text for screen readers only */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* two lights: warm on Arania's side, cold on the hologram's */
.light { position: fixed; inset: 0; pointer-events: none; transition: opacity .3s ease;
  background:
    radial-gradient(44vmax 36vmax at var(--wx, 25%) var(--wy, 50%), rgba(var(--warm), var(--warm-a)), rgba(var(--warm), calc(var(--warm-a) / 3)) 45%, transparent 72%),
    radial-gradient(40vmax 34vmax at var(--cx, 75%) var(--cy, 50%), rgba(var(--cool), .19), rgba(var(--cool), .06) 45%, transparent 72%); }
/* pointing at Arania turns its warm light up, slowly */
.light::after { content: ""; position: absolute; inset: 0; background: radial-gradient(44vmax 36vmax at var(--wx, 25%) var(--wy, 50%), rgba(var(--warm), .13), rgba(var(--warm), .045) 45%, transparent 72%); opacity: 0; transition: opacity 2s ease; }
body.hover-a .light::after { opacity: 1; transition: opacity 1.8s cubic-bezier(.45,0,.35,1); }
#sky, #orrery { position: fixed; inset: 0; width: 100%; height: 100%; }
#orrery { pointer-events: none; }

/* the maker's mark, at the heart of the orbit (home.js keeps it there; this is where it starts) */
.brand { position: fixed; left: 50%; top: 47%; z-index: 6; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
@media (max-aspect-ratio: 10/11) { .brand { top: 42%; } }
.logo { font-family: "IM Fell English", Georgia, serif; font-size: max(30px, calc(40px * var(--k, 1))); line-height: 1; color: var(--cream); white-space: nowrap; margin: 0; font-weight: 400; }
.logo small { font-family: "IM Fell English SC", Georgia, serif; font-size: .62em; margin-left: .18em; color: var(--brass-hi); letter-spacing: .02em; }

/* the worlds: hidden until home.js has put them on the orbit */
/* the worlds' stage covers the screen and clips at its edges: a hologram reaching past the side of a phone
   mustn't make the phone widen the page */
main { position: absolute; inset: 0; overflow: clip; }
.world { position: absolute; left: 0; top: 0; will-change: transform; color: inherit; text-decoration: none; }
html:not(.laid) .world { visibility: hidden; }
.cap { position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: 88vw; text-align: center; }
.sub { margin: calc(8px * var(--k, 1)) 0 0; font-family: "Alegreya", Georgia, serif; font-style: italic; font-size: max(15px, calc(17px * var(--k, 1))); color: var(--ink-2); text-wrap: balance; }
.hand { margin: calc(4px * var(--k, 1)) 0 0; font-family: "Shadows Into Light", cursive; font-size: max(20px, calc(23px * var(--k, 1))); line-height: 1.2; color: var(--cream); transform: rotate(-3deg); }

/* Arania: the planet and its title are one link */
#arania { outline: none; cursor: pointer; }
#arania .body { width: var(--d); height: var(--d); touch-action: pan-y; opacity: 0; }
#globe { width: 100%; height: 100%; display: block; }
#arania .cap { top: var(--cap-top, calc(100% + 16px)); }
#arania .title { display: block; height: max(26px, calc(34px * var(--k, 1))); width: auto; margin: 0 auto; opacity: .92; transition: opacity .9s ease, filter .9s ease; }
#arania:hover .title, #arania:focus-visible .title { opacity: 1; filter: brightness(1.12); }
#arania .sub { transition: color .9s ease; }
#arania:hover .sub, #arania:focus-visible .sub { color: var(--cream); }
#arania:focus-visible #globe, #arania:focus-visible .globe-flat { outline: 2px solid var(--brass-hi); outline-offset: 6px; border-radius: 50%; }

/* the flat globe: the map in a circle with painted light, for browsers without WebGL (and the no-script page).
   --sun-x/--sun-y: where the warm light is overhead; --rim-x/--rim-y: which way the cold light comes from. */
.globe-flat { --sun-x: 15%; --sun-y: 31%; --rim-x: 1; --rim-y: 0;
  display: none; position: relative; width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  background: url(../assets/globe-map.webp) 54.8% 50% / 200% 100% no-repeat, #b9bfae; }
.globe-flat::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(ellipse 100% 100% at var(--sun-x) var(--sun-y), rgba(255, 244, 222, .1), transparent 40%),
    radial-gradient(ellipse 100% 100% at var(--sun-x) var(--sun-y), transparent 57%, rgba(14, 13, 20, .7) 68%, rgba(12, 11, 16, .86));
  box-shadow: inset calc(var(--rim-x) * -9px) calc(var(--rim-y) * -9px) 11px -4px rgba(107, 168, 255, .75), inset 0 0 0 1.5px rgba(18, 15, 18, .45); }
.globe-flat::after { content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(18, 15, 18, .6) 0 1.5px, transparent 1.5px 4.24px);
  -webkit-mask: radial-gradient(ellipse 100% 100% at var(--sun-x) var(--sun-y), transparent 60%, #000 74%);
  mask: radial-gradient(ellipse 100% 100% at var(--sun-x) var(--sun-y), transparent 60%, #000 74%); }
#arania.flat #globe { display: none; }
#arania.flat .globe-flat { display: block; }

/* Galactic Legends: a hologram, not yet resolved. The projector (puck, lens, cone and galaxy) powers on as one piece. */
#gl { outline: none; }
#gl .body { width: var(--d); height: calc(var(--d) * .9); perspective: 900px; cursor: default; opacity: 0; transition: opacity .5s ease; }
#gl.ready .body { opacity: 1; }
#gl:focus-visible .gl-title { text-shadow: 0 0 .35em rgba(147, 213, 255, .55); }
.holo-plane { position: absolute; left: 50%; top: 40%; width: calc(var(--d) * 1.3); height: calc(var(--d) * 1.3); margin: calc(var(--d) * -.65) 0 0 calc(var(--d) * -.65); transform: rotateX(56deg) rotateZ(var(--spin, 0deg)); }
.holo-plane img { width: 100%; height: 100%; display: block; mix-blend-mode: screen; opacity: .9; }
.holo-flicker { position: absolute; inset: 0; opacity: 0; transition: opacity .5s ease; }
.ready .holo-flicker { opacity: 1; animation: flicker 9s steps(1) infinite; }
@keyframes flicker { 0% { opacity: 1; } 41% { opacity: .82; } 42% { opacity: 1; } 77% { opacity: .9; transform: translateX(1px); } 78% { opacity: 1; transform: none; } 93% { opacity: .7; } 94% { opacity: 1; } }
.scan { position: absolute; left: 6%; right: 6%; top: 16%; height: 52%; background: repeating-linear-gradient(0deg, rgba(147,213,255,.10) 0 1px, transparent 1px 3px); -webkit-mask: radial-gradient(closest-side, #000 55%, transparent); mask: radial-gradient(closest-side, #000 55%, transparent); pointer-events: none; mix-blend-mode: screen; }
.beam { position: absolute; left: 50%; bottom: 7%; width: 84%; height: 50%; transform: translateX(-50%); background: linear-gradient(0deg, rgba(147,213,255,.14), rgba(147,213,255,0)); clip-path: polygon(46% 100%, 54% 100%, 100% 0, 0 0); opacity: 0; transition: opacity .5s ease; }
#gl.ready .beam { opacity: .7; }
#gl.ready.red .beam { opacity: .15; }
.emitter { position: absolute; left: 50%; bottom: 3%; width: 22%; height: 7%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #3a4150, #161a22 70%); box-shadow: inset 0 -2px 0 rgba(255,255,255,.08), 0 2px 0 #05070c; }
.emitter::after { content: ""; position: absolute; left: 50%; top: 22%; width: 28%; height: 40%; transform: translateX(-50%); border-radius: 50%; background: #2b3340; box-shadow: none; transition: background .7s ease, box-shadow .7s ease; }
#gl.ready .emitter::after { background: #bfe6ff; box-shadow: 0 0 10px rgba(147,213,255,.8); }

/* the war: red spreads from the core; the cone and the lens turn red.
   With WebGL, home.js drives the red cone and the lens step by step; the images below are the fallback. */
.holo-red { position: absolute; inset: 0; mix-blend-mode: normal;
  -webkit-mask: radial-gradient(circle at 46% 50%, #000 35%, transparent 70%) center / 0% 0% no-repeat; mask: radial-gradient(circle at 46% 50%, #000 35%, transparent 70%) center / 0% 0% no-repeat;
  opacity: 0; transition: opacity .7s ease, -webkit-mask-size 0s linear .7s, mask-size 0s linear .7s; }
.holo-red img { opacity: 1; }
.beam-red { position: absolute; left: 50%; bottom: 7%; width: 84%; height: 50%; transform: translateX(-50%); background: linear-gradient(0deg, rgba(255,70,55,.3), rgba(255,70,55,0)); clip-path: polygon(46% 100%, 54% 100%, 100% 0, 0 0); opacity: 0; transition: opacity .7s ease; }
.scan-red { background: repeating-linear-gradient(0deg, rgba(255,90,72,.12) 0 1px, transparent 1px 3px); opacity: 0; transition: opacity .7s ease; }
#gl.red .beam-red, #gl.red .scan-red { transition-duration: 1s; }
#gl.red .emitter::after { transition-duration: .8s; }
#gl.red .holo-red { opacity: 1; -webkit-mask-size: 280% 280%; mask-size: 280% 280%; transition: opacity .25s ease, -webkit-mask-size 1.4s cubic-bezier(.3,.6,.2,1), mask-size 1.4s cubic-bezier(.3,.6,.2,1); }
#gl.red .beam-red { opacity: 1; }
#gl.red .emitter::after { background: #ff5a48; box-shadow: 0 0 12px rgba(255,70,55,.9); }
#gl.red .scan-red { opacity: 1; }
#holo { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; mix-blend-mode: screen; }
.ray-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; mix-blend-mode: screen; }
#gl.gl-holo .beam-red { transition: none; }
#gl.gl-holo.ready .emitter::after { background: var(--lens, #bfe6ff); box-shadow: 0 0 12px var(--lens-glow, rgba(147,213,255,.8)); transition: none; }
#gl.gl-holo #holo { opacity: 1; }
#gl.gl-holo .holo-img, #gl.gl-holo .holo-red { display: none; }

#gl .cap { top: var(--cap-top, calc(100% + 4px)); }
.gl-title { font-family: "Star Jedi", sans-serif; line-height: 1; color: #d5ebff; white-space: nowrap; font-size: max(26px, calc(40px * var(--k, 1))); display: inline-block; transform: scaleY(1.2); transform-origin: 50% 0; }
.portrait .gl-title { font-size: 26px; }
#gl .sub { color: #8d9db0; }
#gl .hand { color: #93d5ff; }
/* Coming "soon", in Aurebesh until you look closer: each letter sits in its own slot. All the slots ease to
   their new widths together over the whole sweep (home.js sets --dec-dur), so the line stays centred, and a
   glyph wider than its slot spills out evenly on both sides. */
.decode { min-height: 1.2em; }
.decode .c { display: inline-flex; justify-content: center; transition: width var(--dec-dur, .2s) cubic-bezier(.4,0,.2,1); }
.decode .c.aur { font-family: "Aurebesh Bold", sans-serif; font-size: .72em; }

/* blaster fire from the planets at war (lasers.js draws it). It lies on the hologram's own plane, so it tilts and
   turns with the galaxy. */
.lasers { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: screen; }

.portrait #arania .cap, .portrait #gl .cap { width: min(88vw, 330px); }

/* sound: a speaker in the top corner, with its volume sliding out beside it */
.sound { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); z-index: 8; display: flex; flex-direction: row-reverse; align-items: center; gap: 10px; }
.sound[hidden] { display: none; }
.sound-btn { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(239, 226, 196, .2); border-radius: 50%; background: rgba(4, 6, 12, .45); color: var(--ink-2); cursor: pointer; transition: color .3s ease, border-color .3s ease; }
.sound-btn:hover, .sound-btn:focus-visible { color: var(--cream); border-color: rgba(239, 226, 196, .45); }
.sound-btn:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; }
.sound-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn .spk { fill: currentColor; stroke: none; }
.sound-btn .waves, html.sound-on .sound-btn .x { display: none; }
html.sound-on .sound-btn .waves { display: inline; }
/* on, but waiting for the visitor's first click (browsers insist on one): the speaker breathes */
html.sound-wait .sound-btn { animation: sound-wait 2.6s ease-in-out infinite; }
@keyframes sound-wait { 50% { color: var(--cream); border-color: rgba(239, 226, 196, .5); } }
.sound-vol { width: 0; margin: 0; opacity: 0; accent-color: var(--brass-hi); cursor: pointer; transition: width .3s ease, opacity .3s ease; }
.sound:hover .sound-vol, .sound:focus-within .sound-vol { width: 96px; opacity: 1; }
@media (hover: none) { .sound-vol { display: none; } }

/* the credit line */
.credits { position: fixed; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); margin: 0; font-size: 12px; color: var(--ink-3); z-index: 5; text-align: center; }
.credits a { color: inherit; text-decoration: underline; text-decoration-color: rgba(103, 98, 83, .55); text-underline-offset: 2px; transition: color .3s ease; }
.credits a:hover, .credits a:focus-visible { color: var(--ink-2); }
.credits a:focus-visible { outline: 1px solid var(--ink-2); outline-offset: 2px; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  .ready .holo-flicker { animation: none; }
  html.sound-wait .sound-btn { animation: none; }
  #gl.red .holo-red { transition: opacity .25s ease; }
  .holo-red { transition: opacity .7s ease; }
}
