/* Home only: blueprint → 3D board hero and the pinned directions section. Shared parts live in base.css. */

/* ---------- Fixed 3D canvas and markers (driven by home-scene.js) ---------- */

.scene-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1200ms var(--ease-out);
}

.markers {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 500ms ease;
  transition-delay: calc(var(--n, 0) * 120ms);
}

.marker[data-hidden] {
  opacity: 0 !important;
  pointer-events: none;
}

.marker::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--brass);
  transition: transform 300ms var(--ease-out);
}

.marker:hover::before,
.marker:focus-visible::before,
.marker[aria-expanded="true"]::before {
  transform: scale(1.3);
}

.marker-label {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  background: var(--ink);
  color: #eef2f7;
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition:
    opacity 200ms ease,
    transform 300ms var(--ease-out);
  pointer-events: none;
}

.marker-label b {
  display: block;
  font-weight: 500;
}

.marker-label span {
  color: #aebbd0;
}

.marker:hover .marker-label,
.marker:focus-visible .marker-label,
.marker[aria-expanded="true"] .marker-label {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Story: hero + directions ---------- */

/* Static layout (no JS, no WebGL, reduced motion): drawing, hero text, list of directions. */
.story-sticky {
  display: grid;
  justify-items: center;
  padding: 1.5rem var(--pad-x) clamp(4rem, 9vw, 7rem);
  text-align: center;
}

.story-visual {
  position: relative;
  width: 100%;
  min-height: 44svh;
}

.bp-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transition: opacity 1200ms var(--ease-out);
}

.bp-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 0.11; /* user units = board millimetres */
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.bp-board {
  stroke: var(--ink);
  stroke-width: 0.16;
}

.bp-pad {
  stroke: var(--brass-deep);
}

.bp-terminal {
  stroke: var(--blue-soft);
  stroke-width: 0.08;
}

.bp-chip {
  stroke: var(--ink);
}

.loader {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: min(200px, 40%);
  height: 2px;
  overflow: hidden;
  background: var(--rule);
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 400ms ease;
}

.loader span {
  display: block;
  height: 100%;
  background: var(--ink);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
}

.hero-copy,
.steps-head,
.steps-list {
  position: relative;
  z-index: 2; /* above the fixed 3D canvas */
}

.hero-copy {
  display: grid;
  justify-items: center;
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.hero-copy h1 {
  max-width: 18ch;
  font-size: clamp(2.4rem, 5vw, 4.6rem);
}

.hero-copy p {
  max-width: 42ch;
  margin: 0;
  color: var(--ink-muted);
  font-size: 1.1rem;
}

.steps-head {
  margin-top: clamp(4rem, 9vw, 7rem);
  padding-top: clamp(4rem, 9vw, 7rem);
  border-top: 1px solid var(--rule);
  width: 100%;
}

.steps-heading {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.steps-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.8rem;
  margin-top: 1.4rem;
}

.steps-tabs[hidden] {
  display: none;
}

.tab {
  padding: 0.35rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-faint);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    color 500ms var(--ease-out),
    border-color 500ms var(--ease-out);
}

.tab:hover {
  color: var(--ink-muted);
}

.tab[aria-current="true"] {
  border-bottom-color: var(--brass);
  color: var(--ink);
}

.steps-list {
  display: grid;
  gap: 2.4rem;
  width: 100%;
  max-width: 640px;
  margin-top: 2.4rem;
}

.step h3 {
  margin-bottom: 0.6rem;
  font-size: 1.35rem;
}

.step p {
  max-width: 40ch;
  margin: 0 auto 0.9rem;
  color: var(--ink-muted);
}

/* ---------- Pinned scene (3D available) ----------
   One screen: directions head on top, the board in the middle, and the hero copy and
   the step text sharing the bottom slot. --q (0 → 1.5, set by home.js) crossfades them. */

.has-scene .story {
  height: calc(100svh + var(--count, 4) * 80svh);
  /* Start under the sticky header so the pinned screen is exactly one viewport. */
  margin-top: calc(-1 * var(--topbar-h));
}

.has-scene .story-sticky {
  position: sticky;
  top: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100svh;
  padding: calc(var(--topbar-h) + clamp(1rem, 3vh, 2.5rem)) var(--pad-x) clamp(1.5rem, 4vh, 3rem);
}

.has-scene .steps-head {
  grid-row: 1;
  margin: 0;
  padding: 0;
  border: 0;
}

.has-scene .story-visual {
  grid-row: 2;
  min-height: 0;
}

.has-scene .hero-copy,
.has-scene .steps-list {
  grid-row: 3;
  grid-column: 1;
  align-self: end;
  margin: 0;
}

.has-scene .steps-list {
  min-height: 6.5rem;
}

/* Hero copy leaves (fade, lift, slight blur); the directions head arrives. */
.has-scene .hero-copy {
  opacity: clamp(0, 1 - var(--q, 0) * 2.6, 1);
  filter: blur(calc(clamp(0, var(--q, 0) * 2.6, 1) * 8px));
  transform: translate3d(0, calc(clamp(0, var(--q, 0) * 2.6, 1) * -24px), 0);
}

.has-scene .steps-head {
  opacity: clamp(0, var(--q, 0) * 2.6 - 1.2, 1);
  transform: translate3d(0, calc((1 - clamp(0, var(--q, 0) * 2.6 - 1.2, 1)) * 16px), 0);
}

.has-scene .story:not(.is-past-hero) .steps-head {
  pointer-events: none;
}

.has-scene .story.is-past-hero .hero-copy {
  pointer-events: none;
}

.has-scene .step h3 {
  display: none;
}

.has-scene .step {
  position: absolute;
  inset: auto 0 0;
  opacity: 0;
  filter: blur(6px);
  transform: translate3d(0, 20px, 0);
  visibility: hidden;
  transition:
    opacity 700ms var(--ease-out),
    filter 700ms var(--ease-out),
    transform 900ms var(--ease-out),
    visibility 0s linear 700ms;
}

.has-scene .step.is-active {
  opacity: 1;
  filter: none;
  transform: none;
  visibility: visible;
  transition-delay: 120ms;
}

/* Sections after the pinned story cover the fixed canvas. */
.home-block {
  position: relative;
  z-index: 2;
  background: var(--bg);
}

/* ---------- Intro phases (set on <html> by home-scene.js) ---------- */

/* Scroll is held at the top during the intro (home.js); the gutter avoids a layout jump on release. */
html {
  scrollbar-gutter: stable;
}

html.intro-lock,
html.intro-lock body {
  overflow: hidden;
}

html[data-phase="draw"] .loader,
html[data-phase="reveal"] .loader {
  opacity: 1;
}

html[data-phase="draw"] .bp-line {
  animation: bp-draw 1300ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 200ms);
}

html[data-phase="reveal"] .scene-canvas,
html[data-phase="ready"] .scene-canvas {
  opacity: 1;
}

html[data-phase="reveal"] .bp-svg,
html[data-phase="ready"] .bp-svg {
  opacity: 0;
}

/* Repeat visit ("intro-seen" is set before the first paint): the drawing never shows,
   the board appears as soon as the model is ready. Safety net: if the page script never
   runs (it would set "has-scene" or drop "intro-seen"), the drawing fades in after 3 s
   instead of leaving an empty stage. */
html.intro-seen .bp-svg {
  opacity: 0;
  transition: none;
  animation: bp-fallback 600ms var(--ease-out) 3s forwards;
}

html.intro-seen.has-scene .bp-svg {
  animation: none;
}

@keyframes bp-fallback {
  to {
    opacity: 1;
  }
}

html.intro-seen .scene-canvas {
  transition-duration: 300ms;
}

html[data-phase="ready"] .marker {
  opacity: 1;
}

/* Hero copy rises in after the board settles, line by line. */
html[data-phase="draw"] .hero-copy > *,
html[data-phase="reveal"] .hero-copy > *,
html[data-phase="draw"] .steps-head,
html[data-phase="reveal"] .steps-head {
  opacity: 0;
  transform: translate3d(0, 30px, 0);
}

.hero-copy > * {
  transition:
    opacity 1100ms var(--ease-out),
    transform 1300ms var(--ease-out);
}

.hero-copy > *:nth-child(2) {
  transition-delay: 150ms;
}

.hero-copy > *:nth-child(3) {
  transition-delay: 300ms;
}

@keyframes bp-draw {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .tab {
    font-size: 0.98rem;
  }

  .steps-tabs {
    gap: 0.2rem 1.1rem;
    margin-top: 1rem;
  }

  .has-scene .steps-heading {
    font-size: 1.7rem;
  }
}
