/* Route card Phuket → DLT Krabi (template-parts/route-map.php, assets/js/route-map.js).
   The default state is the finished drawing; .is-armed (set by JS) rewinds it for the animation. */

.pdl-route {
  --route-sea: #EAF4F3;
  --route-land: #F4EFE4;
  --route-land-edge: #E4D9C3;
  --route-track: var(--slate-200);
  --route-line: var(--emerald-600);
  --route-ink: var(--slate-900);
  --route-muted: var(--slate-600);
  --route-ease: cubic-bezier(0.16, 1, 0.3, 1);

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: center;
  /* The steps grid above already ends with 48px; mirror it towards the button below. */
  margin: 0 0 48px;
  padding: 28px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.pdl-route__map {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--route-sea);
}

.pdl-route__map svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font-sans);
}

.pdl-route__sea { fill: var(--route-sea); }
.pdl-route__land { fill: var(--route-land); stroke: var(--route-land-edge); stroke-width: 1; stroke-linejoin: round; }

.pdl-route__minor { fill: var(--slate-600); font-size: 17px; font-weight: 600; }
.pdl-route__bridge { fill: #FFFFFF; stroke: var(--route-ink); stroke-width: 2.5; }

.pdl-route__credit {
  margin: 0;
  padding: 6px 12px 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--slate-600);
  text-align: right;
}
.pdl-route__credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.pdl-route__area {
  fill: var(--slate-500);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pdl-route__track,
.pdl-route__line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 2 9;
}
.pdl-route__track { stroke: var(--route-track); }
.pdl-route__line { stroke: var(--route-line); }

/* The mask path is drawn in full by default (dashoffset 0); JS moves the offset for the draw effect. */
.pdl-route__reveal {
  fill: none;
  stroke: #FFFFFF;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 0;
}

.pdl-route__time rect { fill: var(--route-ink); }
.pdl-route__time text { fill: #FFFFFF; font-size: 18px; font-weight: 700; }

.pdl-route__place { fill: var(--route-ink); font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }

.pdl-route__pin circle { stroke: #FFFFFF; stroke-width: 3; }
.pdl-route__pin--start circle { fill: var(--route-line); }
.pdl-route__pin--end circle { fill: var(--route-ink); }
.pdl-route__pin--end .pdl-route__halo {
  fill: var(--emerald-glow);
  stroke: none;
  transform-box: fill-box;
  transform-origin: center;
}

.pdl-route__van-body > circle { fill: #FFFFFF; stroke: var(--border-subtle); stroke-width: 1.5; filter: drop-shadow(0 4px 6px rgba(15, 23, 42, 0.18)); }
.pdl-route__van-body > path { fill: var(--route-ink); }
.pdl-route__van-body > .pdl-route__van-window { fill: var(--emerald-400); }
.pdl-route__van-wheel { fill: var(--route-ink); stroke: #FFFFFF; stroke-width: 1.2; }

.pdl-route__label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--emerald-700);
}

.pdl-route__title {
  margin: 0 0 20px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--route-ink);
}

.pdl-route__stops {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  counter-reset: pdl-stop;
}

.pdl-route__stop {
  position: relative;
  padding-left: 44px;
  counter-increment: pdl-stop;
  transition: opacity 0.45s var(--route-ease), transform 0.45s var(--route-ease);
}

.pdl-route__stop::before {
  content: counter(pdl-stop);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #FFFFFF;
  background: var(--route-ink);
}

.pdl-route__stop:last-child::before { background: var(--route-line); }

.pdl-route__stop:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 14px;
  top: 36px;
  bottom: -14px;
  width: 2px;
  background: var(--slate-200);
}

.pdl-route__when {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--emerald-700);
}

.pdl-route__what {
  display: block;
  margin: 2px 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--route-ink);
}

.pdl-route__detail {
  display: block;
  font-size: 14px;
  line-height: 1.55;
  color: var(--route-muted);
}

.pdl-route__replay {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  background: var(--slate-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.2s var(--route-ease), border-color 0.2s var(--route-ease), background 0.2s var(--route-ease);
}
.pdl-route__replay[hidden] { display: none; }
.pdl-route__replay svg { transition: transform 0.45s var(--route-ease); }
.pdl-route__replay:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
@media (hover: hover) {
  .pdl-route__replay:hover { color: var(--route-ink); border-color: var(--slate-400); background: #FFFFFF; }
  .pdl-route__replay:hover svg { transform: rotate(-120deg); }
}
.pdl-route__replay:active { transform: scale(0.98); }

/* Armed by JS: stops wait until the van reaches them. */
.pdl-route.is-armed .pdl-route__stop:not(.is-reached) {
  opacity: 0;
  transform: translateY(8px);
}

/* A slow glow around DLT Krabi once the van has arrived; three pulses, then it rests. */
.pdl-route.is-arrived .pdl-route__halo { animation: pdl-route-halo 2.4s var(--route-ease) 3; }
@keyframes pdl-route-halo {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}

@media (max-width: 860px) {
  .pdl-route {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: 16px;
  }
  .pdl-route__panel { padding: 0 6px 6px; }
  .pdl-route__title { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .pdl-route__stop,
  .pdl-route__replay svg { transition: none; }
  .pdl-route.is-arrived .pdl-route__halo { animation: none; }
}
