:root {
  --assembly: 0;
  --assembly-e: 0;
  --home-bg: #040705;
  --home-ink: #f4f7f2;
  --home-soft: #b7c2b8;
  --home-muted: #758177;
  --home-line: rgba(213, 239, 215, .13);
  --home-accent: #79f2a8;
  --home-display: "Space Grotesk", "Avenir Next", sans-serif;
  --home-body: Inter, "Segoe UI", system-ui, sans-serif;
}

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

html { background: var(--home-bg); }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--home-bg);
  color: var(--home-ink);
  font-family: var(--home-body);
  -webkit-font-smoothing: antialiased;
}

a, button { -webkit-tap-highlight-color: transparent; }

.home-scene {
  position: fixed;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.home-scrim {
  position: fixed;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 40%, transparent 0 16%, rgba(4,7,5,.12) 48%, rgba(4,7,5,.72) 110%),
    linear-gradient(180deg, transparent 68%, rgba(4,7,5,.74));
}

.home-nav {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 72px;
  padding: 0 clamp(18px, 4vw, 52px);
  pointer-events: none;
}

.home-brand,
.home-nav-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--home-soft);
  font: 700 11px/1 var(--home-body);
  letter-spacing: .18em;
  text-transform: uppercase;
}

.home-brand::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1px solid var(--home-accent);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(121,242,168,.85);
}

.home-nav-status { color: var(--home-muted); }

.home-nav-status::before {
  content: "";
  width: 20px;
  height: 1px;
  background: currentColor;
}

.landing {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 90px 20px 70px;
}

.landing-core {
  width: min(1100px, 100%);
  text-align: center;
  perspective: 1000px;
}

.forest-sigil {
  position: relative;
  width: clamp(82px, 10vw, 132px);
  aspect-ratio: 1;
  margin: 0 auto 24px;
  color: var(--home-accent);
  filter: drop-shadow(0 0 28px rgba(121,242,168,.18));
  animation: sigil-breathe 7s ease-in-out infinite;
}

.forest-sigil svg { width: 100%; height: 100%; overflow: visible; }
.forest-sigil .sigil-ring { fill: none; stroke: currentColor; stroke-width: .65; opacity: .4; }
.forest-sigil .sigil-branch { fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; }
.forest-sigil .sigil-seed { fill: currentColor; transform-origin: center; animation: seed-pulse 2.8s ease-in-out infinite; }

@keyframes sigil-breathe {
  0%, 100% { transform: rotate(-2deg) translateY(2px); opacity: .78; }
  50% { transform: rotate(2deg) translateY(-4px); opacity: 1; }
}

@keyframes seed-pulse {
  0%, 100% { transform: scale(.74); opacity: .6; }
  50% { transform: scale(1.16); opacity: 1; }
}

.landing-kicker {
  margin: 0 0 17px;
  color: var(--home-accent);
  font: 700 11px/1 var(--home-body);
  letter-spacing: .28em;
  text-transform: uppercase;
}

.landing h1 {
  margin: 0;
  font: 700 clamp(64px, 14vw, 180px)/.74 var(--home-display);
  letter-spacing: -.085em;
  text-transform: uppercase;
  text-wrap: balance;
}

.landing h1 span {
  display: block;
  color: transparent;
  -webkit-text-stroke: 1px rgba(244,247,242,.42);
  font-size: .42em;
  line-height: 1.45;
  letter-spacing: .05em;
}

.landing-copy {
  max-width: 580px;
  margin: clamp(28px, 5vh, 54px) auto 0;
  color: var(--home-soft);
  font-size: clamp(16px, 2vw, 21px);
  line-height: 1.58;
  text-wrap: balance;
}

.scroll-invite {
  position: absolute;
  left: 50%;
  bottom: 24px;
  display: grid;
  justify-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--home-muted);
  font: 700 9px/1 var(--home-body);
  letter-spacing: .22em;
  text-transform: uppercase;
  transform: translateX(-50%);
  cursor: pointer;
}

.scroll-invite::after {
  content: "";
  width: 1px;
  height: 38px;
  background: linear-gradient(var(--home-accent), transparent);
  animation: scroll-line 1.8s ease-in-out infinite;
  transform-origin: top;
}

@keyframes scroll-line {
  0%, 100% { transform: scaleY(.35); opacity: .45; }
  55% { transform: scaleY(1); opacity: 1; }
}

.assembly {
  position: relative;
  z-index: 3;
  height: 250svh;
}

.factory {
  position: sticky;
  top: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 72px clamp(12px, 2.5vw, 34px) 26px;
}

.factory::before,
.factory::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.factory::before {
  inset: 9% 4%;
  border: 1px solid rgba(121,242,168, calc(.03 + var(--assembly) * .1));
  clip-path: polygon(0 7%, 5% 7%, 5% 0, 95% 0, 95% 7%, 100% 7%, 100% 93%, 95% 93%, 95% 100%, 5% 100%, 5% 93%, 0 93%);
}

.factory::after {
  width: min(70vw, 920px);
  height: 1px;
  top: 50%;
  left: 50%;
  background: linear-gradient(90deg, transparent, rgba(121,242,168,.3), transparent);
  transform: translate(-50%, -50%) rotate(calc((1 - var(--assembly)) * 8deg));
  opacity: var(--assembly);
}

.factory-frame {
  --frame-gap: clamp(14px, 2vw, 24px);
  width: min(1480px, 100%);
  max-height: calc(100svh - 96px);
  display: grid;
  grid-template-columns: minmax(590px, .98fr) minmax(340px, .72fr);
  gap: var(--frame-gap);
  align-items: stretch;
}

.portal-board,
.preview-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--home-line);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.035), transparent 35%),
    rgba(6, 12, 8, .86);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 40px 100px rgba(0,0,0,.44);
  backdrop-filter: blur(24px);
  opacity: calc(.08 + var(--assembly) * .92);
}

.portal-board {
  padding: clamp(16px, 2vw, 26px);
  transform: translateX(calc((1 - var(--assembly-e)) * -112%)) rotateY(calc((1 - var(--assembly-e)) * 13deg));
  transform-origin: right center;
  will-change: transform, opacity;
}

.preview-stage {
  min-height: 690px;
  transform: translateX(calc((1 - var(--assembly-e)) * 112%)) rotateY(calc((1 - var(--assembly-e)) * -13deg));
  transform-origin: left center;
  will-change: transform, opacity;
}

.portal-board::after,
.preview-stage::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(213,239,215,.065);
  border-radius: 19px;
  pointer-events: none;
}

.board-header {
  position: relative;
  z-index: 2;
  min-height: 56px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.board-kicker,
.preview-index {
  color: var(--home-accent);
  font: 700 9px/1 var(--home-body);
  letter-spacing: .2em;
  text-transform: uppercase;
}

.board-header h2 {
  margin: 7px 0 0;
  font: 650 clamp(20px, 2vw, 27px)/1 var(--home-display);
  letter-spacing: -.035em;
}

.board-readout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--home-muted);
  font: 600 9px/1 var(--home-body);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.board-readout::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--home-accent);
  box-shadow: 0 0 14px rgba(121,242,168,.7);
  animation: live-dot 2.5s ease-in-out infinite;
}

@keyframes live-dot { 50% { opacity: .35; box-shadow: 0 0 3px rgba(121,242,168,.3); } }

.project-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.portal {
  --accent: #79f2a8;
  /* Woven entrance: each card materializes inside the arriving board on its
     own serpentine slot (--cd set inline by row/column). */
  --k: clamp(0, calc((var(--assembly-e, 1) * 1.4 - var(--cd, 0) - .35) / .55), 1);
  position: relative;
  min-width: 0;
  height: clamp(105px, 13vh, 128px);
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid rgba(213,239,215,.1);
  border-radius: 17px;
  background: rgba(255,255,255,.018);
  color: var(--home-ink);
  text-align: left;
  cursor: pointer;
  isolation: isolate;
  opacity: var(--k);
  translate: 0 calc((1 - var(--k)) * 24px);
  transition: border-color .25s ease, background .25s ease, box-shadow .25s ease;
}

/* Pointer-depth: the card tilts toward the cursor, the sigil floats above the
   plane, the copy sinks a step behind it, and the hover light enters from the
   cursor's side of the card. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .portal {
    transform: perspective(760px) rotateX(calc(var(--py, 0) * -6deg)) rotateY(calc(var(--px, 0) * 8deg));
    transition: border-color .25s ease, background .25s ease, box-shadow .25s ease, transform .18s ease-out;
  }
  .portal-icon {
    translate: calc(var(--px, 0) * 7px) calc(var(--py, 0) * 7px);
    transition: translate .22s ease-out, border-color .25s ease, background .25s ease, box-shadow .25s ease;
  }
  .portal-copy {
    translate: calc(var(--px, 0) * -4px) calc(var(--py, 0) * -3px);
    transition: translate .26s ease-out;
  }
  .portal:hover {
    background: linear-gradient(calc(118deg + var(--px, 0) * 44deg), color-mix(in srgb, var(--accent) 11%, transparent), rgba(255,255,255,.02) 62%);
  }
  .portal:hover .portal-icon,
  .portal:focus-visible .portal-icon {
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    box-shadow: 0 8px 22px -8px var(--accent);
  }
}

.portal::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 140px;
  height: 140px;
  left: var(--mx, 50%);
  top: var(--my, 50%);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 27%, transparent), transparent 68%);
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity .25s ease;
}

.portal:hover,
.portal:focus-visible,
.portal[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 54%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, rgba(255,255,255,.02));
  box-shadow: inset 0 0 30px color-mix(in srgb, var(--accent) 6%, transparent), 0 0 28px color-mix(in srgb, var(--accent) 8%, transparent);
}

.portal:hover::before,
.portal:focus-visible::before,
.portal[aria-pressed="true"]::before { opacity: 1; }

.portal:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.portal[aria-disabled="true"] { cursor: default; }

.portal-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 15px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.portal-icon svg {
  width: 38px;
  height: 38px;
  overflow: visible;
  animation: portal-icon-idle 6s ease-in-out infinite;
}
.icon-line,
.icon-ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: center;
}
.icon-fill { fill: currentColor; transform-origin: center; }
.icon-ring { opacity: .42; }

.portal:hover .portal-icon svg,
.portal:focus-visible .portal-icon svg,
.portal[aria-pressed="true"] .portal-icon svg {
  animation: portal-icon-alive 1.15s ease-in-out infinite;
  filter: drop-shadow(0 0 6px currentColor);
}

@keyframes portal-icon-idle {
  0%, 100% { transform: translateY(0) rotate(-.6deg); opacity: .78; }
  50% { transform: translateY(-1.5px) rotate(.8deg); opacity: 1; }
}

@keyframes portal-icon-alive {
  0%, 100% { transform: translateY(1px) rotate(-2deg) scale(.98); }
  45% { transform: translateY(-2px) rotate(2deg) scale(1.07); }
  70% { transform: translateY(0) rotate(-1deg) scale(1.02); }
}

.portal-copy { min-width: 0; align-self: center; }
.portal-name {
  display: block;
  font: 650 clamp(11px, .95vw, 13px)/1.12 var(--home-display);
  letter-spacing: -.015em;
  text-wrap: balance;
}

.portal-meta {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--home-muted);
  font: 650 8px/1.2 var(--home-body);
  letter-spacing: .1em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.portal-meta.experimental { color: #74eff8; }
.portal-meta.development { color: #dbbb74; }

.preview-stage {
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 3vw, 38px);
}

.preview-stage::before {
  content: "";
  position: absolute;
  width: 70%;
  aspect-ratio: 1;
  top: -20%;
  right: -20%;
  border: 1px solid color-mix(in srgb, var(--preview-accent, #79f2a8) 18%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 90px color-mix(in srgb, var(--preview-accent, #79f2a8) 8%, transparent);
  animation: preview-orbit 18s linear infinite;
}

@keyframes preview-orbit { to { transform: rotate(360deg); } }

.preview-head {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-status {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--preview-accent, #79f2a8) 34%, transparent);
  border-radius: 999px;
  color: var(--preview-accent, #79f2a8);
  background: color-mix(in srgb, var(--preview-accent, #79f2a8) 7%, transparent);
  font: 700 9px/1 var(--home-body);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.preview-visual {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 220px;
  display: grid;
  place-items: center;
}

.preview-visual::before,
.preview-visual::after {
  content: "";
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--preview-accent, #79f2a8) 16%, transparent);
  border-radius: 50%;
  animation: preview-orbit 22s linear infinite;
}
.preview-visual::before { width: min(34vh, 280px); aspect-ratio: 1; }
.preview-visual::after { width: min(24vh, 190px); aspect-ratio: 1; animation-direction: reverse; animation-duration: 14s; }

.preview-glyph {
  width: clamp(100px, 14vw, 170px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--preview-accent, #79f2a8);
  filter: drop-shadow(0 0 28px color-mix(in srgb, var(--preview-accent, #79f2a8) 28%, transparent));
  animation: preview-float 5s ease-in-out infinite;
}
.preview-glyph svg { width: 100%; height: 100%; }

@keyframes preview-float { 50% { transform: translateY(-8px) rotate(2deg); } }

.preview-copy { position: relative; z-index: 2; }
.preview-title {
  max-width: 10ch;
  margin: 0;
  font: 700 clamp(38px, 5vw, 72px)/.89 var(--home-display);
  letter-spacing: -.06em;
  text-wrap: balance;
}

.preview-description {
  max-width: 46ch;
  min-height: 4.7em;
  margin: 19px 0 0;
  color: var(--home-soft);
  font-size: clamp(14px, 1.25vw, 17px);
  line-height: 1.55;
}

.preview-actions {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.preview-open {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid color-mix(in srgb, var(--preview-accent, #79f2a8) 50%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--preview-accent, #79f2a8) 11%, transparent);
  color: var(--home-ink);
  font: 700 11px/1 var(--home-body);
  letter-spacing: .12em;
  text-decoration: none;
  text-transform: uppercase;
}

.preview-open::after { content: "↗"; color: var(--preview-accent, #79f2a8); font-size: 16px; }
.preview-open:hover { background: color-mix(in srgb, var(--preview-accent, #79f2a8) 18%, transparent); }
.preview-open[hidden] { display: none; }
.preview-hint { color: var(--home-muted); font-size: 11px; line-height: 1.35; }

.factory-progress {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 2px;
  height: 120px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255,255,255,.07);
  transform: translateY(-50%);
}

.factory-progress span {
  position: relative;
  display: block;
  width: 100%;
  height: calc(var(--assembly) * 100%);
  overflow: hidden;
  background: var(--home-accent);
  box-shadow: 0 0 12px var(--home-accent);
}

.factory-progress span::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.9), transparent);
  animation: rail-shimmer 2.4s ease-in-out infinite;
}

@keyframes rail-shimmer {
  from { transform: translateY(-120%); }
  to { transform: translateY(340%); }
}

.home-footer {
  position: relative;
  z-index: 4;
  min-height: 280px;
  display: grid;
  place-items: center;
  padding: 60px 20px;
  color: var(--home-muted);
  text-align: center;
}

.home-footer p { max-width: 44ch; margin: 0; font-size: 13px; line-height: 1.7; }

/* Bug fix (Windows bottom-cut): on short desktop viewports — 1080p at 125%
   scaling (~722px) or 1366×768 (~625px) — the panels' fixed 690px min-height
   and the 13vh card floor of 105px overflow .factory-frame's
   calc(100svh - 96px) cap, and .factory's overflow:hidden clips the bottom
   row of portals and both panel edges. Compress the vertical rhythm so the
   frame always fits the viewport instead of being cut. */
@media (min-width: 901px) and (max-height: 820px) {
  .factory { padding-top: 64px; }
  .factory-frame { max-height: calc(100svh - 84px); }
  .preview-stage { min-height: min(690px, calc(100svh - 110px)); }
  .preview-visual { min-height: 140px; }
  .preview-title { font-size: clamp(30px, 4.6vh, 52px); }
  .preview-description { min-height: 0; }
  .board-header { min-height: 44px; margin-bottom: 10px; }
  .portal { height: clamp(70px, 11.4vh, 128px); }
}

@media (max-width: 1080px) {
  .factory-frame { grid-template-columns: minmax(500px, 1fr) minmax(300px, .65fr); }
  .portal { grid-template-columns: 46px 1fr; padding: 9px; }
  .portal-icon { width: 46px; height: 46px; }
  .portal-icon svg { width: 34px; height: 34px; }
}

@media (max-width: 900px) {
  .home-nav-status { display: none; }
  .assembly { height: auto; }
  .factory {
    position: relative;
    min-height: 0;
    overflow: visible;
    padding: 84px 12px 30px;
  }
  .factory-frame {
    max-height: none;
    grid-template-columns: 1fr;
  }
  .portal-board,
  .preview-stage {
    opacity: 1;
    transform: none;
    will-change: auto;
  }
  .preview-stage { min-height: 580px; order: -1; }
  .portal { height: 112px; opacity: 1; translate: none; }
  .factory-progress { display: none; }
  /* Bug fix: on touch viewports the entire card is a scroll target — restrict
     the interactive area to the icon only so scrolling over a card does not
     accidentally fire navigation. Events from the icon still bubble to the
     card's click handler, preserving all selection/navigation logic. */
  .portal { pointer-events: none; cursor: default; }
  .portal .portal-icon { pointer-events: auto; cursor: pointer; }
}

@media (max-width: 560px) {
  /* Bug fix: on narrow phones the centered landing-core can overflow its grid
     cell downward and collide with the absolute scroll-invite at bottom:24px
     ("Growing ecosystem / forest notices" overlaps "Assemble the portal").
     Switch to flex-column so the invite follows the core in normal flow and
     the landing grows past 100svh when content demands it. */
  .landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(20px, 3vh, 36px);
    padding-bottom: max(36px, 5vh);
  }
  .landing-core { width: 100%; text-align: center; }
  .scroll-invite {
    position: static;
    left: unset;
    bottom: unset;
    transform: none;
    flex-shrink: 0;
  }
  .landing h1 { font-size: clamp(60px, 22vw, 100px); }
  .landing-copy { font-size: 16px; }
  .preview-stage { min-height: 530px; padding: 24px; }
  .preview-visual { min-height: 190px; }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal { height: 128px; grid-template-columns: 1fr; grid-template-rows: 54px 1fr; text-align: center; justify-items: center; }
  .portal-icon { width: 52px; height: 52px; }
  .portal-copy { width: 100%; }
  .portal-name { font-size: 11px; }
  .portal-meta { font-size: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --assembly: 1; --assembly-e: 1; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .portal-board, .preview-stage { opacity: 1; transform: none; }
  .portal { opacity: 1; translate: none; }
}
