/* Habillage « moderne » : surfaces claires, coins arrondis, ombres douces, vignettes 3D, onglets en bas, animations.
   Chargé en tout dernier : il ne change que l'apparence. Les couleurs de marque (rouge ATHP, encre) restent celles de style.css.
   Repères Mobbin : accueil (Asana, Jobber), listes (Airtasker, Dave), choix par vignettes (Blinkit, Instacart, CVS),
   visionneuse 3D (Apple Store, Tonal, Best Buy), photos (Grailed, Binance, Yubo). */

:root {
  --papier2: #f3f3f5;
  --trait: #e6e6ea;
  --trait-fort: #cdcdd3;
  --rayon: 16px;
  --rayon-petit: 12px;
  --surface-douce: #f6f6f8;
  --ombre: 0 1px 2px rgba(16, 16, 22, 0.04), 0 8px 24px -14px rgba(16, 16, 22, 0.18);
  --ombre-haute: 0 2px 6px rgba(16, 16, 22, 0.06), 0 18px 40px -18px rgba(16, 16, 22, 0.35);
  --onglets: calc(64px + env(safe-area-inset-bottom));
  --entree: cubic-bezier(0.2, 0.8, 0.2, 1);
  --barre-bas: calc(var(--onglets) + 80px);
}

body { background: var(--papier2); -webkit-font-smoothing: antialiased; }
h1 { letter-spacing: -0.02em; }
h2 { font-size: 12.5px; letter-spacing: 0.06em; }

/* ------------------------------------------------------------------ en-tête : clair, translucide */
.entete {
  background: rgba(255, 255, 255, 0.82); color: var(--encre);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(16, 16, 22, 0.06);
}
.marque { color: var(--encre); }
.marque img { background: none; padding: 0; border-radius: 0; }
.pastille { background: var(--succes-clair); color: var(--succes); font-weight: 650; }
.pastille.attente { background: var(--alerte-clair); color: var(--alerte); }
.menu summary { color: var(--encre); border-radius: 999px; }
.menu > div { border-radius: var(--rayon); box-shadow: var(--ombre-haute); border: 1px solid var(--trait); animation: monte 0.18s var(--entree); }

/* ------------------------------------------------------------------ cartes, boutons, champs */
.carte, .groupe { border: 1px solid rgba(16, 16, 22, 0.05); border-radius: var(--rayon); box-shadow: var(--ombre); }
.bouton { border-radius: var(--rayon-petit); border-color: var(--trait-fort); font-weight: 650; transition: transform 0.12s var(--entree), background-color 0.15s, box-shadow 0.15s; }
.bouton.principal { box-shadow: 0 6px 16px -8px rgba(236, 27, 36, 0.7); }
.bouton:active:not(:disabled) { transform: scale(0.97); translate: none; filter: none; }
.bouton:disabled { box-shadow: none; }

/* Champs pleins, sans cadre, qui s'éclairent au toucher (Binance, Yubo). */
input[type='text'], input[type='password'], input[type='search'], input:not([type]), select, textarea {
  background: var(--surface-douce); border: 1.5px solid transparent; border-radius: var(--rayon-petit);
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; background: var(--papier); border-color: var(--encre); box-shadow: 0 0 0 4px rgba(28, 28, 31, 0.08); }
input[type='search'] {
  padding-left: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2363626a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px center; background-size: 20px;
}
.champ[data-niveau='attention'] :is(input, select) { border-color: #c98a1c; background: #fffaf0; }
.champ[data-niveau='bloquant'] :is(input, select) { border-color: var(--accent); background: #fff6f5; }
.segments { gap: 4px; padding: 4px; background: var(--surface-douce); border-radius: var(--rayon-petit); }
.segments span { border: 0; border-radius: 9px; background: transparent; transition: background-color 0.15s, color 0.15s, box-shadow 0.15s; }
.segments input:checked + span { background: var(--papier); color: var(--encre); box-shadow: 0 1px 3px rgba(16, 16, 22, 0.15); font-weight: 700; }

.badge { border: 0; padding: 4px 10px; font-weight: 700; }
.badge.brouillon { background: var(--surface-douce); color: var(--texte-doux); }
.compte { background: var(--surface-douce); color: var(--encre); border-radius: 999px; padding: 2px 9px; }

/* ------------------------------------------------------------------ accueil */
.salut { display: grid; gap: 2px; }
.salut .sur-titre { letter-spacing: 0.02em; text-transform: none; font-size: 14px; font-weight: 600; }
.salut h1 { font-size: 30px; }

/* Une carte par relevé : la vignette du composant à gauche, le reste en lignes (Dave, Airtasker). */
.releve:has(> .cadre-vignette) {
  display: grid; grid-template-columns: 68px minmax(0, 1fr); column-gap: 14px; row-gap: 10px; align-items: start;
  padding: 14px 56px 14px 14px;
}
.releve > .cadre-vignette { grid-row: 1 / span 2; }
.releve:has(> .cadre-vignette) > div:not(.etat) { display: grid; gap: 2px; min-width: 0; }
.releve:has(> .cadre-vignette) > .etat { grid-column: 2; width: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px; }
.releve:has(> .cadre-vignette) .date { margin-left: auto; }
.releve h3 { font-size: 16.5px; line-height: 1.3; }
.releve .sur-titre { font-size: 11.5px; letter-spacing: 0.05em; }
.releve .lieu { font-size: 14px; }
.releve { transition: transform 0.15s var(--entree), box-shadow 0.15s, border-color 0.15s; }
.releve:hover { translate: none; border-color: rgba(16, 16, 22, 0.12); box-shadow: var(--ombre-haute); }
.releve:active { transform: scale(0.985); translate: none; filter: none; }
.retour-charge { border-radius: 10px; }
.plus-actions { border-radius: 999px; }

/* La vignette : un puits teinté, l'image arrive en fondu ; en attendant, un reflet passe (Blinkit, Instacart). */
.cadre-vignette {
  position: relative; display: block; width: 68px; aspect-ratio: 1; border-radius: 14px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #ffffff, #eceef2);
}
.cadre-vignette img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.35); opacity: 1; transition: opacity 0.35s var(--entree); }
.cadre-vignette.attente img { opacity: 0; }
.type:not(.prete) img {
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.8) 50%, transparent 80%) 0 0 / 200% 100%, radial-gradient(circle at 50% 38%, #ffffff, #e7e9ee);
  animation: reflet 1.2s linear infinite;
}
.cadre-vignette.attente::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.75) 50%, transparent 80%);
  background-size: 200% 100%; animation: reflet 1.2s linear infinite;
}

.outils-liste .choisir:not(.actif) { border-color: transparent; background: var(--papier); box-shadow: var(--ombre); }
.lien-affaires { border: 0; padding: 10px 14px; border-radius: 999px; background: var(--papier); box-shadow: var(--ombre); }

/* ------------------------------------------------------------------ « Que relevez-vous ? » : des vignettes */
.choix-types { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; }
.type { padding: 0 0 12px; border: 0; box-shadow: none; background: transparent; gap: 2px; text-align: left; }
.type:hover { translate: none; }
.type img {
  width: 100%; margin: 0 0 8px; aspect-ratio: 1; object-fit: cover; border: 0; border-radius: var(--rayon);
  background: radial-gradient(circle at 50% 38%, #ffffff, #e7e9ee); box-shadow: inset 0 0 0 1px rgba(16, 16, 22, 0.05);
  transition: transform 0.2s var(--entree), box-shadow 0.2s;
}
.type img[src] { animation: apparait 0.35s var(--entree); }
.type:hover img { box-shadow: inset 0 0 0 2px var(--accent); }
.type:active img { transform: scale(0.96); }
.type h3 { font-size: 15px; line-height: 1.25; padding: 0 2px; }
.type .sur-titre { padding: 0 2px; }
.type p:last-child:not(.sur-titre) { padding: 0 2px; }
.domaines a { border: 0; background: var(--papier); box-shadow: var(--ombre); transition: background-color 0.15s, color 0.15s; }
.domaines a:hover, .domaines a:focus-visible { background: var(--encre); color: #fff; }
.ref-bloc { border-radius: var(--rayon); }
input[type='number'] { min-height: 52px; background: var(--surface-douce); border: 1.5px solid transparent; border-radius: var(--rayon-petit); }
/* Un seul rouge par écran : la photo par IA passe en encre, l'appareil photo dans une pastille. */
.ia-photo.principal { background: var(--encre); border-color: var(--encre); border-radius: var(--rayon); min-height: 72px; padding: 14px 18px; gap: 14px; box-shadow: var(--ombre-haute); }
.ia-photo.principal:hover { background: #2b2b30; border-color: #2b2b30; }
.ia-photo.principal svg { width: 44px; height: 44px; padding: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); }

/* ------------------------------------------------------------------ fiche : la scène 3D (Apple Store, Tonal, Best Buy) */
.carte-3d { border: 0; }
.vue-3d { background: radial-gradient(120% 90% at 50% 30%, #ffffff 0%, #eef0f4 55%, #e2e5ea 100%); }
.modes-vue {
  padding: 3px; gap: 2px; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.78); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 1px 2px rgba(16, 16, 22, 0.08), 0 6px 16px -10px rgba(16, 16, 22, 0.4);
}
.modes-vue button { border-radius: 999px; transition: background-color 0.18s, color 0.18s; }
.modes-vue button + button { border-left: 0; }
.modes-vue button[aria-pressed='true'] { background: var(--encre); color: #fff; }
.agrandir {
  border: 0; border-radius: 999px; padding: 0 14px;
  background: rgba(255, 255, 255, 0.78); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 1px 2px rgba(16, 16, 22, 0.08), 0 6px 16px -10px rgba(16, 16, 22, 0.4);
}
.agrandir.cotes[aria-pressed='true'], .agrandir[aria-pressed='true'] { background: var(--encre); color: #fff; }
.legende-3d { border-top: 0; background: var(--papier); }
.curseur input[type='range'] { accent-color: var(--accent); }
.carte-3d.agrandie { animation: apparait 0.22s var(--entree); }

/* Photos : des carrés ; « + » dans une tuile pleine, croix ronde dans le coin (Grailed, Binance, Yubo). */
.photos img { aspect-ratio: 1; border: 0; border-radius: var(--rayon-petit); box-shadow: inset 0 0 0 1px rgba(16, 16, 22, 0.06); }
.ajouter-photo { aspect-ratio: 1; border: 0; border-radius: var(--rayon-petit); background: var(--surface-douce); color: var(--encre); transition: background-color 0.15s, transform 0.12s; }
.ajouter-photo svg { padding: 10px; width: 52px; height: 52px; border-radius: 999px; background: var(--papier); box-shadow: var(--ombre); }
.ajouter-photo:hover { background: #ececf0; color: var(--encre); }
.ajouter-photo:active { transform: scale(0.97); }
.retirer { width: 30px; height: 30px; top: 8px; right: 8px; background: rgba(16, 16, 22, 0.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.retirer svg { width: 16px; height: 16px; }

.bloc { border-radius: var(--rayon-petit); }
.calculs { border-radius: var(--rayon); border-color: rgba(16, 16, 22, 0.05); box-shadow: var(--ombre); }
.avancement { height: 6px; background: #e4e4e9; }
.avancement i { background: linear-gradient(90deg, var(--succes), #2fa36b); transition: width 0.4s var(--entree); }

/* Fournitures : un long nom de composant dans la liste ne doit pas élargir la page. */
.fo-filtres select { min-width: 0; }

/* Équivalents, aperçus, propositions de l'IA : mêmes surfaces. */
.eq-carte { border: 1px solid rgba(16, 16, 22, 0.05); border-left-width: 4px; box-shadow: var(--ombre); }
.ap-vignette { border: 0; border-radius: var(--rayon-petit); background: radial-gradient(circle at 50% 40%, #ffffff, #eceef2); }
.sug-liste { border: 0; border-radius: var(--rayon); box-shadow: var(--ombre-haute); animation: monte 0.16s var(--entree); }
.ia-panneau { border: 0; border-radius: var(--rayon); box-shadow: var(--ombre); }
.tuile { border: 0; border-radius: var(--rayon); box-shadow: var(--ombre); }

/* ------------------------------------------------------------------ feuilles, annonces */
.voile { animation: fondu 0.18s ease-out; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.feuille { border-radius: 22px 22px 0 0; padding-top: 10px; }
.feuille::before { content: ''; justify-self: center; width: 40px; height: 5px; border-radius: 99px; background: var(--trait-fort); margin-bottom: 8px; }
.annonce { border-radius: 14px; }

/* ------------------------------------------------------------------ barre d'onglets (téléphone) */
.onglets { display: none; }

@media (max-width: 940px) {
  .entete { min-height: 56px; }
  .page { padding-bottom: calc(var(--barre-bas) + 24px); }

  .onglets {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: var(--onglets);
    display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 6px env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.86); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid rgba(16, 16, 22, 0.07);
  }
  .onglet {
    position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 52px;
    color: var(--texte-doux); text-decoration: none; font-size: 11.5px; font-weight: 650; border-radius: 12px;
    transition: color 0.18s;
  }
  .onglet svg { width: 24px; height: 24px; stroke-width: 1.9; transition: transform 0.2s var(--entree); }
  .onglet.actif { color: var(--accent); }
  .onglet.actif svg { transform: translateY(-1px) scale(1.08); stroke-width: 2.2; }
  .onglet.actif::before { content: ''; position: absolute; top: -6px; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); animation: apparait 0.25s var(--entree); }
  .onglet:active svg { transform: scale(0.9); }
  /* La fiche plein écran 3D passe devant la barre. */
  body:has(.carte-3d.agrandie) .onglets { display: none; }
  /* Dans une fiche, l'écran va à la saisie et à la 3D : la barre se retire, « Relevés » en haut ramène à la liste. */
  body:has(.fiche) .onglets { display: none; }
  body:has(.fiche) .page { padding-bottom: 40px; }

  /* « Nouveau relevé » : bouton flottant en pilule, au-dessus des onglets (Jobber, monday.com). */
  .accueil > .bouton.geant {
    left: auto; right: 16px; bottom: calc(var(--onglets) + 14px);
    min-height: 56px; padding: 0 22px 0 18px; font-size: 17px; border-radius: 999px;
    box-shadow: 0 12px 28px -10px rgba(236, 27, 36, 0.75), 0 2px 6px rgba(16, 16, 22, 0.15);
  }
  /* Seulement à l'arrivée sur l'écran : la liste se redessine à chaque frappe et à chaque synchronisation. */
  .page.entre .accueil > .bouton.geant { animation: surgit 0.35s var(--entree) 0.1s both; }
  .barre-choix { bottom: calc(var(--onglets) + 12px); }
  .annonce { bottom: calc(var(--onglets) + 84px); }
  .affaire-detail .bouton.geant { border-radius: 999px; }

  .salut h1 { font-size: 30px; }
  .releve:has(> .cadre-vignette) { grid-template-columns: 60px minmax(0, 1fr); padding-right: 52px; }
  .cadre-vignette { width: 60px; border-radius: 13px; }
  .choix-types { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
  .type .sur-titre { display: none; }
  .domaines { background: rgba(243, 243, 245, 0.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }

  .carte-3d { border-radius: 0 0 22px 22px; box-shadow: 0 14px 28px -20px rgba(16, 16, 22, 0.5); }
  .agrandir { min-height: 46px; }
  /* Au doigt : la croix d'une photo garde la taille prévue par terrain.css. */
  .retirer { width: 44px; height: 44px; }
  .groupe { border-radius: 20px; }

  /* Corrige la carte d'affaire : son état reste à droite, le texte garde sa largeur. */
  .carte.affaire { flex-direction: column; gap: 10px; }
  .carte.affaire .etat { width: auto; flex-direction: row; justify-content: space-between; align-items: center; }
}

/* ------------------------------------------------------------------ animations */
@keyframes monte { from { opacity: 0; transform: translateY(10px); } }
@keyframes apparait { from { opacity: 0; transform: scale(0.96); } }
@keyframes fondu { from { opacity: 0; } }
@keyframes surgit { from { opacity: 0; transform: translateY(18px) scale(0.94); } }
@keyframes reflet { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Chaque écran entre en douceur, ses blocs l'un après l'autre (classe posée par habillage.js à l'arrivée
   d'un écran seulement : une recherche ou une synchronisation qui redessine la liste ne la fait pas rejouer).
   « backwards » : une fois jouée, l'animation ne laisse rien derrière elle (ni transformation, ni calque). */
.page.entre > * > *:not(.bouton.geant, .barre-choix), .page.entre .liste > * { animation: monte 0.4s var(--entree) backwards; }
.page.entre > * > :nth-child(2), .page.entre .liste > :nth-child(2) { animation-delay: 0.04s; }
.page.entre > * > :nth-child(3), .page.entre .liste > :nth-child(3) { animation-delay: 0.08s; }
.page.entre > * > :nth-child(4), .page.entre .liste > :nth-child(4) { animation-delay: 0.12s; }
.page.entre > * > :nth-child(5), .page.entre .liste > :nth-child(5) { animation-delay: 0.16s; }
.page.entre > * > :nth-child(n + 6), .page.entre .liste > :nth-child(n + 6) { animation-delay: 0.2s; }
.page.entre .liste > :nth-child(n + 9) { animation: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
}
