:root {
  --forest: #1f3a22;
  --agri: #4f7a3a;
  --soil: #6b4a2e;
  --cream: #f3ecdd;
  --cream-2: #efe6d3;
  --sky: #a9bfcf;
  --water: #3b7fa3;
  --terracotta: #b5573b;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--sky); color: var(--cream); font-family: var(--body); }
body { -webkit-font-smoothing: antialiased; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#scroll { height: 1100vh; }   /* scroll length = story length */

/* loader */
#loader {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; gap: 18px;
  background: var(--cream-2); color: var(--forest); transition: opacity .8s ease, visibility .8s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-mark { font-family: var(--display); font-weight: 800; font-stretch: 80%; font-size: 40px; letter-spacing: .02em; text-align: center; }
.loader-bar { width: 220px; height: 2px; background: rgba(31,58,34,.15); }
.loader-bar span { display: block; height: 100%; width: 0; background: var(--forest); transition: width .2s; }
.loader-note { font-size: 13px; text-align: center; opacity: .7; }

/* brand + rail */
.brand {
  position: fixed; top: 28px; left: 36px; z-index: 5; display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 800; font-stretch: 80%; font-size: 22px; letter-spacing: .03em;
  color: var(--cream); transition: color .6s;
}
.brand .mark { width: 28px; height: 28px; }
body.on-light .brand { color: var(--forest); }

.rail { position: fixed; right: 30px; top: 50%; transform: translateY(-50%); z-index: 5; display: grid; gap: 14px; }
.rail button {
  all: unset; cursor: pointer; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  font-size: 12px; font-variant-numeric: tabular-nums; color: currentColor; opacity: .55; transition: opacity .3s;
}
.rail button .t { opacity: 0; transform: translateX(6px); transition: opacity .3s, transform .3s; white-space: nowrap; }
.rail button .d { width: 18px; height: 2px; background: currentColor; transition: width .3s; }
.rail button.active { opacity: 1; }
.rail button.active .t, .rail button:hover .t { opacity: 1; transform: none; }
.rail button.active .d { width: 34px; }
.rail { color: var(--cream); transition: color .6s; }
body.on-light .rail { color: var(--forest); }

/* beats */
#overlay { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.beat { position: absolute; opacity: 0; visibility: hidden; will-change: opacity, transform; }
.num { display: block; font-size: 12px; font-variant-numeric: tabular-nums; opacity: .7; margin-bottom: 10px; }

.hero { left: 36px; bottom: 9vh; max-width: min(760px, 86vw); }
.hero::before {
  content: ""; position: absolute; inset: -30vh -40vw -12vh -10vw; z-index: -1;
  background: radial-gradient(ellipse at 20% 85%, rgba(15,25,12,.55), rgba(15,25,12,0) 60%);
}
.hero h1 {
  margin: 0 0 18px; font-family: var(--display); font-weight: 800; font-stretch: 78%;
  font-size: clamp(42px, 6.6vw, 104px); line-height: .92; text-transform: uppercase; letter-spacing: -.005em;
}
.hero p { margin: 0; font-size: clamp(16px, 1.35vw, 20px); line-height: 1.45; max-width: 520px; opacity: .92; }
.hint { margin-top: 34px; display: flex; align-items: center; gap: 12px; font-size: 13px; opacity: .8; }
.hint-line { width: 40px; height: 1px; background: currentColor; transform-origin: left; animation: hint 2.4s ease-in-out infinite; }
@keyframes hint { 0%, 100% { transform: scaleX(.3); } 50% { transform: scaleX(1); } }

.caption { left: 36px; bottom: 10vh; max-width: 420px; }
.caption.right { left: auto; right: 110px; bottom: auto; top: 16vh; }
.caption::before {
  content: ""; position: absolute; inset: -60px -80px; z-index: -1;
  background: radial-gradient(ellipse, rgba(15,25,12,.45), rgba(15,25,12,0) 70%);
}
.caption h3 { margin: 0 0 10px; font-family: var(--display); font-weight: 700; font-stretch: 85%; font-size: 30px; line-height: 1.05; }
.caption p { margin: 0; font-size: 18px; line-height: 1.5; }

.card {
  left: 36px; bottom: 8vh; width: min(500px, 88vw); padding: 26px 28px 28px;
  background: rgba(243,236,221,.94); color: var(--forest); border-radius: 4px;
  box-shadow: 0 18px 50px rgba(31,40,20,.18);
}
.card h2 {
  margin: 0 0 14px; font-family: var(--display); font-weight: 800; font-stretch: 78%;
  font-size: clamp(30px, 3.4vw, 48px); line-height: .98; text-transform: uppercase;
}
.card h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 700; font-stretch: 85%; font-size: 28px; }
.card p { margin: 0; font-size: 16px; line-height: 1.5; color: #34452f; }

.card.side { left: auto; right: 190px; bottom: auto; top: 14vh; width: min(400px, 88vw); }
.gis { left: auto; right: 190px; bottom: auto; top: 50%; transform: translateY(-50%); width: min(400px, 88vw); }
.layers { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 9px; font-size: 14px; }
.layers li { display: flex; align-items: center; gap: 8px; opacity: .3; transition: opacity .4s; }
.layers li.on { opacity: 1; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 2px; flex: none; }
.sw.lidar { background: repeating-linear-gradient(90deg, #c9bf86 0 2px, transparent 2px 4px), #efe6d3; outline: 1px solid #c9bf86; }
.sw.dem { background: linear-gradient(90deg, #2f5f73, #8fa86a, #c9bf86, #b98d5f); }
.sw.net { background: var(--water); height: 4px; }
.sw.zone { background: rgba(79,143,179,.5); outline: 1px solid #4f8fb3; }
.sw.safe { background: #5f8f4e; border-radius: 50%; }
.sw.reject { background: var(--terracotta); border-radius: 50%; margin-left: 10px; }

.states { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.state { padding: 12px; border: 1px solid rgba(31,58,34,.2); border-radius: 3px; transition: background .4s, color .4s, border-color .4s; }
.state b { display: block; font-family: var(--display); font-stretch: 85%; font-size: 18px; margin-bottom: 4px; }
.state span { font-size: 12.5px; line-height: 1.35; display: block; }
.state.active { background: var(--forest); color: var(--cream); border-color: var(--forest); }
.state[data-state="OTWORZ"].active { background: var(--water); border-color: var(--water); }

.final { left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; width: min(960px, 92vw); }
.final::before {
  content: ""; position: absolute; inset: -20vh -20vw; z-index: -1;
  background: radial-gradient(ellipse, rgba(15,25,12,.5), rgba(15,25,12,0) 62%);
}
.final h2 {
  margin: 0; font-family: var(--display); font-weight: 800; font-stretch: 78%;
  font-size: clamp(44px, 7vw, 112px); line-height: .92; text-transform: uppercase;
}
.final-brand {
  margin: 26px 0 30px; display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 800; font-stretch: 80%; font-size: 26px; letter-spacing: .03em;
}
.final-brand .mark { width: 32px; height: 32px; }
.cta {
  display: table; margin: 0 auto; padding: 16px 30px; border-radius: 2px;
  background: var(--cream); color: var(--forest); text-decoration: none;
  font-weight: 600; font-size: 15px; transition: background .25s, transform .25s;
}
.cta:hover { background: #fff; transform: translateY(-1px); }
.beat.live { pointer-events: auto; }

#debug {
  position: fixed; left: 12px; bottom: 10px; z-index: 30; font: 12px/1.4 ui-monospace, Consolas, monospace;
  background: rgba(0,0,0,.6); color: #fff; padding: 6px 9px; border-radius: 3px;
}

@media (max-width: 760px) {
  .brand { top: 18px; left: 20px; }
  .rail { display: none; }
  .hero, .caption, .card { left: 20px; right: 20px; width: auto; }
  .card.side, .gis { right: 20px; left: 20px; top: auto; bottom: 6vh; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .hint-line { animation: none; } }
