/* Faundex — faundex.com
   Brand colors (light): violet #65416d, amber #e5ac38.
   Dark-mode tones #a369af / #99701f are provisional. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/assets/fonts/BricolageGrotesque-Variable.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f3ef;
  --ink: #65416d;
  --accent: #e5ac38;
  --switch-delay: 0s;
  --switch-duration: .7s;

  /* One fluid size drives everything: no device breakpoints.
     Grows with the viewport width, never below 270px (so the logo is never tiny on a phone),
     never wider than 86% of the screen, never taller than the screen allows, capped at 880px. */
  --logo-w: min(clamp(270px, 34vw + 190px, 880px), 86vw, 140svh);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #151217;
  --ink: #a369af;
  --accent: #99701f;
  color-scheme: dark;
}

/* Brand-color themes, reached with double tap (light → dark → amber → violet → light).
   White letters; the underscore takes the other brand color, never white. */
:root[data-theme="amber"] {
  --bg: #e5ac38;
  --ink: #ffffff;
  --accent: #65416d;
  --phrase: #ffffff;
  color-scheme: light;
}

:root[data-theme="violet"] {
  --bg: #65416d;
  --ink: #ffffff;
  --accent: #e5ac38;
  --phrase: #ffffff;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #151217;
    --ink: #a369af;
    --accent: #99701f;
  }
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html {
  background: var(--bg);
  transition: background-color var(--switch-duration) ease var(--switch-delay);
  /* The page has nothing to click or scroll: pointer gestures belong to the field,
     and this also turns off double-tap zoom. */
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: default;
}

#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  /* a little above the optical center */
  transform: translateY(-5svh);
  pointer-events: none;
}

.wordmark {
  margin: 0;
  width: var(--logo-w);
  line-height: 0;
}

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

.letters > * {
  fill: var(--ink);
  transition: fill var(--switch-duration) ease var(--switch-delay);
}

.underscore {
  fill: var(--accent);
  transition: fill var(--switch-duration) ease var(--switch-delay);
}

.phrase {
  margin: calc(var(--logo-w) * .085) 0 0;
  max-width: calc(var(--logo-w) * 1.08);
  font-size: clamp(15px, calc(var(--logo-w) * .041), 34px);
  font-weight: 430;
  font-optical-sizing: auto;
  letter-spacing: -.005em;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
  color: var(--phrase, color-mix(in oklab, var(--ink) 86%, var(--bg)));
  transition: color var(--switch-duration) ease var(--switch-delay);
}

.phrase span { display: inline-block; }

/* ---------- Intro ----------
   The head script adds .intro before first paint; main.js removes it when done.
   Timeline: the field blooms from the logo, the letters rise one by one,
   the underscore draws itself and blinks twice like a terminal cursor,
   then the phrase arrives word by word. */

.intro .letters > * {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: letter-in 1s cubic-bezier(.2, .85, .25, 1.12) both;
  animation-delay: calc(.32s + var(--i) * .075s);
}

.intro .underscore {
  transform-box: fill-box;
  transform-origin: 0 50%;
  animation:
    underscore-draw .5s cubic-bezier(.65, 0, .35, 1) .95s both,
    cursor-blink 1.06s ease-in-out 1.5s 2;
}

.intro .phrase span {
  animation: word-in .9s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(1.45s + var(--w) * .085s);
}

@keyframes letter-in {
  from {
    opacity: 0;
    transform: translateY(55%) scaleY(.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes underscore-draw {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* Cursor rhythm (on half, off half) with a short ~120ms fade at each edge,
   centered where a hard blink would switch, so it still reads as a cursor. */
@keyframes cursor-blink {
  0%, 44.5% { opacity: 1; }
  55.5%, 89% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes word-in {
  from {
    opacity: 0;
    transform: translateY(.6em);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --switch-duration: .35s; }

  .intro .letters > *,
  .intro .underscore,
  .intro .phrase span {
    animation: fade-in .6s ease both;
    animation-delay: 0s;
  }

  @keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}
