/* Influx website. Plain CSS, no build step. Colour tokens first, redefined for dark below. */

@font-face { font-family: "Clarity City"; font-weight: 300; font-display: swap; src: url("../fonts/ClarityCity-Light.woff2") format("woff2"); }
@font-face { font-family: "Clarity City"; font-weight: 400; font-display: swap; src: url("../fonts/ClarityCity-Regular.woff2") format("woff2"); }
@font-face { font-family: "Clarity City"; font-weight: 500; font-display: swap; src: url("../fonts/ClarityCity-Medium.woff2") format("woff2"); }
@font-face { font-family: "Clarity City"; font-weight: 600; font-display: swap; src: url("../fonts/ClarityCity-SemiBold.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #fafaf8;
  --ink: #17181a;
  --muted: #5f646b;
  --line: rgb(0 0 0 / 0.12);
  --logo: #808080;            /* the brand grey, as in the PNG */
  --accent: #f05123;          /* the dot */
  --dot: #2f6bff;             /* the dot field and the glow behind the logo */
  --dot-opacity: 0.55;        /* dots at their strongest, read by hero.js */
  --dot-glow: 0.06;
  --stream-rgb: 23 24 26;     /* stream particles and their trails, read by hero.js */
  --stream-particle: 0.5;     /* particle opacity */
  --logo-halo: rgb(255 255 255 / 0.95);  /* the pool of light behind the logo */
  --logo-glow: 0.55;                     /* how strong the dot's glow is (1 = full) */
  --logo-shadow: rgb(0 0 0 / 0.16);      /* and the faint shadow under its letters */
  --media-opacity: 0.3;       /* the footage is dark, so on the light page it stays a faint wash */
  --media-a: #c9cbd0;
  --media-b: #8f939b;
  --media-c: #e7e3de;

  --font: "Clarity City", "Avenir Next", "Helvetica Neue", sans-serif;
  --gutter: clamp(1.25rem, 4vw, 4rem);
  --header-h: 4.5rem;
}

/* dark is the default; light only when the toggle chose it */
:root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0a0b0d;
  --ink: #f3f3f1;
  --muted: #979ca4;
  --line: rgb(255 255 255 / 0.14);
  --logo: #9c9c9c;
  --dot: #5d8dff;
  --dot-opacity: 0.5;
  --dot-glow: 0.09;
  --stream-rgb: 236 237 240;
  --stream-particle: 0.62;
  --logo-halo: rgb(93 141 255 / 0.34);
  --logo-glow: 1;
  --logo-shadow: rgb(0 0 0 / 0.55);
  --media-opacity: 0.5;
  --media-a: #3a3d44;
  --media-b: #1b1d21;
  --media-c: #55585f;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem / 1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 0.25rem; }

/* ---------- top bar: small nav over a thin rule ---------- */

.site-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 10;
  padding: 0 var(--gutter);

  & .site-header__bar {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(1.25rem, 3vw, 2.5rem);
    border-bottom: 1px solid var(--line);
  }

  & nav { display: flex; gap: clamp(1.25rem, 3vw, 2.5rem); }

  & nav a {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--muted);
    transition: color 0.2s ease;

    &:hover { color: var(--ink); }
  }
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;

  &:hover { color: var(--ink); border-color: var(--muted); }

  & svg { width: 1rem; height: 1rem; grid-area: 1 / 1; transition: opacity 0.3s ease, rotate 0.5s ease; }

  /* show the icon for the theme you'd switch to */
  & .icon-sun { opacity: 0; rotate: -90deg; }
}
:root:not([data-theme="light"]) .theme-toggle {
  & .icon-sun { opacity: 1; rotate: 0deg; }
  & .icon-moon { opacity: 0; rotate: 90deg; }
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: max(100svh, 40rem);
  padding: var(--header-h) var(--gutter) 0;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  align-items: center;
  overflow: hidden;
  isolation: isolate;
  view-timeline: --hero block;
}

/* the video loop: the setting, behind everything */
.hero__media {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: var(--media-opacity);
  /* full bleed, as the setting behind everything: held back on the left where the logo sits, faded out at the bottom */
  -webkit-mask-image: linear-gradient(to right, rgb(0 0 0 / 0.4) 0%, rgb(0 0 0 / 0.4) 24%, #000 66%), linear-gradient(to top, transparent 4%, #000 46%);
  mask-image: linear-gradient(to right, rgb(0 0 0 / 0.4) 0%, rgb(0 0 0 / 0.4) 24%, #000 66%), linear-gradient(to top, transparent 4%, #000 46%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;

  & .hero__media-inner {
    position: absolute;
    inset: -2% 0;
    filter: grayscale(1) contrast(1.05);
  }

  /* when the frame has to crop, lose more of the empty wall than of the people */
  & video { width: 100%; height: 100%; object-fit: cover; object-position: 60% 50%; display: block; }

  /* a faint warm wash so the footage sits in the brand's colour */
  &::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(200deg, var(--accent), transparent 60%);
    opacity: 0.1;
    mix-blend-mode: soft-light;
  }
}

/* a soft blue glow behind the logo */
.hero__glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 46% 56% at 27% 56%, color-mix(in srgb, var(--dot) calc(var(--dot-glow) * 100%), transparent), transparent 72%);
}

/* fine blue dots that follow the same flow as the stream lines; hero.js paints them once per layout */
.hero__dotfield {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* on the first run the dots appear behind the stream lines' front; hero.js moves --reveal across */
  --reveal: 0px;
  -webkit-mask-image: linear-gradient(to right, #000 calc(var(--reveal) - 11rem), transparent var(--reveal));
  mask-image: linear-gradient(to right, #000 calc(var(--reveal) - 11rem), transparent var(--reveal));
}

/* particle streams running across, behind the logo; they fade out along the flow and at the top and bottom */
.hero__streams {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 43%, rgb(0 0 0 / 0.32) 54%, rgb(0 0 0 / 0.32) 78%, transparent 96%), linear-gradient(to bottom, transparent var(--header-h), #000 22%, #000 78%, transparent 98%);
  mask-image: linear-gradient(to right, transparent 0%, #000 12%, #000 43%, rgb(0 0 0 / 0.32) 54%, rgb(0 0 0 / 0.32) 78%, transparent 96%), linear-gradient(to bottom, transparent var(--header-h), #000 22%, #000 78%, transparent 98%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

/* everything dissolves into the page at the bottom */
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 18%;
  z-index: 1;
  background: linear-gradient(to top, var(--bg), transparent);
  pointer-events: none;
}

.hero__logo {
  position: relative;
  z-index: 2;
  justify-self: center;
  width: clamp(15rem, 29vw, 27rem);
  margin-top: -4vh;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wordmark {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;

  & .wm-fill path { fill: var(--logo); }
  & .wm-fill .wm-dot { fill: var(--accent); }
  & .wm-fill .wm-tm { fill: none; stroke: var(--logo); stroke-width: 1.1; stroke-linejoin: round; }

  /* the construction lines, added by hero.js: a long straight line through every straight edge, and the bends */
  & .wm-sketch :is(path, circle) { fill: none; stroke: var(--ink); stroke-width: 1; stroke-linecap: round; }
  & .wm-sketch .is-dot { stroke: var(--accent); }
}

.hero__copy {
  position: relative;
  z-index: 2;
  /* level with the logo, where the stream lines come out of it */
  align-self: center;
  max-width: 35rem;
  margin: -1vh 0 0 clamp(0rem, 4vw, 4rem);

  /* a soft shade of the page colour behind the words, so bright parts of the footage don't swallow them */
  &::before {
    content: "";
    position: absolute;
    inset: -4.5rem -6rem;
    z-index: -1;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--bg) 78%, transparent) 30%, transparent);
    pointer-events: none;
  }

  & h1 {
    margin: 0;
    font-size: clamp(2.125rem, 3.7vw, 3.5rem);
    font-weight: 500;
    line-height: 1.06;
    letter-spacing: -0.025em;
    text-wrap: balance;
  }

  & p {
    margin: 1.25rem 0 0;
    max-width: 30rem;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    color: color-mix(in srgb, var(--ink) 78%, var(--bg)); /* a step stronger than --muted: it sits on footage */
    text-wrap: pretty;
  }
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: 62rem;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color 0.2s ease, gap 0.2s ease;

  &:hover { background: var(--accent); gap: 0.75rem; }
  & svg { width: 1rem; height: 1rem; }
}

/* ---------- the logo's lift: a halo behind it, a glow on the dot, a faint shadow under the letters ---------- */

/* a soft pool of light behind the word, no edges. It fades in as the word completes (see the sequence below) */
.hero__logo::after {
  content: "";
  position: absolute;
  inset: -45% -22%;
  z-index: -1;
  background: radial-gradient(ellipse 50% 50% at 50% 55%, var(--logo-halo), transparent 70%);
  filter: blur(0.75rem);
  pointer-events: none;
}

/* how far the dot's glow has come up, 0 to 1. Registered as a number so the sequence can fade it: browsers
   switch a filter built from variables on in one step rather than fading it */
@property --logo-glow-in { syntax: "<number>"; inherits: true; initial-value: 1; }

.wordmark {
  /* a faint shadow under the letters, just enough for a sense of depth; it arrives with each letter */
  & .wm-fill { filter: drop-shadow(0 1.5px 2px var(--logo-shadow)); }

  /* a slightly darker rim keeps the dot's edge crisp inside its glow */
  & .wm-fill .wm-dot {
    stroke: color-mix(in srgb, var(--accent) 74%, #000);
    stroke-width: 1.4;
    /* the glow: two soft layers, no bright core */
    filter:
      drop-shadow(0 0 8px color-mix(in srgb, var(--accent) calc(var(--logo-glow) * var(--logo-glow-in) * 40%), transparent))
      drop-shadow(0 0 24px color-mix(in srgb, var(--accent) calc(var(--logo-glow) * var(--logo-glow-in) * 26%), transparent));
  }
}

/* ---------- the intro sequence (only when hero.js is running and motion is allowed) ---------- */

/* nothing shows until the sequence starts, so there's no flash of the finished logo */
.js .hero:not(.is-playing):not(.is-done) {
  & .wm-fill > *, & .wm-sketch, & .hero__copy > *, & .hero__media, & .hero__logo::after { opacity: 0; }
}

.hero.is-playing {
  /* 1. as the stream lines' front passes, each sketch line fades in while sliding along itself and stretching
        out a tail, until it lies through its edge and runs on past both ends (delays are set by hero.js).
        2. the moment a letter's lines are in (--at, per letter) they fade away, still sliding and stretching a little */
  & .wm-sketch .is-line {
    opacity: 0;
    animation:
      wm-line-in var(--arrive) cubic-bezier(0.16, 0.8, 0.25, 1) var(--delay) forwards,
      wm-line-out var(--wm-fade) ease-in var(--at) forwards;
  }

  /* the bends draw themselves in between the lines, and fade with them */
  & .wm-sketch .is-curve {
    opacity: 0;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation:
      wm-curve-in var(--arrive) ease-out var(--delay) forwards,
      wm-curve-out var(--wm-fade) ease-in var(--at) forwards;
  }

  /* 3. and that letter fades in, so the word fills in order: i n f l u x */
  & .wm-fill > * {
    opacity: 0;
    animation: wm-fill var(--wm-fill) ease var(--at) forwards;
  }

  /* the dot gets a small pop as it fills */
  & .wm-fill .wm-dot {
    transform-box: fill-box;
    transform-origin: center;
    --logo-glow-in: 0;
    /* the glow waits for the pop to finish, then comes up slowly */
    animation:
      wm-pop 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) var(--at) forwards,
      wm-glow 1.8s cubic-bezier(0.37, 0, 0.63, 1) calc(var(--at) + 0.6s) forwards;
  }

  /* the halo starts as the last letters are filling and comes up slowly, done just before the copy has settled */
  & .hero__logo::after {
    opacity: 0;
    animation: fade-in 1.9s cubic-bezier(0.37, 0, 0.63, 1) calc(var(--after-logo) - 0.6s) forwards;
  }

  /* the footage is there from the start, as the setting; 4. the headline arrives once the word is in */
  & .hero__media { opacity: 0; animation: fade-to-media 1.2s ease forwards; }
  & .hero__copy > * { opacity: 0; animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--after-logo) + 0.25s) forwards; }
  & .hero__copy > :nth-child(2) { animation-delay: calc(var(--after-logo) + 0.4s); }
  & .hero__copy > :nth-child(3) { animation-delay: calc(var(--after-logo) + 0.55s); }
  & .hero__copy > :nth-child(4) { animation-delay: calc(var(--after-logo) + 0.7s); }
}

@keyframes wm-line-in {
  from { opacity: 0; translate: var(--travel) 0; scale: 0.04 1; }
  to { opacity: var(--strength); translate: 0 0; scale: 1 1; }
}
@keyframes wm-line-out { to { opacity: 0; translate: var(--drift) 0; scale: 1.15 1; } }
@keyframes wm-curve-in { to { opacity: var(--strength); stroke-dashoffset: 0; } }
@keyframes wm-curve-out { to { opacity: 0; } }
@keyframes wm-fill { to { opacity: 1; } }
@keyframes wm-pop {
  from { opacity: 0; scale: 0.6; }
  60% { opacity: 1; }
  to { opacity: 1; scale: 1; }
}
@keyframes wm-glow { from { --logo-glow-in: 0; } to { --logo-glow-in: 1; } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes fade-to-media { to { opacity: var(--media-opacity); } }
@keyframes rise {
  from { opacity: 0; translate: 0 1rem; }
  to { opacity: 1; translate: 0 0; }
}

/* once it has played, the pencil pass is gone for good */
.hero.is-done .wm-sketch { display: none; }

/* ---------- scroll: layers leave at different speeds (browsers with scroll-driven animations) ---------- */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .hero__media-inner, .hero__streams, .wordmark {
      animation: linear both;
      animation-timeline: --hero;
      animation-range: exit 0% exit 100%;
    }
    .hero__media-inner { animation-name: leave-slow; }
    .hero__streams { animation-name: leave-mid; }
    .wordmark { animation-name: leave-fast; }
  }
}
@keyframes leave-slow { to { translate: 0 1.8%; } }
@keyframes leave-mid { to { translate: 0 -6%; } }
@keyframes leave-fast { to { translate: 0 -38%; opacity: 0; } }

/* ---------- first content section (placeholder until step 4) ---------- */

.section {
  padding: clamp(4rem, 10vw, 8rem) var(--gutter);
  max-width: 75rem;
  margin: 0 auto;

  & h2 {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }

  & + .section { border-top: 1px solid var(--line); }
}

/* ---------- narrower screens ---------- */

@media (max-width: 56rem) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 1fr auto;
    align-items: center;
  }

  /* the footage drops behind the logo at low opacity */
  .hero__media {
    inset: 0;
    --media-opacity: 0.26;
    -webkit-mask-image: linear-gradient(to top, transparent 6%, #000 55%, #000 80%, transparent 100%);
    mask-image: linear-gradient(to top, transparent 6%, #000 55%, #000 80%, transparent 100%);
  }

  .hero__logo { width: clamp(12rem, 52vw, 20rem); margin-top: 6vh; }

  .hero__glow { background: radial-gradient(ellipse 80% 42% at 50% 42%, color-mix(in srgb, var(--dot) calc(var(--dot-glow) * 100%), transparent), transparent 72%); }

  /* the copy sits under the logo here, so the streams thin out before they reach it */
  .hero__streams {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 16%, #000 84%, transparent 100%), linear-gradient(to bottom, transparent var(--header-h), #000 22%, #000 52%, rgb(0 0 0 / 0.2) 66%, transparent 92%);
    mask-image: linear-gradient(to right, transparent 0%, #000 16%, #000 84%, transparent 100%), linear-gradient(to bottom, transparent var(--header-h), #000 22%, #000 52%, rgb(0 0 0 / 0.2) 66%, transparent 92%);
  }

  .hero__copy { margin: 0 0 clamp(3rem, 9vh, 5rem); max-width: 32rem; justify-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body, .theme-toggle svg { transition: none; }
}
