/* GRAPHICA Flow site — world.css — v1.19 (a phone held sideways: the hero logo a little lower); v1.18 (the day's words twinkle 18% softer; before: v1.17, a phone: the hero logo sits higher, --phone-hero-lift; before: v1.16,a transparency for every kind of text: --alpha-*; before: v1.15, the opening's fades are linear, so the seconds in Look Studio are the seconds you see: --intro-ease; before: v1.14, the opening's own --intro-* variables, from the press on Start; the floating words' and the firm's name's size and colour; before: the background's own entrance: INTRO.groundDelaySeconds / groundFadeSeconds)
   The moving world: the shader ground, the homepage river and logo (rules copied from the homepage, so it looks
   1:1), the logo again in the finale on the shore, the vignette, the site's three canvases (the far sky, the near
   thread, the dust in front) and the things that live in the world (labels, mission control).
   The engine makes [data-sc-world] fixed and full screen; every layer here sits inside it. The engine gives its
   empty legs z-index 100–120, so the layers start above that. The 3D camera (scripts/depth-camera.js) gives the
   world its perspective and moves every layer marked data-plane; the ground and the vignette stay on the screen. */

.world > [data-sc-segment] {
  pointer-events: none;
}

.world-ground,
.river-net,
.veil,
.river-stage,
.world-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-ground {
  z-index: 200;
}

.river-net {
  z-index: 201;
}

/* the homepage vignette: stays on the screen, the world moves under it */
.veil {
  z-index: 202;
  background: linear-gradient(rgba(0, 0, 0, var(--veil-a)), rgba(0, 0, 0, var(--veil-a))),
    radial-gradient(46% 34% at 50% 50%, rgba(11, 10, 9, var(--veil-c)), transparent 72%),
    radial-gradient(130% 95% at 50% 50%, transparent 42%, rgba(0, 0, 0, var(--veil-e)) 100%);
}

/* the site's canvases cover the screen and draw the 3D camera themselves (scripts/world-canvas.js sets their size).
   The engine's reset caps every canvas at its parent's width; a canvas sized by the script must never be squeezed,
   so the cap is lifted here */
.world-canvas {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
  pointer-events: none;
}

.sky {
  z-index: 203;
}

/* the opening's fades run in a straight line: with the page's own ease-out (cubic-bezier(0.16, 1, 0.3, 1)) a fade is
   almost all there in its first fifth, so a long fade looked like a short one and the seconds in Look Studio showed
   nothing. Linear = the fade takes the seconds that are set, all the way to the end. */
:root {
  --intro-ease: linear;
}

/* the background (the colour gradient, the net, the sky of stars) comes up after the press on Start:
   --intro-ground-delay and --intro-ground-time are written from config.js INTRO (scripts/intro-timing.js).
   "backwards": it holds its first frame while it waits and leaves the layer's own opacity alone afterwards. Like the
   logo, it waits for "is-started" */
.world-ground,
.river-net,
.sky {
  animation: ground-in var(--intro-ground-time, 0s) var(--intro-ease) var(--intro-ground-delay, 0s) backwards;
}

.js:not(.is-started) .world-ground,
.js:not(.is-started) .river-net,
.js:not(.is-started) .sky {
  animation-play-state: paused;
}

@keyframes ground-in {
  from {
    opacity: 0;
  }
}

/* the hero logo's stage, centred as on the homepage */
.river-stage {
  z-index: 204;
  display: grid;
  place-items: center;
}

.weave {
  z-index: 205;
}

/* the labels' layer keeps its children in 3D, so the chaos labels sit at their own depth */
.world-labels {
  z-index: 206;
  transform-style: preserve-3d;
}

/* a scene's frame holder: it carries that scene's things, laid out on its own screen, to the scene's place in the
   world, turned its own way (scripts/scene-frames.js frameCss). It keeps them in 3D */
.scene-frame {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  transform-style: preserve-3d;
}

/* the dust floats in front of the whole world (the text is in front of the world element itself) */
.dust {
  z-index: 207;
}

[data-plane] {
  will-change: transform;
}

#gp-mobile-shader,
#net {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#gp-mobile-shader {
  opacity: var(--bg-k);
}

/* ---- the hero logo, as on the homepage ---- */
.logo {
  position: relative;
  display: block;
}

.logo--hero {
  width: var(--logo-px);
}

/* a phone: the logo sits higher than the middle (tokens.css --phone-hero-lift); its first text follows (copy.css).
   The layout measures the logo where it sits, so the river and the words still find it */
@media (max-aspect-ratio: 21/20) {
  .logo--hero {
    translate: 0 calc(var(--phone-hero-lift) * -1px);
  }
}

/* a phone held sideways: the logo a little lower than the middle (tokens.css --phone-wide-hero-drop) */
@media (min-aspect-ratio: 21/20) and (max-height: 520px) {
  .logo--hero {
    translate: 0 var(--phone-wide-hero-drop);
  }
}

.logo-ink {
  position: relative;
  z-index: 1;
  display: block;
}

.logo--hero .logo-ink {
  filter: drop-shadow(0 0 calc(var(--lh) * 0.3) rgba(254, 194, 49, calc(var(--logo-glow) * var(--glow-k))));
}

.logo svg {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.logo .ink {
  fill: var(--ink);
}

/* the logo's entrance: the opening's own times (config.js INTRO, scripts/intro-timing.js); the homepage's
   --logo-delay / --logo-time only stand in for a page whose script never ran */
.logo--hero svg {
  animation: logo-in var(--intro-logo-time, var(--logo-time)) var(--intro-ease) var(--intro-logo-delay, var(--logo-delay))
    both;
}

/* the logo's entrance waits for the start: "is-started" on <html> is set at the press on Start
   (scripts/start-gate.js; index.html has a failsafe for a page whose script never runs) */
.js:not(.is-started) .logo--hero svg {
  animation-play-state: paused;
}

@keyframes logo-in {
  from {
    opacity: 0;
    filter: blur(10px);
    transform: scale(0.985);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: none;
  }
}

/* back glow: Martin's VS Dash logo glow, scaled to the logo height (homepage values) */
.logo-glow {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  inset: calc(var(--lh) * -0.367 * var(--aura-size)) calc(var(--lh) * -0.267 * var(--aura-size));
  opacity: var(--glow-k);
}

.logo-breath {
  position: absolute;
  inset: 0;
  animation: aura-breath var(--aura-breath) ease-in-out infinite;
}

.logo-aura {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  opacity: var(--aura-a);
  filter: blur(calc(var(--lh) * var(--aura-blur)));
}

.logo-aura::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 200%;
  background: linear-gradient(90deg, #fec231, #4bf1e2 25%, #fec231 50%, #4bf1e2 75%, #fec231);
  animation: aura-run var(--aura-run) linear infinite;
}

@keyframes aura-breath {
  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

@keyframes aura-run {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

/* ---- the logo of the finale: the hero's logo and glow once more, placed in the world by scripts/finale.js.
   It is not there while the sky goes into the middle of the screen; once the sky is in it comes up out of a blur
   (--finale-alpha, --finale-blur) and glows softly (--finale-flare). It lights up when the river reaches it
   (--finale-lit) and fills with light while the sky goes into it (--finale-charge). 0.12749 is the logo's height
   per width. ---- */
.logo--finale {
  --lh: calc(var(--finale-px, 240px) * 0.12749);

  position: absolute;
  left: 0;
  top: 0;
  width: var(--finale-px, 240px);
  opacity: var(--finale-alpha, 0);
  filter: blur(calc(var(--finale-blur, 0) * 1px)); /* it comes up out of a blur once the sky is in */
  scale: calc(1 + 0.025 * var(--finale-flare, 0));
  will-change: translate, scale, opacity, filter;
}

.logo--finale .logo-glow {
  opacity: calc(var(--finale-lit, 0) * (0.5 + 0.5 * var(--finale-charge, 0)) + var(--finale-flare, 0));
}

.logo--finale .logo-aura {
  opacity: calc(var(--aura-a) * (1.6 + 1.6 * var(--finale-flare, 0)));
}

.logo--finale .logo-ink {
  filter: drop-shadow(
    0 0 calc(var(--lh) * (0.25 + 0.6 * var(--finale-flare, 0)))
      rgba(254, 194, 49, calc(0.2 * var(--finale-lit, 0) + 0.55 * var(--finale-flare, 0)))
  );
}

/* the firm's name under its signature figure, spaced out like a star chart (scripts/sign-name.js) */
.sign-name {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% 0;
  padding-left: 0.32em; /* balances the space after the last letter, so the name stays centred */
  overflow: hidden;
  color: color-mix(in srgb, var(--color-sign-name) calc(var(--alpha-sign-name) * 100%), transparent);
  font-size: calc(var(--t-label) * var(--size-sign-name));
  font-weight: var(--weight-medium);
  font-stretch: var(--stretch-label);
  letter-spacing: 0.32em;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow:
    0 0 18px rgba(11, 10, 9, 0.9),
    0 0 26px rgba(255, 227, 154, 0.28);
  opacity: 0;
  will-change: transform, opacity, filter;
}

/* ---- text that lives in the world: each chaos label floats at its own depth (scripts/chaos-labels.js).
   Bare words, no frame: each one twinkles softly on its own beat (--twinkle-delay), like a star ---- */
.chaos-labels {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.chaos-label {
  --twinkle-seconds: 3.2s;

  position: absolute;
  left: 0;
  top: 0;
  translate: 0 -50%;
  transform-origin: 0 50%;
  color: color-mix(in srgb, var(--color-words) calc(var(--alpha-words) * 100%), transparent);
  font-size: calc(var(--t-label) * var(--size-words));
  font-weight: var(--weight-medium);
  font-stretch: var(--stretch-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity;
  animation: label-twinkle var(--twinkle-seconds) ease-in-out var(--twinkle-delay, 0s) infinite;
}

@keyframes label-twinkle {
  0%,
  100% {
    color: color-mix(in srgb, var(--color-words) calc(var(--alpha-words) * 100%), transparent);
    text-shadow:
      0 0 6px rgba(254, 194, 49, 0.18),
      0 0 18px rgba(11, 10, 9, 0.7);
  }

  45% {
    color: color-mix(in srgb, var(--color-words-glint) calc(var(--alpha-words) * 100%), transparent);
    text-shadow:
      0 0 8px rgba(255, 227, 154, 0.6),
      0 0 22px rgba(254, 194, 49, 0.37);
  }

  55% {
    color: color-mix(in srgb, var(--color-words-glint) calc(var(--alpha-words) * 100%), transparent);
    text-shadow:
      0 0 5px rgba(255, 255, 255, 0.7),
      0 0 16px rgba(75, 241, 226, 0.29);
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo--hero svg,
  .world-ground,
  .river-net,
  .sky,
  .logo-breath,
  .logo-aura::before,
  .chaos-label {
    animation: none;
  }

  :root {
    --bg-k: 1;
    --glow-k: 1;
  }
}
