/*
 * لوين؟ — «تابع رحلتي على هذا الخط» on «الخطوط» (/map, js/line-follow.js). Loaded after lines.css.
 *
 * Before the ride: three stops on a short navy rail (the direction, where to get off, the notice),
 * the choices drawn as the placards a rider reads on the vehicle. During the ride: the same live
 * board as «ابدأ الرحلة» (/trip), in the line's own colour, turning yellow 300 m before the stop.
 * Colour never says it alone: every choice and state also has a mark or words.
 */

/* ── In the line's detail: the way in ───────────────────────────── */

/* The one invitation on the page: a soft teal card, the icon in a solid teal circle */
.btn--follow {
  justify-content: flex-start;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1.5px solid rgba(22, 184, 166, 0.55);
  border-radius: 14px;
  background: var(--teal-50);
  color: var(--navy);
  text-align: start;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn--follow:hover { border-color: var(--teal); background: #D5F1EC; }
.btn--follow:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.btn--follow > .icon { width: 34px; height: 34px; padding: 7px; border-radius: 999px; background: var(--teal); color: var(--navy); transform: rotate(-90deg); }
.btn--follow__text { display: grid; gap: 1px; }
.btn--follow__hint { font-size: 0.8125rem; font-weight: 600; color: #3D5573; }

.counter--gps { border-color: var(--teal); background: var(--white); color: var(--lines-teal-text); }
.line-card__gps .icon--trace,
.detail-badge--gps .icon--trace { width: 14px; height: 14px; }

/* ── The steps before following ─────────────────────────────────── */

.follow { padding-bottom: 8px; }
.follow__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font: 800 1.25rem/1.35 var(--shell-display, var(--font));
}
.follow__heading:focus { outline: none; }
.follow__heading:focus-visible { outline: 3px solid var(--navy); outline-offset: 4px; border-radius: 6px; }
.follow__heading .icon { width: 22px; height: 22px; color: var(--shell-teal-deep, #0B6F64); transform: rotate(-90deg); }

/* The stops: a numbered circle on a rail that runs down the start side. */
.follow-steps { position: relative; display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.follow-steps::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 18px;
  inset-inline-start: 13px;
  width: 4px;
  border-radius: 999px;
  background: repeating-linear-gradient(var(--navy) 0 10px, transparent 10px 16px);
  opacity: 0.22;
}
.follow-step { position: relative; padding-inline-start: 42px; }
.follow-step__set { min-width: 0; margin: 0; padding: 0; border: 0; }
.follow-step__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.45;
}
.follow-step__num {
  position: absolute;
  inset-inline-start: 0;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 3px solid var(--white);
  border-radius: 999px;
  background: var(--navy);
  color: var(--yellow);
  font: 800 0.9375rem/1 var(--shell-display, var(--font));
  box-shadow: 0 0 0 1.5px var(--navy);
}
.follow-step__note { margin: 6px 0 0; font-size: 0.8125rem; line-height: 1.6; color: var(--muted); }
.follow-step__again { margin-top: 2px; }

/* A choice: the placard of the vehicle; chosen = navy board, the line's band on top. */
.follow-choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  margin: 0 0 8px;
  padding: 10px 14px;
  border: 1px solid var(--control-edge);
  border-radius: 14px;
  background: var(--white);
  color: var(--navy);
  font-weight: 700;
  line-height: 1.45;
  cursor: pointer;
  transition: background 0.18s var(--shell-ease, ease), color 0.18s var(--shell-ease, ease), border-color 0.18s;
}
.follow-choice:hover { border-color: var(--border-strong); }
.follow-choice input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.follow-choice__text { min-width: 0; overflow-wrap: anywhere; }
.follow-choice__mark {
  flex: none;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border-strong);
  border-radius: 999px;
  background: var(--white);
}
/* The way there teal, the way back purple, as the swatches of the detail. */
.follow-choice--outbound .follow-choice__mark { border-color: var(--teal); }
.follow-choice--return .follow-choice__mark { border-color: var(--purple); }
.follow-choice__mark--end { border-radius: 5px; border-color: var(--navy); }
.follow-choice__mark--pin { border-color: var(--navy); border-radius: 999px 999px 999px 4px; transform: rotate(-45deg); }
/* Chosen: a light tint and the line's colour along the top (and the filled mark), not a navy block */
.follow-choice:has(input:checked) {
  border-color: var(--line, var(--teal));
  background: var(--teal-50);
  background: color-mix(in srgb, var(--line, var(--teal)) 9%, var(--white));
  color: var(--navy);
  box-shadow: inset 0 4px 0 var(--line, var(--teal)), 0 0 0 1px var(--line, var(--teal));
}
.follow-choice input:checked + .follow-choice__mark { border-color: var(--yellow); background: var(--yellow); box-shadow: inset 0 0 0 4px var(--navy); }
.follow-choice--return:has(input:checked) { border-color: var(--purple); background: #F3EAFB; box-shadow: inset 0 4px 0 var(--purple), 0 0 0 1px var(--purple); }
.follow-choice:has(input:focus-visible) { outline: 3px solid var(--navy); outline-offset: 3px; }
/* Without :has() the mark alone shows the choice. */
.follow-choice input:focus-visible + .follow-choice__mark { outline: 3px solid var(--navy); outline-offset: 2px; }

.follow-notice { display: grid; gap: 6px; margin: 0; padding: 12px 14px; border-radius: 14px; background: var(--surface); list-style: none; font-size: 0.875rem; line-height: 1.7; }
.follow-notice li { position: relative; padding-inline-start: 18px; }
.follow-notice li::before { content: ""; position: absolute; top: 0.62em; inset-inline-start: 2px; width: 8px; height: 8px; border-radius: 2px; background: var(--teal); }
.follow-notice--plain { display: block; color: var(--muted); }

.follow__error { margin: 14px 0 0; font-weight: 700; color: var(--danger); }
.follow__error:empty { display: none; }
.follow__actions { display: flex; gap: 8px; margin: 16px 0 0; }
.follow__actions .btn--ghost { flex: 0 1 auto; }
.follow-go {
  flex: 1 1 auto;
  background: var(--teal);
  color: var(--navy);
  font-size: 1.0625rem;
  box-shadow: inset 0 -2px 0 rgba(20, 45, 78, 0.18), 0 6px 14px rgba(22, 184, 166, 0.28);
}
.follow-go:hover { background: #13A493; }
.follow-go:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.follow-go .icon { transform: rotate(-90deg); }
.follow-go[aria-busy="true"] { cursor: progress; opacity: 0.8; }

/* ── During the ride: the board, in the sheet head ──────────────── */

.follow-live { display: grid; gap: 10px; padding-top: 2px; }
.follow-board {
  --progress: 0;
  position: relative;
  overflow: hidden;
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 10px 24px rgba(20, 45, 78, 0.26);
}
.follow-board::before { content: ""; position: absolute; top: 0; inset-inline: 0; height: 5px; background: var(--line, var(--teal)); }
.follow-board__top { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; font-size: 0.875rem; font-weight: 700; color: rgba(255, 255, 255, 0.84); }
.follow-board__dot { flex: none; width: 10px; height: 10px; border-radius: 999px; background: var(--teal); }
.follow-board__line { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-board__dir { flex: none; margin-inline-start: auto; padding: 1px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); font-size: 0.8125rem; white-space: nowrap; }
.follow-board__title { margin: 10px 0 0; font-size: 1.125rem; font-weight: 700; line-height: 1.55; overflow-wrap: anywhere; }
.follow-board__km {
  display: inline-block;
  margin-inline: 2px;
  font: 800 2.75rem/1 var(--shell-display, var(--font));
  font-variant-numeric: tabular-nums;
  color: var(--yellow);
  direction: ltr;
  unicode-bidi: isolate;
  vertical-align: -0.12em;
}
.follow-board__place { font-weight: 800; }
.follow-board__sub { margin: 6px 0 0; font-size: 0.9375rem; line-height: 1.55; color: rgba(255, 255, 255, 0.86); }

/* The rail: from where you got on (start) to where you get off (end). */
.follow-rail { position: relative; height: 20px; margin: 14px 8px 2px; }
.follow-rail::before { content: ""; position: absolute; top: 50%; inset-inline: 0; height: 4px; margin-top: -2px; border-radius: 999px; background: rgba(255, 255, 255, 0.2); }
.follow-rail__done { position: absolute; top: 50%; inset-inline-start: 0; width: calc(var(--progress) * 100%); height: 4px; margin-top: -2px; border-radius: 999px; background: var(--line, var(--teal)); transition: width 0.6s var(--shell-ease, ease); }
.follow-rail__me {
  position: absolute;
  top: 50%;
  inset-inline-start: calc(var(--progress) * 100%);
  width: 18px;
  height: 18px;
  margin-block-start: -9px;
  margin-inline-start: -9px;
  border: 3px solid var(--navy);
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 0 0 0 2px var(--yellow);
  transition: inset-inline-start 0.6s var(--shell-ease, ease);
}
.follow-rail__stop { position: absolute; top: 50%; inset-inline-end: 0; width: 16px; height: 16px; margin-block-start: -8px; margin-inline-end: -8px; border: 3px solid var(--white); border-radius: 4px; background: var(--navy); }

.follow-board.is-waiting .follow-rail { opacity: 0.35; }
.follow-board.is-weak .follow-board__sub { color: var(--yellow); font-weight: 700; }
/* ≤ 300 m: yellow board, navy text, a bigger title. */
.follow-board.is-near { background: var(--yellow); color: var(--navy); box-shadow: 0 10px 26px rgba(196, 140, 20, 0.38); }
.follow-board.is-near .follow-board__top,
.follow-board.is-near .follow-board__sub { color: var(--navy); }
.follow-board.is-near .follow-board__dir { background: rgba(20, 45, 78, 0.12); }
.follow-board.is-near .follow-board__dot { background: var(--navy); }
.follow-board.is-near .follow-board__title { font: 800 1.625rem/1.3 var(--shell-display, var(--font)); }
.follow-board.is-near .follow-rail::before { background: rgba(20, 45, 78, 0.22); }
.follow-board.is-near .follow-rail__done { background: var(--navy); }
.follow-board.is-near .follow-rail__me { border-color: var(--yellow); background: var(--navy); box-shadow: 0 0 0 2px var(--navy); }
.follow-board.is-near .follow-rail__stop { border-color: var(--navy); background: var(--white); }

.follow-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.follow-notify,
.follow-end-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
}
.follow-notify[hidden] { display: none; }
.follow-notify { flex: 0 1 auto; border: 1.5px solid var(--border-strong); background: var(--white); color: var(--navy); }
.follow-notify:hover { border-color: var(--navy); }
.follow-notify[aria-pressed="true"] { border-color: #0B8F80; background: var(--teal-50); color: var(--lines-teal-text); }
.follow-notify[aria-pressed="true"] .icon { fill: currentColor; }
.follow-end-btn { flex: 1 1 10rem; border: 0; background: var(--navy); color: var(--white); }
.follow-end-btn:hover { background: var(--navy-700); }
.follow-notify:focus-visible,
.follow-end-btn:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.follow-live__note { margin: 0; font-size: 0.8125rem; line-height: 1.6; color: var(--muted); }

/* ── After the ride ─────────────────────────────────────────────── */

.follow-done__text { margin: -6px 0 14px; font-weight: 600; color: var(--muted); }
.follow-done .btn--block { margin-top: 16px; }

/* ── On the map ─────────────────────────────────────────────────── */

/* «اضغط على الخط حيث ستنزل»: over the map, above the lowered sheet (as the drawing bar). */
.pick-bar {
  position: absolute;
  inset-inline: 8px;
  bottom: calc(var(--sheet-visible, 0px) + 8px);
  z-index: 1150;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  max-width: 36rem;
  margin-inline: auto;
  padding: 10px 12px;
  border-top: 4px solid var(--teal);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--lines-elev);
}
.pick-bar[hidden] { display: none; }
.pick-bar__text { display: flex; flex: 1 1 14rem; align-items: center; gap: 6px; margin: 0; font-size: 0.9375rem; font-weight: 700; line-height: 1.5; }
.pick-bar__text .icon { flex: none; width: 20px; height: 20px; color: var(--shell-teal-deep, #0B6F64); }
.pick-bar__hint { flex: 1 0 100%; order: 3; margin: 0; font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }
@media (hover: none) and (pointer: coarse) { .pick-bar__hint { display: none; } }
.map--public.is-picking { outline: 4px solid var(--teal); outline-offset: -4px; cursor: crosshair; }
.map--public.is-picking:focus-visible ~ .map-crosshair { display: block; }

/* Where to get off: a navy square with a yellow core and its tag; where to get on: a yellow ring. */
.follow-pin { border: 3px solid var(--navy); border-radius: 4px; background: var(--yellow); box-shadow: 0 0 0 2px var(--white); }
.follow-pin--board { border-radius: 999px; background: var(--white); border-color: var(--navy); }
.follow-pin__label {
  position: absolute;
  bottom: 14px;
  left: 50%;
  max-width: 12rem;
  overflow: hidden;
  padding: 1px 10px;
  border: 2px solid var(--white);
  border-radius: 999px;
  background: var(--navy);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.6;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(20, 45, 78, 0.3);
}
.follow-pin--board .follow-pin__label { top: 14px; bottom: auto; background: var(--white); color: var(--navy); border-color: var(--navy); }

/* You, while following (memory only): the blue of «أنا» (me.css). */
.follow-me { display: grid; place-items: center; }
.follow-me__dot { width: 18px; height: 18px; border: 3px solid var(--white); border-radius: 999px; background: var(--me, #1A73E8); box-shadow: 0 0 0 2px var(--me, #1A73E8), 0 2px 8px rgba(20, 45, 78, 0.4); }

@media (prefers-reduced-motion: no-preference) {
  .follow-board__dot { animation: follow-ping 1.8s ease-out infinite; }
  .follow-board.is-near { animation: follow-nudge 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 2; }
  .follow-me__dot { animation: follow-me 2.4s ease-out infinite; }
  .follow-step { animation: follow-in 0.32s var(--shell-ease, ease) both; }
  .follow-step:nth-child(2) { animation-delay: 0.06s; }
  .follow-step:nth-child(3) { animation-delay: 0.12s; }
}
@keyframes follow-ping {
  0% { box-shadow: 0 0 0 0 rgba(22, 184, 166, 0.7); }
  75%, 100% { box-shadow: 0 0 0 9px rgba(22, 184, 166, 0); }
}
@keyframes follow-nudge { 50% { transform: scale(1.025); } }
@keyframes follow-me {
  0% { box-shadow: 0 0 0 2px var(--me, #1A73E8), 0 0 0 2px rgba(26, 115, 232, 0.45); }
  80%, 100% { box-shadow: 0 0 0 2px var(--me, #1A73E8), 0 0 0 16px rgba(26, 115, 232, 0); }
}
@keyframes follow-in { from { opacity: 0; transform: translateY(6px); } }

@media (forced-colors: active) {
  .follow-choice:has(input:checked) { outline: 3px solid Highlight; }
  .follow-board,
  .follow-pin { border: 2px solid CanvasText; }
  .follow-rail,
  .follow-steps::before { forced-color-adjust: none; }
}
