/**
 * SmileSen — couche UX globale (app clinique, vitrine, pages auth).
 * Fluidité, accessibilité, tactile, focus clavier, typographie.
 */

:root {
  /* Réorientés vers le monde « le carton réglé » (static/css/tokens.css).
     Le nom ne change pas, la valeur change : c'est ce qui convertit tous les
     écrans d'un coup, sans qu'aucun composant puisse être oublié. */
  --sn-font: var(--fam-parole);
  --sn-display: var(--fam-parole);
  --sn-valeur: var(--fam-valeur);
}

body {
  font-family: var(--sn-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .v-reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Lien d'évitement */
.sn-skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
  padding: var(--pas-2) var(--pas-3);
  font-size: var(--t-annot);
  font-weight: 600;
  /* LE LIEN D'ÉVITEMENT N'EST PAS UNE PLACE DE LA MARQUE.
     Il apparaît au clavier, une fraction de seconde, pour une personne qui
     cherche à atteindre le contenu — et il portait la couleur du cabinet.
     Avec un rouge pur, la meilleure encre possible y tenait 4,21:1 ; avec un
     gris moyen, 4,48:1. C'était la DERNIÈRE paire du produit sous le seuil,
     et elle ne devait rien à la marque : c'est un affordance du monde, donc
     un PAVÉ — de l'encre, du texte clair, et la garantie qui va avec. */
  color: var(--texte-pave);
  background: var(--fond-pave);
  border-radius: var(--rayon);
  text-decoration: none;
}
.sn-skip-link:focus {
  left: max(12px, env(safe-area-inset-left));
  top: max(0px, env(safe-area-inset-top));
  width: auto;
  height: auto;
  overflow: visible;
  outline: 2px solid var(--bord);
  outline-offset: 2px;

  /* il ne paraît qu'au clavier, mais il se clique : la cible du monde */
  min-height: var(--l-cible);
  display: inline-flex;
  align-items: center;
}

/* Anneau focus clavier cohérent */
:where(
  a,
  button,
  input,
  select,
  textarea,
  summary,
  [role="button"],
  [tabindex]:not([tabindex="-1"])
):focus {
  outline: none;
}
:where(
  a,
  button,
  input,
  select,
  textarea,
  summary,
  [role="button"],
  [tabindex]:not([tabindex="-1"])
):focus-visible {
  outline: 2px solid var(--sn-primary, var(--etat-acquis));
  outline-offset: 2px;
}

/* Tactile — évite double-tap zoom sur boutons */
:where(
  button,
  .btn,
  .btn-green,
  .sn-btn,
  .vitrine-btn,
  .vitrine-nav-toggle,
  .admin-menu-toggle,
  .cashdesk-btn-primary,
  .cashdesk-btn-outline,
  .clinical-hub-nav__item,
  .vitrine-slot-btn
) {
  touch-action: manipulation;
}

/* ===========================================================================
   LA CIBLE DU MONDE SUR LES CHAMPS DE SAISIE.

   `--l-cible: 44px` était déclaré depuis le choix du monde et n'avait jamais
   été posé. Mesurés dans le navigateur, les champs de texte du produit font
   16 à 19 px de haut : sur /accounts/profile/, dix-sept champs ; sur les
   listes de commandes, les filtres de saisie rapide.

   Au fauteuil, on vise avec un gant. Quarante-quatre pixels est la règle de
   la maison, plus stricte que les vingt-quatre de WCAG 2.5.8 — et c'est
   voulu : le praticien ne tape pas assis au calme.

   Les cases à cocher et les boutons radio sont hors de cette règle : leur
   cible est leur LIBELLÉ, qui les enveloppe, et les grossir donnerait des
   carrés de la taille d'un bouton. Le sélecteur les écarte nommément.

   ⚠ Le sélecteur ne met QUE l'ancêtre dans :where(). Première version, tout
   y était : spécificité nulle, et la règle perdait contre n'importe quelle
   classe — dix-sept champs de /accounts/profile/ restaient à 16 px. Une
   garantie MINIMALE doit gagner ; c'est l'inverse d'une couleur par défaut,
   qui doit perdre. */
:where(.theme-admin, .op, .admin-login)
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
:where(.theme-admin, .op, .admin-login) select,
:where(.theme-admin, .op, .admin-login) textarea {
  min-height: var(--l-cible);
}

/* Une zone de texte garde sa hauteur propre dès qu'elle en demande une. */
:where(.theme-admin, .op) textarea[rows] {
  min-height: auto;
}

/* Champs iOS — pas de zoom au focus (mobile / tablette) */
@media (max-width: 1023.98px) {
  :where(input, select, textarea) {
    font-size: max(16px, 1em);
  }
}

/* App clinique — transitions légères */
.theme-admin .sn-card,
.theme-admin .cashdesk-panel,
.theme-admin .consultation-item,
.theme-admin .sm-card,
.theme-admin .planning-stat-card--filter,
.theme-admin .clinical-hub-nav__item {
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.theme-admin .sn-btn,
.theme-admin .btn-green,
.theme-admin .cashdesk-btn-primary {
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.theme-admin .sn-btn:active:not(:disabled),
.theme-admin .btn-green:active:not(:disabled),
.theme-admin .cashdesk-btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

/* Vitrine — boutons et cartes */
.vitrine-body .vitrine-btn,
.vitrine-body .vitrine-card,
.vitrine-body .v-pricing-card {
  transition: box-shadow 0.2s ease, transform 0.18s ease, background 0.15s ease;
}
.vitrine-body .vitrine-btn:active {
  transform: scale(0.98);
}

/* Messages flash — apparition douce (legacy inline) */
.dental-message,
.vitrine-message,
.sn-card .dental-message {
  animation: sn-fade-in 0.35s ease;
}

/* ── Toasts flottants (INTRANET — bas droite, 7 s) ── */
.sn-toast-region {
  position: fixed;
  z-index: 10050;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: var(--pas-2);
  width: min(22.5rem, calc(100vw - 2rem));
  pointer-events: none;
}

.sn-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--pas-2);
  width: 100%;
  padding: 0.75rem var(--pas-3) var(--pas-3);
  border-radius: var(--rayon);
  font-size: var(--t-annot);
  line-height: 1.45;
  border: 1px solid transparent;
  overflow: hidden;
  animation: sn-toast-in 0.32s ease forwards;
}

.sn-toast--enter {
  animation: none;
  opacity: 0;
  transform: translateX(1.25rem);
}

.sn-toast--leaving {
  animation: sn-toast-out 0.28s ease forwards;
}

.sn-toast__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  margin-top: 0.0625rem;
}

.sn-toast__text {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-right: 0.25rem;
}

.sn-toast__close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: -0.125rem -0.125rem 0 0;
  padding: 0;
  border: none;
  border-radius: var(--rayon);
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.sn-toast__close:hover {
  opacity: 1;
  background: var(--fond-intitule);
}

.sn-toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: 0.28;
  transform-origin: left center;
  animation: sn-toast-progress 7s linear forwards;
}

.sn-toast--success {
  background: var(--etat-acquis-fond);
  color: var(--etat-acquis);
  border-color: var(--etat-acquis);
}

.sn-toast--error {
  background: var(--fond-case);
  color: var(--etat-afaire);
  border-color: var(--etat-afaire);
}

.sn-toast--warning {
  background: var(--fond-intitule);
  color: var(--texte-faible);
  border-color: var(--bord-fort);
}

.sn-toast--info {
  background: var(--etat-acquis-fond);
  color: var(--etat-acquis);
  border-color: var(--etat-acquis);
}

@keyframes sn-fade-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sn-toast-in {
  from {
    opacity: 0;
    transform: translateX(1.25rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes sn-toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(1.25rem);
  }
}

@keyframes sn-toast-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sn-toast,
  .sn-toast--enter,
  .sn-toast--leaving,
  .sn-toast__progress {
    animation: none !important;
  }
  .sn-toast--enter {
    opacity: 1;
    transform: none;
  }
}

.param-toast-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Safe area contenu principal */
#main-content {
  scroll-margin-top: 4rem;
}

/* Liens — l'encre par défaut, et sa transition.

   Un lien qu'aucune règle ne touche prend le BLEU DU NAVIGATEUR : `#0000EE`,
   soit 1,69:1 sur une case de nuit. Trouvé sur /accounts/profile/ — les liens
   de fichier joint (avatar, signature) n'avaient jamais reçu de couleur.
   C'est un défaut du système, pas de la page : un lien du produit est écrit à
   l'encre de ce qui est constaté.

   Le sélecteur est enveloppé de :where() : il ne pèse rien, donc n'importe
   quel composant qui nomme sa couleur l'emporte. Une règle-balai qui gagne
   contre les composants rend des boutons invisibles — c'est arrivé sur la
   vitrine, vingt-huit fois sur une page. */
:where(.theme-admin, .vitrine-body) :where(a:not(.sn-btn):not(.btn):not(.btn-green):not(.vitrine-btn)) {
  color: var(--etat-acquis);
  transition: color 0.12s ease;
}

/* Formulaires — focus ring renforcé */
.theme-admin input:focus-visible,
.theme-admin select:focus-visible,
.theme-admin textarea:focus-visible,
.vitrine-body .vitrine-input:focus-visible,
.vitrine-body input:focus-visible,
.vitrine-body select:focus-visible,
.vitrine-body textarea:focus-visible {
  border-color: var(--sn-primary, var(--etat-acquis));
}

/* Cookie banner vitrine — safe area */
.v-cookie-banner {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* Hub clinique scroll fluide mobile */
.clinical-hub-nav {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.clinical-hub-nav::-webkit-scrollbar {
  display: none;
}
