/* ==========================================================================
   X-ray section: sticky stage + scroll-locked steps
   The stage stays pinned (position: sticky) while the four steps scroll past;
   JS only flips data-state on the stage and CSS transitions do the rest, so
   the visual state also works if GSAP never loads.
   ========================================================================== */

.xray {
  position: relative;
  padding-block: var(--space-section);
  color: var(--text-on-dark);
  background:
    radial-gradient(60% 40% at 85% 10%, rgb(16 140 181 / 0.28), transparent 70%),
    radial-gradient(50% 35% at 0% 70%, rgb(242 137 74 / 0.12), transparent 70%),
    var(--abyss-900);
}

.xray__intro { max-width: 54rem; margin-bottom: clamp(2.5rem, 6vw, 5rem); }
.xray__intro .eyebrow { color: var(--sand-400); }

.xray__intro h2 {
  margin-top: 0.4rem;
  font-size: clamp(2.1rem, min(3.4vw, 6.5svh), 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.005em;
}

/* Intro answer: no card, just a hairline, a gold question and a larger answer */
.xray__intro .answer {
  max-width: 36rem;
  margin-top: 1.5rem;
  padding: 1.25rem 0 0;
  border: 0;
  border-top: 1px solid rgb(150 217 240 / 0.28);
  border-radius: 0;
  background: none;
}
.xray__intro .answer h3 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.25rem, 1.1rem + 0.5vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: 0;
}
.xray__intro .answer p {
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.2rem);
  line-height: 1.65;
  color: var(--text-on-dark);
}

.xray__how { margin-top: clamp(3.5rem, 8vw, 7rem); }
.xray__how > .eyebrow { color: var(--sand-400); margin-bottom: 1.5rem; }
.xray__stage-label { display: none; }

@media (min-width: 64em) {
  .xray__intro {
    max-width: none;
    margin-bottom: 0;
    display: grid;
    grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
    column-gap: clamp(2rem, 5vw, 6rem);
    align-items: start;
  }
  .xray__intro .eyebrow { grid-column: 1 / -1; }
  .xray__intro h2 { grid-column: 1; }
  .xray__intro .answer { grid-column: 2; margin-top: 0.6rem; }
}







/* Direct-answer block (also used on light sections) */
.answer {
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  max-width: 44rem;
  padding: 1.25rem 1.5rem 1.4rem;
  border-left: 3px solid var(--sand-400);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
  background: rgb(236 248 254 / 0.06);
}
.answer h3 { font-size: var(--step-1); color: var(--sand-400); margin-bottom: 0.5rem; letter-spacing: 0.02em; }
.answer p { color: var(--text-muted-on-dark); }
.answer--light { background: rgb(9 84 115 / 0.06); border-left-color: var(--teal-700); }
.answer--light h3 { color: var(--teal-700); }
.answer--light p { color: var(--text-muted-on-light); }

/* ---------- Layout ---------- */
.xray__grid { position: relative; }

.xray__stage {
  position: sticky;
  top: var(--header-h);
  z-index: 5;
  padding-block: 0.5rem 0.75rem;
  background: var(--abyss-900);   /* hides steps passing underneath on mobile */
  --dot: 22%;
}
.xray__stage[data-state="1"] { --dot: 24%; }
.xray__stage[data-state="2"] { --dot: 12%; }
.xray__stage[data-state="3"] { --dot: 3%; }
.xray__stage[data-state="4"] { --dot: 94%; }

.xray__frame {
  position: relative;
  width: min(100%, calc(40svh * 1.333));
  margin-inline: auto;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-l);
  border: 1px solid var(--glass-dark-border);
  background:
    linear-gradient(rgb(150 217 240 / 0.05) 1px, transparent 1px) 0 0 / 2.5rem 2.5rem,
    linear-gradient(90deg, rgb(150 217 240 / 0.05) 1px, transparent 1px) 0 0 / 2.5rem 2.5rem,
    linear-gradient(160deg, #07354a, #031b26 70%);
  box-shadow: var(--shadow-float);
}
.xray__svg {
  width: 100%; height: 100%;
  border-radius: inherit;
  cursor: crosshair;
  touch-action: pan-y;      /* vertical swipes still scroll the page */
  -webkit-user-select: none; user-select: none;
}

/* ---------- Steps ---------- */
.xray__steps { position: relative; }
.xray-step {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.85rem;
  min-height: 62svh;
  padding-block: 2rem;
  transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
}
.js .xray-step { opacity: 0.28; transform: translateX(-0.75rem); }
.js .xray-step.is-active { opacity: 1; transform: none; }

.xray-step__num {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 9vw, 7rem);
  line-height: 0.85;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--sand-400);
}
.xray-step h3 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.4rem); line-height: 1.1; }
.xray-step p:not(.xray-step__num) { max-width: 30rem; color: var(--text-muted-on-dark); font-size: var(--step-0); }
.xray-step p.xray-step__lead {
  margin-top: 0.5rem;
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--sand-400);
}
.xray-step .btn { align-self: flex-start; }

.inline-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  align-self: flex-start;
  margin-top: 0.5rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-pill);
  background: var(--sand-400);
  color: var(--abyss-900);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.35s var(--ease-out-expo), background 0.35s;
}
.inline-cta svg { transition: transform 0.35s var(--ease-out-expo); }
.inline-cta:hover { background: var(--sand-100); }
.inline-cta:hover svg { transform: translateX(4px); }
.inline-cta--light { background: var(--teal-700); color: var(--cyan-50); }
.inline-cta--light:hover { background: var(--abyss-800); }

/* ---------- Hotspots ---------- */
.hotspot {
  position: absolute;
  left: var(--x); top: var(--y);
  z-index: 3;
  width: 2.75rem; height: 2.75rem;     /* 44px touch target */
  margin: -1.375rem 0 0 -1.375rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.hotspot::before {
  content: "";
  position: absolute; inset: 0.85rem;
  border-radius: 50%;
  background: var(--sand-400);
  box-shadow: 0 0 0 3px rgb(3 27 38 / 0.7);
  transition: transform 0.3s var(--ease-out-expo);
}
.hotspot::after {
  content: "";
  position: absolute; inset: 0.35rem;
  border-radius: 50%;
  border: 2px solid var(--sand-400);
  animation: hotspot-ping 2.4s var(--ease-out-expo) infinite;
}
.hotspot:hover::before, .hotspot:focus-visible::before, .hotspot[aria-expanded="true"]::before { transform: scale(1.4); }
@keyframes hotspot-ping { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(1.5); opacity: 0; } }

.hotspot-panel {
  position: absolute;
  z-index: 4;
  left: 50%; bottom: 1rem;
  pointer-events: none;
  width: min(92%, 24rem);
  translate: -50% 0;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-m);
  font-size: 0.9rem;
  line-height: 1.45;
}
.hotspot-panel strong { display: block; margin-bottom: 0.25rem; font-family: var(--font-body); font-weight: 700; font-size: 1rem; color: var(--sand-400); letter-spacing: 0.03em; }
.hotspot-panel p { color: var(--text-muted-on-dark); }
.hotspot-panel[hidden] { display: none; }

/* ---------- Legend + caption ---------- */
.xray__legend {
  position: absolute;
  left: 1rem; top: 1rem;
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted-on-dark);
}
.xray__legend-bar {
  position: relative;
  width: clamp(5rem, 14vw, 8rem); height: 6px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--cyan-400), var(--cyan-500) 35%, var(--sand-400) 75%, var(--heat-500));
}
.xray__legend-bar i {
  position: absolute; top: 50%; left: var(--dot);
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgb(3 27 38 / 0.8), 0 0 12px #fff;
  transition: left 1s var(--ease-out-expo);
}
.xray__caption {
  position: absolute;
  left: 0; right: 0; bottom: -2.1rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-muted-on-dark);
}

/* ---------- SVG state machine (driven by data-state on the stage) ---------- */
.xray__svg [data-damp], .xray__svg [data-mould], .xray__svg [data-warp], .xray__svg [data-heat],
.xray__svg [data-air], .xray__svg [data-dry], .xray__svg [data-drops] {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 1s var(--ease-out-expo), transform 1.4s var(--ease-out-expo);
}
.xray__svg [data-damp] { transform: scale(0.6); }

.xray__stage[data-state="1"] [data-damp]  { opacity: 0.55; transform: scale(0.85); }
.xray__stage[data-state="1"] [data-drops] { opacity: 1; }
.xray__stage[data-state="1"] [data-heat]  { opacity: 0.15; }

.xray__stage[data-state="2"] [data-damp]  { opacity: 0.95; transform: scale(1.2); }
.xray__stage[data-state="2"] [data-drops] { opacity: 1; }
.xray__stage[data-state="2"] [data-heat]  { opacity: 0.4; }

.xray__stage[data-state="3"] [data-damp]  { opacity: 1; transform: scale(1.32); }
.xray__stage[data-state="3"] [data-drops] { opacity: 1; }
.xray__stage[data-state="3"] [data-mould] { opacity: 1; }
.xray__stage[data-state="3"] [data-warp]  { opacity: 1; }
.xray__stage[data-state="3"] [data-heat]  { opacity: 0.9; }

.xray__stage[data-state="4"] [data-air]   { opacity: 1; }
.xray__stage[data-state="4"] [data-dry]   { opacity: 0.9; }
.xray__stage[data-state="4"] [data-damp]  { opacity: 0; transform: scale(0.4); }

/* No-JS: show the hidden layer (surface is faded) and the problem state */
.no-js .xray__svg [data-surface-layer] { opacity: 0.2; }
.no-js .xray__stage [data-mould], .no-js .xray__stage [data-warp], .no-js .xray__stage [data-damp] { opacity: 0.9; }

/* ---------- Laptop / desktop: two columns ---------- */
@media (min-width: 64em) {
  .xray__grid {
    display: grid;
    grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
    column-gap: clamp(2rem, 5vw, 6rem);
    align-items: start;
  }
  .xray__stage {
    grid-column: 2; grid-row: 1;
    top: calc(var(--header-h) + 1rem);
    padding-block: 0;
    background: transparent;
  }
  .xray__frame {
    width: min(100%, calc((100svh - var(--header-h) - 7.5rem) * 1.333));
    margin-inline: 0;
  }
  .xray__stage-label { display: block; margin-bottom: 1rem; color: var(--sand-400); }
  /* the in-flow label stays for screen readers, the pinned one is the visible one */
  .xray__how > .eyebrow {
    position: absolute; width: 1px; height: 1px; margin: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .xray__how { position: relative; }
  .xray__steps { grid-column: 1; grid-row: 1; }
  .xray-step { min-height: 78svh; }
}

@media (max-width: 63.99em) {
  .xray__stage { margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); box-shadow: 0 1.25rem 1.5rem -0.5rem var(--abyss-900); }
  .xray__frame { margin-bottom: 2.25rem; }
  .xray-step { min-height: 52svh; padding-block: 1.5rem; }
  .hotspot-panel { bottom: 1rem; font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hotspot::after { animation: none; opacity: 0.5; }
}
