/* Remote Gravity hero story: one place, verified then watched.
   Default = the finished record (no script / reduced motion). .anim-ready sets the start;
   .is-playing runs a 14 s timeline:
   0.4 officer travels · 3.0 confirmed 18 m · 3.6 photo · 4.4 address confirmed (Current)
   5.4–7.4 days 01→60 · 7.6 borrower confirms by link · 8.6–9.6 days 60→74
   9.8 no response (Unconfirmed) · 10.4–12.6 second visit · 12.8 business not operating (Changed) */

@property --day {
  syntax:'<integer>';
  inherits:false;
  initial-value:74
}

.story {
  background:#fff;
  color:var(--ink);
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden
}

.story-head {
  display:flex;
  align-items:center;
  gap:8px 14px;
  flex-wrap:wrap;
  padding:12px 16px;
  border-bottom:1px solid var(--line-soft)
}

.story-title {
  flex:1 1 auto;
  font-size:15px;
  line-height:20px;
  font-weight:600
}

.story-title .mono {
  font-size:13px;
  font-weight:500
}

.story-day {
  --day:74;
  counter-reset:day var(--day);
  font-size:12px;
  line-height:16px;
  font-weight:500;
  letter-spacing:.04em;
  color:var(--ink-2);
  font-variant-numeric:tabular-nums
}

.story-day::before {
  content:"DAY " counter(day, decimal-leading-zero)
}

.story-state {
  display:grid;
  justify-items:end
}

.story-chip {
  grid-area:1/1
}

.chip-current,.chip-un {
  display:none
}

.story-map {
  position:relative;
  line-height:0
}

.story-map svg {
  display:block
}

.ring,.officer,.pin,.dist {
  transform-box:fill-box
}

.ring {
  opacity:0;
  transform-origin:center
}

.pin,.dist {
  transform-origin:50% 100%
}

.officer {
  opacity:0;
  transform-box:view-box;
  transform-origin:0 0
}

.story-photos {
  position:absolute;
  top:10px;
  right:10px;
  width:34%;
  aspect-ratio:4/3
}

.story-photo {
  position:absolute;
  inset:0;
  margin:0;
  border-radius:6px;
  border-color:#fff;
  box-shadow:0 4px 14px rgba(18,32,58,.22)
}

.story-photo .stamp {
  padding:4px 7px;
  font-size:10px;
  line-height:13px
}

.story-box {
  position:absolute;
  left:24%;
  top:12%;
  width:46%;
  height:50%;
  border:2px solid #fff;
  box-shadow:0 0 0 1px rgba(18,32,58,.45)
}

.story-box span {
  position:absolute;
  top:-2px;
  left:-2px;
  transform:translateY(-100%);
  background:var(--brand);
  color:var(--on-brand);
  font:500 9px/12px var(--mono);
  padding:1px 4px;
  letter-spacing:.05em
}

.story-log {
  margin:0;
  padding:6px 16px 4px;
  list-style:none
}

.lg {
  display:grid;
  grid-template-columns:118px minmax(0,1fr);
  gap:4px 12px;
  padding:9px 0;
  border-top:1px solid var(--line-soft);
  font-size:14px;
  line-height:20px
}

.lg:first-child {
  border-top:0
}

.lg-t {
  font-size:11.5px;
  line-height:20px;
  color:var(--ink-3)
}

.lg-x b {
  font-weight:600
}

.story-foot {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:10px 16px;
  border-top:1px solid var(--line-soft);
  font-size:12px;
  line-height:16px;
  color:var(--ink-3)
}

.story-replay {
  padding:4px 10px;
  border:1px solid #8F8A7F;
  border-radius:6px;
  background:#fff;
  color:var(--heading);
  font:600 12px/16px var(--sans);
  cursor:pointer
}

.story-replay:focus-visible {
  outline:2px solid var(--navy);
  outline-offset:2px
}

/* Start state */
.story.anim-ready .story-day { --day:1 }
.story.anim-ready .story-chip { display:inline-block; opacity:0 }
.story.anim-ready .pin,
.story.anim-ready .dist,
.story.anim-ready .story-photo,
.story.anim-ready .story-box,
.story.anim-ready .lg { opacity:0 }

/* Keyframes */
@keyframes st-in { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:none } }
@keyframes st-fade { from { opacity:0 } to { opacity:1 } }
@keyframes st-out { to { opacity:0 } }
@keyframes st-pop { 0% { opacity:0; transform:scale(.4) } 70% { opacity:1; transform:scale(1.08) } 100% { opacity:1; transform:none } }
@keyframes st-drop { 0% { opacity:0; transform:translateY(-16px) } 70% { opacity:1; transform:translateY(2px) } 100% { opacity:1; transform:none } }
@keyframes st-ring { 0% { opacity:.9; transform:scale(.6) } 100% { opacity:0; transform:scale(3.2) } }
@keyframes st-days {
  0%, 39.7% { --day:1 }
  54.4%, 63.2% { --day:60 }
  70.6%, 100% { --day:74 }
}
/* Visit 1: down the side street, then along Example Street to the address */
@keyframes st-route-a {
  0% { transform:translate(150px,-12px) }
  62% { transform:translate(150px,170px) }
  100% { transform:translate(232px,170px) }
}
/* Visit 2: along Demo Lane, down the cross street, then west to the address */
@keyframes st-route-b {
  0% { transform:translate(572px,70px) }
  45% { transform:translate(330px,70px) }
  75% { transform:translate(330px,170px) }
  100% { transform:translate(250px,170px) }
}
@keyframes st-photo-in { 0% { opacity:0; transform:translateY(10px) scale(.92) } 100% { opacity:1; transform:none } }
@keyframes st-photo-back { to { transform:translate(-10px,-8px) scale(.94); opacity:.55 } }

/* Timeline */
.story.is-playing .story-day { animation:st-days 13.6s linear both }

.story.is-playing .officer-a { animation:st-fade .3s .3s both, st-route-a 2.6s cubic-bezier(.45,0,.4,1) .4s both, st-out .4s 5s forwards }
.story.is-playing .pin { animation:st-drop .5s 3s both }
.story.is-playing .dist { animation:st-pop .3s 3.3s both }
.story.is-playing .photo-1 { animation:st-photo-in .45s 3.6s both, st-photo-back .5s 12.6s forwards }
.story.is-playing .lg-1 { animation:st-in .4s 3s both }
.story.is-playing .lg-2 { animation:st-in .4s 4.4s both }
.story.is-playing .chip-current { animation:st-fade .25s 4.4s both, st-out .2s 9.8s forwards }

.story.is-playing .ring-1 { animation:st-ring 1.1s 7.6s both }
.story.is-playing .ring-2 { animation:st-ring 1.1s 8s both }
.story.is-playing .lg-3 { animation:st-in .4s 7.7s both }

.story.is-playing .ring-3 { animation:st-ring 1.1s 9.6s both }
.story.is-playing .ring-4 { animation:st-ring 1.1s 10s both }
.story.is-playing .lg-4 { animation:st-in .4s 9.8s both }
.story.is-playing .chip-un { animation:st-fade .25s 9.8s both, st-out .2s 12.8s forwards }

.story.is-playing .officer-b { animation:st-fade .3s 10.3s both, st-route-b 2.2s cubic-bezier(.45,0,.4,1) 10.4s both, st-out .4s 13.4s forwards }
.story.is-playing .photo-2 { animation:st-photo-in .45s 12.8s both }
.story.is-playing .story-box { animation:st-pop .35s 13.2s both }
.story.is-playing .lg-5 { animation:st-in .4s 12.8s both }
.story.is-playing .chip-ch { animation:st-pop .35s 12.9s both }

/* Finished still: photo 1 sits behind photo 2 */
.story:not(.is-playing) .photo-1 { transform:translate(-10px,-8px) scale(.94); opacity:.55 }
.story.anim-ready:not(.is-playing) .photo-1 { transform:none; opacity:0 }

@media (max-width:520px) {
  .lg { grid-template-columns:1fr; gap:0 }
  .story-map { padding-bottom:12px; background:#EFEDE7 }
  .story-photos { position:relative; top:auto; right:auto; width:62%; margin:0 auto }
}

/* Pause is scoped to this illustration and keeps its current frame. */
.story.is-paused *, .story.is-paused *::before, .story.is-paused *::after {
  animation-play-state:paused !important
}
@media (prefers-reduced-motion:reduce) {
  .story *, .story *::before, .story *::after { animation:none !important }
}
