/* ===========================================================================
   CE-51 · Finał realizacji z wezwaniem (case study finale with a call)
   Root:     section.ce-case-finale – the close of a case study before the
             other works (CE-37): a film as high as the window in a frame
             with side margins, then a dark veil with a call to write and
             the UI button, and the frame opening to the full width.
   v2 (27.10.2026, Figma „uklad 5” 3186:681): a film instead of the
             picture (the slider of frames „funk-finale”, after rico Slider
             1-01), the frame with side margins as the media of CE-32
             (--cf-gut = --m-gut, 24 px at ≥ 1512) and, with the veil, the
             margins going to 0 – the frame widens to the whole window with
             the same curve and time as the veil's opacity (left / right
             transitions, no horizontal scroll); back up, the other way
             round; .is-snap – at once.
   K-02 (27.10.2026): the section stays transparent (the page in the
             frame's margins), but on a phone with the bars hidden the
             window (lvh) is taller than the stage (svh) – the band under
             the stuck stage gets an apron (__stage::after, lvh − svh high,
             the veil's colour, with the veil); the section clips it, so it
             never hangs over the next section.
   Parts:    __stage (sticky, one window high), __box (the frame, clips;
             side margins --cf-gut until .is-shown), __img __video (the
             film, object-fit: cover; data-src loaded by the script, the
             poster without it), __veil (#1D1D1E at 90%
             with a backdrop blur and the grain of CE-08), __in (the call
             and the button, centred), __say (H2; the script splits it into
             the kit's lines .lf-rl / .lf-rl__in and letters .lf-ch),
             __btn (the kit's UI button .lf-btn .lf-btn--ui, light on the
             veil, data-drawer – opens the contact drawer of chrome.js)
   States:   .is-shown (the veil is up), .is-said (the call and the button
             are in / coming in; without it the way out runs), .is-snap
             (a state set without transitions), __say.is-lines (split)
   Mechanics: ce/CE-51-case-finale.js – built on the mechanics of CE-08
             „inline statement” (Usługi), with a picture instead of a film
             (v2: a film again, played in view, without the ring of CE-08)
             and a button under the text (23.10.2026, Figma crear-2025-web-
             design „uklad 5” 3078:25863, node 3078:25992): the section is
             1 + HOLD windows high; its stage comes up like any section,
             sticks at the top for HOLD of a window and scrolls away. The
             clean picture first; SAY_AT of a window after the stage has
             stuck the veil fades in (#1D1D1E 90%, blur 8 px) and the frame
             widens to the full width (v2), the call
             comes in letter by letter as the section headings do (lines
             rising out of their masks, letters lighting from white at 5%
             through --ui-brand into white), then the button grows in as
             the kit's [data-pop] (lf-pop-grow / lf-pop-content). Scrolled
             back up, all of it goes the other way round; coming back from
             below it is simply there. Then the dark picture with the call
             scrolls away with the page.
             Reduced motion, or no script: the poster with the veil at the
             full width, the call and the button at once, a plain block in
             the flow, nothing moves or plays.
   Layout:   the stage fills the window (100svh, the whole width – as the
             statement of CE-08); the frame inside it 100svh high, inset by
             --cf-gut at the sides until the veil comes; the call TT Hoves Pro Expanded 400,
             clamp(24px, 2.778vw, 56px) (42 px at 1512), white, centred,
             at most 75% of the width; 40 px to the button. 162 px above
             the section (Figma: 162 from the quote), no gap below (CE-37
             holds its own).
   Base:     realizacje/funk/#napisz-do-nas · registry: CE-51
   =========================================================================== */

@property --cf-lit {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

.ce-case-finale {
  --cf-ease: cubic-bezier(.65, 0, .35, 1);   /* easeInOutCubic – the way out */
  --cf-gut: clamp(12px, 1.587vw, 24px);  /* the frame's side margins – as --m-gut of CE-32 */
  position: relative;
  height: 190vh;                         /* 1 + HOLD windows – the script sets it to the pixel */
  height: 190svh;
  margin-top: clamp(72px, 10.714vw, 162px);
  padding: 0;                            /* a <section> – not the kit's section rhythm */
  background: transparent;               /* v2: the page shows in the frame's margins */
  overflow: clip;                        /* K-02: clips the apron at the section's end; clip (not hidden) keeps the sticky stage */
}

.ce-case-finale__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
}

/* K-02: the apron – the band of a window taller than the stage (lvh − svh,
   phone bars hidden; 0 elsewhere) under the stuck stage: the page's own
   colour (as the margins) while the frame is clean, the veil's colour at
   the full width with the veil, the same curve and time */
.ce-case-finale__stage::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 0;
  height: calc(100lvh - 100svh);
  background: rgba(29, 29, 30, .9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--cf-ease) var(--veil-out-at, 0ms);
}
.ce-case-finale.is-shown .ce-case-finale__stage::after {
  opacity: 1;
  transition: opacity .35s var(--ease-out-quart);
}

.ce-case-finale__box {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--cf-gut);
  right: var(--cf-gut);
  overflow: hidden;
  background: #1d1d1e;
  /* out: with the veil (the same curve, time and delay) */
  transition: left .3s var(--cf-ease) var(--veil-out-at, 0ms), right .3s var(--cf-ease) var(--veil-out-at, 0ms);
}
.ce-case-finale.is-shown .ce-case-finale__box {
  left: 0;
  right: 0;
  transition: left .35s var(--ease-out-quart), right .35s var(--ease-out-quart);
}

.ce-case-finale__img {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
}

/* the veil: #1D1D1E at 90% with a blur of the picture under it (Figma:
   the overlay of 3078:25992), and the fine grain of CE-08 */
.ce-case-finale__veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  background: rgba(29, 29, 30, .9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  /* out: last, after the letters */
  transition: opacity .3s var(--cf-ease) var(--veil-out-at, 0ms);
}
.ce-case-finale__veil::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .1;
  mix-blend-mode: soft-light;
  pointer-events: none;
}
.ce-case-finale.is-shown .ce-case-finale__veil {
  opacity: 1;
  transition: opacity .35s var(--ease-out-quart);
}

.ce-case-finale__in {
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(28px, 2.646vw, 40px);
  width: min(75%, 100% - 2 * var(--gut));
  text-align: center;
}

.ce-case-finale__say {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 2.7778vw, 3.5rem);   /* 42 px at 1512 */
  font-weight: 400;
  line-height: 1.22;
  letter-spacing: -.035em;
  color: #fff;
  text-wrap: balance;
}
@media (max-width: 900px) {
  .ce-case-finale__say { font-size: clamp(1.375rem, 1rem + 1.6vw, 1.625rem); }   /* 22 px at 375 */
}

/* the lines and letters (kit classes; the letters' light is one number,
   --cf-lit, as in CE-08: opacity .05 → 1 over the first .15, the red share
   (1 − lit)⁴ – so one linear transition gives the flash in and its
   reverse out) */
.ce-case-finale__say .lf-rl {
  overflow: clip;
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
.ce-case-finale__say .lf-rl__in {
  white-space: nowrap;
  transform: translateY(110%);
  transition: transform .25s var(--cf-ease) var(--line-out-at, 0ms);
}
.ce-case-finale.is-said .ce-case-finale__say .lf-rl__in {
  transform: none;
  transition: transform .6s var(--ease-out-expo) calc(var(--say-at, 80ms) + var(--i, 0) * 40ms);
}
.ce-case-finale__say .lf-ch {
  --cf-lit: 0;
  opacity: calc(.05 + .95 * min(1, var(--cf-lit) / .15));
  color: color-mix(in srgb, var(--ui-brand) calc(min(1, var(--cf-lit) * 50) * (1 - var(--cf-lit)) * (1 - var(--cf-lit)) * (1 - var(--cf-lit)) * (1 - var(--cf-lit)) * 100%), #fff);
  animation: none;
  transition: --cf-lit .2s linear calc(var(--ch-out-at, 0ms) + (var(--c-last, 0) - var(--c, 0)) * var(--ch-out-step, 1ms));
}
.ce-case-finale.is-said .ce-case-finale__say .lf-ch {
  --cf-lit: 1;
  transition: --cf-lit .6s linear calc(var(--say-at, 80ms) + var(--c, 0) * var(--ch-step, 10ms));
}

/* the button: the kit's UI button, light on the dark veil; it grows in
   after the call (the kit's pop keyframes, --pop-w measured by the
   script) and fades on the way out */
.ce-case-finale .ce-case-finale__btn {
  background: #fff;
  color: var(--ui-ink, #1d1d1e);
  visibility: hidden;
  opacity: 0;
  transition: background-color .2s ease, opacity .2s var(--cf-ease), visibility 0s linear .2s;
}
.ce-case-finale .ce-case-finale__btn:hover { background: #e9e9e9; }
.ce-case-finale .ce-case-finale__btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.ce-case-finale__btn .lf-btn__icon img { filter: invert(1); }   /* the white arrow of the kit, dark here */
.ce-case-finale.is-said .ce-case-finale__btn {
  visibility: visible;
  opacity: 1;
  overflow: hidden;
  transform-origin: center;
  transition: background-color .2s ease;
  animation: lf-pop-grow 1.25s var(--ease-elastic) var(--btn-at, 600ms) both;
}
.ce-case-finale.is-said .ce-case-finale__btn > * {
  animation: lf-pop-content 1s var(--ease-out-expo) calc(var(--btn-at, 600ms) + 250ms) both;
}

/* the state at once, without transitions */
.ce-case-finale.is-snap .ce-case-finale__box,
.ce-case-finale.is-snap .ce-case-finale__stage::after,
.ce-case-finale.is-snap .ce-case-finale__veil,
.ce-case-finale.is-snap .ce-case-finale__say .lf-rl__in,
.ce-case-finale.is-snap .ce-case-finale__say .lf-ch,
.ce-case-finale.is-snap .ce-case-finale__btn,
.ce-case-finale.is-snap .ce-case-finale__btn > * { transition: none; animation: none; }

/* without the script (no html.cr-js) or with reduced motion: a plain block
   in the flow – the poster with the veil at the full width, the call and
   the button */
html:not(.cr-js) .ce-case-finale { height: auto; }
html:not(.cr-js) .ce-case-finale__stage { position: relative; }
html:not(.cr-js) .ce-case-finale__stage::after { display: none; }
html:not(.cr-js) .ce-case-finale__box { left: 0; right: 0; transition: none; }
html:not(.cr-js) .ce-case-finale__veil { opacity: 1; }
html:not(.cr-js) .ce-case-finale__btn { visibility: visible; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .ce-case-finale { height: auto; }
  .ce-case-finale__stage { position: relative; min-height: 32rem; }
  .ce-case-finale__stage::after { display: none; }
  .ce-case-finale__box,
  .ce-case-finale.is-shown .ce-case-finale__box { left: 0; right: 0; transition: none; }
  .ce-case-finale__veil,
  .ce-case-finale.is-shown .ce-case-finale__veil { opacity: 1; transition: none; }
  .ce-case-finale .ce-case-finale__btn,
  .ce-case-finale.is-said .ce-case-finale__btn { visibility: visible; opacity: 1; animation: none; transition: none; }
  .ce-case-finale.is-said .ce-case-finale__btn > * { animation: none; }
}

/* Older Safari (15.4–15.x): no overflow: clip on the section, so the apron would
   spill over the next section – drop it there (the light strip under the stage
   comes back, nothing overlaps). */
@supports not (overflow: clip) {
  .ce-case-finale__stage::after { display: none; }
}
