/* Space Dinos landing page
   Layout tokens come from the Figma frame "MacBook Air - 2" (1280 x 832). */

@font-face {
  font-family: "Geist Mono";
  src: url("assets/fonts/geist-mono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --ink: #ffffff;
  --ink-soft: rgb(255 255 255 / 0.8);     /* Figma: tagline at 80% white */
  --focus: #ffffff;
  --danger: #ff8a80;

  /* Icon is 187px tall in a 832px-tall frame (22.5% of the short side). */
  --mark-h: clamp(128px, 22.5vmin, 220px);
  --mark-w: calc(var(--mark-h) * 307 / 306);
  --logo-ratio: 3.0965;                    /* logo.svg is 963 x 311 */
  --logo-w: min(calc(var(--mark-h) * var(--logo-ratio)), calc(100vw - 48px));

  /* "120px below the icon/logo area". Scales down on short windows. */
  --tagline-gap: min(120px, 14.42vh);

  --hit: 44px;                             /* HIG minimum touch target */
  --menu-gap: clamp(8px, 4vw, 20px);       /* 44 + 20 = Figma's 64px icon pitch */
  --edge: 8px;                             /* Figma: legal line ends 8px above the bottom edge */
  --navy: #020f24;                         /* Figma: input fill and Join label */

  --font-mono: "Geist Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  height: 100%;
  margin: 0;
  background: #000;
}

body {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

/* ---------- Decorative layers ---------- */

.scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  z-index: 2;
  height: 100vh;
  height: 100dvh;
  min-height: 300px;
  padding:
    env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--mark-w);
  height: var(--mark-h);
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: none;
  color: inherit;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* While the logo is showing, the hover/tap target grows to the logo's footprint. */
.mark.is-logo { width: var(--logo-w); }

.mark-fallback { display: none; }

.tagline {
  position: absolute;
  left: 50%;
  top: calc(50% + var(--mark-h) / 2 + var(--tagline-gap));
  transform: translateX(-50%);
  margin: 0;
  font-size: clamp(1.0625rem, 0.9rem + 0.75vw, 1.375rem);  /* 22px in Figma */
  font-weight: 400;
  line-height: 1.3;
  color: var(--ink-soft);
  white-space: nowrap;
  text-shadow: 0 0 12px rgb(0 0 0 / 0.9);
  transition: opacity 0.2s ease;
}

/* Terminal cursor. Absolutely placed so the sentence itself stays optically centred. */
.cursor {
  position: absolute;
  left: 100%;
  top: 0.12em;
  width: 0.58em;
  height: 1.05em;
  margin-left: 0.3em;
  background: currentColor;
  animation: cursor-blink 1.06s steps(1, end) infinite;
}
@keyframes cursor-blink {
  0%, 49.99% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ---------- Dock: signup field + icon row ---------- */

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
  pointer-events: none;
}
.dock > * { pointer-events: auto; }

.menu ul {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--menu-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu-button {
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.15s var(--ease-out), opacity 0.15s ease;
}
.menu-button img { display: block; }
@media (hover: hover) {
  .menu-button:hover { background: rgb(255 255 255 / 0.14); }
}
.menu-button:active { transform: scale(0.92); opacity: 0.7; }
.menu-button[aria-expanded="true"] { background: rgb(255 255 255 / 0.2); }

/* Email popup — Figma node 3317:44 */
.signup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, 100%);
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 4px;
  background: rgb(255 255 255 / 0.08);
  animation: signup-glitch-in 0.26s linear both;
}
.signup[hidden] { display: none; }
.signup.is-closing { animation: signup-glitch-out 0.2s linear both; pointer-events: none; }

/* A very small glitch as the popup opens and closes: a few pixels of sideways jitter, a brief
   red/cyan fringe in the spec's channel colours, and an opacity flicker. Each step holds, then jumps. */
@keyframes signup-glitch-in {
  0%   { opacity: 0;    transform: translateX(-3px) skewX(-2deg); filter: drop-shadow(2px 0 0 rgb(255 8 20 / 0.6)) drop-shadow(-2px 0 0 rgb(0 217 255 / 0.6)); animation-timing-function: steps(1, end); }
  22%  { opacity: 0.75; transform: translateX(2px);               filter: drop-shadow(-2px 0 0 rgb(255 8 20 / 0.5)) drop-shadow(2px 0 0 rgb(0 217 255 / 0.5)); animation-timing-function: steps(1, end); }
  44%  { opacity: 0.35; transform: translateX(-1px) skewX(1deg);  filter: drop-shadow(1px 0 0 rgb(255 8 20 / 0.4)) drop-shadow(-1px 0 0 rgb(0 217 255 / 0.4)); animation-timing-function: steps(1, end); }
  66%  { opacity: 1;    transform: translateX(1px);               filter: drop-shadow(1px 0 0 rgb(255 8 20 / 0.25)) drop-shadow(-1px 0 0 rgb(0 217 255 / 0.25)); animation-timing-function: steps(1, end); }
  84%  { opacity: 0.85; transform: none;                          filter: none; animation-timing-function: steps(1, end); }
  100% { opacity: 1;    transform: none;                          filter: none; }
}
@keyframes signup-glitch-out {
  0%   { opacity: 1;    transform: none;                          filter: none; animation-timing-function: steps(1, end); }
  20%  { opacity: 0.8;  transform: translateX(1px);               filter: drop-shadow(1px 0 0 rgb(255 8 20 / 0.3)) drop-shadow(-1px 0 0 rgb(0 217 255 / 0.3)); animation-timing-function: steps(1, end); }
  45%  { opacity: 0.4;  transform: translateX(-2px) skewX(1deg);  filter: drop-shadow(-2px 0 0 rgb(255 8 20 / 0.5)) drop-shadow(2px 0 0 rgb(0 217 255 / 0.5)); animation-timing-function: steps(1, end); }
  70%  { opacity: 0.7;  transform: translateX(3px) skewX(-2deg);  filter: drop-shadow(2px 0 0 rgb(255 8 20 / 0.6)) drop-shadow(-2px 0 0 rgb(0 217 255 / 0.6)); animation-timing-function: steps(1, end); }
  100% { opacity: 0;    transform: translateX(-3px);              filter: none; }
}

.signup-label {
  display: block;
  font-size: 0.9375rem;         /* 15px */
  line-height: 1.3;
  color: var(--ink-soft);
}

.signup-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.signup-field input {
  flex: 1 1 264px;
  min-width: 0;
  min-height: var(--hit);
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 2px;
  background: var(--navy);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
}
.signup-field input::placeholder { color: rgb(255 255 255 / 0.5); opacity: 1; }
.signup-field input:focus-visible { outline-offset: 1px; }
.signup-field input { transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease; }

/* Error state: red border (doubled by an inset ring so it reads at a glance), a faint red wash,
   and a message underneath with a warning mark, so colour is never the only signal. */
.signup-field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
  background: #2a1016;
}

.signup-submit {
  flex: 0 0 auto;
  min-height: var(--hit);
  padding: 12px;
  border: 1px solid #fff;
  border-radius: 2px;
  background: #fff;
  color: rgb(2 15 36 / 0.8);    /* --navy at 80% */
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s var(--ease-out), opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
/* Hover: the button inverts to the field's navy with a white outline and label. */
@media (hover: hover) {
  .signup-submit:hover:not([disabled]) { background: var(--navy); color: #fff; }
}
.signup-submit:active { transform: scale(0.96); opacity: 0.8; }
.signup-submit[disabled] { opacity: 0.55; cursor: default; }

/* iOS zooms the whole page when a focused field's text is under 16px. Touch devices get 16px. */
@media (pointer: coarse) {
  .signup-field input { font-size: 1rem; }
}

.signup-status {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--ink-soft);
}
.signup-status:empty { display: none; }
.signup-status:focus { outline: none; }   /* focused by script after success; it is not a control */
.signup-status.is-error { color: var(--danger); }
.signup-status.is-error::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  width: 1.15em;
  height: 1.15em;
  margin-right: 0.5em;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.85em;
  line-height: 1;
}

/* Success state: the welcome line takes the label's place and the field and button are gone. */
.signup.is-success .signup-label,
.signup.is-success .signup-field { display: none; }
.signup.is-success .signup-status {
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

/* Legal line — Figma node 3317:8 (9px). Figma has it at 40% white, which is 3.7:1 on black;
   50% is the lowest that clears the 4.5:1 contrast minimum for small text. */
.legal {
  margin: -2px 0 0;             /* 12px dock gap - 2 = 10px under the 44px targets, as in Figma */
  font-size: 0.5625rem;
  line-height: 12px;
  color: rgb(255 255 255 / 0.5);
  text-align: center;
  white-space: nowrap;
}
.legal small { font-size: inherit; }

/* ---------- Pause control (WCAG 2.2.2: moving content must be pausable) ---------- */

.motion-toggle {
  position: fixed;
  z-index: 3;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  opacity: 0.6;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.15s var(--ease-out);
}
@media (hover: hover) {
  .motion-toggle:hover { opacity: 1; background: rgb(255 255 255 / 0.14); }
}
.motion-toggle:focus-visible { opacity: 1; }
.motion-toggle:active { transform: scale(0.92); }
.motion-toggle .glyph-play { display: none; }
.motion-toggle[aria-pressed="true"] .glyph-play { display: block; }
.motion-toggle[aria-pressed="true"] .glyph-pause { display: none; }

/* ---------- Responsive ---------- */

/* When the window is not tall enough for tagline + field + icon row, the field takes the tagline's place. */
@media (max-height: 900px) {
  .stage.signup-open .tagline { opacity: 0; }
}

/* Short windows (landscape phones, split view): stack everything around the centre instead of pinning to edges. */
@media (max-height: 540px) {
  :root {
    --mark-h: clamp(84px, 30vh, 128px);
    --tagline-gap: clamp(10px, 5vh, 28px);
    --edge: 8px;
  }
  .stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--tagline-gap);
  }
  .mark, .tagline {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    flex: 0 0 auto;
  }
  .dock {
    position: relative;
    bottom: auto;
    flex: 0 0 auto;
    width: 100%;
  }
  /* No room for both: the field replaces the tagline and the stack re-centres. */
  .stage.signup-open .tagline { display: none; }
  .dock { gap: 8px; }
}

@media (max-width: 359px) {
  :root { --menu-gap: 6px; }
}

/* ---------- Motion preferences ---------- */

.motion-paused .cursor { animation: none; }
.motion-paused .signup, .motion-paused .signup.is-closing { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .signup, .signup.is-closing { animation: none; }
  .menu-button, .signup-submit, .signup-field input, .motion-toggle, .tagline { transition: none; }
  .motion-toggle { display: none; }   /* everything is already still */
}

@media (prefers-contrast: more) {
  :root {
    --ink-soft: #fff;
  }
  .legal, .signup-field input::placeholder { color: #fff; }
  .signup { background: rgb(0 0 0 / 0.92); border-color: rgb(255 255 255 / 0.7); }
  .signup-field input { border-color: rgb(255 255 255 / 0.7); }
}

@media (forced-colors: active) {
  .cursor { background: CanvasText; }
  .menu-button, .motion-toggle { border: 1px solid ButtonText; }
}

/* ---------- No-WebGL fallback ---------- */

.no-webgl body { background: #000 url("space.avif") center / cover no-repeat; }
.no-webgl .scene { display: none; }
.no-webgl .mark-fallback {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  height: 100%;
  width: auto;
  max-width: none;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease;
}
.no-webgl .mark-fallback-logo { height: calc(var(--logo-w) / var(--logo-ratio)); opacity: 0; }
.no-webgl .mark.is-logo .mark-fallback-icon { opacity: 0; }
.no-webgl .mark.is-logo .mark-fallback-logo { opacity: 1; }
