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

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  min-height: 100%;
}

body {
  overflow-x: visible;
  background-color: var(--color-bg);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-2);
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}

.skip:focus {
  left: var(--space);
  top: var(--space);
  z-index: 100;
  background: var(--color-stone);
  color: var(--color-text-hi);
  padding: 0.5rem 0.75rem;
}

/* ---------- Nav ---------- */
#nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: #0e1114;
  border-bottom: 1px solid #2a3038;
  color: #e6e8ea;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: 72px;
  color: var(--color-text-hi);
}

#nav .logo,
#nav .logo-word,
#nav .logo:hover {
  color: #f4f5f6;
}

.logo-mark {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.logo-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.15;
  white-space: nowrap;
}

#nav-drawer {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

#nav-drawer a {
  color: #e6e8ea;
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
}

#nav-drawer a:not(.cta)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 150ms ease;
}

#nav-drawer a:not(.cta):hover {
  color: var(--color-text-hi);
}

#nav-drawer a:not(.cta):hover::after {
  transform: scaleX(1);
}

#nav-drawer .cta {
  background: var(--color-accent);
  color: #000;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  font-weight: 500;
}

#nav-drawer .cta:hover {
  background: var(--color-accent-2);
  color: #000;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-stone-2);
  color: var(--color-text-hi);
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--color-text-hi);
  position: relative;
  margin: 0 auto;
}

.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle span::before {
  top: -5px;
}

.nav-toggle span::after {
  top: 5px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-accent);
  color: #000;
}

.btn-primary:hover {
  background: var(--color-accent-2);
  color: #000;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-hi);
  border-color: var(--color-stone-2);
}

.btn-ghost:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-2);
}

/* ---------- Hero ---------- */
#hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 2rem;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  overflow: hidden;
  perspective: 1400px;
  transform-style: preserve-3d;
}

.hero-copy {
  min-width: 0;
  transform: translateZ(28px);
}

.hero-copy .kicker {
  margin: 0 0 1rem;
  color: var(--color-muted);
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  font-weight: 500;
}

#hero h1 {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-hi);
  font-size: clamp(2.2rem, 4.4vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 12ch;
}

.subhead {
  margin: 0 0 1.75rem;
  max-width: 38rem;
  color: var(--color-text);
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-object {
  position: relative;
  width: 100%;
  min-height: min(70vh, 640px);
  height: min(70vh, 640px);
  cursor: pointer;
  transform: rotateX(8deg);
  transform-style: preserve-3d;
  background: transparent;
  border-radius: 0;
}

.hero-object canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Chapters ---------- */
#services {
  position: relative;
}

.chapter {
  --chapter-p: 0;
  --chapter-fade: 0;
  min-height: 160vh;
  border-top: 1px solid var(--color-stone-2);
  position: relative;
  overflow: visible;
  background-image: none;
}

.logic-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.chapter-inner {
  position: sticky;
  top: var(--nav);
  min-height: calc(100vh - var(--nav));
  height: calc(100vh - var(--nav));
  max-height: calc(100vh - var(--nav));
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(240px, 0.95fr);
  gap: 2rem;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 1.75rem;
  overflow: hidden;
  z-index: 1;
}

.chapter-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  opacity: var(--chapter-fade);
  transform: translateX(calc(-2.5rem * (1 - var(--chapter-fade))));
}

.chapter-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  height: min(280px, calc(100vh - var(--nav) - 4rem));
  width: 100%;
  opacity: var(--chapter-fade);
}

.service-icon {
  width: 200px;
  height: 200px;
  background-color: var(--color-text);
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
  transform: rotate(calc(var(--chapter-p) * 8deg))
    scale(calc(0.82 + 0.18 * var(--chapter-fade)));
}

.icon-consult {
  -webkit-mask-image: url("../media/icons/icon-consult.svg");
  mask-image: url("../media/icons/icon-consult.svg");
}
.icon-integrate {
  -webkit-mask-image: url("../media/icons/icon-integrate.svg");
  mask-image: url("../media/icons/icon-integrate.svg");
}
.icon-agents {
  -webkit-mask-image: url("../media/icons/icon-agents.svg");
  mask-image: url("../media/icons/icon-agents.svg");
}
.icon-build {
  -webkit-mask-image: url("../media/icons/icon-build.svg");
  mask-image: url("../media/icons/icon-build.svg");
}

.chapter-mark img {
  display: none;
}

.chapter .kicker {
  margin: 0 0 0.6rem;
  color: var(--color-muted);
  font-size: 0.85rem;
  font-style: italic;
  letter-spacing: 0.04em;
}

.chapter h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-hi);
  font-size: clamp(1.85rem, 4.2vw, 3.35rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 18ch;
}

.chapter p.body {
  margin: 0;
  max-width: 40rem;
  color: var(--color-text);
  font-size: 1.125rem;
}

#principles,
#tools,
#method {
  max-width: var(--max);
  margin: 0 auto;
  padding: 3rem 1.25rem;
}

.principles-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  counter-reset: p;
}

.principles-list li {
  margin: 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-stone-2);
  color: var(--color-text-hi);
  font-size: 1.05rem;
}

.tools-label {
  margin: 0 0 1rem;
  color: var(--color-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.tools-marquee {
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

.tools-track {
  display: flex;
  align-items: center;
  gap: 3rem;
  width: max-content;
  animation: tools-marquee 32s linear infinite;
}

.tools-marquee:hover .tools-track {
  animation-play-state: paused;
}

.tool-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  color: var(--color-text);
}

.tool-mark {
  display: inline-flex;
  transition: transform 200ms ease;
  transform-style: preserve-3d;
}

.tool-mark img {
  height: 32px;
  width: auto;
  display: block;
  filter: grayscale(1) brightness(1.25);
  transition: filter 200ms ease;
}

.tool-mark:hover {
  transform: rotateY(18deg);
}

.tool-mark:hover img {
  filter: grayscale(0) brightness(0) invert(0.55) sepia(1) saturate(6) hue-rotate(160deg);
}

@keyframes tools-marquee {
  to { transform: translateX(-50%); }
}

.method-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  counter-reset: m;
}

.method-list li {
  margin: 0;
  color: var(--color-text);
  font-size: 0.95rem;
}

.method-list strong {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--color-text-hi);
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.contact-note,
.disclaimer {
  color: var(--color-muted);
  font-size: 0.9rem;
  max-width: 36rem;
}

/* ---------- Recap ---------- */
#recap {
  padding: 5rem 1.25rem;
  max-width: var(--max);
  margin: 0 auto;
}

#recap h2 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-hi);
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin: 0 0 1.5rem;
}

.recap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.card {
  background: var(--color-stone);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.15rem;
  padding: 1.25rem 1.35rem;
  overflow: hidden;
  transition: transform 200ms ease, border-color 200ms ease;
}

.card-visual {
  height: 140px;
  margin: -0.25rem -0.25rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-visual .service-icon {
  width: 88px;
  height: 88px;
  transform: none;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 170, 255, 0.35);
}

.card:hover .service-icon {
  background-color: var(--color-accent);
}

.card h3 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-text-hi);
  font-size: 1.15rem;
}

.card p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}

/* ---------- About / contact / footer ---------- */
#about,
#contact {
  max-width: var(--max);
  margin: 0 auto;
  padding: 5rem 1.25rem;
  border-top: 1px solid var(--color-stone-2);
}

#about h2,
#contact h2 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-hi);
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 1.25rem;
}

#about .lede {
  font-size: 1.2rem;
  color: var(--color-text-hi);
  max-width: 40rem;
}

#about .body {
  max-width: 40rem;
}

.form {
  max-width: 36rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--color-text-hi);
  font-weight: 500;
}

.field input,
.field textarea {
  width: 100%;
  background: var(--color-stone);
  border: 1px solid var(--color-stone-2);
  color: var(--color-text-hi);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  font-family: var(--font-body);
  font-size: 1rem;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--color-accent);
}

.field textarea {
  min-height: 8rem;
  resize: vertical;
}

.field .error {
  color: var(--color-error);
  font-size: 0.85rem;
  margin: 0.3rem 0 0;
  min-height: 1.1em;
}

.hp {
  display: none;
}

.form-note {
  margin: 0.75rem 0 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.form-note.is-ok {
  color: var(--color-accent-2);
}

.form-note.is-err {
  color: var(--color-error);
}

.form .btn-primary {
  align-self: flex-start;
}

footer {
  border-top: 1px solid var(--color-stone-2);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--color-muted);
  font-size: 0.85rem;
  background: #0e1114;
}

footer img {
  width: 32px;
  height: 32px;
}

footer p {
  margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #nav-drawer {
    display: none;
    position: absolute;
    top: var(--nav);
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: #0e1114;
    border-bottom: 1px solid var(--color-stone-2);
    padding: 0.5rem 1.25rem 1rem;
  }

  #nav-drawer.open {
    display: flex;
  }

  #nav-drawer a {
    padding: 0.7rem 0;
    width: 100%;
  }

  #nav-drawer .cta {
    width: 100%;
    text-align: center;
    margin-top: 0.35rem;
  }

  .logo-word {
    font-size: 16px;
    letter-spacing: 0.08em;
    white-space: normal;
    max-width: 12rem;
  }

  #hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 2.5rem;
  }

  .hero-object {
    min-height: 320px;
    height: 360px;
    order: -1;
  }

  .chapter-inner {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    min-height: calc(100vh - var(--nav));
    padding: 1.25rem;
    overflow: visible;
  }

  .chapter-mark {
    height: min(280px, 55vw);
    order: -1;
  }

  .chapter-mark img {
    width: min(220px, 60vw);
  }

  .recap-grid,
  .principles-list,
  .method-list {
    grid-template-columns: 1fr;
  }

  .form .btn-primary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .card,
  .geo-tilt,
  .service-icon {
    transition: none;
    transform: none;
  }

  .card:hover {
    transform: none;
  }

  .geo-spin,
  .marquee-track,
  .tools-track {
    animation: none;
  }

  .chapter-copy {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .scene-3d,
  .shape {
    animation: none !important;
  }
}

/* ---------- C: split bands + pale 3D ---------- */
#hero { background: #ffffff; position: relative; }
#principles,
#tools,
#recap,
#about,
#contact,
#method {
  max-width: none;
  width: 100%;
}
#principles,
#tools { background: var(--color-band); }
#consulting { background: #ffffff; }
#integration { background: var(--color-band); }
#agents { background: #ffffff; }
#build { background: var(--color-band); }
#recap { background: #ffffff; }
#about { background: var(--color-band); }
#method { background: #ffffff; }
#contact { background: #ffffff; }

#principles,
#tools,
#method,
#about,
#contact,
#recap {
  position: relative;
}

.scene-3d {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  perspective: 900px;
  overflow: hidden;
  opacity: 0.62;
  transform: translateY(calc(var(--chapter-p, 0) * -10vh));
}

.hero-copy,
.hero-object,
#principles .principles-list,
#tools .tools-label,
#tools .tools-marquee,
#recap h2,
#recap .recap-grid,
#method h2,
#method .method-list,
#about h2,
#about .lede,
#about .body,
#contact h2,
#contact .form,
#contact .contact-note {
  position: relative;
  z-index: 1;
}

.shape {
  position: absolute;
  border: 3px solid rgba(0, 170, 255, 0.42);
  background: rgba(214, 228, 236, 0.72);
  animation: drift3d 36s linear infinite;
}

.scene-hero .shape {
  width: min(92vh, 900px);
  height: min(92vh, 900px);
  min-width: 640px;
  min-height: 640px;
  right: -2%;
  top: 2%;
  border-radius: 40% 60% 55% 45%;
  transform: rotateX(18deg) rotateY(22deg);
}

.scene-slabs .shape {
  width: min(88vw, 1100px);
  height: 24vh;
  min-height: 160px;
  left: 4%;
  border-radius: 8px;
}
.scene-slabs .s1 { top: 22%; animation-duration: 32s; }
.scene-slabs .s2 { top: 38%; left: 18%; animation-duration: 40s; animation-direction: reverse; }
.scene-slabs .s3 { top: 54%; left: 6%; animation-duration: 36s; }

.scene-nodes .shape {
  width: min(46vh, 460px);
  height: min(46vh, 460px);
  min-width: 260px;
  min-height: 260px;
  border-radius: 50%;
}
.scene-nodes .s1 { top: 20%; left: 12%; }
.scene-nodes .s2 { top: 48%; right: 16%; animation-duration: 42s; }
.scene-nodes .s3 { top: 64%; left: 28%; animation-duration: 30s; animation-direction: reverse; }

.scene-rings .shape {
  border-radius: 50%;
  background: transparent;
  border-width: 4px;
}
.scene-rings .s1 { width: min(74vh, 700px); height: min(74vh, 700px); min-width: 460px; min-height: 460px; right: 2%; top: 6%; }
.scene-rings .s2 { width: min(94vh, 900px); height: min(94vh, 900px); min-width: 640px; min-height: 640px; right: -4%; top: 0; animation-duration: 44s; }
.scene-rings .s3 { width: min(42vh, 400px); height: min(42vh, 400px); right: 14%; top: 26%; animation-direction: reverse; }

.scene-frames .shape {
  border-radius: 14px;
  background: transparent;
  border-width: 3px;
}
.scene-frames .s1 { width: min(70vw, 820px); height: min(60vh, 560px); left: 6%; top: 10%; }
.scene-frames .s2 { width: min(86vw, 1040px); height: min(76vh, 720px); left: 2%; top: 4%; animation-duration: 38s; }
.scene-frames .s3 { width: min(48vw, 560px); height: min(40vh, 400px); left: 14%; top: 28%; animation-direction: reverse; }

.scene-quiet .shape {
  width: min(58vw, 680px);
  height: min(44vh, 430px);
  right: 4%;
  top: 22%;
  border-radius: 18px;
  animation-duration: 48s;
}

@keyframes drift3d {
  0% { transform: translate3d(0, 0, 0) rotateX(12deg) rotateY(0deg); }
  50% { transform: translate3d(12px, -18px, 20px) rotateX(18deg) rotateY(180deg); }
  100% { transform: translate3d(0, 0, 0) rotateX(12deg) rotateY(360deg); }
}

.tool-mark img {
  filter: none;
}
.tool-mark:hover img {
  filter: brightness(0) saturate(100%) invert(48%) sepia(98%) saturate(2000%) hue-rotate(168deg);
}
