/* ============================================================
   formatique.in — feuille de style
   Thème : cahier à carreaux Seyès (clair) / tableau noir (sombre)
   ============================================================ */

:root {
  --papier: #F9FAFC;
  --surface: #FFFFFF;
  --encre: #1C2B4B;
  --encre-douce: #56627C;
  --ligne: #E3EAF6;
  --ligne-forte: #C3D2EC;
  --marge: #D23B52;
  --classe: #2A63CC;
  --sur-classe: #FFFFFF;
  --ombre: 0 1px 0 rgba(28, 43, 75, .06), 0 6px 18px -10px rgba(28, 43, 75, .35);

  --f-titre: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-texte: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;

  --t-xs: .8125rem;
  --t-s: .9375rem;
  --t-m: 1.0625rem;
  --t-l: 1.3125rem;
  --t-xl: 1.75rem;
  --t-xxl: clamp(2rem, 1.4rem + 2.4vw, 2.75rem);

  --rayon: 10px;
  --colonne: 58rem;
}

/* Valeurs communes aux deux thèmes */
:root {
  color-scheme: light;
  --t-pct: 100%;
  --pastille-texte: #fff;
  --icone-lune: inline-block;
  --icone-soleil: none;
}

/* Sombre : automatique (réglage de l'appareil) tant que l'élève n'a pas choisi... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --papier: #1B2723;
    --surface: #223029;
    --encre: #ECEFE6;
    --encre-douce: #A7B3AA;
    --ligne: rgba(236, 239, 230, .05);
    --ligne-forte: rgba(236, 239, 230, .11);
    --marge: #E8808F;
    --ombre: 0 1px 0 rgba(0, 0, 0, .25), 0 8px 20px -12px rgba(0, 0, 0, .6);
    --t-pct: 55%;
    --pastille-texte: #1B2723;
    --icone-lune: none;
    --icone-soleil: inline-block;
  }
}
/* ... ou choisi avec le bouton soleil/lune */
:root[data-theme="dark"] {
  color-scheme: dark;
  --papier: #1B2723;
  --surface: #223029;
  --encre: #ECEFE6;
  --encre-douce: #A7B3AA;
  --ligne: rgba(236, 239, 230, .05);
  --ligne-forte: rgba(236, 239, 230, .11);
  --marge: #E8808F;
  --ombre: 0 1px 0 rgba(0, 0, 0, .25), 0 8px 20px -12px rgba(0, 0, 0, .6);
  --t-pct: 55%;
  --pastille-texte: #1B2723;
  --icone-lune: none;
  --icone-soleil: inline-block;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--f-texte);
  font-size: var(--t-m);
  line-height: 1.55;
}

a { color: inherit; }
img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 3px solid var(--classe);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.evitement {
  position: absolute; left: 1rem; top: -4rem; z-index: 50;
  background: var(--encre); color: var(--papier);
  padding: .6rem 1rem; border-radius: 6px;
}
.evitement:focus { top: 1rem; }

.ico { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em; }
.ico-grand { width: 2.25rem; height: 2.25rem; }

/* ---------- Le cahier Seyès ---------- */

.mode-feuille,
.bandeau {
  background-color: var(--papier);
  background-image:
    linear-gradient(var(--ligne-forte) 1px, transparent 1px),
    linear-gradient(var(--ligne) 1px, transparent 1px),
    linear-gradient(90deg, var(--ligne) 1px, transparent 1px);
  background-size: 100% 32px, 100% 8px, 32px 100%;
}

/* La marge rouge du cahier */
body, .mode-app .contenu { position: relative; }
.mode-feuille::before,
.mode-app .contenu::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: max(1.25rem, calc(50% - var(--colonne) / 2 - 2.5rem));
  width: 2px;
  background: var(--marge);
  opacity: .55;
  pointer-events: none;
}
.mode-feuille::before { left: max(1.25rem, calc(50% - 15.5rem)); }

/* ---------- Typographie ---------- */

h1, h2, h3, .logo, .marque-nom, .intercalaire-nom {
  font-family: var(--f-titre);
  font-optical-sizing: auto;
  line-height: 1.15;
  margin: 0;
}

.titre-page {
  font-size: var(--t-xxl);
  font-weight: 750;
  font-stretch: 85%;
  letter-spacing: -.01em;
  margin-bottom: 1.5rem;
}

.titre-bloc {
  font-size: var(--t-l);
  font-weight: 650;
  margin: 0 0 .5rem;
}

.intro { color: var(--encre-douce); max-width: 38rem; margin: -.75rem 0 1.5rem; }
.petit { font-size: var(--t-s); color: var(--encre-douce); }

/* ---------- Boutons ---------- */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 2.75rem;
  padding: .55rem 1.15rem;
  border: 1.5px solid var(--ligne-forte);
  border-radius: 999px;
  background: var(--surface);
  color: var(--encre);
  font: 600 var(--t-m)/1.2 var(--f-texte);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.bouton:hover { border-color: var(--encre-douce); }
.bouton:active { transform: translateY(1px); }

.bouton-plein {
  width: 100%;
  background: var(--encre);
  border-color: var(--encre);
  color: var(--papier);
}
.bouton-plein:hover { background: color-mix(in srgb, var(--encre) 85%, var(--classe)); border-color: transparent; }

.bouton-classe {
  background: var(--classe);
  border-color: var(--classe);
  color: var(--sur-classe);
}
.bouton-classe:hover { background: color-mix(in srgb, var(--classe) 82%, #000); border-color: transparent; }
.bouton[disabled] { opacity: .6; cursor: progress; }

/* ---------- Page de connexion (feuille) ---------- */

.mode-feuille .contenu {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 3rem 1.25rem 2rem 2.75rem;
}

.feuille { width: 100%; max-width: 26rem; }

.feuille-entete { margin-bottom: 2rem; }

.logo {
  font-size: clamp(2.5rem, 1.6rem + 4vw, 3.75rem);
  font-weight: 800;
  font-stretch: 78%;
  letter-spacing: -.025em;
  line-height: 1;
  color: var(--encre);
}

.feuille-sous {
  margin: .5rem 0 0;
  color: var(--encre-douce);
  font-size: var(--t-m);
}

.formulaire { display: grid; gap: .5rem; }
.formulaire > .bouton { margin-top: 1rem; }

.champ-titre {
  font-weight: 700;
  font-size: var(--t-s);
  margin-top: .5rem;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  min-height: 3rem;
  padding: .6rem .9rem;
  font: 400 var(--t-m)/1.3 var(--f-texte);
  color: var(--encre);
  background: var(--surface);
  border: 1.5px solid var(--ligne-forte);
  border-radius: 8px;
  transition: border-color .15s;
}
input:hover { border-color: var(--encre-douce); }
input:focus-visible { outline-offset: 0; border-color: var(--classe); }
input[aria-invalid="true"] { border-color: var(--marge); }

.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 3.25rem; font-size: 1.25rem; letter-spacing: .08em; }
.voir-mdp {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--encre-douce);
  cursor: pointer;
}
.voir-mdp:hover { color: var(--encre); }
.voir-mdp[aria-pressed="true"] { color: var(--classe); }

.alerte {
  margin: 0 0 .5rem;
  padding: .75rem 1rem;
  border-left: 4px solid var(--marge);
  background: color-mix(in srgb, var(--marge) 10%, var(--surface));
  border-radius: 0 8px 8px 0;
  font-size: var(--t-s);
}

.note {
  display: flex; gap: .6rem; align-items: flex-start;
  margin: 0 0 .5rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--ligne-forte);
  border-radius: 8px;
  font-size: var(--t-s);
}


/* ---------- Bandeau (pages connectées) ---------- */

.bandeau {
  border-bottom: 2px solid var(--encre);
  position: relative;
  z-index: 2;
}

.bandeau-int {
  max-width: calc(var(--colonne) + 4rem);
  margin: 0 auto;
  padding: .9rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
}

.marque { text-decoration: none; display: grid; margin-right: auto; }
.marque-nom {
  font-size: 1.75rem;
  font-weight: 800;
  font-stretch: 78%;
  letter-spacing: -.02em;
  line-height: 1;
}
.marque-sous { font-size: var(--t-xs); color: var(--encre-douce); margin-top: .2rem; }

.recherche, .filtre { position: relative; flex: 1 1 16rem; max-width: 24rem; }
.recherche .ico, .filtre .ico {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--encre-douce); pointer-events: none;
}
.recherche input, .filtre input { padding-left: 2.6rem; min-height: 2.75rem; }

.session { display: flex; align-items: center; gap: .75rem; }

.ecole {
  font: 700 var(--t-xs)/1 var(--f-texte);
  letter-spacing: .04em;
  padding: .4rem .6rem;
  border: 1.5px solid var(--encre);
  border-radius: 4px;
  background: var(--surface);
}

.quitter {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 2.75rem; padding: 0 .5rem;
  font-size: var(--t-s); font-weight: 600;
  text-decoration: none; color: var(--encre-douce);
  border-radius: 6px;
}
.quitter:hover { color: var(--marge); }

/* ---------- Mise en page ---------- */

.mode-app .contenu { flex: 1; }

.page {
  max-width: var(--colonne);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}
.page-etroite { max-width: 40rem; }

.bloc { margin-top: 3rem; }

/* Fil d'Ariane */
.ariane ol {
  list-style: none; margin: 0 0 .75rem; padding: 0;
  display: flex; flex-wrap: wrap; gap: .25rem;
  font-size: var(--t-s); color: var(--encre-douce);
}
.ariane li + li::before { content: "/"; margin: 0 .4rem 0 .15rem; opacity: .5; }
.ariane a { text-decoration: none; border-bottom: 1px solid var(--ligne-forte); }
.ariane a:hover { color: var(--encre); border-color: var(--encre); }
.ariane [aria-current] { color: var(--encre); font-weight: 600; }

/* ---------- Intercalaires (accueil) ---------- */

.intercalaires {
  list-style: none; margin: 2.5rem 0 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 2.75rem 1.25rem;
}

.intercalaire a {
  position: relative;
  display: flex; flex-direction: column; gap: .35rem;
  min-height: 9.5rem;
  padding: 1.4rem 1.4rem 1.25rem;
  background: var(--classe);
  color: var(--sur-classe);
  text-decoration: none;
  border-radius: 3px var(--rayon) var(--rayon) var(--rayon);
  box-shadow: var(--ombre);
  transition: transform .18s cubic-bezier(.3, .7, .4, 1.4);
}

/* L'onglet qui dépasse, décalé comme dans un vrai classeur */
.onglet {
  position: absolute;
  bottom: 100%;
  left: calc(.75rem + var(--decalage, 0) * 21%);
  width: 32%;
  height: 1.2rem;
  background: inherit;
  border-radius: 8px 8px 0 0;
}

.intercalaire a:hover { transform: translateY(-4px); }

.intercalaire-nom {
  font-size: var(--t-xl);
  font-weight: 750;
  font-stretch: 85%;
}
.intercalaire-info { font-size: var(--t-s); opacity: .92; margin-top: auto; }
.intercalaire .pastille { position: absolute; top: .9rem; right: .9rem; background: var(--surface); color: var(--marge); }

/* ---------- Listes de dossiers / fichiers ---------- */

.tete-dossier {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 1rem 1.5rem;
  margin-bottom: 1.75rem;
}
.tete-dossier .titre-page { margin: 0; }

.titre-classe {
  position: relative;
  padding-left: 1.1rem;
}
.titre-classe::before {
  content: "";
  position: absolute; left: 0; top: .12em; bottom: .12em;
  width: .4rem; border-radius: 3px;
  background: var(--classe);
}

.filtre { max-width: 22rem; margin-bottom: 1rem; }
.vide-filtre { color: var(--encre-douce); }

.dossiers, .fichiers {
  list-style: none; margin: 0; padding: 0;
  border-top: 1px solid var(--ligne-forte);
}
.dossiers + .fichiers { border-top: 0; }

.dossier, .fichier { border-bottom: 1px solid var(--ligne-forte); }

.dossier a {
  display: flex; align-items: center; gap: .9rem;
  min-height: 4rem;
  padding: .5rem .75rem;
  text-decoration: none;
  border-radius: 6px;
}
.dossier a:hover, .fichier-lien:hover { background: color-mix(in srgb, var(--classe) 7%, transparent); }
.ico-dossier { width: 1.75rem; height: 1.75rem; color: var(--classe); }
.dossier-nom { font-weight: 700; font-size: var(--t-m); }
.dossier .meta { margin-left: auto; }

.fichier { display: flex; align-items: center; gap: .25rem; }

.fichier-lien {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: .9rem;
  min-height: 4rem;
  padding: .5rem .75rem;
  text-decoration: none;
  border-radius: 6px;
}
.fichier-texte { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .6rem; }
.fichier-nom { font-weight: 600; overflow-wrap: anywhere; }
.fichier-lien:hover .fichier-nom { text-decoration: underline; text-underline-offset: 3px; }

.meta {
  flex-basis: 100%;
  display: flex; flex-wrap: wrap; gap: 0 .9rem;
  font-size: var(--t-xs); color: var(--encre-douce);
}
.dossier .meta { flex-basis: auto; }
.meta-chemin { color: var(--encre); font-weight: 600; }

/* Pastille type de fichier : un mini-document coloré */
.type {
  --t: #6B7280;
  flex: none;
  position: relative;
  width: 2.6rem; height: 3rem;
  display: grid; place-items: end center;
  padding-bottom: .4rem;
  background: color-mix(in srgb, var(--t) 13%, var(--surface));
  border: 1.5px solid color-mix(in srgb, var(--t) 45%, transparent);
  border-radius: 4px 11px 4px 4px;
  color: color-mix(in srgb, var(--t) var(--t-pct), #fff);
  font: 800 .72rem/1 var(--f-titre);
  font-stretch: 80%;
}
.type-pdf { --t: #C8323C; }
.type-texte { --t: #2B5CB8; }
.type-calc { --t: #1E7B45; }
.type-diapo { --t: #C2561B; }
.type-image { --t: #8C3FB8; }
.type-video { --t: #B8326E; }
.type-audio { --t: #1F8282; }
.type-archive { --t: #7A6A48; }
.type-code { --t: #3A4A6B; }
.type-brut { --t: #5A6478; }

.bouton-icone {
  flex: none;
  width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center;
  margin-right: .25rem;
  border-radius: 50%;
  color: var(--encre-douce);
}
.bouton-icone:hover { color: var(--classe); background: color-mix(in srgb, var(--classe) 10%, transparent); }

.pastille {
  display: inline-block;
  padding: .15rem .45rem;
  background: var(--marge);
  color: var(--pastille-texte);
  font: 700 .72rem/1.2 var(--f-texte);
  border-radius: 4px;
  transform: rotate(-2deg);
  white-space: nowrap;
}

/* ---------- États vides / erreurs ---------- */

.vide {
  padding: 2.5rem 0;
  max-width: 34rem;
}
.vide h2 { font-size: var(--t-l); margin-bottom: .4rem; }
.vide p { color: var(--encre-douce); margin: 0 0 1.25rem; }
.vide-page { margin: 0 auto; padding: 5rem 1.25rem; }
.mode-feuille .vide-page { padding: 0; }
.vide-code {
  font: 800 4.5rem/1 var(--f-titre); font-stretch: 75%;
  color: var(--marge) !important; margin: 0 0 .5rem !important;
}
.vide-page h1 { font-size: var(--t-xl); margin-bottom: .5rem; }

/* ---------- Dépôt de travaux ---------- */

.depot { margin-top: .5rem; }

.zone-depot {
  position: relative;
  display: block;
  border: 2px dashed color-mix(in srgb, var(--classe) 55%, var(--ligne-forte));
  border-radius: var(--rayon);
  background: var(--surface);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.zone-depot input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.zone-depot:hover, .zone-depot.survol { background: color-mix(in srgb, var(--classe) 7%, var(--surface)); border-color: var(--classe); }
.zone-depot:focus-within { outline: 3px solid var(--classe); outline-offset: 2px; }

.zone-vide {
  display: grid; justify-items: center; gap: .35rem;
  padding: 2rem 1rem;
  text-align: center;
}
.zone-vide .ico { color: var(--classe); }

.zone-choisi {
  display: flex; align-items: center; gap: .9rem;
  padding: 1rem 1.1rem;
}
.zone-choisi[hidden] { display: none; }
.zone-texte { flex: 1; min-width: 0; display: grid; }
.zone-changer { font-size: var(--t-s); font-weight: 600; color: var(--classe); text-decoration: underline; }

.progression { margin-top: .75rem; }
.progression-barre {
  height: .65rem; border-radius: 99px; overflow: hidden;
  background: var(--ligne);
  border: 1px solid var(--ligne-forte);
}
.progression-barre span {
  display: block; height: 100%; width: 0;
  background: var(--classe);
  transition: width .2s;
}

.aide { margin-top: 1rem; font-size: var(--t-s); color: var(--encre-douce); }
.aide summary { cursor: pointer; font-weight: 600; }
.aide p { margin: .5rem 0 0; }

.recu { text-align: left; }
.recu-coche {
  display: grid; place-items: center;
  width: 3.5rem; height: 3.5rem; margin-bottom: 1.25rem;
  border-radius: 50%;
  background: var(--classe); color: var(--sur-classe);
}
.recu-coche .ico { width: 1.9rem; height: 1.9rem; }
.recu .titre-page { margin-bottom: .5rem; }
.recu-details {
  margin: 1.5rem 0;
  border-top: 1px solid var(--ligne-forte);
}
.recu-details div {
  display: flex; gap: 1rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--ligne-forte);
}
.recu-details dt { width: 6rem; flex: none; color: var(--encre-douce); }
.recu-details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ---------- Bouton soleil / lune ---------- */

.theme {
  width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--encre-douce);
  cursor: pointer;
}
.theme:hover { color: var(--encre); background: color-mix(in srgb, var(--encre) 8%, transparent); }
.theme .ico { width: 1.35rem; height: 1.35rem; }
.theme .ico-lune { display: var(--icone-lune); }
.theme .ico-soleil { display: var(--icone-soleil); }
.theme-coin { position: absolute; top: .75rem; right: .75rem; z-index: 3; }

/* ---------- Pied de page ---------- */

.pied {
  padding: 1.5rem 1.25rem 1.75rem;
  text-align: center;
  font-size: var(--t-xs);
  color: var(--encre-douce);
}
.pied p { margin: 0; }
.pied a { text-underline-offset: 2px; }
.mode-feuille .pied { position: relative; }

/* ---------- L'araignée (1 chance sur 50) ---------- */

.araignee {
  position: fixed;
  top: 0; left: 0;
  width: 50px; height: 50px;
  background: url("/assets/img/araignee.png") center / contain no-repeat;
  z-index: 40;
  opacity: 0;
  transform: scale(0);
  transition: opacity .2s, transform .2s;
}

/* ---------- Petits écrans ---------- */

@media (max-width: 40rem) {
  .bandeau-int { gap: .75rem; }
  .recherche { order: 3; flex-basis: 100%; max-width: none; }
  .quitter span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .marque-sous { display: none; }
  .mode-app .contenu::before { display: none; }
  .page { padding-top: 1.75rem; }
  .intercalaires { grid-template-columns: 1fr; gap: 2.25rem; }
  .intercalaire a { min-height: 7rem; }
  .fichier-lien, .dossier a { gap: .7rem; padding-left: .25rem; padding-right: .25rem; }
  .tete-dossier .bouton { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .bandeau, .pied, .bouton-icone, .filtre, .araignee { display: none; }
  .mode-feuille, .bandeau { background: none; }
}
