/* ==========================================================================
   THE DISSOLVING CANVAS  (?bridge=organic; ?bridge=hard keeps the original edge, and is the default)
   The meeting of the Approach watercolor (.ap-canvas) and the Services scene (.svp) on the homepage.

   Two decorative pieces, nothing else changes:
   1 · .bridge  a near-black organic form at the foot of the watercolor canvas. It sits in the
       canvas's own stacking context at z -1: above the artwork (the canvas background), below all
       of the Approach content, exactly as the approved ivory veil does. The artwork itself is not
       touched; only the strip below the development forms is covered. One SVG per layout (wide
       ≥1180, tablet 700–1179, phone <700), each drawn for that layout's free space and kept at its
       own proportions (height follows width). The fill is the page's own --dark-bg, so the form
       is the same black as Services. A small blur in the SVG feathers only its edge.
   2 · .svp::before  where the form meets Services, the Living Tide is held back by a near-black
       layer that thins along a curve echoing the form, so the contours come up gradually instead
       of starting on a straight line. Above the video (z 1, first in the section's paint order),
       below every piece of Services content (also z 1, later). Wide screens only, as the video is.
       The video, its sticky layer, its clip and its strength are not touched.
   ========================================================================== */

.bridge { display: none; }

html[data-bridge="organic"] {

  & .ap-canvas { position: relative; isolation: isolate; }   /* already so with the watercolor; kept explicit */

  & .bridge {
    display: block;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: -1;
    pointer-events: none;
    color: var(--dark-bg);
  }
  & .bridge__edge { display: none; width: 100%; overflow: hidden; }
  & .bridge__edge path { fill: currentColor; }
}

/* phone: one shallow curve, rising to the right */
@media (max-width: 699.98px) {
  html[data-bridge="organic"] .bridge__edge--phone { display: block; height: min(15vw, 64px); }
}
/* tablet: low under the last form (left), a single sweep up through the open wash on the right */
@media (min-width: 700px) and (max-width: 1179.98px) {
  html[data-bridge="organic"] .bridge__edge--tablet { display: block; height: 15vw; }
}
/* wide: high on the left, low under Group Development, then one gentle rise to the right edge (refined 2026-11-23 for
   the Thresholds: the last small dip at the far right was removed, so the edge is two broad curves) */
@media (min-width: 1180px) {
  html[data-bridge="organic"] .bridge__edge--wide { display: block; height: 12.5vw; }
}

/* ---------- the Living Tide comes up through the dark (only where the video plays) -------- */
@media (min-width: 900px) {
  html[data-bridge="organic"]:is([data-services="tide"], [data-services="tide-dark"]) .svp::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: min(7.5vw, 9.5rem);                 /* ends just above the Services eyebrow at every width */
    z-index: 1;
    pointer-events: none;
    background: var(--dark-bg);
    -webkit-mask: var(--bridge-veil) 0 0 / 100% 100% no-repeat;
            mask: var(--bridge-veil) 0 0 / 100% 100% no-repeat;
  }
  /* tablet: the form rose on the right, so the contours come up a little earlier there */
  html[data-bridge="organic"] {
    --bridge-veil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 100' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='white'/%3E%3Cstop offset='.5' stop-color='white'/%3E%3Cstop offset='1' stop-color='white' stop-opacity='.35'/%3E%3C/linearGradient%3E%3Cfilter id='b' x='-5%25' y='-50%25' width='110%25' height='200%25'%3E%3CfeGaussianBlur stdDeviation='8'/%3E%3C/filter%3E%3C/defs%3E%3Cpath fill='url(%23g)' filter='url(%23b)' d='M-60 -40 L-60 86 C250 90 500 84 680 68 C820 55 900 36 1060 30 L1060 -40 Z'/%3E%3C/svg%3E");
  }
}
/* wide: the form rose highest on the left and lowest in the middle; the contours follow */
@media (min-width: 1180px) {
  html[data-bridge="organic"] {
    --bridge-veil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 100' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='white'/%3E%3Cstop offset='.5' stop-color='white'/%3E%3Cstop offset='1' stop-color='white' stop-opacity='.35'/%3E%3C/linearGradient%3E%3Cfilter id='b' x='-5%25' y='-50%25' width='110%25' height='200%25'%3E%3CfeGaussianBlur stdDeviation='9'/%3E%3C/filter%3E%3C/defs%3E%3Cpath fill='url(%23g)' filter='url(%23b)' d='M-60 -40 L-60 34 C200 30 420 80 760 88 C1010 95 1260 66 1660 57 L1660 -40 Z'/%3E%3C/svg%3E");
  }
}

/* ---------- motion: the form advances with the scroll (no script, no loop) ---------------------
   As the edge comes up the screen the form grows from 72 % to its full height, held at the
   bottom (so no gap can open above Services): the boundary moves up through the free space and
   its curves deepen a little. Tied to the scroll position, so it reverses with it and never runs
   on its own. Reduced motion, or a browser without scroll-driven animation: the static form. */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    html[data-bridge="organic"] .bridge {
      transform-origin: 50% 100%;
      animation: bridge-advance linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 50%;
    }
  }
}
@keyframes bridge-advance {
  from { transform: scaleY(0.72); }
  to   { transform: scaleY(1); }
}
