/* Calendrier de recherche, écran et barre de chargement, contexte partagé.
   Feuille 04 sur 08 : les pages les chargent dans l’ordre des numéros, qui est celui
   de la cascade. Une règle peut corriger une feuille précédente, jamais une suivante. */

/* Calendrier de recherche */
.search-card {
  position: relative;
}
.date-picker {
  position: absolute;
  z-index: 20;
  left: 50%;
  width: min(880px, calc(100% - 56px));
  transform: translateX(-50%);
  top: calc(100% - 18px);
  padding: 22px 28px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 22px 46px rgba(16, 42, 67, 0.16);
}
.date-picker-topline,
.date-picker-months,
.date-picker-footer {
  display: flex;
  align-items: center;
}
.date-picker-topline {
  position: relative;
  justify-content: flex-end;
  min-height: 38px;
  margin-bottom: 12px;
}
.date-picker-step {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.date-picker-topline strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1rem;
}
.date-picker-close svg,
.month-control svg {
  width: 18px;
  height: 18px;
}
.date-picker-close,
.month-control {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}
.date-picker-close:hover,
.month-control:hover {
  border-color: var(--lagoon);
  background: var(--mint);
}
.calendar-navigation {
  position: absolute;
  left: 50%;
  top: 0;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
}
.date-picker-months {
  gap: 20px;
  align-items: center;
}
.calendar-months {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 38px;
  flex: 1;
}
.calendar-month h3 {
  margin: 0 0 14px;
  text-align: center;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  text-transform: capitalize;
}
.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}
.calendar-weekdays {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}
.calendar-day {
  position: relative;
  min-height: 36px;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 0.84rem/1 var(--sans);
  cursor: pointer;
  transition:
    background 0.16s ease,
    color 0.16s ease;
}
.calendar-day > span {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: auto;
  border-radius: 50%;
}
.calendar-day:hover:not(:disabled) > span {
  background: var(--mint);
}
.calendar-day:disabled {
  color: #c7d0d9;
  cursor: not-allowed;
}
.calendar-day.is-in-range {
  background: #e6f1f4;
}
.calendar-day.is-range-start {
  background: linear-gradient(to right, transparent 50%, #e6f1f4 50%);
}
.calendar-day.is-range-end {
  background: linear-gradient(to right, #e6f1f4 50%, transparent 50%);
}
.calendar-day.is-selected > span {
  background: var(--ink);
  color: #fff;
}
.date-picker-footer {
  justify-content: space-between;
  margin-top: 17px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.clear-dates,
.apply-dates {
  border: 0;
  border-radius: var(--r-sm);
  padding: 10px 15px;
  font: 700 0.84rem var(--sans);
  cursor: pointer;
}
.clear-dates {
  background: transparent;
  color: var(--muted);
}
.apply-dates {
  background: var(--ink);
  color: #fff;
}
@media (max-width: 700px) {
  .date-picker {
    position: fixed;
    inset: auto 10px 10px;
    width: auto;
    transform: none;
    max-height: 82vh;
    overflow: auto;
    padding: 19px 16px 14px;
    border-radius: var(--r-lg);
    box-shadow: 0 10px 44px rgba(16, 42, 67, 0.28);
  }
  .date-picker-topline {
    min-height: 34px;
    margin-bottom: 10px;
  }
  .calendar-months {
    grid-template-columns: 1fr;
    gap: 22px;
    touch-action: pan-y;
  }
  .calendar-months .calendar-month:nth-child(2) {
    display: none;
  }
  .date-picker-months {
    display: block;
  }
}

/* Le calendrier se parcourt par glissement. */
.calendar-months.is-sliding-next {
  animation: calendar-slide-next 0.22s ease-out;
}
.calendar-months.is-sliding-previous {
  animation: calendar-slide-previous 0.22s ease-out;
}
@keyframes calendar-slide-next {
  from {
    opacity: 0.3;
    transform: translateX(22px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes calendar-slide-previous {
  from {
    opacity: 0.3;
    transform: translateX(-22px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Recherche : deux itinéraires convergent visuellement vers le même point. */
/* Chargement, temps 1 : page dédiée. Tant qu'aucun résultat n'existe, c'est elle qui
   occupe la page — ce n'est plus une fenêtre posée par-dessus les résultats. */
.search-loading[hidden] {
  display: none;
}
.search-loading {
  display: grid;
  place-items: center;
  min-height: min(52vh, 440px);
  padding: 56px 24px 72px;
}
.search-loading-panel {
  width: min(100%, 620px);
  text-align: center;
}
/* Le libellé fonctionnel n'est là que pour les lecteurs d'écran : à l'écran, la barre de
   recherche dit déjà ce qui se passe, et cette place revient à la phrase. */
.search-loading-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.search-loading-line {
  margin: 0;
  color: var(--ink);
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(24px, 3.4vw, 34px);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
@keyframes inline-progress {
  from {
    transform: translateX(-105%);
  }
  to {
    transform: translateX(365%);
  }
}
/* Chargement, temps 2 : les premiers résultats sont consultables, la recherche continue. */
.results-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(1180px, calc(100% - 48px));
  margin: 20px auto -4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.results-loading[hidden] {
  display: none;
}
.results-loading-bar {
  display: block;
  flex: 0 0 88px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--line);
  overflow: hidden;
}
.results-loading-bar > span {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  animation: inline-progress 1.6s ease-in-out infinite;
}
@media (max-width: 700px) {
  body.results-page .results-loading {
    width: calc(100% - 32px);
    margin: 16px auto -4px;
  }
}
/* La barre de progression EST l'animation : chaque départ progresse vers le point de
   rencontre, et le chemin parcouru est la progression. Durée pilotée par --loading-duration
   (la latence réelle de la recherche). */
.flight-progress {
  --loading-duration: 3000ms;
  position: relative;
  width: min(100%, 340px);
  height: 34px;
  margin: 32px auto 0;
}
.flight-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - 2px);
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--line);
}
.flight-progress-fill {
  position: absolute;
  top: calc(50% - 2px);
  width: 50%;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--coral);
  animation: flight-fill var(--loading-duration) cubic-bezier(0.45, 0.05, 0.3, 1) infinite;
}
.flight-progress-fill-left {
  left: 0;
  transform-origin: left;
}
.flight-progress-fill-right {
  right: 0;
  transform-origin: right;
}
@keyframes flight-fill {
  0% {
    transform: scaleX(0);
    opacity: 0;
  }
  6% {
    transform: scaleX(0);
    opacity: 1;
  }
  72%,
  82% {
    transform: scaleX(1);
    opacity: 1;
  }
  88% {
    transform: scaleX(1);
    opacity: 0;
  }
  89%,
  100% {
    transform: scaleX(0);
    opacity: 0;
  }
}
.flight-point {
  position: absolute;
  z-index: 2;
  top: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lagoon);
  box-shadow: 0 0 0 4px var(--cream);
}
.flight-point-left {
  left: 0;
}
.flight-point-right {
  right: 0;
}
.flight-meeting-point {
  position: absolute;
  z-index: 2;
  top: calc(50% - 6px);
  left: calc(50% - 6px);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 7px rgba(255, 106, 19, 0.16);
  animation: meeting-pulse 1.6s ease-in-out infinite;
}
.flight-rail {
  position: absolute;
  inset: 0;
}
.flight-rail-left {
  animation: rail-from-left var(--loading-duration) cubic-bezier(0.45, 0.05, 0.3, 1) infinite;
}
.flight-rail-right {
  animation: rail-from-right var(--loading-duration) cubic-bezier(0.45, 0.05, 0.3, 1) infinite;
}
@keyframes rail-from-left {
  0% {
    transform: translateX(0);
    opacity: 0;
  }
  6% {
    transform: translateX(0);
    opacity: 1;
  }
  72%,
  82% {
    transform: translateX(46%);
    opacity: 1;
  }
  88% {
    transform: translateX(46%);
    opacity: 0;
  }
  89%,
  100% {
    transform: translateX(0);
    opacity: 0;
  }
}
@keyframes rail-from-right {
  0% {
    transform: translateX(0);
    opacity: 0;
  }
  6% {
    transform: translateX(0);
    opacity: 1;
  }
  72%,
  82% {
    transform: translateX(-46%);
    opacity: 1;
  }
  88% {
    transform: translateX(-46%);
    opacity: 0;
  }
  89%,
  100% {
    transform: translateX(0);
    opacity: 0;
  }
}
.flight-plane {
  position: absolute;
  z-index: 3;
  top: calc(50% - 11px);
  width: 22px;
  height: 22px;
  color: var(--ink);
}
.flight-plane svg {
  display: block;
  width: 100%;
  height: 100%;
}
/* L'avion du module vole déjà vers la droite : celui parti de gauche n'a rien à faire,
   celui parti de droite se retourne. Une rotation de 90° supposait un avion vu de dessus. */
.flight-rail-left .flight-plane {
  left: -11px;
}
.flight-rail-right .flight-plane {
  right: -11px;
}
.flight-rail-right .flight-plane svg {
  transform: scaleX(-1);
}
@keyframes meeting-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 7px rgba(255, 106, 19, 0.12);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(255, 106, 19, 0.03);
  }
}

@media (max-width: 600px) {
  .search-loading {
    min-height: min(48vh, 380px);
    padding: 40px 16px 56px;
  }
  .flight-progress {
    width: min(100%, 260px);
  }
  .search-loading-copy {
    font-size: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .flight-meeting-point,
  .flight-progress-fill,
  .flight-rail,
  .results-loading-bar > span {
    animation: none;
  }
  .flight-progress-fill {
    transform: scaleX(1);
  }
  .flight-rail-left {
    transform: translateX(46%);
  }
  .flight-rail-right {
    transform: translateX(-46%);
  }
  .results-loading-bar > span {
    width: 100%;
  }
}
.favorite-result {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--coral);
  font-size: 22px;
  box-shadow: 0 5px 18px rgba(16, 42, 67, 0.16);
}
.favorite-result svg {
  width: 20px;
  height: 20px;
}
.save-search svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}
.favorite-heart-toggle svg,
.search-trash svg {
  width: 18px;
  height: 18px;
}
.favorite-result:hover,
.favorite-result:focus-visible {
  transform: scale(1.05);
  outline: 3px solid var(--coral);
  outline-offset: 2px;
}
.detail-favorite {
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  cursor: pointer;
}
.detail-favorite-status:empty {
  display: none;
}
.detail-favorite-status.is-toast {
  position: fixed;
  z-index: 140;
  left: 50%;
  bottom: 28px;
  min-height: 0;
  margin: 0;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: #fff;
  box-shadow: 0 14px 38px rgba(6, 17, 30, 0.28);
  transform: translateX(-50%);
}
.share-destination {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--coral);
  box-shadow: 0 5px 18px rgba(16, 42, 67, 0.16);
}
.share-destination svg {
  width: 20px;
  height: 20px;
}
.share-destination:hover,
.share-destination:focus-visible {
  transform: scale(1.05);
  outline: 3px solid var(--coral);
  outline-offset: 2px;
}
.favorite-status {
  min-height: 20px;
  margin: -12px 0 16px;
  color: var(--lagoon);
  font-size: 12px;
  font-weight: 700;
}
.detail-page .flight-actions {
  grid-column: 4;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #fff6e8;
}
.detail-page .flight-person.one-way .flight-actions {
  grid-column: 3;
  grid-row: 1;
}
.detail-page .flight-actions .flight-price {
  grid-column: auto;
  grid-row: auto;
  width: 100%;
  min-height: 0;
}
.share-flight {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 700 12px var(--sans);
  cursor: pointer;
}
.share-flight svg {
  width: 19px;
  height: 19px;
  color: var(--coral);
}
.share-flight:hover,
.share-flight:focus-visible {
  background: var(--mint);
  outline: 0;
}
.share-flight:focus-visible {
  box-shadow: inset 0 0 0 3px var(--coral);
}
.share-status {
  min-height: 20px;
  margin: 0 0 8px;
  color: var(--lagoon);
  font-size: 13px;
  font-weight: 700;
}
@media (max-width: 760px) {
  .detail-page .flight-actions,
  .detail-page .flight-person.one-way .flight-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
  }
  .detail-page .flight-actions .flight-price {
    min-height: 94px;
  }
  .share-flight {
    min-width: 94px;
    border-top: 0;
    border-left: 1px solid var(--line);
    flex-direction: column;
  }
}

.shared-context {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin: 16px 0 0;
  padding: 15px 17px;
  border: 1px solid #c7d5e1;
  border-radius: var(--r-md);
  background: var(--mint);
  color: var(--ink);
}
.shared-context svg {
  width: 25px;
  height: 25px;
  color: var(--lagoon);
}
.shared-context strong,
.shared-context span {
  display: block;
}
.shared-context span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.shared-context a {
  color: var(--lagoon);
  font-size: 12px;
  font-weight: 800;
}
.flight-person.is-shared {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}
@media (max-width: 760px) {
  .shared-context {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .shared-context a {
    grid-column: 2;
    min-height: 36px;
    display: flex;
    align-items: center;
  }
}
