/* Diacenter : parcours « 3 étapes », scènes au trait qui s'animent au survol, focus ou tap (js/journey.js). */

.journey {
  position: relative;
  --card-pad: 20px;
}

/* Le sol commun relie les trois scènes ; il se dessine une fois de gauche à droite. */
.journey__ground {
  position: absolute;
  top: calc(var(--card-pad) + 137px);
  left: 0;
  width: 100%;
  height: 2px;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  --draw-dur: 2.6s;
}

.journey__ground path {
  vector-effect: non-scaling-stroke;
}

.journey__steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 40px);
}

.journey__card {
  display: block;
  height: 100%;
  padding: var(--card-pad);
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

/* Signale que la scène réagit : surface translucide et bord au survol. */
.journey__card:hover,
.journey__card:focus-visible,
.journey__card.is-playing {
  border-color: var(--line-strong);
  background: var(--surface-glass);
}

a.journey__card .journey__title {
  display: inline;
  background-image: linear-gradient(var(--sea), var(--sea));
  background-size: 0 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 250ms var(--ease), color var(--dur) var(--ease);
}

a.journey__card:is(:hover, :focus-visible) .journey__title {
  background-size: 100% 2px;
  color: var(--sea);
}

.scene {
  display: block;
  width: auto;
  height: 150px;
  margin-bottom: 28px;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  --draw-dur: .7s;
}

.scene * {
  transform-box: fill-box;
  transform-origin: center;
}

.scene__accent {
  stroke: var(--sea);
}

.scene__soft {
  stroke: var(--ink-soft);
  stroke-width: 1.25;
}

.scene__dpe {
  stroke-width: 4.5;
  stroke-linecap: butt;
}

.scene__seal {
  stroke: var(--sea);
  fill: var(--surface-mist);
}

.journey__title {
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.journey__card p {
  max-width: 34ch;
  margin-top: 8px;
  color: var(--ink-soft);
}

/* ---------- Étape 1 : le téléphone sonne ---------- */
.s1-phone {
  transform-origin: center bottom;
}

.is-playing .s1-phone {
  animation: s1-ring 520ms ease-in-out;
}

.is-playing .s1-wave {
  transform-origin: left center;
  animation: s1-wave 700ms ease-out 2 both;
}

.is-playing .s1-wave--far {
  animation-delay: 120ms;
}

.s1-bubble {
  transform-origin: right bottom;
}

.is-playing .s1-bubble {
  animation: s1-pop 420ms cubic-bezier(.3, 1.5, .5, 1) 300ms both;
}

@keyframes s1-ring {
  15%, 55% { transform: rotate(-4deg); }
  35%, 75% { transform: rotate(4deg); }
}

@keyframes s1-wave {
  from { opacity: 0; transform: scale(.6); }
}

@keyframes s1-pop {
  from { opacity: 0; transform: scale(.2); }
}

/* ---------- Étape 2 : mesure au télémètre ---------- */
.is-playing .s2-device {
  animation: s2-aim 300ms ease-out;
}

.is-playing .s2-beam {
  animation: s2-trace 450ms ease-out 150ms both;
}

.is-playing .s2-cote {
  animation: s2-trace 450ms ease-out 550ms both;
}

.s2-label {
  fill: var(--ink);
  stroke: none;
  font-size: 10px;
  font-weight: 800;
  opacity: 0;
  transition: opacity 250ms ease;
}

.is-playing .s2-label {
  opacity: 1;
  transition-delay: 850ms;
}

@keyframes s2-aim {
  50% { transform: translateX(3px); }
}

@keyframes s2-trace {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* ---------- Étape 3 : le rapport est remis ---------- */
.is-playing .s3-doc {
  animation: s3-drop 450ms cubic-bezier(.2, .8, .3, 1);
}

.is-playing .scene__dpe {
  animation: s2-trace 300ms ease-out both;
  animation-delay: calc(350ms + var(--i) * 70ms);
}

.is-playing .scene__seal {
  animation: s3-stamp 380ms cubic-bezier(.3, 1.4, .5, 1) 950ms both;
}

@keyframes s3-drop {
  from { opacity: .3; transform: translateY(-14px) rotate(-3deg); }
}

@keyframes s3-stamp {
  from { opacity: 0; transform: scale(1.9); }
  70% { opacity: 1; transform: scale(.9); }
}

@media (max-width: 767px) {
  .journey__ground {
    display: none;
  }

  .journey__steps {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .journey {
    --card-pad: 16px;
  }

  .scene {
    height: 120px;
    margin-bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-playing :is(.s1-phone, .s1-wave, .s1-bubble, .s2-device, .s2-beam, .s2-cote, .s3-doc, .scene__dpe, .scene__seal) {
    animation: none;
  }

  .is-playing .s2-label {
    transition-delay: 0s;
  }
}
