/* Поиск авиабилетов FlyJoy. Использует цвета сайта из design.css:
   --ink, --muted, --blue, --line, --lilac, --paper. */

.fj-avia-hero { padding-top: 40px; }
.fj-avia-hero h1 { margin: 6px 0 10px; }
.fj-avia-hero p { max-width: 620px; font-size: 17px; margin: 0; }

.fj-avia { margin: 28px 0 64px; color: var(--ink); }
.fj-avia [hidden] { display: none !important; }

/* --- Форма поиска --- */
.fj-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
  gap: 16px 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 40px -30px rgba(21, 44, 64, .45);
}
.fj-search__route { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: end; grid-column: 1 / -1; }
.fj-search__dates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fj-search__pax { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr); gap: 10px; }
.fj-field--small span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Пассажиры и класс свёрнуты в одну строку; раскрываются строкой формы ниже. */
#fj-pax { grid-column: 1 / -1; }
.fj-pax-toggle {
  min-height: 48px; padding: 11px 40px 11px 14px; text-align: left;
  border: 1px solid #d6d3ca; border-radius: 12px; background: var(--paper) no-repeat right 14px center;
  color: var(--ink); font: inherit; font-size: 16px; font-weight: 500; letter-spacing: 0; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-size: 5px 5px, 5px 5px; background-position: right 20px center, right 15px center;
}
.fj-pax-toggle[aria-expanded="true"] { border-color: var(--blue); }

/* --- Три ответа над выдачей --- */
.fj-picks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 28px 0 0; }
@media (max-width: 1000px) { .fj-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fj-pick {
  display: grid; gap: 4px; align-content: start; padding: 16px 18px; text-align: left;
  border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
button.fj-pick:hover { border-color: var(--blue); transform: translateY(-2px); }
.fj-pick:first-child { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.fj-pick__label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.fj-pick__info { color: var(--blue); }
.fj-pick strong { font-size: 22px; font-weight: 650; color: var(--blue); }
.fj-pick small { color: var(--muted); font-size: 13px; }
.fj-pick--empty { cursor: default; opacity: .7; }
@media (prefers-reduced-motion: reduce) { .fj-pick { transition: none; } }
.fj-submit { grid-column: 1 / -1; justify-self: start; min-width: 220px; }

.fj-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.fj-field input, .fj-field select, .fj-field textarea, .fj-city__box {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid #d6d3ca;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
}
.fj-field textarea { resize: vertical; min-height: 80px; }
.fj-field input:focus, .fj-field select:focus, .fj-field textarea:focus, .fj-city__box:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: transparent;
}
.fj-field--small select { padding-inline: 10px; }

.fj-city { position: relative; }
.fj-city__box { display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.fj-city__box input { border: 0; outline: 0; padding: 0; min-height: 46px; background: transparent; }
.fj-city__box input:focus { outline: 0; }
.fj-city__code { font-size: 13px; font-weight: 700; color: var(--muted); }
.fj-city__list {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 40px -20px rgba(21, 44, 64, .4);
  max-height: 320px; overflow: auto;
}
.fj-city__list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 15px; color: var(--ink); }
.fj-city__list li small { color: var(--muted); font-weight: 400; }
.fj-city__list li:hover, .fj-city__list li[aria-selected="true"] { background: var(--lilac); }
.fj-city__list .fj-city__empty { color: var(--muted); cursor: default; }

.fj-swap {
  width: 44px; height: 44px; margin-bottom: 2px;
  border: 1px solid var(--line); border-radius: 50%;
  background: #fff; color: var(--blue); font-size: 18px; cursor: pointer;
}
.fj-swap:hover { background: var(--lilac); }

/* --- Сообщения --- */
.fj-warning { margin: 18px 0 0; padding: 12px 16px; border-radius: 12px; background: #fdf5e4; color: #6b4e14; font-size: 14px; }
.fj-error { margin: 14px 0 0; padding: 12px 16px; border-radius: 12px; background: #fdecec; color: #8a1f1f; font-size: 14px; }
.fj-loading, .fj-empty { margin: 28px 0; color: var(--muted); }
.fj-note { color: var(--muted); font-size: 14px; }

/* --- Результаты --- */
.fj-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin: 28px 0 12px; }
.fj-summary { margin: 0; font-weight: 600; color: var(--ink); }
.fj-toolbar__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; font-size: 14px; }
.fj-toolbar select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.fj-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.fj-results { display: grid; gap: 14px; }
.fj-offer {
  display: grid; grid-template-columns: minmax(0, 1fr) 210px;
  border: 1px solid var(--line); border-radius: 18px; background: #fff; overflow: hidden;
}
.fj-offer__main { display: grid; gap: 14px; padding: 20px 22px; }
.fj-offer__carrier { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.fj-offer__carrier span { color: var(--muted); font-size: 14px; }
.fj-offer__airline { display: inline-flex; align-items: center; gap: 10px; font-size: 17px; }
.fj-airline-logo { flex: none; border-radius: 8px; background: #fff; box-shadow: 0 0 0 1px rgba(11,26,42,.08); object-fit: contain; }
.fj-pick__airline { display: inline-flex; align-items: center; gap: 6px; }
.fj-pick__airline .fj-airline-logo { border-radius: 5px; }
.fj-offer__side { display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 20px; background: var(--paper); border-left: 1px solid var(--line); }
.fj-offer__side small { color: var(--muted); }
.fj-offer__side .button { margin-top: 8px; }
.fj-price { font-size: 26px; font-weight: 650; letter-spacing: -.02em; color: var(--blue); }
.fj-seats { color: #9a3c12; font-size: 13px; font-weight: 600; }
.fj-tag { padding: 2px 8px; border-radius: 999px; background: var(--lilac); color: var(--ink) !important; font-size: 12px !important; }

.fj-dir { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 1.2fr) minmax(0, 1fr); align-items: center; gap: 12px; }
.fj-dir__point { display: flex; flex-direction: column; min-width: 0; }
.fj-dir__point strong { font-size: 22px; font-weight: 650; }
.fj-dir__point span { font-size: 14px; overflow-wrap: anywhere; }
.fj-dir__point small { color: var(--muted); font-size: 12px; }
.fj-dir__point--end { text-align: right; }
.fj-dir__line { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--muted); font-size: 12px; }
.fj-dir__track { position: relative; width: 100%; height: 2px; background: var(--line); }
.fj-dir__track::before, .fj-dir__track::after { content: ""; position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.fj-dir__track::before { left: 0; }
.fj-dir__track::after { right: 0; }
.fj-dir__transfer { color: #9a3c12; }

.fj-offer__badges { display: flex; flex-wrap: wrap; gap: 6px; }
.fj-badge { display: inline-flex; align-items: center; gap: 2px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.fj-badge--available { background: #e6f2ea; color: #1d5a32; }
.fj-badge--unavailable { background: #f3eeee; color: #7a3434; }
.fj-badge--unknown { background: var(--lilac); color: var(--muted); }
.fj-more { margin: 18px auto 0; display: flex; }

/* --- Окно с подробностями --- */
.fj-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border: 0; border-radius: 22px; background: var(--paper); color: var(--ink); }
.fj-dialog::backdrop { background: rgba(21, 44, 64, .45); backdrop-filter: blur(3px); }
.fj-panel__top { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; background: var(--paper); border-bottom: 1px solid var(--line); }
.fj-panel__top h2 { margin: 0; font-size: 24px; }
.fj-close { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: #fff; cursor: pointer; font-size: 16px; color: var(--ink); }
.fj-panel__body { padding: 8px 24px 28px; }
.fj-panel__price { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 18px 0 6px; }
.fj-panel__price strong { font-size: 28px; color: var(--blue); }
.fj-panel__block { padding: 0; margin-top: 20px; }
.fj-panel__block h3 { margin: 0 0 10px; font-size: 18px; }

.fj-segs { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.fj-seg { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; font-size: 14px; }
.fj-seg__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.fj-seg__head span, .fj-seg small { color: var(--muted); }

.fj-conds { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.fj-conds li { display: grid; grid-template-columns: 190px 1fr; gap: 10px; align-items: start; font-size: 14px; color: var(--muted); white-space: pre-line; }
.fj-conds .fj-badge { justify-self: start; }

.fj-fams { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.fj-fam { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-align: left; cursor: pointer; color: var(--ink); font: inherit; }
.fj-fam:hover { border-color: var(--blue); }
.fj-fam.is-current { border: 2px solid var(--blue); cursor: default; }
.fj-fam__price { font-size: 18px; font-weight: 650; color: var(--blue); }
.fj-fam small { color: var(--muted); }

.fj-rules { margin-top: 20px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.fj-rules summary { padding: 14px 16px; cursor: pointer; font-weight: 600; }
.fj-rules div { padding: 0 16px 16px; }
.fj-rules h4 { margin: 8px 0; }
.fj-rules pre { margin: 0; white-space: pre-wrap; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--muted); max-height: 360px; overflow: auto; }

.fj-lead { margin-top: 26px; padding: 22px; border-radius: 18px; background: #fff; border: 1px solid var(--line); display: grid; gap: 14px; }
.fj-lead h3 { margin: 0; font-size: 20px; }
.fj-lead p { margin: 0; font-size: 14px; }
.fj-lead__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fj-lead .button { justify-self: start; min-width: 200px; cursor: pointer; }
.fj-lead .button:disabled { opacity: .6; cursor: wait; }
.fj-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.fj-consent input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.fj-form-status { min-height: 1em; font-size: 14px; }
.fj-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* --- Телефоны и планшеты --- */
@media (max-width: 860px) {
  .fj-search { grid-template-columns: 1fr; padding: 18px; }
  .fj-search__pax { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fj-offer { grid-template-columns: 1fr; }
  .fj-offer__side { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; border-left: 0; border-top: 1px solid var(--line); }
  .fj-offer__side .button { margin-top: 0; }
  .fj-lead__grid { grid-template-columns: 1fr; }
  .fj-conds li { grid-template-columns: 1fr; gap: 4px; }
  /* Три ответа — компактным списком: все видны сразу (в ленте «С багажом» уходила за край экрана). */
  .fj-picks { grid-template-columns: 1fr; gap: 8px; margin-top: 20px; }
  .fj-pick { grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 2px; padding: 12px 14px; }
  .fj-pick__label { grid-column: 1; align-self: center; }
  .fj-pick strong { grid-column: 2; grid-row: 1 / span 3; align-self: center; font-size: 20px; }
  .fj-pick small { grid-column: 1; }
}
@media (max-width: 520px) {
  .fj-search__route { grid-template-columns: 1fr; }
  .fj-swap { justify-self: end; margin: -6px 0; transform: rotate(90deg); }
  .fj-submit { width: 100%; }
  .fj-dir__point strong { font-size: 18px; }
  .fj-panel__body, .fj-panel__top { padding-inline: 16px; }
  .fj-lead { padding: 16px; }
}

/* --- Микро-анимации (ТЗ «Поиск 2.0»): 150–400 мс, одна кривая, только transform и opacity --- */
:root { --fj-ease: cubic-bezier(.2, .7, .2, 1); }

/* Ожидание поиска: самолётик по пунктиру и скелетоны карточек */
.fj-wait { display: grid; gap: 14px; margin: 28px 0; }
.fj-wait .fj-loading { margin: 0; }
.fj-wait__route { display: flex; align-items: center; gap: 8px; max-width: 360px; }
.fj-wait__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: none; }
.fj-wait__line { position: relative; flex: 1; height: 18px; background: linear-gradient(90deg, var(--line) 50%, transparent 0) center / 10px 2px repeat-x; overflow: hidden; }
.fj-wait__plane { position: absolute; top: -1px; left: 0; color: var(--blue); font-size: 16px; line-height: 1; animation: fj-fly 1.8s var(--fj-ease) infinite; }
/* Паровоз (поиск поездов) выше самолётика — полоса выше, чтобы колёса не обрезались. */
.fj-wait--train .fj-wait__line { height: 30px; }
.fj-wait__train svg { display: block; }
@keyframes fj-fly { from { transform: translateX(-20px); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } to { transform: translateX(340px); opacity: 0; } }
.fj-skeleton { display: grid; gap: 10px; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.fj-skeleton__bar { display: block; height: 12px; width: 60%; border-radius: 6px; background: linear-gradient(90deg, #eeece6 25%, #f7f5f0 45%, #eeece6 65%) 0 0 / 300% 100%; animation: fj-shimmer 1.4s linear infinite; }
.fj-skeleton__bar--wide { width: 85%; height: 18px; }
.fj-skeleton__bar--short { width: 35%; }
@keyframes fj-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* Появление результатов: подъём на 8 px с шагом 40 мс */
.fj-rise { animation: fj-rise .25s var(--fj-ease) both; animation-delay: calc(var(--fj-i, 0) * 40ms); }
@keyframes fj-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fj-fade { animation: fj-fade .3s var(--fj-ease) both; }
@keyframes fj-fade { from { opacity: 0; } to { opacity: 1; } }

/* Окно рейса: справа на компьютере, снизу на телефоне; фон размыт */
.fj-dialog[open] { animation: fj-panel-in .3s var(--fj-ease); }
.fj-dialog[open]::backdrop { animation: fj-fade .3s var(--fj-ease); }
@keyframes fj-panel-in { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@media (max-width: 860px) {
  @keyframes fj-panel-in { from { opacity: 0; transform: translateY(32px); } to { opacity: 1; transform: none; } }
}

/* Кнопка ⇄ поворачивается; выбранный код города вспыхивает */
.fj-swap { transition: transform .25s var(--fj-ease), background .15s; }
.fj-swap.is-turned { transform: rotate(180deg); }
@media (max-width: 520px) { .fj-swap.is-turned { transform: rotate(270deg); } }
.fj-city__code.is-new { animation: fj-flash .4s var(--fj-ease); }
@keyframes fj-flash { from { color: var(--blue); transform: scale(1.15); } to { transform: none; } }
.fj-city__list:not([hidden]) { animation: fj-drop .15s var(--fj-ease); }
@keyframes fj-drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Цена перетекает при смене тарифа */
.fj-price.is-changed, .fj-panel__price strong.is-changed { animation: fj-flash .4s var(--fj-ease); display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  .fj-wait__plane, .fj-skeleton__bar, .fj-rise, .fj-fade, .fj-dialog[open], .fj-dialog[open]::backdrop,
  .fj-city__code.is-new, .fj-city__list:not([hidden]), .fj-price.is-changed, .fj-panel__price strong.is-changed { animation: none; }
  .fj-swap { transition: none; }
}

/* --- Календарь низких цен --- */
.fj-cal { grid-column: 1 / -1; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.fj-cal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.fj-cal__title { font-size: 15px; text-transform: capitalize; }
.fj-cal__nav { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--blue); font-size: 18px; cursor: pointer; }
.fj-cal__nav:disabled { opacity: .35; cursor: default; }
.fj-cal__week, .fj-cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.fj-cal__week span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding-bottom: 4px; }
.fj-cal__day {
  display: grid; justify-items: center; gap: 1px; min-height: 48px; padding: 6px 2px; border: 1px solid transparent; border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; cursor: pointer; transition: border-color .15s, transform .15s;
}
.fj-cal__day b { font-size: 14px; font-weight: 600; }
.fj-cal__day small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
button.fj-cal__day:hover { border-color: var(--blue); }
.fj-cal__day--blank, .fj-cal__day--off { background: transparent; cursor: default; color: #b9b6ad; }
/* Сочные цвета цен: зелёный — дёшево, оранжевый — средне, красный — дорого; текст белый. */
.fj-cal__day--cheap { background: #2FB35A; }
.fj-cal__day--mid { background: #F59A23; }
.fj-cal__day--high { background: #C9343A; }
/* Контраст не ниже 4.5:1 (ТЗ, A11Y / D-06): на зелёном и оранжевом — тёмный текст, на красном — белый. */
.fj-cal__day--cheap, .fj-cal__day--mid { color: #0B1A2A; }
.fj-cal__day--high { color: #fff; }
.fj-cal__day--cheap small, .fj-cal__day--mid small, .fj-cal__day--high small { color: inherit; font-weight: 700; }
button.fj-cal__day--cheap:hover, button.fj-cal__day--mid:hover, button.fj-cal__day--high:hover { border-color: transparent; transform: translateY(-2px); filter: brightness(1.06); }
.fj-cal__day.is-selected { border-color: var(--navy, #0B1A2A); box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--navy, #0B1A2A); }
.fj-cal__grid.is-loading .fj-cal__day small { opacity: .3; }
.fj-cal__grid.is-loading { animation: fj-fade .6s ease-in-out infinite alternate; }
.fj-cal__note { margin: 10px 0 0; font-size: 12px; font-weight: 400; color: var(--muted); }
@media (max-width: 520px) {
  .fj-cal { padding: 12px 8px; }
  .fj-cal__week, .fj-cal__grid { gap: 2px; }
  .fj-cal__day { min-height: 44px; padding: 5px 0; }
  .fj-cal__day small { font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) { .fj-cal__day { transition: none; } .fj-cal__grid.is-loading { animation: none; } }
/* Подвал окон поиска (общий для всех окон: они подключают этот файл). Строки переносятся, а не сжимаются. */
.wrap > footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 24px 0 32px; font-size: 12px; line-height: 1.7; }
.wrap > footer a { text-underline-offset: 3px; }
/* Долгий поиск у поставщика: пояснение через 10 с (ТЗ, TECH-03). */
.fj-slow { margin: 12px 0 0; font-size: 14px; color: #5A6B7D; }
