/* case files 01–05 — the hero's evidence photo, scanned into its colour truth.
   Spec: docs/specs/features/case-file-truths.md. Final state (no animation / reduced motion / unpinned) = truth fully shown. */

.tv-truth-rig {
  --tv-truth-t0: .5s;        /* scan starts */
  --tv-truth-sweep: 1.9s;    /* scan crosses the photo */
  --tv-truth-ink: var(--story-ink, #101012);
  --tv-truth-mint: var(--tv-accent, #d4b26a);
  --tv-truth-red: #e3412f;
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  aspect-ratio: 1;
  translate: -50% 0;
}

/* ---------- photo plate ---------- */
.tv-truth-plate {
  position: absolute;
  inset: 0;
  margin: 0;
  border-radius: calc(1.4 * var(--u));
  overflow: hidden;
  background: #111;
  box-shadow: 0 0 0 3px var(--tv-truth-ink), 0 calc(1.4 * var(--u)) calc(2.6 * var(--u)) rgb(0 0 0 / .24);
  container-type: inline-size;
}
.tv-truth-evidence,
.tv-truth-color {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}
.tv-truth-color { clip-path: inset(0 0 0 0); }

/* ---------- scan line ---------- */
.tv-truth-scan {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}
.tv-truth-rig[data-sweep="x"] .tv-truth-scan { top: 0; bottom: 0; left: 0; width: 0; }
.tv-truth-rig:is([data-sweep="y"], [data-sweep="up"]) .tv-truth-scan { left: 0; right: 0; top: 0; height: 0; }
.tv-truth-scan::before {
  /* trailing glow over the freshly decoded part */
  content: "";
  position: absolute;
  background: linear-gradient(var(--tv-truth-glow, 90deg), transparent, rgb(20 230 205 / .32));
  mix-blend-mode: screen;
}
.tv-truth-scan::after {
  content: "";
  position: absolute;
  background: var(--tv-truth-mint);
  box-shadow: 0 0 10px 2px rgb(20 230 205 / .85), 0 0 28px 6px rgb(20 230 205 / .35);
}
.tv-truth-rig[data-sweep="x"] .tv-truth-scan::before { top: 0; bottom: 0; right: 0; width: 16cqw; }
.tv-truth-rig[data-sweep="x"] .tv-truth-scan::after { top: 0; bottom: 0; left: -1.5px; width: 3px; }
.tv-truth-rig[data-sweep="y"] .tv-truth-scan::before { --tv-truth-glow: 180deg; left: 0; right: 0; bottom: 0; height: 16cqw; }
.tv-truth-rig[data-sweep="up"] .tv-truth-scan::before { --tv-truth-glow: 0deg; left: 0; right: 0; top: 0; height: 16cqw; }
.tv-truth-rig:is([data-sweep="y"], [data-sweep="up"]) .tv-truth-scan::after { left: 0; right: 0; top: -1.5px; height: 3px; }

.tv-truth-read {
  position: absolute;
  padding: .2em .6em;
  border-radius: 999px;
  background: var(--tv-truth-ink);
  color: var(--tv-truth-mint);
  font-family: var(--reel-mono, var(--font-mono));
  font-size: clamp(9px, 2.4cqw, 12px);
  font-weight: 600;
  white-space: nowrap;
}
/* the readout rides just ahead of the line, so it is never cut by the photo edge */
.tv-truth-rig[data-sweep="x"] .tv-truth-read { top: 4%; left: 8px; }
.tv-truth-rig[data-sweep="y"] .tv-truth-read { right: 4%; top: 8px; }
.tv-truth-rig[data-sweep="up"] .tv-truth-read { right: 4%; bottom: 8px; }

/* ---------- pins on the truth ---------- */
.tv-truth-pins {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}
.tv-truth-pin {
  position: absolute;
  left: var(--tv-x);
  top: var(--tv-y);
  width: 0;
  height: 0;
}
.tv-truth-pin::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(7px, 2.2cqw, 12px);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--tv-truth-red);
  box-shadow: 0 0 0 2px #fffdf8, 0 0 0 3.5px var(--tv-truth-ink);
}
.tv-truth-pin::after {
  /* leader line */
  content: "";
  position: absolute;
  top: -1px;
  width: 5cqw;
  height: 2px;
  background: #fffdf8;
  box-shadow: 0 0 0 1px var(--tv-truth-ink);
}
.tv-truth-pin[data-side="right"]::after { left: 0; transform-origin: left center; }
.tv-truth-pin[data-side="left"]::after { right: 0; transform-origin: right center; }
.tv-truth-chip {
  position: absolute;
  top: 0;
  translate: 0 -50%;
  padding: .3em .65em;
  border: 2px solid var(--tv-truth-ink);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--tv-truth-ink);
  font-family: var(--reel-mono, var(--font-mono));
  font-size: clamp(9px, 2.5cqw, 13px);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.tv-truth-pin[data-side="right"] .tv-truth-chip { left: 5cqw; }
.tv-truth-pin[data-side="left"] .tv-truth-chip { right: 5cqw; }

/* ---------- verdict stamp ---------- */
.tv-truth-stamp {
  position: absolute;
  right: 5%;
  bottom: 5%;
  padding: .25em .6em;
  border: 3px solid var(--tv-truth-red);
  border-radius: 8px;
  background: rgb(255 253 248 / .86);
  color: var(--tv-truth-red);
  font-family: var(--reel-mono, var(--font-mono));
  font-size: clamp(12px, 4.2cqw, 22px);
  font-weight: 800;
  letter-spacing: .06em;
  white-space: nowrap;
  rotate: -8deg;
}

/* ---------- the original evidence, pinned beside the truth ---------- */
.tv-truth-proof {
  position: absolute;
  right: calc(100% - 7%);
  bottom: 4%;
  z-index: 1;
  display: grid;
  gap: calc(.5 * var(--u));
  width: 30%;
  padding: calc(.8 * var(--u)) calc(.8 * var(--u)) calc(.6 * var(--u));
  border-radius: calc(.6 * var(--u));
  background: #fffdf8;
  box-shadow: 0 0 0 2px var(--tv-truth-ink), 0 calc(.8 * var(--u)) calc(1.6 * var(--u)) rgb(0 0 0 / .22);
  rotate: -6deg;
  color: var(--tv-truth-ink);
  font-family: var(--reel-mono, var(--font-mono));
  font-size: clamp(9px, calc(1.1 * var(--u)), 12px);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}
.tv-truth-proof img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: calc(.3 * var(--u));
}
/* narrow stages: no room beside the photo */
@container (aspect-ratio < 1.25 / 1) {
  .tv-truth-proof { display: none; }
}

/* ---------- motion: only while the pinned scene is on screen and active ---------- */
.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] .tv-truth-color {
  animation: tv-truth-open-x var(--tv-truth-sweep) var(--tv-truth-t0) cubic-bezier(.55, .05, .35, 1) both;
}
.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] [data-sweep="y"] .tv-truth-color { animation-name: tv-truth-open-y; }
.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] [data-sweep="up"] .tv-truth-color { animation-name: tv-truth-open-up; }

.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] .tv-truth-scan {
  animation:
    tv-truth-scan-x var(--tv-truth-sweep) var(--tv-truth-t0) cubic-bezier(.55, .05, .35, 1) both,
    tv-truth-blink var(--tv-truth-sweep) var(--tv-truth-t0) linear both;
}
.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] [data-sweep="y"] .tv-truth-scan { animation-name: tv-truth-scan-y, tv-truth-blink; }
.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] [data-sweep="up"] .tv-truth-scan { animation-name: tv-truth-scan-up, tv-truth-blink; }

.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] .tv-truth-pin {
  animation: tv-truth-pop .45s calc(var(--tv-truth-t0) + var(--tv-truth-sweep) + var(--tv-i) * .14s) cubic-bezier(.34, 1.56, .64, 1) both;
}
.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] .tv-truth-stamp {
  animation: tv-truth-stamp .4s calc(var(--tv-truth-t0) + var(--tv-truth-sweep) + .75s) cubic-bezier(.34, 1.56, .64, 1) both;
}
.HomeLogoStory_pin___jkuM[data-inview="true"] [data-active="true"] .tv-truth-proof {
  animation: tv-truth-proof .55s calc(var(--tv-truth-t0) + var(--tv-truth-sweep) * .6) cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes tv-truth-open-x { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes tv-truth-open-y { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes tv-truth-open-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes tv-truth-scan-x { from { left: 0; } to { left: 100%; } }
@keyframes tv-truth-scan-y { from { top: 0; } to { top: 100%; } }
@keyframes tv-truth-scan-up { from { top: 100%; } to { top: 0; } }
@keyframes tv-truth-blink { 0% { opacity: 0; } 6%, 92% { opacity: 1; } 100% { opacity: 0; } }
@keyframes tv-truth-pop { from { opacity: 0; scale: .4; } to { opacity: 1; scale: 1; } }
@keyframes tv-truth-stamp { from { opacity: 0; scale: 1.8; } to { opacity: 1; scale: 1; } }
@keyframes tv-truth-proof { from { opacity: 0; translate: 30% 0; rotate: 4deg; } to { opacity: 1; translate: 0 0; rotate: -6deg; } }

@media (prefers-reduced-motion: reduce) {
  .tv-truth-rig * { animation: none !important; }
}
