:root {
  --bg: #1a1b1d;
  --bg-rgb: 26, 27, 29;
  --ink: #e9eaec;
  --muted: #9aa0a8;
  --primary: rgb(54, 226, 232);
  --secondary: rgb(240, 47, 51);
  --edge: clamp(20px, 5.5vw, 64px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.7s ease;
}

/* ---- preloader reveal -------------------------------------------------- */
#scroller, .chrome, .menu-toggle, .footnote {
  transition: opacity 0.75s ease;
}
body.is-loading { background: #000; }
body.is-loading #scroller,
body.is-loading .chrome,
body.is-loading .menu-toggle,
body.is-loading .footnote {
  opacity: 0;
  pointer-events: none;
}

/* ---- tunnel canvas + atmosphere ---------------------------------------- */
#tunnel {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
}
/* film grain + vignette */
.atmos {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.atmos.vignette {
  background: radial-gradient(130% 100% at var(--vx, 40%) var(--vy, 45%),
              transparent 38%, rgba(0, 0, 0, 0.30) 72%, rgba(0, 0, 0, 0.62) 100%);
}
.atmos.grain {
  opacity: 0.05;
  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='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- scroll stage ------------------------------------------------------ */
#scroller {
  position: relative;
  z-index: 2;
  height: 100dvh;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#scroller::-webkit-scrollbar { display: none; }

.slice {
  min-height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: safe center;
  justify-content: center;
  padding: clamp(70px, 12vh, 130px) var(--edge);
  position: relative;
}

.slice-inner {
  position: relative;
  width: 100%;
  max-width: 560px;
}
/* local legibility scrim behind the text */
.slice-inner::before {
  content: "";
  position: absolute;
  inset: -8% -12%;
  z-index: -1;
  background: radial-gradient(ellipse at 30% 50%,
              rgba(var(--bg-rgb), 0.88) 0%, rgba(var(--bg-rgb), 0.6) 48%, transparent 78%);
}

@media (min-width: 900px) {
  .slice { justify-content: flex-end; padding-right: clamp(64px, 12vw, 220px); }
  .slice-inner { max-width: 600px; }
}

/* ---- type -------------------------------------------------------------- */
.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 1.6rem;
  display: inline-block;
}
.eyebrow.secondary { color: var(--secondary); }

h1 {
  font-size: clamp(2.6rem, 8vw, 5.6rem);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
h2 {
  font-size: clamp(1.9rem, 4.6vw, 3.4rem);
  font-weight: 600;
  line-height: 1.03;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.lead {
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.55;
  color: var(--muted);
  margin-top: 1.6rem;
  max-width: 46ch;
}
.quote {
  font-size: clamp(2.1rem, 5.5vw, 4rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.quote .accent { color: var(--primary); }
.attrib {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-top: 1.8rem;
  text-transform: uppercase;
}

/* instrument list */
.insts { margin-top: 2.2rem; display: flex; flex-direction: column; gap: 1.15rem; }
.inst {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.1rem;
  align-items: baseline;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.inst:last-child { border-bottom: none; }
.inst .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--secondary);
  padding-top: 0.35em;
}
.inst .name { font-size: clamp(1.15rem, 2vw, 1.5rem); font-weight: 600; letter-spacing: -0.01em; }
.inst .desc { font-size: clamp(0.9rem, 1.3vw, 1.02rem); color: var(--muted); margin-top: 0.25rem; line-height: 1.5; }

/* CTA */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 2.1rem;
  padding: 0.95rem 1.6rem;
  border: 1px solid var(--primary);
  color: var(--ink);
  background: transparent;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, gap 0.25s ease;
}
.cta:hover { background: var(--primary); color: #07181a; gap: 1.1rem; }
.cta .arr { transition: transform 0.25s ease; }
.cta:hover .arr { transform: translateX(3px); }
.contact {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(12px, 1.2vw, 14px);
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 1.8rem;
}
.contact a { color: var(--primary); text-decoration: none; }

/* ---- lateral detour ---------------------------------------------------- */
/* button on slice 02 that opens the side view */
.lateral-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 2.2rem;
  padding: 0.85rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.02);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, gap 0.25s ease;
}
.lateral-btn:hover { border-color: var(--primary); background: rgba(54, 226, 232, 0.07); gap: 1.1rem; }
.lateral-btn .arr { color: var(--primary); transition: transform 0.25s ease; }
.lateral-btn:hover .arr { transform: translateX(4px); }

/* parallax easing shared by foreground layers */
:root { --slide-ease: cubic-bezier(0.76, 0, 0.24, 1); --slide-dur: 0.82s; }

#scroller { transition: transform var(--slide-dur) var(--slide-ease); will-change: transform; }
body.detour-open #scroller { transform: translateX(-100%); pointer-events: none; }

.detour {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: safe center;
  justify-content: flex-start;
  padding: clamp(70px, 12vh, 130px) var(--edge);
  transform: translateX(100%);
  transition: transform var(--slide-dur) var(--slide-ease), visibility 0s linear var(--slide-dur);
  visibility: hidden;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
body.detour-open .detour.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform var(--slide-dur) var(--slide-ease), visibility 0s;
}
.detour-inner { max-width: 560px; }
@media (min-width: 900px) {
  .detour { justify-content: flex-end; padding-right: clamp(64px, 12vw, 220px); }
  .detour-inner { max-width: 600px; }
}

/* detour content reveals when its panel opens */
.detour.is-open .reveal {
  animation: reveal-in 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(0.18s + var(--i, 0) * 95ms);
}

/* back button */
.back {
  position: fixed;
  top: var(--edge);
  left: var(--edge);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem 0.6rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(22, 23, 25, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.25s ease;
}
.back .arr { color: var(--primary); transition: transform 0.25s ease; }
.back:hover { border-color: var(--primary); }
.back:hover .arr { transform: translateX(-4px); }
body.detour-open .detour.is-open .back {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  transition-delay: 0.3s;
}

/* hide the vertical-journey chrome while the side view is open */
body.detour-open .wordmark,
body.detour-open .counter,
body.detour-open #dots,
body.detour-open #hint { opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
body.detour-open #dots { pointer-events: none; }

/* ---- reveal animation -------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
}
.slice.is-active .reveal {
  animation: reveal-in 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 95ms);
}
@keyframes reveal-in {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  .slice.is-active .reveal { animation: none; }
}

/* ---- fixed chrome ------------------------------------------------------ */
.chrome {
  position: fixed;
  z-index: 5;
  pointer-events: none;
}
.wordmark { top: var(--edge); left: var(--edge); }
.wordmark .mark {
  font-weight: 700;
  font-size: clamp(15px, 1.5vw, 18px);
  letter-spacing: 0.34em;
}
.wordmark .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 5px;
}

.counter {
  bottom: clamp(16px, 3vh, 26px);
  right: var(--edge);
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  letter-spacing: 0.12em;
}
.counter .big { font-size: clamp(15px, 1.5vw, 18px); color: var(--ink); }
.counter .tot { color: var(--muted); }
.counter .lbl { font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); margin-top: 5px; }

/* progress dots */
#dots {
  right: clamp(14px, 2.4vw, 30px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: auto;
}
.dot {
  width: 9px; height: 9px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
}
.dot:hover { border-color: var(--primary); }
.dot.on {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(54, 226, 232, 0.15);
}

/* scroll hint */
#hint {
  left: 50%;
  bottom: clamp(20px, 4vh, 40px);
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  transition: opacity 0.5s ease;
}
#hint .arrow {
  width: 1px; height: 26px;
  background: linear-gradient(var(--primary), transparent);
  animation: drop 1.8s ease-in-out infinite;
}
@keyframes drop {
  0%, 100% { transform: scaleY(0.4); transform-origin: top; opacity: 0.4; }
  50% { transform: scaleY(1); transform-origin: top; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { #hint .arrow { animation: none; } }

.footnote {
  position: fixed;
  left: var(--edge);
  bottom: clamp(16px, 3vh, 26px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.95rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(154, 160, 168, 0.55);
  pointer-events: none;
}
.footnote a {
  color: rgba(154, 160, 168, 0.7);
  text-decoration: none;
  pointer-events: auto;
  transition: color 0.2s ease;
}
.footnote a:hover { color: var(--primary); }

@media (max-width: 640px) {
  .wordmark .sub, .counter .lbl, .footnote { display: none; }
  #dots { gap: 11px; }
}

/* ---- mobile hardening -------------------------------------------------- */
/* On short / narrow screens, content can exceed one screen. Soften the snap
   so tall slices scroll naturally instead of being trapped, and top-align so
   nothing is ever clipped above the fold. */
@media (max-width: 640px), (max-height: 720px) {
  #scroller { scroll-snap-type: y proximity; }
  .slice {
    align-items: safe start;
    scroll-snap-stop: normal;
    padding-top: clamp(96px, 16vh, 140px);
    padding-bottom: clamp(72px, 12vh, 110px);
  }
  .detour { align-items: safe start; }
  .detour-inner { padding-top: 64px; }
}

/* shrink the dense hero on short viewports so it fits the first screen */
@media (max-height: 720px) {
  .slice--hero h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); }
  .tagline { font-size: 1rem; margin-top: 0.9rem; }
  .lead { font-size: 0.95rem; margin-top: 1.1rem; }
}

/* expand the progress-dot tap targets to ~44px on touch without growing the
   visible dot */
@media (pointer: coarse) {
  .dot { position: relative; }
  .dot::after {
    content: "";
    position: absolute;
    inset: -17px;
  }
}

/* ---- Angineered content additions -------------------------------------- */
/* hero heading — longer brand copy needs a smaller scale */
.slice--hero h1 { font-size: clamp(1.95rem, 4.3vw, 3.45rem); line-height: 1.05; }

/* punchy tagline line under a heading */
.tagline {
  font-size: clamp(1.05rem, 1.8vw, 1.4rem);
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  margin-top: 1.2rem;
  max-width: 32ch;
  text-wrap: balance;
}

/* the CTA can be a link too */
.cta { text-decoration: none; }

/* compact lists inside detours (longer service/capability lists) */
.detour .insts { gap: 0.85rem; margin-top: 1.9rem; }
.detour .inst { padding-bottom: 0.85rem; }

/* contact lines in the contact detour */
.contact-line {
  display: flex;
  gap: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(12px, 1.2vw, 14px);
  letter-spacing: 0.06em;
  color: var(--ink);
  margin-top: 0.7rem;
}
.contact-line:first-of-type { margin-top: 1.6rem; }
.contact-line .k {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.8em;
  flex: 0 0 6.5em;
  padding-top: 0.15em;
}
.contact-line a { color: var(--primary); text-decoration: none; }
.contact-line a:hover { text-decoration: underline; }

/* ---- hamburger toggle -------------------------------------------------- */
.menu-toggle {
  position: fixed;
  top: var(--edge);
  right: var(--edge);
  z-index: 22;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(22, 23, 25, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.menu-toggle:hover { border-color: var(--primary); }
.menu-toggle .bars {
  position: relative;
  width: 20px;
  height: 14px;
  display: block;
}
.menu-toggle .bars span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.32s cubic-bezier(0.76, 0, 0.24, 1), opacity 0.2s ease, background 0.25s ease;
}
.menu-toggle .bars span:nth-child(1) { top: 0; }
.menu-toggle .bars span:nth-child(2) { top: 50%; transform: translateY(-50%); }
.menu-toggle .bars span:nth-child(3) { bottom: 0; }
.menu-toggle:hover .bars span { background: var(--primary); }
/* open → X */
body.menu-open .menu-toggle .bars span:nth-child(1) { top: 50%; transform: translateY(-50%) rotate(45deg); }
body.menu-open .menu-toggle .bars span:nth-child(2) { opacity: 0; }
body.menu-open .menu-toggle .bars span:nth-child(3) { bottom: auto; top: 50%; transform: translateY(-50%) rotate(-45deg); }

/* ---- nav overlay ------------------------------------------------------- */
.nav-menu {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: safe center;
  padding: clamp(80px, 14vh, 150px) var(--edge);
  background: rgba(20, 21, 23, 0.93);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  backdrop-filter: blur(18px) saturate(130%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
  overflow-y: auto;
}
body.menu-open .nav-menu {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0s;
}
.nav-inner { width: 100%; max-width: 880px; margin: 0 auto; }
.nav-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--primary);
  display: block;
  margin-bottom: clamp(1.4rem, 4vh, 2.6rem);
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li { border-top: 1px solid rgba(255, 255, 255, 0.09); }
.nav-list li:last-child { border-bottom: 1px solid rgba(255, 255, 255, 0.09); }

.nav-item {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: clamp(1rem, 3vw, 2.4rem);
  padding: clamp(0.85rem, 2.2vh, 1.4rem) 0;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  transition: padding-left 0.3s cubic-bezier(0.76, 0, 0.24, 1);
}
.nav-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.1vw, 13px);
  color: var(--muted);
  flex: 0 0 auto;
  padding-top: 0.5em;
  transition: color 0.25s ease;
}
.nav-text { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: clamp(1.6rem, 4.4vw, 2.9rem);
  line-height: 1.0;
  letter-spacing: -0.02em;
  transition: color 0.25s ease, transform 0.3s cubic-bezier(0.76, 0, 0.24, 1);
}
.nav-desc {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 0.04em;
  color: var(--muted);
}
.nav-item:hover .nav-name,
.nav-item:focus-visible .nav-name { color: var(--primary); }
.nav-item:hover { padding-left: clamp(0.6rem, 1.6vw, 1.2rem); }
.nav-item:hover .nav-num { color: var(--primary); }
/* current section */
.nav-item.on .nav-num { color: var(--secondary); }
.nav-item.on .nav-name { color: var(--ink); }
.nav-item.on .nav-name::after {
  content: "";
  display: inline-block;
  width: 0.5em; height: 0.5em;
  margin-left: 0.5em;
  border-radius: 50%;
  background: var(--secondary);
  vertical-align: middle;
}

.nav-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem clamp(1.5rem, 4vw, 3rem);
  margin-top: clamp(1.8rem, 5vh, 3rem);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(12px, 1.2vw, 14px);
  letter-spacing: 0.06em;
}
.nav-foot a { color: var(--primary); text-decoration: none; }
.nav-foot a:hover { text-decoration: underline; }

/* staggered reveal of nav items when the menu opens */
body.menu-open .nav-eyebrow,
body.menu-open .nav-list li,
body.menu-open .nav-foot {
  animation: nav-rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
body.menu-open .nav-list li:nth-child(1) { animation-delay: 0.06s; }
body.menu-open .nav-list li:nth-child(2) { animation-delay: 0.12s; }
body.menu-open .nav-list li:nth-child(3) { animation-delay: 0.18s; }
body.menu-open .nav-list li:nth-child(4) { animation-delay: 0.24s; }
body.menu-open .nav-list li:nth-child(5) { animation-delay: 0.30s; }
body.menu-open .nav-foot { animation-delay: 0.36s; }
@keyframes nav-rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* hide the journey chrome behind the menu (keeps the toggle, which sits above) */
body.menu-open .counter,
body.menu-open #dots,
body.menu-open #hint,
body.menu-open .wordmark { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }

@media (prefers-reduced-motion: reduce) {
  body.menu-open .nav-eyebrow,
  body.menu-open .nav-list li,
  body.menu-open .nav-foot { animation: none; }
  .menu-toggle .bars span { transition: none; }
}

@media (max-width: 640px) {
  .menu-toggle { width: 44px; height: 44px; }
}

/* ---- mobile: translucent panel behind content for legibility ----------- */
@media (max-width: 640px) {
  .slice-inner,
  .detour-inner {
    background: rgba(20, 21, 23, 0.66);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    padding: clamp(18px, 5.5vw, 28px);
  }
  /* the radial scrim is redundant once the panel is in place */
  .slice-inner::before { display: none; }
}
