/* Планировщик маршрута и сопровождение прогулки. */

/* Панель планирования маршрута и её расположение на экране. */
.routePanel {
  position: fixed;
  z-index: 85;
  right: 16px;
  top: 100px;
  bottom: 18px;
  width: 348px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 48px #0003;
  overflow: hidden;

  :where([data-layout="mobile"]) & {
    left: 50%;
    right: auto;
    top: calc((100dvh - var(--m-nav, 74px)) / 2);
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100% - 24px));
    height: 70dvh;
    max-height: calc(100dvh - var(--m-nav, 74px) - env(safe-area-inset-top) - 24px);
    transition: height .22s ease;
  }

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

/* Заголовок маршрута и кнопка закрытия панели. */
.routeHeader {
  position: relative;
  padding: 18px 18px 10px;
  flex-shrink: 0;

  :where([data-layout="mobile"]) & {
    padding: 0 16px 10px;
  }

  @media (max-height: 600px) {
    padding-bottom: 6px;
  }
}

.routeHeader > .muted {
  font-size: 10px;
  letter-spacing: .12em;

  @media (max-height: 500px) {
    display: none;
  }
}

.routeHeader h2 {
  margin: 6px 24px 0 0;
  font-size: 20px;
  line-height: 1.25;

  :where([data-layout="mobile"]) & {
    font-size: 17px;
  }

  @media (max-height: 600px) {
    font-size: 16px;
  }

  @media (max-height: 500px) {
    margin-top: 0;
  }
}

.routeHeader > button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  font-size: 24px;
  color: var(--ink);
  border-radius: 8px;

  :where([data-layout="mobile"]) & {
    top: 0;
  }

  @media (max-height: 500px) {
    height: 26px;
    line-height: 1;
  }
}

.routeHeader > button:hover {
  background: var(--soft);
}

/* Настройки маршрута и выбор способа передвижения. */
.routeSettings {
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;

  @media (max-height: 600px) {
    padding-bottom: 6px;
  }
}

.routeModes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.routeModes button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 7px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  font-size: 11px;

  @media (max-height: 600px) {
    min-height: 34px;
  }
}

.routeModes button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--onaccent);
  font-weight: 700;
}

.routeModes svg {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Кнопки изменения и отображения маршрута. */
.routeTools {
  display: flex;
  gap: 5px;
  margin-top: 8px;

  @media (max-height: 600px) {
    margin-top: 5px;
  }
}

.routeTools button {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap;

  @media (max-height: 600px) {
    min-height: 28px;
    padding: 3px 6px;
  }
}

.routeTools button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.routeTools #routeFit {
  margin-left: auto;
}

.routePanel button:disabled {
  opacity: .4;
  cursor: default;
}

/* Список остановок маршрута. */
.routeList {
  list-style: none;
  margin: 0;
  padding: 4px 12px;
  overflow: auto;
  flex: 1;
  min-height: 60px;

  :where([data-layout="mobile"]) & {
    overscroll-behavior: contain;
  }

  @media (max-height: 600px) {
    min-height: 36px;
  }
}

.routeList li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  cursor: grab;
  border-radius: 8px;
}

.routeList li.routeHighlighted {
  background: var(--soft);
  outline: 2px solid #4784ee;
}

.routeList label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  margin: 0;
}

.routeList strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.routeList small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

/* Номера остановок в списке и на карте. */
.routeNumber {
  background: #4784ee;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.routeMapNumber {
  background: #4784ee;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  width: 34px;
  height: 34px;
  box-shadow: 0 2px 8px #0005;
  cursor: pointer;
}

.routeExcluded {
  opacity: .5;
}

/* Кнопки изменения порядка остановок. */
.routeMove {
  display: flex;
  flex-direction: column;
}

.routeMove button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.routeMove button:hover:not(:disabled) {
  color: var(--ink);
}

.routeMove svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Выделение начала и конца маршрута. */
.routeStartPoint {
  background: #27855d;
}

.routeFinishPoint {
  background: #ca6245;
}

.routeMapNumber.routeStartPoint {
  z-index: 2;
}

.routeMapNumber.routeFinishPoint {
  z-index: 2;
}

.routeMapNumber.routeBothPoint {
  z-index: 2;
}

.routeBothPoint {
  background: linear-gradient(135deg, #27855d 50%, #ca6245 50%);
}

/* Область раскрытия панели маршрута на телефоне. */
.routeHandle {
  display: none;

  :where([data-layout="mobile"]) & {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 100%;
    height: 18px;
    padding: 0;
    touch-action: none;
  }
}

/* Итоги маршрута, ошибки и ссылки на внешние сервисы. */
.routeFooter {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 10px 14px 14px;
  max-height: 45%;
  overflow: auto;

  @media (max-height: 600px) {
    padding: 5px 12px 8px;
    max-height: 34%;
  }
}

.routeSummary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
  font-size: 14px;
}

#routeErrorRetry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
}

.routeLinksTitle {
  display: block;
  margin: 6px 0;
  font-size: 11px;
  color: var(--muted);

  @media (max-height: 600px) {
    margin: 2px 0;
  }
}

.routeProviders {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.routeProvider {
  display: block;
  text-align: center;
  padding: 9px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  text-decoration: none;
  font-size: 11px;
  cursor: pointer;

  @media (max-height: 600px) {
    padding: 6px 2px;
  }
}

.routeProvider:not(.isUnavailable) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.routeProvider:not(.isUnavailable):hover {
  background: var(--accent);
  color: var(--onaccent);
}

.routeProvider.isUnavailable {
  color: var(--muted);
  cursor: default;
  background: var(--soft);
}

.routeProvider small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
}

.routeLimitsInfo {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

body.routing .pin {
  visibility: hidden;
}

.routePanel.routeExpanded {

  :where([data-layout="mobile"]) & {
    height: calc(100dvh - var(--m-nav, 74px) - env(safe-area-inset-top) - 24px);
  }
}

.routeHandle span {

  :where([data-layout="mobile"]) & {
    width: 34px;
    height: 4px;
    border-radius: 4px;
    background: var(--muted);
    opacity: .4;
  }
}

body.routing #sidebar {

  :where([data-layout="mobile"]) & {
    visibility: hidden;
  }
}

body.routing #detail {
  display: none !important;
}

/* Кнопки выбора остановок на карте. */
.routeMapTools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  flex-shrink: 0;
}

.routeMapTools button {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;

  @media (max-height: 500px) {
    padding: 4px 8px;
    font-size: 11px;
  }
}

#routePick[aria-pressed="true"] {
  background: var(--accent);
  color: var(--onaccent);
  border-color: var(--accent);
  font-weight: 700;
}

#routePickHint {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 11px;
}

/* Кнопки сопровождения прогулки и слежения за позицией. */
.routeNavigationControls {
  display: flex;
  gap: 6px;
  margin: 7px 0;
}

.routeNavigationControls .primary {
  flex: 1;
  min-height: 38px;
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;

  @media (max-height: 500px) {
    min-height: 30px;
    padding: 5px;
  }
}

#routeFollow {
  width: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 22px;
}

#routeFollow[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.routeNavigationStatus {
  font-size: 13px;
  line-height: 1.4;
  padding: 4px 0;
  overflow-wrap: anywhere;
}

.routeList .routeVisited strong {
  text-decoration: line-through;
  color: var(--muted);
}

.routeList .routeVisited .routeNumber {
  background: #27855d;
}

.routeMapNumber.routeVisited {
  opacity: .55;
}

.routePickCandidate {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--accent);
  font-size: 24px;
}

/* Окно прибытия к месту с фотографией, описанием и оценкой. */
.routeArrivalDialog {
  width: 420px;
}

.routeArrivalPhoto {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
}

.routeArrivalDescription {
  max-height: 90px;
  overflow: auto;
  white-space: pre-wrap;
}

#routeArrival h3 {
  font-size: 16px;
  margin: 18px 0 10px;
}

.routeArrivalVote {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.routeArrivalVote button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 10px;
}

.routeArrivalVote button:first-child {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#routeArrivalReview textarea {
  min-height: 76px;
}

#routeArrivalContinue {
  margin-top: 14px;
  min-height: 44px;
}

/* Вид панели во время выбора остановок на карте. */
body.routePicking .routeSettings {
  display: none;
}

body.routePicking .routeList {
  display: none;
}

body.routePicking .routeFooter {
  display: none;
}

body.routePicking .routePanel {
  bottom: auto;
  height: auto;

  :where([data-layout="mobile"]) & {
    top: auto;
    bottom: calc(var(--m-nav, 74px) + 12px);
    transform: translateX(-50%);
  }
}

/* Свёрнутая панель маршрута во время прогулки. */
body.navigating .routePanel:not(.routeExpanded) {

  :where([data-layout="mobile"]) & {
    top: auto;
    bottom: calc(var(--m-nav, 74px) + 12px);
    transform: translateX(-50%);
    height: auto;
  }
}

body.navigating .routePanel:not(.routeExpanded) .routeSettings {

  :where([data-layout="mobile"]) & {
    display: none;
  }
}

body.navigating .routePanel:not(.routeExpanded) .routeMapTools {

  :where([data-layout="mobile"]) & {
    display: none;
  }
}

body.navigating .routePanel:not(.routeExpanded) .routeList {

  :where([data-layout="mobile"]) & {
    display: none;
  }
}

body.navigating .routePanel:not(.routeExpanded) #routeLinks {

  :where([data-layout="mobile"]) & {
    display: none;
  }
}

body.navigating .routePanel:not(.routeExpanded) .routeFooter {

  :where([data-layout="mobile"]) & {
    max-height: none;
  }
}

.routePanel .routeMapTools {

  @media (max-height: 500px) {
    padding: 4px 12px;
  }
}

.routePanel .routeList {

  @media (max-height: 500px) {
    min-height: 0;
  }
}

.routePanel .routeSettings {

  @media (max-height: 500px) {
    padding-bottom: 4px;
  }
}

.routePanel .routeModes button {

  @media (max-height: 500px) {
    min-height: 30px;
  }
}

.routePanel .routeTools button {

  @media (max-height: 500px) {
    min-height: 26px;
  }
}

.routePanel .routeFooter {

  @media (max-height: 500px) {
    min-height: 0;
  }
}
