/* =====================================================================
   Live scene: "A first call, in five steps" (Work With Me page head)
   ---------------------------------------------------------------------
   A faded line drawing of Renel's three working worlds (storefront,
   apartment building, laptop workflow) with chat bubbles that play out
   an EXAMPLE first call through the five-step method:
   Gather → Define → Root cause → Solve → Own it.

   Loaded only on /work-with-me/. Reads the v3.2 tokens from site.css,
   so it must load AFTER site.css. Never names a raw brand colour except
   the translucent tints below, which are derived from --hero-text.

   States
   - Default (no JavaScript, or reduced motion): the finished scene,
     shown still. Nothing is hidden.
   - .is-live (added by live-scene.js): items start hidden and appear
     one at a time as .on is added.
   ===================================================================== */

.scene{
  /* Scene-only tints, all built from existing tokens */
  --scene-line:rgb(246 246 243 / .12);           /* frame border, path line */
  --scene-wash:rgb(246 246 243 / .035);          /* frame fill over the dark head */
  --scene-art:var(--hero-text);                  /* drawing colour (faded below) */
  --scene-you-bg:rgb(246 246 243 / .10);         /* visitor bubble */
  --scene-you-line:rgb(246 246 243 / .16);
  --scene-me-bg:var(--surface);                  /* Renel's bubble and notes */
  --scene-me-ink:var(--heading);
  --scene-label:var(--accent-text);              /* small labels on white (#2B3BD6, AA on white) */
  --scene-go:var(--sweep);                       /* lime: active step + final pill */
  --scene-go-ink:var(--sweep-ink);
  --scene-h:clamp(400px,36vw,500px);             /* stage height */
  position:relative;
  min-width:0;
}

/* ---------- Page-head layout (only on heads that opt in) ---------- */
/* Desktop: text left, scene right. The text keeps its original order and
   is centred against the scene with two flexible spacer rows. */
@media (min-width:1000px){
  .pagehead--scene .wrap{
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(380px,.9fr);
    grid-template-rows:1fr auto auto auto auto 1fr;
    column-gap:clamp(40px,5vw,80px);
  }
  .pagehead--scene .wrap>*{grid-column:1}
  .pagehead--scene .wrap>.eyebrow{grid-row:2;justify-self:start}
  .pagehead--scene .wrap>h1{grid-row:3}
  .pagehead--scene .wrap>.rule{grid-row:4}
  .pagehead--scene .wrap>p{grid-row:5}
  .pagehead--scene .wrap>.scene{grid-column:2;grid-row:1 / -1}
}
/* Tablet and phone: the scene sits under the intro, a little shorter. */
@media (max-width:999px){
  .pagehead--scene .scene{margin-top:clamp(32px,6vw,48px);--scene-h:clamp(380px,62vw,440px)}
}

/* ---------- The frame ---------- */
.scene-stage{
  container-type:inline-size;                    /* lets the step path adapt to the frame's own width */
  position:relative;
  height:var(--scene-h);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  border:1px solid var(--scene-line);
  border-radius:var(--radius-xl);
  background:
    radial-gradient(120% 70% at 0% 100%,color-mix(in srgb,var(--hero-glow) 70%,transparent) 0,transparent 70%),
    var(--scene-wash);
  color:var(--hero-text);
  font-size:var(--fs-sm);
  line-height:1.45;
  isolation:isolate;
}

/* The faded drawing behind everything */
.scene-art{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  z-index:-1;
  color:var(--scene-art);
  opacity:.13;
  fill:none;
  stroke:currentColor;
  stroke-width:1.3;
  stroke-linecap:round;
  stroke-linejoin:round;
  pointer-events:none;
}
.scene-art .dash{stroke-dasharray:3 7}
.scene-art .soft{opacity:.6}

/* ---------- Top bar: label + five-point path ---------- */
.scene-top{
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:18px 20px 12px;
}
.scene-tag{
  padding-right:96px;                             /* room for the Pause button on the same line */
  font:var(--label-weight) 11.5px/1.3 var(--font-label);
  letter-spacing:var(--label-tracking);
  text-transform:uppercase;
  color:var(--hero-sub);
}
.scene-path{
  display:flex;
  align-items:center;
  gap:0;
  list-style:none;
  margin:0;
  padding:0;
}
.scene-path li{
  display:flex;
  align-items:center;
  gap:7px;
  flex:0 0 auto;
  font:var(--label-weight) 11px/1 var(--font-label);
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--hero-muted);
  white-space:nowrap;
  transition:color var(--dur-base);
}
/* the line between dots */
.scene-path li+li::before{
  content:"";
  width:clamp(10px,3.2cqi,22px);
  height:1px;
  margin:0 7px;
  background:var(--scene-line);
  transition:background var(--dur-slow);
}
.scene-path i{
  width:9px;
  height:9px;
  border-radius:50%;
  border:1px solid var(--hero-muted);
  flex-shrink:0;
  transition:background var(--dur-base),border-color var(--dur-base),box-shadow var(--dur-base);
}
.scene-path .is-done{color:var(--hero-sub)}
.scene-path .is-done i{background:var(--hero-sub);border-color:var(--hero-sub)}
.scene-path .is-done+li::before,.scene-path .is-active::before{background:var(--hero-sub)}
.scene-path .is-active{color:var(--hero-text)}
.scene-path .is-active i{background:var(--scene-go);border-color:var(--scene-go);box-shadow:0 0 0 4px color-mix(in srgb,var(--scene-go) 22%,transparent)}
/* Narrow frames: show every dot but only the current step's name */
@container (max-width:500px){
  .scene-path li:not(.is-active) b{display:none}
}
.scene-path b{font-weight:inherit}

/* ---------- The feed of messages ---------- */
.scene-feed{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;                       /* newest message sits at the bottom */
  padding:0 16px 18px;
  /* older messages fade out under the top bar */
  -webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 18%);
          mask-image:linear-gradient(to bottom,transparent 0,#000 18%);
}

/* Each item collapses to zero height until it appears, so the stack
   pushes up smoothly (grid-template-rows 0fr → 1fr). */
.scene-item{
  display:grid;
  grid-template-rows:1fr;
  flex-shrink:0;
}
.scene-item>.in{
  min-height:0;
  overflow:hidden;
  display:flex;
  align-items:flex-end;
  gap:8px;
  padding:10px 4px 2px;                          /* the top padding is the gap between messages */
}

/* Visitor ("you"): right side, glassy */
.scene .from-you>.in{justify-content:flex-end}
.scene .from-you p{
  max-width:82%;
  margin:0;
  padding:10px 14px;
  border:1px solid var(--scene-you-line);
  border-radius:16px 16px 4px 16px;
  background:var(--scene-you-bg);
  color:var(--hero-text);
  font-size:inherit;
  -webkit-backdrop-filter:blur(6px);
          backdrop-filter:blur(6px);
}

/* Renel ("me"): left side, white, with the RCD mark */
.scene-avatar{
  display:grid;
  place-items:center;
  width:28px;
  height:28px;
  flex-shrink:0;
  border-radius:50%;
  background:var(--hero-text);
  color:var(--heading);
  font:600 9.5px/1 var(--font-sans);
  letter-spacing:.02em;
}
.scene .from-me p{
  max-width:80%;
  margin:0;
  padding:10px 14px;
  border-radius:16px 16px 16px 4px;
  background:var(--scene-me-bg);
  color:var(--scene-me-ink);
  font-size:inherit;
  box-shadow:0 6px 18px rgb(0 0 0 / .22);
}

/* Notes: the problem statement and the plan */
.scene-note{
  width:min(100%,360px);
  margin-left:36px;                               /* lines up with Renel's bubbles */
  padding:12px 14px 13px;
  border-radius:var(--radius-md);
  background:var(--scene-me-bg);
  color:var(--scene-me-ink);
  box-shadow:0 10px 26px rgb(0 0 0 / .28);
}
.scene-note .label{
  display:block;
  margin-bottom:4px;
  font:var(--label-weight) 10.5px/1.3 var(--font-label);
  letter-spacing:var(--label-tracking);
  text-transform:uppercase;
  color:var(--scene-label);
}
.scene .scene-note p{margin:0;color:inherit;font-size:inherit;font-weight:600;max-width:none}
.scene-note ul{list-style:none;margin:4px 0 0;padding:0;display:grid;gap:5px}
.scene-note li{display:flex;align-items:center;gap:8px}
/* the tick box: draws its check when the plan appears */
.scene-note li::before{
  content:"";
  width:14px;
  height:14px;
  flex-shrink:0;
  border-radius:4px;
  background:var(--scene-go) no-repeat center/10px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.8 5.2 4 7.3 8.2 2.8' fill='none' stroke='%230B0C0F' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Final line: lime pill */
.scene .own>.in{padding-top:14px}
.scene-own{
  margin-left:36px;
  padding:9px 16px;
  border-radius:18px;                             /* a pill on one line, a soft card if it wraps on small phones */
  text-wrap:balance;
  background:var(--scene-go);
  color:var(--scene-go-ink);
  font-weight:600;
  font-size:var(--fs-xs);
  letter-spacing:-.005em;
}

/* Typing dots (only used while the scene is live) */
.scene-typing{display:none}
.scene-typing .dots{
  display:inline-flex;
  gap:4px;
  padding:12px 14px;
  border-radius:16px 16px 16px 4px;
  background:var(--scene-me-bg);
}
.scene-typing .dots span{width:6px;height:6px;border-radius:50%;background:var(--text-muted)}

/* ---------- Pause / play button ---------- */
.scene-toggle{
  position:absolute;
  top:13px;
  right:13px;
  z-index:2;
  display:inline-flex;
  align-items:center;
  gap:6px;
  min-height:32px;                                /* comfortable touch target with the padding below */
  padding:6px 12px 6px 10px;
  border:1px solid var(--scene-line);
  border-radius:var(--radius-pill);
  background:rgb(11 12 15 / .55);
  color:var(--hero-text);
  font:var(--label-weight) 11.5px/1 var(--font-label);
  letter-spacing:.06em;
  text-transform:uppercase;
  cursor:pointer;
  transition:background var(--dur-fast),border-color var(--dur-fast);
}
.scene-toggle:hover{background:rgb(246 246 243 / .12);border-color:var(--hero-line)}
.scene-toggle svg{width:12px;height:12px;fill:currentColor}
.scene-toggle .play{display:none}
.scene-toggle[aria-pressed="true"] .pause{display:none}
.scene-toggle[aria-pressed="true"] .play{display:block}

/* =====================================================================
   Live mode (JavaScript on, motion allowed)
   ===================================================================== */
.scene.is-live .scene-item{
  grid-template-rows:0fr;
  opacity:0;
  translate:0 10px;
  transition:
    grid-template-rows var(--dur-slow) var(--ease-out),
    opacity var(--dur-slow) var(--ease-out),
    translate var(--dur-slow) var(--ease-out);
}
.scene.is-live .scene-item.on{grid-template-rows:1fr;opacity:1;translate:none}
/* a hidden item must take no space at all, padding included */
.scene.is-live .scene-item>.in{transition:padding var(--dur-slow) var(--ease-out)}
.scene.is-live .scene-item:not(.on)>.in{padding-top:0;padding-bottom:0}
.scene.is-live .scene-typing{display:grid}
.scene.is-live .scene-feed{transition:opacity var(--dur-base)}
.scene.is-live.is-resetting .scene-feed{opacity:0}

/* The plan's ticks land one after another */
.scene.is-live .plan li{opacity:0;translate:-6px 0;transition:opacity var(--dur-base),translate var(--dur-base) var(--ease-out)}
.scene.is-live .plan.on li{opacity:1;translate:none}
.scene.is-live .plan.on li:nth-child(2){transition-delay:.35s}
.scene.is-live .plan.on li:nth-child(3){transition-delay:.7s}

@keyframes scene-dot{0%,60%,100%{opacity:.35;translate:0 0}30%{opacity:1;translate:0 -3px}}
.scene.is-live .scene-typing.on .dots span{animation:scene-dot 1s ease-in-out infinite}
.scene.is-live .scene-typing.on .dots span:nth-child(2){animation-delay:.15s}
.scene.is-live .scene-typing.on .dots span:nth-child(3){animation-delay:.3s}

/* The drawing breathes very slowly. Paused along with everything else. */
@keyframes scene-drift{from{translate:0 0}to{translate:-10px -8px}}
.scene.is-live .scene-art{animation:scene-drift 18s ease-in-out infinite alternate}
.scene.is-live.is-paused .scene-art,
.scene.is-live.is-paused .scene-typing .dots span{animation-play-state:paused}

/* Safety net: if the visitor asks for reduced motion after the page has
   loaded, show everything at once with no movement. live-scene.js also
   stops the sequence. */
@media (prefers-reduced-motion:reduce){
  .scene.is-live .scene-item,.scene.is-live .plan li{grid-template-rows:1fr;opacity:1;translate:none;transition:none}
  .scene.is-live .scene-typing{display:none}
  .scene.is-live .scene-art{animation:none}
}

/* Windows High Contrast / forced colours: keep bubbles readable */
@media (forced-colors:active){
  .scene .from-you p,.scene .from-me p,.scene-note,.scene-own{border:1px solid CanvasText}
}
