/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

 html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: "DM Sans", sans-serif;
  scroll-behavior: smooth;
}

:root {
  --swiper-pagination-color: #FFFFFF;
  --swiper-pagination-bullet-size: 6px;
  --swiper-pagination-bullet-width: 6px;
  --swiper-pagination-bullet-height: 6px;
  --swiper-pagination-bullet-inactive-color: #000;
  --swiper-pagination-bullet-inactive-opacity: 0.2;
  --swiper-pagination-bullet-opacity: 1;
  --swiper-pagination-bullet-horizontal-gap: 2px;
  --swiper-pagination-bullet-vertical-gap: 6px;
}

/* Messages flash (shared/_flash_messages) : bottom-10 par défaut. En mobile
   web, la barre d'onglets est fixée en bas (5rem + safe area) : sans ce
   décalage, le message tombait dessus. En natif, les pages portent souvent
   une barre d'actions collante en bas (et la tab bar UIKit) : le message
   s'affiche en haut, sous la status bar. */
@media (max-width: 39.9375rem) {
  body:has(header[data-bottom-tab-bar]) #flash {
    bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
  }
}

body[data-turbo-native] #flash {
  top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
  bottom: auto;
}

/* Progress bar Turbo : visible pour les visites initiées par l'utilisateur —
   sur réseau lent, sans elle un tap paraît « mort ». Masquée UNIQUEMENT pendant
   les visites déclenchées par un refresh broadcasté (pattern Fizzy, cf.
   docs/realtime-updates.md) : src/turbo_streams.js pose data-stream-refresh sur
   <html> le temps de cette visite. `visibility: hidden` et non `display: none` :
   Turbo pilote toujours l'élément, on ne casse pas son cycle de rendu. */
.turbo-progress-bar {
  background-color: #ff385c; /* corail de marque, cf. tab bar iOS */
}

html[data-stream-refresh] .turbo-progress-bar {
  visibility: hidden;
}

/* Feedback global de soumission (réseau lent) : Turbo pose aria-busy="true"
   sur le <form> et désactive le bouton soumetteur pendant la requête. On rend
   cet état visible sur tous les boutons submit sans opt-in par vue : bouton
   estompé + spinner centré À LA PLACE du contenu (texte et icônes masqués,
   largeur conservée : rien ne bouge). Le texte est masqué par
   -webkit-text-fill-color et non color, pour que le spinner garde
   currentColor. Seul le bouton cliqué bascule (:disabled : Turbo désactive le
   soumetteur, submit_once_controller tous les boutons) — dans un formulaire à
   deux boutons submit, l'autre garde son libellé. Les boutons qui gèrent déjà
   leur propre spinner (group-aria-busy:* ou .show-when-busy) sont exclus. */
form[aria-busy="true"] :is(button:not([type]), button[type="submit"], input[type="submit"]) {
  opacity: 0.7;
  pointer-events: none;
}

form[aria-busy="true"] :is(button:not([type]), button[type="submit"]):disabled:not(:has([class*="group-aria-busy"], .show-when-busy)) {
  -webkit-text-fill-color: transparent;
}

/* Bouton déjà positionné (absolute/fixed/sticky) : il sert lui-même de repère
   au spinner, on ne l'écrase pas en relative. */
form[aria-busy="true"] :is(button:not([type]), button[type="submit"]):disabled:not(:has([class*="group-aria-busy"], .show-when-busy)):not(.absolute, .fixed, .sticky) {
  position: relative;
}

form[aria-busy="true"] :is(button:not([type]), button[type="submit"]):disabled:not(:has([class*="group-aria-busy"], .show-when-busy)) > * {
  visibility: hidden;
}

form[aria-busy="true"] :is(button:not([type]), button[type="submit"]):disabled:not(:has([class*="group-aria-busy"], .show-when-busy))::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 9999px;
  animation: busy-spin 0.6s linear infinite;
}

/* Navigation par frame (onglets HTML via #main) : en plus du fondu [busy], un
   spinner centré apparaît si la réponse tarde (~300 ms) — seul feedback de ces
   navigations, la progress bar Turbo ne couvrant pas les fetchs de frame.
   Réservé aux navigations par lien : un submit de formulaire passe aussi la
   frame en [busy], mais le bouton affiche déjà son propre spinner (aria-busy
   sur le <form>) — pas d'overlay en plus. Les wizards (onboarding_wizard,
   booking_wizard) n'en ont pas : le lien Retour affiche des points animés
   (cf. onboarding_wizard_controller). */
turbo-frame#main[busy]:not(:has(form[aria-busy="true"]))::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border: 3px solid rgb(0 0 0 / 0.1);
  border-top-color: #ff385c;
  border-radius: 9999px;
  opacity: 0;
  animation: busy-spin 0.7s linear infinite, busy-appear 0.2s ease-out 0.3s forwards;
}

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

@keyframes busy-appear {
  to { opacity: 1; }
}

.swiper-button-next, .swiper-button-prev {
  background: #FFFFFF !important;
  width: 50px !important;
  height: 50px !important;
  border-radius: 100% !important;
  color: #000;
}

.swiper-button-next:after, .swiper-button-prev:after {
  font-family: swiper-icons;
  font-size: 16px;
  text-transform: none !important;
  letter-spacing: 0;
  font-variant: initial;
  line-height: 1;
}

/* Prevent scrolling while dialog is open */
body:has(dialog[data-dialog-target="dialog"][open]) {
  overflow: hidden;
}

/* Dialog backdrop via ::backdrop — fades in/out progressively via KEYFRAMES, so it
   also animates on OPEN (when the pseudo-element first appears). A plain transition
   pops straight to dark because there's no prior state to transition from. Synced
   with the sheet slide. */
dialog[data-dialog-target="dialog"]::backdrop {
  background-color: rgb(0 0 0 / 0);
}

dialog[data-dialog-target="dialog"][open]:not([closing])::backdrop {
  animation: backdrop-fade-in 500ms cubic-bezier(0.33, 1, 0.68, 1) forwards;
}

dialog[data-dialog-target="dialog"][closing]::backdrop {
  animation: backdrop-fade-out 380ms cubic-bezier(0.32, 0, 0.67, 0) forwards;
}

@keyframes backdrop-fade-in {
  from { background-color: rgb(0 0 0 / 0); }
  to   { background-color: rgb(0 0 0 / 0.5); }
}

@keyframes backdrop-fade-out {
  from { background-color: rgb(0 0 0 / 0.5); }
  to   { background-color: rgb(0 0 0 / 0); }
}

/* Keyframes for sliding and fading in */
@keyframes slide-fade-in {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Keyframes for sliding and fading out */
@keyframes slide-fade-out {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(100%);
  }
}

/* Apply animations — smooth, native-sheet-like slide. easeOutCubic
   (cubic-bezier(0.33, 1, 0.68, 1)) spreads the motion evenly with a soft settle
   (not front-loaded, so it reads as slow & deliberate rather than snappy);
   close accelerates away a bit quicker. No permanent will-change on [open]: the
   browser promotes the layer for the slide anyway, and a layer kept promoted
   would be re-rasterized on every frame of a height animation (src/dialog_height). */
dialog[data-dialog-target="dialog"][open] {
  animation: slide-fade-in 500ms cubic-bezier(0.33, 1, 0.68, 1) forwards;
}

dialog[data-dialog-target="dialog"][closing] {
  animation: slide-fade-out 380ms cubic-bezier(0.32, 0, 0.67, 0) forwards;
  will-change: transform, opacity;
}

/* Respect users who prefer reduced motion: no slide, just an instant appearance. */
@media (prefers-reduced-motion: reduce) {
  dialog[data-dialog-target="dialog"][open],
  dialog[data-dialog-target="dialog"][closing],
  dialog[data-dialog-target="dialog"][open]::backdrop,
  dialog[data-dialog-target="dialog"][closing]::backdrop {
    animation-duration: 1ms;
  }
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

turbo-frame[busy] .loader {
  display: flex
}

turbo-frame .loader {
  display: none
}

/* Bascule contenu ↔ spinner pendant la soumission d'un formulaire.
   Alternative lisible au pattern group-aria-busy pour les boutons qui affichent
   leur spinner À LA PLACE de leur contenu (flèche → spinner). Keyé sur
   aria-busy (posé par Turbo sur le <form> le temps de la requête), et NON sur
   [disabled] : un bouton grisé par validation ne montre donc jamais de spinner.
   Les boutons qui portent .show-when-busy sont exclus du spinner ::after global
   (cf. plus haut) pour éviter le double spinner. Éléments basculés inline. */
.show-when-busy { display: none; }
form[aria-busy="true"] .hide-when-busy { display: none; }
form[aria-busy="true"] .show-when-busy { display: inline-flex; }

/* Défilement doux (html, plus haut) : coupé pour qui a demandé moins
   d'animations au système. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Style de base pour les popups de map */

#custom-popup {
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

@media (min-width: 640px) { 
  #custom-popup {
    transform-origin: center bottom;
    left: var(--popup-left, 0);
    top: var(--popup-top, 0);
  }

  #custom-popup[data-direction="top"] {
    transform: translate(-50%, -100%);
  }
  
  #custom-popup[data-direction="right"] {
    transform: translate(0, -50%);
  }
  
  #custom-popup[data-direction="bottom"] {
    transform: translate(-50%, 0%);
  }
  
  #custom-popup[data-direction="left"] {
    transform: translate(-100%, -50%);
  }
}

@media (max-width: 640px) { 
  #custom-popup {
    bottom: 20px;
    left: 20px;
    right: 20px;
  }
}

#custom-popup.hidden {
  opacity: 0;
  pointer-events: none;
}

#custom-popup:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

/* Custom Turbo Confirm Dialog Animations */
/* Confirm dialog : bottom-sheet collé en bas sur mobile (comme les autres
   modals .dialog-sheet), fenêtre centrée sur desktop. */
#turbo-confirm-dialog {
  opacity: 1;
  scale: 1;
  translate: 0 0;
  position: fixed;
  inset: auto 0 0 0;        /* collé en bas, pleine largeur */
  width: 100%;
  max-width: 100%;
  margin: 0;
  transition: opacity 0.2s ease-out, scale 0.2s ease-out, translate 0.2s ease-out,
              overlay 0.2s ease-out allow-discrete,
              display 0.2s ease-out allow-discrete;
}

#turbo-confirm-dialog[open] {
  @starting-style {
    opacity: 0;
    translate: 0 100%;      /* glisse depuis le bas */
  }
}

#turbo-confirm-dialog:not([open]) {
  opacity: 0;
  translate: 0 100%;
}

@media (min-width: 640px) {
  /* Centrée par inset 0 + margin auto, comme les modales du back-office
     (admin/surfaces.css) : un translate -50% s'y ajoutait et décalait la
     fenêtre vers le haut à gauche. */
  #turbo-confirm-dialog {
    inset: 0;
    margin: auto;
    height: fit-content;
    max-width: 28rem;       /* max-w-md */
  }

  #turbo-confirm-dialog[open] {
    @starting-style {
      opacity: 0;
      scale: 0.95;
      translate: 0 0;
    }
  }

  #turbo-confirm-dialog:not([open]) {
    opacity: 0;
    scale: 0.95;
    translate: 0 0;
  }
}

/* Wizard step transitions (View Transitions API, activated via meta tag).
   Only the content of <main> (named "wizard-main") moves: the old step slides
   a little and fades out, then the new one slides in and fades in. The header,
   progress bar and footer (part of "root") snap instantly to their new state. */
@keyframes wizard-content-out-left {
  to { opacity: 0; transform: translateX(-24px); }
}
@keyframes wizard-content-in-right {
  from { opacity: 0; transform: translateX(24px); }
}
@keyframes wizard-content-out-right {
  to { opacity: 0; transform: translateX(24px); }
}
@keyframes wizard-content-in-left {
  from { opacity: 0; transform: translateX(-24px); }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}
::view-transition-old(root) { opacity: 0; }
::view-transition-new(root) { opacity: 1; }

::view-transition-old(wizard-main) {
  animation: 140ms cubic-bezier(0.4, 0, 1, 1) both wizard-content-out-left;
}
::view-transition-new(wizard-main) {
  animation: 320ms cubic-bezier(0.2, 0, 0.2, 1) 120ms both wizard-content-in-right;
}

html[data-wizard-direction="back"]::view-transition-old(wizard-main) {
  animation-name: wizard-content-out-right;
}
html[data-wizard-direction="back"]::view-transition-new(wizard-main) {
  animation-name: wizard-content-in-left;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(wizard-main),
  ::view-transition-new(wizard-main) {
    animation: none;
  }
}