/* Motion v2: The Post. Desktop-forward, quiet on touch and reduced motion. */

html.lenis, html.lenis-smooth { scroll-behavior: auto; }

.scan-layer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(201, 165, 106, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 165, 106, 0.14) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(circle 200px at var(--scan-x, 50%) var(--scan-y, 50%), #000 0%, transparent 70%);
  mask-image: radial-gradient(circle 200px at var(--scan-x, 50%) var(--scan-y, 50%), #000 0%, transparent 70%);
  opacity: 0.55;
  mix-blend-mode: screen;
}
html.can-scan .scan-layer { display: block; }
html.reduce-motion .scan-layer,
html.is-touch .scan-layer,
body.is-open .scan-layer { display: none !important; }

/* ----- Hero split ----- */
.hero-split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  align-items: center;
  gap: clamp(24px, 5vw, 72px);
  max-width: calc(var(--max) + var(--pad-x) * 2);
  margin: 0 auto;
  width: 100%;
  text-align: left;
  padding-top: 6vh;
  padding-bottom: 10vh;
}
.hero-split .lede { margin-left: 0; text-align: left; }
.hero-split .hero-actions { justify-content: flex-start; }

.hero-crest {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 377 / 400;
  justify-self: end;
}
.crest-fallback,
.crest-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.crest-canvas {
  opacity: 0;
  transition: opacity 0.6s var(--ease);
  display: block;
}
.has-webgl .crest-canvas { opacity: 1; }
.has-webgl .crest-fallback { opacity: 0; }

/* ----- Method: pinned chapters ----- */
.method {
  position: relative;
  background: var(--navy);
  border-top: 1px solid var(--gold-line);
  border-bottom: 1px solid var(--gold-line);
}
html.motion:not(.reduce-motion):not(.is-touch) .method {
  height: 400vh;
}
.method-sticky {
  position: relative;
}
html.motion:not(.reduce-motion):not(.is-touch) .method-sticky {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}
.method-frame {
  height: 100%;
  max-width: calc(var(--max) + var(--pad-x) * 2);
  margin: 0 auto;
  padding: 36px var(--pad-x) 48px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.method-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(16px, 3vh, 32px);
}
.method-head .kicker { margin: 0; }
.method-index {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.method-grid {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
.method-step {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  z-index: 1;
}
html.motion:not(.reduce-motion):not(.is-touch) .method-step {
  position: absolute;
  inset: 0;
}
.method-step.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  position: relative;
  z-index: 2;
}
html.motion:not(.reduce-motion):not(.is-touch) .method-step.is-active {
  position: absolute;
}
html.reduce-motion .method-step,
html.is-touch .method-step {
  position: relative;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  margin-bottom: 48px;
}
.method-copy { min-width: 0; }
.method-title {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-size: clamp(3rem, 7vw, 6rem);
  line-height: 0.95;
  font-weight: 500;
  color: var(--ivory);
}
.method-title .ch {
  display: inline-block;
  will-change: transform, opacity;
}
.method-panel p {
  margin: 0;
  max-width: 28em;
  color: var(--ivory-soft);
  font-weight: 300;
  font-size: 1.05rem;
  line-height: 1.65;
}

.method-visual,
.visual {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.visual-caption {
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel-2);
  line-height: 1.5;
}

/* Deployment diagram */
.deploy-svg {
  width: 100%;
  height: auto;
  color: var(--gold);
  overflow: visible;
}
.svg-kicker {
  fill: var(--gold);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
.svg-label {
  fill: var(--steel);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.svg-label.gold { fill: var(--gold-bright); }
.deploy-path {
  stroke: var(--gold);
  stroke-linecap: round;
  fill: none;
  opacity: 0.35;
  stroke-dasharray: 420;
  stroke-dashoffset: 420;
}
.visual-deploy.is-drawn .deploy-path,
html.reduce-motion .deploy-path,
html.is-touch .deploy-path {
  stroke-dashoffset: 0;
  opacity: 0.85;
  transition: stroke-dashoffset 1.4s var(--ease), opacity 0.8s ease;
}
.deploy-origin { fill: var(--gold-bright); }
.deploy-node circle {
  fill: var(--navy);
  stroke: var(--gold);
  stroke-width: 1.5;
}
.deploy-node { opacity: 0.35; transition: opacity 0.5s ease; }
.visual-deploy.is-drawn .deploy-node,
html.reduce-motion .deploy-node,
html.is-touch .deploy-node { opacity: 1; }
.deploy-axis { stroke: var(--gold-line); stroke-width: 1; }

/* Floor presence */
.floor-scene {
  position: relative;
  height: 280px;
  overflow: hidden;
  border: 1px solid var(--gold-line);
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(201, 165, 106, 0.08), transparent 55%),
    #0c1018;
  perspective: 600px;
}
.floor-grid {
  position: absolute;
  left: -10%;
  right: -10%;
  top: 20%;
  height: 160%;
  background-image:
    linear-gradient(rgba(201, 165, 106, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 165, 106, 0.22) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: rotateX(64deg);
  transform-origin: top center;
}
.floor-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(224, 196, 138, 0.18) 50%, transparent 100%);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  background-position: -40% 0;
}
html.motion:not(.reduce-motion) .visual-present.is-active .floor-scan {
  animation: floor-scan 3.8s ease-in-out infinite;
}
@keyframes floor-scan {
  0% { background-position: -40% 0; }
  100% { background-position: 140% 0; }
}
.floor-tag {
  position: absolute;
  top: 14px;
  left: 16px;
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

/* Sample report */
.mini-log {
  background: #07090d;
  border: 1px solid var(--rule);
  padding: 16px 18px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ivory-soft);
}
.mini-log .log-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 10px;
}
.mini-log .sample {
  color: var(--gold-bright);
  border: 1px solid var(--gold-line);
  padding: 1px 6px;
  letter-spacing: 0.1em;
}
.mini-log .sample-flag {
  margin: 0 0 10px;
  color: var(--steel-2);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.mini-log .log-row {
  display: grid;
  grid-template-columns: 48px 52px 1fr auto;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
  color: var(--ivory-soft);
}
.mini-log .ok { color: #9ad7b0; }
.visual-report .log-row {
  opacity: 0;
  transform: translateY(8px);
}
.visual-report.is-drawn .log-row,
html.reduce-motion .visual-report .log-row,
html.is-touch .visual-report .log-row {
  opacity: 1;
  transform: none;
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}
.visual-report.is-drawn .log-row:nth-child(4) { transition-delay: 0.05s; }
.visual-report.is-drawn .log-row:nth-child(5) { transition-delay: 0.12s; }
.visual-report.is-drawn .log-row:nth-child(6) { transition-delay: 0.19s; }
.visual-report.is-drawn .log-row:nth-child(7) { transition-delay: 0.26s; }
.visual-report.is-drawn .log-row:nth-child(8) { transition-delay: 0.33s; }

.method-ticks {
  list-style: none;
  display: flex;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
}
.method-ticks li {
  width: 28px;
  height: 2px;
  background: var(--gold-line);
  transition: background 0.3s ease, width 0.3s ease;
}
.method-ticks li.is-active {
  background: var(--gold);
  width: 44px;
}

/* Magnetic buttons stay in normal flow; transform is applied by JS. */
.btn.magnet { will-change: transform; }

/* Mobile / reduced: stack the method as a normal section */
@media (max-width: 900px) {
  .hero-split {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
    padding-top: 4vh;
  }
  .hero-split .lede,
  .hero-split .hero-actions { justify-content: center; text-align: center; }
  .hero-crest {
    order: -1;
    max-width: 200px;
    justify-self: center;
    margin-bottom: 4px;
  }
  .hero .scroll-hint { display: none; }

  html.motion:not(.reduce-motion):not(.is-touch) .method { height: auto; }
  html.motion:not(.reduce-motion):not(.is-touch) .method-sticky {
    position: relative;
    height: auto;
    overflow: visible;
  }
  .method-step {
    grid-template-columns: 1fr;
    position: relative !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
    margin-bottom: 40px;
  }
  .method-index { display: none; }
  .method-ticks { display: none; }
  .method-title { font-size: clamp(2.6rem, 14vw, 4rem); }
  .floor-scene { height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  html.motion:not(.is-touch) .method { height: auto; }
  html.motion:not(.is-touch) .method-sticky {
    position: relative;
    height: auto;
    overflow: visible;
  }
  .method-step {
    position: relative !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    grid-template-columns: 1fr;
    margin-bottom: 48px;
  }
  .crest-canvas { display: none !important; }
  .crest-fallback { opacity: 1 !important; }
}

.hero-split h1 { font-size: clamp(2.5rem, 5.2vw, 4.75rem); }
html.js-gsap.motion .hero h1 .word,
html.js-gsap.motion .hero .reveal-hero {
  animation: none !important;
}
@media (max-width: 900px) {
  .hero-split h1 { font-size: clamp(2.25rem, 11vw, 3rem); }
}
