/* ═══════════════════════════════════════════════════════════════
   ADAPTIA — animations.css  v1.0
   Micro-interactions, loading states, transitions responsives
   Inject via <link> or inline in ds.css
═══════════════════════════════════════════════════════════════ */

/* ── Global transitions ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Smooth scrolling */
html { scroll-behavior: smooth; }

/* Focus rings accessibles */
:focus-visible {
  outline: 2px solid var(--accent, #2d6a4f);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ── Boutons ────────────────────────────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
  transition: all .18s cubic-bezier(.4,0,.2,1);
}

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.15);
  opacity: 0;
  border-radius: inherit;
  transition: opacity .3s;
}
.btn:active::after { opacity: 1; }

/* Hover lift */
.btn-primary:hover, .btn-ink:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(45,106,79,.28);
}
.btn-primary:active, .btn-ink:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Ghost hover */
.btn-ghost:hover {
  transform: translateX(2px);
}

/* Disabled state */
.btn:disabled, .btn[disabled] {
  opacity: .42;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Loading state on button */
.btn.loading {
  pointer-events: none;
  opacity: .75;
}
.btn.loading .btn-text { opacity: 0; }
.btn.loading::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: btn-spin .65s linear infinite;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
@keyframes btn-spin { to { transform: translate(-50%,-50%) rotate(360deg); } }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  transition: box-shadow .2s, transform .2s;
}

/* Flow cards (index page) */
.flow-card {
  transition: all .22s cubic-bezier(.4,0,.2,1);
}
.flow-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(28,27,46,.12);
}
.flow-card.done:hover {
  box-shadow: 0 6px 20px rgba(45,106,79,.18);
}

/* User cards (login page) */
.user-card {
  transition: all .15s cubic-bezier(.4,0,.2,1);
}
.user-card:hover {
  transform: translateX(4px);
}
.user-card:active {
  transform: translateX(2px) scale(.99);
}

/* ── Page entrance animation ─────────────────────────────────── */
@keyframes page-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-body,
.login-card-wrap,
.layout {
  animation: page-in .3s cubic-bezier(.4,0,.2,1) both;
}

/* ── Sidebar items ───────────────────────────────────────────── */
.cls-item, .tch-item {
  transition: background .12s, border-color .12s, transform .12s;
}
.cls-item:hover, .tch-item:hover {
  transform: translateX(2px);
}
.cls-item.active, .tch-item.active {
  animation: slide-in-left .2s cubic-bezier(.4,0,.2,1) both;
}
@keyframes slide-in-left {
  from { transform: translateX(-6px); opacity: .7; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Connectivity bar ────────────────────────────────────────── */
.conn-dot-wrap {
  transition: all .4s cubic-bezier(.4,0,.2,1);
}
.conn-dot-wrap.conn-ok {
  animation: conn-ok-pop .4s cubic-bezier(.4,0,.2,1) both;
}
@keyframes conn-ok-pop {
  0%   { transform: scale(.8); opacity: .5; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1);   opacity: 1; }
}

/* Pulse erreur */
.conn-dot-wrap.conn-err .conn-dot {
  animation: dot-err-pulse 1.2s ease-in-out infinite;
}
@keyframes dot-err-pulse {
  0%, 100% { box-shadow: 0 0 3px rgba(224,122,122,.4); }
  50%       { box-shadow: 0 0 10px rgba(224,122,122,.8); }
}

/* ── Header step trail ───────────────────────────────────────── */
.a-step {
  transition: all .15s;
}
.a-step.current {
  animation: step-current-in .3s cubic-bezier(.4,0,.2,1) both;
}
@keyframes step-current-in {
  from { opacity: .5; transform: scale(.95); }
  to   { opacity: 1;  transform: scale(1); }
}
.a-step.done {
  animation: step-done .4s cubic-bezier(.4,0,.2,1) both;
}
@keyframes step-done {
  from { opacity: .7; }
  to   { opacity: 1; }
}

/* ── Spinner global ─────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(45,106,79,.2);
  border-top-color: var(--accent, #2d6a4f);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }
.spinner.sm { width: 12px; height: 12px; border-width: 2px; }
.spinner.white {
  border-color: rgba(255,255,255,.3);
  border-top-color: white;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton loading ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--paper-2) 25%, var(--paper-3) 50%, var(--paper-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s ease-in-out infinite;
  border-radius: var(--r, 6px);
}
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast ───────────────────────────────────────────────────── */
#a-toast {
  transition: transform .28s cubic-bezier(.4,0,.2,1), opacity .28s;
}
#a-toast.show {
  animation: toast-in .28s cubic-bezier(.4,0,.2,1) both;
}
@keyframes toast-in {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Modals ──────────────────────────────────────────────────── */
.a-modal-overlay {
  transition: opacity .2s;
}
.a-modal-overlay:not(.open) { opacity: 0; pointer-events: none; }
.a-modal-overlay.open { opacity: 1; }
.a-modal {
  animation: modal-in .25s cubic-bezier(.4,0,.2,1) both;
}
@keyframes modal-in {
  from { transform: scale(.94) translateY(-8px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* ── Forms ───────────────────────────────────────────────────── */
input, textarea, select {
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  animation: field-focus .2s cubic-bezier(.4,0,.2,1) both;
}
@keyframes field-focus {
  from { box-shadow: 0 0 0 0 rgba(45,106,79,0); }
  to   { box-shadow: 0 0 0 3px rgba(45,106,79,.1); }
}

/* ── Badge animations ────────────────────────────────────────── */
.badge {
  transition: transform .12s, opacity .12s;
}
.badge-custom.show {
  animation: badge-pop .25s cubic-bezier(.4,0,.2,1) both;
}
@keyframes badge-pop {
  from { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Progress bar ────────────────────────────────────────────── */
.prog-fill {
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* ── Student cards ───────────────────────────────────────────── */
.s-card {
  transition: box-shadow .2s, transform .15s;
  animation: card-appear .3s cubic-bezier(.4,0,.2,1) both;
}
.s-card:nth-child(1)  { animation-delay: .04s; }
.s-card:nth-child(2)  { animation-delay: .08s; }
.s-card:nth-child(3)  { animation-delay: .12s; }
.s-card:nth-child(4)  { animation-delay: .16s; }
.s-card:nth-child(5)  { animation-delay: .20s; }
.s-card:nth-child(6)  { animation-delay: .24s; }
.s-card:nth-child(7)  { animation-delay: .28s; }
.s-card:nth-child(8)  { animation-delay: .32s; }
.s-card:nth-child(n+9){ animation-delay: .36s; }
@keyframes card-appear {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Profile hero animation (settings) ──────────────────────── */
.profile-hero {
  animation: hero-in .35s cubic-bezier(.4,0,.2,1) both;
}
@keyframes hero-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Success redirect animation (login) ─────────────────────── */
@keyframes success-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45,106,79,0); }
  50%       { box-shadow: 0 0 32px rgba(45,106,79,.25); }
}
.login-card.success {
  animation: success-glow .6s ease-in-out 2;
}

/* ── Role badges ────────────────────────────────────────────── */
.role-badge {
  animation: badge-appear .3s cubic-bezier(.4,0,.2,1) both;
  animation-delay: .1s;
}
@keyframes badge-appear {
  from { transform: scale(0) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

/* ── Readonly banner ─────────────────────────────────────────── */
#readonly-banner {
  animation: banner-drop .3s cubic-bezier(.4,0,.2,1) both;
}
@keyframes banner-drop {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── Help drawer ─────────────────────────────────────────────── */
.help-trigger {
  animation: fab-in .5s cubic-bezier(.4,0,.2,1) .5s both;
}
@keyframes fab-in {
  from { transform: scale(0) rotate(-90deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}

/* ── Tab transitions ─────────────────────────────────────────── */
.stab-panel.active {
  animation: tab-in .2s cubic-bezier(.4,0,.2,1) both;
}
@keyframes tab-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Language cards ─────────────────────────────────────────── */
.lang-card {
  transition: all .18s cubic-bezier(.4,0,.2,1);
}
.lang-card.active {
  animation: lang-select .25s cubic-bezier(.4,0,.2,1) both;
}
@keyframes lang-select {
  0%   { transform: scale(.97); }
  60%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* ── Connectivity bar enter ──────────────────────────────────── */
#conn-bar {
  animation: conn-bar-in .3s cubic-bezier(.4,0,.2,1) both;
  animation-delay: .1s;
}
@keyframes conn-bar-in {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Icon grid (PWA settings) ────────────────────────────────── */
.icon-item {
  animation: icon-pop .3s cubic-bezier(.4,0,.2,1) both;
}
.icon-item:nth-child(1) { animation-delay: .05s; }
.icon-item:nth-child(2) { animation-delay: .10s; }
.icon-item:nth-child(3) { animation-delay: .15s; }
.icon-item:nth-child(4) { animation-delay: .20s; }
.icon-item:nth-child(5) { animation-delay: .25s; }
.icon-item:nth-child(6) { animation-delay: .30s; }
.icon-item:nth-child(7) { animation-delay: .35s; }
.icon-item:nth-child(8) { animation-delay: .40s; }
.icon-item:nth-child(n+9) { animation-delay: .45s; }
@keyframes icon-pop {
  from { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  70%  { transform: scale(1.05) rotate(2deg); }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ── User chip (header) ──────────────────────────────────────── */
.a-user-chip {
  animation: chip-in .35s cubic-bezier(.4,0,.2,1) .2s both;
}
@keyframes chip-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Bilingual exercise layout ───────────────────────────────── */
.bilingual-exercise {
  animation: bilingual-in .4s cubic-bezier(.4,0,.2,1) both;
}
@keyframes bilingual-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.bilingual-col {
  transition: background .2s;
}

/* ── DB stats ────────────────────────────────────────────────── */
.db-stat .n {
  transition: color .3s;
  animation: count-up .5s cubic-bezier(.4,0,.2,1) both;
}
@keyframes count-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */

/* Mobile (< 480px) */
@media (max-width: 480px) {
  .a-header { padding: 0 12px; gap: 10px; }
  .a-logo   { font-size: 18px; }
  .a-steps  { display: none; } /* hidden on very small screens */
  .a-lang   { display: none; } /* shown in mobile menu instead */

  .page-body { padding: 16px 12px 80px; }

  .cards-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .help-trigger { bottom: 16px; right: 16px; width: 42px; height: 42px; }
  .help-drawer  { width: 100%; max-width: 100%; }

  .sticky-foot { padding: 10px 12px; flex-wrap: wrap; }
  .sticky-foot .btn { flex: 1; min-width: 0; text-align: center; justify-content: center; }
}

/* Tablet (481px – 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .a-step .s-label { display: none; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: 220px 1fr; }
}

/* Desktop (769px – 1200px) */
@media (min-width: 769px) and (max-width: 1200px) {
  .page-body { max-width: 92%; }
}

/* Large (> 1200px) */
@media (min-width: 1201px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}

/* Print */
@media print {
  .a-header, .a-sidenav, #conn-bar, .help-trigger, .help-drawer,
  .help-overlay, .sticky-foot, #a-toast, .btn-secondary, .btn-ghost,
  [data-requires], .no-print { display: none !important; }

  body { background: white; font-size: 12pt; }
  .s-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  .bilingual-exercise { grid-template-columns: 1fr 1fr; }

  a[href]::after { content: ' (' attr(href) ')'; font-size: 9pt; color: #666; }
  a[href^='#']::after,
  a[href^='javascript']::after { content: ''; }
}

/* ── Dark mode (system preference) ──────────────────────────── */
@media (prefers-color-scheme: dark) {
  /* Conserve le design clair par défaut — Adaptia est pensé pour usage en salle de classe */
  /* Activer seulement si besoin : */
  /*
  :root {
    --ink:    #e8e6ff;
    --paper:  #1a1928;
    --white:  #252435;
    --paper-2:#1e1d30;
    --paper-3:#2d2b48;
  }
  */
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
