/* ==========================================================================
   Diytify — one-screen landing
   Tokens mirror the Diytify design system. One committed look: night navy.
   ========================================================================== */

:root {
  color-scheme: dark;

  --navy-950: #02022d;
  --navy-990: #010115;
  --navy-900: #0a0a3a;          /* derived: raised navy */
  --indigo-700: #06068b;
  --sky-500: #3295eb;
  --logo-cyan: #1eb9e5;
  --logo-indigo: #4e63f2;
  --white: #ffffff;
  --grey-450: #b7b7b7;
  --line-night: #23234f;

  --ink: var(--white);
  --ink-muted: var(--grey-450);
  --accent: var(--sky-500);

  --font-sans: "Encode Sans", "Helvetica Neue", Arial, sans-serif;

  --space-15: 15px;
  --space-20: 20px;
  --space-30: 30px;
  --space-45: 45px;
  --space-60: 60px;
  --hold: 4000ms;
  --fit: 1;

  --radius-pill: 1000px;
  --gutter: clamp(16px, 3.2vw, 48px);
  --ease-out: cubic-bezier(.2, .7, .1, 1);
  --ease-expo: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--navy-990);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--sky-500); color: var(--navy-950); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- preloader (port of .preloader .loader) ---------- */
.preloader { position: fixed; inset: 0; z-index: 999; display: grid; place-items: center; background: var(--navy-950); transition: opacity .6s; }
.preloader.is-done { opacity: 0; pointer-events: none; }
.loader { width: 30px; height: 30px; border: 4px solid var(--white); animation: loader 2s infinite ease; }
.loader-inner { display: block; width: 100%; background: var(--white); animation: loader-inner 2s infinite ease-in; }
@keyframes loader { 0% { transform: rotate(0) } 25%, 50% { transform: rotate(180deg) } 75%, 100% { transform: rotate(360deg) } }
@keyframes loader-inner { 0%, 25% { height: 0 } 50%, 75% { height: 100% } 100% { height: 0 } }

/* ---------- stage ---------- */
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "top   top"
    "copy  ."
    "bottom bottom";
  padding: calc(env(safe-area-inset-top, 0px) + 22px) var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 22px);
  background: radial-gradient(90% 80% at 65% 45%, var(--navy-950) 0%, var(--navy-990) 70%);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.stage.is-dragging { cursor: grabbing; }

.stage__canvas { position: absolute; inset: 0; z-index: -3; width: 100%; height: 100%; display: block; }
.stage__fallback { display: none; }
.stage.no-webgl .stage__canvas { display: none; }
.stage.no-webgl .stage__fallback {
  display: block; position: absolute; z-index: -3; width: min(42vw, 460px); right: 12%; top: 50%; translate: 0 -50%;
  filter: drop-shadow(0 30px 90px rgba(50, 149, 235, .45));
}
/* keeps the headline readable over the brightest pixels */
.stage__scrim {
  position: absolute; inset: 0; z-index: -2; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(1, 1, 21, .82) 0%, rgba(1, 1, 21, .35) 38%, transparent 58%),
    linear-gradient(0deg, rgba(1, 1, 21, .7) 0%, transparent 28%);
}
.stage__grain {
  position: absolute; inset: -50%; z-index: -1; pointer-events: none; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain { 0% { transform: translate(0, 0) } 20% { transform: translate(-3%, 2%) } 40% { transform: translate(2%, -4%) } 60% { transform: translate(-4%, -2%) } 80% { transform: translate(3%, 3%) } 100% { transform: translate(0, 0) } }

/* ---------- top bar ---------- */
.top { grid-area:top; display: flex; align-items: center; justify-content: space-between; gap: var(--space-20); }
.top__brand img { width: clamp(112px, 11vw, 150px); }
.status {
  display: inline-flex; align-items: center; gap: 10px; margin: 0;
  padding: 7px 14px 7px 12px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: lowercase;
  color: var(--ink-muted); border: 1px solid var(--line-night); border-radius: var(--radius-pill);
  background: rgba(2, 2, 45, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.status__dot { width: 8px; height: 8px; background: var(--sky-500); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(50, 149, 235, .6) } 70% { box-shadow: 0 0 0 10px rgba(50, 149, 235, 0) } 100% { box-shadow: 0 0 0 0 rgba(50, 149, 235, 0) } }

/* ---------- orbit badge ---------- */
.orbit {
  position: absolute; z-index: 0; right: calc(var(--gutter) + 6px); top: 104px;
  width: 132px; aspect-ratio: 1; pointer-events: none;
}
.orbit__text { position: absolute; inset: 0; width: 100%; height: 100%; animation: spin 22s linear infinite; }
.orbit__text text { font: 700 13px var(--font-sans); fill: var(--ink-muted); font-stretch: 112%; }
.orbit__ring { position: absolute; inset: 24%; animation: spin 9s linear infinite reverse; }
.orbit__ring i { position: absolute; left: 50%; top: 0; width: 5px; height: 5px; margin-left: -2.5px; background: var(--sky-500); transform-origin: 2.5px calc(66px * .52); }
.orbit__ring i:nth-child(2) { transform: rotate(45deg); background: var(--logo-cyan); }
.orbit__ring i:nth-child(3) { transform: rotate(90deg); }
.orbit__ring i:nth-child(4) { transform: rotate(135deg); background: var(--logo-indigo); }
.orbit__ring i:nth-child(5) { transform: rotate(180deg); }
.orbit__ring i:nth-child(6) { transform: rotate(225deg); background: var(--logo-cyan); }
.orbit__ring i:nth-child(7) { transform: rotate(270deg); }
.orbit__ring i:nth-child(8) { transform: rotate(315deg); background: var(--logo-indigo); }
.orbit__mark { position: absolute; inset: 36%; width: 28%; animation: breathe 4s ease-in-out infinite; }
@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 50% { transform: scale(.86); } }

/* ---------- copy ---------- */
.copy {
  grid-area: copy; align-self: end;
  width: min(100%, 58vw); max-width: 900px;
  padding-block: var(--space-45) var(--space-30);
  pointer-events: none;
}
.eyebrow {
  margin: 0 0 var(--space-20); font-size: 12px; font-weight: 700; font-stretch: 125%;
  letter-spacing: .2em; text-transform: uppercase; color: var(--sky-500);
}
/* The headline sizes itself: --size is the design size, --fit (set by the
   headline controller) shrinks it only if its widest line would not fit. */
.headline {
  --size: clamp(34px, 4.8vw, 84px);
  margin: 0;
  font-size: calc(var(--size) * var(--fit, 1));
  font-weight: 900; line-height: .98; letter-spacing: -0.03em;
}
.headline__visual { display: block; }
.line { display: block; white-space: nowrap; }
.line--accent { color: var(--accent); }
.word { display: inline-block; }
.glyph { display: inline-block; width: .5em; vertical-align: -0.02em; font-size: .72em; line-height: 1; text-align: center; color: var(--logo-cyan); font-weight: 400; }
.lead { margin: var(--space-30) 0 0; max-width: 34ch; font-size: clamp(16px, 1.4vw, 20px); font-weight: 500; line-height: 1.5; color: var(--ink-muted); }

/* load sequence: lines rise one after another once the preloader lifts */
.is-loaded .line { animation: rise 1s var(--ease-expo) both; }
.is-loaded .line:nth-child(2) { animation-delay: .08s; }
.is-loaded .line:nth-child(3) { animation-delay: .16s; }
.is-loaded .eyebrow, .is-loaded .lead, .is-loaded .top, .is-loaded .bottom, .is-loaded .orbit { animation: fade 1.2s var(--ease-out) both .35s; }
@keyframes rise { from { opacity: 0; transform: translateY(.4em); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- bottom bar ---------- */
.bottom {
  grid-area: bottom;
  display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: var(--space-20) var(--space-30);
  padding-top: var(--space-20); border-top: 1px solid var(--line-night);
}
.legal { grid-column: 1; grid-row: 1; margin: 0; font-size: 12px; letter-spacing: 1px; color: var(--ink-muted); }
.hint { grid-column: 2; grid-row: 1; margin: 0; justify-self: center; display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: .08em; color: var(--ink-muted); white-space: nowrap; }
.hint strong { color: var(--white); font-weight: 700; font-variant-numeric: tabular-nums; }
.hint__ripple { display: inline-flex; align-items: center; gap: 10px; }
.hint__sep { width: 4px; height: 4px; background: var(--sky-500); }
.stage.no-webgl .hint { visibility: hidden; }

.formations { grid-column: 3; grid-row: 1; display: flex; gap: 6px; }
.formation {
  display: grid; gap: 8px; min-width: 76px; padding: 8px 4px 4px; text-align: left;
  background: none; border: 0; cursor: pointer; color: var(--ink-muted);
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
  transition: color .2s linear;
}
.formation:hover { color: var(--white); }
.formation[aria-pressed="true"] { color: var(--white); }
.formation__bar { position: relative; display: block; height: 2px; background: var(--line-night); overflow: hidden; }
.formation__bar > span { position: absolute; inset: 0; background: var(--sky-500); transform: scaleX(0); transform-origin: left; }
.formation[aria-pressed="true"] .formation__bar > span { transform: scaleX(.12); }
.formation.is-counting .formation__bar > span { animation: hold var(--hold, 4000ms) linear forwards; }
@keyframes hold { from { transform: scaleX(.12); } to { transform: scaleX(1); } }
.stage.no-webgl .formations { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .bottom { grid-template-columns: 1fr auto; }
  .hint { display: none; }
  .formations { grid-column: 2; }
}

@media (max-aspect-ratio: 23/20) {
  /* portrait: the scene sits in the upper half, the words below it */
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "copy" "bottom"; }
  .stage__scrim { background: linear-gradient(0deg, rgba(1, 1, 21, .92) 0%, rgba(1, 1, 21, .55) 42%, transparent 62%); }
  .orbit { display: none; }
  .copy { width: 100%; max-width: none; }
  .stage.no-webgl .stage__fallback { right: 50%; translate: 50% 0; top: 16%; width: min(60vw, 320px); }
}

@media (max-width: 720px) {
  .bottom { grid-template-columns: minmax(0, 1fr); gap: var(--space-15); }
  .formations { grid-column: 1; grid-row: 1; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
  .formations::-webkit-scrollbar { display: none; }
  .formation { min-width: 68px; flex: none; }
  .legal { grid-row: 2; }
  .status { font-size: 11px; padding: 6px 12px 6px 10px; }
}

/* Calm mode (prefers-reduced-motion): the scene still changes shape, slowly
   and without swirl (see morph_renderer.js). Here nothing spins, slides or
   flickers; text and chrome fade in, and the progress bars still fill. */
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .orbit__text, .orbit__ring, .orbit__mark, .stage__grain, .status__dot,
  .loader, .loader-inner { animation: none !important; }
  .loader-inner { height: 50%; }
  .is-loaded .line,
  .is-loaded .eyebrow, .is-loaded .lead, .is-loaded .top, .is-loaded .bottom, .is-loaded .orbit { animation-name: appear; }
  .stage.is-calm .hint__ripple { display: none; }
}
