/*
 * Clearvoy Home motion studies
 * These rules are opt-in and are injected only into the isolated study wrapper.
 * The approved Home baseline route remains unchanged.
 */

body[data-motion-study] {
  --motion-ease: cubic-bezier(0.22, 0.78, 0.24, 1);
  --motion-ink: #0d2730;
  --motion-paper: #ffffff;
  --motion-rule: #dce4e1;
  --motion-blocked: #d94d2b;
  --motion-ready: #2e6656;
}

/* Study A — Record Carry */

.motion-carry-clone {
  position: fixed;
  z-index: 80;
  left: 0;
  top: 0;
  width: var(--carry-width, 1100px);
  height: var(--carry-height, 94px);
  display: grid;
  transform: translate3d(var(--carry-x, 0), var(--carry-y, 0), 0);
  transform-origin: left top;
  overflow: hidden;
  border: 1px solid var(--motion-rule);
  color: var(--motion-ink);
  background: var(--motion-paper);
  box-shadow: 0 18px 40px rgba(13, 39, 48, calc(0.18 * var(--carry-shadow, 0)));
  opacity: var(--carry-opacity, 0);
  pointer-events: none;
  will-change: transform, width, height, opacity;
}

.motion-carry-clone .opening-action {
  opacity: calc(1 - var(--carry-progress, 0));
}

.motion-carry-clone::before {
  content: "Same release record";
  position: absolute;
  z-index: 2;
  left: 16px;
  bottom: 7px;
  color: rgba(13, 39, 48, calc(0.62 * var(--carry-progress, 0)));
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: var(--carry-progress, 0);
}

body[data-motion-study="record-carry"] .handoff-strip,
body[data-motion-study="record-carry"] .working-state__head,
body[data-motion-study="record-carry"] .working-state__question,
body[data-motion-study="record-carry"] .working-state__facts,
body[data-motion-study="record-carry"] .working-state__answer {
  transition:
    opacity 180ms ease-out,
    border-color 280ms ease-out,
    background-color 280ms ease-out;
}

body[data-motion-study="record-carry"] .handoff-strip {
  opacity: var(--record-source-opacity, 1);
}

body[data-motion-study="record-carry"] .working-state__head {
  opacity: var(--record-target-head-opacity, 1);
  border-bottom-color: color-mix(
    in srgb,
    var(--motion-blocked) calc(var(--record-dock, 0) * 100%),
    var(--motion-rule)
  );
}

body[data-motion-study="record-carry"] .working-state__question,
body[data-motion-study="record-carry"] .working-state__facts,
body[data-motion-study="record-carry"] .working-state__answer {
  opacity: var(--record-detail-opacity, 1);
}

body[data-motion-study="record-carry"] .working-state {
  box-shadow: 0 0 0 calc(var(--record-dock, 0) * 2px) rgba(217, 77, 43, 0.18);
}

/* Study B — Documentary Cut */

body[data-motion-study="documentary-cut"] .pitch-intro--state h2,
body[data-motion-study="documentary-cut"] .pitch-intro--state > p:last-child,
body[data-motion-study="documentary-cut"] .working-state,
body[data-motion-study="documentary-cut"] .photo-hinge__statement,
body[data-motion-study="documentary-cut"] .photo-hinge__closing {
  will-change: clip-path;
}

body[data-motion-study="documentary-cut"] .pitch-intro--state h2 {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 720ms var(--motion-ease);
}

body[data-motion-study="documentary-cut"] .pitch-intro--state > p:last-child {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 520ms var(--motion-ease) 180ms;
}

body[data-motion-study="documentary-cut"] .working-state {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 820ms var(--motion-ease) 280ms;
}

body[data-motion-study="documentary-cut"] .pitch-study.is-documentary-visible .pitch-intro--state h2,
body[data-motion-study="documentary-cut"] .pitch-study.is-documentary-visible .pitch-intro--state > p:last-child,
body[data-motion-study="documentary-cut"] .pitch-study.is-documentary-visible .working-state {
  clip-path: inset(0);
}

body[data-motion-study="documentary-cut"] .photo-hinge__figure {
  overflow: hidden;
}

body[data-motion-study="documentary-cut"] .photo-hinge__figure img {
  transform: scale(1.115);
  transform-origin: 68% 45%;
  transition:
    transform 1050ms var(--motion-ease),
    object-position 1050ms var(--motion-ease);
  object-position: 72% center;
  will-change: transform;
}

body[data-motion-study="documentary-cut"] .photo-hinge__statement {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 760ms var(--motion-ease) 220ms;
}

body[data-motion-study="documentary-cut"] .photo-hinge__closing {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 560ms var(--motion-ease) 620ms;
}

body[data-motion-study="documentary-cut"] .photo-change-study.is-documentary-visible .photo-hinge__figure img {
  transform: scale(1);
  object-position: 64% center;
}

body[data-motion-study="documentary-cut"] .photo-change-study.is-documentary-visible .photo-hinge__statement,
body[data-motion-study="documentary-cut"] .photo-change-study.is-documentary-visible .photo-hinge__closing {
  clip-path: inset(0);
}

/* Study C — Custody Thread */

.motion-custody-thread {
  position: fixed;
  z-index: 78;
  right: 24px;
  top: 118px;
  bottom: 72px;
  width: 184px;
  color: var(--motion-ink);
  opacity: var(--thread-opacity, 0);
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

.motion-custody-thread__rail {
  position: absolute;
  top: 0;
  right: 4px;
  bottom: 0;
  width: 2px;
  background: rgba(13, 39, 48, 0.42);
}

.motion-custody-thread__marker {
  position: absolute;
  z-index: 2;
  right: 0;
  top: var(--thread-position, 9%);
  width: 10px;
  height: 10px;
  transform: translateY(-50%);
  border: 2px solid white;
  background: var(--thread-color, var(--motion-blocked));
  box-shadow: 0 0 0 1px rgba(13, 39, 48, 0.32);
  transition:
    top 420ms var(--motion-ease),
    background-color 260ms ease-out;
}

.motion-custody-thread__label {
  position: absolute;
  right: 22px;
  top: var(--thread-position, 9%);
  width: 150px;
  padding: 11px 12px 12px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: white;
  background: rgba(13, 39, 48, 0.97);
  box-shadow: 0 10px 24px rgba(13, 39, 48, 0.16);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  transition: top 420ms var(--motion-ease);
}

.motion-custody-thread__label span,
.motion-custody-thread__label strong {
  display: block;
}

.motion-custody-thread__label span {
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body[data-motion-study="custody-thread"] .handoff-strip__identity,
body[data-motion-study="custody-thread"] .working-state__fact--evidence,
body[data-motion-study="custody-thread"] .custody-record aside,
body[data-motion-study="custody-thread"] .continuation-stage--human {
  transition:
    background-color 280ms ease-out,
    box-shadow 280ms ease-out;
}

body[data-motion-study="custody-thread"][data-custody-thread-state="release"] .handoff-strip__identity,
body[data-motion-study="custody-thread"][data-custody-thread-state="evidence"] .working-state__fact--evidence,
body[data-motion-study="custody-thread"][data-custody-thread-state="owner"] .custody-record aside,
body[data-motion-study="custody-thread"][data-custody-thread-state="boundary"] .continuation-stage--human {
  background-color: rgba(217, 77, 43, 0.075);
  box-shadow: inset 3px 0 0 var(--motion-blocked);
}

body[data-motion-study="custody-thread"][data-custody-thread-state="boundary"] .motion-custody-thread {
  --thread-color: var(--motion-ready);
}

/* Study D — Cinematic Focus
 * "Cinematic" describes pacing only. The photograph keeps its approved,
 * believable colour and the interface remains completely still.
 */

body[data-motion-study="cinematic-focus"] .photo-hinge__figure {
  overflow: hidden;
  background: #dfe5e4;
}

body[data-motion-study="cinematic-focus"] .photo-hinge__figure img {
  transform: scale(1.045);
  transform-origin: 74% 46%;
  object-position: 59% center;
  transition:
    transform 1500ms var(--motion-ease),
    object-position 1500ms var(--motion-ease);
  will-change: transform;
}

body[data-motion-study="cinematic-focus"] .photo-hinge__card-label,
body[data-motion-study="cinematic-focus"] .photo-hinge__answer {
  transition:
    color 700ms ease-out,
    border-color 700ms ease-out;
}

body[data-motion-study="cinematic-focus"] .photo-hinge__card-label {
  color: rgba(255, 255, 255, 0.62);
}

body[data-motion-study="cinematic-focus"] .photo-hinge__answer {
  border-color: rgba(255, 255, 255, 0.18);
}

body[data-motion-study="cinematic-focus"] .photo-change-study.is-cinematic-focused .photo-hinge__figure img {
  transform: scale(1);
  object-position: 64% center;
}

body[data-motion-study="cinematic-focus"] .photo-change-study.is-cinematic-focused .photo-hinge__card-label {
  color: rgba(255, 255, 255, 0.78);
}

body[data-motion-study="cinematic-focus"] .photo-change-study.is-cinematic-focused .photo-hinge__answer {
  border-color: rgba(255, 255, 255, 0.34);
}

body[data-motion-study="cinematic-focus"] .continuation-documentary-field figure {
  overflow: hidden;
}

body[data-motion-study="cinematic-focus"] .continuation-documentary-field figcaption {
  position: relative;
  z-index: 1;
  background: #f4f7f5;
}

body[data-motion-study="cinematic-focus"] .documentary-field__image {
  transform: scale(1.04);
  transform-origin: 54% 34%;
  object-position: 47% 35%;
  transition:
    transform 1500ms var(--motion-ease),
    object-position 1500ms var(--motion-ease);
  will-change: transform;
}

body[data-motion-study="cinematic-focus"] .continuation-documentary-field.is-cinematic-focused .documentary-field__image {
  transform: scale(1);
  object-position: 50% 35%;
}

/* Complete static state for reduced-motion users. */

body[data-motion-study][data-motion-reduced="true"] .motion-carry-clone,
body[data-motion-study][data-motion-reduced="true"] .motion-custody-thread {
  display: none !important;
}

body[data-motion-study][data-motion-reduced="true"] .pitch-intro--state h2,
body[data-motion-study][data-motion-reduced="true"] .pitch-intro--state > p:last-child,
body[data-motion-study][data-motion-reduced="true"] .working-state,
body[data-motion-study][data-motion-reduced="true"] .photo-hinge__statement,
body[data-motion-study][data-motion-reduced="true"] .photo-hinge__closing {
  clip-path: inset(0) !important;
  opacity: 1 !important;
  transition: none !important;
}

body[data-motion-study][data-motion-reduced="true"] .photo-hinge__figure img {
  transform: none !important;
  object-position: 64% center !important;
  transition: none !important;
}

body[data-motion-study="cinematic-focus"][data-motion-reduced="true"] .documentary-field__image {
  transform: none !important;
  object-position: 50% 35% !important;
  transition: none !important;
}

@media (max-width: 1100px) {
  .motion-custody-thread {
    display: none;
  }
}
