/* ---------- переменные ---------- */

:root {
  --color-bg: #f7f6f3;
  --color-surface: #ffffff;
  --color-border: #e5e2db;
  --color-text: #191b1a;
  --color-text-muted: #6b716f;
  --color-accent: #146661;
  --color-accent-dark: #0e4a46;
  --color-accent-contrast: #f2faf9;
  --color-accent-soft: #e3eeec;
  --color-accent-rgb: 20, 102, 97;
  --color-error-bg: #fbe9e5;
  --color-error-border: #d8503a;
  --color-error-text: #7a2413;
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --radius-input: 10px;
  --shadow: 0 4px 16px rgba(25, 27, 26, 0.07);
  --shadow-hover: 0 10px 24px rgba(var(--color-accent-rgb), 0.14);
}

/* Общий класс для приглушённого текста — используется на страницах
   направлений (marshruty.php): "ещё не рассчитан", "уточнит диспетчер". */
.muted {
  color: var(--color-text-muted);
}

a.muted {
  text-decoration: underline;
}

/* ---------- сброс ---------- */

*, *::before, *::after { box-sizing: border-box; }

/* [hidden] обязан прятать элемент всегда. Без этого правила классы вроде
   .order-form/.order-confirm (display:flex) перебивают стандартный
   display:none браузера для [hidden] — по правилам каскада авторские
   стили побеждают User-Agent независимо от специфичности селектора. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.45;
}

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }

button { font-family: inherit; }

/* ---------- layout ---------- */

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 20px 0; /* было 14px — часть общего увеличения воздуха над "сгибом" */
}

.logo {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-accent);
  text-decoration: none;
}

.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 20px 0;
  margin-top: 40px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.site-footer__phones {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--color-text);
}

.site-footer__copy {
  margin: 0;
}

.site-footer__attribution {
  margin: 6px 0 0;
  font-size: 12px;
}

.site-footer__attribution a {
  color: inherit;
}

.calc {
  padding: 36px 0 72px; /* было 24px/48px — 1.5x, воздуха вокруг калькулятора больше */
}

/* Подзаголовок над калькулятором — заметно легче и мельче заголовка страницы,
   не спорит с ним за внимание. */
.calc__title {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: normal;
  color: var(--color-text-muted);
  margin-bottom: 30px; /* было 20px */
}

.page-title {
  font-size: 34px;
  margin: 32px 0 10px; /* было 24px 0 8px */
}

.content-block {
  padding: 28px 0;
  border-top: 1px solid var(--color-border);
}

.content-block h2 {
  font-size: 22px;
  margin-bottom: 14px;
}

.content-block p {
  margin: 0 0 12px;
  line-height: 1.6;
}

/* ---------- 404 ---------- */

.notfound {
  text-align: center;
  padding: 80px 0;
}

.notfound__code {
  font-size: 56px;
  font-weight: 800;
  color: var(--color-accent-soft);
}

.notfound p {
  font-size: 17px;
  margin: 12px 0 24px;
  color: var(--color-text-muted);
}

.notfound .btn {
  display: inline-flex;
  width: auto;
  text-decoration: none;
  padding: 13px 28px;
}

/* "Как это работает" — номер в кружке и линия между ними, на мобильном
   линия скрывается и шаги идут столбцом (не карточки, шаг легче карточки). */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  position: relative;
}

.steps li {
  margin: 0;
  position: relative;
  padding-right: 16px;
}

.steps__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
  font-size: 16px;
  font-weight: 800;
  position: relative;
  z-index: 1;
  margin-bottom: 14px;
}

.steps__text {
  margin: 0;
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.5;
}

/* FAQ на <details>/<summary> — сворачивается по-настоящему, не просто
   текстовый список с постоянно открытыми ответами. */
.faq__item {
  border-bottom: 1px solid var(--color-border);
  padding: 14px 0;
}

.faq__item:first-of-type {
  border-top: 1px solid var(--color-border);
}

.faq__question {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.faq__question::-webkit-details-marker {
  display: none;
}

.faq__chevron {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

.faq__item[open] .faq__chevron {
  transform: rotate(180deg);
}

/* Приём с grid-template-rows 0fr/1fr — единственный способ анимировать
   высоту <details> плавно, а не скачком. display:grid!important нужен,
   чтобы перебить принудительный display:none у закрытого <details>
   в стандартных стилях браузера — саму видимость после этого целиком
   держит grid-template-rows. */
.faq__answer-wrap {
  display: grid !important;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}

.faq__item[open] .faq__answer-wrap {
  grid-template-rows: 1fr;
}

.faq__answer-wrap > .faq__answer {
  overflow: hidden;
  margin: 10px 0 0;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.route-text p {
  line-height: 1.7;
  margin: 0 0 14px;
}

.route-summary {
  font-size: 15px;
  color: var(--color-text-muted);
  margin: 0 0 14px;
}

.route-list__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14.5px;
}

.route-list__row:first-child {
  border-top: 1px solid var(--color-border);
}

.route-list__row a {
  color: var(--color-text);
  font-weight: 600;
  text-decoration: none;
}

.route-list__row a:hover {
  color: var(--color-accent);
}

.route-list__row .route-list__price {
  color: var(--color-text-muted);
  white-space: nowrap;
}

.route-list__row .route-list__manual {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.route-list__row .route-list__manual:hover {
  color: var(--color-accent-dark);
}

.todo-marker {
  background: #fff3a3;
  color: #7a2413;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: bold;
}

/* ---------- форма ---------- */

.calc__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 14px;
  color: var(--color-text-muted);
}

.field input[type="text"] {
  width: 100%;
  font-size: 16px; /* меньше — iOS зумит страницу при фокусе */
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  color: var(--color-text);
}

.field input[type="text"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb), 0.15);
}

/* ---------- автокомплит ---------- */

.autocomplete {
  position: relative;
}

.autocomplete__list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5000; /* у Leaflet свои слои и контролы доходят до z-index:1000 */
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}

.autocomplete__item {
  display: flex;
  align-items: center;
  min-height: 44px; /* область нажатия пальцем */
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
}

.autocomplete__item:hover,
.autocomplete__item.is-active {
  background: var(--color-bg);
}

.autocomplete__empty {
  padding: 10px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: var(--radius-input);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(var(--color-accent-rgb), 0.25);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.btn--primary:not(:disabled):hover {
  background: var(--color-accent-dark);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.btn--secondary:not(:disabled):hover {
  background: var(--color-accent-contrast);
}

.btn__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.noscript-banner {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border-bottom: 1px solid var(--color-error-border);
  padding: 12px 16px;
  text-align: center;
  font-size: 14px;
}

.form-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ---------- ошибка ---------- */

.error-box {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--color-error-border);
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border-radius: var(--radius);
  font-size: 14px;
}

/* ---------- результат ---------- */

.result {
  margin-top: 24px;
}

.result__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 16px;
  font-size: 15px;
  color: var(--color-text-muted);
}

.result__summary span:first-child {
  color: var(--color-text);
  font-weight: 600;
}

/* ---------- карточки тарифов ---------- */

.tariffs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px; /* было 12px */
  margin-bottom: 20px;
}

.tariff-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 18px; /* было 14px 16px */
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tariff-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.tariff-card__top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tariff-card__badge {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tariff-card__badge svg {
  width: 32px;
  height: auto;
  display: block;
}

.tariff-card__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tariff-card__price {
  font-size: 26px;
  font-weight: 800;
  color: var(--color-accent);
}

/* Новая территория — провайдер маршрутов не вызывался, цены нет.
   Спокойный приглушённый вид, не похожий на ошибку. */
.tariff-card__price--pending {
  color: var(--color-text-muted);
  font-style: italic;
  font-weight: normal;
}

.tariff-card__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.tariff-card__perkm {
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.tariff-card__order-btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px 16px;
  font-size: 15px;
}

.tariff-card--selected {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(var(--color-accent-rgb), 0.2);
}

/* ---------- форма заказа ---------- */

.order-section {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.order-card__tariff {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.order-section__title {
  font-size: 18px;
  margin: 0;
}

.order-section__title span {
  color: var(--color-accent);
}

.order-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.order-form textarea {
  width: 100%;
  font-size: 16px; /* как у input — не даём iOS зумить страницу */
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  resize: vertical;
}

.order-form textarea:focus,
.order-form input[type="tel"]:focus,
.order-form input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb), 0.15);
}

.order-form input[type="tel"],
.order-form input[type="datetime-local"] {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  color: var(--color-text);
}

/* Приманка для ботов: спрятана визуально и от скринридеров, но остаётся
   в DOM обычным полем — так её чаще заполняют примитивные боты, которые
   просто проходятся по всем полям формы (в отличие от display:none,
   который некоторые боты научились пропускать). */
.hp-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.order-confirm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px;
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
  border-radius: var(--radius);
  font-size: 14.5px;
}

.order-confirm svg {
  flex: none;
  margin-top: 2px;
}

/* ---------- карта ---------- */

.map-box {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.map {
  position: relative;
  z-index: 1; /* ниже списка подсказок */
  height: 320px;
  width: 100%;
}

.map-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  font-size: 14px;
  text-align: center;
  padding: 0 16px;
}

/* ---------- планшет и шире ---------- */

@media (min-width: 768px) {
  .calc__form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
    gap: 14px;
  }

  .btn--primary {
    width: auto;
    white-space: nowrap;
  }

  .tariffs {
    grid-template-columns: repeat(2, 1fr);
  }

  .steps {
    grid-template-columns: repeat(4, 1fr);
  }

  .steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: calc(12.5% + 20px);
    right: calc(12.5% + 20px);
    height: 1px;
    background: var(--color-border);
  }

  .map {
    height: 420px;
  }
}

@media (min-width: 1000px) {
  .tariffs {
    grid-template-columns: repeat(3, 1fr);
  }
}
