/* Veilleuse (mode nuit) de la webapp : mêmes couleurs que la veilleuse du site
   (planche V5 carte 11, palette F « Bleu minuit pastel », validées par Loïc les 28 et 29 octobre 2026).
   Active quand <html data-veilleuse="on"> (veilleuse.js : de 19 h à 7 h, ou le bouton lune).
   Le thème figé peint son verre en !important dans @layer meettomo-theme ; une déclaration
   importante d'une couche NOMMÉE AVANT gagne, d'où l'ordre ci-dessous : ce fichier doit être
   chargé avant meettomo-theme.css. Le thème partagé n'est pas modifié. Le jour ne change pas.
   Tomo, ses accessoires et les couleurs réelles des objets gardent leurs couleurs. */
@layer meettomo-veilleuse, meettomo-theme;

@layer meettomo-veilleuse {
 :root[data-veilleuse=on] {
  /* Night glass (palette F, 29 October 2026): the same transparent pane, tinted periwinkle-cobalt,
     with a brighter glossy sheen across the top. */
  [data-mt-surface]{
   background:linear-gradient(180deg,#ffffff2e 0,#ffffff00 42%),linear-gradient(128deg,#34477ac4,#26356ab0 48%,#3a3a78c4)!important;
   box-shadow:inset 0 1px 0 #ffffff47,inset 0 0 0 1px #ffffff12,0 16px 36px #04060c55!important;
  }
  [data-mt-surface=compact]{background:linear-gradient(180deg,#ffffff1f 0,#ffffff00 45%),linear-gradient(135deg,#3d528cd6,#2a3a70d0)!important}
  /* The watercolor still answers the pointer, as a lamp-lit tint that keeps the text readable. */
  [data-mt-surface]:is([data-mt-hover=true],[data-mt-focus=true],[data-mt-touch=true])::after{opacity:.3!important}
  [data-mt-surface][aria-pressed=true]:not(.chosen):not(.answer-correct):not([data-result])::after,
  .navigation [data-mt-surface][aria-current=page]::after,.sidebar nav :is(button.active,[aria-current=page])::after{opacity:.32!important}
  /* Boutons de nuit : neutres au repos ; lueur jaune pâle, comme le logo, seulement au survol, au toucher,
     au clavier : un seul bouton éclairé à la fois ; la page en cours garde sa teinte pastel
     (planche E3 « lampe forte », Loïc, 6 novembre 2026). */
  :is(button,a.button,.button)[data-mt-surface]{box-shadow:inset 0 1px 0 #ffffff33,inset 0 0 0 1px #ffffff14!important;transition:box-shadow .25s ease}
  :is(button,a.button,.button)[data-mt-surface]:is([data-mt-hover=true],[data-mt-focus=true],[data-mt-touch=true],:active){box-shadow:var(--mt-night-glow,inset 0 1px 0 #ffe9a88c,0 0 0 1.5px #ffe9a8a6,0 0 24px #ffdf9a73)!important}
  [data-mt-surface].button.primary:not(.secondary){background:linear-gradient(128deg,#ffffffe6,#ffffff9e) padding-box,linear-gradient(90deg,#9fd6b9,#bba8ea,#f0ad8c,#f0cf6a) border-box!important}
  [data-mt-surface]:is(.answer-correct,[data-result=correct]){background:#294538!important}
  [data-mt-surface][data-result=wrong]{background:#4a3328!important}
 }
}
@media (any-hover:hover){
 @layer meettomo-veilleuse{:root[data-veilleuse=on] [data-mt-surface]:hover::after{opacity:.3!important}}
}

/* Couleurs de nuit (règles simples). */
:root[data-veilleuse=on]{color-scheme:dark}
:root[data-veilleuse=on] body{background:#1a2340;color:#eef0ea}
:root[data-veilleuse=on] .mt-gradient{opacity:1;background:linear-gradient(118deg,#1a2340 0%,#22407a 18%,#3d3f8a 34%,#5a4580 52%,#2f5f7a 70%,#20506a 86%,#1a2340 100%)}
:root[data-veilleuse=on] .mt-pool{opacity:.9}
:root[data-veilleuse=on] .mt-pool-mint{background:radial-gradient(circle,#2f6a8a 0,#2f6a8a00 66%)}
:root[data-veilleuse=on] .mt-pool-lavender{background:radial-gradient(circle,#5a5ab0 0,#5a5ab000 66%)}
:root[data-veilleuse=on] .mt-pool-peach{background:radial-gradient(circle,#8a5a8a 0,#8a5a8a00 66%)}
:root[data-veilleuse=on] .mt-pool-sun{background:radial-gradient(circle,#8a7a4a 0,#8a7a4a00 64%);opacity:.7}
:root[data-veilleuse=on] .brand img{filter:drop-shadow(0 0 7px #ffd98a59) drop-shadow(0 0 18px #ffd98a2e)}
:root[data-veilleuse=on] .sidebar{background:#1e2850d9;border-color:#ffffff1a}

/* Texte peint en encre de jour : relevé au clair de lune. Gardent leur encre sombre : les boutons
   principaux (verre blanc arc-en-ciel) et les pastilles pastel qui ont un sens (états, niveaux). */
:root[data-veilleuse=on]{--ink:#eef0ea}
:root[data-veilleuse=on] body :is(p,li,dd,dt,label,legend,td,th,small,span,b,strong,em,div,button,h1,h2,h3,h4,h5,a,summary,figcaption):not(:is(.button.primary,.primary-action,.tomo-avatar,.tomo,.tomo-thoughts,.veilleuse-fx,.teacher-state,.teacher-chip) *):not(.button.primary,.primary-action,.teacher-state,.teacher-chip){color:#d6dce1}
:root[data-veilleuse=on] body :is(h1,h2,h3,h4,h5,strong,b):not(:is(.button.primary,.teacher-state,.teacher-chip) *){color:#f4f1e8}
:root[data-veilleuse=on] body a:not(.button,.has-lang-flag,[data-mt-surface]){color:#a9e8ff}
:root[data-veilleuse=on] :is(.button.primary,.teacher-chip),:root[data-veilleuse=on] :is(.button.primary,.teacher-chip) *{color:#203b4a}

/* Îlots clairs de la webapp qui passent au verre de nuit. */
:root[data-veilleuse=on] :is(dialog,#tomo-help){background:linear-gradient(150deg,#2f3f74fa,#24305af5)!important;color:#eef0ea;border-color:#ffffff24!important;box-shadow:inset 0 1px 1px #ffffff24,0 25px 80px #0008!important}
:root[data-veilleuse=on] dialog::backdrop{background:#0a0f1fa6}
:root[data-veilleuse=on] #tomo-help-text{background:#ffffff14!important;border-color:#ffffff1f!important}
:root[data-veilleuse=on] .step-dot{background:#ffffff1f}
:root[data-veilleuse=on] .listen{background:#2a3a70b8!important;border-color:#ffffff2e!important;color:#eef0ea}
:root[data-veilleuse=on] .tomo-avatar{background:radial-gradient(circle,#34477a,#26356a)}
:root[data-veilleuse=on] :is(input,select,textarea){background:#232d4f!important;color:#eef0ea!important;border-color:#ffffff2e!important}
:root[data-veilleuse=on] :is(input,textarea)::placeholder{color:#9aa6b0}


/* Petites pastilles et bulles claires : verre de nuit, texte clair. */
:root[data-veilleuse=on] :is(.xp-pill,.hero-bubble,.chip,.preview-session-note,.gift-progress-track,.demo-pill,.tomo-thoughts,.hero-labels>span,.mt-bubble,.parent-trust,.teacher-status,.pill,.teacher-state[data-state=new],.tomo-dock-cta,.national-curriculum-link){background:linear-gradient(180deg,#ffffff1f 0,#ffffff00 45%),linear-gradient(135deg,#3d528cd6,#2a3a70d0)!important;border-color:#ffffff24!important;box-shadow:inset 0 1px 0 #ffffff2e!important}
:root[data-veilleuse=on] :is(.xp-pill,.hero-bubble,.chip,.preview-session-note,.demo-pill,.mt-bubble,.parent-trust,.teacher-status,.pill,.tomo-dock-cta) *{color:#eef0ea}
:root[data-veilleuse=on] :is(.tomo-dock-cta,.national-curriculum-link){color:#eef0ea!important}
/* Chemin des questions : pierres à découvrir en verre de nuit ; en cours, réussie, à revoir gardent leur pastel. */
:root[data-veilleuse=on] .mission-trail{background:#ffffff14;border-color:#ffffff2e;box-shadow:inset 0 1px 0 #ffffff24}
:root[data-veilleuse=on] .mission-trail li:not(.complete,.current,.missed) .trail-stone{background:#ffffff1f;border-color:#ffffff40;box-shadow:none}
:root[data-veilleuse=on] .mission-trail :is(.complete,.current,.missed) .trail-stone{color:#203b4a!important}
:root[data-veilleuse=on] .teacher-state[data-state=new]{color:#eef0ea}
:root[data-veilleuse=on] :is(th,td){background-color:#ffffff0d!important}
:root[data-veilleuse=on] .mt-bubble::after{background:#2f4078!important;border-color:#2f4078!important}
:root[data-veilleuse=on] :is(.nav-icon,.avatar,.subject-icon,.toc-number){background:#ffffff1f!important;color:#eef0ea}
:root[data-veilleuse=on] .nav-icon .nav-paper{fill:none}
:root[data-veilleuse=on] .nav-water-ink{background:linear-gradient(135deg,#4a5aa0,#5a4f96)!important}

/* Espaces parent, enseignant et élève. */
:root[data-veilleuse=on] .mt-roles-list{background:#ffffff14;border-color:#ffffff2e;box-shadow:inset 0 1px 0 #ffffff24}
:root[data-veilleuse=on] .mt-roles-list a:not([aria-current=page]){color:#eef0ea}
:root[data-veilleuse=on] .mt-roles-list a:hover:not([aria-current=page]){background:#ffffff1f}
:root[data-veilleuse=on] .mt-roles-list a[aria-current=page]{color:#203b4a!important}
:root[data-veilleuse=on] .skip-link{background:#fbf9f2;color:#203b4a}
/* Parcours nationaux. 14/11/2026 (contrôle du parcours d’essai) : .primary-action était repeint en gris clair par
   la règle générale ci-dessus, « Check my answer » devenait illisible sur le bouton arc-en-ciel (en, ja, es, ko, ru). */
:root[data-veilleuse=on] .primary-action,:root[data-veilleuse=on] .primary-action *{color:#203b4a}
:root[data-veilleuse=on] .secondary-action{background:#2a3a70b8;border-color:#ffffff2e}
:root[data-veilleuse=on] button[aria-pressed=true]:not([data-mt-surface]){background:#3a4c84d0}
:root[data-veilleuse=on] .answers button[data-result=correct]{background:#294538}
:root[data-veilleuse=on] .answers button[data-result=wrong]{background:#4a3328}
/* Pastilles pastel de la leçon (« Bravo ! » après une bonne réponse, « 6 / 6 · Une leçon de plus », encadré du
   chapitre) : la règle générale éclaircit leur texte, leur fond doit donc passer au vert de nuit (14/11/2026 :
   contraste 1,2:1, presque illisible). Contrôle : check-parcours-essai, « texte illisible ». */
:root[data-veilleuse=on] :is(.result.correct,.victory-label,.series-victory-note){background:#294538!important;border-color:#ffffff24!important}

/* Reflet blanc des boutons secondaires adouci la nuit (« Une pause », « Un petit indice ? »). */
:root[data-veilleuse=on] .button.secondary::before{opacity:.18!important}
/* Barre du bas sur téléphone : un peu d'air entre les boutons. */
@media(max-width:760px){:root[data-veilleuse=on] .sidebar nav>button{scale:.94}}

/* Le menu coupe ce qui dépasse (effet d'eau) : on lui donne de la place pour que le halo des boutons reste rond. */
:root[data-veilleuse=on] .sidebar nav.water-nav{padding:16px;margin:-16px}

/* Règle des boutons du 5 novembre (encre au repos, vert au survol) : à la nuit, encre de lune et vert clair. */
:root[data-veilleuse=on]{--mt-nav-ink:#eef0ea;--mt-nav-icon:#eef0ea;--mt-nav-green:#a6e3c9}
:root[data-veilleuse=on] :is(.sidebar nav .nav-icon,.sidebar .profile .avatar){background:#ffffff1f!important;border-color:#ffffff40!important;box-shadow:inset 0 1px 0 #ffffff33!important}
:root[data-veilleuse=on] .sidebar nav button.active .nav-icon{background:#ffffff2e!important}

/* Bouton soleil/lune (veilleuse.js), dans la barre du haut à côté des points d'effort. */
.veilleuse-toggle{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;flex:none;margin-left:auto;margin-right:10px;border:0;border-radius:50%;color:#24384a;cursor:pointer}
.veilleuse-toggle+.xp-pill{margin-left:0}
.veilleuse-toggle svg{width:18px;height:18px}
@media(any-hover:hover){.veilleuse-toggle:hover{color:#438775}}
:root[data-veilleuse=on] .veilleuse-toggle{color:#eef0ea}
/* Sans barre du haut, le bouton reste en haut de la page et défile avec elle : il ne recouvre plus
   une pastille comme « Question 1 sur 8 » quand on fait défiler (6 novembre 2026). */
.veilleuse-toggle-floating{position:absolute;top:14px;right:14px;z-index:20;margin:0}
@media(max-width:760px){.veilleuse-toggle{width:38px;height:38px;margin-right:6px}}

/* Night stars (components/night-sky.tsx, planche étoiles variante B, Loïc, 29 octobre 2026):
   a few pastel four-point sparkles behind the content. --lit (0 to 1) is set by the pointer. */
.mt-night-sky{position:fixed;inset:0;z-index:-1;pointer-events:none;overflow:hidden;contain:strict;opacity:0;visibility:hidden;transition:opacity .9s ease,visibility 0s .9s}
:root[data-veilleuse=on] .mt-night-sky{opacity:1;visibility:visible;transition:opacity .9s ease}
.mt-night-star{position:absolute;width:var(--s);height:var(--s);margin:calc(var(--s) / -2) 0 0 calc(var(--s) / -2)}
.mt-night-star b,.mt-night-star::before{content:"";position:absolute;inset:0;background:var(--c);clip-path:polygon(50% 0,59% 41%,100% 50%,59% 59%,50% 100%,41% 59%,0 50%,41% 41%)}
.mt-night-star b{display:block;opacity:.3;animation:mt-night-twinkle var(--t) ease-in-out var(--d) infinite alternate}
.mt-night-star::before{opacity:var(--lit,0)}
.mt-night-star::after{content:"";position:absolute;inset:calc(var(--s) * -3);border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--c) 85%,transparent) 0,color-mix(in srgb,var(--c) 25%,transparent) 30%,transparent 64%);opacity:var(--lit,0)}
@keyframes mt-night-twinkle{to{opacity:.75}}
:root:not([data-veilleuse=on]) .mt-night-star b{animation:none}
@media(prefers-reduced-motion:reduce){.mt-night-star b{animation:none;opacity:.75}.mt-night-sky{transition:none}}

/* Sun/moon switch animation (lib/veilleuse-fx.ts), above everything, never catches the pointer. */
.veilleuse-fx{position:fixed;inset:0;z-index:2147483000;pointer-events:none;overflow:hidden}
.veilleuse-fx i{position:absolute;display:block}
/* To night: clouds close in from both sides over a dusk tint, the moon grows from the button. */
.fx-dusk{inset:0;background:linear-gradient(180deg,#1b2338,#2a2a4d 60%,#3a2f4f);opacity:0;animation:fx-dusk 1.9s ease-in-out forwards}
@keyframes fx-dusk{35%{opacity:.96}55%{opacity:.96}to{opacity:0}}
.fx-clouds{top:-8vh;bottom:-8vh;width:78vw;filter:blur(5px) drop-shadow(0 0 30px #1a1f3a)}
.fx-clouds svg{display:block;width:100%;height:100%}
.fx-clouds-left{left:0;transform:translateX(-102%);animation:fx-clouds-left 1.9s cubic-bezier(.5,0,.3,1) forwards}
.fx-clouds-right{right:0;transform:translateX(102%) scaleX(-1);animation:fx-clouds-right 1.9s cubic-bezier(.5,0,.3,1) forwards}
@keyframes fx-clouds-left{38%{transform:translateX(0)}55%{transform:translateX(0)}to{transform:translateX(-102%)}}
@keyframes fx-clouds-right{38%{transform:translateX(0) scaleX(-1)}55%{transform:translateX(0) scaleX(-1)}to{transform:translateX(102%) scaleX(-1)}}
/* The moon and the sun are laid out at their biggest size and shrink back to the button, so the
   phone draws them sharp at their peak (a 20px drawing scaled up by 5 was blurry on iPhone). */
.fx-moon{--big:calc(var(--icon) * 5);left:var(--x);top:var(--y);width:var(--big);height:var(--big);margin:calc(var(--big) / -2) 0 0 calc(var(--big) / -2);z-index:2;transform:scale(.2);animation:fx-moon 2s cubic-bezier(.3,1.2,.4,1) forwards}
.fx-moon svg,.fx-sun svg{display:block;width:100%;height:100%;overflow:visible}
.fx-moon path{fill:#fff1c4;stroke:#ffe29a;stroke-width:1;filter:drop-shadow(0 0 10px #ffe9a8) drop-shadow(0 0 30px #ffd98a99)}
@keyframes fx-moon{35%{transform:scale(1)}60%{transform:scale(1)}85%{transform:scale(.2);opacity:1}to{transform:scale(.2);opacity:0}}
.fx-star{z-index:1;width:calc(10px * var(--s));aspect-ratio:1;background:#fff6d6;clip-path:polygon(50% 0,61% 39%,100% 50%,61% 61%,50% 100%,39% 61%,0 50%,39% 39%);filter:drop-shadow(0 0 4px #ffe9a8);opacity:0;transform:scale(0);animation:fx-star 1.3s ease-out var(--d) forwards}
@keyframes fx-star{25%{opacity:1;transform:scale(1.25)}45%{transform:scale(1)}70%{opacity:1}to{opacity:0;transform:scale(.8)}}
/* To day: a sunrise from the button. The sun grows there and its dawn light spreads in warm rings. */
.fx-sun{--big:calc(var(--icon) * 4.5);left:var(--x);top:var(--y);width:var(--big);height:var(--big);margin:calc(var(--big) / -2) 0 0 calc(var(--big) / -2);z-index:2;transform:scale(.2222);animation:fx-sun 1.9s cubic-bezier(.3,1.3,.4,1) forwards}
.fx-sun svg{fill:#ffd36e;stroke:#ffb84d;stroke-width:2.2;stroke-linecap:round;filter:drop-shadow(0 0 22px #ffd98acc)}
@keyframes fx-sun{30%{transform:scale(1) rotate(90deg)}60%{transform:scale(1) rotate(140deg)}85%{transform:scale(.2222) rotate(180deg);opacity:1}to{transform:scale(.2222) rotate(180deg);opacity:0}}
.fx-dawn{inset:0;background:radial-gradient(circle at var(--x) var(--y),#fff6d6 0,#ffe08a 9%,#ffcf8a 20%,#fbd6c0 38%,#ecdcf2 62%,#fff9f1 90%);clip-path:circle(0 at var(--x) var(--y));animation:fx-dawn 1.9s cubic-bezier(.5,0,.3,1) forwards}
@keyframes fx-dawn{40%{clip-path:circle(150vmax at var(--x) var(--y));opacity:1}58%{clip-path:circle(150vmax at var(--x) var(--y));opacity:1}to{clip-path:circle(150vmax at var(--x) var(--y));opacity:0}}
/* Lamp sparkle around the logo once the night has fallen. */
.fx-twinkle{width:calc(9px * var(--s));aspect-ratio:1;margin:calc(-4.5px * var(--s)) 0 0 calc(-4.5px * var(--s));background:#ffe9b0;clip-path:polygon(50% 0,60% 40%,100% 50%,60% 60%,50% 100%,40% 60%,0 50%,40% 40%);filter:drop-shadow(0 0 3px #ffd98a);opacity:0;transform:scale(0) rotate(0);animation:fx-twinkle 1.1s ease-in-out var(--d) 2 alternate}
@keyframes fx-twinkle{50%{opacity:1;transform:scale(1.2) rotate(45deg)}to{opacity:0;transform:scale(.4) rotate(90deg)}}
:root[data-mt-twinkle] .brand img{animation:mt-lamp 1.8s ease-in-out}
@keyframes mt-lamp{40%{filter:drop-shadow(0 0 10px #ffd98acc) drop-shadow(0 0 26px #ffd98a66)}}

/* Étapes et choix de l'inscription la nuit (6 novembre 2026, demande de Loïc) : le texte était clair sur
   des pastilles claires. Elles passent au verre de nuit ; l'étape en cours garde sa teinte menthe. */
:root[data-veilleuse=on] .onboarding-steps li{background:#ffffff1a!important;box-shadow:inset 0 0 0 1px #ffffff2e;color:#e4e8ec!important}
:root[data-veilleuse=on] .onboarding-steps li span{background:#ffffff26!important;color:#f4f1e8!important}
:root[data-veilleuse=on] .onboarding-steps li.current{background:#a6e3c938!important;box-shadow:inset 0 0 0 1px #a6e3c999;color:#f4f1e8!important}
:root[data-veilleuse=on] .onboarding-steps li.complete span{background:#65b990!important;color:#16242f!important}
:root[data-veilleuse=on] .onboarding-steps li.complete span *{color:#16242f!important}
:root[data-veilleuse=on] .motion-choice-capsules>span{background:#ffffff1f!important;border-color:#ffffff59!important;color:#f4f1e8!important}
:root[data-veilleuse=on] .motion-choice-capsules>span::before{color:#a6e3c9}
/* 22/11/2026 (Loïc : « on ne voit rien ») : la nuit, le verre bleu de [data-mt-surface] recouvrait les cabines du manège
   des classes, et leurs noms en encre foncée devenaient illisibles. Les cabines gardent leurs couleurs pastel de jour
   (ce sont des objets, comme Tomo), et les flèches passent en encre claire (tests/manege-veilleuse-20261122.test.mjs). */
@layer meettomo-veilleuse{
 :root[data-veilleuse=on] .choice-grid.mt-carousel>button.mt-cabin[data-mt-surface]{
  background:radial-gradient(70% 55% at 30% 18%,#ffffffd9,#fff0 60%),linear-gradient(180deg,var(--lt),var(--b) 62%,var(--d))!important;
  box-shadow:inset 0 -7px 0 #00000012,inset 0 -9px 10px -4px var(--d),inset 0 3px 2px #fff,0 14px 18px -10px #04060c80!important}
 :root[data-veilleuse=on] .choice-grid.mt-carousel>button.mt-cabin.is-front[data-mt-surface]{
  box-shadow:inset 0 -7px 0 #00000012,inset 0 -9px 10px -4px var(--d),inset 0 3px 2px #fff,0 14px 18px -10px #04060c80,0 0 22px 4px #bba8ea80!important}
 :root[data-veilleuse=on] .choice-grid.mt-carousel>button.mt-cabin :is(strong,small){color:#203b4a!important}
 :root[data-veilleuse=on] .choice-grid.mt-carousel>button.mt-c-arrow{color:#eef1f6!important}
}
