/*
 * لوين؟ — «أنا» (js/me-dot.js), the locate button «موقعي» and the location dialog (js/locate.js,
 * partials/locate.blade.php) on «الرحلة», «الخطوط» and «ارسم خطًا». Loaded after app.css and shell.css.
 *
 * One clear blue, used only for the rider: the dot, its accuracy circle, the dot of «ابدأ الرحلة» and
 * of «تابع رحلتي على هذا الخط», and the locate button while the map follows you. Grey-blue when the
 * position is old or rough. No inline styles (CSP): Leaflet places the dot through the CSSOM.
 */

:root {
  --me: #1A73E8;
  --me-dim: #8A9FBA;
  --me-halo: rgba(26, 115, 232, 0.22);
}

/* ── «أنا» on the map ── */

/* Over the tiles, the known stops (350), the lines (400) and the drawn route (450): the circle; the dot
   also over the pins and the other markers (600), so it shows even on «موقعي»'s start pin. Never a
   target, so the pins under it can still be dragged. Under the tooltips (650) and the popups (700). */
.leaflet-lowein-me-accuracy-pane { z-index: 460; pointer-events: none; }
.leaflet-lowein-me-pane { z-index: 620; pointer-events: none; }
.leaflet-lowein-me-accuracy-pane *,
.leaflet-lowein-me-pane * { pointer-events: none !important; }

.me-dot { display: grid; place-items: center; }
.me-dot__core {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--white, #FFFFFF);
  border-radius: 999px;
  background: var(--me);
  box-shadow: 0 1px 5px rgba(20, 45, 78, 0.45);
  transition: background-color 0.4s;
}
.me-dot.is-dim .me-dot__core { background: var(--me-dim); }
.me-accuracy { fill: var(--me); fill-opacity: 0.12; stroke: var(--me); stroke-opacity: 0.4; stroke-width: 1; }
.me-accuracy.is-dim { fill: var(--me-dim); stroke: var(--me-dim); }
.me-accuracy.is-hidden { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .me-dot:not(.is-dim) .me-dot__core::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 999px;
    animation: me-pulse 2.4s ease-out infinite;
  }
}
@keyframes me-pulse {
  0% { box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.5); }
  80%, 100% { box-shadow: 0 0 0 14px rgba(26, 115, 232, 0); }
}

/* The rider's own markers while a trip, a ride or a recording is followed use the same blue:
   .live-me__dot (trip.css), .follow-me__dot (follow.css), .me-icon (app.css). */

/* ── «موقعي»: a round button over the map («الرحلة», «الخطوط»), above the sheet on phones ── */

.map-locate {
  position: absolute;
  bottom: calc(var(--sheet-visible, 0px) + 16px);
  left: 12px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--navy);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(20, 45, 78, 0.08), 0 6px 20px rgba(20, 45, 78, 0.12);
  cursor: pointer;
  transition: bottom 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.map-locate .ticon,
.map-locate .icon { width: 22px; height: 22px; }
.map-locate[hidden] { display: none; }
.map-locate:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.shell-stage.is-dragging .map-locate { transition: none; }

/* Following you (.me-locate: the locate button of each map): blue, its centre filled, and «يتابعك»
   next to it; the button keeps its name «موقعي». */
.me-follow { display: none; }
.me-locate[aria-pressed="true"] { border-color: var(--me); color: var(--me); box-shadow: inset 0 0 0 1.5px var(--me), 0 6px 20px rgba(26, 115, 232, 0.25); }
.map-locate.me-locate[aria-pressed="true"] { padding: 0 16px 0 12px; }
.me-locate[aria-pressed="true"] svg circle { fill: currentColor; }
.me-locate[aria-pressed="true"] > .me-follow { display: inline; }
.map-fab .me-follow { font-size: 0.875rem; }

@media (min-width: 900px) {
  .map-locate { bottom: 32px; }
}

/* ── The location dialog ── */

.locate-dialog {
  width: min(28rem, calc(100% - 32px));
  max-width: none;
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px;
  background: var(--white);
  color: var(--navy);
  box-shadow: 0 18px 48px rgba(20, 45, 78, 0.3);
}
.locate-dialog::backdrop { background: rgba(20, 45, 78, 0.5); }
/* Without showModal (very old browsers): over the map and the fullscreen map. */
.locate-dialog.is-fallback { position: fixed; inset: 0; z-index: 4000; }

/* Phones: a sheet from the bottom, as the site's own. */
@media (max-width: 599.98px) {
  .locate-dialog {
    width: 100%;
    max-height: calc(100% - 24px);
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
  }
}

.locate-panel { padding: 22px 20px calc(18px + env(safe-area-inset-bottom, 0px)); }
.locate-panel__title { margin: 0 0 8px; font-size: 1.1875rem; font-weight: 800; line-height: 1.4; }
.locate-panel__title:focus { outline: none; }
.locate-panel__title:focus-visible { outline: 3px solid var(--navy); outline-offset: 4px; border-radius: 6px; }
.locate-panel__text { margin: 0 0 16px; font-size: 1rem; line-height: 1.7; }
.locate-panel__still { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--danger-50); color: var(--danger); font-weight: 600; line-height: 1.6; }
.locate-panel__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.locate-panel__actions .btn { flex: 1 1 9rem; }
.locate-panel__actions .btn[hidden] { display: none; }

/* «أنا» drawn large: the blue dot in its circle (grey-blue when there is no fix, rough when weak). */
.locate-panel__art { position: relative; display: block; width: 64px; height: 64px; margin: 0 0 12px; }
.locate-panel__ring { position: absolute; inset: 0; border: 1.5px solid rgba(26, 115, 232, 0.45); border-radius: 999px; background: rgba(26, 115, 232, 0.12); }
.locate-panel__dot { position: absolute; inset: 21px; border: 3px solid var(--white); border-radius: 999px; background: var(--me); box-shadow: 0 1px 5px rgba(20, 45, 78, 0.45); }
.locate-panel__art--off .locate-panel__ring { border-style: dashed; border-color: var(--me-dim); background: none; }
.locate-panel__art--off .locate-panel__dot { background: var(--me-dim); }
.locate-panel__art--weak .locate-panel__ring { inset: -6px; }
.locate-panel__art--weak .locate-panel__dot { background: var(--me-dim); }

/* The steps to allow the location: a line between stops, as the trip's steps. */
.locate-help { margin: 0 0 16px; }
.locate-help__platform { padding: 12px 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.locate-help__title { margin: 0 0 8px; font-size: 1rem; font-weight: 800; }
.locate-help__note { margin: 10px 0 6px; font-size: 0.9375rem; font-weight: 700; }
.locate-path { position: relative; margin: 0; padding: 0; list-style: none; counter-reset: locate-step; }
.locate-path li {
  position: relative;
  min-height: 28px;
  padding: 3px 0 8px;
  padding-inline-start: 36px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.55;
  counter-increment: locate-step;
}
.locate-path li:last-child { padding-bottom: 0; }
.locate-path li::before {
  content: counter(locate-step);
  position: absolute;
  top: 2px;
  inset-inline-start: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: var(--white);
  font-size: 0.8125rem;
  font-weight: 800;
  line-height: 1;
}
/* The last step is the one to choose: yellow, as a trip's end. */
.locate-path li:last-child::before { background: var(--yellow); }
.locate-path li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 26px;
  bottom: -2px;
  inset-inline-start: 11px;
  border-inline-start: 2px dotted var(--border-strong);
}
.locate-help__more { margin-top: 10px; }
.locate-help__more[hidden] { display: none; }
.locate-help__more > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.locate-help__more > summary:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; border-radius: 6px; }
.locate-help__more .locate-help__platform + .locate-help__platform { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .map-locate,
  .me-dot__core { transition: none; }
}

@media (forced-colors: active) {
  .me-dot__core { forced-color-adjust: none; border-color: Canvas; }
  .me-locate[aria-pressed="true"] { outline: 3px solid Highlight; }
  .locate-dialog { border: 2px solid CanvasText; }
}
