/* The messy reading of the value argument, resolved by a wipe.
   One clapperboard edge travels across the pinned screen, right to left the way
   a crew's Arabic call sheet reads. A single registered property, --x, is the
   edge's position: both worlds are clipped against it from opposite sides and
   the striped bar sits on it, so the edge and what it reveals cannot disagree.
   The screen never changes: the mess becomes the answer, and the answer becomes
   the camera, all in one held frame. */

/* The call sheet's own paper, the one surface here that is a prop rather than
   chrome. Mono allows colour in one place only, the signal, so under it the
   paper is a neutral: the note still reads as paper, without a second colour
   on a black and white page. */
.vmess { --note: #E8D9A8; }
:root[data-brand='mono'] .vmess { --note: #E9E6E0; }

@property --x {
  syntax: '<percentage>';
  inherits: true;
  initial-value: 112%;
}

.vmess { position: relative; }
.vm__pin {
  height: 100vh;
  height: 100svh;
  position: relative;
  overflow: hidden;
  /* The edge starts past the right of the screen, not on it. */
  --x: 112%;
}

.vm__world { position: absolute; inset: 0; }
/* The mess lives to the left of the edge, the answer to the right of it. */
.vm__world--mess { clip-path: inset(0 max(0px, calc(100% - var(--x, 112%))) 0 0); }
.vm__world--kept { clip-path: inset(0 0 0 max(0px, var(--x, 112%))); }

/* ---- the pile ---- */
.vm__pile { position: absolute; inset: 0; z-index: 2; }
.vm__card {
  position: absolute;
  width: clamp(236px, 25vw, 320px);
  background: var(--surface);
  border-radius: 14px;
  padding: .85rem .95rem .95rem;
  box-shadow: 0 1px 0 0 rgba(246,235,217,.07) inset, 0 22px 50px -22px rgba(0,0,0,.9);
  will-change: transform, opacity;
}
.vm__top { display: flex; align-items: center; gap: .55rem; margin-bottom: .55rem; }
/* The app's own mark, at the size a phone draws it. No desaturation: the
   whole point of the pile is that the crew recognises every logo in it. */
.vm__icon { flex: none; width: 1.55rem; height: 1.55rem; line-height: 0; }
.vm__icon svg { display: block; width: 100%; height: 100%; }
.vm__app { font-family: var(--mono); font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.vm__time { margin-inline-start: auto; font-size: .6875rem; color: var(--faint); font-family: var(--mono); }
.vm__who { font-weight: 600; font-size: .9375rem; margin-bottom: .2rem; }
.vm__body { font-size: .875rem; color: var(--muted); line-height: 1.5; }

.vm__card--note {
  background: var(--note);
  color: var(--ink);
  width: clamp(158px, 16vw, 208px);
  border-radius: 2px;
  box-shadow: 0 16px 34px -16px rgba(0,0,0,.85);
}
.vm__card--note .vm__app, .vm__card--note .vm__time { color: rgba(18,18,18,.5); }
.vm__card--note .vm__who { color: rgba(18,18,18,.75); font-size: .8rem; }
.vm__card--note .vm__body { color: var(--ink); font-family: var(--mono); font-size: .9rem; }

/* ---- the paper that keeps falling ---- */
.vm__fall { position: absolute; inset: -12% 0 -12% 0; z-index: 1; pointer-events: none; }
.vm__scrap {
  position: absolute; top: 0;
  background: var(--note); color: rgba(18,18,18,.72);
  font-family: var(--mono); font-size: .625rem;
  padding: .3em .5em; border-radius: 1px; white-space: nowrap;
  opacity: .5; box-shadow: 0 8px 18px -10px rgba(0,0,0,.8);
  will-change: transform;
}

/* ---- the words, one set each side of the edge ---- */
.vm__head {
  position: absolute;
  left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  text-align: center;
  padding-inline: var(--gut);
  pointer-events: none;
}
.vm__line { display: block; font-family: var(--display); font-weight: 900; font-size: var(--t-2xl); line-height: 1.03; letter-spacing: -.03em; }
.vm__world--kept .vm__line { color: var(--accent); }
/* The answer sits in the upper half so the lens can hold the middle. Both are
   centred on the same axis, so the push does not slide sideways. */
.vm__world--kept .vm__head { top: 11%; transform: none; }
/* The journey's own sentence, on the same screen as the answer rather than on
   a screen of its own. */
.vm__next {
  display: block;
  margin-top: .9rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--t-lg);
  letter-spacing: -.02em;
  color: var(--text);
  opacity: .82;
}


/* ---- the edge itself ---- */
.vm__bar {
  position: absolute;
  z-index: 5;
  top: -14%; bottom: -14%;
  left: var(--x, 112%);
  width: clamp(44px, 5.5vw, 78px);
  margin-left: clamp(-39px, -2.75vw, -22px);
  transform: rotate(6deg);
  background-color: var(--ink);
  background-image: repeating-linear-gradient(45deg, var(--paper) 0 24px, var(--ink) 24px 48px);
  box-shadow: 0 0 60px -10px rgba(0,0,0,.9);
  pointer-events: none;
}
.vm__flash { position: absolute; inset: 0; z-index: 6; background: var(--paper); opacity: 0; mix-blend-mode: screen; pointer-events: none; }

.vm__phases { position: absolute; left: 0; right: 0; bottom: clamp(1.25rem, 4vh, 2.5rem); z-index: 7; display: flex; justify-content: center; gap: clamp(1rem, 4vw, 2.75rem); }
.vm__phase { display: flex; align-items: center; gap: .45rem; color: var(--faint); transition: color var(--d) var(--e-out); }
.vm__phase i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0; transition: opacity var(--d) var(--e-out); }
.vm__phase.is-on { color: var(--text); }
.vm__phase.is-on i { opacity: 1; }

@media (max-width: 900px) { .vm__world--kept .vm__head { top: 9%; } }
@media (max-height: 680px) { .vm__world--kept .vm__head { top: 6%; } }
@media (max-width: 760px) {
  .vm__card { width: clamp(168px, 50vw, 232px); padding: .65rem .7rem .75rem; }
  .vm__card--note { width: clamp(128px, 36vw, 164px); }
  .vm__icon { width: 1.3rem; height: 1.3rem; }
  .vm__who { font-size: .85rem; }
  .vm__body { font-size: .8rem; }
}

/* A short phone has no room for a bank of cards above the words, four lines of
   words, and a bank below. The cards give up the room, not the sentence. */
@media (max-width: 760px) and (max-height: 650px) {
  .vm__card { width: clamp(148px, 46vw, 196px); padding: .45rem .55rem .55rem; border-radius: 11px; }
  .vm__card--note { width: clamp(110px, 33vw, 146px); }
  .vm__icon { width: 1.05rem; height: 1.05rem; }
  .vm__top { margin-bottom: .35rem; }
  .vm__who { font-size: .76rem; }
  .vm__body { font-size: .7rem; line-height: 1.4; }
  .vm__line { font-size: var(--t-xl); }
}

/* Reduced motion keeps the argument and drops the choreography. */
.vmess.is-still .vm__pin { height: auto; padding-block: var(--sec); --x: 0%; }
.vmess.is-still .vm__world { position: static; clip-path: none; }
.vmess.is-still .vm__fall, .vmess.is-still .vm__bar, .vmess.is-still .vm__flash { display: none; }
.vmess.is-still .vm__pile { position: static; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.vmess.is-still .vm__card { position: static; width: auto; }
.vmess.is-still .vm__head { position: static; transform: none; margin-block: 2rem; }


/* ---- what is behind the edge -------------------------------------------
   The mess is ink; Klaket is teal. The side the clapperboard reveals is the
   brand's own ground, with the chain drawn on it once and left alone. */
.vm__world--kept { background: var(--teal-deep); }
.vm__world--kept .vm__line { color: var(--paper); }
.vm__world--kept .vm__head {
  top: clamp(2.5rem, 11vh, 6rem);
  transform: none;
  z-index: 4;
}

.vm__chain {
  position: absolute;
  left: 50%;
  top: 56%;
  translate: -50% -50%;
  z-index: 4;
  width: min(100% - var(--gut) * 2, 1060px);
  opacity: 0;
}
.vm__chain-title {
  text-align: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: var(--t-xl);
  letter-spacing: -.02em;
  color: var(--paper);
  margin-bottom: clamp(1.75rem, 5vh, 3rem);
}

/* ---- the rail ---- */
.vm__rail {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: start;
  gap: 0;
  position: relative;
}
.vm__node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9rem;
  text-align: center;
  padding-inline: .35rem;
}
/* The line runs between the nodes, not under them, so it reads as a hand-off.
   Each node draws the segment behind it, back towards the one it came from,
   so it has to start from the inline start rather than from the left: in
   Arabic the chain is dealt right to left, and a physical `left` drew every
   segment on the wrong side — the first agent lost the line to its neighbour
   and the last one grew a tail into empty space. */
.vm__node::before {
  content: '';
  position: absolute;
  top: 34px;
  inset-inline-start: calc(-50% + 34px);
  width: calc(100% - 68px);
  height: 1.5px;
  background: rgba(246, 235, 217, .28);
}
.vm__node:first-child::before { display: none; }

.vm__dot {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(246, 235, 217, .08);
  box-shadow: inset 0 0 0 1.5px rgba(246, 235, 217, .18);
  flex: none;
}
.vm__dot svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--paper);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .85;
}
/* The client's own step is not an agent, so it does not look like one. */
.vm__node.is-human .vm__dot { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(246, 235, 217, .3); }

/* One node is working, and the slate says so the way the mark does. */
.vm__node.is-live .vm__dot {
  background: var(--paper);
  box-shadow: 0 0 0 10px rgba(246, 235, 217, .1);
}
.vm__node.is-live .vm__dot svg { stroke: var(--teal-deep); opacity: 1; }
.vm__dots {
  position: absolute;
  top: -16px;
  inset-inline-end: -18px;
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--ink);
}
.vm__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); }
.vm__dots i:nth-child(2) { opacity: .7; }
.vm__dots i:nth-child(3) { opacity: .45; }

.vm__node-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--t-sm);
  line-height: 1.25;
  letter-spacing: -.01em;
  color: rgba(246, 235, 217, .62);
  text-wrap: balance;
}
.vm__node.is-live .vm__node-label { color: var(--paper); font-weight: 900; }

@media (max-width: 860px) {
  .vm__chain { top: 58%; }
  .vm__rail { grid-template-columns: repeat(3, 1fr); row-gap: 2rem; }
  .vm__node:nth-child(4)::before { display: none; }
  .vm__dot { width: 54px; height: 54px; }
  .vm__dot svg { width: 24px; height: 24px; }
  .vm__node::before { top: 27px; inset-inline-start: calc(-50% + 27px); width: calc(100% - 54px); }
  .vm__node-label { font-size: var(--t-xs); }
}

.vmess.is-still .vm__chain { position: static; transform: none; opacity: 1; margin-top: 2.5rem; }
