/* v139.0 — Motion & Glass UX. Effets purement visuels, aucune logique budget/cloud. */

html {
  --v139-fast: 150ms;
  --v139-medium: 240ms;
  --v139-slow: 320ms;
  --v139-ease: cubic-bezier(.22,.78,.22,1);
  --v139-spring: cubic-bezier(.2,.9,.25,1.08);
  --v139-nav-blur: 24px;
  --v139-sheet-blur: 16px;
  --v139-sheet-shift: 24px;
  --v139-page-shift: 12px;
}

html[data-motion="economy"] {
  --v139-fast: 90ms;
  --v139-medium: 150ms;
  --v139-slow: 190ms;
  --v139-nav-blur: 10px;
  --v139-sheet-blur: 6px;
  --v139-sheet-shift: 12px;
  --v139-page-shift: 7px;
}

html[data-motion="minimal"] {
  --v139-fast: 0ms;
  --v139-medium: 0ms;
  --v139-slow: 0ms;
  --v139-nav-blur: 0px;
  --v139-sheet-blur: 0px;
  --v139-sheet-shift: 0px;
  --v139-page-shift: 0px;
}

/* Navigation basse : verre plus léger + indicateur qui glisse réellement. */
html[data-ui-theme="standard"][data-theme="light"] .ca-bottom-nav {
  background: rgba(255,255,255,.80) !important;
}
html[data-ui-theme="standard"][data-theme="dark"] .ca-bottom-nav {
  background: rgba(21,24,27,.82) !important;
}
html[data-ui-theme="standard"] .ca-bottom-nav {
  -webkit-backdrop-filter: saturate(175%) blur(var(--v139-nav-blur)) !important;
  backdrop-filter: saturate(175%) blur(var(--v139-nav-blur)) !important;
}
html[data-motion="minimal"][data-theme="light"] .ca-bottom-nav { background: #fff !important; }
html[data-motion="minimal"][data-theme="dark"] .ca-bottom-nav { background: #15181B !important; }

html[data-ui-theme="standard"] .ca-bottom-nav .ca-bottom-link::before,
html[data-ui-theme="standard"] .ca-bottom-nav .ca-bottom-button::before {
  opacity: 0 !important;
}

.v139-nav-indicator {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  height: 3px;
  width: 60px;
  border-radius: 0 0 999px 999px;
  background: var(--ca-accent);
  pointer-events: none;
  transform: translate3d(0,0,0);
  transition:
    transform var(--v139-medium) var(--v139-spring),
    width var(--v139-medium) var(--v139-ease),
    opacity var(--v139-fast) ease;
  will-change: transform;
}
.v139-nav-indicator.v139-no-transition { transition: none !important; }

.ca-bottom-nav > .ca-bottom-link,
.ca-bottom-nav > .ca-bottom-button { z-index: 1; }

html:not([data-motion="minimal"]) .ca-bottom-nav .ca-bottom-icon {
  transition:
    transform var(--v139-medium) var(--v139-spring),
    color var(--v139-fast) ease,
    opacity var(--v139-fast) ease !important;
}
html:not([data-motion="minimal"]) .ca-bottom-link.active .ca-bottom-icon,
html:not([data-motion="minimal"]) body[data-active-nav="income"] .ca-bottom-link[data-ca-target="income"] .ca-bottom-icon,
html:not([data-motion="minimal"]) body[data-active-nav="transactions"] .ca-bottom-link[data-ca-target="transactions"] .ca-bottom-icon,
html:not([data-motion="minimal"]) body[data-active-nav="menu"] .ca-bottom-link[data-ca-target="menu"] .ca-bottom-icon,
html:not([data-motion="minimal"]) body[data-active-nav="notifications"] .ca-bottom-link[data-ca-target="notifications"] .ca-bottom-icon,
html:not([data-motion="minimal"]) body[data-active-nav="profile"] .ca-bottom-link[data-ca-target="profile"] .ca-bottom-icon {
  transform: translateY(-2px) scale(1.055) !important;
}

/* Fenêtres / bottom sheets : apparition et disparition continues. */
html[data-ui-theme="standard"] .sheet-backdrop {
  opacity: 0;
  visibility: hidden;
  background: rgba(20,18,15,.13) !important;
  -webkit-backdrop-filter: blur(var(--v139-sheet-blur)) saturate(120%) !important;
  backdrop-filter: blur(var(--v139-sheet-blur)) saturate(120%) !important;
  transition:
    opacity var(--v139-medium) ease,
    visibility var(--v139-medium) allow-discrete,
    display var(--v139-medium) allow-discrete,
    background-color var(--v139-medium) ease,
    -webkit-backdrop-filter var(--v139-medium) ease,
    backdrop-filter var(--v139-medium) ease;
  transition-behavior: allow-discrete;
}

html[data-ui-theme="standard"] .sheet-backdrop.open {
  display: flex;
  opacity: 1;
  visibility: visible;
}

html[data-ui-theme="standard"] .sheet-backdrop > .sheet {
  opacity: 0;
  transform: translate3d(0,var(--v139-sheet-shift),0) scale(.992);
  transform-origin: center bottom;
  transition:
    transform var(--v139-slow) var(--v139-ease),
    opacity var(--v139-medium) ease;
  will-change: transform, opacity;
}

html[data-ui-theme="standard"] .sheet-backdrop.open > .sheet {
  opacity: 1;
  transform: translate3d(0,0,0) scale(1);
}

@starting-style {
  html[data-ui-theme="standard"] .sheet-backdrop.open { opacity: 0; }
  html[data-ui-theme="standard"] .sheet-backdrop.open > .sheet {
    opacity: 0;
    transform: translate3d(0,var(--v139-sheet-shift),0) scale(.992);
  }
}

html[data-ui-theme="standard"][data-theme="light"] .sheet-backdrop > .sheet {
  background: color-mix(in srgb, #fff 91%, transparent) !important;
  -webkit-backdrop-filter: blur(calc(var(--v139-nav-blur) + 4px)) saturate(145%);
  backdrop-filter: blur(calc(var(--v139-nav-blur) + 4px)) saturate(145%);
}
html[data-ui-theme="standard"][data-theme="dark"] .sheet-backdrop > .sheet {
  background: color-mix(in srgb, #15181B 91%, transparent) !important;
  -webkit-backdrop-filter: blur(calc(var(--v139-nav-blur) + 4px)) saturate(135%);
  backdrop-filter: blur(calc(var(--v139-nav-blur) + 4px)) saturate(135%);
}

html[data-motion="economy"] .sheet-backdrop { background: rgba(20,18,15,.17) !important; }
html[data-motion="minimal"] .sheet-backdrop {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  background: rgba(20,18,15,.22) !important;
}
html[data-motion="minimal"][data-theme="light"] .sheet-backdrop > .sheet {
  background: #fff !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
html[data-motion="minimal"][data-theme="dark"] .sheet-backdrop > .sheet {
  background: #15181B !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

.sheet-backdrop.dragging,
.sheet-backdrop.dragging > .sheet {
  transition: none !important;
  animation: none !important;
}

/* Changement Accueil <-> Transactions. */
body.v139-main-transition[data-v139-nav-dir="forward"] #income-section:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="forward"] #income-summary:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="forward"] #transactions-hub:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="forward"] #fixed-section:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="forward"] #variable-section:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="forward"] .expense-tabs:not([hidden]) {
  animation: v139-view-in-forward var(--v139-medium) var(--v139-ease) both;
}
body.v139-main-transition[data-v139-nav-dir="back"] #income-section:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="back"] #income-summary:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="back"] #transactions-hub:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="back"] #fixed-section:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="back"] #variable-section:not([hidden]),
body.v139-main-transition[data-v139-nav-dir="back"] .expense-tabs:not([hidden]) {
  animation: v139-view-in-back var(--v139-medium) var(--v139-ease) both;
}

@keyframes v139-view-in-forward {
  from { opacity: .50; transform: translate3d(var(--v139-page-shift),0,0); }
  to { opacity: 1; transform: translate3d(0,0,0); }
}
@keyframes v139-view-in-back {
  from { opacity: .50; transform: translate3d(calc(0px - var(--v139-page-shift)),0,0); }
  to { opacity: 1; transform: translate3d(0,0,0); }
}

/* Sous-pages Réglages / Profil. */
.v139-section-enter[data-v139-section-dir="forward"] {
  animation: v139-section-forward var(--v139-medium) var(--v139-ease) both;
}
.v139-section-enter[data-v139-section-dir="back"] {
  animation: v139-section-back var(--v139-medium) var(--v139-ease) both;
}
@keyframes v139-section-forward {
  from { opacity: .35; transform: translate3d(var(--v139-page-shift),0,0); }
  to { opacity: 1; transform: translate3d(0,0,0); }
}
@keyframes v139-section-back {
  from { opacity: .35; transform: translate3d(calc(0px - var(--v139-page-shift)),0,0); }
  to { opacity: 1; transform: translate3d(0,0,0); }
}

/* Micro-interactions. */
html:not([data-motion="minimal"]) .section-menu-row,
html:not([data-motion="minimal"]) .sheet-button,
html:not([data-motion="minimal"]) .profile-text-button,
html:not([data-motion="minimal"]) .transactions-segmented button,
html:not([data-motion="minimal"]) .expense-tabs button,
html:not([data-motion="minimal"]) .preference-order-actions button {
  transition:
    transform var(--v139-fast) var(--v139-ease),
    opacity var(--v139-fast) ease,
    background-color var(--v139-fast) ease,
    box-shadow var(--v139-fast) ease;
}
html:not([data-motion="minimal"]) .v139-pressed {
  transform: scale(.985) !important;
}

html:not([data-motion="minimal"]) .notification-badge:not([hidden]),
html:not([data-motion="minimal"]) .v112-undo-toast:not([hidden]) {
  animation: v139-pop var(--v139-medium) var(--v139-spring) both;
}
@keyframes v139-pop {
  from { opacity: 0; transform: translate3d(0,7px,0) scale(.96); }
  to { opacity: 1; transform: translate3d(0,0,0) scale(1); }
}

/* Minimal = aucun mouvement, aucun blur coûteux. */
html[data-motion="minimal"] *,
html[data-motion="minimal"] *::before,
html[data-motion="minimal"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  transition-delay: 0ms !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  scroll-behavior: auto !important;
}
html[data-motion="minimal"] .v139-nav-indicator,
html[data-motion="minimal"] .ca-bottom-icon,
html[data-motion="minimal"] .sheet-backdrop,
html[data-motion="minimal"] .sheet-backdrop > .sheet,
html[data-motion="minimal"] .section-menu-row,
html[data-motion="minimal"] .sheet-button,
html[data-motion="minimal"] .profile-text-button {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html[data-motion-preference="auto"] *,
  html[data-motion-preference="auto"] *::before,
  html[data-motion-preference="auto"] *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
