/* ==========================================================================
   Platform page · 7 — A day in the field app
   The wireframe's four stops, with a line running left to right through
   the day in the app's own status colours:
       ●━━━━━━━━━━━━━━●━━━━━━━━━━━━━━●━━━━━━━━━━━━━━●━━━━━━━━━━━━━━
       7:30 online     9:15 no signal  12:40 weak     5:10 synced
       (green)         (orange)        (blue)         (green)
   Colours blend across the gaps so it reads as one day. Node positions
   and colour stops use the same column maths (--p1..--p3).
   Micro-animation (CSS only):
     arrival   the line draws; each node pops as the line reaches it
     loop      the officer rides the day on a small motorbike; the box on
               the rack is the day's data: brisk on green, slow and waiting
               (orange) through no signal, blue on weak signal, green to
               the end, then fades; every 11s
     hover     the stop's node swells
   Prefixed .dy- and scoped to .dy.
   ========================================================================== */

.dy {
  --dy-full: var(--good);
  --dy-none: var(--warn);
  --dy-weak: var(--accent);
  --dy-gap:  clamp(20px, 2.4vw, 32px);
  --dy-draw: 1.6s;

  position: relative;
  padding: clamp(72px, 9vw, 120px) var(--page-px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.dy-inner { max-width: var(--container); margin: 0 auto; }
.dy-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: clamp(36px, 4.5vw, 56px); }
.dy-title { max-width: 760px; font-size: var(--fs-section-title); font-weight: 600; line-height: 1.12; letter-spacing: -0.03em; text-wrap: balance; }
.dy-title em { font-style: normal; color: var(--accent); }
.dy-sub { font-size: var(--fs-section-sub); line-height: 1.6; color: var(--text-secondary); }

/* ─── The track: line, packet, stops ──────────────────────────────────── */
.dy-track {
  --p1: calc((100% + var(--dy-gap)) * 1 / 4);
  --p2: calc((100% + var(--dy-gap)) * 2 / 4);
  --p3: calc((100% + var(--dy-gap)) * 3 / 4);
  position: relative;
}
.dy-line {
  position: absolute;
  top: 5px; left: 0; right: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--dy-full) 0, var(--dy-full) calc(var(--p1) - var(--dy-gap)),
    var(--dy-none) var(--p1), var(--dy-none) calc(var(--p2) - var(--dy-gap)),
    var(--dy-weak) var(--p2), var(--dy-weak) calc(var(--p3) - var(--dy-gap)),
    var(--dy-full) var(--p3), var(--dy-full) 100%);
  opacity: 0.85;
}

.dy-day {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: var(--dy-gap);
}
.dy-stop { --c: var(--dy-full); position: relative; min-width: 0; padding-top: 30px; }
.dy-stop[data-signal="none"] { --c: var(--dy-none); }
.dy-stop[data-signal="weak"] { --c: var(--dy-weak); }
/* the node */
.dy-stop::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 12px; height: 12px;
  background: var(--c);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--surface);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dy-stop:hover::before { transform: scale(1.35); }

.dy-card { padding-right: 12px; }
.dy-time {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--c);
}
.dy-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.dy-bars i { display: block; width: 3px; background: currentColor; border-radius: 1px; }
.dy-bars i:nth-child(1) { height: 3.5px; }
.dy-bars i:nth-child(2) { height: 6px; }
.dy-bars i:nth-child(3) { height: 8.5px; }
.dy-bars i:nth-child(4) { height: 11px; }
.dy-stop[data-signal="none"] .dy-bars i { opacity: 0.3; }
/* no signal: the bars keep looking for one */
.dy-stop[data-signal="none"] .dy-bars i:first-child { animation: dy-search 2.4s ease-in-out infinite; }
@keyframes dy-search { 50% { opacity: 0.9; } }
.dy-stop[data-signal="weak"] .dy-bars i:nth-child(n+3) { opacity: 0.25; }

.dy-name { margin-top: 12px; font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; color: var(--text-primary); }
.dy-text { margin-top: 6px; font-size: 14.5px; line-height: 1.6; color: var(--text-secondary); }

/* the officer on a motorbike rides the day; the box on the rack is the
   day's data, coloured by the signal (green → orange waiting → blue → green) */
.dy-pkt {
  position: absolute;
  top: -22px; left: 0;            /* wheels sit on the line */
  z-index: 2;
  width: 44px; height: 28px;
  margin-left: -26px;
  color: var(--dy-full);
  opacity: 0;
  pointer-events: none;
}
.dy-bike { display: block; width: 100%; height: 100%; overflow: visible; }
.dy-bike path, .dy-bike circle { fill: none; stroke: var(--text-primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dy-bike .dy-bike-seat { stroke-width: 2.6; }
.dy-bike .dy-bike-engine { stroke-width: 3; stroke: var(--text-secondary); }
.dy-bike .dy-bike-head { fill: var(--text-primary); stroke: none; }
.dy-bike .dy-bike-box { fill: currentColor; stroke: none; }
.dy-wheel { animation: dy-spin 0.5s linear infinite; }
.dy-bike-body { animation: dy-bob 0.32s ease-in-out infinite alternate; }
@keyframes dy-spin { to { transform: rotate(360deg); } }
@keyframes dy-bob  { to { transform: translateY(-0.6px); } }

.dy-track.is-visible .dy-pkt { animation: dy-travel 11s ease-in-out calc(var(--dy-draw) + 0.8s) infinite; }
@keyframes dy-travel {
  0%   { left: 0; opacity: 0; color: var(--dy-full); }
  3%   { opacity: 1; }
  16%  { left: var(--p1); color: var(--dy-full); }
  19%  { color: var(--dy-none); }
  46%  { left: calc(var(--p2) - 6px); color: var(--dy-none); }
  50%  { left: var(--p2); color: var(--dy-weak); }
  67%  { left: var(--p3); color: var(--dy-full); }
  84%  { left: 100%; opacity: 1; }
  90%, 100% { left: 100%; opacity: 0; color: var(--dy-full); }
}

/* ─── Arrival: the line draws, nodes pop as it reaches them ───────────── */
html.has-js .dy-track:not(.is-visible) .dy-line { clip-path: inset(-4px 100% -4px 0); }
html.has-js .dy-track:not(.is-visible) .dy-stop::before { transform: scale(0); }
html.has-js .dy-track:not(.is-visible) .dy-card { opacity: 0; transform: translateY(6px); }
.dy-line { clip-path: inset(-4px 0 -4px 0); }
.dy-track.is-visible .dy-line { transition: clip-path var(--dy-draw) linear 0.2s; }
.dy-track.is-visible .dy-stop::before { transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) calc(0.2s + var(--i) * var(--dy-draw) / 4); }
.dy-track.is-visible .dy-card { transition: opacity 0.5s ease calc(0.3s + var(--i) * var(--dy-draw) / 4), transform 0.5s var(--ease-out) calc(0.3s + var(--i) * var(--dy-draw) / 4); }
.dy-track.is-visible .dy-stop:hover::before { transition-delay: 0s; }

/* ─── Responsive: the day wraps, so the line steps aside ──────────────── */
@media (max-width: 900px) {
  .dy-day { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 32px; }
  .dy-line, .dy-pkt { display: none; }
  .dy-stop { padding-top: 0; border-top: 2px solid var(--c); padding-top: 16px; }
  .dy-stop::before { display: none; }
}
@media (max-width: 560px) {
  .dy-day { grid-template-columns: minmax(0, 1fr); row-gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .dy-pkt { display: none; }
  .dy-wheel, .dy-bike-body { animation: none; }
  .dy-line, .dy-stop::before, .dy-card { transition: none !important; }
  .dy-stop[data-signal="none"] .dy-bars i:first-child { animation: none; }
}
