/* AutoFlow — système visuel des pages applicatives (espace artisan, page client,
   inscription/connexion). Même univers que la page d'accueil (nuit, crème, cuivre,
   Fraunces + Manrope), en version épurée : filets fins, pas d'ombres portées ni de
   dégradés, boutons pilule, aucune icône décorative.
   Chargé AVANT le <style> de chaque page : la page s'appuie sur ces jetons et classes. */

:root {
  --nuit: #0A0E15;
  --encre: #0E131B;        /* fond des blocs */
  --encre-2: #121822;      /* survol, champs */
  --ligne: rgba(242, 234, 217, .08);
  --ligne-forte: rgba(242, 234, 217, .16);
  --creme: #F2EAD9;
  --creme-2: #C9C1B0;
  --gris: #858D9A;
  --cuivre: #C1783C;
  --cuivre-clair: #E2A468;
  --ok: #7DBE96;
  --alerte: #E3957F;
  --info: #A9C4DE;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Manrope", -apple-system, "Segoe UI", sans-serif;
  --rayon: 12px;
  --rayon-champ: 10px;
}

html { background: var(--nuit); }
/* Fond d'ambiance vivant (dans l'esprit de la page d'accueil) : une lueur cuivre et un reflet
   bleuté qui dérivent lentement, plus un grain animé. Fixe, derrière tout le contenu, sans
   capter les clics ; animations coupées si l'utilisateur réduit les mouvements (règle en bas). */
html::before, body::after, html::after { content: ""; position: fixed; pointer-events: none; z-index: -1; }
html::before {
  inset: -25%;
  background:
    radial-gradient(38% 34% at 72% 22%, rgba(193, 120, 60, .22), transparent 70%),
    radial-gradient(30% 28% at 58% 78%, rgba(193, 120, 60, .07), transparent 70%);
  will-change: transform;
  animation: af-derive-a 26s ease-in-out infinite alternate;
}
body::after {
  inset: -25%;
  background:
    radial-gradient(34% 32% at 22% 70%, rgba(110, 145, 190, .11), transparent 70%),
    radial-gradient(26% 24% at 30% 20%, rgba(226, 164, 104, .06), transparent 70%);
  will-change: transform;
  animation: af-derive-b 34s ease-in-out infinite alternate;
}
html::after {
  inset: -60px;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  animation: af-grain 900ms steps(4) infinite;
}
@keyframes af-derive-a { 0% { transform: translate3d(0, 0, 0) scale(1); } 50% { transform: translate3d(-7%, 5%, 0) scale(1.08); } 100% { transform: translate3d(4%, 9%, 0) scale(.96); } }
@keyframes af-derive-b { 0% { transform: translate3d(0, 0, 0) scale(1.04); } 50% { transform: translate3d(8%, -6%, 0) scale(.95); } 100% { transform: translate3d(-3%, -10%, 0) scale(1.1); } }
@keyframes af-grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-18px, 12px); } 50% { transform: translate(12px, -16px); } 75% { transform: translate(-10px, -8px); } 100% { transform: translate(14px, 10px); } }
/* Espace artisan, inscription, connexion (pages <html data-app>) : fond d'écran photo de
   l'établi, comme la page d'accueil, sous un voile sombre qui garde tout lisible, avec un
   zoom très lent. La page client (/pro) garde les lueurs ci-dessus, à la marque de l'artisan. */
/* Une photo par ambiance (attribut data-fond sur <html>) :
   par défaut l'établi (planning, suivi…), « evier » = au travail (devis),
   « nuit » = le téléphone qui répond (réglages, abonnement, inscription, connexion). */
html[data-app] { --af-photo: url("/garde/hero-poster.jpg"); --af-voile: .64; --af-position: center 40%; }
html[data-app][data-fond="evier"] { --af-photo: url("/garde/fond-evier.jpg"); --af-voile: .76; --af-position: center 35%; }
html[data-app][data-fond="nuit"] { --af-photo: url("/garde/fond-nuit.jpg"); --af-voile: .50; --af-position: center 60%; }
html[data-app]::before {
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 14, 21, var(--af-voile)) 0%, rgba(10, 14, 21, .80) 34%, rgba(10, 14, 21, .90) 68%, rgba(10, 14, 21, .95) 100%),
    radial-gradient(60% 45% at 85% 0%, rgba(193, 120, 60, .20), transparent 70%),
    var(--af-photo) var(--af-position) / cover no-repeat;
  transform-origin: 60% 40%;
  animation: af-zoom 40s ease-in-out infinite alternate;
}
/* Fond uni (attribut data-fond="uni") : dans l'espace artisan, une photo
   derriere un planning charge la lecture et mange la batterie sur telephone.
   On la garde la ou l'ecran est vide ou d'entree — connexion, inscription,
   premier rendez-vous a venir : c'est la qu'elle accueille au lieu d'encombrer.
   Le passage d'un etat a l'autre se fait par window.afFond(estVide). */
html[data-app][data-fond="uni"]::before {
  background:
    radial-gradient(70% 50% at 85% 0%, rgba(193, 120, 60, .10), transparent 70%),
    linear-gradient(180deg, #0C111A 0%, #0A0E15 55%, #090D13 100%);
  animation: none;
  transform: none;
}
html[data-app] body::after { display: none; }
@keyframes af-zoom { from { transform: scale(1.02); } to { transform: scale(1.12) translate(-1.5%, 1%); } }
@media print { html::before, body::after, html::after { display: none; } }
body {
  background: transparent;
  color: var(--creme);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(193, 120, 60, .35); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--cuivre-clair); outline-offset: 2px; }

/* ---------- En-tête commun ---------- */
.af-entete {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10, 14, 21, .86);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ligne);
  /* Encoche et barre d'état : sans ça, la nav passe SOUS l'heure et la
     batterie sur iPhone (viewport-fit=cover) et n'est plus cliquable.
     env() vaut 0 partout ailleurs, la mise en page ne bouge pas. */
  padding-top: env(safe-area-inset-top, 0px);
}
.af-entete-in {
  max-width: 1040px; margin: 0 auto; height: 64px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.af-logo {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--creme);
  flex-shrink: 0;
  font-family: var(--serif); font-weight: 460; font-size: 19px; letter-spacing: .01em; white-space: nowrap;
}
/* flex-shrink : sans ca, quand la nav s'allonge, le conteneur ecrase le rond
   du logo et il s'affiche ovale. object-fit garde l'image entiere. */
.af-logo img { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.af-logo i { font-style: italic; color: var(--cuivre-clair); }
.af-logo .af-logo-sous { font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--gris); margin-left: 4px; }
.af-nav { display: flex; align-items: center; gap: 4px; min-width: 0; } /* min-width : la nav rétrécit (et défile) en mobile au lieu d'élargir la page */
.af-nav a {
  position: relative; padding: 8px 12px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; color: var(--creme-2); text-decoration: none; white-space: nowrap;
  transition: color .2s, background .2s;
}
.af-nav a:hover { color: var(--creme); background: rgba(242, 234, 217, .05); }
.af-nav a.actif { color: var(--creme); }
.af-nav a.actif::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 1px; background: var(--cuivre-clair);
}
.af-nav a.discret { color: var(--gris); }
@media (max-width: 720px) {
  .af-entete-in { padding: 0 16px; height: 56px; }
  .af-nav { overflow-x: auto; scrollbar-width: none; }
  .af-nav::-webkit-scrollbar { display: none; }
  .af-nav a { padding: 8px 9px; font-size: 13px; }
  .af-logo .af-logo-sous { display: none; }
}
@media (max-width: 520px) {
  /* Téléphone : le logo se réduit à son rond, toute la largeur va aux liens */
  .af-entete-in { gap: 10px; }
  .af-entete .af-logo > span { display: none; }
  .af-nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
}

/* ---------- Titres et textes ---------- */
.af-titre { font-family: var(--serif); font-weight: 420; font-size: clamp(28px, 4vw, 36px); line-height: 1.1; letter-spacing: -.01em; text-wrap: balance; }
.af-titre em { font-style: italic; font-weight: 340; color: var(--cuivre-clair); }
.af-sous-titre { color: var(--creme-2); font-size: 15px; margin-top: 8px; max-width: 62ch; }
.af-section-titre { font-family: var(--serif); font-weight: 420; font-size: 20px; line-height: 1.25; }
.af-etiquette { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gris); }
.af-aide { font-size: 13px; color: var(--gris); }
.af-chiffre { font-variant-numeric: tabular-nums; }

/* ---------- Boutons ---------- */
/* Bouton principal : orange « déteint » (teinte cuivre légère, texte cuivre clair) */
.af-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 22px; border-radius: 999px; border: 1px solid rgba(226, 164, 104, .30);
  background: rgba(226, 164, 104, .13); color: #EDBB8A;
  font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: .01em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s, opacity .2s;
}
.af-btn:hover { background: rgba(226, 164, 104, .21); border-color: rgba(226, 164, 104, .45); color: #F3C9A0; }
/* Crème plein : réservé aux rares actions à mettre en avant hors cuivre */
.af-btn-creme { background: var(--creme); color: #131008; border-color: transparent; }
.af-btn-creme:hover { background: #fff; color: #131008; }
.af-btn:disabled, .af-btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.af-btn-accent { background: var(--cuivre); color: #fff8ef; border-color: transparent; }
.af-btn-accent:hover { background: #cf8649; color: #fff8ef; }
.af-btn-ghost { background: transparent; color: var(--creme); border-color: var(--ligne-forte); }
.af-btn-ghost:hover { background: rgba(242, 234, 217, .05); border-color: rgba(242, 234, 217, .28); }
.af-btn-danger { background: transparent; color: var(--alerte); border-color: rgba(227, 149, 127, .35); }
.af-btn-danger:hover { background: rgba(227, 149, 127, .08); }
.af-btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.af-btn-bloc { width: 100%; }
.af-lien { font: inherit; color: var(--cuivre-clair); text-decoration: none; font-weight: 600; background: none; border: none; cursor: pointer; padding: 0; }
.af-lien:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Blocs ---------- */
.af-bloc { background: var(--encre); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 24px; }
.af-bloc + .af-bloc { margin-top: 16px; }
.af-filet { height: 1px; background: var(--ligne); border: 0; margin: 20px 0; }
.af-liste > * + * { border-top: 1px solid var(--ligne); }

/* ---------- Champs ---------- */
.af-champ { display: flex; flex-direction: column; gap: 7px; }
.af-champ > label, .af-label { font-size: 12.5px; font-weight: 600; color: var(--creme-2); }
.af-input, .af-champ input:not([type="checkbox"]):not([type="radio"]), .af-champ select, .af-champ textarea {
  width: 100%; background: var(--encre-2); color: var(--creme);
  border: 1px solid var(--ligne-forte); border-radius: var(--rayon-champ);
  padding: 11px 13px; font-family: var(--sans); font-size: 14.5px;
  transition: border-color .2s, background .2s;
}
.af-input::placeholder, .af-champ input::placeholder, .af-champ textarea::placeholder { color: #5f6773; }
.af-input:focus, .af-champ input:focus, .af-champ select:focus, .af-champ textarea:focus { outline: none; border-color: var(--cuivre-clair); background: #141b26; }

/* Remplissage automatique du navigateur : Chrome force un fond blanc et un
   texte noir, illisibles sur fond nuit. L'ombre interieure geante est la seule
   facon de repeindre le fond ; -webkit-text-fill-color reprend la couleur. */
.af-input:-webkit-autofill,
.af-champ input:-webkit-autofill,
.af-champ input:-webkit-autofill:hover,
.af-champ input:-webkit-autofill:focus,
.af-champ textarea:-webkit-autofill,
.af-champ select:-webkit-autofill {
  -webkit-text-fill-color: var(--creme);
  -webkit-box-shadow: 0 0 0 1000px #101722 inset;
  box-shadow: 0 0 0 1000px #101722 inset;
  caret-color: var(--creme);
  transition: background-color 9999s ease-in-out 0s;
}
.af-champ input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px #141b26 inset; box-shadow: 0 0 0 1000px #141b26 inset; }

/* ---------- Pastilles d'état ---------- */
.af-pastille {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--ligne-forte); color: var(--creme-2);
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
.af-pastille::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.af-pastille.ok { color: var(--ok); border-color: rgba(125, 190, 150, .35); }
.af-pastille.alerte { color: var(--alerte); border-color: rgba(227, 149, 127, .35); }
.af-pastille.accent { color: var(--cuivre-clair); border-color: rgba(226, 164, 104, .35); }
.af-pastille.info { color: var(--info); border-color: rgba(169, 196, 222, .3); }

/* ---------- Bandeau d'état (etat.js) ---------- */
#bandeau-etat {
  background: rgba(10, 14, 21, .55) !important; border-bottom: 1px solid var(--ligne) !important;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--gris) !important; font: 500 12.5px var(--sans) !important;
  padding: 9px 16px !important; text-align: center; line-height: 1.5;
}
#bandeau-etat a { color: var(--cuivre-clair) !important; text-decoration: none; font-weight: 600 !important; }
#bandeau-etat a:hover { text-decoration: underline; text-underline-offset: 3px; }
#bandeau-etat .sep { color: #3a414c; margin: 0 8px; }

/* ---------- Divers ---------- */
.af-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px); opacity: 0;
  background: var(--creme); color: #131008; border-radius: 999px; padding: 11px 20px;
  font-size: 14px; font-weight: 600; transition: .3s; pointer-events: none; z-index: 100;
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Mode appli (stores) : rien qui vende l'abonnement — voir appli.js */
html.af-appli a[href^="/abonnement"], html.af-appli a[href^="/inscription"], html.af-appli .af-achat { display: none !important; }
