/* Desktop scroll experience (html[data-mode="experience"]): live WebGL canvas, preloader,
   sticky hero and contact stages, section-dove markers. */

.sequence {
  display: none;
}

html[data-mode="experience"] {
  /* The assembled dove: height = min(46vh, 30vw), width = height × 651/586, centred.
     Copy is laid out in the columns this leaves free on either side. */
  --dove-height: min(46vh, 30vw);
  --dove-half: calc(var(--dove-height) * 0.556);
  --free-column: calc(50vw - var(--dove-half) - 2 * var(--gutter));
}

html[data-mode="experience"] .sequence {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

html.is-scroll-locked {
  overflow: hidden;
}

/* Lenis' recommended rules, inlined (no extra stylesheet request). */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-stopped {
  overflow: clip;
}

/* ─── Preloader ─── */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  background: var(--color-bg);
  transition: opacity var(--duration-base) ease, transform var(--duration-base) ease;
}

.preloader.is-leaving {
  opacity: 0;
  transform: translateY(calc(-1 * var(--space-6)));
  pointer-events: none;
}

.preloader__mark {
  width: 11rem;
  aspect-ratio: 651 / 586;
  margin-bottom: var(--space-5);
}

.dove--preloader .dove__facet {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform var(--duration-base) var(--ease-fold), opacity var(--duration-base) ease;
}

.preloader__value {
  min-width: 5ch;
  font-family: var(--font-body);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: lining-nums tabular-nums;
  text-align: center;
  color: var(--color-primary);
}

.preloader__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

/* ─── Section doves: an empty marker beside each heading, where the scene flies six shards ─── */

html[data-mode="experience"] .section-dove {
  position: absolute;
  top: 50%;
  right: calc(100% + 1.25rem);
  width: 4rem;
  height: 3.6rem;
  transform: translateY(-50%);
}

/* ─── Contact: the dove reassembles while the stage rises (from the moment it enters the screen)
   and the copy and form unfold beside it (ScrollFade); it lands as the stage pins, then a short
   hold before the footer pushes the dove up. ─── */

html[data-mode="experience"] .contact {
  height: 170vh;
}

html[data-mode="experience"] .contact__stage {
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Hidden until the stage starts to rise; still focusable (FocusSettler scrolls to the settled
   position, where it is visible). */
html[data-mode="experience"] [data-contact-intro],
html[data-mode="experience"] [data-contact-panel] {
  opacity: 0;
}

html[data-mode="experience"] .contact__intro {
  position: absolute;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: calc(var(--free-column) + 2 * var(--gutter));
}

html[data-mode="experience"] .contact__panel {
  position: absolute;
  top: calc(var(--header-height) + var(--space-4));
  right: 0;
  bottom: var(--space-4);
  display: flex;
  /* Centred, but never pushed up under the header when it runs taller than the room. */
  align-items: safe center;
  width: max(calc(var(--free-column) + 2 * var(--gutter)), 24rem);
}

/* The letter fits the screen: it never scrolls inside itself. */
html[data-mode="experience"] .contact__panel .form {
  width: 100%;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
}

@media (max-height: 760px) {
  html[data-mode="experience"] .contact__panel .form {
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
  }

  html[data-mode="experience"] .contact__panel .form .h3 {
    font-size: var(--text-lg);
  }

  html[data-mode="experience"] .contact__panel .field textarea {
    height: calc(2 * var(--line) + 6px);
  }

  html[data-mode="experience"] .contact__panel .form__send {
    margin-top: 0;
  }
}

@media (max-width: 1023px), (max-aspect-ratio: 13 / 10) {
  html[data-mode="experience"] .contact__intro {
    top: calc(var(--header-height) + 6vh);
    bottom: auto;
    left: var(--gutter);
    display: block;
    width: min(26rem, 44vw);
    padding: var(--space-6);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }
}

/* ─── Middle sections: long, airy rhythm while the shards tumble ─── */

html[data-mode="experience"] .section {
  padding-top: clamp(var(--space-9), 18vh, 14rem);
}

html[data-mode="experience"] .sheet-edge {
  margin-top: clamp(var(--space-9), 18vh, 14rem);
}

html[data-mode="experience"] .section--team {
  padding-bottom: clamp(var(--space-8), 12vh, var(--space-9));
}

html[data-mode="experience"] [data-show-in="static"],
html[data-mode="static"] [data-show-in="experience"] {
  display: none;
}

/* ─── Legibility over the shards ───
   Copy straight on the canvas gets a crisp page-coloured knockout painted under each glyph
   (a cartographic label halo, no blur). Links, buttons and surfaces are excluded. */
@supports (paint-order: stroke fill) {
  html[data-mode="experience"] :is(.hero__stage, .column, .contact__intro, .press__title) {
    paint-order: stroke fill;
    -webkit-text-stroke: 0.22em var(--color-bg);
  }

  html[data-mode="experience"] :is(.sheet, .service-card, .button, .tag, a, .dock, .person) {
    -webkit-text-stroke: 0;
  }
}
