/*
 * Cap Terminale - systeme de design.
 * Regle de rayons : conteneurs 14px, champs et boutons pilule (999px), cases 6px.
 * Un seul accent (bleu encre), un seul jeu de neutres, clair/sombre automatique.
 * Mouvement : feedback et transitions d etat uniquement, courbe
 * cubic-bezier(0.16, 1, 0.3, 1), jamais de proprietes de mise en page animees.
 */

:root {
  color-scheme: light dark;

  --sans: "SF Pro Display", "Geist", "Segoe UI Variable Display", "Segoe UI",
    system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;

  --courbe: cubic-bezier(0.16, 1, 0.3, 1);
  --rayon: 14px;
  --pilule: 999px;

  --fond: #fbfaf8;
  --surface: #fdfcfa;
  --surface-2: #f4f3ef;
  --texte: #16181d;
  --texte-2: #5f6570;
  --trait: #e7e5e0;
  --accent: #2c6e8f;
  --accent-fort: #245c79;
  --sur-accent: #fdfcfa;
  --erreur: #a3372f;
  --alerte-fond: #f8edeb;
  --ombre: 0 1px 2px rgba(22, 24, 29, 0.05), 0 12px 32px -18px rgba(22, 24, 29, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #131417;
    --surface: #1a1c20;
    --surface-2: #212429;
    --texte: #ecedef;
    --texte-2: #9ba1ab;
    --trait: #2b2e34;
    --accent: #6fa9c4;
    --accent-fort: #8cbed4;
    --sur-accent: #101418;
    --erreur: #d98076;
    --alerte-fond: #27201f;
    --ombre: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -22px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--fond);
  color: var(--texte);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }

p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
li { list-style: none; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s var(--courbe), color 0.25s var(--courbe);
}
a:hover { border-bottom-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------------------
   Boutons et champs
   --------------------------------------------------------------------------- */

.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 550;
  padding: 11px 20px;
  border-radius: var(--pilule);
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
  transition: transform 0.25s var(--courbe), background-color 0.25s var(--courbe),
    color 0.25s var(--courbe), border-color 0.25s var(--courbe), opacity 0.25s var(--courbe);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-principal {
  background: var(--accent);
  color: var(--sur-accent);
}
.btn-principal:hover:not(:disabled) { background: var(--accent-fort); }

.btn-secondaire {
  background: var(--surface-2);
  color: var(--texte);
  border-color: var(--trait);
}
.btn-secondaire:hover:not(:disabled) { border-color: var(--accent); }

.btn-fantome {
  background: transparent;
  color: var(--texte-2);
  border-color: var(--trait);
}
.btn-fantome:hover:not(:disabled) { color: var(--texte); border-color: var(--texte-2); }

.btn-discret {
  background: transparent;
  border: none;
  color: var(--texte-2);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: var(--pilule);
  cursor: pointer;
  font-family: var(--sans);
  transition: color 0.25s var(--courbe), background-color 0.25s var(--courbe),
    transform 0.25s var(--courbe);
}
.btn-discret:hover { color: var(--texte); background: var(--surface-2); }
.btn-discret:active { transform: scale(0.98); }

.btn-aide {
  background: transparent;
  border: 1px solid var(--trait);
  color: var(--accent);
  font-size: 13px;
  padding: 8px 16px;
  min-height: 38px;
}
.btn-aide:hover:not(:disabled) { border-color: var(--accent); }

.btn-fleche {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--pilule);
  border: 1px solid var(--trait);
  background: var(--surface);
  color: var(--texte);
  cursor: pointer;
  transition: transform 0.25s var(--courbe), border-color 0.25s var(--courbe),
    background-color 0.25s var(--courbe);
}
.btn-fleche:hover { border-color: var(--accent); }
.btn-fleche:active { transform: scale(0.96); }

.btn-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--pilule);
  border: none;
  background: transparent;
  color: var(--texte-2);
  cursor: pointer;
  transition: color 0.25s var(--courbe), background-color 0.25s var(--courbe),
    transform 0.25s var(--courbe);
}
.btn-icon:hover { color: var(--erreur); background: var(--alerte-fond); }
.btn-icon:active { transform: scale(0.96); }

.champ { display: flex; flex-direction: column; gap: 6px; }

.champ label {
  font-size: 13px;
  font-weight: 550;
  color: var(--texte-2);
}

.champ input {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--pilule);
  padding: 12px 18px;
  min-height: 44px;
  width: 100%;
  transition: border-color 0.25s var(--courbe), box-shadow 0.25s var(--courbe);
}
.champ input::placeholder { color: var(--texte-2); opacity: 0.75; }
.champ input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.champ.invisible label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.erreur {
  color: var(--erreur);
  font-size: 13.5px;
  background: var(--alerte-fond);
  border: 1px solid color-mix(in srgb, var(--erreur) 35%, transparent);
  border-radius: var(--rayon);
  padding: 10px 14px;
}

.vide {
  color: var(--texte-2);
  font-size: 14px;
  padding: 14px 0;
}

/* ---------------------------------------------------------------------------
   Ecrans d entree
   --------------------------------------------------------------------------- */

.ecran {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.carte-acces {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 36px 32px;
  animation: apparition 0.7s var(--courbe) both;
}

.logo, .logo-petit {
  color: var(--accent);
  display: inline-flex;
}

.carte-acces .logo { margin-bottom: 18px; }
.carte-acces h1 { margin-bottom: 4px; }
.sous-titre {
  color: var(--texte-2);
  font-size: 14px;
  margin-bottom: 26px !important;
}

.formulaire { display: flex; flex-direction: column; gap: 16px; }
.formulaire .btn { width: 100%; }

.note-securite {
  margin-top: 22px !important;
  font-size: 12.5px;
  color: var(--texte-2);
  border-top: 1px solid var(--trait);
  padding-top: 16px;
}

.question-2fa {
  font-size: 14.5px;
  font-weight: 550;
}

.case {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--texte-2);
  cursor: pointer;
  min-height: 40px;
  user-select: none;
}

.case input {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid var(--trait);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  flex: none;
  position: relative;
  transition: background-color 0.2s var(--courbe), border-color 0.2s var(--courbe);
}
.case input[type="radio"] { border-radius: var(--pilule); }

.case input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.case input:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2.5px;
  width: 5px;
  height: 10px;
  border: solid var(--sur-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.case input[type="radio"]:checked::after {
  left: 4.5px;
  top: 4.5px;
  width: 8px;
  height: 8px;
  border: none;
  border-radius: var(--pilule);
  background: var(--sur-accent);
  transform: none;
}
.case input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------------------
   Application : entete
   --------------------------------------------------------------------------- */

#application {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: apparition 0.5s var(--courbe) both;
}

.entete {
  border-bottom: 1px solid var(--trait);
  background: var(--surface);
}

.entete-haut {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.marque { display: flex; align-items: center; gap: 10px; }
.nom-marque { font-weight: 650; letter-spacing: -0.01em; font-size: 15.5px; }
.logo-petit { color: var(--accent); }

.actions-haut { display: flex; align-items: center; gap: 8px; }

.badge {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface-2);
  color: var(--texte-2);
  border-radius: var(--pilule);
  padding: 5px 11px;
}

.nav-jour {
  max-width: 960px;
  margin: 0 auto;
  padding: 6px 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.libelle-jour {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.date-jour {
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.015em;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.jour-semaine {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--texte-2);
}

.aujourdhui { flex: none; }

/* ---------------------------------------------------------------------------
   Application : contenu
   --------------------------------------------------------------------------- */

.contenu {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bandeau {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--texte);
  border-radius: var(--rayon);
  padding: 12px 16px;
  font-size: 13.5px;
}

.panneau {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 24px;
  box-shadow: var(--ombre);
}

.titre-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.compteur {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface-2);
  color: var(--texte);
  border-radius: var(--pilule);
  padding: 6px 13px;
}

.intitule-groupe {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--texte-2);
  margin-bottom: 4px !important;
}

.groupe + .groupe { margin-top: 18px; }

/* Cours */

.liste-cours { display: flex; flex-direction: column; }

.cours {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 11px 0;
  border-top: 1px solid var(--trait);
  font-size: 14px;
}
.cours:first-child { border-top: none; padding-top: 2px; }
.cours.annule .cours-matiere { text-decoration: line-through; color: var(--texte-2); }
.cours-horaire { font-family: var(--mono); font-size: 13px; color: var(--texte-2); }
.cours-matiere { font-weight: 550; }
.cours-meta { color: var(--texte-2); font-size: 13px; }

/* Taches */

.liste-taches { display: flex; flex-direction: column; }

.tache {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 15px 0;
  border-top: 1px solid var(--trait);
  transition: opacity 0.3s var(--courbe);
}
.tache:first-child { border-top: none; padding-top: 4px; }
.tache.est-faite .tache-titre { text-decoration: line-through; color: var(--texte-2); }
.tache.est-faite .tache-corps { opacity: 0.7; }

.case-jour { min-height: 40px; }

.tache-corps { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.tache-matiere {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}

.tache-titre {
  font-size: 14.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.tache-meta { font-size: 12.5px; color: var(--texte-2); }

.tache-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.case-fait.cache { visibility: hidden; }

.form-ajout { margin-top: 18px; }
.champ-ligne { flex-direction: row; gap: 10px; align-items: center; }
.champ-ligne input { flex: 1; min-width: 0; }

/* Reglages et organisation */

.reglages {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.champ-etroit { width: 132px; }
.reglages .btn { flex: none; }

.aide-texte {
  color: var(--texte-2);
  font-size: 13px;
  margin-top: 14px !important;
  max-width: 68ch;
}

.resultat-plan { margin-top: 18px; }

.plan-entete {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--texte-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px !important;
}

.plan-liste { display: flex; flex-direction: column; }

.plan-ligne {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px solid var(--trait);
}
.plan-ligne:first-child { border-top: none; }
.plan-horaire { font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.plan-titre { font-size: 14.5px; overflow-wrap: anywhere; }
.plan-meta { font-family: var(--mono); font-size: 12px; color: var(--texte-2); text-align: right; }

.plan-cours { background: var(--surface-2); border-radius: 10px; padding-left: 10px; padding-right: 10px; }
.plan-cours .plan-titre { color: var(--texte-2); font-weight: 550; }
.plan-cours + .plan-ligne { border-top: none; }

.plan-incertain .plan-meta { color: var(--accent); }

.plan-alerte {
  margin-top: 16px;
  background: var(--alerte-fond);
  border: 1px solid color-mix(in srgb, var(--erreur) 30%, transparent);
  border-radius: var(--rayon);
  padding: 14px 16px;
}
.plan-alerte-titre {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--erreur);
  margin-bottom: 6px !important;
}
.plan-alerte ul { display: flex; flex-direction: column; gap: 4px; }
.plan-alerte li { font-size: 13.5px; }

.plan-doux { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.plan-doux .plan-alerte-titre { color: var(--accent); }

.chargement {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--texte-2);
  font-size: 13.5px;
}
.squelette {
  width: 60px;
  height: 8px;
  border-radius: var(--pilule);
  background: linear-gradient(90deg, var(--surface-2), var(--trait), var(--surface-2));
  animation: pulsation 1.2s var(--courbe) infinite;
}

/* Liens */

.liste-liens { display: flex; flex-direction: column; }
.lien {
  padding: 11px 0;
  border-top: 1px solid var(--trait);
  font-size: 14.5px;
}
.lien:first-child { border-top: none; padding-top: 2px; }
.lien a { font-weight: 550; }
.lien-vide { color: var(--texte-2); }

.grille-liens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.rangee-boutons { display: flex; gap: 10px; flex-wrap: wrap; }

.pied {
  margin-top: auto;
  border-top: 1px solid var(--trait);
  padding: 18px 16px;
  text-align: center;
}
.pied p { font-size: 12.5px; color: var(--texte-2); }

/* ---------------------------------------------------------------------------
   Modale aide
   --------------------------------------------------------------------------- */

.modale { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }

.modale-fond {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 13, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fondu 0.3s var(--courbe) both;
}

.modale-carte {
  position: relative;
  width: min(640px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 22px 24px 26px;
  animation: montee 0.45s var(--courbe) both;
}

.modale-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  position: sticky;
  top: -22px;
  background: var(--surface);
  padding-top: 4px;
  z-index: 1;
}

.aide-section { border-top: 1px solid var(--trait); padding: 14px 0; }
.aide-section h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--texte-2);
  margin-bottom: 8px;
}
.aide-section p { font-size: 14.5px; }
.aide-section ul, .aide-section ol { display: flex; flex-direction: column; gap: 7px; }
.aide-section li { font-size: 14.5px; padding-left: 18px; position: relative; }
.aide-section ol { counter-reset: etapes; }
.aide-section ol li { counter-increment: etapes; padding-left: 26px; }
.aide-section ol li::before {
  content: counter(etapes) ".";
  position: absolute;
  left: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent);
}
.aide-section ul li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: var(--pilule);
  background: var(--trait);
}
/* (classe .aide-fiches retiree avec l'aide IA : ChatGPT s'ouvre en externe) */

/* ---------------------------------------------------------------------------
   Animations (desactivees si prefers-reduced-motion)
   --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .carte-acces { animation: apparition 0.7s var(--courbe) both; }
  #application { animation: apparition 0.5s var(--courbe) both; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

@keyframes apparition {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fondu {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes montee {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulsation {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---------------------------------------------------------------------------
   Complements au systeme
   --------------------------------------------------------------------------- */

.btn-aide {
  border-radius: var(--pilule);
  font-family: var(--sans);
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.25s var(--courbe), color 0.25s var(--courbe),
    transform 0.25s var(--courbe), opacity 0.25s var(--courbe);
}
.btn-aide:active:not(:disabled) { transform: scale(0.98); }
.btn-aide:disabled { opacity: 0.55; cursor: default; }

.cours-contenu {
  grid-column: 2 / -1;
  font-size: 13px;
  line-height: 1.5;
  color: var(--texte-2);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------
   Mobile
   --------------------------------------------------------------------------- */

@media (max-width: 767px) {
  .panneau { padding: 18px 16px; }

  .cours-contenu { grid-column: 1 / -1; }

  .tache {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .tache-actions { justify-content: flex-start; }
  .case-jour { min-height: 44px; }

  /* Cibles tactiles : 44px minimum sur telephone */
  .case { min-height: 44px; }
  .btn-discret { min-height: 44px; }
  .btn-aide { min-height: 44px; }
  .btn-icon { width: 44px; height: 44px; }

  .cours { grid-template-columns: 96px 1fr; }
  .cours-meta { grid-column: 2; }

  .plan-ligne { grid-template-columns: 104px 1fr; }
  .plan-meta { grid-column: 2; text-align: left; }

  /* Colonne unique stricte sous 768px */
  .reglages { display: flex; flex-direction: column; align-items: stretch; }
  .champ-etroit { width: auto; }
  .reglages .btn { width: 100%; }

  .champ-ligne { flex-direction: column; align-items: stretch; }
  .champ-ligne .btn { width: 100%; }

  .date-jour { font-size: 17px; }
  .aujourdhui { display: none; }
}
