/* Vision — six propositions read against one pinned instrument that
   reconfigures itself as you scroll. Beige throughout.

   Typography uses the site tokens from site.css only:
   - Onest (--_fonts---font-family-primary) for body and titles
   - Apk Praktikal (--_fonts---font-family-secondary) for small uppercase labels

   The motion is driven by CSS custom properties that vision-thesis.js writes
   once per animation frame (--vt-p per proposition, --vt-drift on the
   instrument), so layout stays in CSS and the script only reports position. */

.vision-thesis {
  --vt-ink: #022a22;
  --vt-body: rgba(2, 42, 34, 0.74);
  --vt-quiet: rgba(2, 42, 34, 0.5);
  --vt-rule: rgba(2, 42, 34, 0.16);
  --vt-rule-soft: rgba(2, 42, 34, 0.09);
  --vt-green: #0a8352;
  --vt-label: #d2661c;
  --vt-stroke-1: rgba(2, 42, 34, 0.42);
  --vt-stroke-2: rgba(2, 42, 34, 0.56);
  --vt-node: rgba(2, 42, 34, 0.68);
  --vt-font: var(--_fonts---font-family-primary);
  --vt-caps: var(--_fonts---font-family-secondary);
  position: relative;
  color: var(--vt-ink);
  font-family: var(--vt-font);
}

.vt-scrolly {
  position: relative;
}

/* ------------------------------------------------------------ instrument */

.vt-stage {
  position: sticky;
  top: 0;
  z-index: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  pointer-events: none;
  /* Revealed only once the renderer is up, so a script-less visit gets clean
     whitespace instead of an empty framed box. */
  opacity: 0;
  transition: opacity 0.8s ease;
}

.vision-thesis.is-ready .vt-stage { opacity: 1; }

@supports (height: 100svh) {
  .vt-stage { height: 100svh; }
}

.vt-stage > .padding-global,
.vt-stage > .padding-global > .container-large {
  width: 100%;
}

.vt-instrument {
  position: relative;
  margin: 0 0 0 auto;
  width: min(58%, 48rem);
  transform: translate3d(0, calc(var(--vt-drift, 0) * 1px), 0);
  will-change: transform;
}

.vt-instrument__frame {
  position: relative;
  aspect-ratio: 5 / 4;
  /* Thick green frame anchors the instrument in the cream field without glow. */
  border: 3px solid var(--vt-green);
  box-shadow: inset 0 0 0 1px rgba(2, 42, 34, 0.08);
  background:
    linear-gradient(160deg, rgba(2, 42, 34, 0.04), transparent 58%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(2, 42, 34, 0.035) 27px,
      rgba(2, 42, 34, 0.035) 28px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 27px,
      rgba(2, 42, 34, 0.035) 27px,
      rgba(2, 42, 34, 0.035) 28px
    );
}

/* Engraved register marks at opposite frame corners. */
.vt-instrument__frame::before,
.vt-instrument__frame::after {
  content: "";
  position: absolute;
  z-index: 1;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--vt-green);
  pointer-events: none;
}

.vt-instrument__frame::before { top: 4px; left: 4px; border-width: 1.5px 0 0 1.5px; }
.vt-instrument__frame::after { right: 4px; bottom: 4px; border-width: 0 1.5px 1.5px 0; }

.vt-instrument canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.vt-instrument__caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.8rem;
  font-family: var(--vt-caps);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--vt-green);
}

.vt-instrument__id { opacity: 0.72; }

/* ---------------------------------------------------------- propositions */

.vt-track {
  position: relative;
  z-index: 1;
  /* Runway after VI: long enough that Let’s Talk stays below the fold while
     reading, short enough that it arrives as soon as the bottoms lock and rise.
     vision-thesis.js may override this with a measured value. */
  padding-bottom: var(--vt-exit-runway, clamp(16vh, 20vh, 24vh));
}

/* Wide screens: the visual rides in document space beside the prose so it
   scrolls down continuously (no sticky snap / vanish between points).
   Narrow / mobile keep the in-flow slot + fixed pin — do not change. */
@media (min-width: 861px) {
  .vt-scrolly {
    position: relative;
  }

  .vt-stage-slot {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    height: auto;
    z-index: 0;
    pointer-events: none;
  }

  .vt-track {
    margin-top: 0;
    position: relative;
    z-index: 1;
  }

  /* Full-height stage inside the slot — instrument is absolutely pinned by JS. */
  .vt-stage {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    height: auto;
    display: block;
    padding-top: 0;
    align-items: unset;
  }

  .vt-stage > .padding-global,
  .vt-stage > .padding-global > .container-large {
    height: 100%;
    position: relative;
  }

  .vt-instrument {
    position: absolute;
    top: var(--vt-pin-top, 0px);
    right: 0;
    left: auto;
    margin: 0;
    /* top carries scroll position; keep --vt-drift at 0 on desktop. */
    transform: none;
    will-change: top;
  }

  .vt-prop {
    align-items: center;
    min-height: 78vh;
  }

  @supports (height: 78svh) {
    .vt-prop { min-height: 78svh; }
  }
}

.vt-prop {
  display: flex;
  align-items: center;
  min-height: 72vh;
}

@supports (height: 72svh) {
  .vt-prop { min-height: 72svh; }
}

/* --vt-p tracks a proposition's distance from the middle of the viewport and
   --vt-o its readability, both written per frame by the script. Text rises in,
   holds at centre and leaves upward: the page moves the whole time you read
   it. --vt-o is precomputed rather than derived here with abs(), which is too
   recent to depend on. */
.vt-prop__text {
  width: min(48%, 38rem);
  opacity: var(--vt-o, 1);
  transform: translate3d(0, calc(var(--vt-p, 0) * -44px), 0);
  will-change: opacity, transform;
}

.vt-prop__num {
  margin: 0 0 1.1rem;
  padding-bottom: 0.7rem;
  font-family: var(--vt-caps);
  font-size: 0.95rem;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--vt-green);
  border-bottom: 1px solid var(--vt-rule);
}

.vt-prop__title {
  margin: 0;
  font-family: var(--vt-font);
  font-size: clamp(2rem, 3.6vw, 3.1rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.vt-prop__body {
  margin: 1.35rem 0 0;
  max-width: 36rem;
  font-family: var(--vt-font);
  font-size: clamp(1.08rem, 1.35vw, 1.28rem);
  line-height: 1.62;
  color: var(--vt-body);
}

.vt-prop__note {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin: 1.65rem 0 0;
  padding: 0.95rem 0 0.15rem 0.95rem;
  max-width: 30rem;
  border-top: 1px solid var(--vt-rule);
  border-left: 2px solid var(--vt-label);
}

.vt-prop__note-label {
  flex: none;
  font-family: var(--vt-caps);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--vt-label);
}

.vt-prop__note-text {
  font-family: var(--vt-font);
  font-size: 1.08rem;
  line-height: 1.45;
  color: var(--vt-ink);
}

/* -------------------------------------------------------------- colophon */

.vt-colophon-band {
  position: relative;
  z-index: 1;
  /* Tight top so the CTA appears almost as soon as VI and the instrument rise. */
  padding: clamp(1.75rem, 3.5vw, 3rem) 0 clamp(3.5rem, 7vw, 6.5rem);
}

.vt-colophon {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: center;
  gap: 1.5rem 2.5rem;
  padding-top: clamp(1.25rem, 2.5vw, 2rem);
  border-top: 1px solid var(--vt-rule);
}

.vt-colophon__line {
  margin: 0;
  max-width: 28rem;
  font-family: var(--vt-font);
  font-size: clamp(1.15rem, 1.7vw, 1.55rem);
  line-height: 1.35;
  color: var(--vt-ink);
}

.vt-colophon__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.vt-colophon__actions .button-group {
  justify-content: flex-end;
}

/* Running folio, like a page number in a printed thesis. */
.vt-folio {
  position: fixed;
  z-index: 3;
  left: clamp(1rem, 2vw, 2.25rem);
  bottom: clamp(1rem, 2vw, 2.25rem);
  margin: 0;
  padding: 0.4rem 0.65rem;
  background: rgba(2, 24, 19, 0.88);
  font-family: var(--vt-caps);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  color: rgba(251, 247, 240, 0.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.vision-thesis.is-in-view .vt-folio { opacity: 1; }
/* Hide the folio once Let’s Talk is on screen — otherwise it reads as a
   second bubble sitting on the left of the CTA row. */
.vision-thesis.is-colophon-in-view .vt-folio { opacity: 0; }
.vt-folio [data-vt-folio] { color: #fbf7f0; }

/* Narrow screens: the instrument pins below the fixed navbar (not under the
   OVNI / menu bar), with the prose running beneath it. */
@media (max-width: 860px) {
  .vt-scrolly {
    position: relative;
    z-index: 0;
  }

  .vt-stage-slot {
    position: relative;
    z-index: 2;
  }

  .vt-stage {
    /* --vt-nav-offset is measured from the real navbar height in JS so the
       stage pins flush under the logo bar with no peek gap. */
    top: var(--vt-nav-offset, 4.85rem);
    /* Must wrap the full frame + Form caption — a max-height here was
       truncating the green bottom border and letting titles collide with
       “Form I / …”. Size the instrument instead (below). */
    height: auto;
    max-height: none;
    padding-top: 1.1rem;
    /* Extra pad under the Form caption so prose never shares its row. */
    padding-bottom: 1rem;
    align-items: flex-start;
    background-color: #fbf7f0;
    box-shadow: 0 1.25rem 1rem -0.5rem #fbf7f0;
    z-index: 6;
    overflow: visible;
  }

  /* iOS Safari ignores sticky z-index and paints titles through the frame.
     While the thesis is in the pin band, fix the stage above document flow. */
  .vision-thesis.is-stage-fixed .vt-stage {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    top: var(--vt-nav-offset, 4.85rem);
    z-index: 20;
    margin: 0;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  /* Opaque curtain: fills the stage and tucks under the navbar so letter
     tops cannot peek between the bar and the green frame. */
  .vt-stage::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -3rem;
    bottom: 0;
    background: #fbf7f0;
    z-index: 0;
    pointer-events: none;
  }

  /* Cream lip just under the Form caption — sits below the stage box, never
     over the green frame. */
  .vt-stage::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 1.25rem;
    background: #fbf7f0;
    z-index: 2;
    pointer-events: none;
  }

  .vt-stage > .padding-global {
    position: relative;
    z-index: 1;
  }

  .vt-instrument {
    width: min(100%, 22.5rem);
    max-width: 22.5rem;
    margin: 0 auto;
    /* Keep the frame planted in the cream stage — drift was sliding the
       bottom border out from under the caption band. */
    transform: none !important;
  }

  .vt-instrument__frame {
    /* Cap the drawing so frame + caption always fit under the nav on short
       phones, without clipping the 3px green border. */
    width: 100%;
    max-height: min(34svh, 16.5rem);
    aspect-ratio: 5 / 4;
    max-width: 100%;
    height: auto;
    /* Keep canvas inside the padding box so it cannot cover the border. */
    background-clip: padding-box;
    overflow: hidden;
  }

  @supports (height: 34svh) {
    .vt-instrument__frame {
      /* width follows height via aspect-ratio when max-height binds */
      width: min(100%, calc(min(34svh, 16.5rem) * 5 / 4));
      margin-inline: auto;
    }
  }

  .vt-track {
    position: relative;
    z-index: 0;
    /* JS writes --vt-track-clip so copy cannot paint into the stage band. */
    -webkit-clip-path: inset(var(--vt-track-clip, 0px) 0 0 0);
    clip-path: inset(var(--vt-track-clip, 0px) 0 0 0);
  }

  /* Prose sits in the lower half and scrolls up behind the pinned stage. */
  .vt-prop {
    min-height: 72svh;
    align-items: end;
    padding-bottom: 5svh;
    position: relative;
    z-index: 0;
  }

  .vt-prop__text {
    width: 100%;
    /* will-change + translate was promoting titles above the sticky stage. */
    will-change: auto;
    transform: none !important;
    opacity: 1 !important;
  }

  .vt-colophon { grid-template-columns: minmax(0, 1fr); }
  .vt-folio { display: none; }

  /* Solid top bar: green over the dark hero, cream once the thesis scrolls up.
     Keeps logo + menu clear of the pinned instrument. Above the fixed stage. */
  body.is-vision-page .navbar_component {
    z-index: 40;
    background-color: #022a22;
    color: #fbf7f0;
    transition:
      background-color 0.35s ease,
      color 0.35s ease,
      box-shadow 0.35s ease;
  }

  body.is-vision-page .navbar_component .navbar_logo-link,
  body.is-vision-page .navbar_component .navbar_search-toggle {
    color: #fbf7f0;
  }

  body.is-vision-page.is-vision-nav-light .navbar_component {
    background-color: #fbf7f0;
    color: #022a22;
    box-shadow: 0 1px 0 rgba(2, 42, 34, 0.1);
  }

  body.is-vision-page.is-vision-nav-light .navbar_component .navbar_logo-link,
  body.is-vision-page.is-vision-nav-light .navbar_component .navbar_search-toggle {
    color: #022a22;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vt-prop__text {
    opacity: 1 !important;
    transform: none !important;
  }

  .vt-instrument { transform: none !important; }

  .vt-plate {
    transition: opacity 0.3s ease;
    transform: none !important;
  }

  .vt-plate :is(.p-line, .p-accent, .p-axis, .p-bound, .p-tick, .p-node, .p-mark) {
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
    transition: none !important;
    animation: none !important;
  }

  /* The travelling segment has nowhere to travel, so retire it. */
  .vt-plate .p-pulse { display: none; }
}
