/* ---- SCROLLVERHAAL "ZO WERKT HET" ----
   Een telefoon blijft in beeld staan terwijl je scrolt; per stap verandert het scherm.
   js/story.js zet data-step (0-3) en een paar CSS-variabelen op .story. */

.story {
  --story-nav: 64px;
  --hold: 0;        /* 0..1: hoe ver de alarmknop is gevuld */
  --route: 0;       /* 0..1: hoe ver de stip over de route is */
  background: var(--dark);
  color: #fff;
  position: relative;
}
.story-track {
  height: 480vh;
  position: relative;
}
.story-stage {
  position: sticky;
  top: var(--story-nav);
  height: calc(100vh - var(--story-nav));
  height: calc(100svh - var(--story-nav));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  overflow: hidden;
}

/* ---- Tekst ---- */
.story-copy {
  position: relative;
  min-height: 21rem;
}
.story-kicker {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7fd3a8;
  margin-bottom: 1rem;
}
.story-line {
  position: absolute;
  inset: 2.5rem 0 auto 0;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
.story-line h2 {
  font-size: clamp(2.2rem, 5.2vw, 4rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  text-wrap: balance;
}
.story-line p {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  color: rgba(255, 255, 255, 0.72);
  max-width: 30rem;
  line-height: 1.55;
}
.story[data-step="0"] .story-line[data-step="0"],
.story[data-step="1"] .story-line[data-step="1"],
.story[data-step="2"] .story-line[data-step="2"],
.story[data-step="3"] .story-line[data-step="3"] {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.story-try {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
}

.story-dots {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
}
.story-dots span {
  width: 28px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.3s ease;
}
.story[data-step="0"] .story-dots span:nth-child(-n + 1),
.story[data-step="1"] .story-dots span:nth-child(-n + 2),
.story[data-step="2"] .story-dots span:nth-child(-n + 3),
.story[data-step="3"] .story-dots span:nth-child(-n + 4) {
  background: #7fd3a8;
}

/* ---- Beeld: telefoon met contacten eromheen ---- */
.story-visual {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-phone {
  position: relative;
  width: 270px;
  height: 560px;
  border-radius: 46px;
  background: #0b0f16;
  padding: 11px;
  box-shadow:
    0 0 0 2px #2a3342,
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 120px rgba(127, 211, 168, 0.08);
  transform: scale(var(--phone-scale, 1));
  transform-origin: center;
  z-index: 2;
}
.story-phone::before {
  /* camera-eiland */
  content: '';
  position: absolute;
  top: 20px;
  left: 50%;
  width: 84px;
  height: 24px;
  margin-left: -42px;
  border-radius: 14px;
  background: #000;
  z-index: 5;
}
.story-screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 36px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
.story-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.story-view.is-visible {
  opacity: 1;
}
/* Onzichtbare schermen mogen de knop niet afdekken */
.story-view:not(.is-visible) {
  pointer-events: none;
}

/* App-kop zoals in de app */
.story-app-head {
  padding: 46px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background 0.4s ease, color 0.4s ease;
}
.story-app-head img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 3px;
}
.story-app-name {
  font-weight: 900;
  font-size: 1rem;
  line-height: 1.1;
}
.story-app-sub {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}
.story.is-alarm .story-app-head {
  background: var(--red);
  color: #fff;
  border-color: var(--red-dk);
}
.story.is-alarm .story-app-sub {
  color: rgba(255, 255, 255, 0.85);
}

/* Alarmknop met vulring */
.story-alarm-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
}
.story-alarm-btn {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  box-shadow: inset 0 0 0 6px var(--green-dk), 0 10px 30px rgba(23, 109, 74, 0.35);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: background 0.35s ease, box-shadow 0.35s ease, transform 0.15s ease;
}
.story-alarm-btn:active {
  transform: scale(0.97);
}
.story-alarm-btn:focus-visible {
  outline: 3px solid #7fd3a8;
  outline-offset: 6px;
}
.story-alarm-ring {
  position: absolute;
  inset: -12px;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  transform: rotate(-90deg);
  pointer-events: none;
}
.story-alarm-ring circle {
  fill: none;
  stroke-width: 6;
}
.story-alarm-ring .track {
  stroke: rgba(23, 109, 74, 0.15);
}
.story-alarm-ring .fill {
  stroke: var(--red);
  /* Leeg = onzichtbaar (anders blijft het ronde uiteinde als puntje staan). */
  opacity: calc(var(--hold) * 100);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--hold) * 100);
}
.story-alarm-label {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.story-alarm-sub {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.9;
  text-transform: uppercase;
}
.story.is-alarm .story-alarm-btn {
  background: var(--red);
  box-shadow: inset 0 0 0 6px var(--red-dk), 0 0 0 0 rgba(198, 40, 40, 0.5);
  animation: story-pulse 1.6s ease-out infinite;
}
.story .when-active,
.story.is-alarm .when-idle {
  display: none;
}
.story.is-alarm .when-active {
  display: inline;
}
.story.is-alarm .story-alarm-ring .track {
  stroke: transparent;
}
@keyframes story-pulse {
  0% { box-shadow: inset 0 0 0 6px var(--red-dk), 0 0 0 0 rgba(198, 40, 40, 0.45); }
  100% { box-shadow: inset 0 0 0 6px var(--red-dk), 0 0 0 28px rgba(198, 40, 40, 0); }
}
.story-alarm-status {
  width: 100%;
  min-height: 92px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.74rem;
  line-height: 1.45;
}
.story-alarm-status strong {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 2px;
}
.story-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.story-status-row.is-on {
  opacity: 1;
  transform: none;
  color: var(--text);
}
.story-status-row::before {
  content: '✓';
  color: var(--green);
  font-weight: 900;
}

/* Kaart met live locatie */
.story-map {
  position: relative;
  flex: 1;
  background: #e7eee9;
}
.story-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.story-live-pill {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.74rem;
  font-weight: 800;
  box-shadow: 0 6px 20px rgba(17, 24, 32, 0.15);
}
.story-live-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.6);
  animation: story-blink 1.4s ease-out infinite;
}
@keyframes story-blink {
  0% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.6); }
  100% { box-shadow: 0 0 0 8px rgba(198, 40, 40, 0); }
}
.story-map-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  background: var(--surface);
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 0.74rem;
  box-shadow: 0 8px 24px rgba(17, 24, 32, 0.16);
}
.story-map-card strong {
  display: block;
  font-size: 0.82rem;
}
.story-map-card span {
  color: var(--muted);
}

/* Veilig */
.story-safe {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(180deg, #eef7f2 0%, var(--bg) 100%);
}
.story-safe-check {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 3.4rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 36px rgba(23, 109, 74, 0.35);
  transform: scale(0.6);
  transition: transform 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.story[data-step="3"] .story-safe-check {
  transform: scale(1);
}
.story-safe h3 {
  font-size: 1.35rem;
  font-weight: 900;
}
.story-safe p {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Contacten die gewaarschuwd worden */
.story-contacts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.story-contact {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--text);
  border-radius: 16px;
  padding: 10px 14px 10px 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(var(--from-x, 0), 16px) scale(0.92);
  transition: opacity 0.45s ease, transform 0.55s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.story-contact.is-on {
  opacity: 1;
  transform: none;
}
.story-contact b {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
}
.story-contact strong {
  display: block;
  font-size: 0.86rem;
  line-height: 1.2;
}
.story-contact span {
  font-size: 0.74rem;
  color: var(--muted);
}
.story-contact:nth-child(1) { top: 16%; left: -2%; --from-x: 40px; }
.story-contact:nth-child(2) { top: 44%; right: 4%; --from-x: -40px; }
.story-contact:nth-child(3) { bottom: 14%; left: 2%; --from-x: 40px; }
.story-contact:nth-child(1) b { background: #7c3aed; }
.story-contact:nth-child(2) b { background: #0e7490; }
.story-contact:nth-child(3) b { background: #b45309; }

/* ---- 3D: de telefoon draait naar je toe als het alarm gaat, de meldingen spatten eruit ---- */
.story-visual {
  /* Alleen perspectief, geen preserve-3d: dan blijft de telefoon gewoon bovenop liggen en is de knop
     overal aan te raken (anders valt de achterkant van de gedraaide telefoon "achter" dit vlak). */
  perspective: 1400px;
}
.story-phone {
  transform: scale(var(--phone-scale, 1)) rotateY(calc((1 - var(--hold)) * -22deg + var(--turn, 0deg)))
    rotateX(calc((1 - var(--hold)) * 9deg)) translateZ(calc(var(--hold) * 40px));
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.25, 1);
}
.story[data-step="2"] .story-phone { --turn: 14deg; }
.story[data-step="3"] .story-phone { --turn: -8deg; }
.story-contact {
  transform: translate(var(--burst-x, 0), var(--burst-y, 0)) scale(0.3);
  transition: opacity 0.35s ease, transform 0.75s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.story-contact.is-on {
  transform: scale(1.04);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}
.story-contact:nth-child(1) { --burst-x: 150px; --burst-y: 140px; }
.story-contact:nth-child(2) { --burst-x: -150px; --burst-y: 0; }
.story-contact:nth-child(3) { --burst-x: 150px; --burst-y: -120px; }

/* Golven en een rode schokgolf als het alarm afgaat */
.story-waves,
.story-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 1;
}
.story-waves i {
  position: absolute;
  left: -170px;
  top: -170px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  border: 3px solid rgba(198, 40, 40, 0.8);
  opacity: 0;
}
.story.is-alarm[data-step="1"] .story-waves i {
  animation: story-wave 2.6s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
.story-waves i:nth-child(2) { animation-delay: 0.85s !important; }
.story-waves i:nth-child(3) { animation-delay: 1.7s !important; }
@keyframes story-wave {
  0% { transform: scale(0.5); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}
.story-burst i {
  position: absolute;
  left: -200px;
  top: -200px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(198, 40, 40, 0) 55%, rgba(198, 40, 40, 0.55) 80%, rgba(198, 40, 40, 0) 100%);
  opacity: 0;
}
.story.is-alarm .story-burst i {
  animation: story-burst 1s cubic-bezier(0.1, 0.7, 0.3, 1) 1;
}
@keyframes story-burst {
  0% { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(3.2); opacity: 0; }
}
.story.is-alarm .story-screen {
  animation: story-kick 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 1;
}
@keyframes story-kick {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ---- Telefoon (smal scherm): tekst boven, telefoon eronder ---- */
@media (max-width: 820px) {
  .story-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-items: start;
    gap: 0.5rem;
    padding-top: 1.25rem;
  }
  .story-copy {
    min-height: 11rem;
  }
  .story-kicker {
    margin-bottom: 0.25rem;
    font-size: 0.72rem;
  }
  .story-line {
    inset: 1.4rem 0 auto 0;
  }
  .story-line h2 {
    font-size: 2rem;
    margin-bottom: 0.4rem;
  }
  .story-line p {
    font-size: 0.98rem;
  }
  .story-try {
    margin-top: 0.6rem;
    font-size: 0.85rem;
  }
  .story-dots {
    display: none;
  }
  .story-visual {
    align-items: flex-start;
  }
  .story-phone {
    transform-origin: top center;
  }
  .story-contact {
    min-width: 0;
    padding: 7px 10px 7px 7px;
  }
  .story-contact b {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }
  .story-contact:nth-child(1) { top: 6%; left: 0; --burst-x: 90px; --burst-y: 120px; }
  .story-contact:nth-child(2) { top: 30%; right: 0; --burst-x: -90px; --burst-y: 40px; }
  .story-contact:nth-child(3) { top: 54%; left: 0; bottom: auto; --burst-x: 90px; --burst-y: -60px; }
}

/* ---- Minder beweging: geen golven of knipperen; de stappen wisselen gewoon ---- */
@media (prefers-reduced-motion: reduce) {
  .story-line,
  .story-view,
  .story-contact,
  .story-status-row,
  .story-safe-check {
    transition: none;
  }
  .story.is-alarm .story-alarm-btn,
  .story-live-pill i,
  .story.is-alarm .story-screen {
    animation: none;
  }
  .story-waves,
  .story-burst {
    display: none;
  }
  .story-phone {
    transform: scale(var(--phone-scale, 1));
    transition: none;
  }
  .story-contact,
  .story-contact.is-on {
    transform: none;
  }
}

/* Alleen voor schermlezers */
.story .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* De meldingen zweven voor de telefoon */
.story-contacts {
  transform: translateZ(90px);
}
@media (prefers-reduced-motion: reduce) {
  .story-contacts {
    transform: none;
  }
}
