/* =====================================================================
   PIKO — mascotte + voyage d'un colis. Aucune dépendance.
   Extrait et généralisé depuis docs/animation-statuts/style.css (Takaful).
   Toutes les variables sont préfixées --pk- : surchargez-les pour la charte
   graphique de l'autre application sans toucher au reste du fichier.
   ===================================================================== */
:root {
  --pk-bg: #f1f4f8; --pk-card: #ffffff; --pk-ink: #1a2230; --pk-muted: #566478; --pk-line: #d8dfe8;
  --pk-primary: #1b57b5; --pk-orange: #e8730c; --pk-orange-ink: #ffffff;
  --pk-ok: #17803f; --pk-warn: #c4600c; --pk-ko: #c42e33; --pk-info: #1f6fd0;
  --pk-bubble: #fff7ea; --pk-bubble-line: #f2c58f;
  --pk-fly-ms: 950ms;           /* durée du vol de Piko d'un point à l'autre */
}
@media (prefers-color-scheme: dark) {
  :root {
    --pk-bg: #11161d; --pk-card: #19202a; --pk-ink: #e9eef5; --pk-muted: #a3b0c2; --pk-line: #2b3646;
    --pk-primary: #6aa5ff; --pk-orange: #ff9b3d; --pk-orange-ink: #1b1000;
    --pk-ok: #45c47f; --pk-warn: #f29a52; --pk-ko: #f27479; --pk-info: #66aaf5;
    --pk-bubble: #2a2218; --pk-bubble-line: #6b4a24;
  }
}

/* ---------- Scène : le conteneur est la référence de position de Piko ---------- */
.pk-journey { position: relative; color: var(--pk-ink); font: 14px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; }
.pk-stage { position: relative; background: var(--pk-card); border: 1px solid var(--pk-line); border-radius: 12px; padding: 8px; }
.pk-stage svg.pk-route { display: block; width: 100%; height: auto; }

/* ---------- Piko flottant : la position est une simple transform: translate(x,y) ----------
   La transition CSS fait le vol ; le JS ne fait qu'écrire la destination. */
.piko-fly { position: absolute; left: 0; top: 0; z-index: 31; transform: translate(40px, 40px);
  transition: transform var(--pk-fly-ms) cubic-bezier(.45, .05, .25, 1); pointer-events: none; }
.piko-wrap { flex: 0 0 auto; position: relative; }
.piko-svg { display: block; width: 78px; height: auto; aspect-ratio: 128 / 140; overflow: visible;
  animation: pk-bob 3s ease-in-out infinite; transform-origin: center 70%; filter: drop-shadow(0 8px 8px #c6612f33); }
.piko-fly.flying .piko-svg { animation: pk-fly var(--pk-fly-ms) ease-in-out 1; }

/* Expressions : un seul <g data-face> visible à la fois */
.expression { display: none; }
.expression.active { display: block; animation: pk-face-pop .24s ease-out; }
.eye-pair { transform-box: fill-box; transform-origin: center; animation: pk-blink 6.5s ease-in-out infinite; }

/* Le bras droit pointe vers la cible : --aim est écrit par piko.js (degrés) */
.arm-right { transform-origin: 101px 94px; transform: rotate(var(--aim, 0deg)); transition: transform .6s ease; }

/* Réactions selon l'humeur (data-emotion posé sur .piko-wrap) */
.piko-wrap[data-emotion="laugh"] .piko-svg, .piko-wrap[data-emotion="silly"] .piko-svg { animation: pk-jump .45s ease-in-out 3; }
.piko-wrap[data-emotion="grumpy"] .piko-svg { animation: pk-huff .35s ease-in-out 3; }
.piko-wrap[data-emotion="surprise"] .piko-svg { animation: pk-pop .5s ease-in-out 2; }

@keyframes pk-bob { 0%,100% { transform: translateY(0) rotate(-1.2deg); } 50% { transform: translateY(-5px) rotate(1.2deg); } }
@keyframes pk-fly { 0% { transform: rotate(0); } 30% { transform: translateY(-12px) rotate(-10deg); } 70% { transform: translateY(-6px) rotate(8deg); } 100% { transform: rotate(0); } }
@keyframes pk-face-pop { 0% { opacity: .4; transform: scale(.86); transform-origin: 65px 65px; } 100% { opacity: 1; transform: scale(1); } }
@keyframes pk-blink { 0%,44%,48%,100% { transform: scaleY(1); } 46% { transform: scaleY(.08); } }
@keyframes pk-jump { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
@keyframes pk-huff { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
@keyframes pk-pop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.09); } }

/* ---------- Route, stations, colis (SVG générés par journey.js) ---------- */
.pk-route .pk-road { fill: none; stroke: var(--pk-line); stroke-width: 10; stroke-linecap: round; }
.pk-route .pk-road-dash { fill: none; stroke: var(--pk-card); stroke-width: 2; stroke-dasharray: 2 12; stroke-linecap: round; }
.pk-route .pk-done { fill: none; stroke: var(--pk-ok); stroke-width: 10; stroke-linecap: round; opacity: .85; }
.pk-station .pk-dot { fill: var(--pk-card); stroke: var(--pk-muted); stroke-width: 3; transition: stroke .3s, fill .3s; }
.pk-station.visited .pk-dot { stroke: var(--pk-ok); fill: color-mix(in srgb, var(--pk-ok) 18%, var(--pk-card)); }
.pk-station.current .pk-dot { stroke: var(--pk-orange); stroke-width: 4; animation: pk-pulse 1.2s ease-in-out infinite; }
.pk-station text { fill: var(--pk-ink); font-size: 12px; font-weight: 600; text-anchor: middle; }
.pk-station text.pk-sub { fill: var(--pk-muted); font-weight: 400; font-size: 11px; }
.pk-station .pk-ico { font-size: 16px; text-anchor: middle; dominant-baseline: central; fill: var(--pk-ink); }
@keyframes pk-pulse { 0%,100% { stroke-width: 4; } 50% { stroke-width: 8; } }

.pk-parcel .pk-box { fill: #d9a45b; stroke: #8a5a1e; stroke-width: 2; transition: fill .3s; }
.pk-parcel .pk-tape { fill: #f3dba8; }
.pk-parcel .pk-face circle { fill: #3a2a22; }
.pk-parcel .pk-face path { fill: none; stroke: #3a2a22; stroke-width: 1.8; stroke-linecap: round; }
.pk-parcel .pk-label { fill: var(--pk-ink); font-size: 11px; font-weight: 700; text-anchor: middle; }
.pk-parcel.moving .pk-inner { animation: pk-hop .5s ease-in-out infinite; }
@keyframes pk-hop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ---------- Bulle de guidage (HTML) ---------- */
.pk-guide { margin-top: 8px; background: var(--pk-bubble); border: 2px solid var(--pk-bubble-line); border-radius: 12px; padding: 8px 10px; display: grid; gap: 5px; }
.pk-title { font-weight: 800; font-size: 15px; background: var(--pk-orange); color: var(--pk-orange-ink); border-radius: 8px; padding: 2px 9px; }
.pk-title.pulse { animation: pk-title-pulse .9s ease-in-out 4; }
@keyframes pk-title-pulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--pk-orange) 70%, transparent); } 50% { transform: scale(1.05); box-shadow: 0 0 0 10px transparent; } }
.pk-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: start; }
.pk-lab { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--pk-muted); padding-top: 2px; }
.pk-row p { margin: 0; }
.pk-row.now p { font-weight: 600; }
.pk-row:has(p:empty) { display: none; }
.pk-nav { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.pk-btn { border: 1px solid var(--pk-line); background: var(--pk-card); color: var(--pk-ink); border-radius: 8px; padding: 5px 12px; cursor: pointer; font: inherit; min-height: 32px; }
.pk-btn:disabled { opacity: .45; cursor: default; }
.pk-btn.primary { background: var(--pk-primary); color: #fff; border-color: transparent; font-weight: 700; }
.pk-btn.primary.pulse { animation: pk-btn-pulse 1.4s ease-in-out infinite; }   /* halo seul : la cible de clic ne bouge pas */
@keyframes pk-btn-pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pk-primary) 60%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
.pk-steps { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pk-steps i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--pk-line); background: var(--pk-card); }
.pk-steps i.done { background: var(--pk-ok); border-color: var(--pk-ok); }
.pk-steps i.cur { border-color: var(--pk-orange); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pk-orange) 30%, transparent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--pk-primary) 70%, transparent); outline-offset: 2px; }

/* ---------- Accessibilité : pas de mouvement si l'utilisateur le demande ---------- */
@media (prefers-reduced-motion: reduce) {
  .piko-fly { transition: none; }
  .piko-svg, .piko-fly.flying .piko-svg, .eye-pair, .pk-parcel.moving .pk-inner,
  .pk-station.current .pk-dot, .pk-title.pulse, .pk-btn.primary.pulse { animation: none !important; }
  .arm-right { transition: none; }
}
@media (max-width: 640px) { .pk-row { grid-template-columns: 1fr; gap: 0; } .piko-svg { width: 58px; } }
