/* Helix World · Space homepage
   Cinematic black field. Type is tracked, not transformed. */

@font-face {
  font-family: "Alumni Sans";
  src: url("./fonts/AlumniSans-VF.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

.space {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  background: #000;
  color: #d8d4cc;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  transform-origin: 50% 50%;
}

.app[data-mode="space"] .space {
  display: block;
}

.app[data-mode="space"] {
  min-height: 100dvh;
  background: #000;
  cursor: none;
}

.app[data-mode="space"] * {
  cursor: none;
}

/* The dialog sits in the top layer above #space-pixel, so it uses the same
   pointer as a CSS cursor; the prompt field keeps the caret. */
.app[data-mode="space"] .space-prompt,
.app[data-mode="space"] .space-prompt * {
  cursor: url("space/pointer.svg") 1 1, default;
}

.app[data-mode="space"] .space-prompt textarea {
  cursor: text;
}

.app[data-mode="space"] .topbar,
.app[data-mode="space"] .workspace,
.app[data-mode="space"] .drawer {
  display: none;
}

.app[data-mode="space"] .space-return,
.app[data-mode="play"] .space-return {
  display: none;
}

.space-return {
  margin-right: 4px;
}

html:has(.app[data-mode="space"]),
html:has(.app[data-mode="space"]) body {
  background: #000;
}

.space-nebula {
  position: absolute;
  inset: -12%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.space-nebula i {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(72px);
  will-change: transform;
}

.space-nebula i:nth-child(1) {
  width: 46vw;
  height: 34vw;
  left: -8%;
  top: -6%;
  background: radial-gradient(ellipse at center, rgba(118, 118, 120, 0.55), rgba(70, 70, 72, 0.16) 46%, transparent 72%);
  animation: nebula-a 26s ease-in-out infinite alternate;
}

.space-nebula i:nth-child(2) {
  width: 38vw;
  height: 46vw;
  right: -6%;
  top: 8%;
  background: radial-gradient(ellipse at center, rgba(150, 150, 152, 0.42), rgba(80, 80, 82, 0.12) 50%, transparent 74%);
  animation: nebula-b 34s ease-in-out infinite alternate;
}

.space-nebula i:nth-child(3) {
  width: 52vw;
  height: 28vw;
  left: 18%;
  bottom: -8%;
  background: radial-gradient(ellipse at center, rgba(96, 96, 98, 0.5), rgba(48, 48, 50, 0.14) 48%, transparent 72%);
  animation: nebula-a 30s ease-in-out infinite alternate-reverse;
}

.space-nebula i:nth-child(4) {
  width: 22vw;
  height: 22vw;
  right: 16%;
  bottom: 12%;
  background: radial-gradient(circle at center, rgba(176, 176, 178, 0.38), transparent 68%);
  filter: blur(54px);
  animation: nebula-b 22s ease-in-out infinite alternate;
}

.space-nebula i:nth-child(5) {
  width: 30vw;
  height: 40vw;
  left: 34%;
  top: 22%;
  background: radial-gradient(ellipse at center, rgba(82, 82, 84, 0.46), transparent 70%);
  filter: blur(90px);
  animation: nebula-c 38s ease-in-out infinite alternate;
}

.space-nebula i:nth-child(6) {
  width: 16vw;
  height: 20vw;
  left: 8%;
  top: 46%;
  background: radial-gradient(circle at center, rgba(140, 140, 142, 0.34), transparent 70%);
  filter: blur(48px);
  animation: nebula-c 24s ease-in-out infinite alternate-reverse;
}

@keyframes nebula-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(7vw, 4vh, 0) scale(1.14); }
}

@keyframes nebula-b {
  from { transform: translate3d(0, 0, 0) scale(1.06); }
  to { transform: translate3d(-6vw, 6vh, 0) scale(0.9); }
}

@keyframes nebula-c {
  from { transform: translate3d(0, 0, 0) scale(0.94); }
  to { transform: translate3d(4vw, -5vh, 0) scale(1.1); }
}

/* Oversized so the jitter never shows an edge; moved by transform so the
   filtered grain is rasterized once and only composited per frame. */
.space-noise {
  position: absolute;
  top: -20%;
  left: -20%;
  z-index: 0;
  width: 140%;
  height: 140%;
  pointer-events: none;
  opacity: 0.42;
  background-image: url("./space/noise.png");
  background-repeat: repeat;
  animation: space-noise 0.09s infinite;
  filter: contrast(1.35) brightness(1.15);
  will-change: transform;
}

@keyframes space-noise {
  0% { transform: translate3d(0, 0, 0); }
  10% { transform: translate3d(-2.5%, -5%, 0); }
  20% { transform: translate3d(-7.5%, 2.5%, 0); }
  30% { transform: translate3d(3.5%, -12.5%, 0); }
  40% { transform: translate3d(10%, 12.5%, 0); }
  50% { transform: translate3d(-12.5%, 5%, 0); }
  60% { transform: translate3d(7.5%, 2.5%, 0); }
  70% { transform: translate3d(0, 7.5%, 0); }
  80% { transform: translate3d(12.5%, 12.5%, 0); }
  90% { transform: translate3d(-5%, 5%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.space-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  perspective: 1600px;
  perspective-origin: 50% 48%;
  overflow: hidden;
  pointer-events: none;
}

.space-world {
  position: absolute;
  inset: 0;
  z-index: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  pointer-events: none;
}

.space-card {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  padding: 0;
  border: 0;
  background: #101010;
  overflow: visible;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  cursor: pointer;
  pointer-events: auto;
}

.space-card::after {
  content: "";
  position: absolute;
  inset: -28px -20px;
}

.space-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.space-logo {
  position: fixed;
  top: 22px;
  left: 24px;
  z-index: 46;
  width: 42px;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.app:not([data-mode="space"]) .space-logo {
  display: none;
}

.space-brand {
  position: absolute;
  top: 30px;
  left: 0;
  right: 0;
  z-index: 2;
  text-align: center;
  pointer-events: none;
}

.space-role {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.38em;
  --ink: #8d8982;
  white-space: nowrap;
  font-kerning: none;
}

.space-mark {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  mix-blend-mode: difference;
}

.space-title {
  margin: 0;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(44px, 7.6vw, 104px);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 0.95;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  transform-origin: 50% 50%;
}


.space-hint {
  position: absolute;
  left: 50%;
  top: 58%;
  z-index: 2;
  width: min(460px, calc(100% - 48px));
  transform: translate(-50%, 0);
  text-align: center;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.12em;
  line-height: 1.5;
  --ink: #9a958c;
}

.space-hint[hidden],
.space-brand[hidden],
.space-footer[hidden],
.space-intro[hidden],
.space-audio[hidden],
.space-links[hidden] {
  display: none;
}

.space-intro {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  background: #000;
  color: #fff;
  overflow: hidden;
  isolation: isolate;
  pointer-events: auto;
}

.space-intro.is-leaving {
  --hole: -28%;
  -webkit-mask-image: radial-gradient(circle at 50% 48%, transparent var(--hole), #000 calc(var(--hole) + 28%));
  mask-image: radial-gradient(circle at 50% 48%, transparent var(--hole), #000 calc(var(--hole) + 28%));
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.app[data-mode="space"] .space-intro:not([hidden]) {
  display: block;
}

.space-intro-inner {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.space-intro .space-noise {
  opacity: 0.5;
  filter: contrast(1.4) brightness(1.18);
}

.space-intro-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 48px);
}

.space-intro-line {
  margin: 0;
  width: 100%;
  min-width: max-content;
  min-height: 1.2em;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.08em;
  word-spacing: 0.12em;
  line-height: 1.2;
  text-align: center;
  color: #fff;
  white-space: nowrap;
}

.space-intro-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  width: max-content;
  max-width: 100%;
  height: auto;
  margin-top: 18px;
  padding: 14px 16px;
  overflow: visible;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

.space-intro-choice button {
  appearance: none;
  position: relative;
  width: auto;
  min-width: 0;
  margin: 0;
  border: 0;
  background: none;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.space-intro-choice button:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 3px;
}

.space-intro-label {
  position: relative;
  display: inline-block;
  line-height: 1;
  transition: transform 0.3s;
}

.space-intro-spark,
.space-intro-arrow {
  display: block;
  flex: 0 0 auto;
  pointer-events: none;
}

.space-intro-spark {
  position: absolute;
  left: 8px;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-50%) scale(0);
  transition: transform 0.3s;
}

.space-intro-arrow {
  width: 8px;
  height: 8px;
  transition: transform 0.3s;
}

#space-intro-on {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 1px;
  background: #fff;
  color: #111;
}

#space-intro-off {
  display: inline-block;
  overflow: hidden;
  padding: 0;
  color: #fff;
}

#space-intro-off::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

#space-intro-on:hover,
#space-intro-on:focus-visible {
  background: #fff;
}

#space-intro-on:hover .space-intro-label,
#space-intro-on:focus-visible .space-intro-label {
  transform: translateX(16px);
}

#space-intro-on:hover .space-intro-arrow,
#space-intro-on:focus-visible .space-intro-arrow {
  transform: scale(0);
}

#space-intro-on:hover .space-intro-spark,
#space-intro-on:focus-visible .space-intro-spark {
  transform: translateY(-50%) scale(1);
}

#space-intro-off:hover::after,
#space-intro-off:focus-visible::after {
  transform: scaleX(0);
  transform-origin: right center;
}

.space-intro-percent {
  position: absolute;
  right: 40px;
  bottom: 28px;
  z-index: 2;
  margin: 0;
  font-family: "Alumni Sans", Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(80px, 11vw, 128px);
  font-weight: 200;
  letter-spacing: -0.05em;
  line-height: 0.78;
  color: #fff;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  font-kerning: none;
}

/* Sits between the noise and the cards: it lights the void, never the images. */
.space-blob {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: #fff;
  filter: blur(32px);
  mix-blend-mode: difference;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

/* Text over the glow darkens toward its centre. space.js feeds --glow-x/--glow-y
   per element; the stops follow the blob's falloff (~90% at 59px, ~10% at 141px). */
.space-role,
.space-hint,
.space-footer,
.space-upload-note,
.space-upload-button {
  color: transparent;
  background-image: radial-gradient(
    circle var(--glow-r, 0px) at var(--glow-x, -999px) var(--glow-y, -999px),
    #1b1a18 36%,
    var(--ink) 86%
  );
  -webkit-background-clip: text;
  background-clip: text;
}

.app:not([data-mode="space"]) .space-blob,
.app:not([data-mode="space"]) .space-pixel {
  display: none;
}

.space-pixel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 90;
  width: 15px;
  height: 22px;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
}

.space-pixel path {
  fill: #fff;
  stroke: #111;
  stroke-width: 1.15;
  stroke-linejoin: miter;
  paint-order: stroke fill;
}

.space-links {
  position: absolute;
  top: 19px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
}

.space-link,
.space-audio {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: #c8c4bc;
  text-decoration: none;
  cursor: pointer;
}

.space-link:hover,
.space-link:focus-visible,
.space-audio:hover,
.space-audio:focus-visible {
  color: #fff;
}

.space-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.space-audio svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.space-audio[aria-pressed="false"] .icon-sound,
.space-audio[aria-pressed="true"] .icon-muted {
  display: none;
}

.space-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 36px;
  z-index: 2;
  padding-left: 0.28em;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.28em;
  --ink: #8d8982;
  pointer-events: none;
  white-space: nowrap;
  font-kerning: none;
}

.space-upload {
  position: absolute;
  right: 28px;
  bottom: 36px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(280px, calc(100% - 48px));
}

.space-upload-note {
  margin: 0;
  text-align: right;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.45;
  --ink: #c8c4bc;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.space-upload:hover .space-upload-note,
.space-upload:focus-within .space-upload-note {
  opacity: 1;
  transform: none;
}

.space-upload-button {
  position: relative;
  display: inline-block;
  overflow: hidden;
  /* Hit area larger than the text; the negative margin keeps it in place. */
  padding: 12px 16px;
  margin: -12px -16px;
  --ink: #fff;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.space-upload-button::after {
  content: "";
  position: absolute;
  left: 16px;
  bottom: 12px;
  width: calc(100% - 32px);
  height: 1px;
  background: var(--ink);
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

.space-upload:hover .space-upload-button::after,
.space-upload:focus-within .space-upload-button::after {
  transform: scaleX(0);
  transform-origin: right center;
}

.space-prompt {
  width: min(440px, calc(100vw - 48px));
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  background: #000;
  color: #fff;
}

.space-prompt::backdrop {
  background: rgba(0, 0, 0, 0.84);
}

.space-prompt-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #111;
}

.space-prompt h2 {
  margin: 16px 0 18px;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.space-prompt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.space-prompt-head span {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: #8d8982;
}

.space-prompt textarea {
  min-height: 132px;
  max-height: 180px;
  resize: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  background: #000;
  color: #fff;
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.space-prompt textarea::placeholder {
  color: #8d8982;
}

.space-prompt textarea:focus {
  border-color: rgba(255, 255, 255, 0.7);
}

.space-prompt-hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #9a958c;
}

.space-prompt-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 22px;
  margin-top: 18px;
}

.space-prompt-actions button {
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

#space-prompt-cancel {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
}

#space-prompt-cancel::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

#space-prompt-cancel:hover::after,
#space-prompt-cancel:focus-visible::after {
  transform: scaleX(0);
  transform-origin: right center;
}

#space-prompt-go {
  position: relative;
  padding: 8px 14px;
  border: 0;
  border-radius: 1px;
  background: #fff;
  color: #111;
  /* Text turns faster than the fill so the two cross quickly and the label stays legible. */
  transition: background-color 0.35s ease, color 0.18s ease;
}

/* Spans the label only (inset by the padding) and grows from its centre. */
#space-prompt-go::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 7px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

#space-prompt-go:not(:disabled):hover,
#space-prompt-go:not(:disabled):focus-visible {
  background: #000;
  color: #fff;
}

#space-prompt-go:not(:disabled):hover::after,
#space-prompt-go:not(:disabled):focus-visible::after {
  transform: scaleX(1);
}

#space-prompt-go:disabled {
  opacity: 0.55;
}

.space-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.space-glyph {
  display: inline-block;
}

.space-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 5;
  font-size: 11px;
  letter-spacing: 0.28em;
  color: #ece8e0;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .space-logo { top: 16px; left: 16px; width: 32px; }
  .space-brand { top: 20px; }
  .space-footer { right: 0; bottom: 64px; }
  .space-upload { right: 16px; bottom: 18px; max-width: calc(100% - 32px); }
  .space-title { font-size: clamp(32px, 12vw, 64px); letter-spacing: 0.055em; }
  .space-hint { top: 56%; }
  .space-links { top: 12px; right: 9px; }
  .space-link,
  .space-audio { width: 30px; height: 30px; }
  .space-intro-stack { max-width: calc(100% - 32px); }
  .space-intro-line { font-size: 14px; letter-spacing: 0.06em; }
  .space-intro-choice { gap: 18px; margin-top: 14px; padding: 12px; }
  .space-intro-percent { right: 18px; bottom: 16px; font-size: clamp(56px, 18vw, 88px); }
}

@media (max-width: 340px) {
  .space-role { letter-spacing: 0.24em; }
}

@media (pointer: coarse) {
  .app[data-mode="space"],
  .app[data-mode="space"] * {
    cursor: auto;
  }
  .space-cursor,
  .space-blob,
  .space-pixel {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .space-card { will-change: auto; }
  .space-blob,
  .space-pixel {
    display: none;
  }
  .app[data-mode="space"],
  .app[data-mode="space"] * {
    cursor: auto;
  }
  .space-noise,
  .space-nebula i {
    animation: none;
  }
  .space-intro-label,
  .space-intro-spark,
  .space-intro-arrow,
  #space-intro-off::after,
  .space-upload-note,
  .space-upload-button::after,
  #space-prompt-cancel::after,
  #space-prompt-go,
  #space-prompt-go::after {
    transition: none;
  }
}
