/* Refonte « pensée pour le téléphone » (REFONTE.md), chargé en dernier. Sur un ordinateur, rien ne change. */

/* ---------- Étape 2 : la série, réponses sous le pouce ---------- */
@media (max-width:640px){
  /* L'écran de la série prend la hauteur du téléphone : la fiche s'allonge, ses réponses descendent en bas */
  .wrap:has(#v-quiz:not([hidden])){padding-bottom:calc(16px + env(safe-area-inset-bottom))}
  #v-quiz:not([hidden]){display:flex;flex-direction:column;min-height:calc(100dvh - 44px - env(safe-area-inset-bottom))}
  #quiz-card{flex:1 0 auto;display:flex;flex-direction:column}
  /* La correction reste sous les choix : au-dessus, une longue explication poussait la bonne réponse sous « Suivant » */
  #qzone{margin-top:auto;padding-top:var(--espace-5)}
  /* Aide, Afficher la réponse, Pas su, Je savais : restent au bas de l'écran quand la réponse est longue */
  #qzone>.row{position:sticky;bottom:0;z-index:1;flex-wrap:nowrap;background:var(--bristol);padding-block:var(--espace-3) var(--espace-1)}
  #qzone>.row>.btn{flex:1 1 0;min-height:56px}
  #qzone>.row:not(.aide-row)>#aide-btn{flex:0 0 auto;padding-inline:var(--espace-5)}   /* « Afficher la réponse » sur une ligne */
  #next-row:not([hidden]){position:sticky;bottom:0;z-index:2;background:var(--kraft);padding-block:var(--espace-3) var(--espace-2)}
  /* Arrêter : une croix ronde de 44 px ; le mot reste lu par les lecteurs d'écran */
  #quit{width:44px;height:44px;flex:none;padding:0;gap:0;justify-content:center;border-radius:var(--rayon-rond);
    background:var(--bristol);box-shadow:var(--ombre-fiche);font-size:0;text-decoration:none}
}

/* ---------- Étape 3 : balayer la fiche (js/refonte.js), sur tous les écrans ---------- */
#quiz-card:has(#qzone #self-ok){touch-action:pan-y}   /* le doigt à l'horizontale va à la fiche, à la verticale à la page */
#quiz-card.pc-tire{user-select:none;-webkit-user-select:none;cursor:grabbing}
/* Pendant un geste, la fiche ou la feuille a sa propre couche : l'iPhone la déplace sans la redessiner */
#quiz-card.pc-tire,.pci-feuille.pc-tire,#pc-reglages-feuille.pc-tire{will-change:transform}
.pc-balai{position:absolute;top:14px;z-index:2;padding:2px 10px;border-radius:4px;font:700 16px/1.4 var(--f-body);opacity:0;pointer-events:none}
.pc-balai-oui{left:14px;rotate:-6deg;background:var(--surligneur);color:var(--on-surligneur);border:2px solid var(--on-surligneur)}
.pc-balai-non{right:14px;rotate:6deg;background:var(--bristol);color:var(--correcteur);border:2px solid var(--correcteur)}
.pc-balai-aide{margin:var(--espace-2) 0 0;text-align:center;font-size:13.5px;line-height:18px;color:var(--crayon)}

/* ---------- Étape 4 : Aujourd'hui sur un écran (téléphone) ---------- */
.pc-edt-plus{display:none}
@media (max-width:640px){
  /* Le titre de l'écran est celui de l'onglet : le nom de l'appli et le compte des chapitres partent */
  #accueil-jour>.top .brand>h1,#accueil-jour #sous-titre{display:none}
  /* Plus de grande fiche autour de tout : chaque bloc est posé sur le kraft */
  .today{margin-top:0;padding:0;background:none;border:0;box-shadow:none;gap:var(--espace-5)}
  .today-head h2{font-size:34px;line-height:36px}
  .today-main{gap:var(--espace-4)}
  .today-side{border-top:0;padding-top:0}
  /* La boîte, plus basse : tranches de 5 px ; sa légende et la ligne sous le bouton partent (le titre dit déjà ce qui sort) */
  .pc-accueil-boite .pc-colonne>.pc-case{height:84px;gap:2px}
  .pc-accueil-boite .pc-tranche{height:5px}
  #pc-boite-legende,#daily-note,#streak-sub{display:none}
  /* « Révision du jour » reste au-dessus des onglets quand on fait défiler */
  #daily{position:sticky;bottom:calc(92px + env(safe-area-inset-bottom));z-index:3}
  /* Le prochain rendez-vous seul ; les autres se comptent sous « Mon emploi du temps » (js/refonte.js) */
  #ech-list>li.pc-plus-tard{display:none}
  /* Cours du jour et emploi du temps : deux lignes d'une même fiche */
  #soir{border-top:0;padding:var(--espace-3) var(--espace-4);background:var(--bristol);border-radius:var(--rayon-fiche) var(--rayon-fiche) 0 0}
  #soir:has(#soir-list:empty) .pc-soir-top>b,#soir:has(#soir-list:empty) #soir-note{display:none}
  .today-main>div:has(>#go-edt){margin-top:calc(-1 * var(--espace-4));padding:var(--espace-1) var(--espace-4);background:var(--bristol);
    border-top:1px solid var(--bristol-pale);border-radius:0 0 var(--rayon-fiche) var(--rayon-fiche);box-shadow:var(--ombre-fiche);
    display:flex;align-items:center;justify-content:space-between;gap:var(--espace-3)}
  .pc-edt-plus{display:block;flex:none;font-size:13.5px;line-height:18px;color:var(--crayon)}
}
@media (max-width:640px){#go-edt .edt-detail{display:none}}
@media (max-width:640px){#go-edt{white-space:nowrap}.pc-edt-plus{flex:0 1 auto;min-width:0;text-align:right}}

/* ---------- Étape 5 : Réviser par matière (téléphone, js/refonte.js) ---------- */
.pc-rev-tete,.pc-rev-liste{display:none}
@media (max-width:640px){
  #accueil-reviser>.part-sep,#accueil-reviser .step-title .n{display:none}
  .pc-rev-tete{display:flex;flex-direction:column;align-items:flex-start;gap:var(--espace-1);margin-bottom:var(--espace-5)}
  .pc-rev-titre{margin:0;font:400 34px/36px var(--f-display)}
  #accueil-reviser:not([data-rev="matiere"]) .pc-rev-retour{display:none}
  /* La liste : « Mes erreurs », puis une ligne par matière ; les chapitres sont dans l'écran de chaque matière */
  #accueil-reviser[data-rev="liste"] .pc-rev-liste{display:flex;flex-direction:column;gap:var(--espace-3);margin-bottom:var(--espace-3)}
  #accueil-reviser[data-rev="liste"] :is(#matieres,.stats,#stats-explication,#chapitres,.step-title:has(+ #chapitres)){display:none}
  #accueil-reviser[data-rev="matiere"] :is(#matieres,.subj-tools){display:none}
  .pc-rev-sec{margin:var(--espace-3) 0 0;font:400 20px/26px var(--f-display)}
  .pc-rev-groupe{display:flex;flex-direction:column;background:var(--bristol);border-radius:var(--rayon-fiche);box-shadow:var(--ombre-fiche)}
  .pc-rev-ligne{min-height:60px;padding:8px 16px;border:0;border-bottom:1px solid var(--bristol-pale);background:transparent;display:flex;align-items:center;gap:12px;
    text-align:left;font:inherit;color:var(--graphite);-webkit-tap-highlight-color:transparent}
  .pc-rev-groupe>.pc-rev-ligne:last-child{border-bottom:0}
  .pc-rev-ligne:active{background:var(--bristol-pale)}
  .pc-rev-seule{background:var(--bristol);border:0;border-radius:var(--rayon-fiche);box-shadow:var(--ombre-fiche)}
  .pc-rev-ligne>span{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
  .pc-rev-ligne b{font-size:16px;line-height:22px}
  .pc-rev-ligne small{font-size:13.5px;line-height:18px;color:var(--crayon)}
  .pc-rev-ligne .dot{flex:none}
  .pc-rev-chevron{flex:none}
  /* Les écrans glissent : 0,25 s, depuis la droite pour une matière, depuis la gauche pour revenir */
  #accueil-reviser.pc-pousse{animation:pc-pousse .25s cubic-bezier(.2,.8,.3,1)}
  #accueil-reviser.pc-revient{animation:pc-revient .25s cubic-bezier(.2,.8,.3,1)}
}
@keyframes pc-pousse{from{translate:48px 0;opacity:0}}
@keyframes pc-revient{from{translate:-48px 0;opacity:0}}
@media (prefers-reduced-motion:reduce){#accueil-reviser.pc-pousse,#accueil-reviser.pc-revient{animation:none}}

/* ---------- Étape 6 : réglages de Réviser dans une feuille (téléphone, js/refonte.js) ---------- */
.pc-reglages-feuille{display:contents}   /* ailleurs, rien ne change : ses enfants restent à leur place dans Réviser */
.pc-reglages-ok,.pc-reglages-resume,.pc-reglages-fond{display:none}
@media (max-width:640px){
  .pc-reglages-feuille{display:none}
  .pc-reglages-feuille.pc-ouverte{display:block;position:fixed;left:0;right:0;bottom:0;z-index:60;max-height:85dvh;overflow-y:auto;overscroll-behavior:contain;
    box-sizing:border-box;padding:var(--espace-3) var(--espace-5) calc(var(--espace-5) + env(safe-area-inset-bottom));background:var(--bristol);
    border-radius:var(--rayon-boite) var(--rayon-boite) 0 0;box-shadow:var(--ombre-fiche-levee)}
  .pc-reglages-feuille.pc-ouverte::before{content:"";display:block;width:40px;height:5px;margin:0 auto var(--espace-3);border-radius:999px;background:var(--kraft-fonce)}
  .pc-reglages-feuille .step-title:first-child,.pc-reglages-feuille>.step-title:first-of-type{margin-top:0}
  .pc-reglages-fond:not([hidden]){display:block;position:fixed;inset:0;z-index:59;background:rgba(0,0,0,.45)}
  .pc-reglages-ok{display:flex;width:100%;justify-content:center;margin-top:var(--espace-4)}
  .pc-reglages-resume{display:flex;width:100%;min-height:44px;margin-bottom:var(--espace-2);padding:0 14px;align-items:center;justify-content:space-between;gap:12px;
    border:1px solid var(--line);border-radius:var(--rayon-fiche);background:var(--bristol);font:inherit;font-size:15px;color:var(--graphite);text-align:left}
  .pc-reglages-resume>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .pc-reglages-feuille.pc-monte{animation:pci-monte .3s cubic-bezier(.2,.8,.3,1) both}
  .pc-reglages-feuille.pc-descend{animation:pci-descend .22s cubic-bezier(.7,0,.8,.2) both}
  .pc-reglages-fond:not([hidden]){animation:pc-apparait .25s ease both}
  .pc-reglages-fond.pc-descend{animation:pci-efface .22s ease-in both}
}

/* ---------- Étapes 7 et 8 : Paramètres et Mes cours en écrans (téléphone, js/refonte.js) ---------- */
.pc-par-tete{display:none}
@media (max-width:640px){
  /* Une rubrique ouverte prend l'écran : le titre de l'onglet, « Ajouter un cours » et les autres rubriques se cachent */
  :is(#v-profil,#v-outils):has(>.rubrique[open])>:not(.rubrique[open],.pc-par-tete){display:none}
  :is(#v-profil,#v-outils):has(>.rubrique[open])>.pc-par-tete{display:block;margin-bottom:var(--espace-2)}
  :is(#v-profil,#v-outils)>.rubrique>summary{min-height:60px}
  /* Son en-tête devient le titre de l'écran : on revient par « ‹ Paramètres », pas en touchant le titre */
  :is(#v-profil,#v-outils)>.rubrique[open]{background:none;box-shadow:none;padding:0}
  :is(#v-profil,#v-outils)>.rubrique[open]>summary{pointer-events:none;padding:0 0 var(--espace-4)}
  :is(#v-profil,#v-outils)>.rubrique[open]>summary .rub-titre{font-size:34px;line-height:36px}
  :is(#v-profil,#v-outils)>.rubrique[open]>summary :is(.rub-sous,.pc-icone){display:none}
  :is(#v-profil,#v-outils)>.rubrique[open]>:not(summary){background:var(--bristol);border-radius:var(--rayon-fiche);box-shadow:var(--ombre-fiche);margin-bottom:var(--espace-3)}
  :is(#v-profil,#v-outils).pc-pousse{animation:pc-pousse .25s cubic-bezier(.2,.8,.3,1)}
  :is(#v-profil,#v-outils).pc-revient{animation:pc-revient .25s cubic-bezier(.2,.8,.3,1)}
}
@media (prefers-reduced-motion:reduce){:is(#v-profil,#v-outils).pc-pousse,:is(#v-profil,#v-outils).pc-revient{animation:none}}
@media (max-width:640px){:is(#v-profil,#v-outils)>.rubrique>summary>.pc-icone{transform:rotate(180deg)}}   /* une ligne qui ouvre un écran : chevron vers la droite */

/* ---------- Étape 9 : glisser une feuille vers le bas pour la fermer (js/refonte.js) ---------- */
.pc-installer .pci-feuille{touch-action:none;user-select:none;-webkit-user-select:none}   /* feuilles courtes : le doigt, n'importe où, va à la feuille */
.pc-installer .pci-feuille::before{content:"";align-self:center;width:40px;height:5px;margin:-12px 0 0;border-radius:999px;background:var(--kraft-fonce)}
.pc-poignee{display:none}
@media (max-width:640px){
  /* Réglages de Réviser : la feuille défile ; on la tire par sa poignée */
  .pc-reglages-feuille.pc-ouverte::before{display:none}
  .pc-reglages-feuille.pc-ouverte>.pc-poignee{display:block;position:sticky;top:calc(-1 * var(--espace-3));z-index:1;height:28px;margin:calc(-1 * var(--espace-3)) calc(-1 * var(--espace-5)) 0;
    touch-action:none;cursor:grab;background:var(--bristol);border-radius:var(--rayon-boite) var(--rayon-boite) 0 0}
  .pc-poignee::after{content:"";display:block;width:40px;height:5px;margin:12px auto 0;border-radius:999px;background:var(--kraft-fonce)}
}

/* ---------- Étape 10 : couleur de l'appli (<html data-couleur>, js/refonte.js), sur tous les écrans ---------- */
/* Ombres refaites sur les variables : celles de boite.css ont le brun du kraft écrit en dur */
:root[data-couleur]{--ombre-fiche:0 2px 0 var(--bristol-ombre);--ombre-fiche-levee:0 3px 0 var(--bristol-ombre),0 10px 24px rgba(0,0,0,.14);
  --ombre-bouton:0 4px 0 var(--action-ombre);--ombre-bouton-secondaire:0 4px 0 var(--bristol-ombre)}
/* Jour */
:root[data-couleur="ardoise"]{--kraft:#DCE1E6;--kraft-fonce:#A9B4BF;--case:#8E9BA8;--bristol-ombre:#B5C0CB;--action-ombre:#6E7B88}
:root[data-couleur="sauge"]{--kraft:#DCE5D5;--kraft-fonce:#A8B99C;--case:#8DA080;--bristol-ombre:#B4C3A9;--action-ombre:#6F8063}
:root[data-couleur="lavande"]{--kraft:#E4DFEC;--kraft-fonce:#B6AACB;--case:#9C8EB5;--bristol-ombre:#C2B8D4;--action-ombre:#7D6F96}
:root[data-couleur="rose"]{--kraft:#EFDFDA;--kraft-fonce:#CFA9A0;--case:#B98C82;--bristol-ombre:#D8B8B0;--action-ombre:#996B62}
/* Soir (thème de l'appareil, ou choisi) : le même carton sombre, teinté ; le bristol suit la teinte. Contrastes mesurés : 4,5:1 au moins */
@media (prefers-color-scheme: dark){
  :root[data-couleur="ardoise"]:not([data-theme="light"]){--kraft:#171B20;--kraft-fonce:#2E353E;--case:#222830;--bristol:#252B33;--bristol-pale:#39414C;--bristol-ombre:#0F0D0A;--action-ombre:#4F5B68}
  :root[data-couleur="sauge"]:not([data-theme="light"]){--kraft:#161C17;--kraft-fonce:#2D372C;--case:#212921;--bristol:#242C24;--bristol-pale:#374236;--bristol-ombre:#0F0D0A;--action-ombre:#55634F}
  :root[data-couleur="lavande"]:not([data-theme="light"]){--kraft:#1B1822;--kraft-fonce:#352F42;--case:#272232;--bristol:#2A2533;--bristol-pale:#443D52;--bristol-ombre:#0F0D0A;--action-ombre:#5E5470}
  :root[data-couleur="rose"]:not([data-theme="light"]){--kraft:#201817;--kraft-fonce:#3E2E2B;--case:#2E2220;--bristol:#322725;--bristol-pale:#4D3C38;--bristol-ombre:#0F0D0A;--action-ombre:#6B544E}
}
:root[data-couleur="ardoise"][data-theme="dark"]{--kraft:#171B20;--kraft-fonce:#2E353E;--case:#222830;--bristol:#252B33;--bristol-pale:#39414C;--bristol-ombre:#0F0D0A;--action-ombre:#4F5B68}
:root[data-couleur="sauge"][data-theme="dark"]{--kraft:#161C17;--kraft-fonce:#2D372C;--case:#212921;--bristol:#242C24;--bristol-pale:#374236;--bristol-ombre:#0F0D0A;--action-ombre:#55634F}
:root[data-couleur="lavande"][data-theme="dark"]{--kraft:#1B1822;--kraft-fonce:#352F42;--case:#272232;--bristol:#2A2533;--bristol-pale:#443D52;--bristol-ombre:#0F0D0A;--action-ombre:#5E5470}
:root[data-couleur="rose"][data-theme="dark"]{--kraft:#201817;--kraft-fonce:#3E2E2B;--case:#2E2220;--bristol:#322725;--bristol-pale:#4D3C38;--bristol-ombre:#0F0D0A;--action-ombre:#6B544E}
/* Le choix, dans Paramètres › Révision et apparence */
.pc-couleurs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;margin:var(--espace-2) 0}
.pc-couleur{min-height:76px;display:flex;flex-direction:column;align-items:center;gap:6px;font-size:13.5px;cursor:pointer;position:relative}
.pc-couleur input{position:absolute;opacity:0;width:1px;height:1px}
.pc-pastille{width:44px;height:44px;border-radius:var(--rayon-rond);border:3px solid;box-sizing:border-box}
.pc-pastille[data-c="kraft"]{background:#E8DCC8;border-color:#BFA982}
.pc-pastille[data-c="ardoise"]{background:#DCE1E6;border-color:#A9B4BF}
.pc-pastille[data-c="sauge"]{background:#DCE5D5;border-color:#A8B99C}
.pc-pastille[data-c="lavande"]{background:#E4DFEC;border-color:#B6AACB}
.pc-pastille[data-c="rose"]{background:#EFDFDA;border-color:#CFA9A0}
.pc-couleur:has(input:checked){font-weight:700}
.pc-couleur:has(input:checked) .pc-pastille{box-shadow:0 0 0 3px var(--bristol),0 0 0 5px var(--graphite)}
.pc-couleur:has(input:focus-visible) .pc-pastille{outline:2px solid var(--focus);outline-offset:6px}

/* ---------- Pas de zoom aux doigts ni de double toucher (demande de Matthéo, 10/11) ; l'iPhone : js/appli.js ---------- */
html{touch-action:pan-x pan-y}

/* ---------- Connexion : bouton œil dans le champ du mot de passe ---------- */
.mdp-champ{position:relative}
.mdp-champ .saisie{padding-right:48px}
.mdp-oeil{position:absolute;top:0;right:0;bottom:0;width:44px;display:grid;place-items:center;background:none;border:0;color:var(--ink-soft)}
.mdp-oeil[aria-pressed="false"] .barre{display:none}

/* ---------- Annuler la dernière réponse d'une série (js/refonte.js) ---------- */
.pc-annuler{flex:none;min-height:44px;display:inline-flex;align-items:center;gap:6px;padding:0 14px 0 10px;border:0;border-radius:var(--rayon-rond);
  background:var(--bristol);box-shadow:var(--ombre-fiche);font:inherit;font-size:15px;font-weight:700;color:var(--graphite);cursor:pointer;-webkit-tap-highlight-color:transparent}
.pc-annuler[hidden]{display:none}
.pc-annuler:active{transform:translateY(1px);box-shadow:none}

/* ---------- « ⋯ » d'une série : modifier ou supprimer la question (js/refonte.js), feuille du bas de installation.css ---------- */
.pc-plus{flex:none;width:44px;height:44px;display:grid;place-items:center;padding:0;border:0;border-radius:var(--rayon-rond);
  background:var(--bristol);box-shadow:var(--ombre-fiche);color:var(--graphite);cursor:pointer;-webkit-tap-highlight-color:transparent}
.pc-plus[hidden]{display:none}
.pc-plus:active{transform:translateY(1px);box-shadow:none}
.pcq-enonce{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.pcq-action{display:flex;align-items:center;justify-content:center;gap:10px}
.btn.pcq-suppr{color:var(--correcteur)}
