/* ConvivioPOS Festa - geometry/state for everything festa-core.js injects.
   Look of bands, cards and step highlights lives in festa.css (SHELL).

   Z-INDEX STRATEGY (ribbon)
   main.cv-page-main is a stacking context (position:relative + isolation:isolate, set by
   festa.css and repeated here). The ribbon layer is its first child with z-index:-1, so it
   paints above main's own background but below every section: the strand shows on the cream
   page and in sections without a background, and "dives under" the colour-blocked bands
   (their background and content both cover it), reappearing between them. No transform is
   ever applied to main/body (the fixed nav must keep its containing block).
   NEVER UNDER CONTENT: festa-core.js measures every text/media box (layout offsets, glyph
   overflow padded) and routes the strand through gutter lanes kept stroke/2 + 8px away from
   content, changing side only in the empty rows between blocks. A block with no lane gets
   .cvf-ribbon-under (hook only, no style) and its content rows are cut out of the ribbon by
   an SVG clip-path (#cvf-ribbon-clip), so the strand "passes under" it. Stroke follows the
   gutter on desktop (64-120px) and is 60px on phones (set inline as --cvf-ribbon-w). */

/* ------------------------------------------------------------------ probes */
.cvf-vh-probe {
  position: fixed; top: 0; left: 0; width: 0; height: 100vh; height: 100svh;
  margin: 0; padding: 0; border: 0; visibility: hidden; pointer-events: none; overflow: hidden; contain: strict;
}

/* ------------------------------------------------------------------ ribbon */
body.cv-festa-theme .cvf-ribbon-host { position: relative; isolation: isolate; }
.cvf-ribbon-layer {
  --cvf-ribbon-w: 120px;
  position: absolute; inset: 0; z-index: -1;
  pointer-events: none; overflow: hidden; contain: strict;
}
.cvf-ribbon-layer[hidden] { display: none; }
.cvf-ribbon { position: absolute; top: 0; left: 0; display: block; overflow: visible; }
.cvf-ribbon-base,
.cvf-ribbon-hi { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.cvf-ribbon-base { stroke: var(--cvf-tomato, #F0442E); stroke-width: var(--cvf-ribbon-w); }
.cvf-ribbon-hi { stroke: var(--cvf-crust, #E9A23B); stroke-width: calc(var(--cvf-ribbon-w) * .24); opacity: .85; }
.cvf-ribbon-empty .cvf-ribbon { opacity: 0; }

/* ------------------------------------------------------------------ stages
   A stage is one square host for one original illustration (no extra props). The
   character box is sized by festa-core.js (--cvf-char-size, ~90% of the stage) so hops and
   leans keep ~8% headroom; nothing on or around a stage clips (overflow stays visible). */
.cvf-stage { position: relative; overflow: visible; pointer-events: none; user-select: none; -webkit-user-select: none; }
.cvf-stage-char {
  position: absolute; z-index: 1; left: 50%; bottom: 2%;
  width: var(--cvf-char-size, 90%); aspect-ratio: 1 / 1;
  margin-left: calc(var(--cvf-char-size, 90%) / -2);
  transition: opacity .25s linear;
}
.cvf-stage-char.cvf-char-wait { opacity: 0; }

/* Character fallback (ConvivioFesta.characters missing). */
.cvf-char-fallback {
  display: block; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; translate: 0 10%; transition: opacity .35s ease, translate .6s cubic-bezier(.34, 1.56, .64, 1);
}
.cvf-char-in > .cvf-char-fallback { opacity: 1; translate: none; }

/* Offscreen decorative loops are paused. */
.cvf-offscreen,
.cvf-offscreen * { animation-play-state: paused !important; }

/* Hero: direct child of .hero-layout -> auto-placed in its "art" grid area (festa.css). */
body.cv-festa-theme .cvf-stage--hero {
  width: 100%; max-width: 680px; aspect-ratio: 1 / 1;
  justify-self: center; align-self: center; z-index: 1;
}

/* Interludes: a square art host up to 600px; the stage fills it. */
body.cv-festa-theme .rs-interlude-art.cvf-stage-host {
  position: relative; width: 100%; max-width: 600px; aspect-ratio: 1 / 1;
  min-height: 0; justify-self: center; align-self: center; overflow: visible;
}
body.cv-festa-theme .rs-interlude-art.cvf-stage-ready > :not(.cvf-stage) { display: none; }
.cvf-stage--context { position: absolute; inset: 0; }

/* Article hero (solution pages): floated beside the copy when there is room, else in flow. */
body.cv-festa-theme .cvf-article-ready { position: relative; overflow: visible; }
.cvf-stage--article { position: absolute; width: 0; height: 0; }
.cvf-stage--article.cvf-stage--float { position: absolute; z-index: 1; }
.cvf-stage--article.cvf-stage--flow {
  position: relative; width: min(100%, 520px); height: auto; aspect-ratio: 1 / 1; margin: 28px auto 0;
}

/* ---------------------------------------------------- #service sticky story
   Desktop: heading + steps on the left, the stage spans the whole panel height on the
   right, so the character is as big as the sticky panel allows. */
body.cv-festa-theme .cvf-story .rs-stage.cvf-stage-host {
  position: relative; margin: 0; min-width: 0; min-height: 0; max-width: none; max-height: none;
  aspect-ratio: auto; overflow: visible; border-radius: 0;
}
.cvf-stage--story { position: absolute; inset: 0; }
.cvf-story-spacer { display: block; height: 0; pointer-events: none; }

body.cv-festa-theme .cvf-story.cvf-story-sticky > .rs-sticky {
  position: sticky; top: var(--cvf-story-top, 96px);
  height: var(--cvf-story-panel, 80vh); box-sizing: border-box;
  margin-top: 0; margin-bottom: 0; padding-top: 8px; padding-bottom: 8px;
  display: grid; overflow: visible;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "head stage" "steps stage";
  gap: clamp(14px, 2vw, 26px) clamp(24px, 4vw, 56px);
}
body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-heading { grid-area: head; display: block; margin: 0; }
body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-heading h2 { font-size: clamp(34px, 3.5vw, 58px); line-height: .98; }
body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-intro { max-width: 520px; margin: 14px 0 0; font-size: 16px; line-height: 1.5; }
body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-stage { grid-area: stage; align-self: stretch; height: auto; }
body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-steps {
  grid-area: steps; align-self: end; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-scroll-cue { display: none; }

/* Compact: the active step only (the others stay in the tree, transparent). */
body.cv-festa-theme .cvf-story.cvf-story-compact .rs-steps { grid-template-columns: minmax(0, 1fr); }
body.cv-festa-theme .cvf-story.cvf-story-compact .rs-step {
  grid-area: 1 / 1; opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
body.cv-festa-theme .cvf-story.cvf-story-compact .rs-step.cvf-active { opacity: 1; pointer-events: auto; }

/* Static (reduced motion, short screens, overflow): normal flow. */
body.cv-festa-theme .cvf-story.cvf-story-static .rs-stage { width: min(100%, 600px); height: auto; aspect-ratio: 1 / 1; margin: 18px auto; }

/* Per-step progress bar. */
body.cv-festa-theme .cvf-story .rs-step { position: relative; overflow: hidden; }
.cvf-step-bar {
  position: absolute; left: 18px; right: 18px; bottom: 9px; height: 4px;
  border-radius: 4px; background: #1f1a171a; overflow: hidden; pointer-events: none;
}
.cvf-step-fill {
  display: block; width: 100%; height: 100%; border-radius: inherit;
  background: var(--cvf-tomato-deep, #D63A24);
  transform-origin: 0 50%; transform: scaleX(var(--cvf-step-p, 0));
}
.cvf-story-static .cvf-step-bar { display: none; }

@media (max-width: 759px) {
  .cvf-ribbon-layer { --cvf-ribbon-w: 60px; }
  body.cv-festa-theme .cvf-stage--hero { width: min(92vw, 100%); max-width: none; }
  body.cv-festa-theme .rs-interlude-art.cvf-stage-host { width: min(88vw, 100%); max-width: none; }
  .cvf-stage--article.cvf-stage--flow { width: min(88vw, 100%); }
  body.cv-festa-theme .cvf-story.cvf-story-sticky > .rs-sticky {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(150px, 1fr) auto;
    grid-template-areas: "head" "stage" "steps";
    gap: 10px;
  }
  body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-heading h2 { font-size: clamp(28px, 8.4vw, 40px); }
  body.cv-festa-theme .cvf-story.cvf-story-sticky .rs-intro { margin-top: 10px; font-size: 13px; }
  body.cv-festa-theme .cvf-story.cvf-story-static .rs-stage { width: min(92vw, 100%); }
  .cvf-step-bar { left: 12px; right: 12px; bottom: 7px; height: 3px; }
}

/* ------------------------------------------------------------------ reveals */
@keyframes cvf-rise { from { opacity: 0; translate: 0 34px; } }
html.cvf-js:not(.cvf-reduced) .cvf-reveal:not(.cvf-in) { opacity: 0; translate: 0 34px; }
html.cvf-js:not(.cvf-reduced) .cvf-reveal.cvf-in:not(.cvf-instant) {
  animation: cvf-rise .9s cubic-bezier(.2, .75, .25, 1) backwards;
  animation-delay: var(--cvf-d, 0ms);
}

/* Headlines: each word sits in a mask (clip-path keeps the text baseline, unlike overflow). */
.cvf-split .cvf-w { display: inline-block; clip-path: inset(-.3em -.25em -.24em -.25em); }
.cvf-split.cvf-done .cvf-w { clip-path: none; }
.cvf-split .cvf-wi { display: inline-block; transform-origin: 0 100%; }
@keyframes cvf-word {
  0% { transform: translateY(calc(100% + .35em)) skewY(8deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: none; opacity: 1; }
}
html.cvf-js:not(.cvf-reduced) .cvf-split:not(.cvf-in) .cvf-wi { transform: translateY(calc(100% + .35em)) skewY(8deg); opacity: 0; }
html.cvf-js:not(.cvf-reduced) .cvf-split.cvf-in:not(.cvf-instant) .cvf-wi {
  animation: cvf-word 1.05s cubic-bezier(.16, 1, .3, 1) backwards;
  animation-delay: calc(var(--cvf-d, 0ms) + var(--cvf-l, 0) * 110ms + var(--cvf-wd, 0) * 24ms);
}

.cvf-counting { font-variant-numeric: tabular-nums; }

/* #stats stack: sticky offsets are in festa.css; core feeds --cvf-cover (0..1) to dim the
   card being covered by the next one. */
body.cv-festa-theme .cvf-stack-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: #1f1a17; opacity: calc(var(--cvf-cover, 0) * .22);
}

/* ------------------------------------------------------------------ marquee
   Words separated by ingredients cut out of the original illustrations (marquee-*.webp).
   Every separator box has the same width (seamless loop); each sprite runs its own small
   character loop (anticipation squash, hop with stretch, landing squash, settle), paused
   offscreen (.cvf-offscreen) and removed under reduced motion. Plain dots without sprites. */
.cvf-marquee {
  position: relative; z-index: 1; overflow: hidden; overflow: clip;
  padding: clamp(18px, 3vw, 40px) 0; margin: clamp(4px, 1.5vw, 20px) 0;
  pointer-events: none; user-select: none; -webkit-user-select: none;
}
.cvf-marquee-band {
  width: 112%; margin-left: -6%; transform: rotate(-2deg);
  padding: clamp(12px, 1.6vw, 22px) 0;
  background: var(--cvf-ink, #1F1A17); color: var(--cvf-cream, #FFF6E6);
  box-shadow: 0 18px 40px -24px #1f1a1780;
}
.cvf-marquee-track { display: flex; width: max-content; will-change: transform; }
.cvf-marquee-group {
  display: flex; flex: none; align-items: center;
  gap: clamp(18px, 2.4vw, 40px); padding-right: clamp(18px, 2.4vw, 40px);
  font-size: clamp(40px, 6.4vw, 104px);
}
.cvf-marquee-word {
  flex: none; white-space: nowrap;
  font-weight: 700; line-height: 1.04; letter-spacing: -.05em;
}
.cvf-marquee-group > .cvf-marquee-word:nth-child(4n+3) { color: var(--cvf-yolk, #FFD23F); }
.cvf-marquee-sep { flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--cvf-tomato, #F0442E); }
.cvf-marquee-sprite {
  flex: none; display: inline-flex; align-items: flex-end; justify-content: center;
  width: 1.3em; height: 1.1em;
}
.cvf-marquee-sprite > img {
  display: block; width: auto; height: 100%; max-width: none; margin: 0;
  transform-origin: 50% 100%; user-select: none; -webkit-user-drag: none;
  animation: cvf-ms-hop 1.8s cubic-bezier(.45, 0, .55, 1) infinite both;
}
.cvf-ms-1 > img { animation-name: cvf-ms-bob; animation-duration: 2.2s; animation-delay: -.5s; }
.cvf-ms-2 > img { animation-name: cvf-ms-roll; animation-duration: 2s; animation-delay: -1.1s; }
.cvf-ms-3 > img { animation-name: cvf-ms-wave; animation-duration: 2.4s; animation-delay: -.3s; }
/* basil: quick hop with squash and stretch */
@keyframes cvf-ms-hop {
  0%, 100% { transform: none; }
  14% { transform: scale(1.1, .86) rotate(-2deg); }
  34% { transform: translateY(-24%) scale(.92, 1.1) rotate(4deg); }
  50% { transform: translateY(-30%) scale(1, 1) rotate(5deg); }
  66% { transform: translateY(0) scale(1.12, .84) rotate(-1deg); }
  78% { transform: scale(.97, 1.04) rotate(0deg); }
  88% { transform: scale(1.02, .98); }
}
/* carrot: tall stretch bounce */
@keyframes cvf-ms-bob {
  0%, 100% { transform: none; }
  18% { transform: scale(1.14, .82); }
  40% { transform: translateY(-20%) scale(.88, 1.14) rotate(-6deg); }
  58% { transform: translateY(-22%) scale(.96, 1.04) rotate(4deg); }
  74% { transform: translateY(0) scale(1.14, .84) rotate(0deg); }
  86% { transform: scale(.96, 1.05); }
}
/* tomato: round, heavier hop with a roll */
@keyframes cvf-ms-roll {
  0%, 100% { transform: none; }
  16% { transform: scale(1.12, .85); }
  38% { transform: translateY(-26%) scale(.93, 1.08) rotate(-8deg); }
  52% { transform: translateY(-28%) rotate(-10deg); }
  70% { transform: translateY(0) scale(1.15, .83) rotate(-2deg); }
  84% { transform: scale(.97, 1.04) rotate(1deg); }
}
/* waving tomato: small double hop and a sway */
@keyframes cvf-ms-wave {
  0%, 100% { transform: none; }
  12% { transform: scale(1.08, .9) rotate(3deg); }
  26% { transform: translateY(-16%) scale(.95, 1.06) rotate(-5deg); }
  40% { transform: translateY(0) scale(1.08, .9) rotate(2deg); }
  54% { transform: translateY(-12%) scale(.96, 1.05) rotate(6deg); }
  68% { transform: translateY(0) scale(1.06, .93) rotate(-2deg); }
  82% { transform: rotate(2deg); }
}
@media (max-width: 759px) {
  .cvf-marquee-sep { width: 12px; height: 12px; }
}

/* ------------------------------------------------------------ reduced motion */
html.cvf-reduced .cvf-ribbon-base,
html.cvf-reduced .cvf-ribbon-hi { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
html.cvf-reduced .cvf-ribbon-empty .cvf-ribbon { opacity: 1; }
html.cvf-reduced .cvf-marquee-track { transform: none !important; }
html.cvf-reduced .cvf-marquee-sprite > img { animation: none !important; transform: none !important; }
html.cvf-reduced .cvf-stage-char,
html.cvf-reduced .cvf-char-fallback,
html.cvf-reduced .cvf-story .rs-step { transition: none !important; }
html.cvf-reduced .cvf-stage-char.cvf-char-wait,
html.cvf-reduced .cvf-char-fallback { opacity: 1; translate: none; }
html.cvf-reduced .cvf-stack-card::after { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .cvf-ribbon-base, .cvf-ribbon-hi { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
  .cvf-ribbon-empty .cvf-ribbon { opacity: 1; }
  .cvf-marquee-track { transform: none !important; }
  .cvf-marquee-sprite > img { animation: none !important; transform: none !important; }
  .cvf-stage-char, .cvf-char-fallback { transition: none !important; }
  .cvf-stage-char.cvf-char-wait, .cvf-char-fallback { opacity: 1; translate: none; }
  .cvf-reveal, .cvf-split .cvf-wi { animation: none !important; opacity: 1 !important; translate: none !important; transform: none !important; }
}
