/* ==========================================================================
   Попутки — визуальный язык BlaBlaCar.
   Палитра снята с их публичных стилей (sitestyleguide.com/blablacar.com).
   Логотип и шрифт свои: GT Eesti лицензионный, берём Inter с fallback.
   ========================================================================== */

:root {
  /* Бренд */
  --blue: #0071eb;         /* True Blue: кнопки, акценты */
  --blue-dark: #0066d4;    /* hover */
  --blue-soft: #e8f2ff;    /* подложки, бейджи */

  /* Текст */
  --ink: #131314;
  --slate: #054652;        /* заголовки */
  /* Изначальный #6f8b90 даёт 3.6:1 — ниже AA. Этот оттенок той же гаммы
     проходит с запасом: 5.3:1 на белом и 4.9:1 на сером фоне. */
  --muted: #55707a;        /* вторичный текст */

  /* Служебное */
  --green: #54b65d;
  --green-soft: #eaf7ec;
  --yellow: #ffcd57;
  --yellow-soft: #fff8e6;
  --surface: #f6f7f8;
  --white: #ffffff;
  --line: #dedede;
  --line-soft: #eef0f2;

  /* Форма */
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgb(19 19 20 / 6%);
  --shadow: 0 4px 16px rgb(19 19 20 / 8%);
  --shadow-lg: 0 12px 40px rgb(19 19 20 / 12%);

  /* Ритм */
  --wrap: 1120px;
  --gap: 16px;

  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

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

/* Важнее любого display: у полей он задан явно, и без этого правила
   `hidden` в шаблоне не сработал бы. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--slate);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

p {
  margin: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* --------------------------------------------------------------------------
   Шапка
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--blue);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--blue);
  color: var(--white);
}

.brand__text {
  color: var(--slate);
}

.site-nav {
  display: flex;
  gap: 24px;
  font-size: 15px;
  font-weight: 500;
}

.site-nav a {
  color: var(--slate);
}

.site-nav a:hover {
  color: var(--blue);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  padding: 56px 0 64px;
  background:
    radial-gradient(1200px 400px at 50% -160px, var(--blue-soft), transparent 70%),
    var(--white);
}

.hero__title {
  max-width: 760px;
  font-size: clamp(28px, 5vw, 44px);
}

.hero__subtitle {
  max-width: 620px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 17px;
}

.hero .search-form {
  margin-top: 32px;
}

/* --------------------------------------------------------------------------
   Форма поиска
   -------------------------------------------------------------------------- */

.search-form {
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line-soft);
}

.search-form__row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.search-form__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 12px;
  padding: 12px 6px 4px;
  border-top: 1px solid var(--line-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.field--grow {
  flex: 1 1 180px;
}

.field--small {
  min-width: 120px;
}

.field__label {
  padding-left: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field__control {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}

.field__control:hover {
  background: #f0f2f4;
}

.field__control:focus {
  outline: none;
  background: var(--white);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(0 113 235 / 15%);
}

select.field__control {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236f8b90' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.swap {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 48px;
  margin-bottom: 0;
  color: var(--blue);
  background: var(--blue-soft);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.swap:hover {
  background: #d8e9ff;
}

.swap:active {
  transform: scale(0.94);
}

.search-form__submit {
  height: 48px;
  padding: 0 28px;
  font-size: 16px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  color: var(--white);
  background: var(--blue);
}

.btn--primary:hover {
  background: var(--blue-dark);
}

.btn--ghost {
  color: var(--slate);
  background: var(--white);
  border-color: var(--line);
}

.btn--ghost:hover {
  border-color: var(--slate);
}

.btn--vk {
  height: 40px;
  padding: 0 18px;
  /* Текст темнее основного синего: #0071eb на подложке даёт 4.07:1 —
     ниже AA. #0068d9 даёт 4.66:1, оставаясь в той же гамме. */
  color: #0068d9;
  background: var(--blue-soft);
  font-size: 14px;
}

.btn--vk:hover {
  color: var(--white);
  background: var(--blue);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate);
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Как это работает
   -------------------------------------------------------------------------- */

.how {
  padding-bottom: 72px;
}

.section-title {
  margin-bottom: 24px;
  font-size: 24px;
}

.how .section-title:not(:first-child) {
  margin-top: 48px;
}

/* Быстрые ссылки на направления */

.route-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  color: var(--slate);
  font-size: 15px;
  font-weight: 600;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.route-chip:hover {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: var(--blue);
  text-decoration: none;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
}

.step__num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 14px;
  color: var(--blue);
  font-weight: 700;
  background: var(--white);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.step h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.step p {
  color: var(--muted);
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   Выдача
   -------------------------------------------------------------------------- */

.search-bar {
  padding: 20px 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.search-bar .search-form {
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

.results {
  padding: 36px 20px 80px;
}

.results__layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.results__aside {
  position: sticky;
  top: 88px;
}

.results__main {
  min-width: 0;
}

/* Фильтры: на десктопе — колонка, на мобильном — свёрнутый блок */

.filters-wrap {
  display: block;
  margin-bottom: 4px;
}

.filters-wrap__summary {
  display: none;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.filters__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.filters__title {
  font-size: 16px;
}

.filters__reset {
  font-size: 13px;
}

.filters__group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: none;
}

.filters__group legend {
  margin-bottom: 8px;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filters__apply {
  width: 100%;
  height: 40px;
}

.radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--slate);
  cursor: pointer;
}

.radio input {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
  cursor: pointer;
}

.results__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.results__title {
  font-size: clamp(24px, 3.5vw, 32px);
}

.results__window {
  margin-top: 6px;
  color: var(--muted);
  font-size: 16px;
}

.results__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 14px;
}

.count {
  color: var(--slate);
  font-weight: 600;
}

/* Свежесть данных */

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 999px;
}

.freshness__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentcolor;
}

.freshness--fresh {
  color: #2f7a39;
  background: var(--green-soft);
}

.freshness--stale,
.freshness--error {
  color: #8a6100;
  background: var(--yellow-soft);
}

.freshness--unknown {
  color: var(--muted);
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   Карточка поездки
   -------------------------------------------------------------------------- */

.trip-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trip {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  padding: 20px 22px;
  background: var(--white);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s, border-color 0.18s;
}

.trip:hover {
  border-color: #d5e4f7;
  box-shadow: var(--shadow);
}

/* Время */

.trip__time {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 20px;
  border-right: 1px solid var(--line-soft);
}

.trip__day {
  color: var(--slate);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.trip__month {
  color: var(--muted);
  font-size: 13px;
}

.trip__clock {
  margin-top: 6px;
  color: var(--slate);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trip__relative {
  margin-top: 2px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Маршрут с таймлайном */

.trip__route {
  display: flex;
  gap: 14px;
  align-items: stretch;
  min-width: 0;
}

.timeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 5px;
  padding-bottom: 5px;
}

.timeline__dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: var(--white);
}

.timeline__dot--end {
  background: var(--blue);
}

.timeline__line {
  flex: 1 1 auto;
  width: 2px;
  min-height: 16px;
  background: linear-gradient(var(--blue), #b9d8fb);
}

.trip__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.trip__cities {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.trip__city {
  overflow: hidden;
  color: var(--slate);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip__city--to {
  font-weight: 700;
}

/* Вторичная строка: через что, окно времени, машина, места. Пустые
   элементы не рисуются, поэтому отступов «в никуда» не остаётся. */
.trip__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  color: var(--muted);
  font-size: 13px;
}

.trip__meta > span:not(:last-child)::after {
  content: "·";
  margin-left: 12px;
  color: var(--line);
}

.trip__car {
  color: var(--slate);
}

.trip__meta .badge {
  font-size: 12px;
}

.trip__unknown {
  color: var(--muted);
  font-size: 13px;
}

/* Цена и действие */

.trip__aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 148px;
}

.trip__price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}

.trip__price strong {
  color: var(--slate);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.trip__price span {
  color: var(--muted);
  font-size: 12px;
}

.trip__no-price {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
}

.badge--seats {
  color: #2f7a39;
  background: var(--green-soft);
}

/* «Максимум двое сзади» — не характеристика свободных мест, а условие
   поездки, поэтому цвет нейтральный: зелёный уже занят бейджем мест. */
.badge--back-row {
  gap: 5px;
  padding: 3px 9px 3px 7px;
  color: var(--slate);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-weight: 500;
}

.badge--back-row svg {
  flex: 0 0 auto;
  color: var(--muted);
}

/* Подробности */

.trip__details {
  grid-column: 1 / -1;
}

.trip__details summary {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.trip__details summary::-webkit-details-marker {
  display: none;
}

.trip__details summary::before {
  content: "▸ ";
}

.trip__details[open] summary::before {
  content: "▾ ";
}

.trip__details summary:hover {
  color: var(--blue);
}

.trip__facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 12px 0 0;
  padding: 14px 16px;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.trip__facts dt {
  color: var(--muted);
}

.trip__facts dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Компактный вид для «без времени» */

.trip-list--compact .trip {
  grid-template-columns: 1fr auto;
  padding: 14px 18px;
}

.trip-list--compact .trip__time {
  display: none;
}

/* --------------------------------------------------------------------------
   Пустое состояние, пагинация, доп. блоки
   -------------------------------------------------------------------------- */

.empty-state {
  padding: 48px 0;
  text-align: center;
}

.empty-state h1,
.empty-state h2 {
  margin-bottom: 12px;
  font-size: 24px;
}

.empty-state p {
  max-width: 520px;
  margin: 0 auto 20px;
  color: var(--muted);
}

.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
}

.pager__status {
  color: var(--muted);
  font-size: 14px;
}

.extra {
  margin-top: 32px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius);
}

.extra > summary {
  color: var(--slate);
  font-weight: 600;
  cursor: pointer;
}

.extra__hint {
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   Подвал
   -------------------------------------------------------------------------- */

.site-footer {
  padding: 40px 0 56px;
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--line-soft);
}

.site-footer p {
  max-width: 680px;
}

.site-footer__meta {
  margin-top: 12px;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------------- */

@media (max-width: 960px) {
  .results__layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .results__aside {
    position: static;
  }

  /* На узком экране фильтры — свёрнутый блок: иначе они выталкивают
     выдачу за пределы первого экрана. */
  .filters-wrap {
    padding: 14px 16px;
    background: var(--white);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
  }

  .filters-wrap__summary {
    display: block;
    color: var(--slate);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
  }

  .filters-wrap[open] .filters-wrap__summary {
    margin-bottom: 14px;
  }

  .filters {
    padding: 0;
    border: none;
    border-radius: 0;
  }

  .filters__head {
    display: none;
  }

  .filters__group:nth-of-type(3) {
    display: none;
  }

  .search-form__row {
    flex-wrap: wrap;
  }

  .search-form__submit {
    flex: 1 1 auto;
  }

  .trip {
    grid-template-columns: 84px 1fr;
    gap: 16px;
  }

  .trip__aside {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
  }

  .trip__price {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 32px 0 40px;
  }

  .site-nav {
    display: none;
  }

  .trip {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }

  .trip__time {
    flex-flow: row wrap;
    align-items: baseline;
    gap: 8px;
    padding-right: 0;
    padding-bottom: 12px;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
  }

  .trip__day {
    font-size: 22px;
  }

  .trip__clock {
    margin-top: 0;
    font-size: 18px;
  }

  .trip__relative {
    margin-top: 0;
  }

  .trip__aside {
    flex-wrap: wrap;
    gap: 10px;
  }

  .search-form {
    padding: 12px;
    border-radius: var(--radius);
  }

  .search-form__filters {
    gap: 12px;
  }

  .results {
    padding-top: 24px;
  }

  .results__meta {
    align-items: flex-start;
  }
}

/* Уважаем настройку «меньше движения». */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
