/* ==========================================================================
   SERVICES · THE GENTLE CURRENT  (studies 1 · ivory, 2 · orange, 3 · still)
              and THE LIVING TIDE (tide: the same panels over the Runway contour video)
   --------------------------------------------------------------------------
   Built on Version A (warm-ivory panels); the scroll system is unchanged.
   Only these three modes are touched here; A, B and the classic list keep
   their own styles exactly.

   · a few slow contour lines in the dark space behind the panels (1, 2)
   · panel interiors: a stronger heading, the heading rising through a mask,
     a faint enlarged contour of the service's own symbol in the empty corner
   · motion: scripts/services-panels.js (one controller)
   ========================================================================== */

.svp-current, .svp-motif, .svp-tide, .svp-tide-ctl { display: none; }

html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) {

  /* ---------- the current: sticky to the viewport while the section is on screen -------- */
  & .svp { position: relative; }
  /* lift the content above the background layers. The two background layers (the code-drawn
     current and the Living Tide video) and the pinned pause control must be excluded: this rule
     is more specific than their own 'position: sticky' and would otherwise turn them 'relative',
     so the background scrolled away with the intro and the control never pinned. */
  & .svp > :not(.svp-current):not(.svp-tide):not(.svp-tide-ctl) { position: relative; z-index: 1; }

  /* ---------- heading: a little larger, and a mask it can rise through ------------------- */
  & .svp-panel__lead { container-type: inline-size; }
  & .svp-panel__title {
    /* larger, but never wider than its column ('Facilitation' is the longest word) */
    font-size: min(clamp(3.4rem, 1.1rem + 6.6vw, 9.25rem), 21.2cqi);   /* "Facilitation" is 4.48 em wide */
    /* the mask: clipped at the bottom edge only (room left for descenders) */
    padding-bottom: 0.14em;
    margin-bottom: -0.14em;
    clip-path: inset(-0.3em -0.2em 0 -0.2em);
  }
  & .svp-title-in { display: inline-block; }

  /* supporting copy sits a touch more deliberately: the audience line a step larger */
  & .svp-panel__who { font-size: clamp(1.5rem, 1.1rem + 1.15vw, 2.375rem); }
}

/* ---------- the lines (studies 1 and 2), wide screens only -------------------------------- */
@media (min-width: 900px) {
  html:is([data-services="ivory"], [data-services="orange"]) .svp-current {
    display: block;
    position: sticky;
    top: 0;
    width: 100%;
    height: 100svh;
    margin-bottom: -100svh;          /* takes no room: the content scrolls over it */
    pointer-events: none;
    z-index: 0;
    overflow: visible;
  }
  html:is([data-services="ivory"], [data-services="orange"]) .svp-current path {
    fill: none;
    stroke-width: 1.25px;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }
  html[data-services="ivory"]  .svp-current path { stroke: #F4E9DD; stroke-opacity: 0.13; }
  html[data-services="orange"] .svp-current path { stroke: #FD6722; stroke-opacity: 0.26; }
}

/* ---------- the faint enlarged contour of the symbol, in each panel's empty corner -------- */
@media (min-width: 900px) {
  /* a little more of the panel for the name, so the heading can grow */
  html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) .svp-panel__sheet { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) .svp-motif {
    display: block;
    position: absolute;
    top: 0; right: 0;
    width: clamp(12rem, 6rem + 9vw, 20rem);
    height: auto; aspect-ratio: 1;
    transform: translate(20%, -44%);         /* cropped by the panel's top corner: only its lower part shows */
    margin: 0;
    grid-area: auto;
    color: var(--svp-ink);
    opacity: 0.075;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4px;
    pointer-events: none;
    z-index: 0;
  }
  html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) .svp-motif circle { vector-effect: non-scaling-stroke; }
  html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) .svp-motif .glyph__o { fill: none; stroke: currentColor; }
  /* mirrored panels: the corner on the other side */
  html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) .svp-panel:nth-child(even) .svp-motif { right: auto; left: 0; transform: translate(-20%, -44%); }
  /* the panel's own content stays above it */
  html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) .svp-panel__lead,
  html:is([data-services="ivory"], [data-services="orange"], [data-services="still"], [data-services="tide"], [data-services="tide-dark"]) .svp-panel__body { position: relative; z-index: 1; }
}

/* ==========================================================================
   THE LIVING TIDE  (?services=tide; strength ?tide=15 | 25 | 35, default 25)
   One looping contour video behind the whole section, wide screens only.
   Sticky (like the current) so it stays in the viewport while the section is
   on screen and never leaks past it. Composited with 'screen': the video's own
   black adds nothing, so no rectangle can show against the page's near-black;
   only its ivory lines lighten the canvas, at the chosen strength. The file
   itself is untouched; the strength is a property of the page.
   ========================================================================== */
@media (min-width: 900px) {
  /* the scene's edge is the video's edge. A sticky box is held inside its section by its margin
     box, and this layer's margin box is 0 tall (height 100svh, margin -100svh), so near the end of
     the section its painted box would hang up to one screen past it, over the footer. 'clip'
     (not 'hidden') trims that without making .svp a scroll container, so sticky still works. */
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp { overflow: clip; }
  /* …and the field fades into the page over the last few rem rather than ending on a hard line:
     above the video (later in the tree, same z), below the content (z 1) */
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 7rem;
    background: linear-gradient(to bottom, rgb(from var(--dark-bg) r g b / 0), var(--dark-bg));
    pointer-events: none; z-index: 0;
  }
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide {
    display: block;
    position: sticky;
    top: 0;
    height: 100svh;
    margin-bottom: -100svh;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
  }
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide__video {
    display: block;
    width: 100%; height: 100%;
    object-fit: cover;                       /* fills the viewport at any aspect; never stretched */
    opacity: 0;                              /* shown once the first frame is ready: no flash */
    mix-blend-mode: screen;
    transition: opacity 900ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide.is-ready .svp-tide__video { opacity: var(--tide-o, 0.25); }
  html[data-tide="15"] { --tide-o: 0.15; }
  html[data-tide="25"] { --tide-o: 0.25; }
  html[data-tide="35"] { --tide-o: 0.35; }

  /* the pause control: the site's own motion toggle, pinned to the lower right while the section is on screen */
  /* A zero-height line after the panel stack; the button hangs 1.25rem BELOW it. While panels
     scroll the line is pinned (sticky) so the button rests 1.25rem above the viewport's bottom
     edge; at the end of the scene the line stops at the last panel's bottom, so the button lands
     in the dark band under Education instead of on the card. */
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide-ctl {
    display: flex; justify-content: flex-end;
    position: sticky; bottom: calc(2.25rem + 2.5rem);   /* button height + its 1.25rem gaps */
    height: 0; overflow: visible;
    z-index: 3;
    width: min(100% - 2 * var(--gutter), 90rem);
    margin: 0 auto;
  }
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide__toggle { position: relative; right: auto; bottom: auto; top: 1.25rem; transform: none; }
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide__toggle:active { transform: scale(0.94); }
  /* hidden means hidden: the site's .motion-toggle sets its own display, which beats [hidden].
     The control is withdrawn under reduced motion and when the video cannot play. */
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide__toggle[hidden] { display: none; }
  html:is([data-services="tide"], [data-services="tide-dark"]) .svp-tide__toggle:focus-visible { outline: 2px solid var(--dark-focus); outline-offset: 3px; }
}

/* ==========================================================================
   THE LIVING TIDE · DARK  (?services=tide-dark)
   The same scene, video and choreography as ?services=tide; only the panel
   surface changes: charcoal editorial sheets that belong to the near-black
   environment. Everything is expressed through the panel tokens the layout
   already reads (services-panels.css), so no layout rule is touched.

   · sheet a step above the page (#1D1A20 on #110E13) and fully opaque: the
     contours never cross the reading surface; the panel reads as the one calm
     area in a moving field, with a 1px warm-grey edge to hold its boundary
   · the site's own ivory (#F4E9DD) and orange (#FD6722), not new values
   · symbols take the ink colour (ivory strokes) and keep the orange accent
   Contrast on the sheet: ink 14.4:1 · soft 9.6:1 · labels 6.1:1 · orange 5.9:1
   ========================================================================== */
html[data-services="tide-dark"] .svp {
  --svp-sheet: #1D1A20;
  --svp-ink:   #F4E9DD;
  --svp-soft:  #C8C0BD;
  --svp-faint: #A39893;
  --svp-rule:  rgb(244 233 221 / 0.13);
  --svp-edge:  rgb(69 64 71 / 0.72);          /* #454047, restrained */
}
@media (min-width: 900px) {
  /* the corner echo of the symbol: ivory on charcoal reads stronger than ink on ivory */
  html[data-services="tide-dark"] .svp-motif { opacity: 0.055; }
}
