/* ─────────────────────────────────────────────────────────────
   nabla-instruments
   ───────────────────────────────────────────────────────────── */

@font-face {
  font-family: "0xProto";
  src: url("../assets/fonts/0xProto-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "0xProto";
  src: url("../assets/fonts/0xProto-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "0xProto";
  src: url("../assets/fonts/0xProto-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #1c1c1f;
  --bg-2: #242428;
  --fg: #ecebe6;
  --fg-dim: #9a9993;
  --fg-faint: #6e6e68;
  --line: #333338;
  --hot: #ff5b24;          /* distortion accent */
  --hot-dim: #ff5b2433;

  --mono: "0xProto", "0xProto Nerd Font Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1240px;
  --nav-h: 64px;
}

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

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: inherit; }
b { font-weight: 700; color: var(--fg); }
::selection { background: var(--hot); color: var(--bg); }

h1, h2, h3 { font-weight: 400; margin: 0; line-height: 1.1; letter-spacing: -0.02em; }

.kicker {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin-top: 1.5rem;
  padding: 0.8em 1.2em;
  border: 1px solid var(--fg);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn::after { content: "→"; transition: transform 0.2s; }
.btn:hover { background: var(--fg); color: var(--bg); }
.btn:hover::after { transform: translateX(3px); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--hot); outline-offset: 3px; }
.btn--big { font-size: clamp(0.82rem, 3.6vw, 1.4rem); padding: 0.9em 1.4em; white-space: nowrap; }

/* ───── nav ───── */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 var(--gutter);
  background: linear-gradient(to bottom, rgb(28 28 31 / 0.9), rgb(28 28 31 / 0));
  border-bottom: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
.nav.is-solid { background: rgb(28 28 31 / 0.94); border-bottom-color: var(--line); }
.nav nav { display: flex; gap: clamp(0.9rem, 2.5vw, 2rem); font-size: 0.85rem; }
.nav nav a { text-decoration: none; color: var(--fg-dim); transition: color 0.2s; white-space: nowrap; }
.nav nav a:hover { color: var(--fg); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-name { font-size: 1rem; letter-spacing: -0.01em; }

@media (max-width: 640px) {
  .brand-name { display: none; }
  .nav nav { font-size: 0.8rem; }
}
@media (max-width: 360px) {
  .nav nav { gap: 0.7rem; font-size: 0.74rem; }
}

/* ───── hero / 3D stage ───── */

.hero {
  position: relative;
  height: 600vh;          /* scroll length of the 3D sequence */
}

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 55% 60% at 64% 50%, #2e2e34 0%, #232327 45%, var(--bg) 78%);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  color: var(--fg-dim);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  transition: opacity 0.6s;
  pointer-events: none;
}
.loader.is-done { opacity: 0; }
.loader-mark { width: 44px; height: 44px; color: var(--fg); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; transform: scale(0.92); } }

/* tiny instrument-style readouts in the corners */
.hud {
  position: absolute;
  inset: calc(var(--nav-h) + 8px) var(--gutter) 24px;
  pointer-events: none;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--fg-faint);
  text-transform: uppercase;
}
.hud > div { position: absolute; }
.hud-tl { top: 0; left: 0; }
.hud-tr { top: 0; right: 0; font-variant-numeric: tabular-nums; }
.hud-bl { bottom: 0; left: 0; }
.hud-br { bottom: 0; right: 0; font-variant-numeric: tabular-nums; }
.hud-bar { display: block; width: 120px; height: 2px; background: var(--line); }
.hud-bar span { display: block; height: 100%; width: 0; background: var(--hot); }

.steps {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.step {
  position: absolute;
  left: var(--gutter);
  top: 50%;
  width: min(420px, 40vw);
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, transform 0.6s ease, visibility 0s 0.6s;
}
.step.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0s;
}
.step:not(.is-active) { transform: translateY(calc(-50% + 16px)); }

.step h2 { font-size: clamp(1.6rem, 3.2vw, 2.6rem); margin-bottom: 1rem; }
.step p { color: var(--fg-dim); margin: 0; max-width: 38ch; }
.step .kicker { color: var(--hot); }

.step--intro { width: min(640px, 46vw); }
.step--intro .title {
  white-space: nowrap;
  font-size: clamp(3rem, 7vw, 7rem);
  letter-spacing: -0.06em;
  line-height: 0.9;
  margin: 0 0 1.4rem -0.04em;
}
.step--intro .kicker { color: var(--fg-dim); }
.step--intro .lede { font-size: clamp(1rem, 1.6vw, 1.2rem); color: var(--fg); }

.scroll-hint {
  margin-top: 2.5rem !important;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint) !important;
}
.scroll-hint span { display: inline-block; animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(4px); } }

/* Phone: model fills the upper part, copy sits at the bottom */
@media (max-width: 760px) {
  .step {
    top: auto;
    bottom: 64px;
    left: 16px;
    right: 16px;
    width: auto;
    transform: none;
    padding: 1.1rem 1.2rem;
    background: rgb(28 28 31 / 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: 14px;
  }
  .step:not(.is-active) { transform: translateY(16px); }
  .step--intro { background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0; }
  .step h2 { font-size: 1.4rem; margin-bottom: 0.6rem; }
  .step p { font-size: 0.9rem; }
  .hud-tl, .hud-tr { display: none; }
  .hud { bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-mark, .scroll-hint span { animation: none; }
}

/* ───── generic sections ───── */

.section {
  position: relative;
  scroll-margin-top: var(--nav-h);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(80px, 14vw, 160px) var(--gutter);
}
.section-head { margin-bottom: clamp(40px, 6vw, 72px); }
.section-head h2, .about h2, .contact h2 { font-size: clamp(1.9rem, 4.6vw, 3.6rem); }

/* ───── features ───── */

.feature-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.feature {
  padding: clamp(24px, 3vw, 36px);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.3s;
}
.feature:hover { background: var(--bg-2); }
.feature-idx { display: block; font-size: 0.75rem; color: var(--hot); letter-spacing: 0.1em; margin-bottom: 2.5rem; }
.feature h3 { font-size: 1.25rem; margin-bottom: 0.8rem; }
.feature p { margin: 0; color: var(--fg-dim); font-size: 0.92rem; }

.flow {
  margin: clamp(56px, 8vw, 96px) 0 0;
  padding: clamp(16px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-2);
  color: var(--fg-faint);
  overflow-x: auto;
}
.flow svg { display: block; width: 100%; min-width: 620px; height: auto; }
.flow rect { fill: var(--bg); stroke: var(--fg-faint); stroke-width: 1.2; rx: 6; }
.flow text {
  fill: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
  text-anchor: middle;
  letter-spacing: 0.04em;
}
.flow .hot rect { stroke: var(--hot); }
.flow .hot-line { stroke: var(--hot); }
.flow .out rect { fill: var(--fg); stroke: var(--fg); }
.flow .out text { fill: var(--bg); }
.flow .out.hot rect { fill: var(--hot); stroke: var(--hot); }
.flow figcaption { margin-top: 1rem; font-size: 0.78rem; color: var(--fg-dim); }

/* ───── specs ───── */

.spec-list {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr));
  column-gap: clamp(24px, 5vw, 64px);
}
.spec-list > div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.spec-list dt { color: var(--fg-dim); font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; padding-top: 0.15em; }
.spec-list dd { margin: 0; }
@media (max-width: 480px) {
  .spec-list > div { grid-template-columns: 1fr; gap: 0.2rem; }
}

/* ───── about ───── */

.about {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
}
.about-mark { aspect-ratio: 1; max-width: 420px; width: 100%; justify-self: center; color: var(--fg); }
.about-mark svg { width: 100%; height: 100%; }
.about-body h2 { margin-bottom: 1.5rem; }
.about-body p { color: var(--fg-dim); max-width: 60ch; }
.about-sign { color: var(--fg) !important; margin-top: 2rem; }
@media (max-width: 760px) {
  .about { grid-template-columns: 1fr; }
  .about-mark { max-width: 160px; justify-self: start; }
}

/* ───── contact ───── */

.contact { text-align: center; border-top: 1px solid var(--line); }
.contact p { color: var(--fg-dim); margin: 1.2rem auto 0; max-width: 46ch; }

/* ───── footer ───── */

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 28px var(--gutter);
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--fg-dim);
}
.footer p { margin: 0; }
.footer .brand { color: var(--fg); }
.footer-origin { letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem; }
.footer-origin a { color: var(--fg); text-decoration: none; }
.footer-origin a:hover { color: var(--hot); }
.feature a, .about-body p a { color: var(--fg); text-underline-offset: 3px; text-decoration-color: var(--hot); }
.feature a:hover, .about-body p a:hover { color: var(--hot); }
@media (max-width: 640px) {
  .footer { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
}

/* no-WebGL fallback */
.no-webgl .loader-text::after { content: " — 3D view needs WebGL"; }
